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

Allow serial "break" to trigger KeyboardInterrupt #7227

Merged
merged 2 commits into from
Nov 19, 2022

Conversation

jepler
Copy link
Member

@jepler jepler commented Nov 18, 2022

When the USB serial buffer is full, the Ctrl-C code to send KeyboardInterrupt can't be sent, which creates a problem if you've pasted code or otherwise filled the buffer and need to recover. A similar problem affects advanced UIs that interact with CircuitPython and may send characters when they're unexpected, such as mu when it tries to move the cursor based on the user clicking on the screen.

The main way forward seems to be to use some kind of message that can still reach CircuitPython when its internal serial recieve buffer is full. RS232 defines a "break" signal, in which the transmitting device holds its data line in the "space" state for many entire character times. This still exists in the world of USB serial.

This does work, sort of, except that your host computer software will need to properly handle blocking serial writes; tio can send a break with the ctrl-c b sequence, but this only works if it hasn't yet written too much data, so it doesn't actually help in most situations :-/

When the USB serial buffer is full, the Ctrl-C code to send
KeyboardInterrupt can't be sent, which creates a problem if you've
pasted code or otherwise filled the buffer and need to recover.
A similar problem affects advanced UIs that interact with CircuitPython
and may send characters when they're unexpected, such as mu when it
tries to move the cursor based on the user clicking on the screen.

The main way forward seems to be to use some kind of message that can
still reach CircuitPython when its internal serial recieve buffer is full.
RS232 defines a "break" signal, in which the transmitting device holds its
data line in the "space" state for many entire character times. This still
exists in the world of USB serial.

This does work, sort of, except that your host computer software will need
to properly handle blocking serial writes; tio can send a break with
the **ctrl-c b** sequence, but this only works if it hasn't yet written
too much data, so it doesn't actually help in most situations :-/
Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

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

Tested with a QT Py ESP32-S2, running a while True: loop, and also waiting to open a WiFi connection. In both cases, ctrl-t b in tio caused a KeyboardInterrupt. I didn't encounter any problems using tio in this way. Thanks!

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.

None yet

2 participants