Hello,
I am writing a code on an Olimex ESP32 Gateway that sends a command to a board and receives data from the board through rs485 with a baudrate of 115200 * 100.
The data received is about 3 kB foreach command. After sending the command, the code delays 3.5ms (enough for the whole 3kB arrive). And then I read with uart_read_bytes() with a timeout of 0 in smaller chunks (250 bytes). I have set the TOUT feature enabled with a tout of 19.
The problem is that in some random transmissions I read some random number of bytes less than the expected. I connected a logic analyzer on the receive GPIO pins and all the data expected is transmitted over the wire. Also I check the number of bytes in the input buffer after the delay (with uart_get_buffered_data_len()) and in the bad transmissions the number of bytes in the buffer is less than the expected.
I tried to increment the delay and the same happens. If I decrement, increment or disable the TOUT, the number bad transmissions is higher.
Do somebody have an idea of what is happening here?
Thanks.
UART read losing bytes
-
- Posts: 94
- Joined: Tue Sep 07, 2021 12:07 pm
Re: UART read losing bytes
- if that means 11,520,000, which would be about 1MByte per second, that's a really high baud rate. My quick research on RS485 says the flow control is not done with RTS/CTS, but uses software (xon/xoff?). I'd guess there is an occasional buffer overrun, causing dropped characters. I didn't see anyone suggesting >5,000,000 would work, and even those came with caveats.115200 * 100
- I think that means the current problem is NOT in the code you wrote to read the buffer.in the bad transmissions the number of bytes in the buffer is less than the expected
Craige
Who is online
Users browsing this forum: No registered users and 421 guests