eive-obsw/watchdog/Watchdog.h

50 lines
940 B
C
Raw Normal View History

2021-07-29 11:35:20 +02:00
#ifndef WATCHDOG_WATCHDOG_H_
#define WATCHDOG_WATCHDOG_H_
#include <array>
class WatchdogTask {
public:
enum class States {
NOT_STARTED,
RUNNING,
SUSPENDED,
FAULTY
};
enum class LoopResult {
OK,
2021-07-29 16:31:04 +02:00
SUSPEND_RQ,
2021-07-29 11:35:20 +02:00
CANCEL_RQ,
RESTART_RQ,
2021-07-29 16:31:04 +02:00
TIMEOUT,
2021-07-29 18:09:54 +02:00
HUNG_UP,
2021-07-29 16:31:04 +02:00
FAULT
2021-07-29 11:35:20 +02:00
};
WatchdogTask();
virtual ~WatchdogTask();
int performOperation();
private:
int fd = 0;
2021-07-29 16:31:04 +02:00
bool obswRunning = false;
bool watchdogRunning = false;
2021-07-29 18:09:54 +02:00
bool printNotRunningLatch = false;
2021-07-29 11:35:20 +02:00
std::array<uint8_t, 64> buf;
States state = States::NOT_STARTED;
LoopResult watchdogLoop();
2021-07-29 16:31:04 +02:00
LoopResult pollEvent(struct pollfd& waiter);
LoopResult parseCommandByte(ssize_t readLen);
int performRunningOperation();
2021-07-29 18:09:54 +02:00
int performNotRunningOperation(LoopResult type);
2021-07-29 17:21:27 +02:00
int performSuspendOperation();
2021-07-29 11:35:20 +02:00
};
#endif /* WATCHDOG_WATCHDOG_H_ */