Timestamp 如何知道疯狂谎言之间信息传输的时间?

Timestamp 如何知道疯狂谎言之间信息传输的时间?,timestamp,stm32,transmission,nrf51,crazyflie,Timestamp,Stm32,Transmission,Nrf51,Crazyflie,我需要你的帮助。我正在与Crazyflies(stm32和nrf51)合作。下面是crazyflies之间的消息传输代码,我想知道crazyflies和丢失的数据包之间的消息传输时间。什么都可以帮我 #include <string.h> #include <stdint.h> #include <stdbool.h> #include <stdio.h> #include "app.h" #include "Fr

我需要你的帮助。我正在与Crazyflies(stm32和nrf51)合作。下面是crazyflies之间的消息传输代码,我想知道crazyflies和丢失的数据包之间的消息传输时间。什么都可以帮我

#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>

#include "app.h"

#include "FreeRTOS.h"
#include "task.h"

#include "radiolink.h"
#include "configblock.h"

#define DEBUG_MODULE "P2P"
#include "debug.h"

#define MESSAGE "hello world"
#define MESSAGE_LENGHT 11


void p2pcallbackHandler(P2PPacket *p)
{
  // Parse the data from the other crazyflie and print it
  uint8_t other_id = p->data[0];
  static char msg[MESSAGE_LENGHT + 1];
  memcpy(&msg, &p->data[1], sizeof(char)*MESSAGE_LENGHT);
  msg[MESSAGE_LENGHT] = 0;
  uint8_t rssi = p->rssi;

  DEBUG_PRINT("[RSSI: -%d dBm] Message from CF nr. %d, %s\n", rssi, other_id, msg);
}

void appMain()
{
  DEBUG_PRINT("Waiting for activation ...\n");

    // Initialize the p2p packet 
    static P2PPacket p_reply;
    p_reply.port=0x00;
    
    // Get the current address of the crazyflie and obtain
    //   the last two digits and send it as the first byte
    //   of the payload
    uint64_t address = configblockGetRadioAddress();
    uint8_t my_id =(uint8_t)((address) & 0x00000000ff);
    p_reply.data[0]=my_id;

    //Put a string in the payload
    char *str="Hello World";
    memcpy(&p_reply.data[1], str, sizeof(char)*MESSAGE_LENGHT);

    // Set the size, which is the amount of bytes the payload with ID and the string 
    p_reply.size=sizeof(char)*MESSAGE_LENGHT+1;

    // Register the callback function so that the CF can receive packets as well.
    p2pRegisterCB(p2pcallbackHandler);

  while(1) {
    // Send a message every 2 seconds
    //   Note: if they are sending at the exact same time, there will be message collisions, 
    //    however since they are sending every 2 seconds, and they are not started up at the same
    //    time and their internal clocks are different, there is not really something to worry about

    vTaskDelay(M2T(2000));
    radiolinkSendP2PPacketBroadcast(&p_reply);
   }
}
#包括
#包括
#包括
#包括
#包括“app.h”
#包括“FreeRTOS.h”
#包括“task.h”
#包括“radiolink.h”
#包括“configblock.h”
#定义调试模块“P2P”
#包括“debug.h”
#定义消息“hello world”
#定义消息长度11
无效p2pcallbackHandler(P2PPacket*p)
{
//解析来自另一个crazyflie的数据并打印它
uint8_t other_id=p->data[0];
静态字符消息[消息长度+1];
memcpy(&msg,&p->data[1],大小(字符)*消息长度);
消息[消息长度]=0;
uint8_t rssi=p->rssi;
调试打印(“[RSSI:-%d dBm]消息,来自CF编号%d,%s\n”,RSSI,其他id,msg);
}
void appMain()
{
调试打印(“等待激活…\n”);
//初始化p2p数据包
静态P2PPacket p_应答;
p_reply.port=0x00;
//获取crazyflie的当前地址并获取
//最后两位数字,并将其作为第一个字节发送
//有效载荷的计算
uint64_t address=configblockGetRadioAddress();
uint8\u t我的id=(uint8\u t)((地址)和0x00000000ff);
p_reply.data[0]=我的_id;
//在有效载荷中放一根绳子
char*str=“你好,世界”;
memcpy(&p_reply.data[1],str,sizeof(char)*消息长度);
//设置大小,即ID为的有效负载和字符串的字节数
p_reply.size=sizeof(char)*消息长度+1;
//注册回调函数,以便CF也可以接收数据包。
p2pRegisterCB(p2pcallbackHandler);
而(1){
//每2秒发送一条消息
//注意:如果它们在同一时间发送,则会发生消息冲突,
//但是,由于它们每2秒发送一次,并且不会同时启动
//时间和它们的内部时钟是不同的,没有什么好担心的
vTaskDelay(M2T(2000));
RadioInkSendP2ppackeBroadcast(p_回复);
}
}

多谢各位

p2pcallbackHandler是中断回调吗?然后,您可以从RTC创建一个时间戳(如果有)。微控制器上没有自动生成的时间戳。