Ihor Nehrutsa 2024-04-07 17:48:09 +03:00 zatwierdzone przez GitHub
commit 73ae0308fb
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
4 zmienionych plików z 50 dodań i 4 usunięć

2
docs/esp32/quickref.rst 100644 → 100755
Wyświetl plik

@ -578,7 +578,7 @@ See :ref:`machine.WDT <machine.WDT>`. ::
from machine import WDT
# enable the WDT with a timeout of 5s (1s is the minimum)
wdt = WDT(timeout=5000)
wdt = WDT(timeout=5000) # timeout in milliseconds
wdt.feed()
.. _Deep_sleep_mode:

1
docs/esp32/tutorial/index.rst 100644 → 100755
Wyświetl plik

@ -20,4 +20,5 @@ to `<https://www.python.org>`__.
intro.rst
pwm.rst
wdt.rst
peripheral_access.rst

Wyświetl plik

@ -0,0 +1,43 @@
.. _esp32_wdt:
WDT
===
When the WDT timeout is short, a problem occurs when updating the software:
you don't have enough time to copy the updates to the device.
ESP32 allows reinitialise the watchdog with a longer timeout - like an hour.
More comprehansive example usage::
# Save as 'main.py' and it will run automatically after 'boot.py'
import sys
from time import sleep
from machine import WDT, reset
try:
print('Press Ctrl-C to break the program.')
sleep(5)
print('Enable the WDT with a timeout of 5s.')
wdt = WDT(timeout=5000)
seconds = 1
while True: # infinite work loop
print('Do something useful in less than 5 seconds.')
print(f'Sleep {seconds} seconds.')
if seconds >= 5:
print(f'WDT will reboot the board.')
sleep(seconds)
seconds += 1
wdt.feed()
# 1/0 # uncomment this line to raise an runtime exception, then WDT reboot
# sys.exit() # uncomment this line for planned program exit
except SystemExit:
wdt = WDT(timeout=1000 * 60 * 60) # 1 hour before WDT reboot
print('Now you have 1 hour to update program on the board.')
print('When ready, type reset() on the REPL/WebREPL command line to reboot.')

8
docs/library/machine.WDT.rst 100644 → 100755
Wyświetl plik

@ -5,15 +5,17 @@ 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
reconfigured in any way. After enabling, the application must "feed" the
up into a non recoverable state. Once started it cannot be stopped
in any way. After enabling, the application must "feed" the
watchdog periodically to prevent it from expiring and resetting the system.
Example usage::
from machine import WDT
wdt = WDT(timeout=2000) # enable it with a timeout of 2s
wdt.feed()
while True:
# do something useful in less than 2 seconds
wdt.feed()
Availability of this class: pyboard, WiPy, esp8266, esp32, rp2040, mimxrt.