-
• #2
@Sache, please read the conversation about Something is wrong - PICO, especially post #7 and adjust your code accordingly.
In a nutshell:
- remove the
save()
from your code completely - put the rest of the code in a function called, for example,
setup()
- add function
onInit()
in which you invokesetup();
And you should be all set.
- remove the
-
• #3
@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. -
• #4
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 :)
-
• #5
@Sacha, any dynamic, time oriented 'thing' should be started by
onInit()
orE.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.
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:
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.
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