diff --git a/include/sta/tacos/debug.hpp b/include/sta/tacos/debug.hpp new file mode 100644 index 0000000..b1df4c2 --- /dev/null +++ b/include/sta/tacos/debug.hpp @@ -0,0 +1,28 @@ +#ifndef STA_TACOS_DEBUG_HPP +#define STA_TACOS_DEBUG_HPP + +#include + +/** + * @defgroup tacos_debugging TACOS Debugging + * @brief Functions and classes that are used to debugging TACOS. + * + * @details This module contains all functions and classes that are used for debugging TACOS. This is mostly used for writing automated tests. + */ + +namespace sta +{ + namespace tacos + { +#ifdef STA_TACOS_WATCHDOG_ENABLED + /** + * @return uint16_t Returns the number thread restarts performed by the watchdog. Can be used for debugging and testing. + * + * @ingroup tacos_debugging + */ + uint16_t getNumThreadRestarts(); +#endif // STA_TACOS_WATCHDOG_ENABLED + } // namespace tacos +} // namespace sta + +#endif // STA_TACOS_DEBUG_HPP \ No newline at end of file diff --git a/include/sta/tacos/thread.hpp b/include/sta/tacos/thread.hpp index 8291c93..82a07dd 100644 --- a/include/sta/tacos/thread.hpp +++ b/include/sta/tacos/thread.hpp @@ -27,6 +27,7 @@ namespace sta /** * @brief A status flags for the watchdog. * + * @ingroup tacos_thread */ enum class ThreadStatus { @@ -137,13 +138,14 @@ namespace sta protected: /** - * @brief + * @brief Sends a heartbeat signal by setting the thread status to RUNNING * */ void heartbeat(); /** - * @brief Set the thread's status to waiting. Should be called before executing + * @brief Set the thread's status to waiting. This can called before executing code which is very likely + * to exceed a watchdog cycle. This stops the watchdog from restarting the thread. * */ void waiting(); @@ -151,7 +153,7 @@ namespace sta /** * @brief Get the current status of the thread. * - * @return ThreadStatus + * @return ThreadStatus The current status of the thread. */ ThreadStatus getStatus(); diff --git a/include/sta/tacos/watchdog.hpp b/include/sta/tacos/watchdog.hpp index 5953c57..ca0b103 100644 --- a/include/sta/tacos/watchdog.hpp +++ b/include/sta/tacos/watchdog.hpp @@ -16,6 +16,12 @@ #include +/** + * @defgroup tacos_watchdog Watchdog Task + * @ingroup tacos + * @brief Watchdog class for TACOS. + */ + namespace sta { namespace tacos @@ -23,6 +29,7 @@ namespace sta /** * @brief Watchdog class for TACOS using singleton pattern. * + * @ingroup tacos_watchdog */ class Watchdog: public TacosThread { @@ -30,7 +37,7 @@ namespace sta /** * @brief Getter for the singleton instance. Constructs the instance if no exists. * - * @return Watchdog* + * @ingroup tacos_watchdog */ static Watchdog* instance() { diff --git a/src/debug.cpp b/src/debug.cpp new file mode 100644 index 0000000..43552c6 --- /dev/null +++ b/src/debug.cpp @@ -0,0 +1,15 @@ +#include + + +namespace sta +{ + namespace tacos + { +#ifdef STA_TACOS_WATCHDOG_ENABLED + uint16_t getNumThreadRestarts() + { + return Watchdog::instance()->getNumRestarts(); + } +#endif // STA_TACOS_WATCHDOG_ENABLED + } // namespace tacos +} // namespace sta