Understanding UART receive buffering
Posted: Mon Nov 14, 2022 8:45 pm
Hi,
I'm receiving a 262 282 byte data packet (sent in one piece) on an ESP32 (2400 baud, 8N1) like so:
Data is received in chunks of 120, 120 and 42 bytes.
I understand that the ESP32 has a hardware receive buffer and that an interrupt is triggered when 120 bytes have been received (or after a timeout). What I don't understand is the purpose of the internal RxRingBuffer which is initialized to 256 bytes (or 512 above). Is there a way to actually use this buffer?
I'm receiving a 262 282 byte data packet (sent in one piece) on an ESP32 (2400 baud, 8N1) like so:
Code: Select all
void setup()
{
Serial.begin(115200);
Serial2.setRxBufferSize(512);
Serial2.begin(2400);
}
void loop()
{
uint8_t buffer[512];
size_t bytesRead;
while(!Serial2.available());
bytesRead = Serial2.read(buffer, sizeof(buffer));
Serial.printf("\nBytes received: %u\n", bytesRead);
}
I understand that the ESP32 has a hardware receive buffer and that an interrupt is triggered when 120 bytes have been received (or after a timeout). What I don't understand is the purpose of the internal RxRingBuffer which is initialized to 256 bytes (or 512 above). Is there a way to actually use this buffer?