-
Notifications
You must be signed in to change notification settings - Fork 984
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
USB CDC Serial loses data when sending too quickly #2243
Comments
Hi @ondras12345 for (uint32_t i = 0; i < 5000U; i++)
{
Serial.printf("%u: testing... abcdefghijklmnopqrstuvwxyz\r\n", i);
+ Serial.flush();
} |
That you for you input. I cannot believe It didn't occur to me to try Is there a way to fix the problem while still letting CDC use all of its output queue? I believe calling |
You can try to flush only %5 message or something like this. |
Why does calling Arduino_Core_STM32/cores/arduino/USBSerial.cpp Lines 152 to 157 in 2c45eba
write: Arduino_Core_STM32/cores/arduino/USBSerial.cpp Lines 67 to 90 in 2c45eba
I think calling |
The queue management was added by a contributor several years ago, unfortunately after several update of the USB Device middleware, it was hard to backport this implementation due to major rework of the library.
|
Describe the bug
Text
print
ed to USB CDCSerial
is received with several lines / packets missing if there is no delay between prints.To Reproduce
Build this:
Export compiled binary in Arduino IDE.
Upload using ST-Link V2:
Steps to reproduce the behavior:
minicom -D /dev/ttyACM0
t
to run the test. Observe incomplete messages. Rerun test multiple times if no incomplete messages occur, they seem to be rare on some PCs.Observed behavior
Data is missing in the middle:
Or at the end:
The likelihood of triggering the bug seems to depend on which computer I do my testing with. With two laptops (one Linux, one Windows), it occurs multiple times in each test. On another one, it is much more rare, but still should definitely occur within say 50 runs of the test.
Expected behavior
Text printed to Serial should be received by PC without error.
Desktop:
st-flash
, see aboveBoard:
Additional context
Here are some things I tried:
while(!Serial)
before printing "done" does not seem to ensure it gets printed.usb
/tty
-related errors are shown indmesg
.The text was updated successfully, but these errors were encountered: