工具/软件:
我正在使用高级数据包格式进行数据发送和接收、但我可以发送的最大数据长度仅为 255 个字节。 根据手册、数据长度不应受限制。 您能告诉我我我的配置是否有问题吗? 配置和用法如下:
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.
工具/软件:
我正在使用高级数据包格式进行数据发送和接收、但我可以发送的最大数据长度仅为 255 个字节。 根据手册、数据长度不应受限制。 您能告诉我我我的配置是否有问题吗? 配置和用法如下:
packet_tx 代码如下所示:
不确定您使用的 PHY(400bps??) 由于 SLR PHY 中的数据速率为 2.5kbps 或 5kbps(它们有一个固定的同步字(不是 0xFE6B2840) ):
https://www.ti.com/lit/swra642
假设您使用我们的某个 SLR PHY、则可以使用以下代码来传输长度字节为 2 个字节而不是 1 的数据包:
TX:
/***** Includes *****/
/* Standard C Libraries */
#include <stdlib.h>
#include <unistd.h>
/* TI Drivers */
#include <ti/drivers/rf/RF.h>
#include <ti/drivers/GPIO.h>
/* Driverlib Header files */
#include DeviceFamily_constructPath(driverlib/rf_prop_mailbox.h)
/* Board Header files */
#include "ti_drivers_config.h"
#include <ti_radio_config.h>
/***** Defines *****/
// Packet TX Configuration
#define SIZE_OF_LENGHT_FIELD 2
#define PAYLOAD_LENGTH 400
#define PACKET_INTERVAL 500000 // Set packet interval to 500000 us or 500 ms
static RF_Object rfObject;
static RF_Handle rfHandle;
static uint8_t packet[SIZE_OF_LENGHT_FIELD + PAYLOAD_LENGTH];
static uint16_t seqNumber;
void *mainThread(void *arg0)
{
RF_Params rfParams;
RF_Params_init(&rfParams);
GPIO_setConfig(CONFIG_GPIO_GLED, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
GPIO_write(CONFIG_GPIO_GLED, CONFIG_GPIO_LED_OFF);
RF_cmdPropTxAdv.pktLen = PAYLOAD_LENGTH + SIZE_OF_LENGHT_FIELD;
RF_cmdPropTxAdv.pPkt = packet;
RF_cmdPropTxAdv.startTrigger.triggerType = TRIG_NOW;
RF_cmdPropTxAdv.condition.rule = 1;
RF_cmdPropTxAdv.pktConf.bUseCrc = 1;
// Request access to the radio
rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
// Set the frequency
RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
while(1)
{
packet[0] = (uint8_t)(PAYLOAD_LENGTH);
packet[1] = (uint8_t)(PAYLOAD_LENGTH >> 8);
for (uint16_t i = 2; i < PAYLOAD_LENGTH + SIZE_OF_LENGHT_FIELD; i++)
{
packet[i] = i - 1;
}
// Send packet
RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTxAdv, RF_PriorityNormal, NULL, 0);
GPIO_toggle(CONFIG_GPIO_GLED);
// Power down the radio
RF_yield(rfHandle);
// Sleep for PACKET_INTERVAL us
usleep(PACKET_INTERVAL);
}
}
接收:
/***** Includes *****/
/* Standard C Libraries */
#include <stdlib.h>
/* TI Drivers */
#include <ti/drivers/rf/RF.h>
#include <ti/drivers/GPIO.h>
/* Driverlib Header files */
#include DeviceFamily_constructPath(driverlib/rf_prop_mailbox.h)
/* Board Header files */
#include "ti_drivers_config.h"
/* Application Header files */
#include "RFQueue.h"
#include <ti_radio_config.h>
/***** Defines *****/
#define DATA_ENTRY_HEADER_SIZE 8 // Constant header size of a Generic Data Entry
#define NUM_DATA_ENTRIES 2 // NOTE: Only two data entries supported at the moment
#define SIZE_OF_LENGHT_FIELD 2
// Optional appended bytes at the end of the packet
// -------------------------------------------------------
// | CRC1 | CRC0 | RSSI | TS0 | TS1 | TS2 | TS3 | Status |
// -------------------------------------------------------
#define CRC 0 // 2 if .rxConf.bIncludeCrc = 0x1, 0 otherwise
#define RSSI 0 // 1 if .rxConf.bAppendRssi = 0x1, 0 otherwise
#define TIMESTAMP 0 // 4 if .rxConf.bAppendTimestamp = 0x1, 0 otherwise
#define STATUS 0 // 1 if .rxConf.bAppendStatus = 0x1, 0 otherwise
#define NUM_APPENDED_BYTES SIZE_OF_LENGHT_FIELD + CRC + RSSI + TIMESTAMP + STATUS
#define MAX_LENGTH 400 // Max length byte the radio will accept
static void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e);
static RF_Object rfObject;
static RF_Handle rfHandle;
/* Buffer which contains all Data Entries for receiving data.
* Pragmas are needed to make sure this buffer is 4 byte aligned (requirement from the RF Core) */
static uint8_t rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
MAX_LENGTH,
NUM_APPENDED_BYTES)]
__attribute__((aligned(4)));
// Receive dataQueue for RF Core to fill in data
dataQueue_t dataQueue;
rfc_dataEntryGeneral_t* currentDataEntry;
uint16_t packetLength;
uint8_t* packetDataPointer;
rfc_propRxOutput_t rxStatistics;
uint8_t packet[MAX_LENGTH + NUM_APPENDED_BYTES - SIZE_OF_LENGHT_FIELD]; // Length is stored separately
void *mainThread(void *arg0)
{
RF_Params rfParams;
RF_Params_init(&rfParams);
GPIO_setConfig(CONFIG_GPIO_RLED, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
GPIO_write(CONFIG_GPIO_RLED, CONFIG_GPIO_LED_OFF);
if( RFQueue_defineQueue(&dataQueue,
rxDataEntryBuffer,
sizeof(rxDataEntryBuffer),
NUM_DATA_ENTRIES,
MAX_LENGTH + NUM_APPENDED_BYTES))
{
// Failed to allocate space for all data entries
while(1);
}
// Modify CMD_PROP_RX command for application needs
// Set the Data Entity queue for received data
RF_cmdPropRxAdv.pQueue = &dataQueue;
// Discard ignored packets from Rx queue
RF_cmdPropRxAdv.rxConf.bAutoFlushIgnored = 1;
// Discard packets with CRC error from Rx queue
RF_cmdPropRxAdv.rxConf.bAutoFlushCrcErr = 1;
// Implement packet length filtering to avoid PROP_ERROR_RXBUF
RF_cmdPropRxAdv.maxPktLen = MAX_LENGTH;
RF_cmdPropRxAdv.pktConf.bRepeatOk = 1;
RF_cmdPropRxAdv.pktConf.bRepeatNok = 1;
RF_cmdPropRxAdv.pOutput = (uint8_t*)&rxStatistics;
RF_cmdPropRxAdv.condition.rule = 1;
RF_cmdPropRxAdv.pktConf.bUseCrc = 0x1;
RF_cmdPropRxAdv.rxConf.bIncludeHdr = 0x1;
RF_cmdPropRxAdv.endTrigger.triggerType = 0x1;
RF_cmdPropRxAdv.pktConf.bCrcIncHdr = 0x1;
RF_cmdPropRxAdv.hdrConf.numHdrBits = 16;
RF_cmdPropRxAdv.hdrConf.numLenBits = 16;
// Optional bytes to append:
RF_cmdPropRxAdv.rxConf.bIncludeCrc = 0x0;
RF_cmdPropRxAdv.rxConf.bAppendRssi = 0x0;
RF_cmdPropRxAdv.rxConf.bAppendTimestamp = 0x0;
RF_cmdPropRxAdv.rxConf.bAppendStatus = 0x0;
// Request access to the radio
rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
// Set the frequency
RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropRxAdv, RF_PriorityNormal, &callback, RF_EventRxEntryDone);
while(1);
}
void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
{
if (e & RF_EventRxEntryDone)
{
// Toggle pin to indicate RX
GPIO_toggle(CONFIG_GPIO_RLED);
// Get current unhandled data entry
currentDataEntry = RFQueue_getDataEntry();
packetLength = ((uint16_t)((*(uint8_t*)(¤tDataEntry->data+1)) << 8) | (uint16_t)(*(uint8_t*)(¤tDataEntry->data)));
packetDataPointer = (uint8_t*)(¤tDataEntry->data + SIZE_OF_LENGHT_FIELD);
// Copy the payload and the status bytes to the packet variable
memcpy(packet, packetDataPointer, (packetLength + NUM_APPENDED_BYTES - SIZE_OF_LENGHT_FIELD));
RFQueue_nextEntry();
}
}
代码经过测试、可按预期运行。
Siri
首先、如果您使用 SLR 模式、则无法更改同步字(请参阅)
其次、即使您有 2 个可用的长度字节、调制解调器中的内部限制将此限制为 8191 字节(包括标头和 CRC)。
发送非常长的数据包通常是一个不好的主意、因为“数据包错误率“会随着数据包长度的增加而增加。
Siri
嗨、Siri
我们使用 “0000:未编码的二进制调制“的 fecMode、是否可以修改同步字? 如何根据“CC13xx 远距离模式“模式 1 设置 64 位同步字?
此致。
应用手册中说明了 LRM 的建议运行限值、我提到过几次 (https://www.ti.com/lit/swra642)
Siri