kaluma-project / kaluma

A tiny JavaScript runtime for RP2040 (Raspberry Pi Pico)
https://kalumajs.org
Apache License 2.0
632 stars 38 forks source link

reboot problem #598

Closed pclokcer closed 1 year ago

pclokcer commented 1 year ago

I want to reboot my board. how can I reboot?

communix commented 1 year ago

@pclokcer To reboot the system, plug out the power and plug in the power. If you need to skip the javascript code, please see this document (https://kalumajs.org/docs/boards/pico#skip-code-loading-on-boot)

pclokcer commented 1 year ago

in fact, I want to do watchdog @communix

communix commented 1 year ago

@pclokcer OK. I got it. Let me think about how we can implement watchdog.

communix commented 1 year ago

@pclokcer watchdog class is implemented in the master branch. Please try it.

This is the sample code.

const { WDT } = require('wdt');
const wdt = new WDT(1000); // 1 sec watchdog timeout

var timer = 0;

var timer_id = setInterval(()=> {
    wdt.feed(); // Reset watchdog timer
    timer += 500;
    console.log("Reset watchdog timer " + timer + " ms");
    if (timer > 10000) { // Do not reset for 10 sec.
        clearInterval(timer_id);
        console.log("Watchdog reset after 1 sec.");
    }
}, 500);
pclokcer commented 1 year ago

vauv thank you