watchdog 2021
-
I have been reading through the posts on watchdogging and still not sure about it, so here is a question that perhaps someone can answer.......
Is the below code snippet the right way to use watchdog in 2.3.2? Do I need the #include <avr/wdt.h> is it already in the mysensors package?
#include <avr/wdt.h> #include <MySensors.h> void setup() { // Setup locally attached sensors wdt_disable(); wait(250); wdt_enable(WDTO_8S); } void presentation() { // Present locally attached sensors } void loop() { // Send locally attached sensor data here wdt_reset(); }This is to use on a gateway but is the same method implemented on sleeping nodes?
I will be using the minicore bootloaders which I believe are optiboot forks.
Thanks.
-
@skywatch, I don't know if you're still looking for the answer, but in case you are, or anyone else who hits through google search, from what I understand reading this page: https://www.nongnu.org/avr-libc/user-manual/group__avr__watchdog.html , you can set your watchdog timer with wdt_enable(time constant), time constant is typically in WDTO_XS format, where X is the seconds, however not all values are available for all processors, please see the link to check which values are supported.
Next thing to do is including wdt_reset() on your loop. This will reset the timer. If the timer isn't reset by the time your counter expires, watchdog will trigger.
-
@skywatch, I don't know if you're still looking for the answer, but in case you are, or anyone else who hits through google search, from what I understand reading this page: https://www.nongnu.org/avr-libc/user-manual/group__avr__watchdog.html , you can set your watchdog timer with wdt_enable(time constant), time constant is typically in WDTO_XS format, where X is the seconds, however not all values are available for all processors, please see the link to check which values are supported.
Next thing to do is including wdt_reset() on your loop. This will reset the timer. If the timer isn't reset by the time your counter expires, watchdog will trigger.
@Melih-Kulig Thanks - #i actually used the code above and it has been working OK for the last 10 days, so no bad effect. I don't know if the watchdog has had to kick in yet but it seems not.
-
Hi all,
I'd like to add, there is no need to call wdt_reset() explicitly in loop().
This already takes place before each loop() call in the MySensors library code behind function doYield():
see: MySensorsCore.cpp#L619And hwWatchdogReset() is an HW abstraction of wdt_reset() for AVR architecture:
/hal/architecture/AVR/MyHwAVR.h#L71My call stack from main() to doYield() is:
> MySensorsProject2.exe!doYield() Line 650 C++ MySensorsProject2.exe!_processInternal() Line 74 C++ MySensorsProject2.exe!_process() Line 91 C++ MySensorsProject2.exe!main(int argc, char * * argv) Line 343 C++ -
Hi all,
I'd like to add, there is no need to call wdt_reset() explicitly in loop().
This already takes place before each loop() call in the MySensors library code behind function doYield():
see: MySensorsCore.cpp#L619And hwWatchdogReset() is an HW abstraction of wdt_reset() for AVR architecture:
/hal/architecture/AVR/MyHwAVR.h#L71My call stack from main() to doYield() is:
> MySensorsProject2.exe!doYield() Line 650 C++ MySensorsProject2.exe!_processInternal() Line 74 C++ MySensorsProject2.exe!_process() Line 91 C++ MySensorsProject2.exe!main(int argc, char * * argv) Line 343 C++@virtualmkr That is useflul to know - thanks! - As it happens I think I had my first wdt 'kick' early this morning as the Gateway with the wdt on was showing as up for 3 hours instead of the 4 days I was expecting, so it restarted and all is still working ;)
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login