Skip to content

Commit b598ec0

Browse files
authored
Merge pull request #6324 from tekktrik/doc/add-watchdog-timeout-docs
Add documentation for watchdog.WatchDogTimeout
2 parents 816a26e + 9a23923 commit b598ec0

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

shared-bindings/watchdog/__init__.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,33 @@
4949
//| w.timeout=2.5 # Set a timeout of 2.5 seconds
5050
//| w.mode = WatchDogMode.RAISE
5151
//| w.feed()"""
52+
53+
//| class WatchDogTimeout(Exception):
54+
//| """Exception raised when the watchdog timer is set to
55+
//| ``WatchDogMode.RAISE`` and expires.
56+
//|
57+
//| Example::
58+
//|
59+
//| import microcontroller
60+
//| import watchdog
61+
//| import time
62+
//|
63+
//| wdt = microcontroller.watchdog
64+
//| wdt.timeout = 5
65+
//|
66+
//| while True:
67+
//| wdt.mode = watchdog.WatchDogMode.RAISE
68+
//| print("Starting loop -- should exit after five seconds")
69+
//| try:
70+
//| while True:
71+
//| time.sleep(10) # Also works with pass
72+
//| except watchdog.WatchDogTimeout as e:
73+
//| print("Watchdog expired")
74+
//| except Exception as e:
75+
//| print("Other exception")
5276
//|
77+
//| print("Exited loop")
78+
//| """
5379

5480
const mp_obj_type_t mp_type_WatchDogTimeout = {
5581
{ &mp_type_type },

0 commit comments

Comments
 (0)