- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I have a problem with the source code bellow in SDK 3.4.0. When UART 2 receives a data of 1 byte, the thread calling never stops. I do not if the problem comes from the RTOS or UART lib. However, this source code is working fine in SDK 3.1.2.
Thank you for your help
void application_start(void)
{
wiced_init( );
ring_buffer_init(&rx_buffer, rx_data, RX_BUFFER_SIZE );
wiced_uart_init( WICED_UART_2, &uart_config, &rx_buffer );
wiced_rtos_create_thread( &uart_thread, WICED_DEFAULT_WORKER_PRIORITY, "UART_RX", uart_thread_main, UART_THREAD_STACKSIZE, NULL );
}
void uart_thread_main()
{
char read_data;
uint32_t expected_data_size = 1;
while ( wiced_uart_receive_bytes( WICED_UART_2, &read_data, &expected_data_size, WICED_NEVER_TIMEOUT ) == WICED_SUCCESS )
{
WPRINT_APP_INFO( ( "Thread called. Data : %c", read_data ) );
}
WICED_END_OF_CURRENT_THREAD( );
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
The problem was resolved in SDK 3.5.1. "expected_data_size = 1" at the end of the while loop is mandatory.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
The platform used is the BCM943362WCD4
BR,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I could not replicate the problem the BCM943362WCD4 and WICED 3.4.0 AWS Ready SDK.
Please can you try with 3.4.0 AWS Ready SDK.
Best Ready,
Ab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Was the problem fixed by trying the AWS release? I'm seeing the same behavior, my UART code in 3.1.2 is working like a charm, but on the new SDK it goes into a loop constant receiving the same value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
The problem was resolved in SDK 3.5.1. "expected_data_size = 1" at the end of the while loop is mandatory.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Why? Does that mean wiced_uart_receive_bytes() can return WICED_SUCCESS with
expected_data_size != 1?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Since the length is passed to the function as a pointer, it uses the value stored in the memory location. So the value only works one time.
in platform_uart_receive_bytes it has this line:
*expected_data_size -= transfer_size;
where the expected_data_size is the pointer to the value passes by the user/developer. Maybe a local copy of the value was better, so that the length value does not need to be reset, but again using this method i think it would be possible to determine how many bytes was actually received if the receive function fails.
So when the function returns the length value will be 0, and if it is not reset before making a new receive call, it will never go into the while loop where is actually receives on the UART. Instead it jumps to the end and returns the result value which is set to PLATFORM_SUCCESS at the start. So you could argue that the handling of a 0 length is not properly implemented.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, resetting the length variable fixed my issue. Thanks alot