Skip to content

Commit cfa99b3

Browse files
committed
Create a WD option that disables both watchdog and critical state. Useful for ground processes (e.g., mission server) that do not run in a satellite environment
1 parent a6153a6 commit cfa99b3

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

proclib.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ EVTHandler *PROC_evt(ProcessData *proc)
101101

102102
struct CSState *proc_get_cs_state(ProcessData *proc)
103103
{
104-
if (!proc)
104+
if (!proc || proc->wdMode == WD_NOTSAT)
105105
return NULL;
106106
return &proc->criticalState;
107107
}
@@ -353,7 +353,8 @@ ProcessData *PROC_init_xdr_hashsize(const char *procName, enum WatchdogMode wdMo
353353
// Register process with the s/w watchdog (make sure to send null byte!)
354354
PROC_wd_enable(proc);
355355

356-
critical_state_init(&proc->criticalState, proc->name);
356+
if (proc->wdMode != WD_NOTSAT)
357+
critical_state_init(&proc->criticalState, proc->name);
357358
#if TIME_TEST
358359
gettimeofday(&endTime, NULL);
359360
timersub(&endTime, &startTime, &totalTime);
@@ -364,7 +365,7 @@ ProcessData *PROC_init_xdr_hashsize(const char *procName, enum WatchdogMode wdMo
364365
}
365366

366367
void PROC_wd_enable(ProcessData *proc) {
367-
if (!proc->name || proc->wdMode == WD_DISABLED)
368+
if (!proc->name || proc->wdMode == WD_DISABLED || proc->wdMode == WD_NOTSAT)
368369
return;
369370

370371
if (proc->wdMode == WD_ENABLED)
@@ -385,7 +386,8 @@ void PROC_cleanup(ProcessData *proc)
385386
return;
386387

387388
cmd_cleanup_cb_state(proc->cmds, proc->evtHandler);
388-
critical_state_cleanup(&proc->criticalState);
389+
if (proc->wdMode != WD_NOTSAT)
390+
critical_state_cleanup(&proc->criticalState);
389391

390392
// Clear errno to prevent false errors
391393
errno = 0;

proclib.h

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ extern "C" {
4949

5050

5151
enum WatchdogMode {
52+
/// Constant for disabling the watchdog and critical state
53+
WD_NOTSAT = 3,
5254
/// Constant for enabling the XDR watchdog when initializing a process.
5355
WD_XDR = 2,
5456
/// Constant for enabling the watchdog when initializing a process.

0 commit comments

Comments
 (0)