diff options
| author | Sean Cross <sean@xobs.io> | 2020-05-27 10:21:43 +0800 |
|---|---|---|
| committer | Sean Cross <sean@xobs.io> | 2020-05-27 11:28:50 +0800 |
| commit | dbf1bef56ab3a7ce73388c9833c9aa5a4074eb24 (patch) | |
| tree | 475977568c19a41451c9dee09e9a494405f9272a /shared-module/network | |
| parent | e470376c126828c768dfbcf25430869e8bc2b021 (diff) | |
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>
Diffstat (limited to 'shared-module/network')
0 files changed, 0 insertions, 0 deletions
