File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 29
29
#include "supervisor/serial.h"
30
30
#include "lib/oofatfs/ff.h"
31
31
#include "py/mpconfig.h"
32
+ #include "py/mpstate.h"
32
33
33
34
#include "supervisor/shared/status_leds.h"
34
35
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
+
35
43
int mp_hal_stdin_rx_chr (void ) {
36
44
for (;;) {
37
45
#ifdef MICROPY_VM_HOOK_LOOP
38
46
MICROPY_VM_HOOK_LOOP
39
47
#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
+ }
40
58
if (serial_bytes_available ()) {
41
59
toggle_rx_led ();
42
60
return serial_read ();
You can’t perform that action at this time.
0 commit comments