File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2929#include "supervisor/serial.h"
3030#include "lib/oofatfs/ff.h"
3131#include "py/mpconfig.h"
32+ #include "py/mpstate.h"
3233
3334#include "supervisor/shared/status_leds.h"
3435
36+ #if CIRCUITPY_WATCHDOG
37+ #include "shared-bindings/watchdog/__init__.h"
38+ #define WATCHDOG_EXCEPTION_CHECK () (MP_STATE_VM(mp_pending_exception) == &mp_watchdog_timeout_exception)
39+ #else
40+ #define WATCHDOG_EXCEPTION_CHECK () 0
41+ #endif
42+
3543int mp_hal_stdin_rx_chr (void ) {
3644 for (;;) {
3745 #ifdef MICROPY_VM_HOOK_LOOP
3846 MICROPY_VM_HOOK_LOOP
3947 #endif
48+ // Check to see if we've been CTRL-Ced by autoreload or the user.
49+ if (MP_STATE_VM (mp_pending_exception ) == MP_OBJ_FROM_PTR (& MP_STATE_VM (mp_kbd_exception ))) {
50+ // clear exception and generate stacktrace
51+ MP_STATE_VM (mp_pending_exception ) = MP_OBJ_NULL ;
52+ nlr_raise (& MP_STATE_VM (mp_kbd_exception ));
53+ }
54+ if (MP_STATE_VM (mp_pending_exception ) == MP_OBJ_FROM_PTR (& MP_STATE_VM (mp_reload_exception )) || WATCHDOG_EXCEPTION_CHECK ()) {
55+ // stop reading immediately
56+ return EOF ;
57+ }
4058 if (serial_bytes_available ()) {
4159 toggle_rx_led ();
4260 return serial_read ();
You can’t perform that action at this time.
0 commit comments