Created debug.hpp and fixed doxygen

This commit is contained in:
dario 2024-02-14 13:36:21 +01:00
parent 801408e371
commit f11a6fd5f7
4 changed files with 56 additions and 4 deletions

View File

@ -0,0 +1,28 @@
#ifndef STA_TACOS_DEBUG_HPP
#define STA_TACOS_DEBUG_HPP
#include <sta/tacos/watchdog.hpp>
/**
* @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

View File

@ -27,6 +27,7 @@ namespace sta
/** /**
* @brief A status flags for the watchdog. * @brief A status flags for the watchdog.
* *
* @ingroup tacos_thread
*/ */
enum class ThreadStatus enum class ThreadStatus
{ {
@ -137,13 +138,14 @@ namespace sta
protected: protected:
/** /**
* @brief * @brief Sends a heartbeat signal by setting the thread status to RUNNING
* *
*/ */
void heartbeat(); 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(); void waiting();
@ -151,7 +153,7 @@ namespace sta
/** /**
* @brief Get the current status of the thread. * @brief Get the current status of the thread.
* *
* @return ThreadStatus * @return ThreadStatus The current status of the thread.
*/ */
ThreadStatus getStatus(); ThreadStatus getStatus();

View File

@ -16,6 +16,12 @@
#include <sta/tacos/thread.hpp> #include <sta/tacos/thread.hpp>
/**
* @defgroup tacos_watchdog Watchdog Task
* @ingroup tacos
* @brief Watchdog class for TACOS.
*/
namespace sta namespace sta
{ {
namespace tacos namespace tacos
@ -23,6 +29,7 @@ namespace sta
/** /**
* @brief Watchdog class for TACOS using singleton pattern. * @brief Watchdog class for TACOS using singleton pattern.
* *
* @ingroup tacos_watchdog
*/ */
class Watchdog: public TacosThread class Watchdog: public TacosThread
{ {
@ -30,7 +37,7 @@ namespace sta
/** /**
* @brief Getter for the singleton instance. Constructs the instance if no exists. * @brief Getter for the singleton instance. Constructs the instance if no exists.
* *
* @return Watchdog* * @ingroup tacos_watchdog
*/ */
static Watchdog* instance() static Watchdog* instance()
{ {

15
src/debug.cpp Normal file
View File

@ -0,0 +1,15 @@
#include <sta/tacos/debug.hpp>
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