From 7129ea67bdf4c85d496a22c692a84f0f7a6ede97 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 9 Jan 2021 16:06:54 +0100 Subject: [PATCH] linux fixes --- osal/linux/BinarySemaphore.cpp | 20 +++++++++++++------- osal/linux/CountingSemaphore.cpp | 4 +++- osal/linux/MessageQueue.cpp | 14 ++++++++------ osal/linux/TcUnixUdpPollingTask.cpp | 2 ++ osal/linux/TmTcUnixUdpBridge.cpp | 8 ++++++-- 5 files changed, 32 insertions(+), 16 deletions(-) diff --git a/osal/linux/BinarySemaphore.cpp b/osal/linux/BinarySemaphore.cpp index 0a6bb29f..c2eb8514 100644 --- a/osal/linux/BinarySemaphore.cpp +++ b/osal/linux/BinarySemaphore.cpp @@ -1,10 +1,11 @@ #include "BinarySemaphore.h" +#include "../../serviceinterface/ServiceInterfacePrinter.h" #include "../../serviceinterface/ServiceInterfaceStream.h" -extern "C" { +#include #include #include -} + BinarySemaphore::BinarySemaphore() { // Using unnamed semaphores for now @@ -113,7 +114,8 @@ uint8_t BinarySemaphore::getSemaphoreCounter(sem_t *handle) { } else if(result != 0 and errno == EINVAL) { // Could be called from interrupt, use lightweight printf - printf("BinarySemaphore::getSemaphoreCounter: Invalid semaphore\n"); + fsfw::printError("BinarySemaphore::getSemaphoreCounter: " + "Invalid semaphore\n"); return 0; } else { @@ -128,13 +130,17 @@ void BinarySemaphore::initSemaphore(uint8_t initCount) { switch(errno) { case(EINVAL): // Value exceeds SEM_VALUE_MAX - case(ENOSYS): - // System does not support process-shared semaphores + case(ENOSYS): { + // System does not support process-shared semaphores #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "BinarySemaphore: Init failed with" << strerror(errno) - << std::endl; + sif::error << "BinarySemaphore: Init failed with " + << strerror(errno) << std::endl; +#else + fsfw::printError("BinarySemaphore: Init failed with %s\n", + strerror(errno)); #endif } + } } } diff --git a/osal/linux/CountingSemaphore.cpp b/osal/linux/CountingSemaphore.cpp index 0bb71831..07c52212 100644 --- a/osal/linux/CountingSemaphore.cpp +++ b/osal/linux/CountingSemaphore.cpp @@ -1,5 +1,7 @@ #include "../../osal/linux/CountingSemaphore.h" -#include "../../serviceinterface/ServiceInterfaceStream.h" +#include "../../serviceinterface/ServiceInterface.h" + +#include CountingSemaphore::CountingSemaphore(const uint8_t maxCount, uint8_t initCount): maxCount(maxCount), initCount(initCount) { diff --git a/osal/linux/MessageQueue.cpp b/osal/linux/MessageQueue.cpp index e7b09b4f..d93b7f6d 100644 --- a/osal/linux/MessageQueue.cpp +++ b/osal/linux/MessageQueue.cpp @@ -1,5 +1,5 @@ #include "MessageQueue.h" -#include "../../serviceinterface/ServiceInterfaceStream.h" +#include "../../serviceinterface/ServiceInterface.h" #include "../../objectmanager/ObjectManagerIF.h" #include @@ -121,14 +121,16 @@ ReturnValue_t MessageQueue::handleError(mq_attr* attributes, break; } - default: + default: { // Failed either the first time or the second time #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "MessageQueue::MessageQueue: Creating Queue " << std::hex - << name << std::dec << " failed with status: " - << strerror(errno) << std::endl; + sif::error << "MessageQueue::MessageQueue: Creating Queue " << name + << " failed with status: " << strerror(errno) << std::endl; +#else + fsfw::printError("MessageQueue::MessageQueue: Creating Queue %s" + " failed with status: %s\n", name, strerror(errno)); #endif - + } } return HasReturnvaluesIF::RETURN_FAILED; diff --git a/osal/linux/TcUnixUdpPollingTask.cpp b/osal/linux/TcUnixUdpPollingTask.cpp index a8387e87..11ed7fee 100644 --- a/osal/linux/TcUnixUdpPollingTask.cpp +++ b/osal/linux/TcUnixUdpPollingTask.cpp @@ -1,6 +1,8 @@ #include "TcUnixUdpPollingTask.h" #include "../../globalfunctions/arrayprinter.h" +#include + TcUnixUdpPollingTask::TcUnixUdpPollingTask(object_id_t objectId, object_id_t tmtcUnixUdpBridge, size_t frameSize, double timeoutSeconds): SystemObject(objectId), diff --git a/osal/linux/TmTcUnixUdpBridge.cpp b/osal/linux/TmTcUnixUdpBridge.cpp index 1d318d3b..0bedce0f 100644 --- a/osal/linux/TmTcUnixUdpBridge.cpp +++ b/osal/linux/TmTcUnixUdpBridge.cpp @@ -1,5 +1,5 @@ #include "TmTcUnixUdpBridge.h" -#include "../../serviceinterface/ServiceInterfaceStream.h" +#include "../../serviceinterface/ServiceInterface.h" #include "../../ipc/MutexHelper.h" #include @@ -188,12 +188,16 @@ void TmTcUnixUdpBridge::handleBindError() { void TmTcUnixUdpBridge::handleSendError() { switch(errno) { - default: + default: { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcUnixBridge::handleSendError: " << strerror(errno) << std::endl; +#else + fsfw::printError("TmTcUnixBridge::handleSendError: %s\n", + strerror(errno)); #endif } + } } void TmTcUnixUdpBridge::setClientAddressToAny(bool ipAddrAnySet){