how many bytes are read with uart_read_bytes()
Posted: Sat Dec 05, 2020 7:22 pm
Hello everyone,
I'm working on a project that uses uart to receives lots of data(~45KB), the data is initialized with SOT and ended with EOT.
So in order to read the data I wait for the starting SOT and then I increment a buffer pointer accordingly to the data comming through.(I don't receive all the data at once, the sender uses 512 Bytes chunks).
To increment my pointer buffer I check how many bytes are available using: and if I still have space in my buffer I call
What is weird is that once in a while the buffer overflow even though I'm constantly checking if there is still space in it, so this makes me think that maybe uart_read_bytes() is returning more bytes then I thought it was going to. Does that makes sense? uart_read_bytes() shouldn't only read the number of bytes I pass as parameter?
I'm working on a project that uses uart to receives lots of data(~45KB), the data is initialized with SOT and ended with EOT.
So in order to read the data I wait for the starting SOT and then I increment a buffer pointer accordingly to the data comming through.(I don't receive all the data at once, the sender uses 512 Bytes chunks).
To increment my pointer buffer I check how many bytes are available using:
Code: Select all
uart_get_buffered_data_len(uart_num, &length);
Code: Select all
length = uart_read_bytes(uart_num, buffer+length2, length, 0);