circuitpython/shared-bindings/watchdog
Sean Cross dbf1bef56a watchdog: support catching the timeout
With this patch, the exception can now be caught:

    import microcontroller
    import watchdog
    import time

    wdt = microcontroller.watchdog
    wdt.timeout = 5

    while True:
        wdt.mode = watchdog.WatchDogMode.RAISE
        print("Starting loop -- should exit after five seconds")
        try:
            while True:
                time.sleep(10)
                # pass # This also works for a spinloop
        except watchdog.WatchDogTimeout as e:
            print("Watchdog Expired (PASS)")
        except Exception as e:
            print("Other exception (FAIL)")
    print("Exited loop")

This prints:

    Starting loop -- should exit after five seconds
    Watchdog Expired (PASS)
    Starting loop -- should exit after five seconds
    Watchdog Expired (PASS)
    Starting loop -- should exit after five seconds
    Watchdog Expired (PASS)

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-27 11:28:50 +08:00
..
__init__.c watchdog: support catching the timeout 2020-05-27 11:28:50 +08:00
__init__.h watchdog: move timeout exception to shared-bindings 2020-05-27 11:28:49 +08:00
WatchDogMode.c watchdogtimer: refactor to new api 2020-05-27 11:28:49 +08:00
WatchDogMode.h watchdogtimer: refactor to new api 2020-05-27 11:28:49 +08:00
WatchDogTimer.c watchdog: rename module from wdt and move to microcontroller 2020-05-27 11:28:49 +08:00
WatchDogTimer.h watchdog: rename module from wdt and move to microcontroller 2020-05-27 11:28:49 +08:00