The wait function does not trigger the watchdog?
-
I wanted to do a quick test of the watchdog function on the serial gateway.
So originally I had a variable that would increment, and then make a
wait()function take increasingly long. But to my surprise, this didn't trigger the watchdog.#include <MySensors.h> // The MySensors library, which takes care of creating the wireless network. #include <avr/wdt.h> // The watchdog timer - if the device becomes unresponsive and doesn't periodically reset the timer, then it will automatically reset once the timer reaches 0. // Clock for the watchdog #define INTERVAL 1000 // Every second we reset the watchdog timer. If the device freezes, the watchdog will not re reset, and the device will reboot. unsigned long previousMillis = 0; // Used to run the internal clock int boogyman = 0; void setup() { Serial.begin(115200); // For serial debugging over USB. Serial.println(F("Hello, I am a Candle receiver")); wdt_enable(WDTO_2S); // Starts the watchdog timer. If it is not reset once every 2 seconds, then the entire device will automatically restart. } void presentation() { // The receiver does not have any extra children itself. } void loop() { if(millis() - previousMillis >= INTERVAL){ // Main loop, runs every second. previousMillis = millis(); // Store the current time as the previous measurement start time. Serial.print("resetting watchdog. Boogyman:"); Serial.println(boogyman); wdt_reset(); // Reset the watchdog timer wait(boogyman); boogyman = boogyman + 300; } //delay(boogyman); }Even if the increasing variable would theoretically call the
waitfunction for more than 2 seconds (the watchdog timeout), it just kept on increasing.if I changed the
wait()into adelay(), it would actually trigger the watchdog.So, I'm curious: how does the wait function work? The Arduino can't do multi-tasking, right? So how is it possible that the loop that runs every second is still able to keep the watchdog at bay?
While I'm at it, I am also curious how the MySensors library integrates itself into the Arduino. It seems to manage the messages in the background perfectly well. Is that because the 'interupt' acts like a very basic multi-tasking?
I was under the assuption that using the loop above, this loop would never run 'paralel'. Is that assumption still correct?
-
I wanted to do a quick test of the watchdog function on the serial gateway.
So originally I had a variable that would increment, and then make a
wait()function take increasingly long. But to my surprise, this didn't trigger the watchdog.#include <MySensors.h> // The MySensors library, which takes care of creating the wireless network. #include <avr/wdt.h> // The watchdog timer - if the device becomes unresponsive and doesn't periodically reset the timer, then it will automatically reset once the timer reaches 0. // Clock for the watchdog #define INTERVAL 1000 // Every second we reset the watchdog timer. If the device freezes, the watchdog will not re reset, and the device will reboot. unsigned long previousMillis = 0; // Used to run the internal clock int boogyman = 0; void setup() { Serial.begin(115200); // For serial debugging over USB. Serial.println(F("Hello, I am a Candle receiver")); wdt_enable(WDTO_2S); // Starts the watchdog timer. If it is not reset once every 2 seconds, then the entire device will automatically restart. } void presentation() { // The receiver does not have any extra children itself. } void loop() { if(millis() - previousMillis >= INTERVAL){ // Main loop, runs every second. previousMillis = millis(); // Store the current time as the previous measurement start time. Serial.print("resetting watchdog. Boogyman:"); Serial.println(boogyman); wdt_reset(); // Reset the watchdog timer wait(boogyman); boogyman = boogyman + 300; } //delay(boogyman); }Even if the increasing variable would theoretically call the
waitfunction for more than 2 seconds (the watchdog timeout), it just kept on increasing.if I changed the
wait()into adelay(), it would actually trigger the watchdog.So, I'm curious: how does the wait function work? The Arduino can't do multi-tasking, right? So how is it possible that the loop that runs every second is still able to keep the watchdog at bay?
While I'm at it, I am also curious how the MySensors library integrates itself into the Arduino. It seems to manage the messages in the background perfectly well. Is that because the 'interupt' acts like a very basic multi-tasking?
I was under the assuption that using the loop above, this loop would never run 'paralel'. Is that assumption still correct?
@alowhum most of these questions are way too advanced for me to answer, but I know that
wait()calls_process()which processes messages and kicks the watchdog (throughdoYield()). See https://github.com/mysensors/MySensors/blob/development/core/MySensorsCore.cpp#L565while (hwMillis() - enteringMS < waitingMS) {
_process();
}By default, nrf24-based nodes do not use interrupts for message handling.
There is nothing done in parallell.
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