mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/TACOS.git
synced 2025-08-06 01:37:33 +00:00
Combined watchdog code with latest changes.
This commit is contained in:
@@ -22,6 +22,45 @@ namespace sta
|
||||
{
|
||||
namespace tacos
|
||||
{
|
||||
/**
|
||||
* @brief A status flags for the watchdog.
|
||||
*
|
||||
*/
|
||||
enum class ThreadStatus
|
||||
{
|
||||
/**
|
||||
* @brief This thread wants to be ignored by the watchdog.
|
||||
*
|
||||
*/
|
||||
IGNORED,
|
||||
|
||||
/**
|
||||
* @brief The thread terminated regularly. The watchdog will not try to restart this thread.
|
||||
*
|
||||
*/
|
||||
STOPPED,
|
||||
|
||||
/**
|
||||
* @brief The thread's status is unknown. If the watchdog encounters this status, it will try to
|
||||
* restart the affected thread.
|
||||
*
|
||||
*/
|
||||
UNKNOWN,
|
||||
|
||||
/**
|
||||
* @brief The thread is running as intended. The watchdog will set this flag back to UNKNOWN.
|
||||
*
|
||||
*/
|
||||
RUNNING,
|
||||
|
||||
/**
|
||||
* @brief The thread is waiting and might not send a heartbeat signal in a while. The watchdog will
|
||||
* not do anything in this case.
|
||||
*
|
||||
*/
|
||||
WAITING
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Abstract class for thread implementations in Tacos.
|
||||
*
|
||||
@@ -97,8 +136,37 @@ namespace sta
|
||||
*/
|
||||
virtual void cleanup();
|
||||
|
||||
private:
|
||||
#ifdef STA_TACOS_WATCHDOG_ENABLED
|
||||
#define BLOCKING(stmt) waiting(); stmt heartbeat()
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
void heartbeat();
|
||||
|
||||
/**
|
||||
* @brief Set the thread's status to waiting. Should be called before executing
|
||||
*
|
||||
*/
|
||||
void waiting();
|
||||
public:
|
||||
/**
|
||||
* @brief Get the current status of the thread.
|
||||
*
|
||||
* @return ThreadStatus
|
||||
*/
|
||||
ThreadStatus getStatus();
|
||||
|
||||
/**
|
||||
* @brief Reset the thread's status to UNKNOWN. Should only be called by the Watchdog.
|
||||
*
|
||||
*/
|
||||
void resetStatus();
|
||||
#endif // STA_TACOS_WATCHDOG_ENABLED
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Static function to pass to RTOS to run as a thread. Calls the loop function implemented here.
|
||||
*/
|
||||
@@ -108,6 +176,9 @@ namespace sta
|
||||
osThreadId_t instance_;
|
||||
osThreadAttr_t attribs_;
|
||||
bool running_;
|
||||
#ifdef STA_TACOS_WATCHDOG_ENABLED
|
||||
ThreadStatus status_;
|
||||
#endif // STA_TACOS_WATCHDOG_ENABLED
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user