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)
ESP32 doesn't see all the data in UART rx buffer
ESP32 doesn't see all the data in UART rx buffer
Last edited by Alexix on Mon Dec 02, 2019 11:18 pm, edited 1 time in total.
Re: ESP32 doesn't see all the data in UART rx buffer
UPD:
Attached the example of received bytes from UART buffer.
All the shown bytes were sent to ESP32 as a single pack of data. --END-- line represents the point, where Serial2.available / Serial2.read think the Rx buffer is now empty. After interracting with Serial port (UART with PC) (for example sending something via serial monitor of Arduino IDE), ESP32 detects the rest of the received bytes.
The tested code is provided below.
Attached the example of received bytes from UART buffer.
All the shown bytes were sent to ESP32 as a single pack of data. --END-- line represents the point, where Serial2.available / Serial2.read think the Rx buffer is now empty. After interracting with Serial port (UART with PC) (for example sending something via serial monitor of Arduino IDE), ESP32 detects the rest of the received bytes.
The tested code is provided below.
Code: Select all
void setup()
{
Serial.begin(115200);
Serial2.begin(115200, SERIAL_8N2);
}
void loop()
{
while (Serial2.available()>0)
{
Serial.println(Serial2.read(), HEX);
i=1;
delay(10);
}
if (i==1)
{
Serial.println("--END--");
Serial.println(" ");
i=0;
}
delay(100);
}
- Attachments
-
- sdf.png (16.98 KiB) Viewed 6841 times
Re: ESP32 doesn't see all the data in UART rx buffer
HI,
Have you find a solution for your probleme and could you send me a example code has you send to this module bceause I don't find serial commande manuel for this ship ?
Sincerely
Eric
Have you find a solution for your probleme and could you send me a example code has you send to this module bceause I don't find serial commande manuel for this ship ?
Sincerely
Eric
Who is online
Users browsing this forum: No registered users and 89 guests