From 350488483695bef8aa81c008d0960465a944e848 Mon Sep 17 00:00:00 2001 From: Thomas Basler Date: Fri, 28 Apr 2023 21:02:10 +0200 Subject: [PATCH] Fix: xSemaphoreTake was useless There was no check of the return value implemented therefore xSemaphoreTake was just executed and not locked --- lib/Hoymiles/src/Hoymiles.cpp | 4 +++- src/MessageOutput.cpp | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/Hoymiles/src/Hoymiles.cpp b/lib/Hoymiles/src/Hoymiles.cpp index 3a9999ff..29b239af 100644 --- a/lib/Hoymiles/src/Hoymiles.cpp +++ b/lib/Hoymiles/src/Hoymiles.cpp @@ -12,7 +12,9 @@ #include "inverters/HM_4CH.h" #include -#define HOY_SEMAPHORE_TAKE() xSemaphoreTake(_xSemaphore, portMAX_DELAY) +#define HOY_SEMAPHORE_TAKE() \ + do { \ + } while (xSemaphoreTake(_xSemaphore, portMAX_DELAY) != pdPASS) #define HOY_SEMAPHORE_GIVE() xSemaphoreGive(_xSemaphore) HoymilesClass Hoymiles; diff --git a/src/MessageOutput.cpp b/src/MessageOutput.cpp index 2a84816b..dc9c6715 100644 --- a/src/MessageOutput.cpp +++ b/src/MessageOutput.cpp @@ -8,7 +8,9 @@ MessageOutputClass MessageOutput; -#define MSG_LOCK() xSemaphoreTake(_lock, portMAX_DELAY) +#define MSG_LOCK() \ + do { \ + } while (xSemaphoreTake(_lock, portMAX_DELAY) != pdPASS) #define MSG_UNLOCK() xSemaphoreGive(_lock) MessageOutputClass::MessageOutputClass() @@ -45,7 +47,7 @@ void MessageOutputClass::loop() _ws->textAll(_buffer, _buff_pos); _buff_pos = 0; } - if(_forceSend) { + if (_forceSend) { _buff_pos = 0; } MSG_UNLOCK();