Part Number:CC2652P
你好,我使用串口通讯时发现UART驱动会把0x00识别为结束位,请问要如何设置才能使它能成功识别0x00而不是作为结束位?
user4777655:
uartParams的dataMode设置为UART_DATA_BINARY
,
Weijin Yuan:
UART_init(); UART_Params_init(&gUartParams); gUartParams.baudRate = 115200; gUartParams.writeMode = UART_MODE_CALLBACK; gUartParams.writeDataMode = UART_DATA_BINARY; gUartParams.writeCallback = UartWriteCallback1; gUartParams.readMode = UART_MODE_CALLBACK; gUartParams.readDataMode = UART_DATA_BINARY; gUartParams.readCallback = UartReadCallback1; gUartHandle = UART_open(CONFIG_UART_0, &gUartParams); if (NULL != gUartHandle) { UART_read(gUartHandle, gUartRxBuffer, sizeof(gUartRxBuffer)); UART_control(gUartHandle, 32, NULL); }
已经设置了UART_DATA_BINARY
,
user4777655:
gUartRxBuffer大小没给够?正好在0x00塞满返回了?
,
Weijin Yuan:
应该是strncpy函数的问题,我直接移植了过来,没有注意到。谢谢了
,
Kevin Qiu1:
我将关闭此帖,如有其他问题,请重开一个新帖