From 2617521444c6c98af187736a405827d205ec8a09 Mon Sep 17 00:00:00 2001 From: dario Date: Wed, 7 Feb 2024 17:04:19 +0100 Subject: [PATCH] Fixed thread starting to work correctly --- include/sta/tacos/thread.hpp | 4 ++++ src/thread.cpp | 24 ++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/include/sta/tacos/thread.hpp b/include/sta/tacos/thread.hpp index 8517c77..842b27e 100644 --- a/include/sta/tacos/thread.hpp +++ b/include/sta/tacos/thread.hpp @@ -89,6 +89,8 @@ namespace sta void loop() override; + void start() override; + /** * @brief This function is executed first when this thread is started. */ @@ -149,6 +151,8 @@ namespace sta * */ void resetStatus(); + + void watchdogIgnore(); #endif // STA_TACOS_WATCHDOG_ENABLED /** diff --git a/src/thread.cpp b/src/thread.cpp index 0f4ebda..35175e0 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -33,6 +33,18 @@ namespace sta return running_; } + void TacosThread::start() + { + if (getInstance() == NULL) + { + RtosThread::start(); + } + else + { + sysNotify(STA_RTOS_THREAD_FLAG_START); + } + } + void TacosThread::init() {} void TacosThread::loop() @@ -54,8 +66,11 @@ namespace sta while (!isTerminationRequested()) { #ifdef STA_TACOS_WATCHDOG_ENABLED - // Send a fresh heartbeat signal. - heartbeat(); + if (status_ == ThreadStatus::UNKNOWN) + { + // Send a fresh heartbeat signal. + heartbeat(); + } #endif // STA_TACOS_WATCHDOG_ENABLED // Execute user-space implementation. @@ -111,6 +126,11 @@ namespace sta { status_ = ThreadStatus::UNKNOWN; } + + void TacosThread::watchdogIgnore() + { + status_ = ThreadStatus::IGNORED; + } #endif // STA_TACOS_WATCHDOG_ENABLED void TacosThread::requestTermination()