Device I/O API 1.0

Package jdk.dio.watchdog

Interfaces and classes for using system watchdog timers (WDT).

See: Description

Package jdk.dio.watchdog Description

Interfaces and classes for using system watchdog timers (WDT).

A watchdog timer is used to reset/reboot the system in case of hang or critical failure. This is used to reset the system from a unresponsive state to a normal state. A watchdog timer can be set with a time interval for the reset/reboot. Continuously refreshing the watchdog timer within the specified time interval prevents the reset/reboot. If the watchdog timer has not been refreshed within the specified time interval a critical failure is assumed and a system reset/reboot is carried out.
A windowed watchdog timer must be refreshed within an open time window. If the watchdog is refreshed too soon - during the closed window - or if it is refreshed too late - after the watchdog timeout has expired - the device will be rebooted.

In order to use with a specific watchdog timer, an application should first open and obtain an WatchdogTimer instance for the watchdog timer the application wants to use, using its numerical ID, name, type (interface) and/or properties:

Using its ID
 WatchdogTimer wdt = DeviceManager.open(8);
 
Using its name and interface
 WatchdogTimer wdt = DeviceManager.open("WDT", WatchdogTimer.class, null);
 
Or for a windowed watchdog timer,
 WindowedWatchdogTimer wdt = DeviceManager.open("WWDT", WindowedWatchdogTimer.class, null);
 
Once the device opened, the application can start using it and can especially start the timer using the WatchdogTimer.start method and subsequently refresh the timer periodically using the WatchdogTimer.refresh method
 wdt.start(1000);
 ...
 wdt.refresh();
 
When done, the application should call the WatchdogTimer.close method to close the watchdog timer.
 wdt.close();
 

The following sample codes give examples of using the watchdog timer API:

 public class WatchdogSample {
     public boolean checkSomeStatus() {
         // check some status....
         // if status is ok then return true to kick watch dog timer.
         return true;
     }
 
     public void test_loop() {
         WatchdogTimer watchdogTimer = (WatchdogTimer) DeviceManager.open(WDT_ID);
 
         watchdogTimer.start(180000); // Start watch dog timer with 3 min duration.
 
         while (true) {
             if (checkSomeStatus() == true) {
                 // Everything goes fine, timer will be kick.
                 watchdogTimer.refresh();
                 // do something more...
             } else {
                 // Something goes wrong. Timer will not be kick.
                 // If status not recovered within 2-3 turns then system will be reboot.
             }
             sleep(60000); // sleep for 1 min.
         }
     }
 }
 

Unless otherwise noted, passing a null argument to a constructor or method in any class or interface in this package will cause a NullPointerException to be thrown.

Device I/O API 1.0