When I was doing usart data sent to the TCP encountered a problem

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable
Hello
           When I was doing usart data sent to the TCP encountered a problem:
           Somewhile ,when I  through the usart send “abcdefg”  to the BCM943362WCD4 , It can receive the data ”abc”. But it lost the data “defg”. And I send “abcdefg” to the BCM943362WCD4 again, It receive the data ”defgabcdefg”.Why is this?
            My English is not good, I hope you can understand ^_^ thx.

    while(1){

        while (wiced_uart_receive_bytes( WICED_UART_1, &c, 1, 1 )==WICED_SUCCESS )

        {

            rxbuf[rxcount++]=c;

            readflag=true;

        }

        if(readflag==true)

        {

            wiced_tcp_send_buffer( &tcp_client_socket,rxbuf,rxcount);

            wiced_uart_transmit_bytes( WICED_UART_1,rxbuf,rxcount);

            memset(rxbuf,0,rxcount);

            rxcount=0;

            readflag=false;

        }         

}

0 Likes
1 Solution
Anonymous
Not applicable

Are you using ring buffer? One thing that catches my attention here is wiced_uart_receive_bytes() only waits for 1 millisecond. Try changing that to WICED_NEVER_TIMEOUT.

View solution in original post

0 Likes
3 Replies
Anonymous
Not applicable

Are you using ring buffer? One thing that catches my attention here is wiced_uart_receive_bytes() only waits for 1 millisecond. Try changing that to WICED_NEVER_TIMEOUT.

0 Likes
Anonymous
Not applicable

Yes,I am using the ring buffer.

I changed the WICED_NEVER_TIMEOUT=5 millisecond,it perfect to accept.

Thank you very much.^_^

0 Likes
Anonymous
Not applicable

Did you mean that you changed the timeout_ms argument from 1 to 5?

Please do not change the default definition of WICED_NEVER_TIMEOUT.

0 Likes