From 86b72a2efd2ad1affc7f91ca79e08c617424219d Mon Sep 17 00:00:00 2001 From: dario Date: Wed, 9 Oct 2024 16:09:37 +0200 Subject: [PATCH] Updated SPATZ to ignore TICK() when disabled --- include/sta/debug/spatz.hpp | 4 +++- src/debug/spatz.cpp | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/sta/debug/spatz.hpp b/include/sta/debug/spatz.hpp index 1d71f4a..d80832a 100644 --- a/include/sta/debug/spatz.hpp +++ b/include/sta/debug/spatz.hpp @@ -45,7 +45,7 @@ namespace sta * @param buffer The float buffer to write the data to. * @param length The number of floats to request. */ - void request(uint8_t id, float * buffer, size_t length); + bool request(uint8_t id, float * buffer, size_t length); /** * @brief Request doubles for a specific sensor id via the printable. @@ -80,6 +80,8 @@ namespace sta #define STA_SPATZ_INIT(mutex, signal) ((void)0) +#define STA_SPATZ_TICK() ((void)0) + #endif // STA_SPATZ_ENABLED #endif // STA_CORE_SPATZ_HPP diff --git a/src/debug/spatz.cpp b/src/debug/spatz.cpp index 11318e3..6488ba0 100644 --- a/src/debug/spatz.cpp +++ b/src/debug/spatz.cpp @@ -47,15 +47,20 @@ namespace sta mutex_->release(); } - void request(uint8_t id, float * buffer, size_t length) + bool request(uint8_t id, float * buffer, size_t length) { mutex_->acquire(); HAL_UART_Receive_IT(&huart1, reinterpret_cast(buffer), length * sizeof(float)); Debug->printf("%d", id); - signal_->wait(0x01, 100); + if (signal_->wait(0x01, 100) != 0x01) + { + mutex_->release(); + return false; + } mutex_->release(); + return true; } void request(uint8_t id, double * buffer, size_t length)