@@ -5,43 +5,19 @@ class WDT -- watchdog timer
5
5
===========================
6
6
7
7
The WDT is used to restart the system when the application crashes and ends
8
- up into a non recoverable state. Once started it cannot be stopped
9
- in any way. After enabling, the application must "feed" the
8
+ up into a non recoverable state. Once started it cannot be stopped or
9
+ reconfigured in any way. After enabling, the application must "feed" the
10
10
watchdog periodically to prevent it from expiring and resetting the system.
11
11
12
12
Example usage::
13
13
14
14
from machine import WDT
15
15
<
8000
/td> wdt = WDT(timeout=2000) # enable it with a timeout of 2s
16
- wdt.feed()
16
+ while True:
17
+ # do something useful in less than 2 seconds
17
18
18
-
19
- When the WDT timeout is short, there is a software update issue:
20
- you don't have enough time to copy the updates to the device.
21
- You may reinitialise the watchdog with a longer timeout – like an hour.
22
-
23
- More comprehansive example usage::
24
-
25
- # main.py # starts automatically after boot.py
26
- import sys
27
- from machine import WDT
28
-
29
- wdt = WDT(timeout=5000) # 5s
30
-
31
- while True: # infinite work loop
32
- # do something useful in less than 5 seconds
33
-
34
- # 1/0 # uncoment this line to raise an runtime exception, then WDT reboot
35
-
36
- # while True: # uncomment three lines to simulate program deadlock, then WDT reboot
37
- # print('Wait for WDT reboot')
38
- # sleep_ms(1000)
39
-
40
- wdt.feed() # all right
41
-
42
- if False: # replace False with True to terminate the program
43
- wdt = WDT(timeout=1000 * 60 * 60) # 1 hour before WDT reboot
44
- sys.exit(0) # will enter to REPL(WebREPL)
19
+ if verify_that_everything_is_functioning_correctly():
20
+ wdt.feed()
45
21
46
22
Availability of this class: pyboard, WiPy, esp8266, esp32.
47
23
0 commit comments