Skip to content
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

delay first serial write to allow host setup time #7041

Merged
merged 1 commit into from Oct 12, 2022

Conversation

dhalbert
Copy link
Collaborator

Fixes #6892 and other cases in which serial output (usually USB output) is fed back into the REPL input, as noted on Linux. (@bill88t take note.)

@jepler's diagnosis of this is that serial terminal programs on Linux first open the serial channel with "echo mode" on, in which serial output is echoed back to the serial input. They then immediately turn echo off with an ioctl(), but there is a race condition in which one or more characters may get echoed before the echo gets turned off.

This PR adds 50 ms of delay before the very first write after the serial channel (USB or console UART) is available. I also tested with 100ms, but 50ms seems to be enough.

@jepler Could you test this on the nRF52840, which exhibits this problem even without the status bar? I could not reproduce it on my end, but on the other hand you had more trouble reproducing the status bar problem. Thanks.

@hathach this appears to be what we were trying to understand late last night (for you).

@dhalbert dhalbert requested a review from jepler October 12, 2022 00:35
@bill88t
Copy link

bill88t commented Oct 12, 2022

Tested on picow and waveshare_esp32s2_pico. This issue seems fixed.
Yes, I did make sure to disable my workarounds.

@dhalbert
Copy link
Collaborator Author

dhalbert commented Oct 12, 2022

@bill88t Great! Thanks for testing.

Copy link
Member

@jepler jepler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a solid workaround to a vexing bug. Tested on CPB.

@jepler jepler merged commit e3688b4 into adafruit:main Oct 12, 2022
@dhalbert dhalbert deleted the serial-first-write-delay branch October 12, 2022 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CircuitPython 8.X title-set ansi code sometimes ends up in stdin
3 participants