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:可帮助了解 UART 中的部分返回模式

Guru**** 2347060 points
Other Parts Discussed in Thread: CC1310
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/sub-1-ghz-group/sub-1-ghz/f/sub-1-ghz-forum/1493306/cc1310-helps-to-understand-the-partial-return-mode-in-uart

器件型号:CC1310

工具与软件:

在论坛上做了一些阅读后,我发现了它的功能
uart_echo_on、uart_data_text、uart_readPolling ()、uart_writePolling ()与 CC1310 UART 驱动程序不兼容。

我的问题是:我将一个 CC1310通过 UART 连接到一个传感器、当它执行成功的发送操作时响应"+OK"、当接收传感器响应数据时、它会发送至 CC1310、如"+RCV=3、5、hello、-13、23"。 我已经确定在 CC1310中、我在 RX 引脚中会有一个这样的字符串:"+OK+RCV=3、5、hello、-13、23"。 最后一个字符串告诉我、传感器成功发送了数据并接收了包含有用数据的响应。

我使用该函数编写了以下程序
UART_CONTROL (UART、UARTCC26XX_CMD_RETURN_PARTIAL_ENABLE、NULL);
在第一个实例中、我注意到当部分返回被激活时、我得到对应于"+OK"的5个字节、在未连接目标传感器的情况下正常。
当部分返回值检测到"+OK"时、它是否会完成读取字符串?

如何继续读取其余有用数据?
"+OK\r\n+RCV=3,5,hello,-13,23.
我可以想到在回调中调用 uart_read 并存储在一个新的缓冲区中。
这种方法是否正确?

提前感谢。


char buffer01[]="AT+SEND=5,4,CMD1\r\n";

static void Task_RF(UArg arg0, UArg arg1){
uartLoRa_Init();



while(1){

   

if(motionFlag){

switch(status){

       case Send_CMD01:{

       UART_write(uart,buffer01, strlen(buffer01));
       usleep(500000);

       Noc.status = RX_CMD01;
       break;
}

case RX_CMD01:{

    UART_control(uart, UARTCC26XX_CMD_RETURN_PARTIAL_ENABLE, NULL);


    UART_read(uart, &data,5);
    usleep(100000);


     break;
}
	}
		}
			}	
			
static void RXUartCb(UART_Handle handle, void *buf, size_t count){


    if(count == 5){

    UART_control(uart, UARTCC26XX_CMD_RETURN_PARTIAL_DISABLE, NULL);
    UART_read(uart, &data2,21);

    }
    
    if(data2[0]== '+' && data2[1]== 'R' &&data2[2]== 'C' &&data2[3]== 'V'){
    	  //Here I will process the useful data

	}
	else{
		//I will return to the initial state Send_CMD01

	}
    

			

void uart_Init(void){

     UART_init();
     UART_Params   uartParams;
     UART_Params_init(&uartParams);
     uartParams.writeDataMode = UART_DATA_BINARY;
     uartParams.readDataMode  = UART_DATA_BINARY;
     uartParams.readMode = UART_MODE_CALLBACK;
     uartParams.writeMode = UART_MODE_CALLBACK;
     uartParams.readCallback = RXUartCb;
     uartParams.writeCallback = TXUartCb;
     uartParams.baudRate = 115200;
     uart = UART_open(Board_UART0, &uartParams);


}