From c688f089669ce3ef28a2358351445e2de5f12fe7 Mon Sep 17 00:00:00 2001 From: CarlWachter Date: Mon, 11 Mar 2024 14:42:35 +0100 Subject: [PATCH] can task --- App/Src/tasks/can_task.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/App/Src/tasks/can_task.cpp b/App/Src/tasks/can_task.cpp index 2212da7..9bf7983 100644 --- a/App/Src/tasks/can_task.cpp +++ b/App/Src/tasks/can_task.cpp @@ -10,6 +10,7 @@ #include #include "can.h" #include +#include #include @@ -27,15 +28,13 @@ namespace tasks void CanTask::func() { - if (CAN_queue_.available() > 0) + CanSysMsg msg; + if (CAN_queue_.get(&msg, osWaitForever)) { - // Receiving message - CanSysMsg msg; - CAN_queue_.get(&msg); // Interpret received uint8_t type_id, sensor_ID, value, include; - unpackValues(canRX[0], &type_id, &sensor_ID, &value, &include); + unpackValues(msg.payload[0], &type_id, &sensor_ID, &value, &include); // Reformat for internal use msg.header.payloadLength = 2; @@ -60,9 +59,9 @@ namespace tasks } // Append to the correct thread's queue - for (std::shared_ptr thread : Manager::instance()->getActiveThreads()){ + for (std::shared_ptr thread : sta::tacos::Manager::instance()->getActiveThreads()){ if (thread->getCanID() == target_ID){ - thread->CAN_queue_.put(sysMsg); + thread->CAN_queue_.put(msg); break; } }