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.

CC2652R7: UART data logging issue

Part Number: CC2652R7

Hi team,

we are trying to log uart data by using putty terminal in that we are facing some data logging format issue while saving in text file but in putty terminal data format is correct

I have attached  the UART configuration and screen capture of putty terminal and text file (data format issue) for you reference. Please help us regarding this

/********************uart code*******************************/

UART_Handle uart;
UART_Params uartParams;
UART_init();
UART_Params_init(&uartParams);
uartParams.writeDataMode = UART_DATA_BINARY;//UART_DATA_BINARY;
uartParams.readDataMode = UART_DATA_BINARY;
uartParams.baudRate = 9600;
uartParams.dataLength = UART_LEN_8;
uartParams.readEcho = UART_ECHO_OFF;

uart = UART_open(CONFIG_UART_0, &uartParams);

if (uart == NULL) {

while (1);
}

We have initialized buffers as below

unsigned char recBuf[2005]; 

char buffer[80];

/*logic to write data to UART*/

for(i=5,j=0;i<2005;i++,j++)
{
sprintf(buffer,"%x",recBuf[i]);
UART_write(uart,&buffer, sizeof(buffer));

}

=~=~=~=~=~=~=~=~=~=~=~= PuTTY log 2022.04.12 18:38:52 =~=~=~=~=~=~=~=~=~=~=~=
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

  • Hi santhosh,

    As currently written, each UART_write will write 80 bytes to UART which may not be your intent based on your sprintf usage.  Perhaps you should use a specific buffer value, like buffer[i], to accomplish your needs.  Also keep in mind that %x is the format specifier for lower-case hex code whereas UART_write will perform a verbatim data write which will be translated by the terminal into its ASCII representation.  Furthermore, sprintf and UART_write are both performing writes to the UART buffer which may not be what you desire for the application to be doing.  Given these considerations I think it would be best for you to further reference the available examples and step debug through your code to get a better understanding for how UART communication is designed.  Also please note that UART Driver is being deprecated and replaced by UART2 during the second quarter of 2022.

    Regards,
    Ryan