
Description
Hardware:
Board: ESP32-S2 Saola 1R Dev Kit featuring ESP32-S2 WROVER
Core Installation version: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json
IDE name: Arduino IDE 1.8.15
Flash Frequency: 80Mhz
PSRAM enabled: no
Upload Speed: 921600
Computer OS: Windows 7 x64
Description:
When using the "USB CDC On Boot = Enabled" Serial port, it will lose incoming characters (received by the ESP32-S2) unless the PC slows down the sent data by using smaller writes with delays between each write. The example sketch below sets the receive buffer to 2K, however even if I only write 1024 bytes in one Windows API call to WriteFile() I will often only see ~800 bytes arrive.
The sketch runs a tight loop reading and throwing away characters, but it keeps a count. Once there is a delay of 2 seconds when the incoming data stops, it reports how many characters it saw. Of course, this is a bare minimum sketch, which shows the larger problem I'm having in my project.
To try the sketch, configure the USB-COM port for the device to be COM1 (single digit COM ports can be used from the command line) and open the device from PuTTY. Type a few characters, wait a couple of seconds, it will report back how many characters were typed.
The device is now primed (DTR & RTS has been configured by PuTTY) where you can close PuTTY but get it ready to open again (have the PuTTY config window open and ready to connect)... In a DOS console (command prompt), type "copy my1024b.bin \b com1" (the file needs to be created beforehand and should have 1024 bytes in it)... Once it says "1 file(s) copied.", quickly press the Open button in PuTTY and it will tell you how many characters it got.
Sketch:
static int c = 0;
static unsigned long tm;
static char buf [260];
void setup () {
delay (2500);
Serial.begin (921600);
Serial.setRxBufferSize (2048);
}
void loop () {
if (Serial.available ()) {
Serial.read ();
c++;
tm = micros ();
}
if ((c) && (micros () - tm >= 2000000)) { // 2s
sprintf (buf, "%05d\n", c);
Serial.write (buf);
c = 0;
}
}
Debug Messages:
00825