Watchdog only once ?

Posted on
  • Dear Gordon
    I've done some tests with the new watchdog function. My testcode is the following (right side):

    doreset=false;
    setInterval(function() { if(doreset===false) { console.log('kick'); E.kickWatchdog(); } },20000);
    E.enableWatchdog(25,false);
    save();

    You will see in the console every 20 seconds 'kick'. E.kickWatchdog is called.
    Then please set the var doreset to true:

    doreset=true;

    After a few seconds the pico will reset. Then please reconnect to the console.
    You will see the output of 'kick' again.

    Please give the variable doreset again the value of true.

    doreset=true;

    On the console 'kick' messages are gone. E.kickWatchdog is not called anymore.

    But the pico does not reset after more that 25 seconds. Please see the attached screenshot.

    Do I understand something wrong ? It only resets once ?

    Thanks

    Sacha


    1 Attachment

    • NewWatchdog.png
  • @Sache, please read the conversation about Something is wrong - PICO, especially post #7 and adjust your code accordingly.

    In a nutshell:

    1. remove the save() from your code completely
    2. put the rest of the code in a function called, for example, setup()
    3. add function onInit() in which you invoke setup();

    And you should be all set.

  • @allObjects
    Thanks, i know about onInit. I didn't know that the watchdog function has to be called/restarted after a reset while other internal functions like Intervals/Timers for example not.

  • Yes, remembering watchdog state is something I didn't bother adding - it would be possible but might use for extra memory, and I figured if you're at the more advanced state of using the watchdog you could probably cope with putting it in onInit :)

  • @Sacha, any dynamic, time oriented 'thing' should be started by onInit() or E.on("init",function(){...}) - including intervals/timers - to guarantee expected behavior. Yes, the interval/timer itself may not need it, but its the functions triggered by them that may not be able to complete (when you upload). And personally, I wonder if timer (setTimeout();) actually works when only happens on upload. And when it works, the timing behavior in respect to the context is for sure different.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Watchdog only once ?

Posted by Avatar for Sacha @Sacha

Actions