This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

UART serial input too long, causes crashes

Hi,

Setting the scene:

I have several sensors that are decoded via an external device that outputs UART serial data (115200 baud rate).

The data looks like this:
Received string: 1,1177,1,1175,2,0,20,119,136

This can be received fine by my UART RTT code running on the nordic 52840-dk.

However if I add another sensor it does not read the string at all and the board becomes locked.

The new string is : (Note is was tested via arduino serial)

1,1177,1,1175,1,1150,2,0,20,119,136

So my question is why when the string gets longer does it cause the code to stop working?

My RTT setup code is below for reference:

Thanks

  //Set up the RTT
    const app_uart_comm_params_t comm_params =
      {
          RX_PIN_NUMBER,
          TX_PIN_NUMBER,
          RTS_PIN_NUMBER,
          CTS_PIN_NUMBER,
          UART_HWFC,
          false,
#if defined (UART_PRESENT)
          NRF_UART_BAUDRATE_115200
#else
          NRF_UARTE_BAUDRATE_115200
#endif
      };
    APP_UART_FIFO_INIT(&comm_params,
                         UART_RX_BUF_SIZE,
                         UART_TX_BUF_SIZE,
                         uart_error_handle,
                         APP_IRQ_PRIORITY_LOWEST,
                         err_code);

    APP_ERROR_CHECK(err_code);

To read the data I use app_uart_get(&c) where c is a uint8_t.

This is the relevant header code:

#define MAX_TEST_DATA_BYTES     (32U)                /**< max number of test bytes to be used for tx and rx. */
#define UART_TX_BUF_SIZE 1024                         /**< UART TX buffer size. */
#define UART_RX_BUF_SIZE 1024                         /**< UART RX buffer size. */
#define UART_HWFC APP_UART_FLOW_CONTROL_DISABLED // APP_UART_FLOW_CONTROL_ENABLED / APP_UART_FLOW_CONTROL_DISABLED

  • Hi Thomas

    I'm not sure exactly what MAX_TEST_DATA_BYTES is used for in your example, but the working string is less than 32 bytes in length, while the non-working string is 35 bytes long, so perhaps this define has something to do with it?

    Otherwise I am not sure why a slightly longer string would lead to such issues. 

    As a side note I would recommend using the nrf_libuarte driver for UART rather than the app_uart_fifo driver, as it is more well tested and robust. 

    Best regards
    Torbjørn

Related