From 03b1e799ea39028b38e802c595ec54f6ca05e2a4 Mon Sep 17 00:00:00 2001 From: Wellington Castro Date: Tue, 17 Dec 2024 13:49:08 -0300 Subject: [PATCH 1/2] fix: read once per update hook if cmd_in frequency is higher than communication frequency this can result in an endless update hook --- tasks/Task.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/Task.cpp b/tasks/Task.cpp index 70cc056..3ca4c61 100644 --- a/tasks/Task.cpp +++ b/tasks/Task.cpp @@ -161,7 +161,7 @@ void Task::publishFault() } void Task::updateHook() { - while (_cmd_in.read(m_cmd_in) == RTT::NewData) { + if (_cmd_in.read(m_cmd_in) == RTT::NewData) { if (m_cmd_in.elements.size() != 1) { return exception(INVALID_COMMAND_SIZE); } From af0c7f8ccb42c79700414207b9b33fcd751bbaa1 Mon Sep 17 00:00:00 2001 From: Wellington Castro Date: Tue, 17 Dec 2024 13:49:49 -0300 Subject: [PATCH 2/2] chore: do base updateHook first --- tasks/Task.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/Task.cpp b/tasks/Task.cpp index 3ca4c61..9814014 100644 --- a/tasks/Task.cpp +++ b/tasks/Task.cpp @@ -161,6 +161,8 @@ void Task::publishFault() } void Task::updateHook() { + TaskBase::updateHook(); + if (_cmd_in.read(m_cmd_in) == RTT::NewData) { if (m_cmd_in.elements.size() != 1) { return exception(INVALID_COMMAND_SIZE); @@ -185,8 +187,6 @@ void Task::updateHook() auto state = readAndPublishControllerStates(); evaluateInverterStatus(state.inverter_status); - - TaskBase::updateHook(); } void Task::processIO() {