Description
Basic Infos
Hardware
Hardware: ESP8266 module
Core Version: 2.4.0
Description
I am running the hardware serial at 74880 baud. Each byte of serial data is 9 bits (8 bits of data and 1 stop bit). This means the fastest I should be able to receive 128 bytes of data is 15 milliseconds. I have logs showing checking Serial.available changes from 0 bytes to 128 bytes in 5ms. So it seems the available function isn't getting updated as often as new bytes of data are arriving.
I took a look at the code and got confused so I'm hoping someone with knowledge of how hardware serial works on esp8266 can help me. It looks like in ESP8266 2.1.0 you switched from the standard interrupt based serial approach to using a hardware buffer that is 128 bytes.
Reading through the serial documentation (http://esp8266.github.io/Arduino/versions/2.3.0/doc/reference.html) it seems you have 128 byte FIFO buffer shared for RX and TX. Then you have an additional 256 bytes for TX and 256 bytes for RX. So this means depending on your combination of RX and TX data the max RX data you might receive before starting to drop bytes is 384, but it is also possible that it could start dropping bytes after 256 if you fill the hardware FIFO with TX data. Is my understanding correct?
While I am not seeing any data dropped, I worried about delays in getting the RX data and I want a way to detect when the buffer overflows. Can someone explain to me when Serial.available() actually is notified that there is data? Would it be reasonable to manually go get the data out of the hardware FIFO during Serial.available() to prevent extra latency and prevent confusion like I'm having?
Also there is no query to see how big the serial buffer is, right? In my code I'm trying to detect if that buffer ever overflows. Previously I thought that limit was 128 bytes, but now I'm not sure what to set it to. I guess the safe value is 256 unless my understanding above is incorrect and then it would be 384. Do I have a better option for detecting RX serial buffer overflow?