Software watchdog
-
Hi all, I am asking for a suggestion.
I use a LoPy and need to check if the main task get stuck (don't terminate within a specified time) forcing it to terminate after the timeout happens.
I tried using software timer, but I am not able to propagate the exception from the Timer's callback to the "stuck" thread, also using sys.exit() doesn't help: the SystemExit exception doesn't propagate to the main thread.
Any help or idea would be appreciated...
Many thanks!
-
@tuftec said in Software watchdog:
@Andrea-Zauli Yes!!!
Read here
https://docs.pycom.io/firmwareapi/pycom/machine/wdt/and here
https://docs.pycom.io/firmwareapi/pycom/machine/Peter.
Many thanks!!
-
I suggest a hardware WDT (Watch Dog Timer), like the TPL5010.
-
@Andrea-Zauli Yes!!!
Read here
https://docs.pycom.io/firmwareapi/pycom/machine/wdt/and here
https://docs.pycom.io/firmwareapi/pycom/machine/Peter.
-
Thanks for the reply. How con I set the watchdog function? Is it a specific timer?
-
I use the watchdog reset function. You enable the watchdog function and then keeping feeding the time out timer at various stages during your code. If something goes horribly wrong the watchdog timer expires (dog does not get feed) and forces a reset.
When your code boots you need to read the reset reason code. If the reason is watchdog timeout you can then do something sensible, like flag an error message.
I hope this helps.
Peter.
-
@Andrea-Zauli There is is always the big hammer called "machine.reset()", which starts the whole device again.