2016-06-07 22:46:27 +01:00
|
|
|
.. currentmodule:: machine
|
2017-04-18 06:27:37 +01:00
|
|
|
.. _machine.WDT:
|
2015-06-10 22:29:56 +01:00
|
|
|
|
|
|
|
class WDT -- watchdog timer
|
|
|
|
===========================
|
|
|
|
|
|
|
|
The WDT is used to restart the system when the application crashes and ends
|
|
|
|
up into a non recoverable state. Once started it cannot be stopped or
|
2015-10-14 11:32:01 +01:00
|
|
|
reconfigured in any way. After enabling, the application must "feed" the
|
2015-06-10 22:29:56 +01:00
|
|
|
watchdog periodically to prevent it from expiring and resetting the system.
|
|
|
|
|
|
|
|
Example usage::
|
|
|
|
|
2015-10-20 15:24:25 +01:00
|
|
|
from machine import WDT
|
|
|
|
wdt = WDT(timeout=2000) # enable it with a timeout of 2s
|
2015-09-13 16:06:12 +01:00
|
|
|
wdt.feed()
|
2015-06-10 22:29:56 +01:00
|
|
|
|
2020-05-02 08:17:54 +01:00
|
|
|
Availability of this class: pyboard, WiPy, esp8266, esp32.
|
2016-08-17 05:22:39 +01:00
|
|
|
|
2015-06-10 22:29:56 +01:00
|
|
|
Constructors
|
|
|
|
------------
|
|
|
|
|
2016-06-09 01:03:53 +01:00
|
|
|
.. class:: WDT(id=0, timeout=5000)
|
2015-06-10 22:29:56 +01:00
|
|
|
|
2020-05-02 08:17:54 +01:00
|
|
|
Create a WDT object and start it. The timeout must be given in milliseconds.
|
|
|
|
Once it is running the timeout cannot be changed and the WDT cannot be stopped either.
|
2021-12-15 00:49:22 +00:00
|
|
|
|
2020-05-02 08:17:54 +01:00
|
|
|
Notes: On the esp32 the minimum timeout is 1 second. On the esp8266 a timeout
|
|
|
|
cannot be specified, it is determined by the underlying system.
|
2015-06-10 22:29:56 +01:00
|
|
|
|
|
|
|
Methods
|
|
|
|
-------
|
|
|
|
|
2015-09-13 16:06:12 +01:00
|
|
|
.. method:: wdt.feed()
|
2015-06-10 22:29:56 +01:00
|
|
|
|
2015-09-13 16:06:12 +01:00
|
|
|
Feed the WDT to prevent it from resetting the system. The application
|
2015-06-10 22:29:56 +01:00
|
|
|
should place this call in a sensible place ensuring that the WDT is
|
2015-09-13 16:06:12 +01:00
|
|
|
only fed after verifying that everything is functioning correctly.
|