summaryrefslogtreecommitdiff
path: root/supervisor
diff options
context:
space:
mode:
authorJeff Epler <jepler@unpythonic.net>2020-08-23 08:46:42 -0500
committerJeff Epler <jepler@unpythonic.net>2020-08-23 08:47:18 -0500
commitf8a9e11ff4f42620bbe6e678f009bdadcb4ac542 (patch)
tree879470792b1a771b0404cd997611818389714d5f /supervisor
parentdc36a2c0b60655245bdfec98adb7e05a5cdf2fd3 (diff)
WIP supervisor: check for interrupt during rx_chr
Diffstat (limited to 'supervisor')
-rw-r--r--supervisor/shared/micropython.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/supervisor/shared/micropython.c b/supervisor/shared/micropython.c
index 245db11d4..cd9485f8c 100644
--- a/supervisor/shared/micropython.c
+++ b/supervisor/shared/micropython.c
@@ -29,14 +29,32 @@
#include "supervisor/serial.h"
#include "lib/oofatfs/ff.h"
#include "py/mpconfig.h"
+#include "py/mpstate.h"
#include "supervisor/shared/status_leds.h"
+#if CIRCUITPY_WATCHDOG
+#include "shared-bindings/watchdog/__init__.h"
+#define WATCHDOG_EXCEPTION_CHECK() (MP_STATE_VM(mp_pending_exception) == &mp_watchdog_timeout_exception)
+#else
+#define WATCHDOG_EXCEPTION_CHECK() 0
+#endif
+
int mp_hal_stdin_rx_chr(void) {
for (;;) {
#ifdef MICROPY_VM_HOOK_LOOP
MICROPY_VM_HOOK_LOOP
#endif
+ // Check to see if we've been CTRL-Ced by autoreload or the user.
+ if (MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception))) {
+ // clear exception and generate stacktrace
+ MP_STATE_VM(mp_pending_exception) = MP_OBJ_NULL;
+ nlr_raise(&MP_STATE_VM(mp_kbd_exception));
+ }
+ if (MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception)) || WATCHDOG_EXCEPTION_CHECK()) {
+ // stop reading immediately
+ return EOF;
+ }
if (serial_bytes_available()) {
toggle_rx_led();
return serial_read();