-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Possible regression of serial communication performance since version 2.x #7505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hello @awawa-dev, thanks for the issue. I'm tagging @SuGlider who did bunch of improvements to Serial recently. |
@awawa-dev - Please turn on Log messages (Core Debug Level: "Verbose") in the Arduino IDE. Change your void setup()
{
Serial.setRxBufferSize(MAX_BUFFER); // before begin()
Serial.begin(COM_SPEED);
Serial.setTimeout(50);
Serial.write("Hello tester!");
}
|
For 900, the solution is to replace uint16_t internalIndex = min(Serial.available(), MAX_BUFFER);
if (internalIndex > 0)
{
lastDataTime = millis();
// internalIndex = Serial.readBytes(buffer, internalIndex);
internalIndex = Serial.read(buffer, internalIndex);
}
else if (lastDataTime + 1000 < millis())
{
Serial.println(framesReceived);
lastDataTime = millis();
framesReceived = 0;
state = TestProtocol::HEADER_A;
} |
Anyway, it doesn't work well with 1800. Let me analyze it further. |
Thank you for your time and effort. I can confirm that it works for 1200 bytes frames now with usually no errors. Then it gets worse quickly if the frame is only slightly bigger. |
@awawa-dev |
Great! I will test it right away. |
@SuGlider Great job 😄 I've tested your PR not only using test sketch but also my main project: I confirm everything works now perfectly. Hope this PR will be merged soon. And that along with the changes you recommended here will finally allow me to upgrade my ESP32 LED driver to Arduino ESP32 ver. 2. Because of that performance issue, it was on hold for almost a year (I'm aware that it could be difficult to detect due specific serial chip capability and large frame/speed transmission configuration) |
Excellent! |
Added new change to override |
Thank you for the update. Just for your information, as I just received the ESP2-S2 mini lolin: it seems that the problem described here does not apply to this board, possibly due to the integrated onboard USB-UART instead of the external one. |
Yes, but in that case the ESP32-S2 mini lolin uses USB CDC instead of UART. Therefore, it doesn't use |
Is there any preprocessor |
Yes, it is in the source files:
|
For the ESp32-S2 mini lolin, it is set by default in the Board menu and setup in the https://github.com/espressif/arduino-esp32/blob/master/boards.txt#L5583 |
Thank you very much. Now I can handle all the cases for the different board variants I have. |
Bug espressif/arduino-esp32#7505 that affected non-CDC devices is finally fixed.
Board
ESP32 dev module
Device Description
Board capable of 2Mb serial speed (CH9102x)
Hardware Configuration
nothing is connected
Version
v2.0.5
IDE Name
Arduino IDE, PlatformIO
Operating System
Windows, Linux
Flash frequency
default
PSRAM enabled
no
Upload speed
default
Description
As of version 2.x I observe possible performance regression compared to version 1.x when high-speed communication is used (2 000 000 baud). We verify the integrity of the frame data to make sure the frame is complete and undamaged.
Simplified sketch and python test client provided as an attachment. 'Esp32 dev module' with CH9102x
With version 1.0.6 was working fine.

Sending 900 bytes frames without any problem to ESP32 board. The reception is confirmed.
Since version 2.x the same sketch does not work anymore, which was first reported by our users and then confirmed by us after testing. We are unable to maintain such communication, all 900 byte frames are damaged or incomplete:
None of 900 byte frames is receive undamaged and completed.
It starts to work for ~600 byte frame but with high error rate:
client_and_sketch.zip
Sketch
Test client and sketch provided as an attachment in the description section.
Debug Message
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: