Uart receive with timeout


#1

Hello,

I have modified snip.uart example like below. Basically I want to UART receive with timeout and check the number of incoming bytes. I have 2 questions

  1. UART RECEIVE does not work when I set the timeout anything other than WICED_NEVER_TIMOUT
  2. When timeout is set to WICED_NEVER_TIMEOUT, expected Data Size always return as 0

can you please tell me what I am missing?

void application_start( )
{
    char c[8];
    uint32_t expected_data_size = 2;

    wiced_gpio_init(USER_LED, OUTPUT_PUSH_PULL);
    /* Initialise ring buffer */
    ring_buffer_init(&rx_buffer, rx_data, RX_BUFFER_SIZE );


    /* Initialise UART. A ring buffer is used to hold received characters */
    //wiced_uart_init( STDIO_UART, &uart_config, &rx_buffer );
    wiced_uart_init( STDIO_UART, &uart_config, NULL );


    /* Send a test string to the terminal */
    wiced_uart_transmit_bytes( STDIO_UART, TEST_STR, sizeof( TEST_STR ) - 1 );

    /* Wait for user input. If received, echo it back to the terminal */

    //while ( wiced_uart_receive_bytes( STDIO_UART, &c, &expected_data_size, WICED_NEVER_TIMEOUT ) == WICED_SUCCESS )
    while ( wiced_uart_receive_bytes( STDIO_UART, c, &expected_data_size, 10) == WICED_SUCCESS )
    {
        snprintf(c,3,"%x\n",expected_data_size); 
        wiced_uart_transmit_bytes( STDIO_UART, c, 8 );
        expected_data_size = 2;
        memset(c, 0, 8);
    }
}

#2

Hello,

I have also written this to Wiced forum and a pal there said that this was a bug in the WICED API. I’ll update here when I get more info about this.

In the meantime, I simply had to start a thread to read in a blocking way.

best
rifo


#3

Much appreciate for sharing the experience. :smile:


#4

What is the solution for this?
Any modifications needs to be done?
I am also facing the same issue.


#5

I switched to a blocking uart function call. But this was with wiced sdk 3.7.
Cypress has now moved to wiced sdk 5.0. This issue may have been fixed there.

Which SDK are you using?