#ifndef WATCHDOG_WATCHDOG_H_ #define WATCHDOG_WATCHDOG_H_ #include #include #include 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 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_ */