eive-obsw/watchdog/Watchdog.h

51 lines
976 B
C++

#ifndef WATCHDOG_WATCHDOG_H_
#define WATCHDOG_WATCHDOG_H_
#include <array>
#include <cstdint>
#include <string>
class WatchdogTask {
public:
enum class States {
NOT_STARTED,
RUNNING,
SUSPENDED,
FAULTY
};
enum class LoopResult {
OK,
SUSPEND_RQ,
CANCEL_RQ,
RESTART_RQ,
TIMEOUT,
HUNG_UP,
FAULT
};
WatchdogTask();
virtual ~WatchdogTask();
int performOperation();
private:
int fd = 0;
bool obswRunning = false;
bool watchdogRunning = false;
bool printNotRunningLatch = false;
std::array<uint8_t, 64> buf;
States state = States::NOT_STARTED;
LoopResult watchdogLoop();
LoopResult pollEvent(struct pollfd& waiter);
LoopResult parseCommandByte(ssize_t readLen);
int performRunningOperation();
int performNotRunningOperation(LoopResult type);
int performSuspendOperation();
};
#endif /* WATCHDOG_WATCHDOG_H_ */