ESP32 doesn't see all the data in UART rx buffer
Posted: Thu Nov 28, 2019 4:36 pm
I am using ESP32 WROOM to communicate with TI PGA460 chip via asynchronous UART2 (pins 16 17, 115200 8N2). The command transmission from ESP32 works fine, but the problem appears with the response data reception.
PGA460 responds with known number of bytes every time. ESP32 receives them all, but the reading functions (eg. Serial.read(), Serial.available(), ...) see a various number of received bytes in buffer (from 0 to all of the received) (randomly?). For example, PGA460 responds with 10 bytes, all of them are being received by ESP32, but when the reading function is called (serial.read inside while(serial.available) cycle), it recognizes (for example) 7 of them. (sometimes none of them)
It was noticed that if I send someting via Serial monitor (using Arduino IDE (UART connection with PC), the rest of the bytes are being found in the buffer (even if the UART2 connection with PGA460 was preliminary unpluged). What could be a reason of that and the possible solution ? (the same connection with other ESP32 works fine in both ways)
PGA460 responds with known number of bytes every time. ESP32 receives them all, but the reading functions (eg. Serial.read(), Serial.available(), ...) see a various number of received bytes in buffer (from 0 to all of the received) (randomly?). For example, PGA460 responds with 10 bytes, all of them are being received by ESP32, but when the reading function is called (serial.read inside while(serial.available) cycle), it recognizes (for example) 7 of them. (sometimes none of them)
It was noticed that if I send someting via Serial monitor (using Arduino IDE (UART connection with PC), the rest of the bytes are being found in the buffer (even if the UART2 connection with PGA460 was preliminary unpluged). What could be a reason of that and the possible solution ? (the same connection with other ESP32 works fine in both ways)