Always clear RX buffer on CTRL-C
Some serial sources clear their RX buffers and others didn't. This cause CP to skip into the REPL based on characters typed before the CTRL-C. The serial file transfer code looks for "press any key" which is skipped in this case. Fixes https://github.com/circuitpython/web-editor/issues/238
This commit is contained in:
parent
30d57b1ade
commit
b5517cb04b
5 changed files with 6 additions and 1 deletions
|
|
@ -26,6 +26,7 @@ void bleio_characteristic_buffer_extend(bleio_characteristic_buffer_obj_t *self,
|
|||
for (uint16_t i = 0; i < len; i++) {
|
||||
if (data[i] == mp_interrupt_char) {
|
||||
mp_sched_keyboard_interrupt();
|
||||
ringbuf_clear(&self->ringbuf);
|
||||
} else {
|
||||
ringbuf_put(&self->ringbuf, data[i]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ static void _copy_out_of_fifo(void) {
|
|||
for (size_t i = 0; i < len; ++i) {
|
||||
if (rx_buf[i] == mp_interrupt_char) {
|
||||
mp_sched_keyboard_interrupt();
|
||||
ringbuf_clear(&ringbuf);
|
||||
} else {
|
||||
ringbuf_put(&ringbuf, rx_buf[i]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ static void write_to_ringbuf(bleio_characteristic_buffer_obj_t *self, uint8_t *d
|
|||
for (uint16_t i = 0; i < len; i++) {
|
||||
if (data[i] == mp_interrupt_char) {
|
||||
mp_sched_keyboard_interrupt();
|
||||
ringbuf_clear(&self->ringbuf);
|
||||
} else {
|
||||
ringbuf_put(&self->ringbuf, data[i]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,8 +155,9 @@ static void send_bufn_core(const char *buf, size_t n) {
|
|||
for (; n--; buf++) {
|
||||
int code = *buf;
|
||||
if (code == mp_interrupt_char) {
|
||||
ringbuf_clear(&_incoming_ringbuf);
|
||||
mp_sched_keyboard_interrupt();
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
if (ringbuf_num_empty(&_incoming_ringbuf) == 0) {
|
||||
// Drop on the floor
|
||||
|
|
|
|||
|
|
@ -227,6 +227,7 @@ void websocket_background(void) {
|
|||
while (ringbuf_num_empty(&_incoming_ringbuf) > 0 &&
|
||||
_read_next_payload_byte(&c)) {
|
||||
if (c == mp_interrupt_char) {
|
||||
ringbuf_clear(&_incoming_ringbuf);
|
||||
mp_sched_keyboard_interrupt();
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue