Watchdog
A watchdog timer is used to reset the system if the system fails or locks up.
It is recommended to run the watchdog inside a thread in the application.
Max timeout is 131 seconds.
- .NET
- Python
- C/C++
using GHIElectronics.Endpoint.Core;
using GHIElectronics.Endpoint.Devices.Watchdog;
using var watchdog = WatchdogController.FromName(EPDomino24.Watchdog.Id);
watchdog.Enable(TimeSpan.FromSeconds(10)); // 10 seconds
var cnt = 0;
while (true) {
Console.WriteLine("cnt: " + cnt++);
Thread.Sleep(1000);
watchdog.Reset();
}
import datetime, time
from GHIElectronics.Endpoint.Core import EPDomino24
from GHIElectronics.Endpoint.Devices.Watchdog import WatchdogController
watchdog = WatchdogController.FromName(EPDomino24.Watchdog.Id)
watchdog.Enable(datetime.timedelta(seconds=10)) # 10 seconds
cnt = 0
while True:
print("cnt:", cnt)
cnt += 1
time.sleep(1)
watchdog.Reset()
#include <chrono>
#include <cstdio>
#include <thread>
#include <endpoint/Watchdog.h>
#include <endpoint/EPDomino24.h>
using namespace GHIElectronics::Endpoint::Core;
using namespace GHIElectronics::Endpoint::Devices::Watchdog;
auto watchdog = WatchdogController::FromName(EPDomino24::Watchdog::Id);
watchdog.Enable(std::chrono::seconds(10)); // 10 seconds
int cnt = 0;
while (true) {
std::printf("cnt: %d\n", cnt++);
std::this_thread::sleep_for(std::chrono::seconds(1));
watchdog.Reset();
}