From 9a23923b2d793e6db1cac8778be810604506599e Mon Sep 17 00:00:00 2001 From: Alec Delaney Date: Fri, 29 Apr 2022 11:41:22 -0600 Subject: [PATCH] Add documentation for watchdog.WatchDogTimeout --- shared-bindings/watchdog/__init__.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/shared-bindings/watchdog/__init__.c b/shared-bindings/watchdog/__init__.c index ced56a781b..a0e357e2ac 100644 --- a/shared-bindings/watchdog/__init__.c +++ b/shared-bindings/watchdog/__init__.c @@ -49,7 +49,33 @@ //| w.timeout=2.5 # Set a timeout of 2.5 seconds //| w.mode = WatchDogMode.RAISE //| w.feed()""" + +//| class WatchDogTimeout(Exception): +//| """Exception raised when the watchdog timer is set to +//| ``WatchDogMode.RAISE`` and expires. //| +//| Example:: +//| +//| 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) # Also works with pass +//| except watchdog.WatchDogTimeout as e: +//| print("Watchdog expired") +//| except Exception as e: +//| print("Other exception") +//| +//| print("Exited loop") +//| """ const mp_obj_type_t mp_type_WatchDogTimeout = { { &mp_type_type },