← index #7867Issue #7734
Related · high · value 0.302
QUERY · ISSUE

Ctrl+A followed by Ctrl+C gets serial input stuck since 1.17

openby aivarannamaaopened 2021-09-28updated 2022-05-01

OS: Ubuntu 20.04

Device: RPi Pico

main.py:

from machine import Pin
from time import sleep
led = Pin(25, Pin.OUT)
n = 0

while True:
    led.toggle()
    print("13 x {} = {}".format(n, 13*n)) # print the thirteen-times table
    n = n+1
    sleep(0.5)

With MicroPython 1.17, when I plug this device in, connect with tio and press Ctrl+C, then it successfully interrupts and gives me normal prompt. When I, instead, first press Ctrl+A and then Ctrl+C, then nothing happens and the input kind of gets stuck (if I do it via pyserial, then the write method blocks). Same happens when I press Ctrl+D and then Ctrl+C.

Sometimes I get out of this situation by hard-resetting Pico, but sometimes even this doesn't help and I need to either restart my computer or reset USB.

When I go back to 1.16, then this problem disappears.

This issue is relevant for Thonny IDE, because upon connecting a device, it sends Ctrl+A to probe whether the device is already idle at prompt or a process is running.

CANDIDATE · ISSUE

Serial keeps outputting after Ctrl+C

closedby moefear85opened 2021-08-31updated 2023-11-06

Sometimes I print debug info to Serial in a very tight loop, causing buffers to fill up. Thus after pressing Ctrl+C to end the running code, it can take up to even 20 seconds before the board responds. I'm not sure if micropython is simply caught up, but I assume it has long since processed and responded to the Ctrl+C and terminated the program, but continues to send all the "pent-up" data out over serial. The same might be happening on the PC side, so I'm not sure whether this should be a micropython issue or not.

But, is it possible, after micropython sees a Ctrl+C, that it immediately discard everything in the output buffer, since usually by the time someone presses Ctrl+C, they are no longer interested in the rest of the serial output.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied