sys/usb_cdc_acm_stdio: only submit and flush for non-empty buffer #20986
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Contribution description
There seems to be some problem the implementation of stdio over usbus_cdc_acm where printing an empty string sometimes leads to the next character being missed in the printout. I've managed to pin the problem down to the call to
usbus_cdc_acm_flush(&cdcacm);
insys/usb/usbus/cdc/acm/cdc_acm_stdio.c
and, more specifically, to_ep_xmit
incpu/nrf5x_common/periph/usbdev.c
, but since I have no non-nRF hardware at hand, I cannot tell whether it is a nRF specific issue.In any case, skipping the flushing (and submitting) in the first place seems to fix the issue for now. If anyone has an idea how to investigate this further and maybe fix the root cause somewhere deeper in the usb driver, please tell me, I'm happy to test more.
Testing procedure
stdio_cdc_acm
such asfeather-nrf52840-sense
make -C tests/sys/usbus_cdc_acm_stdio BOARD=feather-nrf52840-sense flash term
text 0
On
master
, this sometimes skips over thex
in the printout. With this PR, I never managed to reproduce the issue.Issues/PRs references
Found while investigating failing tests for #20980