8 Replies Latest reply on Mar 2, 2017 9:30 PM by axel.lin_1746341

    llSDK 3.7 Uart Timeout & Number of Bytes to Receive Problem

    riforifo

      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);

          }

      }