This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC1310 如何用RF发送不同长度的数据

Hi ,我打算将串口接收的指令通过RF透传出去,指令不同所以字节长度不同,请问射频该怎么动态的发送不同长度的数据呢?我想的是在任务中根据具体指令,把要发送的数据的长度填充给RF_cmdPropTxAdv.pktLen参数,这样想对吗?

  • 可以看下用户手册中关于 unlimited or unknown packet length的实现: www.ti.com.cn/.../swcu117h.pdf
  • Hi Viki,先说我这个想法可行吗?另外手册这方面我也看了理解的差不多,有没有这方面的代码可参考?
  • 可行,可以用 CMD_PROP_TX_ADV 实现,参考下类似问题: e2e.ti.com/.../509837
  • 发送无限长数据要pktLen = 0,接收无限长数据要maxPktLen =0对吗?
    如果用这种方式,接收队列有代码可参数还好说,发送队列的创建也好说,但是发送队列如何填充数据呢?我想的是先创建一个普通数组放我的数据,在发送队列中,第一个字节数据 *(uint8_t *)(&(currentDataEntry->data)) = packetLength;然后memcpy 剩余数据,最后执行发送命令,请指点一下方法,说完这个问题就解决了。。。
  • 直接使用变长模式发送就可以了。
    可以阅读Technical Reference Mannual的23.7.1 Packet Formats和23.7.2.1.1 Command Structures详细了解。
    还可以参考SDK中的rfPacketTx例程,就是使用的变长模式。
  • 你意思是靠payload中的长度字节来控制吗?我试了一下可以,好像必须动态修改RF_cmdPropTxAdv.pktLen,让它们关系稳定。但我感觉这种方式有点麻烦且不太放心,你看看我上面的那个表达,给个定心丸吧大哥。。。
  • 就是通过pktLen来设置每一包数据的长度,就是这样操作的,没问题。

    The transmit operations contain a buffer with the data to be transmitted. The number of bytes in this buffer
    is given by pktLen. For the CMD_PROP_TX command, the length given in pktLen is transmitted as the
    first byte if pktConf.bVarLen is 1, and then followed by the contents of the transmit buffer.

     

  • 恩是的,但是我用的TX_Adv命令且是WOR例程下的收发切换,高级数据包格式,这个貌似不太合适,发送队列用过吗?
  • TX_ADV也有pktLen设置的。

  • 恩,我想让pktLen = 0,用队列方式发送,该怎么办?对于接收人家有RF_cmdPropRx.pQueue = &dataQueue;这个参数,对于发送如何把发送队列与RF关联起来呢?我研究了一下没有思路。。。
  • pktLen = 0 是使用unlimited length模式。

    按照你的描述,你的应用中,不同数据包的长度不同,但是每种数据包的长度是知道的,因此没有必要用unlimited length模式。可以直接将pktConf.bVarLen设置为1, a length byte equal to the value of pktLen is sent next. 操作更简单方便。

    RF_cmdPropRx.pQueue = &dataQueue 是配置将接收到的数据放入dataQueue队列。

    如果一定要类比,TX端对应的语句是RF_cmdPropTx.pPkt = packet;

  • 你说的对,我发现在高级数据包格式中光靠pktLen控制长度不管事,在WOR例程中,要发送的第一个字节还必须是长度,这是啥原因,手册里的格式一直没看懂,请给解释一下吧。。
  • 以下是使用TX_ADV命令,变长模式发送数据包的代码段,供参考

    static void txTaskFunction(UArg arg0, UArg arg1)
    {
    uint32_t curtime;
    RF_Params rfParams;
    RF_Params_init(&rfParams);

    RF_cmdPropTxAdv.pktLen = PAYLOAD_LENGTH;
    RF_cmdPropTxAdv.pPkt = packet;
    RF_cmdPropTxAdv.startTrigger.triggerType = TRIG_ABSTIME;
    RF_cmdPropTxAdv.startTrigger.pastTrig = 1;
    RF_cmdPropTxAdv.startTime = 0;

    /* Request access to the radio */
    rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioSetup, &rfParams);

    /* Set the frequency */
    RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);

    /* Get current time */
    curtime = RF_getCurrentTime();
    while(1)
    {
    /* Create packet with random payload */
    uint8_t i;
    for (i = 0; i < PAYLOAD_LENGTH; i++)
    {
    packet[i] = rand();
    }

    /* Set absolute TX time to utilize automatic power management */
    curtime += PACKET_INTERVAL;
    RF_cmdPropTxAdv.startTime = curtime;

    /* Send packet */
    RF_EventMask result = RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTxAdv, RF_PriorityNormal, NULL, 0);
    if (!(result & RF_EventLastCmdDone))
    {
    /* Error */
    while(1);
    }

    PIN_setOutputValue(pinHandle, Board_PIN_LED1,!PIN_getOutputValue(Board_PIN_LED1));
    }
    }
  • 我理解了你这个方法,但是这个方法用了后就不通信了,在高级数据包格式下我必须让packet[0] = 负载长度;才能正常通信,这让我有点怀疑人生,强调一下我用的WOR例程。。
  • 因为WOR接收程序中的RF_cmdPropRxSniff是copy的RF_cmdPropRx命令的配置,而RF_cmdPropRx是配置成的变长模式,即接收端会将接收到的第一个字节判定为length字段。

    For the CMD_PROP_TX command, the length given in pktLen is transmitted as the first byte if pktConf.bVarLen is 1, and then followed by the contents of the transmit buffer.

    而在使用CMD_PROP_TX_ADV时,不会自动像CMD_PROP_TX将RF_cmdPropTxAdv.pktLen字段自动添加到发送缓存中,需要手动添加到发送缓存中,因此packet[0]要配置成payload的长度,否则接收端会将packet[0]的内容认为是包长,从而导致CRC验证不通过。

    If a length field is to be transmitted using CMD_PROP_TX_ADV, it must be given explicitly from the system side as part of the header.

    你可以在WOR_RX代码中把下面这个参数设置为0,代码就可以跑进rx的callback了。
    RF_cmdPropRxSniff.rxConf.bAutoFlushCrcErr = 0;
    这时,你可以看到RF_cmdPropRxSniff命令的status是0x3406,表示PROP_DONE_RXERR,Operation ended after receiving packet with CRC error。
  • 完美,结帖了
x 出现错误。请重试或与管理员联系。