File syn_watchdog.h¶
FileList > sched > syn_watchdog.h
Go to the source code of this file
Task-level watchdog monitor. More...
#include "../common/syn_defs.h"#include "../port/syn_port_system.h"#include "../system/syn_errlog.h"#include <stdbool.h>
Classes¶
| Type | Name |
|---|---|
| struct | SYN_WDT_Entry Single watchdog entry for task monitoring. |
| struct | SYN_Watchdog Software watchdog — monitors task deadlines. |
Public Types¶
| Type | Name |
|---|---|
| typedef void(* | SYN_WDT_TimeoutCallback Called when a task misses its check-in deadline. |
Public Functions¶
| Type | Name |
|---|---|
| void | syn_watchdog_checkin (SYN_Watchdog * wdt, int8_t id) Check in a task (reset its timeout). |
| void | syn_watchdog_init (SYN_Watchdog * wdt, SYN_WDT_Entry * entries, uint8_t capacity, SYN_WDT_TimeoutCallback callback, void * ctx) Initialize the watchdog monitor. |
| int8_t | syn_watchdog_register (SYN_Watchdog * wdt, const char * name, uint32_t timeout_ms) Register a task for monitoring. |
| void | syn_watchdog_unregister (SYN_Watchdog * wdt, int8_t id) Unregister a task. |
| void | syn_watchdog_update (SYN_Watchdog * wdt) Check all tasks for timeouts. |
Detailed Description¶
Each registered task must "check in" periodically. If any task misses its deadline, the watchdog fires a callback (typically system reset).
This is distinct from a hardware watchdog — it monitors individual software tasks, not just the main loop.
** **
static SYN_Watchdog wdt;
static SYN_WDT_Entry entries[3];
syn_watchdog_init(&wdt, entries, 3, on_timeout, NULL);
int id0 = syn_watchdog_register(&wdt, "sensor", 5000); // 5s timeout
int id1 = syn_watchdog_register(&wdt, "comms", 2000);
// In each task:
syn_watchdog_checkin(&wdt, id0);
// In main loop:
syn_watchdog_update(&wdt);
Public Types Documentation¶
typedef SYN_WDT_TimeoutCallback¶
Called when a task misses its check-in deadline.
typedef void(* SYN_WDT_TimeoutCallback) (struct SYN_Watchdog *wdt, const SYN_WDT_Entry *entry, void *ctx);
Parameters:
wdtWatchdog instance.entryThe entry that timed out.ctxUser context.
Public Functions Documentation¶
function syn_watchdog_checkin¶
Check in a task (reset its timeout).
Parameters:
wdtWatchdog.idTask ID returned by syn_watchdog_register().
function syn_watchdog_init¶
Initialize the watchdog monitor.
void syn_watchdog_init (
SYN_Watchdog * wdt,
SYN_WDT_Entry * entries,
uint8_t capacity,
SYN_WDT_TimeoutCallback callback,
void * ctx
)
Parameters:
wdtWatchdog instance.entriesArray of entries (caller-owned).capacityMaximum number of monitored tasks.callbackTimeout handler.ctxContext for callback.
function syn_watchdog_register¶
Register a task for monitoring.
Parameters:
wdtWatchdog.nameTask name.timeout_msMaximum allowed time between check-ins.
Returns:
Task ID (index) for use with syn_watchdog_checkin(), or -1 if full.
function syn_watchdog_unregister¶
Unregister a task.
Parameters:
wdtWatchdog.idTask ID returned by syn_watchdog_register().
function syn_watchdog_update¶
Check all tasks for timeouts.
Call from your main loop or a periodic timer. If any task has exceeded its timeout, the callback is invoked.
Parameters:
wdtWatchdog instance.
The documentation for this class was generated from the following file src/syntropic/sched/syn_watchdog.h