There is a proper hardware watchdog timer in most microcontrollers that you can use as well - once set up, if it's not called every so often then it'll reset the device.
Espruino has two modes - one is automatic (if the interpreter doesn't return to the 'idle' state then it'll reboot), and the other requires you to manually 'kick' it:
E.enableWatchdog(0.5); // automatic mode
while(1); // Espruino will reboot because it has not been idle for 0.5 sec
E.enableWatchdog(1, false);
setInterval(function() {
if (everything_ok)
E.kickWatchdog();
}, 500);
/* Espruino will now reset if everything_ok is false,
or if the interval fails to be called */
This wasn't implemented on Puck.js until this morning (it'll be in firmware 1v94), but if you install the latest firmware from http://www.espruino.com/binaries/travis/master/ it should have the feature in it.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hi,
You can use http://www.espruino.com/FlashEEPROM to write data to flash memory, so data can be kept even after reset.
There is a proper hardware watchdog timer in most microcontrollers that you can use as well - once set up, if it's not called every so often then it'll reset the device.
Espruino has two modes - one is automatic (if the interpreter doesn't return to the 'idle' state then it'll reboot), and the other requires you to manually 'kick' it:
This wasn't implemented on Puck.js until this morning (it'll be in firmware 1v94), but if you install the latest firmware from http://www.espruino.com/binaries/travis/master/ it should have the feature in it.