diff options
| author | Damien George <damien@micropython.org> | 2024-10-10 16:38:39 +1100 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2024-10-15 11:40:08 +1100 |
| commit | d92694c3e80c369a22d92b65d875e2d27dc47eaf (patch) | |
| tree | c3dee101ff4ba79102ba73844f2fa7bd4d94ab46 | |
| parent | 7746785035f7003e33f9b101c8bbb4d7a74f216f (diff) | |
tools: Only issue a single Ctrl-C when entering raw REPL.
A long time ago when there was only the `stm` port, Ctrl-C would trigger a
preemptive NLR jump to break out of running code. Then in commit
124df6f8d07b53542b6960dbeea9b63bff469a67 a more general approach to
asynchronous `KeyboardInterrupt` exceptions was implemented, and `stmhal`
supported both approaches, with the general (soft) interrupt taking
priority.
Then in commit bc1488a05f509cd5be8bfab9574babfcb993806f `pyboard.py` was
updated with a corresponding change to make it issue a double Ctrl-C to
break out of any existing code when entering the raw REPL (two Ctrl-C
characters were sent in order to more reliably trigger the preemptive NLR
jump).
No other port has preemptive NLR jumps and so a double Ctrl-C doesn't
really behave any differently to a single Ctrl-C: with USB CDC the double
Ctrl-C would most likely be in the same USB packet and so processed in the
same low-level USB callback, so it's just setting the keyboard interrupt
flag twice in a row. The VM/runtime then just sees one keyboard interrupt
and acts as though only one Ctrl-C was sent.
This commit changes the double Ctrl-C to a single Ctrl-C in `pyboard.py`
and `mpremote`. That keeps things as simple as they need to be.
Signed-off-by: Damien George <damien@micropython.org>
| -rw-r--r-- | tools/mpremote/mpremote/transport_serial.py | 2 | ||||
| -rwxr-xr-x | tools/pyboard.py | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/tools/mpremote/mpremote/transport_serial.py b/tools/mpremote/mpremote/transport_serial.py index 6f43e2c41..28ccaf6d8 100644 --- a/tools/mpremote/mpremote/transport_serial.py +++ b/tools/mpremote/mpremote/transport_serial.py @@ -121,7 +121,7 @@ class SerialTransport(Transport): return data def enter_raw_repl(self, soft_reset=True): - self.serial.write(b"\r\x03\x03") # ctrl-C twice: interrupt any running program + self.serial.write(b"\r\x03") # ctrl-C: interrupt any running program # flush input (without relying on serial.flushInput()) n = self.serial.inWaiting() diff --git a/tools/pyboard.py b/tools/pyboard.py index 55cbe8384..8459bcf65 100755 --- a/tools/pyboard.py +++ b/tools/pyboard.py @@ -348,7 +348,7 @@ class Pyboard: return data def enter_raw_repl(self, soft_reset=True): - self.serial.write(b"\r\x03\x03") # ctrl-C twice: interrupt any running program + self.serial.write(b"\r\x03") # ctrl-C: interrupt any running program # flush input (without relying on serial.flushInput()) n = self.serial.inWaiting() |
