Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Cannot use ctrl-C to interrupt code.py after sending data to the REPL #4817

Closed
@Neradoc

Description

@Neradoc

When code.py is running, sending a certain quantity of characters to the serial port disables ctrl-C.
Here is a test python script that takes the serial as argument, and can be run to see if it interrupts the code, using a simple code.py blinking an LED. Different values of NUMCHARS will cause the issue depending on the board/port.

# that's for convenience
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('port', type=str, help="Serial port of the board", nargs=1)
args = parser.parse_args()
serial_port = args.port[0]

# that's the actual test
import serial
import time

CTRLC = b'\x03'
NUMCHARS = 1000

channel = serial.Serial(serial_port)
channel.write(b" " * NUMCHARS)
channel.write(CTRLC)
channel.close()

That was discovered when using Mu, since clicking in the serial panel makes it send characters to move the insertion point in the REPL, leading to the issue. mu-editor/mu#1505

(Tested on MacOS Catalina with the circuitplayground and a few different boards)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions