工具与软件:
您好、先生、
当我以1秒的轮询间隔通过 Modbus 轮询 CC2651R3器件的配置时、它正常工作。 但是、当我尝试使用相同的 Modbus 轮询配置(间隔为1秒)通过射频通信轮询不同的 CC2651R3器件时、它无法正常工作。 有趣的是、如果我将轮询间隔增加到2秒、则通信正常工作。 什么原因可能导致该问题?
此致、
Reshmi。
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.
您好、Alex、
我以 rfUARTBridge 的示例代码 为例、 请在下面找到无线电代码
void * mainThread (void * arg0){
packetRxCb = no_packet;
rf_Params rfParams;
rf_params_init (&rfParams);
if (RFQueue_defineQueue (&dataQueue、
rxDataEntryBuffer、
sizeof (rxDataEntryBuffer)、
NUM_DATA_ENTRIES、
max_length + NUM_APPLATED_BYTES)
{
/*无法为所有数据条目分配空间*/
while (1);
}
/*修改设置以便能够执行 RX*/
/*为接收到的数据设置数据实体队列*/
RF_cmdPropRx.pQueue =&dataQueue;
/*丢弃 Rx 队列中忽略的数据包*/
rf_cmdPropRx.rxConf.bAutoFlushIgnored = 1;
/*从 Rx 队列中丢弃有 CRC 错误的数据包*/
rf_cmdPropRx.rxConf.bAutoFlushCrcErr = 1;
/*实施数据包长度过滤以避免 PROP_ERROR_RXBUF */
RF_cmdPropRx.maxPktLen = MAX_LENGTH;
RF_cmdPropRx.pktConf.bRepeatOk = 1;
RF_cmdPropRx.pktConf.bRepeatNok = 1;
rf_cmdPropTx.pPKt =数据包;
RF_cmdPropTx.startTriggerType = trig_now;
/*请求访问对讲机*/
rfHandle = rf_open (&rfObject、&rf_prop、(RF_RadioSetup*)&RF_cmdPropRadioDivSetup、&R rfParams);
/*设置频率*/
RF_postCmd (rfHandle、(RF_Op*)&RF_cmdfs、RF_PriorityNormal、NULL、0);
rfPostHandle = RF_postCmd (rfHandle、(RF_Op*)&RF_cmdPropRx、RF_PriorityNormal、&ReceivedOnRFcallback、RF_EventRxEntryDone);
while (1){
//我的应用程序代码
}
}
void ReceivedOnRFcallback (RF_Handle h、RF_CmdHandle ch、RF_EventMask e)
{
if (e & RF_EventRxEntryDone)
{
/*获取当前未处理的数据条目*/
currentDataEntry = RFQueue_getDataEntry ();//从条目加载数据
/*处理 数据、位于¤tDataEntry->data:
*-长度是当前配置的第一个字节
*-数据从第二个字节开始*/
长度 =*(uint8_t*)(¤tDataEntry->data);//获取 长度(使用发送)
DataPointer =(uint8_t*)(¤tDataEntry->data + 1);//data 从第二个字节开始
/*将有效负载+状态字节复制到 变量*/
memcpy (testbuff、DataPointer、(长度+ 1));
totalBytes =长度;
/*将读取条目指针移动到下一个条目*/
RFQueue_nextEntry();
RXCb = packet_received;
}
}
谢谢!
Reshmi。
您好、Reshmi:
您的代码还在 rfPostHandle 行后包含如下代码行正确吗?
while(1)
{
/* Check if anything has been received via RF*/
if(packetRxCb)
{
memcpy(input, packet, (packetLength));
size_t bytesWritten = 0;
while (bytesWritten == 0)
{
status = UART2_write(uart, &input, packetLength, &bytesWritten);
if (status != UART2_STATUS_SUCCESS)
{
/* UART2_write() failed */
while (1);
}
}
/* Reset RF RX callback flag */
packetRxCb = NO_PACKET;
}
/* Check if anything has been received via UART*/
if (bytesReadCount != 0)
{
/*The packet length is set to the number of
* bytes read by UART2_read() */
RF_cmdPropTx.pktLen = bytesReadCount;
int i;
for (i=0; i<bytesReadCount; i++)
{
uint8_t* buffer8 = (uint8_t*) input;
packet[i] = buffer8[i];
}
/*Cancel the ongoing command*/
RF_cancelCmd(rfHandle, rfPostHandle, 1);
/*Send packet*/
RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTx, RF_PriorityNormal, NULL, 0);
/* Toggle green led to indicate TX */
GPIO_toggle(CONFIG_GPIO_GLED);
/* Resume RF RX */
rfPostHandle = RF_postCmd(rfHandle, (RF_Op*)&RF_cmdPropRx,
RF_PriorityNormal, &ReceivedOnRFcallback,
RF_EventRxEntryDone);
bytesReadCount = 0;
/* Resume UART read */
status = UART2_read(uart, &input, bytesToRead, NULL);
}
}
}
谢谢!
Alex F