From 4681b86850076c013be2477d3850fd536361b62e Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Tue, 24 May 2016 01:37:56 +0300 Subject: [PATCH] esp8266/esp_mphal: Handle Ctrl+C from dupterm (e.g. WebREPL). --- esp8266/esp_mphal.c | 4 ++++ esp8266/esp_mphal.h | 3 +++ 2 files changed, 7 insertions(+) diff --git a/esp8266/esp_mphal.c b/esp8266/esp_mphal.c index eabf8ca208..04154a3781 100644 --- a/esp8266/esp_mphal.c +++ b/esp8266/esp_mphal.c @@ -176,6 +176,10 @@ static int call_dupterm_read(void) { mp_uos_deactivate("dupterm: EOF received, deactivating\n", MP_OBJ_NULL); return -1; } + if (*(byte*)bufinfo.buf == interrupt_char) { + mp_keyboard_interrupt(); + return -2; + } return *(byte*)bufinfo.buf; } else { mp_uos_deactivate("dupterm: Exception in read() method, deactivating: ", nlr.ret_val); diff --git a/esp8266/esp_mphal.h b/esp8266/esp_mphal.h index 13b1c8fdf0..377bbeb6a4 100644 --- a/esp8266/esp_mphal.h +++ b/esp8266/esp_mphal.h @@ -29,6 +29,9 @@ #include "py/ringbuf.h" +void mp_keyboard_interrupt(void); +extern int interrupt_char; + struct _mp_print_t; // Structure for UART-only output via mp_printf() extern const struct _mp_print_t mp_debug_print;