From 44dcd3104eae56157adee88e0ecbd8712fe86881 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Wed, 30 Dec 2020 22:01:11 +0100 Subject: [PATCH 01/50] device handler base update --- devicehandlers/DeviceHandlerBase.cpp | 19 +++++++++++-------- devicehandlers/DeviceHandlerBase.h | 4 ++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index d0630854..efee1462 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -16,8 +16,8 @@ #include -object_id_t DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT; -object_id_t DeviceHandlerBase::rawDataReceiverId = objects::NO_OBJECT; +object_id_t DeviceHandlerBase::defaultPowerSwitcherId = objects::NO_OBJECT; +object_id_t DeviceHandlerBase::defaultRawDataReceiverId = objects::NO_OBJECT; object_id_t DeviceHandlerBase::defaultFdirParentId = objects::NO_OBJECT; DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId, @@ -151,9 +151,9 @@ ReturnValue_t DeviceHandlerBase::initialize() { return ObjectManagerIF::CHILD_INIT_FAILED; } - if(rawDataReceiverId != objects::NO_OBJECT) { + if(defaultRawDataReceiverId != objects::NO_OBJECT) { AcceptsDeviceResponsesIF *rawReceiver = objectManager->get< - AcceptsDeviceResponsesIF>(rawDataReceiverId); + AcceptsDeviceResponsesIF>(defaultRawDataReceiverId); if (rawReceiver == nullptr) { sif::error << "DeviceHandlerBase::initialize: Raw receiver object " @@ -165,8 +165,9 @@ ReturnValue_t DeviceHandlerBase::initialize() { defaultRawReceiver = rawReceiver->getDeviceQueue(); } - if(powerSwitcherId != objects::NO_OBJECT) { - powerSwitcher = objectManager->get(powerSwitcherId); + if(defaultPowerSwitcherId != objects::NO_OBJECT) { + powerSwitcher = objectManager->get( + defaultPowerSwitcherId); if (powerSwitcher == nullptr) { sif::error << "DeviceHandlerBase::initialize: Power switcher " << "object ID set but no valid object found." << std::endl; @@ -682,8 +683,10 @@ void DeviceHandlerBase::doGetRead() { replyRawData(receivedData, receivedDataLen, requestedRawTraffic); } - if (mode == MODE_RAW and defaultRawReceiver != MessageQueueIF::NO_QUEUE) { - replyRawReplyIfnotWiretapped(receivedData, receivedDataLen); + if (mode == MODE_RAW) { + if(defaultRawReceiver != MessageQueueIF::NO_QUEUE) { + replyRawReplyIfnotWiretapped(receivedData, receivedDataLen); + } } else { parseReply(receivedData, receivedDataLen); diff --git a/devicehandlers/DeviceHandlerBase.h b/devicehandlers/DeviceHandlerBase.h index 24ba0372..0d14bf4e 100644 --- a/devicehandlers/DeviceHandlerBase.h +++ b/devicehandlers/DeviceHandlerBase.h @@ -739,10 +739,10 @@ protected: PeriodicTaskIF* executingTask = nullptr; //!< Object which switches power on and off. - static object_id_t powerSwitcherId; + static object_id_t defaultPowerSwitcherId; //!< Object which receives RAW data by default. - static object_id_t rawDataReceiverId; + static object_id_t defaultRawDataReceiverId; //!< Object which may be the root cause of an identified fault. static object_id_t defaultFdirParentId; From 56eac4647265deb8b115eb1c970a0b81153a03cc Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Wed, 30 Dec 2020 22:17:08 +0100 Subject: [PATCH 02/50] Revert "device handler base update" This reverts commit 44dcd3104eae56157adee88e0ecbd8712fe86881. --- devicehandlers/DeviceHandlerBase.cpp | 19 ++++++++----------- devicehandlers/DeviceHandlerBase.h | 4 ++-- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index efee1462..d0630854 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -16,8 +16,8 @@ #include -object_id_t DeviceHandlerBase::defaultPowerSwitcherId = objects::NO_OBJECT; -object_id_t DeviceHandlerBase::defaultRawDataReceiverId = objects::NO_OBJECT; +object_id_t DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT; +object_id_t DeviceHandlerBase::rawDataReceiverId = objects::NO_OBJECT; object_id_t DeviceHandlerBase::defaultFdirParentId = objects::NO_OBJECT; DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId, @@ -151,9 +151,9 @@ ReturnValue_t DeviceHandlerBase::initialize() { return ObjectManagerIF::CHILD_INIT_FAILED; } - if(defaultRawDataReceiverId != objects::NO_OBJECT) { + if(rawDataReceiverId != objects::NO_OBJECT) { AcceptsDeviceResponsesIF *rawReceiver = objectManager->get< - AcceptsDeviceResponsesIF>(defaultRawDataReceiverId); + AcceptsDeviceResponsesIF>(rawDataReceiverId); if (rawReceiver == nullptr) { sif::error << "DeviceHandlerBase::initialize: Raw receiver object " @@ -165,9 +165,8 @@ ReturnValue_t DeviceHandlerBase::initialize() { defaultRawReceiver = rawReceiver->getDeviceQueue(); } - if(defaultPowerSwitcherId != objects::NO_OBJECT) { - powerSwitcher = objectManager->get( - defaultPowerSwitcherId); + if(powerSwitcherId != objects::NO_OBJECT) { + powerSwitcher = objectManager->get(powerSwitcherId); if (powerSwitcher == nullptr) { sif::error << "DeviceHandlerBase::initialize: Power switcher " << "object ID set but no valid object found." << std::endl; @@ -683,10 +682,8 @@ void DeviceHandlerBase::doGetRead() { replyRawData(receivedData, receivedDataLen, requestedRawTraffic); } - if (mode == MODE_RAW) { - if(defaultRawReceiver != MessageQueueIF::NO_QUEUE) { - replyRawReplyIfnotWiretapped(receivedData, receivedDataLen); - } + if (mode == MODE_RAW and defaultRawReceiver != MessageQueueIF::NO_QUEUE) { + replyRawReplyIfnotWiretapped(receivedData, receivedDataLen); } else { parseReply(receivedData, receivedDataLen); diff --git a/devicehandlers/DeviceHandlerBase.h b/devicehandlers/DeviceHandlerBase.h index 0d14bf4e..24ba0372 100644 --- a/devicehandlers/DeviceHandlerBase.h +++ b/devicehandlers/DeviceHandlerBase.h @@ -739,10 +739,10 @@ protected: PeriodicTaskIF* executingTask = nullptr; //!< Object which switches power on and off. - static object_id_t defaultPowerSwitcherId; + static object_id_t powerSwitcherId; //!< Object which receives RAW data by default. - static object_id_t defaultRawDataReceiverId; + static object_id_t rawDataReceiverId; //!< Object which may be the root cause of an identified fault. static object_id_t defaultFdirParentId; From 0a4d0b593713e61b7ddf47ecb4b1657d8a0a8674 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Wed, 30 Dec 2020 22:34:40 +0100 Subject: [PATCH 03/50] bugfix --- devicehandlers/DeviceHandlerBase.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index d0630854..251320cb 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -682,8 +682,10 @@ void DeviceHandlerBase::doGetRead() { replyRawData(receivedData, receivedDataLen, requestedRawTraffic); } - if (mode == MODE_RAW and defaultRawReceiver != MessageQueueIF::NO_QUEUE) { - replyRawReplyIfnotWiretapped(receivedData, receivedDataLen); + if (mode == MODE_RAW) { + if (defaultRawReceiver != MessageQueueIF::NO_QUEUE) { + replyRawReplyIfnotWiretapped(receivedData, receivedDataLen); + } } else { parseReply(receivedData, receivedDataLen); From c4fb1f49d813a97113099d4c6e257d5606955182 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Wed, 30 Dec 2020 22:56:46 +0100 Subject: [PATCH 04/50] updated defaultcfg --- defaultcfg/fsfwconfig/CMakeLists.txt | 21 +++++++------- .../fsfwconfig/devices/logicalAddresses.cpp | 5 ---- .../fsfwconfig/devices/logicalAddresses.h | 2 +- .../fsfwconfig/devices/powerSwitcherList.cpp | 4 --- .../objects/{Factory.cpp => FsfwFactory.cpp} | 29 +++++++++---------- .../objects/{Factory.h => FsfwFactory.h} | 2 +- 6 files changed, 26 insertions(+), 37 deletions(-) delete mode 100644 defaultcfg/fsfwconfig/devices/logicalAddresses.cpp delete mode 100644 defaultcfg/fsfwconfig/devices/powerSwitcherList.cpp rename defaultcfg/fsfwconfig/objects/{Factory.cpp => FsfwFactory.cpp} (60%) rename defaultcfg/fsfwconfig/objects/{Factory.h => FsfwFactory.h} (91%) diff --git a/defaultcfg/fsfwconfig/CMakeLists.txt b/defaultcfg/fsfwconfig/CMakeLists.txt index b8b41c93..4b8f4474 100644 --- a/defaultcfg/fsfwconfig/CMakeLists.txt +++ b/defaultcfg/fsfwconfig/CMakeLists.txt @@ -1,15 +1,14 @@ -target_sources(${TARGET_NAME} - PRIVATE +target_sources(${LIB_FSFW_NAME} PRIVATE + ipc/missionMessageTypes.cpp + objects/FsfwFactory.cpp + pollingsequence/PollingSequenceFactory.cpp ) -# Add include paths for the executable -target_include_directories(${TARGET_NAME} - PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} +# Should be added to include path +target_include_directories(${TARGET_NAME} PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} ) -# Add include paths for the FSFW library -target_include_directories(${LIB_FSFW_NAME} - PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} -) \ No newline at end of file +if(NOT FSFW_CONFIG_PATH) + set(FSFW_CONFIG_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +endif() diff --git a/defaultcfg/fsfwconfig/devices/logicalAddresses.cpp b/defaultcfg/fsfwconfig/devices/logicalAddresses.cpp deleted file mode 100644 index c7ce314d..00000000 --- a/defaultcfg/fsfwconfig/devices/logicalAddresses.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "logicalAddresses.h" - - - - diff --git a/defaultcfg/fsfwconfig/devices/logicalAddresses.h b/defaultcfg/fsfwconfig/devices/logicalAddresses.h index e0827ba3..53edcd54 100644 --- a/defaultcfg/fsfwconfig/devices/logicalAddresses.h +++ b/defaultcfg/fsfwconfig/devices/logicalAddresses.h @@ -2,7 +2,7 @@ #define CONFIG_DEVICES_LOGICALADDRESSES_H_ #include -#include "../objects/systemObjectList.h" +#include #include /** diff --git a/defaultcfg/fsfwconfig/devices/powerSwitcherList.cpp b/defaultcfg/fsfwconfig/devices/powerSwitcherList.cpp deleted file mode 100644 index 343f78d0..00000000 --- a/defaultcfg/fsfwconfig/devices/powerSwitcherList.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include "powerSwitcherList.h" - - - diff --git a/defaultcfg/fsfwconfig/objects/Factory.cpp b/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp similarity index 60% rename from defaultcfg/fsfwconfig/objects/Factory.cpp rename to defaultcfg/fsfwconfig/objects/FsfwFactory.cpp index 41333b1c..428adf1d 100644 --- a/defaultcfg/fsfwconfig/objects/Factory.cpp +++ b/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp @@ -1,9 +1,5 @@ -#include "Factory.h" -#include "../tmtc/apid.h" -#include "../tmtc/pusIds.h" -#include "../objects/systemObjectList.h" -#include "../devices/logicalAddresses.h" -#include "../devices/powerSwitcherList.h" +#include "FsfwFactory.h" +#include #include #include @@ -11,24 +7,27 @@ #include #include #include -#include +#include #include /** - * This class should be used to create all system objects required for - * the on-board software, using the object ID list from the configuration - * folder. + * This function builds all system objects required for using + * the FSFW. It is recommended to build all other required objects + * in a function with an identical prototype, call this function in it and + * then pass the function to the object manager so it builds all system + * objects on software startup. * - * The objects are registered in the internal object manager automatically. - * This is used later to add objects to tasks. + * All system objects are registered in the internal object manager + * automatically. The objects should be added to tasks at a later stage, using + * their objects IDs. * - * This file also sets static framework IDs. + * This function also sets static framework IDs. * - * Framework objects are created first. + * Framework should be created first before creating mission system objects. * @ingroup init */ -void Factory::produce(void) { +void Factory::produceFsfwObjects(void) { setStaticFrameworkObjectIds(); new EventManager(objects::EVENT_MANAGER); new HealthTable(objects::HEALTH_TABLE); diff --git a/defaultcfg/fsfwconfig/objects/Factory.h b/defaultcfg/fsfwconfig/objects/FsfwFactory.h similarity index 91% rename from defaultcfg/fsfwconfig/objects/Factory.h rename to defaultcfg/fsfwconfig/objects/FsfwFactory.h index fe55deff..2724d2e3 100644 --- a/defaultcfg/fsfwconfig/objects/Factory.h +++ b/defaultcfg/fsfwconfig/objects/FsfwFactory.h @@ -9,7 +9,7 @@ namespace Factory { * @brief Creates all SystemObject elements which are persistent * during execution. */ - void produce(); + void produceFsfwObjects(); void setStaticFrameworkObjectIds(); } From 7b15a5a431b7a2b1c8d1cbdeffbf2431f0b37315 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Wed, 30 Dec 2020 22:57:52 +0100 Subject: [PATCH 05/50] moved includes --- defaultcfg/fsfwconfig/OBSWConfig.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/defaultcfg/fsfwconfig/OBSWConfig.h b/defaultcfg/fsfwconfig/OBSWConfig.h index 8ad2cb67..6ed8ea2c 100644 --- a/defaultcfg/fsfwconfig/OBSWConfig.h +++ b/defaultcfg/fsfwconfig/OBSWConfig.h @@ -3,11 +3,12 @@ #include "OBSWVersion.h" +#ifdef __cplusplus + #include "objects/systemObjectList.h" #include "events/subsystemIdRanges.h" #include "returnvalues/classIds.h" -#ifdef __cplusplus namespace config { #endif From 5be95fada76a6ea8ab24ed9d37d4f157a6910ac0 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Fri, 1 Jan 2021 17:18:37 +0100 Subject: [PATCH 06/50] bugfixes and RTEMS update for STM32 --- defaultcfg/fsfwconfig/CMakeLists.txt | 8 +++----- osal/rtems/CMakeLists.txt | 18 ++++++++++++++++++ osal/rtems/Clock.cpp | 5 ++++- osal/rtems/InternalErrorCodes.cpp | 2 ++ 4 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 osal/rtems/CMakeLists.txt diff --git a/defaultcfg/fsfwconfig/CMakeLists.txt b/defaultcfg/fsfwconfig/CMakeLists.txt index b8b41c93..c37d8ddd 100644 --- a/defaultcfg/fsfwconfig/CMakeLists.txt +++ b/defaultcfg/fsfwconfig/CMakeLists.txt @@ -8,8 +8,6 @@ target_include_directories(${TARGET_NAME} ${CMAKE_CURRENT_SOURCE_DIR} ) -# Add include paths for the FSFW library -target_include_directories(${LIB_FSFW_NAME} - PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} -) \ No newline at end of file +if(NOT DEFINED FSFW_CONFIG_DIRECTORY) + set(FSFW_CONFIG_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) +endif() \ No newline at end of file diff --git a/osal/rtems/CMakeLists.txt b/osal/rtems/CMakeLists.txt new file mode 100644 index 00000000..bff03184 --- /dev/null +++ b/osal/rtems/CMakeLists.txt @@ -0,0 +1,18 @@ +target_sources(${LIB_FSFW_NAME} + PRIVATE + Clock.cpp + CpuUsage.cpp + InitTask.cpp + InternalErrorCodes.cpp + MessageQueue.cpp + MultiObjectTask.cpp + Mutex.cpp + MutexFactory.cpp + PollingTask.cpp + QueueFactory.cpp + RtemsBasic.cpp + TaskBase.cpp + TaskFactory.cpp +) + + diff --git a/osal/rtems/Clock.cpp b/osal/rtems/Clock.cpp index e5f37ec6..aa135ade 100644 --- a/osal/rtems/Clock.cpp +++ b/osal/rtems/Clock.cpp @@ -1,5 +1,8 @@ -#include "../../timemanager/Clock.h" #include "RtemsBasic.h" + +#include "../../timemanager/Clock.h" +#include "../../ipc/MutexHelper.h" + #include uint16_t Clock::leapSeconds = 0; diff --git a/osal/rtems/InternalErrorCodes.cpp b/osal/rtems/InternalErrorCodes.cpp index ddf365d5..f4079814 100644 --- a/osal/rtems/InternalErrorCodes.cpp +++ b/osal/rtems/InternalErrorCodes.cpp @@ -34,8 +34,10 @@ ReturnValue_t InternalErrorCodes::translate(uint8_t code) { return OUT_OF_PROXIES; case INTERNAL_ERROR_INVALID_GLOBAL_ID: return INVALID_GLOBAL_ID; +#ifndef STM32H743ZI_NUCLEO case INTERNAL_ERROR_BAD_STACK_HOOK: return BAD_STACK_HOOK; +#endif // case INTERNAL_ERROR_BAD_ATTRIBUTES: // return BAD_ATTRIBUTES; // case INTERNAL_ERROR_IMPLEMENTATION_KEY_CREATE_INCONSISTENCY: From f223aa148edc13ee76ffc807b933a29cab92aae1 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Fri, 1 Jan 2021 18:05:02 +0100 Subject: [PATCH 07/50] updated cmake lists --- defaultcfg/fsfwconfig/CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/defaultcfg/fsfwconfig/CMakeLists.txt b/defaultcfg/fsfwconfig/CMakeLists.txt index 8c8d8086..cbd4ecde 100644 --- a/defaultcfg/fsfwconfig/CMakeLists.txt +++ b/defaultcfg/fsfwconfig/CMakeLists.txt @@ -9,6 +9,7 @@ target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ) -if(NOT DEFINED FSFW_CONFIG_DIRECTORY) - set(FSFW_CONFIG_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) +if(NOT FSFW_CONFIG_PATH) + set(FSFW_CONFIG_PATH ${CMAKE_CURRENT_SOURCE_DIR}) endif() + From ced753b513f65ed6948e4a3b048bb744b2c04805 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Fri, 1 Jan 2021 18:06:33 +0100 Subject: [PATCH 08/50] include guard --- defaultcfg/fsfwconfig/objects/FsfwFactory.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/defaultcfg/fsfwconfig/objects/FsfwFactory.h b/defaultcfg/fsfwconfig/objects/FsfwFactory.h index 2724d2e3..198b22f2 100644 --- a/defaultcfg/fsfwconfig/objects/FsfwFactory.h +++ b/defaultcfg/fsfwconfig/objects/FsfwFactory.h @@ -1,5 +1,5 @@ -#ifndef FACTORY_H_ -#define FACTORY_H_ +#ifndef FSFWCONFIG_OBJECTS_FACTORY_H_ +#define FSFWCONFIG_OBJECTS_FACTORY_H_ #include #include @@ -14,4 +14,4 @@ namespace Factory { } -#endif /* FACTORY_H_ */ +#endif /* FSFWCONFIG_OBJECTS_FACTORY_H_ */ From e5b3f991efbf74cd7d50c74ed774779b25b7c56c Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 2 Jan 2021 19:39:02 +0100 Subject: [PATCH 09/50] added important rtems include --- osal/rtems/Clock.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/osal/rtems/Clock.cpp b/osal/rtems/Clock.cpp index aa135ade..dda15464 100644 --- a/osal/rtems/Clock.cpp +++ b/osal/rtems/Clock.cpp @@ -4,6 +4,7 @@ #include "../../ipc/MutexHelper.h" #include +#include uint16_t Clock::leapSeconds = 0; MutexIF* Clock::timeMutex = nullptr; From 7759b19961a9892d9f1473c49fe64f450dee468d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 2 Jan 2021 23:22:50 +0100 Subject: [PATCH 10/50] added new files --- serviceinterface/CMakeLists.txt | 8 ++++---- serviceinterface/ServiceInterfacePrinter.cpp | 2 ++ serviceinterface/ServiceInterfacePrinter.h | 0 3 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 serviceinterface/ServiceInterfacePrinter.cpp create mode 100644 serviceinterface/ServiceInterfacePrinter.h diff --git a/serviceinterface/CMakeLists.txt b/serviceinterface/CMakeLists.txt index d84adbeb..84c79177 100644 --- a/serviceinterface/CMakeLists.txt +++ b/serviceinterface/CMakeLists.txt @@ -1,5 +1,5 @@ -target_sources(${LIB_FSFW_NAME} - PRIVATE - ServiceInterfaceStream.cpp - ServiceInterfaceBuffer.cpp +target_sources(${LIB_FSFW_NAME} PRIVATE + ServiceInterfaceStream.cpp + ServiceInterfaceBuffer.cpp + ServiceInterfacePrinter.cpp ) \ No newline at end of file diff --git a/serviceinterface/ServiceInterfacePrinter.cpp b/serviceinterface/ServiceInterfacePrinter.cpp new file mode 100644 index 00000000..4c4c28cb --- /dev/null +++ b/serviceinterface/ServiceInterfacePrinter.cpp @@ -0,0 +1,2 @@ +#include "ServiceInterfacePrinter.h" + diff --git a/serviceinterface/ServiceInterfacePrinter.h b/serviceinterface/ServiceInterfacePrinter.h new file mode 100644 index 00000000..e69de29b From b30405fee73317379f6c959adce720d5ba677a23 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 3 Jan 2021 01:02:07 +0100 Subject: [PATCH 11/50] added stdio pinters --- defaultcfg/fsfwconfig/FSFWConfig.h | 14 ++- serviceinterface/ServiceInterfaceBuffer.h | 3 +- serviceinterface/ServiceInterfacePrinter.cpp | 102 +++++++++++++++++++ serviceinterface/ServiceInterfacePrinter.h | 33 ++++++ 4 files changed, 149 insertions(+), 3 deletions(-) diff --git a/defaultcfg/fsfwconfig/FSFWConfig.h b/defaultcfg/fsfwconfig/FSFWConfig.h index e1815d05..d94f6cc7 100644 --- a/defaultcfg/fsfwconfig/FSFWConfig.h +++ b/defaultcfg/fsfwconfig/FSFWConfig.h @@ -4,14 +4,20 @@ #include #include -//! Used to determine whether C++ ostreams are used -//! Those can lead to code bloat. +//! Used to determine whether C++ ostreams are used which can increase +//! the binary size significantly. If this is disabled, +//! the C stdio functions can be used alternatively #define FSFW_CPP_OSTREAM_ENABLED 1 //! Reduced printout to further decrease code size //! Be careful, this also turns off most diagnostic prinouts! #define FSFW_ENHANCED_PRINTOUT 0 +//! Can be used to completely disable printouts, even the C stdio ones. +#if FSFW_CPP_OSTREAM_ENABLED == 1 + #define FSFW_DISABLE_PRINTOUT 0 +#endif + //! Can be used to enable additional debugging printouts for developing the FSFW #define FSFW_PRINT_VERBOSITY_LEVEL 0 @@ -20,6 +26,8 @@ //! and translateEvents (and their compiled source files) #define FSFW_OBJ_EVENT_TRANSLATION 0 +#define FSFW_COLORED_OUTPUT 1 + #if FSFW_OBJ_EVENT_TRANSLATION == 1 //! Specify whether info events are printed too. #define FSFW_DEBUG_INFO 1 @@ -50,6 +58,8 @@ static constexpr size_t FSFW_EVENTMGMR_RANGEMATCHERS = 120; //! simulataneously. This will increase the required RAM for //! each CSB service ! static constexpr uint8_t FSFW_CSB_FIFO_DEPTH = 6; + +static constexpr size_t FSFW_PRINT_BUFFER_SIZE = 124; } #endif /* CONFIG_FSFWCONFIG_H_ */ diff --git a/serviceinterface/ServiceInterfaceBuffer.h b/serviceinterface/ServiceInterfaceBuffer.h index c5d5b258..c953846d 100644 --- a/serviceinterface/ServiceInterfaceBuffer.h +++ b/serviceinterface/ServiceInterfaceBuffer.h @@ -2,6 +2,7 @@ #define FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACEBUFFER_H_ #include "../returnvalues/HasReturnvaluesIF.h" +#include #include #include #include @@ -54,7 +55,7 @@ private: bool errStream; //! Needed for buffered mode. - static size_t const BUF_SIZE = 128; + static size_t const BUF_SIZE = fsfwconfig::FSFW_PRINT_BUFFER_SIZE; char buf[BUF_SIZE]; //! In this function, the characters are parsed. diff --git a/serviceinterface/ServiceInterfacePrinter.cpp b/serviceinterface/ServiceInterfacePrinter.cpp index 4c4c28cb..04430d61 100644 --- a/serviceinterface/ServiceInterfacePrinter.cpp +++ b/serviceinterface/ServiceInterfacePrinter.cpp @@ -1,2 +1,104 @@ #include "ServiceInterfacePrinter.h" +#include "../timemanager/Clock.h" + +#include +#include +#include + + +fsfw::PrintLevel printLevel = fsfw::PrintLevel::DEBUG; +uint8_t printBuffer[fsfwconfig::FSFW_PRINT_BUFFER_SIZE]; + +void fsfwPrint(fsfw::PrintLevel printType, const char* fmt, va_list arg) { + uint32_t len = 0; + + /* Check logger level */ + if(printType == fsfw::PrintLevel::NONE or printType > printLevel) { + return; + } + + /* Log message to terminal */ + +#if FSFW_COLORED_OUTPUT == 1 + if(printType == fsfw::PrintLevel::INFO) { + len += sprintf((char *)printBuffer, fsfw::ANSI_COLOR_GREEN); + } + else if(printType == fsfw::PrintLevel::DEBUG) { + len += sprintf((char *)printBuffer, fsfw::ANSI_COLOR_BLUE); + } + else if(printType == fsfw::PrintLevel::WARNING) { + len += sprintf((char *)printBuffer, fsfw::ANSI_COLOR_YELLOW); + } + else if(printType == fsfw::PrintLevel::ERROR_TYPE) { + len += sprintf((char *)printBuffer, fsfw::ANSI_COLOR_RED); + } +#endif + + if (printType == fsfw::PrintLevel::INFO) { + len += sprintf((char *)printBuffer + len, "INFO: "); + } + if(printType == fsfw::PrintLevel::DEBUG) { + len += sprintf((char *)printBuffer + len, "DEBUG: "); + } + if(printType == fsfw::PrintLevel::WARNING) { + len += sprintf((char *)printBuffer + len, "WARNING: "); + } + + if(printType == fsfw::PrintLevel::ERROR_TYPE) { + len += sprintf((char *)printBuffer + len, "ERROR: "); + } + + Clock::TimeOfDay_t now; + Clock::getDateAndTime(&now); + /* + * Log current time to terminal if desired. + */ + len += sprintf((char*)printBuffer + len, "| %lu:%02lu:%02lu.%03lu | ", + (unsigned long) now.hour, + (unsigned long) now.minute, + (unsigned long) now.second, + (unsigned long) now.usecond /1000); + + //changed Jan 2017. Need to update length with buffer size + len += vsnprintf((char *)(printBuffer + len), + sizeof(printBuffer)-len, fmt, arg); + + printf("%s", printBuffer); +} + +void fsfw::setPrintLevel(PrintLevel printLevel_) { + printLevel = printLevel_; +} + +fsfw::PrintLevel fsfw::getPrintLevel() { + return printLevel; +} + +void fsfw::printInfo(const char *fmt, ...) { + va_list args; + va_start(args, fmt); + fsfwPrint(fsfw::PrintLevel::INFO, fmt, args); + va_end(args); +} + +void fsfw::printWarning(const char *fmt, ...) { + va_list args; + va_start(args, fmt); + fsfwPrint(fsfw::PrintLevel::WARNING, fmt, args); + va_end(args); +} + +void fsfw::printDebug(const char *fmt, ...) { + va_list args; + va_start(args, fmt); + fsfwPrint(fsfw::PrintLevel::DEBUG, fmt, args); + va_end(args); +} + +void fsfw::printError(const char *fmt, ...) { + va_list args; + va_start(args, fmt); + fsfwPrint(fsfw::PrintLevel::ERROR_TYPE, fmt, args); + va_end(args); +} diff --git a/serviceinterface/ServiceInterfacePrinter.h b/serviceinterface/ServiceInterfacePrinter.h index e69de29b..a2ba483d 100644 --- a/serviceinterface/ServiceInterfacePrinter.h +++ b/serviceinterface/ServiceInterfacePrinter.h @@ -0,0 +1,33 @@ +#include + +namespace fsfw { + +enum class PrintLevel { + NONE = 0, + //! Strange error when using just ERROR.. + ERROR_TYPE = 1, + WARNING = 2, + INFO = 3, + DEBUG = 4 +}; + + +static const char* const ANSI_COLOR_RED = "\x1b[31m"; +static const char* const ANSI_COLOR_GREEN = "\x1b[32m"; +static const char* const ANSI_COLOR_YELLOW = "\x1b[33m"; +static const char* const ANSI_COLOR_BLUE = "\x1b[34m"; +static const char* const ANSI_COLOR_MAGENTA = "\x1b[35m"; +static const char* const ANSI_COLOR_CYAN = "\x1b[36m"; +static const char* const ANSI_COLOR_RESET = "\x1b[0m"; + +void setPrintLevel(PrintLevel printLevel); +PrintLevel getPrintLevel(); + + +void printInfo(const char *fmt, ...); +void printWarning(const char* fmt, ...); +void printDebug(const char* fmt, ...); +void printError(const char* fmt, ...); + +} + From 0e2875b22d20c68408b052d37c0ff0e69e37b903 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sun, 3 Jan 2021 01:35:17 +0100 Subject: [PATCH 12/50] added colored output for streams as well --- defaultcfg/fsfwconfig/FSFWConfig.h | 9 ++++---- serviceinterface/ServiceInterfaceBuffer.cpp | 23 +++++++++++++++++++ serviceinterface/ServiceInterfaceBuffer.h | 5 ++++ serviceinterface/ServiceInterfacePrinter.cpp | 4 +++- serviceinterface/ServiceInterfacePrinter.h | 9 -------- serviceinterface/ServiceInterfaceStream.cpp | 17 -------------- serviceinterface/ServiceInterfaceStream.h | 7 ------ serviceinterface/serviceInterfaceDefintions.h | 16 +++++++++++++ 8 files changed, 52 insertions(+), 38 deletions(-) create mode 100644 serviceinterface/serviceInterfaceDefintions.h diff --git a/defaultcfg/fsfwconfig/FSFWConfig.h b/defaultcfg/fsfwconfig/FSFWConfig.h index d94f6cc7..261e3d6d 100644 --- a/defaultcfg/fsfwconfig/FSFWConfig.h +++ b/defaultcfg/fsfwconfig/FSFWConfig.h @@ -9,25 +9,26 @@ //! the C stdio functions can be used alternatively #define FSFW_CPP_OSTREAM_ENABLED 1 -//! Reduced printout to further decrease code size +//! More FSFW related printouts. //! Be careful, this also turns off most diagnostic prinouts! #define FSFW_ENHANCED_PRINTOUT 0 //! Can be used to completely disable printouts, even the C stdio ones. -#if FSFW_CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 0 && FSFW_ENHANCED_PRINTOUT == 0 #define FSFW_DISABLE_PRINTOUT 0 #endif //! Can be used to enable additional debugging printouts for developing the FSFW #define FSFW_PRINT_VERBOSITY_LEVEL 0 +//! Can be used to disable the ANSI color sequences for C stdio. +#define FSFW_COLORED_OUTPUT 1 + //! If FSFW_OBJ_EVENT_TRANSLATION is set to one, //! additional output which requires the translation files translateObjects //! and translateEvents (and their compiled source files) #define FSFW_OBJ_EVENT_TRANSLATION 0 -#define FSFW_COLORED_OUTPUT 1 - #if FSFW_OBJ_EVENT_TRANSLATION == 1 //! Specify whether info events are printed too. #define FSFW_DEBUG_INFO 1 diff --git a/serviceinterface/ServiceInterfaceBuffer.cpp b/serviceinterface/ServiceInterfaceBuffer.cpp index 68fc4dec..eb940cfa 100644 --- a/serviceinterface/ServiceInterfaceBuffer.cpp +++ b/serviceinterface/ServiceInterfaceBuffer.cpp @@ -1,5 +1,7 @@ #include "../timemanager/Clock.h" #include "ServiceInterfaceBuffer.h" +#include "serviceInterfaceDefintions.h" +#include #include #include @@ -17,6 +19,21 @@ ServiceInterfaceBuffer::ServiceInterfaceBuffer(std::string setMessage, // Set pointers if the stream is buffered. setp( buf, buf + BUF_SIZE ); } + +#if FSFW_COLORED_OUTPUT == 1 + if(setMessage.find("DEBUG")) { + colorPrefix = fsfw::ANSI_COLOR_MAGENTA; + } + else if(setMessage.find("INFO")) { + colorPrefix = fsfw::ANSI_COLOR_GREEN; + } + else if(setMessage.find("WARNING")) { + colorPrefix = fsfw::ANSI_COLOR_YELLOW; + } + else if(setMessage.find("ERROR")) { + colorPrefix = fsfw::ANSI_COLOR_RED; + } +#endif preamble.reserve(MAX_PREAMBLE_SIZE); preamble.resize(MAX_PREAMBLE_SIZE); } @@ -102,6 +119,12 @@ std::string* ServiceInterfaceBuffer::getPreamble(size_t * preambleSize) { currentSize += 1; parsePosition += 1; } + +#if FSFW_COLORED_OUTPUT == 1 + currentSize += sprintf(parsePosition, "%s", colorPrefix.c_str()); + parsePosition += colorPrefix.size(); +#endif + int32_t charCount = sprintf(parsePosition, "%s: | %02" SCNu32 ":%02" SCNu32 ":%02" SCNu32 ".%03" SCNu32 " | ", this->logMessage.c_str(), loggerTime.hour, diff --git a/serviceinterface/ServiceInterfaceBuffer.h b/serviceinterface/ServiceInterfaceBuffer.h index c953846d..8f2a601c 100644 --- a/serviceinterface/ServiceInterfaceBuffer.h +++ b/serviceinterface/ServiceInterfaceBuffer.h @@ -42,6 +42,11 @@ private: //! For additional message information std::string logMessage; std::string preamble; + +#if FSFW_COLORED_OUTPUT == 1 + std::string colorPrefix; +#endif + // For EOF detection typedef std::char_traits Traits; diff --git a/serviceinterface/ServiceInterfacePrinter.cpp b/serviceinterface/ServiceInterfacePrinter.cpp index 04430d61..177d7c4a 100644 --- a/serviceinterface/ServiceInterfacePrinter.cpp +++ b/serviceinterface/ServiceInterfacePrinter.cpp @@ -1,8 +1,10 @@ #include "ServiceInterfacePrinter.h" +#include "serviceInterfaceDefintions.h" #include "../timemanager/Clock.h" #include + #include #include @@ -25,7 +27,7 @@ void fsfwPrint(fsfw::PrintLevel printType, const char* fmt, va_list arg) { len += sprintf((char *)printBuffer, fsfw::ANSI_COLOR_GREEN); } else if(printType == fsfw::PrintLevel::DEBUG) { - len += sprintf((char *)printBuffer, fsfw::ANSI_COLOR_BLUE); + len += sprintf((char *)printBuffer, fsfw::ANSI_COLOR_MAGENTA); } else if(printType == fsfw::PrintLevel::WARNING) { len += sprintf((char *)printBuffer, fsfw::ANSI_COLOR_YELLOW); diff --git a/serviceinterface/ServiceInterfacePrinter.h b/serviceinterface/ServiceInterfacePrinter.h index a2ba483d..1991f412 100644 --- a/serviceinterface/ServiceInterfacePrinter.h +++ b/serviceinterface/ServiceInterfacePrinter.h @@ -11,15 +11,6 @@ enum class PrintLevel { DEBUG = 4 }; - -static const char* const ANSI_COLOR_RED = "\x1b[31m"; -static const char* const ANSI_COLOR_GREEN = "\x1b[32m"; -static const char* const ANSI_COLOR_YELLOW = "\x1b[33m"; -static const char* const ANSI_COLOR_BLUE = "\x1b[34m"; -static const char* const ANSI_COLOR_MAGENTA = "\x1b[35m"; -static const char* const ANSI_COLOR_CYAN = "\x1b[36m"; -static const char* const ANSI_COLOR_RESET = "\x1b[0m"; - void setPrintLevel(PrintLevel printLevel); PrintLevel getPrintLevel(); diff --git a/serviceinterface/ServiceInterfaceStream.cpp b/serviceinterface/ServiceInterfaceStream.cpp index 5b7b9f00..05643460 100644 --- a/serviceinterface/ServiceInterfaceStream.cpp +++ b/serviceinterface/ServiceInterfaceStream.cpp @@ -13,20 +13,3 @@ std::string* ServiceInterfaceStream::getPreamble() { return streambuf.getPreamble(); } -void ServiceInterfaceStream::print(std::string error, - bool withPreamble, bool withNewline, bool flush) { - if(not streambuf.isBuffered() and withPreamble) { - *this << getPreamble() << error; - } - else { - *this << error; - } - - if(withNewline) { - *this << "\n"; - } - // if mode is non-buffered, no need to flush. - if(flush and streambuf.isBuffered()) { - this->flush(); - } -} diff --git a/serviceinterface/ServiceInterfaceStream.h b/serviceinterface/ServiceInterfaceStream.h index 76fa1bf2..cd2adf85 100644 --- a/serviceinterface/ServiceInterfaceStream.h +++ b/serviceinterface/ServiceInterfaceStream.h @@ -35,13 +35,6 @@ public: */ std::string* getPreamble(); - /** - * This prints an error with a preamble. Useful if using the unbuffered - * mode. Flushes in default mode (prints immediately). - */ - void print(std::string error, bool withPreamble = true, - bool withNewline = true, bool flush = true); - protected: ServiceInterfaceBuffer streambuf; }; diff --git a/serviceinterface/serviceInterfaceDefintions.h b/serviceinterface/serviceInterfaceDefintions.h new file mode 100644 index 00000000..684c7366 --- /dev/null +++ b/serviceinterface/serviceInterfaceDefintions.h @@ -0,0 +1,16 @@ +#ifndef FSFW_SERVICEINTERFACE_SERVICEINTERFACEDEFINTIONS_H_ +#define FSFW_SERVICEINTERFACE_SERVICEINTERFACEDEFINTIONS_H_ + +namespace fsfw { + +static const char* const ANSI_COLOR_RED = "\x1b[31m"; +static const char* const ANSI_COLOR_GREEN = "\x1b[32m"; +static const char* const ANSI_COLOR_YELLOW = "\x1b[33m"; +static const char* const ANSI_COLOR_BLUE = "\x1b[34m"; +static const char* const ANSI_COLOR_MAGENTA = "\x1b[35m"; +static const char* const ANSI_COLOR_CYAN = "\x1b[36m"; +static const char* const ANSI_COLOR_RESET = "\x1b[0m"; + +} + +#endif /* FSFW_SERVICEINTERFACE_SERVICEINTERFACEDEFINTIONS_H_ */ From 5c42888f10c10e42f1c90de98e17feb9fc560cae Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sun, 3 Jan 2021 01:39:06 +0100 Subject: [PATCH 13/50] whitespace --- serviceinterface/ServiceInterfaceBuffer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/serviceinterface/ServiceInterfaceBuffer.cpp b/serviceinterface/ServiceInterfaceBuffer.cpp index eb940cfa..bbfb69c7 100644 --- a/serviceinterface/ServiceInterfaceBuffer.cpp +++ b/serviceinterface/ServiceInterfaceBuffer.cpp @@ -34,6 +34,7 @@ ServiceInterfaceBuffer::ServiceInterfaceBuffer(std::string setMessage, colorPrefix = fsfw::ANSI_COLOR_RED; } #endif + preamble.reserve(MAX_PREAMBLE_SIZE); preamble.resize(MAX_PREAMBLE_SIZE); } From e300207f48d8c4a6790c37c360ce88dab007be54 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sun, 3 Jan 2021 01:40:35 +0100 Subject: [PATCH 14/50] removed comment --- serviceinterface/ServiceInterfacePrinter.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/serviceinterface/ServiceInterfacePrinter.cpp b/serviceinterface/ServiceInterfacePrinter.cpp index 177d7c4a..5ab9e425 100644 --- a/serviceinterface/ServiceInterfacePrinter.cpp +++ b/serviceinterface/ServiceInterfacePrinter.cpp @@ -62,7 +62,6 @@ void fsfwPrint(fsfw::PrintLevel printType, const char* fmt, va_list arg) { (unsigned long) now.second, (unsigned long) now.usecond /1000); - //changed Jan 2017. Need to update length with buffer size len += vsnprintf((char *)(printBuffer + len), sizeof(printBuffer)-len, fmt, arg); From 717027792e830dc046209842500a7aa74761c51e Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sun, 3 Jan 2021 01:47:01 +0100 Subject: [PATCH 15/50] minor improvements and docuemntation --- serviceinterface/ServiceInterfacePrinter.cpp | 22 ++++++++++---------- serviceinterface/ServiceInterfacePrinter.h | 8 ++++++- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/serviceinterface/ServiceInterfacePrinter.cpp b/serviceinterface/ServiceInterfacePrinter.cpp index 5ab9e425..f67dfb53 100644 --- a/serviceinterface/ServiceInterfacePrinter.cpp +++ b/serviceinterface/ServiceInterfacePrinter.cpp @@ -14,6 +14,7 @@ uint8_t printBuffer[fsfwconfig::FSFW_PRINT_BUFFER_SIZE]; void fsfwPrint(fsfw::PrintLevel printType, const char* fmt, va_list arg) { uint32_t len = 0; + char* bufferPosition = reinterpret_cast(printBuffer); /* Check logger level */ if(printType == fsfw::PrintLevel::NONE or printType > printLevel) { @@ -24,31 +25,31 @@ void fsfwPrint(fsfw::PrintLevel printType, const char* fmt, va_list arg) { #if FSFW_COLORED_OUTPUT == 1 if(printType == fsfw::PrintLevel::INFO) { - len += sprintf((char *)printBuffer, fsfw::ANSI_COLOR_GREEN); + len += sprintf(bufferPosition, fsfw::ANSI_COLOR_GREEN); } else if(printType == fsfw::PrintLevel::DEBUG) { - len += sprintf((char *)printBuffer, fsfw::ANSI_COLOR_MAGENTA); + len += sprintf(bufferPosition, fsfw::ANSI_COLOR_MAGENTA); } else if(printType == fsfw::PrintLevel::WARNING) { - len += sprintf((char *)printBuffer, fsfw::ANSI_COLOR_YELLOW); + len += sprintf(bufferPosition, fsfw::ANSI_COLOR_YELLOW); } else if(printType == fsfw::PrintLevel::ERROR_TYPE) { - len += sprintf((char *)printBuffer, fsfw::ANSI_COLOR_RED); + len += sprintf(bufferPosition, fsfw::ANSI_COLOR_RED); } #endif if (printType == fsfw::PrintLevel::INFO) { - len += sprintf((char *)printBuffer + len, "INFO: "); + len += sprintf(bufferPosition + len, "INFO: "); } if(printType == fsfw::PrintLevel::DEBUG) { - len += sprintf((char *)printBuffer + len, "DEBUG: "); + len += sprintf(bufferPosition + len, "DEBUG: "); } if(printType == fsfw::PrintLevel::WARNING) { - len += sprintf((char *)printBuffer + len, "WARNING: "); + len += sprintf(bufferPosition + len, "WARNING: "); } if(printType == fsfw::PrintLevel::ERROR_TYPE) { - len += sprintf((char *)printBuffer + len, "ERROR: "); + len += sprintf(bufferPosition + len, "ERROR: "); } Clock::TimeOfDay_t now; @@ -56,14 +57,13 @@ void fsfwPrint(fsfw::PrintLevel printType, const char* fmt, va_list arg) { /* * Log current time to terminal if desired. */ - len += sprintf((char*)printBuffer + len, "| %lu:%02lu:%02lu.%03lu | ", + len += sprintf(bufferPosition + len, "| %lu:%02lu:%02lu.%03lu | ", (unsigned long) now.hour, (unsigned long) now.minute, (unsigned long) now.second, (unsigned long) now.usecond /1000); - len += vsnprintf((char *)(printBuffer + len), - sizeof(printBuffer)-len, fmt, arg); + len += vsnprintf(bufferPosition + len, sizeof(printBuffer) - len, fmt, arg); printf("%s", printBuffer); } diff --git a/serviceinterface/ServiceInterfacePrinter.h b/serviceinterface/ServiceInterfacePrinter.h index 1991f412..8b81ee7a 100644 --- a/serviceinterface/ServiceInterfacePrinter.h +++ b/serviceinterface/ServiceInterfacePrinter.h @@ -14,7 +14,13 @@ enum class PrintLevel { void setPrintLevel(PrintLevel printLevel); PrintLevel getPrintLevel(); - +/** + * These functions can be used like the C stdio printf and forward the + * supplied formatted string arguments to a printf function. + * They prepend the string with a color (if enabled), a log preamble and + * a timestamp. + * @param fmt Formatted string + */ void printInfo(const char *fmt, ...); void printWarning(const char* fmt, ...); void printDebug(const char* fmt, ...); From 087482300d0177e7297a7749adf279959b34625f Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sun, 3 Jan 2021 01:49:12 +0100 Subject: [PATCH 16/50] include order --- serviceinterface/ServiceInterfacePrinter.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/serviceinterface/ServiceInterfacePrinter.cpp b/serviceinterface/ServiceInterfacePrinter.cpp index f67dfb53..369edd0f 100644 --- a/serviceinterface/ServiceInterfacePrinter.cpp +++ b/serviceinterface/ServiceInterfacePrinter.cpp @@ -1,10 +1,8 @@ +#include #include "ServiceInterfacePrinter.h" #include "serviceInterfaceDefintions.h" - #include "../timemanager/Clock.h" -#include - #include #include @@ -13,7 +11,7 @@ fsfw::PrintLevel printLevel = fsfw::PrintLevel::DEBUG; uint8_t printBuffer[fsfwconfig::FSFW_PRINT_BUFFER_SIZE]; void fsfwPrint(fsfw::PrintLevel printType, const char* fmt, va_list arg) { - uint32_t len = 0; + size_t len = 0; char* bufferPosition = reinterpret_cast(printBuffer); /* Check logger level */ From 61fc6cac97e8febcc2dfcff7956819b8737d3a64 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 3 Jan 2021 13:25:42 +0100 Subject: [PATCH 17/50] added change for windows --- serviceinterface/ServiceInterfaceBuffer.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/serviceinterface/ServiceInterfaceBuffer.cpp b/serviceinterface/ServiceInterfaceBuffer.cpp index bbfb69c7..222c1e2c 100644 --- a/serviceinterface/ServiceInterfaceBuffer.cpp +++ b/serviceinterface/ServiceInterfaceBuffer.cpp @@ -5,6 +5,10 @@ #include #include +#if defined(WIN32) && FSFW_COLORED_OUTPUT == 1 +#include "Windows.h" +#endif + // to be implemented by bsp extern "C" void printChar(const char*, bool errStream); @@ -33,6 +37,15 @@ ServiceInterfaceBuffer::ServiceInterfaceBuffer(std::string setMessage, else if(setMessage.find("ERROR")) { colorPrefix = fsfw::ANSI_COLOR_RED; } + +#ifdef WIN32 + HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); + DWORD dwMode = 0; + GetConsoleMode(hOut, &dwMode); + dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING; + SetConsoleMode(hOut, dwMode); +#endif + #endif preamble.reserve(MAX_PREAMBLE_SIZE); From c19e628d7971e23b64ce87f36bd1f6b2caf2a113 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 3 Jan 2021 13:58:18 +0100 Subject: [PATCH 18/50] all cstdout uses wrapped in preprocessor defines --- container/SharedRingBuffer.cpp | 2 ++ controller/ExtendedControllerBase.cpp | 2 ++ datalinklayer/Clcw.cpp | 2 ++ datalinklayer/DataLinkLayer.cpp | 4 +++ datalinklayer/MapPacketExtraction.cpp | 12 +++++++ datalinklayer/TcTransferFrame.cpp | 23 ++++++++---- datalinklayer/TcTransferFrameLocal.cpp | 2 ++ datalinklayer/VirtualChannelReception.cpp | 2 ++ datapool/PoolDataSetBase.cpp | 10 ++++++ datapool/PoolEntry.cpp | 6 ++++ datapoollocal/HasLocalDataPoolIF.h | 2 ++ datapoollocal/LocalDataPoolManager.cpp | 28 +++++++++++++++ datapoollocal/LocalDataPoolManager.h | 4 +++ datapoollocal/LocalPoolDataSetBase.cpp | 8 +++++ datapoollocal/LocalPoolObjectBase.cpp | 8 +++++ datapoollocal/LocalPoolVariable.tpp | 8 +++++ datapoollocal/LocalPoolVector.tpp | 12 +++++++ datapoollocal/PoolReadHelper.h | 2 ++ .../PollingSequenceFactory.cpp | 2 ++ devicehandlers/DeviceHandlerBase.cpp | 20 +++++++++++ .../DeviceHandlerFailureIsolation.cpp | 4 +++ events/EventManager.cpp | 7 ++-- fdir/FailureIsolationBase.cpp | 8 +++++ globalfunctions/arrayprinter.cpp | 10 +++++- health/HealthHelper.cpp | 8 +++++ internalError/InternalErrorReporter.cpp | 4 ++- ipc/MessageQueueMessage.cpp | 4 +++ ipc/MutexHelper.h | 4 +++ memory/MemoryHelper.cpp | 2 ++ monitoring/MonitoringMessageContent.h | 2 ++ objectmanager/ObjectManager.cpp | 24 ++++++++++++- objectmanager/ObjectManagerIF.h | 2 ++ osal/FreeRTOS/BinSemaphUsingTask.cpp | 2 ++ osal/FreeRTOS/BinarySemaphore.cpp | 6 ++++ osal/FreeRTOS/CountingSemaphUsingTask.cpp | 6 ++++ osal/FreeRTOS/CountingSemaphore.cpp | 8 +++++ osal/FreeRTOS/FixedTimeslotTask.cpp | 6 ++++ osal/FreeRTOS/MessageQueue.cpp | 3 ++ osal/FreeRTOS/Mutex.cpp | 2 ++ osal/FreeRTOS/PeriodicTask.cpp | 6 ++++ osal/FreeRTOS/SemaphoreFactory.cpp | 4 +++ osal/host/Clock.cpp | 16 +++++++++ osal/host/FixedTimeslotTask.cpp | 8 +++++ osal/host/MessageQueue.cpp | 4 +++ osal/host/PeriodicTask.cpp | 6 ++++ osal/host/QueueMapManager.cpp | 4 +++ osal/host/SemaphoreFactory.cpp | 4 +++ osal/linux/BinarySemaphore.cpp | 6 ++++ osal/linux/Clock.cpp | 2 ++ osal/linux/CountingSemaphore.cpp | 2 ++ osal/linux/FixedTimeslotTask.cpp | 4 +++ osal/linux/MessageQueue.cpp | 35 ++++++++++++++++++- osal/linux/Mutex.cpp | 8 +++++ osal/linux/PeriodicPosixTask.cpp | 8 +++++ osal/linux/PosixThread.cpp | 32 +++++++++++++++++ osal/linux/TcUnixUdpPollingTask.cpp | 18 ++++++++++ osal/linux/Timer.cpp | 2 ++ osal/linux/TmTcUnixUdpBridge.cpp | 24 +++++++++++++ osal/rtems/MessageQueue.cpp | 2 ++ osal/rtems/MultiObjectTask.cpp | 4 +++ osal/rtems/Mutex.cpp | 4 +++ osal/rtems/PollingTask.cpp | 8 +++++ osal/rtems/TaskBase.cpp | 2 ++ osal/windows/TcWinUdpPollingTask.cpp | 24 +++++++++++++ osal/windows/TmTcWinUdpBridge.cpp | 30 ++++++++++++++++ parameters/ParameterHelper.cpp | 2 ++ pus/CService201HealthCommanding.cpp | 2 ++ pus/Service1TelecommandVerification.cpp | 4 +++ pus/Service2DeviceAccess.cpp | 6 ++++ pus/Service3Housekeeping.cpp | 6 ++++ pus/Service5EventReporting.cpp | 4 +++ pus/Service8FunctionManagement.cpp | 6 ++++ serialize/SerialBufferAdapter.cpp | 4 +++ storagemanager/ConstStorageAccessor.cpp | 8 +++++ storagemanager/LocalPool.cpp | 16 +++++++++ storagemanager/PoolManager.cpp | 2 ++ storagemanager/StorageAccessor.cpp | 10 ++++++ subsystem/SubsystemBase.cpp | 2 ++ tasks/FixedSlotSequence.cpp | 12 +++++++ tcdistribution/CCSDSDistributor.cpp | 8 +++++ tcdistribution/PUSDistributor.cpp | 12 +++++++ tcdistribution/TcDistributor.cpp | 3 +- timemanager/Stopwatch.cpp | 4 +++ tmtcpacket/pus/TcPacketBase.cpp | 2 ++ tmtcpacket/pus/TcPacketStored.cpp | 6 ++++ tmtcpacket/pus/TmPacketBase.cpp | 4 +++ tmtcpacket/pus/TmPacketStored.cpp | 2 ++ tmtcservices/CommandingServiceBase.cpp | 4 +++ tmtcservices/PusServiceBase.cpp | 8 +++++ tmtcservices/TmTcBridge.cpp | 30 ++++++++++++++++ tmtcservices/VerificationReporter.cpp | 12 +++++++ unittest/internal/InternalUnitTester.cpp | 4 +++ unittest/internal/UnittDefinitions.cpp | 2 ++ unittest/internal/osal/IntTestSemaphore.cpp | 2 ++ .../PollingSequenceFactory.cpp | 2 ++ .../user/unittest/core/CatchDefinitions.cpp | 2 ++ 96 files changed, 715 insertions(+), 14 deletions(-) diff --git a/container/SharedRingBuffer.cpp b/container/SharedRingBuffer.cpp index 6ddb3d3e..340bce37 100644 --- a/container/SharedRingBuffer.cpp +++ b/container/SharedRingBuffer.cpp @@ -47,9 +47,11 @@ ReturnValue_t SharedRingBuffer::initialize() { DynamicFIFO* SharedRingBuffer::getReceiveSizesFIFO() { if(receiveSizesFIFO == nullptr) { // Configuration error. +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "SharedRingBuffer::getReceiveSizesFIFO: Ring buffer" << " was not configured to have sizes FIFO, returning nullptr!" << std::endl; +#endif } return receiveSizesFIFO; } diff --git a/controller/ExtendedControllerBase.cpp b/controller/ExtendedControllerBase.cpp index fa4f6786..f9f7534d 100644 --- a/controller/ExtendedControllerBase.cpp +++ b/controller/ExtendedControllerBase.cpp @@ -107,7 +107,9 @@ MessageQueueId_t ExtendedControllerBase::getCommandQueue() const { } LocalPoolDataSetBase* ExtendedControllerBase::getDataSetHandle(sid_t sid) { +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "ExtendedControllerBase::getDataSetHandle: No child " << " implementation provided, returning nullptr!" << std::endl; +#endif return nullptr; } diff --git a/datalinklayer/Clcw.cpp b/datalinklayer/Clcw.cpp index dc435a2b..19aa4e7b 100644 --- a/datalinklayer/Clcw.cpp +++ b/datalinklayer/Clcw.cpp @@ -55,7 +55,9 @@ void Clcw::setBitLock(bool bitLock) { } void Clcw::print() { +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "Clcw::print: Clcw is: " << std::hex << getAsWhole() << std::dec << std::endl; +#endif } void Clcw::setWhole(uint32_t rawClcw) { diff --git a/datalinklayer/DataLinkLayer.cpp b/datalinklayer/DataLinkLayer.cpp index 75f2edda..6a383851 100644 --- a/datalinklayer/DataLinkLayer.cpp +++ b/datalinklayer/DataLinkLayer.cpp @@ -98,8 +98,10 @@ ReturnValue_t DataLinkLayer::processFrame(uint16_t length) { receivedDataLength = length; ReturnValue_t status = allFramesReception(); if (status != RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "DataLinkLayer::processFrame: frame reception failed. " "Error code: " << std::hex << status << std::dec << std::endl; +#endif // currentFrame.print(); return status; } else { @@ -124,7 +126,9 @@ ReturnValue_t DataLinkLayer::initialize() { if ( virtualChannels.begin() != virtualChannels.end() ) { clcw->setVirtualChannel( virtualChannels.begin()->second->getChannelId() ); } else { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "DataLinkLayer::initialize: No VC assigned to this DLL instance! " << std::endl; +#endif return RETURN_FAILED; } diff --git a/datalinklayer/MapPacketExtraction.cpp b/datalinklayer/MapPacketExtraction.cpp index 845ed7c1..0bf79f42 100644 --- a/datalinklayer/MapPacketExtraction.cpp +++ b/datalinklayer/MapPacketExtraction.cpp @@ -29,9 +29,11 @@ ReturnValue_t MapPacketExtraction::extractPackets(TcTransferFrame* frame) { bufferPosition = &packetBuffer[packetLength]; status = RETURN_OK; } else { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "MapPacketExtraction::extractPackets. Packet too large! Size: " << packetLength << std::endl; +#endif clearBuffers(); status = CONTENT_TOO_LARGE; } @@ -51,24 +53,30 @@ ReturnValue_t MapPacketExtraction::extractPackets(TcTransferFrame* frame) { } status = RETURN_OK; } else { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "MapPacketExtraction::extractPackets. Packet too large! Size: " << packetLength << std::endl; +#endif clearBuffers(); status = CONTENT_TOO_LARGE; } } else { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "MapPacketExtraction::extractPackets. Illegal segment! Last flag: " << (int) lastSegmentationFlag << std::endl; +#endif clearBuffers(); status = ILLEGAL_SEGMENTATION_FLAG; } break; default: +#if CPP_OSTREAM_ENABLED == 1 sif::error << "MapPacketExtraction::extractPackets. Illegal segmentationFlag: " << (int) segmentationFlag << std::endl; +#endif clearBuffers(); status = DATA_CORRUPTED; break; @@ -135,10 +143,14 @@ ReturnValue_t MapPacketExtraction::initialize() { } void MapPacketExtraction::printPacketBuffer(void) { +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "DLL: packet_buffer contains: " << std::endl; +#endif for (uint32_t i = 0; i < this->packetLength; ++i) { +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "packet_buffer[" << std::dec << i << "]: 0x" << std::hex << (uint16_t) this->packetBuffer[i] << std::endl; +#endif } } diff --git a/datalinklayer/TcTransferFrame.cpp b/datalinklayer/TcTransferFrame.cpp index f1a70bdc..0050994a 100644 --- a/datalinklayer/TcTransferFrame.cpp +++ b/datalinklayer/TcTransferFrame.cpp @@ -87,16 +87,25 @@ uint8_t* TcTransferFrame::getFullDataField() { } void TcTransferFrame::print() { +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "Raw Frame: " << std::hex << std::endl; for (uint16_t count = 0; count < this->getFullSize(); count++ ) { sif::debug << (uint16_t)this->getFullFrame()[count] << " "; } sif::debug << std::dec << std::endl; -// debug << "Frame Header:" << std::endl; -// debug << "Version Number: " << std::hex << (uint16_t)this->current_frame.getVersionNumber() << std::endl; -// debug << "Bypass Flag set?| Ctrl Cmd Flag set?: " << (uint16_t)this->current_frame.bypassFlagSet() << " | " << (uint16_t)this->current_frame.controlCommandFlagSet() << std::endl; -// debug << "SCID : " << this->current_frame.getSpacecraftId() << std::endl; -// debug << "VCID : " << (uint16_t)this->current_frame.getVirtualChannelId() << std::endl; -// debug << "Frame length: " << std::dec << this->current_frame.getFrameLength() << std::endl; -// debug << "Sequence Number: " << (uint16_t)this->current_frame.getSequenceNumber() << std::endl; + + sif::debug << "Frame Header:" << std::endl; + sif::debug << "Version Number: " << std::hex + << (uint16_t)this->getVersionNumber() << std::endl; + sif::debug << "Bypass Flag set?| Ctrl Cmd Flag set?: " + << (uint16_t)this->bypassFlagSet() << " | " + << (uint16_t)this->controlCommandFlagSet() << std::endl; + sif::debug << "SCID : " << this->getSpacecraftId() << std::endl; + sif::debug << "VCID : " << (uint16_t)this->getVirtualChannelId() + << std::endl; + sif::debug << "Frame length: " << std::dec << this->getFrameLength() + << std::endl; + sif::debug << "Sequence Number: " << (uint16_t)this->getSequenceNumber() + << std::endl; +#endif } diff --git a/datalinklayer/TcTransferFrameLocal.cpp b/datalinklayer/TcTransferFrameLocal.cpp index e8785c92..1ef772a2 100644 --- a/datalinklayer/TcTransferFrameLocal.cpp +++ b/datalinklayer/TcTransferFrameLocal.cpp @@ -37,7 +37,9 @@ TcTransferFrameLocal::TcTransferFrameLocal(bool bypass, bool controlCommand, uin this->getFullFrame()[getFullSize()-2] = (crc & 0xFF00) >> 8; this->getFullFrame()[getFullSize()-1] = (crc & 0x00FF); } else { +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "TcTransferFrameLocal: dataSize too large: " << dataSize << std::endl; +#endif } } else { //No data in frame diff --git a/datalinklayer/VirtualChannelReception.cpp b/datalinklayer/VirtualChannelReception.cpp index cde28de3..8ad65740 100644 --- a/datalinklayer/VirtualChannelReception.cpp +++ b/datalinklayer/VirtualChannelReception.cpp @@ -102,8 +102,10 @@ uint8_t VirtualChannelReception::getChannelId() const { ReturnValue_t VirtualChannelReception::initialize() { ReturnValue_t returnValue = RETURN_FAILED; if ((slidingWindowWidth > 254) || (slidingWindowWidth % 2 != 0)) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "VirtualChannelReception::initialize: Illegal sliding window width: " << (int) slidingWindowWidth << std::endl; +#endif return RETURN_FAILED; } for (mapChannelIterator iterator = mapChannels.begin(); iterator != mapChannels.end(); diff --git a/datapool/PoolDataSetBase.cpp b/datapool/PoolDataSetBase.cpp index 8f073359..f2c2b867 100644 --- a/datapool/PoolDataSetBase.cpp +++ b/datapool/PoolDataSetBase.cpp @@ -13,18 +13,24 @@ PoolDataSetBase::~PoolDataSetBase() {} ReturnValue_t PoolDataSetBase::registerVariable( PoolVariableIF *variable) { if (state != States::STATE_SET_UNINITIALISED) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "DataSet::registerVariable: " "Call made in wrong position." << std::endl; +#endif return DataSetIF::DATA_SET_UNINITIALISED; } if (variable == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "DataSet::registerVariable: " "Pool variable is nullptr." << std::endl; +#endif return DataSetIF::POOL_VAR_NULL; } if (fillCount >= maxFillCount) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "DataSet::registerVariable: " "DataSet is full." << std::endl; +#endif return DataSetIF::DATA_SET_FULL; } registeredVariables[fillCount] = variable; @@ -47,9 +53,11 @@ ReturnValue_t PoolDataSetBase::read(uint32_t lockTimeout) { unlockDataPool(); } else { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "DataSet::read(): " "Call made in wrong position. Don't forget to commit" " member datasets!" << std::endl; +#endif result = SET_WAS_ALREADY_READ; } @@ -138,8 +146,10 @@ ReturnValue_t PoolDataSetBase::handleUnreadDatasetCommit(uint32_t lockTimeout) { } else if (registeredVariables[count]->getDataPoolId() != PoolVariableIF::NO_PARAMETER) { if (result != COMMITING_WITHOUT_READING) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "DataSet::commit(): commit-without-read call made " "with non write-only variable." << std::endl; +#endif result = COMMITING_WITHOUT_READING; } } diff --git a/datapool/PoolEntry.cpp b/datapool/PoolEntry.cpp index fb73328c..b1ccb260 100644 --- a/datapool/PoolEntry.cpp +++ b/datapool/PoolEntry.cpp @@ -12,9 +12,11 @@ PoolEntry::PoolEntry(std::initializer_list initValue, uint8_t setLength, std::memset(this->address, 0, this->getByteSize()); } else if (initValue.size() != setLength){ +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "PoolEntry: setLength is not equal to initializer list" "length! Performing zero initialization with given setLength" << std::endl; +#endif std::memset(this->address, 0, this->getByteSize()); } else { @@ -67,10 +69,14 @@ bool PoolEntry::getValid() { template void PoolEntry::print() { +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "Pool Entry Validity: " << (this->valid? " (valid) " : " (invalid) ") << std::endl; +#endif arrayprinter::print(reinterpret_cast(address), length); +#if CPP_OSTREAM_ENABLED == 1 sif::debug << std::dec << std::endl; +#endif } template diff --git a/datapoollocal/HasLocalDataPoolIF.h b/datapoollocal/HasLocalDataPoolIF.h index df855110..e94af167 100644 --- a/datapoollocal/HasLocalDataPoolIF.h +++ b/datapoollocal/HasLocalDataPoolIF.h @@ -89,8 +89,10 @@ public: * @return */ virtual LocalPoolObjectBase* getPoolObjectHandle(lp_id_t localPoolId) { +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "HasLocalDataPoolIF::getPoolObjectHandle: Not overriden" << ". Returning nullptr!" << std::endl; +#endif return nullptr; } diff --git a/datapoollocal/LocalDataPoolManager.cpp b/datapoollocal/LocalDataPoolManager.cpp index 5f0d15d3..0eb6f5f5 100644 --- a/datapoollocal/LocalDataPoolManager.cpp +++ b/datapoollocal/LocalDataPoolManager.cpp @@ -21,15 +21,19 @@ LocalDataPoolManager::LocalDataPoolManager(HasLocalDataPoolIF* owner, MessageQueueIF* queueToUse, bool appendValidityBuffer): appendValidityBuffer(appendValidityBuffer) { if(owner == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "LocalDataPoolManager::LocalDataPoolManager: " << "Invalid supplied owner!" << std::endl; +#endif return; } this->owner = owner; mutex = MutexFactory::instance()->createMutex(); if(mutex == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "LocalDataPoolManager::LocalDataPoolManager: " << "Could not create mutex." << std::endl; +#endif } hkQueue = queueToUse; @@ -39,17 +43,21 @@ LocalDataPoolManager::~LocalDataPoolManager() {} ReturnValue_t LocalDataPoolManager::initialize(MessageQueueIF* queueToUse) { if(queueToUse == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "LocalDataPoolManager::initialize: " << std::hex << "0x" << owner->getObjectId() << ". Supplied " << "queue invalid!" << std::dec << std::endl; +#endif } hkQueue = queueToUse; ipcStore = objectManager->get(objects::IPC_STORE); if(ipcStore == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "LocalDataPoolManager::initialize: " << std::hex << "0x" << owner->getObjectId() << ": Could not " << "set IPC store." <getHkQueue(); } else { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "LocalDataPoolManager::LocalDataPoolManager: " << "Default HK destination object is invalid!" << std::endl; +#endif return HasReturnvaluesIF::RETURN_FAILED; } } @@ -85,8 +95,10 @@ ReturnValue_t LocalDataPoolManager::initializeHousekeepingPoolEntriesOnce() { } return result; } +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "HousekeepingManager: The map should only be initialized " << "once!" << std::endl; +#endif return HasReturnvaluesIF::RETURN_OK; } @@ -339,8 +351,10 @@ ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(sid_t sid, AcceptsHkPacketsIF* hkReceiverObject = objectManager->get(packetDestination); if(hkReceiverObject == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "LocalDataPoolManager::subscribeForPeriodicPacket:" << " Invalid receiver!"<< std::endl; +#endif return HasReturnvaluesIF::RETURN_OK; } @@ -369,8 +383,10 @@ ReturnValue_t LocalDataPoolManager::subscribeForUpdatePackets(sid_t sid, AcceptsHkPacketsIF* hkReceiverObject = objectManager->get(packetDestination); if(hkReceiverObject == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "LocalDataPoolManager::subscribeForPeriodicPacket:" << " Invalid receiver!"<< std::endl; +#endif return HasReturnvaluesIF::RETURN_OK; } @@ -575,8 +591,10 @@ ReturnValue_t LocalDataPoolManager::printPoolEntry( lp_id_t localPoolId) { auto poolIter = localPoolMap.find(localPoolId); if (poolIter == localPoolMap.end()) { +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "HousekeepingManager::fechPoolEntry:" << " Pool entry not found." << std::endl; +#endif return HasLocalDataPoolIF::POOL_ENTRY_NOT_FOUND; } poolIter->second->print(); @@ -596,8 +614,10 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid, MessageQueueId_t destination) { if(dataSet == nullptr) { // Configuration error. +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "HousekeepingManager::generateHousekeepingPacket:" << " Set ID not found or dataset not assigned!" << std::endl; +#endif return HasReturnvaluesIF::RETURN_FAILED; } @@ -678,10 +698,12 @@ void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver& receiver) { sid, dataSet, true); if(result != HasReturnvaluesIF::RETURN_OK) { // configuration error +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "LocalDataPoolManager::performHkOperation:" << "0x" << std::hex << std::setfill('0') << std::setw(8) << owner->getObjectId() << " Error generating " << "HK packet" << std::setfill(' ') << std::dec << std::endl; +#endif } } @@ -726,8 +748,10 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid, // Get and check dataset first. LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid); if(dataSet == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "HousekeepingManager::generateHousekeepingPacket:" << " Set ID not found" << std::endl; +#endif return HasReturnvaluesIF::RETURN_FAILED; } @@ -752,8 +776,10 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid, ReturnValue_t result = ipcStore->getFreeElement(&storeId, expectedSize,&storePtr); if(result != HasReturnvaluesIF::RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "HousekeepingManager::generateHousekeepingPacket: " << "Could not get free element from IPC store." << std::endl; +#endif return result; } @@ -762,8 +788,10 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid, result = setPacket.serialize(&storePtr, &size, expectedSize, SerializeIF::Endianness::BIG); if(expectedSize != size) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "HousekeepingManager::generateSetStructurePacket: " << "Expected size is not equal to serialized size" << std::endl; +#endif } // Send structure reporting reply. diff --git a/datapoollocal/LocalDataPoolManager.h b/datapoollocal/LocalDataPoolManager.h index cdefa2c2..37ae8152 100644 --- a/datapoollocal/LocalDataPoolManager.h +++ b/datapoollocal/LocalDataPoolManager.h @@ -375,15 +375,19 @@ ReturnValue_t LocalDataPoolManager::fetchPoolEntry(lp_id_t localPoolId, PoolEntry **poolEntry) { auto poolIter = localPoolMap.find(localPoolId); if (poolIter == localPoolMap.end()) { +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "HousekeepingManager::fechPoolEntry: Pool entry " "not found." << std::endl; +#endif return HasLocalDataPoolIF::POOL_ENTRY_NOT_FOUND; } *poolEntry = dynamic_cast< PoolEntry* >(poolIter->second); if(*poolEntry == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "HousekeepingManager::fetchPoolEntry:" " Pool entry not found." << std::endl; +#endif return HasLocalDataPoolIF::POOL_ENTRY_TYPE_CONFLICT; } return HasReturnvaluesIF::RETURN_OK; diff --git a/datapoollocal/LocalPoolDataSetBase.cpp b/datapoollocal/LocalPoolDataSetBase.cpp index 9ecad218..8e13b602 100644 --- a/datapoollocal/LocalPoolDataSetBase.cpp +++ b/datapoollocal/LocalPoolDataSetBase.cpp @@ -12,8 +12,10 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner, PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) { if(hkOwner == nullptr) { // Configuration error. +#if CPP_OSTREAM_ENABLED == 1 sif::error << "LocalPoolDataSetBase::LocalPoolDataSetBase: Owner " << "invalid!" << std::endl; +#endif return; } hkManager = hkOwner->getHkManagerHandle(); @@ -147,8 +149,10 @@ ReturnValue_t LocalPoolDataSetBase::serializeLocalPoolIds(uint8_t** buffer, auto result = SerializeAdapter::serialize(¤tPoolId, buffer, size, maxSize, streamEndianness); if(result != HasReturnvaluesIF::RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "LocalDataSet::serializeLocalPoolIds: Serialization" " error!" << std::endl; +#endif return result; } } @@ -206,8 +210,10 @@ ReturnValue_t LocalPoolDataSetBase::serialize(uint8_t **buffer, size_t *size, void LocalPoolDataSetBase::bitSetter(uint8_t* byte, uint8_t position) const { if(position > 7) { +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "Pool Raw Access: Bit setting invalid position" << std::endl; +#endif return; } uint8_t shiftNumber = position + (7 - 2 * position); @@ -256,8 +262,10 @@ sid_t LocalPoolDataSetBase::getSid() const { bool LocalPoolDataSetBase::bitGetter(const uint8_t* byte, uint8_t position) const { if(position > 7) { +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "Pool Raw Access: Bit setting invalid position" << std::endl; +#endif return false; } uint8_t shiftNumber = position + (7 - 2 * position); diff --git a/datapoollocal/LocalPoolObjectBase.cpp b/datapoollocal/LocalPoolObjectBase.cpp index b4d0e306..5abef424 100644 --- a/datapoollocal/LocalPoolObjectBase.cpp +++ b/datapoollocal/LocalPoolObjectBase.cpp @@ -5,12 +5,16 @@ LocalPoolObjectBase::LocalPoolObjectBase(lp_id_t poolId, pool_rwm_t setReadWriteMode): localPoolId(poolId), readWriteMode(setReadWriteMode) { if(poolId == PoolVariableIF::NO_PARAMETER) { +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "LocalPoolVar::LocalPoolVar: 0 passed as pool ID, " << "which is the NO_PARAMETER value!" << std::endl; +#endif } if(hkOwner == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "LocalPoolVar::LocalPoolVar: The supplied pool " << "owner is a invalid!" << std::endl; +#endif return; } hkManager = hkOwner->getHkManagerHandle(); @@ -23,15 +27,19 @@ LocalPoolObjectBase::LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId, DataSetIF *dataSet, pool_rwm_t setReadWriteMode): localPoolId(poolId), readWriteMode(setReadWriteMode) { if(poolId == PoolVariableIF::NO_PARAMETER) { +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "LocalPoolVar::LocalPoolVar: 0 passed as pool ID, " << "which is the NO_PARAMETER value!" << std::endl; +#endif } HasLocalDataPoolIF* hkOwner = objectManager->get(poolOwner); if(hkOwner == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "LocalPoolVariable: The supplied pool owner did not " << "implement the correct interface" << " HasLocalDataPoolIF!" << std::endl; +#endif return; } hkManager = hkOwner->getHkManagerHandle(); diff --git a/datapoollocal/LocalPoolVariable.tpp b/datapoollocal/LocalPoolVariable.tpp index a685ea8d..38e9cf4b 100644 --- a/datapoollocal/LocalPoolVariable.tpp +++ b/datapoollocal/LocalPoolVariable.tpp @@ -33,18 +33,22 @@ inline ReturnValue_t LocalPoolVariable::read(dur_millis_t lockTimeout) { template inline ReturnValue_t LocalPoolVariable::readWithoutLock() { if(readWriteMode == pool_rwm_t::VAR_WRITE) { +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "LocalPoolVar: Invalid read write " "mode for read() call." << std::endl; +#endif return PoolVariableIF::INVALID_READ_WRITE_MODE; } PoolEntry* poolEntry = nullptr; ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry); if(result != RETURN_OK or poolEntry == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "PoolVector: Read of local pool variable of object " << std::hex << std::setw(8) << std::setfill('0') << hkManager->getOwner() << " and lp ID " << localPoolId << std::dec << " failed." << std::setfill(' ') << std::endl; +#endif return result; } this->value = *(poolEntry->address); @@ -62,17 +66,21 @@ inline ReturnValue_t LocalPoolVariable::commit(dur_millis_t lockTimeout) { template inline ReturnValue_t LocalPoolVariable::commitWithoutLock() { if(readWriteMode == pool_rwm_t::VAR_READ) { +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "LocalPoolVariable: Invalid read write " "mode for commit() call." << std::endl; +#endif return PoolVariableIF::INVALID_READ_WRITE_MODE; } PoolEntry* poolEntry = nullptr; ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry); if(result != RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "PoolVector: Read of local pool variable of object " "0x" << std::hex << std::setw(8) << std::setfill('0') << hkManager->getOwner() << " and lp ID 0x" << localPoolId << std::dec << " failed.\n" << std::flush; +#endif return result; } *(poolEntry->address) = this->value; diff --git a/datapoollocal/LocalPoolVector.tpp b/datapoollocal/LocalPoolVector.tpp index 46123ccc..dc91fb9b 100644 --- a/datapoollocal/LocalPoolVector.tpp +++ b/datapoollocal/LocalPoolVector.tpp @@ -32,8 +32,10 @@ inline ReturnValue_t LocalPoolVector::read(uint32_t lockTimeout) template inline ReturnValue_t LocalPoolVector::readWithoutLock() { if(readWriteMode == pool_rwm_t::VAR_WRITE) { +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "LocalPoolVar: Invalid read write " "mode for read() call." << std::endl; +#endif return PoolVariableIF::INVALID_READ_WRITE_MODE; } @@ -42,10 +44,12 @@ inline ReturnValue_t LocalPoolVector::readWithoutLock() { memset(this->value, 0, vectorSize * sizeof(T)); if(result != RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "PoolVector: Read of local pool variable of object " "0x" << std::hex << std::setw(8) << std::setfill('0') << hkManager->getOwner() << "and lp ID 0x" << localPoolId << std::dec << " failed." << std::endl; +#endif return result; } std::memcpy(this->value, poolEntry->address, poolEntry->getByteSize()); @@ -64,17 +68,21 @@ inline ReturnValue_t LocalPoolVector::commit( template inline ReturnValue_t LocalPoolVector::commitWithoutLock() { if(readWriteMode == pool_rwm_t::VAR_READ) { +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "LocalPoolVar: Invalid read write " "mode for commit() call." << std::endl; +#endif return PoolVariableIF::INVALID_READ_WRITE_MODE; } PoolEntry* poolEntry = nullptr; ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry); if(result != RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "PoolVector: Read of local pool variable of object " "0x" << std::hex << std::setw(8) << std::setfill('0') << hkManager->getOwner() << " and lp ID 0x" << localPoolId << std::dec << " failed.\n" << std::flush; +#endif return result; } std::memcpy(poolEntry->address, this->value, poolEntry->getByteSize()); @@ -89,8 +97,10 @@ inline T& LocalPoolVector::operator [](int i) { } // If this happens, I have to set some value. I consider this // a configuration error, but I wont exit here. +#if CPP_OSTREAM_ENABLED == 1 sif::error << "LocalPoolVector: Invalid index. Setting or returning" " last value!" << std::endl; +#endif return value[i]; } @@ -101,8 +111,10 @@ inline const T& LocalPoolVector::operator [](int i) const { } // If this happens, I have to set some value. I consider this // a configuration error, but I wont exit here. +#if CPP_OSTREAM_ENABLED == 1 sif::error << "LocalPoolVector: Invalid index. Setting or returning" " last value!" << std::endl; +#endif return value[i]; } diff --git a/datapoollocal/PoolReadHelper.h b/datapoollocal/PoolReadHelper.h index 4fe506ee..bf962c95 100644 --- a/datapoollocal/PoolReadHelper.h +++ b/datapoollocal/PoolReadHelper.h @@ -14,7 +14,9 @@ public: if(readObject != nullptr) { readResult = readObject->read(mutexTimeout); #if FSFW_PRINT_VERBOSITY_LEVEL == 1 +#if CPP_OSTREAM_ENABLED == 1 sif::error << "PoolReadHelper: Read failed!" << std::endl; +#endif #endif } } diff --git a/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.cpp b/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.cpp index f836a746..443b2bbb 100644 --- a/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.cpp +++ b/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.cpp @@ -15,8 +15,10 @@ ReturnValue_t pst::pollingSequenceInitDefault( return HasReturnvaluesIF::RETURN_OK; } else { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "pst::pollingSequenceInitDefault: Sequence invalid!" << std::endl; +#endif return HasReturnvaluesIF::RETURN_FAILED; } } diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index 251320cb..da2b823d 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -39,11 +39,13 @@ DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId, cookieInfo.state = COOKIE_UNUSED; cookieInfo.pendingCommand = deviceCommandMap.end(); if (comCookie == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "DeviceHandlerBase: ObjectID 0x" << std::hex << std::setw(8) << std::setfill('0') << this->getObjectId() << std::dec << ": Do not pass nullptr as a cookie, consider " << std::setfill(' ') << "passing a dummy cookie instead!" << std::endl; +#endif } if (this->fdirInstance == nullptr) { this->fdirInstance = new DeviceHandlerFailureIsolation(setObjectId, @@ -130,24 +132,30 @@ ReturnValue_t DeviceHandlerBase::initialize() { communicationInterface = objectManager->get( deviceCommunicationId); if (communicationInterface == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "DeviceHandlerBase::initialize: Communication interface " "invalid." << std::endl; sif::error << "Make sure it is set up properly and implements" " DeviceCommunicationIF" << std::endl; +#endif return ObjectManagerIF::CHILD_INIT_FAILED; } result = communicationInterface->initializeInterface(comCookie); if (result != RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "DeviceHandlerBase::initialize: Initializing " "communication interface failed!" << std::endl; +#endif return result; } IPCStore = objectManager->get(objects::IPC_STORE); if (IPCStore == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "DeviceHandlerBase::initialize: IPC store not set up in " "factory." << std::endl; +#endif return ObjectManagerIF::CHILD_INIT_FAILED; } @@ -156,10 +164,12 @@ ReturnValue_t DeviceHandlerBase::initialize() { AcceptsDeviceResponsesIF>(rawDataReceiverId); if (rawReceiver == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "DeviceHandlerBase::initialize: Raw receiver object " "ID set but no valid object found." << std::endl; sif::error << "Make sure the raw receiver object is set up properly" " and implements AcceptsDeviceResponsesIF" << std::endl; +#endif return ObjectManagerIF::CHILD_INIT_FAILED; } defaultRawReceiver = rawReceiver->getDeviceQueue(); @@ -168,10 +178,12 @@ ReturnValue_t DeviceHandlerBase::initialize() { if(powerSwitcherId != objects::NO_OBJECT) { powerSwitcher = objectManager->get(powerSwitcherId); if (powerSwitcher == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "DeviceHandlerBase::initialize: Power switcher " << "object ID set but no valid object found." << std::endl; sif::error << "Make sure the raw receiver object is set up properly" << " and implements PowerSwitchIF" << std::endl; +#endif return ObjectManagerIF::CHILD_INIT_FAILED; } } @@ -708,8 +720,10 @@ void DeviceHandlerBase::parseReply(const uint8_t* receivedData, case RETURN_OK: handleReply(receivedData, foundId, foundLen); if(foundLen == 0) { +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "DeviceHandlerBase::parseReply: foundLen is 0!" " Packet parsing will be stuck." << std::endl; +#endif } break; case APERIODIC_REPLY: { @@ -720,8 +734,10 @@ void DeviceHandlerBase::parseReply(const uint8_t* receivedData, foundId); } if(foundLen == 0) { +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "DeviceHandlerBase::parseReply: foundLen is 0!" " Packet parsing will be stuck." << std::endl; +#endif } break; } @@ -1275,9 +1291,11 @@ void DeviceHandlerBase::buildInternalCommand(void) { result = buildNormalDeviceCommand(&deviceCommandId); if (result == BUSY) { //so we can track misconfigurations +#if CPP_OSTREAM_ENABLED == 1 sif::debug << std::hex << getObjectId() << ": DHB::buildInternalCommand: Busy" << std::dec << std::endl; +#endif result = NOTHING_TO_SEND; //no need to report this } } @@ -1302,10 +1320,12 @@ void DeviceHandlerBase::buildInternalCommand(void) { result = COMMAND_NOT_SUPPORTED; } else if (iter->second.isExecuting) { //so we can track misconfigurations +#if CPP_OSTREAM_ENABLED == 1 sif::debug << std::hex << getObjectId() << ": DHB::buildInternalCommand: Command " << deviceCommandId << " isExecuting" << std::dec << std::endl; +#endif // this is an internal command, no need to report a failure here, // missed reply will track if a reply is too late, otherwise, it's ok return; diff --git a/devicehandlers/DeviceHandlerFailureIsolation.cpp b/devicehandlers/DeviceHandlerFailureIsolation.cpp index 9d0535bf..c7f87859 100644 --- a/devicehandlers/DeviceHandlerFailureIsolation.cpp +++ b/devicehandlers/DeviceHandlerFailureIsolation.cpp @@ -169,8 +169,10 @@ void DeviceHandlerFailureIsolation::clearFaultCounters() { ReturnValue_t DeviceHandlerFailureIsolation::initialize() { ReturnValue_t result = FailureIsolationBase::initialize(); if (result != HasReturnvaluesIF::RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "DeviceHandlerFailureIsolation::initialize: Could not" " initialize FailureIsolationBase." << std::endl; +#endif return result; } ConfirmsFailuresIF* power = objectManager->get( @@ -250,8 +252,10 @@ bool DeviceHandlerFailureIsolation::isFdirInActionOrAreWeFaulty( if (owner == nullptr) { // Configuration error. +#if CPP_OSTREAM_ENABLED == 1 sif::error << "DeviceHandlerFailureIsolation::" << "isFdirInActionOrAreWeFaulty: Owner not set!" << std::endl; +#endif return false; } diff --git a/events/EventManager.cpp b/events/EventManager.cpp index 6cc97eb6..6742ff86 100644 --- a/events/EventManager.cpp +++ b/events/EventManager.cpp @@ -122,6 +122,7 @@ void EventManager::printEvent(EventMessage* message) { case severity::INFO: #if DEBUG_INFO_EVENT == 1 string = translateObject(message->getReporter()); +#if CPP_OSTREAM_ENABLED == 1 sif::info << "EVENT: "; if (string != 0) { sif::info << string; @@ -132,10 +133,12 @@ void EventManager::printEvent(EventMessage* message) { << std::dec << message->getEventId() << std::hex << ") P1: 0x" << message->getParameter1() << " P2: 0x" << message->getParameter2() << std::dec << std::endl; -#endif +#endif /* CPP_OSTREAM_ENABLED == 1 */ +#endif /* DEBUG_INFO_EVENT == 1 */ break; default: string = translateObject(message->getReporter()); +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "EventManager: "; if (string != 0) { sif::debug << string; @@ -146,13 +149,13 @@ void EventManager::printEvent(EventMessage* message) { sif::debug << " reported " << translateEvents(message->getEvent()) << " (" << std::dec << message->getEventId() << ") " << std::endl; - sif::debug << std::hex << "P1 Hex: 0x" << message->getParameter1() << ", P1 Dec: " << std::dec << message->getParameter1() << std::endl; sif::debug << std::hex << "P2 Hex: 0x" << message->getParameter2() << ", P2 Dec: " << std::dec << message->getParameter2() << std::endl; +#endif break; } } diff --git a/fdir/FailureIsolationBase.cpp b/fdir/FailureIsolationBase.cpp index a04a0313..fed301b5 100644 --- a/fdir/FailureIsolationBase.cpp +++ b/fdir/FailureIsolationBase.cpp @@ -21,8 +21,10 @@ ReturnValue_t FailureIsolationBase::initialize() { EventManagerIF* manager = objectManager->get( objects::EVENT_MANAGER); if (manager == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "FailureIsolationBase::initialize: Event Manager has not" " been initialized!" << std::endl; +#endif return RETURN_FAILED; } ReturnValue_t result = manager->registerListener(eventQueue->getId()); @@ -36,8 +38,10 @@ ReturnValue_t FailureIsolationBase::initialize() { } owner = objectManager->get(ownerId); if (owner == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "FailureIsolationBase::intialize: Owner object " "invalid. Make sure it implements HasHealthIF" << std::endl; +#endif return ObjectManagerIF::CHILD_INIT_FAILED; } } @@ -45,10 +49,14 @@ ReturnValue_t FailureIsolationBase::initialize() { ConfirmsFailuresIF* parentIF = objectManager->get( faultTreeParent); if (parentIF == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "FailureIsolationBase::intialize: Parent object" << "invalid." << std::endl; +#endif +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Make sure it implements ConfirmsFailuresIF." << std::endl; +#endif return ObjectManagerIF::CHILD_INIT_FAILED; return RETURN_FAILED; } diff --git a/globalfunctions/arrayprinter.cpp b/globalfunctions/arrayprinter.cpp index b1e888c5..c14cc7c6 100644 --- a/globalfunctions/arrayprinter.cpp +++ b/globalfunctions/arrayprinter.cpp @@ -4,10 +4,12 @@ void arrayprinter::print(const uint8_t *data, size_t size, OutputType type, bool printInfo, size_t maxCharPerLine) { +#if CPP_OSTREAM_ENABLED == 1 if(printInfo) { sif::info << "Printing data with size " << size << ": "; } sif::info << "["; +#endif if(type == OutputType::HEX) { arrayprinter::printHex(data, size, maxCharPerLine); } @@ -21,6 +23,7 @@ void arrayprinter::print(const uint8_t *data, size_t size, OutputType type, void arrayprinter::printHex(const uint8_t *data, size_t size, size_t maxCharPerLine) { +#if CPP_OSTREAM_ENABLED == 1 sif::info << std::hex; for(size_t i = 0; i < size; i++) { sif::info << "0x" << static_cast(data[i]); @@ -28,16 +31,18 @@ void arrayprinter::printHex(const uint8_t *data, size_t size, sif::info << " , "; if(i > 0 and i % maxCharPerLine == 0) { sif::info << std::endl; + } - } } sif::info << std::dec; sif::info << "]" << std::endl; +#endif } void arrayprinter::printDec(const uint8_t *data, size_t size, size_t maxCharPerLine) { +#if CPP_OSTREAM_ENABLED == 1 sif::info << std::dec; for(size_t i = 0; i < size; i++) { sif::info << static_cast(data[i]); @@ -49,13 +54,16 @@ void arrayprinter::printDec(const uint8_t *data, size_t size, } } sif::info << "]" << std::endl; +#endif } void arrayprinter::printBin(const uint8_t *data, size_t size) { +#if CPP_OSTREAM_ENABLED == 1 sif::info << "\n" << std::flush; for(size_t i = 0; i < size; i++) { sif::info << "Byte " << i + 1 << ": 0b"<< std::bitset<8>(data[i]) << ",\n" << std::flush; } sif::info << "]" << std::endl; +#endif } diff --git a/health/HealthHelper.cpp b/health/HealthHelper.cpp index d574634d..de795a6c 100644 --- a/health/HealthHelper.cpp +++ b/health/HealthHelper.cpp @@ -41,14 +41,18 @@ ReturnValue_t HealthHelper::initialize() { eventSender = objectManager->get(objectId); if (healthTable == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "HealthHelper::initialize: Health table object needs" "to be created in factory." << std::endl; +#endif return ObjectManagerIF::CHILD_INIT_FAILED; } if(eventSender == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "HealthHelper::initialize: Owner has to implement " "ReportingProxyIF." << std::endl; +#endif return ObjectManagerIF::CHILD_INIT_FAILED; } @@ -79,8 +83,10 @@ void HealthHelper::informParent(HasHealthIF::HealthState health, health, oldHealth); if (MessageQueueSenderIF::sendMessage(parentQueue, &information, owner->getCommandQueue()) != HasReturnvaluesIF::RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "HealthHelper::informParent: sending health reply failed." << std::endl; +#endif } } @@ -98,8 +104,10 @@ void HealthHelper::handleSetHealthCommand(CommandMessage* command) { } if (MessageQueueSenderIF::sendMessage(command->getSender(), &reply, owner->getCommandQueue()) != HasReturnvaluesIF::RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "HealthHelper::handleHealthCommand: sending health " "reply failed." << std::endl; +#endif } } diff --git a/internalError/InternalErrorReporter.cpp b/internalError/InternalErrorReporter.cpp index bfb67289..a2dc529d 100644 --- a/internalError/InternalErrorReporter.cpp +++ b/internalError/InternalErrorReporter.cpp @@ -29,14 +29,16 @@ ReturnValue_t InternalErrorReporter::performOperation(uint8_t opCode) { uint32_t newTmHits = getAndResetTmHits(); uint32_t newStoreHits = getAndResetStoreHits(); -#ifdef DEBUG +#if FSFW_ENHANCED_PRINTOUT == 1 if(diagnosticPrintout) { if((newQueueHits > 0) or (newTmHits > 0) or (newStoreHits > 0)) { +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "InternalErrorReporter::performOperation: Errors " << "occured!" << std::endl; sif::debug << "Queue errors: " << newQueueHits << std::endl; sif::debug << "TM errors: " << newTmHits << std::endl; sif::debug << "Store errors: " << newStoreHits << std::endl; +#endif } } #endif diff --git a/ipc/MessageQueueMessage.cpp b/ipc/MessageQueueMessage.cpp index dcd4def3..cdd4d943 100644 --- a/ipc/MessageQueueMessage.cpp +++ b/ipc/MessageQueueMessage.cpp @@ -15,8 +15,10 @@ MessageQueueMessage::MessageQueueMessage(uint8_t* data, size_t size) : this->messageSize = this->HEADER_SIZE + size; } else { +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "MessageQueueMessage: Passed size larger than maximum" "allowed size! Setting content to 0" << std::endl; +#endif memset(this->internalBuffer, 0, sizeof(this->internalBuffer)); this->messageSize = this->HEADER_SIZE; } @@ -52,7 +54,9 @@ void MessageQueueMessage::setSender(MessageQueueId_t setId) { } void MessageQueueMessage::print(bool printWholeMessage) { +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "MessageQueueMessage content: " << std::endl; +#endif if(printWholeMessage) { arrayprinter::print(getData(), getMaximumMessageSize()); } diff --git a/ipc/MutexHelper.h b/ipc/MutexHelper.h index 97001ade..bd2f5187 100644 --- a/ipc/MutexHelper.h +++ b/ipc/MutexHelper.h @@ -12,12 +12,16 @@ public: ReturnValue_t status = mutex->lockMutex(timeoutType, timeoutMs); if(status == MutexIF::MUTEX_TIMEOUT) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "MutexHelper: Lock of mutex failed with timeout of " << timeoutMs << " milliseconds!" << std::endl; +#endif } else if(status != HasReturnvaluesIF::RETURN_OK){ +#if CPP_OSTREAM_ENABLED == 1 sif::error << "MutexHelper: Lock of Mutex failed with code " << status << std::endl; +#endif } } diff --git a/memory/MemoryHelper.cpp b/memory/MemoryHelper.cpp index 6b11882f..1d2a62a9 100644 --- a/memory/MemoryHelper.cpp +++ b/memory/MemoryHelper.cpp @@ -16,7 +16,9 @@ ReturnValue_t MemoryHelper::handleMemoryCommand(CommandMessage* message) { lastSender = message->getSender(); lastCommand = message->getCommand(); if (busy) { +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "MemHelper: Busy!" << std::endl; +#endif } switch (lastCommand) { case MemoryMessage::CMD_MEMORY_DUMP: diff --git a/monitoring/MonitoringMessageContent.h b/monitoring/MonitoringMessageContent.h index 44d32656..44661e4c 100644 --- a/monitoring/MonitoringMessageContent.h +++ b/monitoring/MonitoringMessageContent.h @@ -72,8 +72,10 @@ private: if (timeStamper == nullptr) { timeStamper = objectManager->get( timeStamperId ); if ( timeStamper == nullptr ) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "MonitoringReportContent::checkAndSetStamper: " "Stamper not found!" << std::endl; +#endif return false; } } diff --git a/objectmanager/ObjectManager.cpp b/objectmanager/ObjectManager.cpp index 5871bfcd..12f4ef4f 100644 --- a/objectmanager/ObjectManager.cpp +++ b/objectmanager/ObjectManager.cpp @@ -18,13 +18,18 @@ ObjectManager::~ObjectManager() { ReturnValue_t ObjectManager::insert( object_id_t id, SystemObjectIF* object) { auto returnPair = objectList.emplace(id, object); if (returnPair.second) { +#if CPP_OSTREAM_ENABLED == 1 // sif::debug << "ObjectManager::insert: Object " << std::hex // << (int)id << std::dec << " inserted." << std::endl; +#endif return this->RETURN_OK; } else { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "ObjectManager::insert: Object id " << std::hex - << (int)id << std::dec << " is already in use!" << std::endl; + << static_cast id << std::dec + << " is already in use!" << std::endl; sif::error << "Terminating program." << std::endl; +#endif //This is very severe and difficult to handle in other places. std::exit(INSERTION_FAILED); } @@ -33,12 +38,16 @@ ReturnValue_t ObjectManager::insert( object_id_t id, SystemObjectIF* object) { ReturnValue_t ObjectManager::remove( object_id_t id ) { if ( this->getSystemObject(id) != NULL ) { this->objectList.erase( id ); +#if CPP_OSTREAM_ENABLED == 1 //sif::debug << "ObjectManager::removeObject: Object " << std::hex // << (int)id << std::dec << " removed." << std::endl; +#endif return RETURN_OK; } else { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "ObjectManager::removeObject: Requested object " << std::hex << (int)id << std::dec << " not found." << std::endl; +#endif return NOT_FOUND; } } @@ -60,8 +69,10 @@ ObjectManager::ObjectManager() : produceObjects(nullptr) { void ObjectManager::initialize() { if(produceObjects == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "ObjectManager::initialize: Passed produceObjects " "functions is nullptr!" << std::endl; +#endif return; } this->produceObjects(); @@ -71,37 +82,48 @@ void ObjectManager::initialize() { result = it.second->initialize(); if ( result != RETURN_OK ) { object_id_t var = it.first; +#if CPP_OSTREAM_ENABLED == 1 sif::error << "ObjectManager::initialize: Object 0x" << std::hex << std::setw(8) << std::setfill('0')<< var << " failed to " "initialize with code 0x" << result << std::dec << std::setfill(' ') << std::endl; +#endif errorCount++; } } if (errorCount > 0) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "ObjectManager::ObjectManager: Counted " << errorCount << " failed initializations." << std::endl; +#endif } //Init was successful. Now check successful interconnections. errorCount = 0; for (auto const& it : objectList) { result = it.second->checkObjectConnections(); if ( result != RETURN_OK ) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "ObjectManager::ObjectManager: Object " << std::hex << (int) it.first << " connection check failed with code 0x" << result << std::dec << std::endl; +#endif errorCount++; } } if (errorCount > 0) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "ObjectManager::ObjectManager: Counted " << errorCount << " failed connection checks." << std::endl; +#endif } } void ObjectManager::printList() { +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "ObjectManager: Object List contains:" << std::endl; for (auto const& it : objectList) { sif::debug << std::hex << it.first << " | " << it.second << std::endl; + } +#endif } diff --git a/objectmanager/ObjectManagerIF.h b/objectmanager/ObjectManagerIF.h index 4bd1d915..16700625 100644 --- a/objectmanager/ObjectManagerIF.h +++ b/objectmanager/ObjectManagerIF.h @@ -86,8 +86,10 @@ extern ObjectManagerIF *objectManager; template T* ObjectManagerIF::get( object_id_t id ) { if(objectManager == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "ObjectManagerIF: Global object manager has not " "been initialized yet!" << std::endl; +#endif } SystemObjectIF* temp = this->getSystemObject(id); return dynamic_cast(temp); diff --git a/osal/FreeRTOS/BinSemaphUsingTask.cpp b/osal/FreeRTOS/BinSemaphUsingTask.cpp index a420ec48..d9f4a3cb 100644 --- a/osal/FreeRTOS/BinSemaphUsingTask.cpp +++ b/osal/FreeRTOS/BinSemaphUsingTask.cpp @@ -8,8 +8,10 @@ BinarySemaphoreUsingTask::BinarySemaphoreUsingTask() { handle = TaskManagement::getCurrentTaskHandle(); if(handle == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Could not retrieve task handle. Please ensure the" "constructor was called inside a task." << std::endl; +#endif } xTaskNotifyGive(handle); } diff --git a/osal/FreeRTOS/BinarySemaphore.cpp b/osal/FreeRTOS/BinarySemaphore.cpp index 6fee5c35..3915afe9 100644 --- a/osal/FreeRTOS/BinarySemaphore.cpp +++ b/osal/FreeRTOS/BinarySemaphore.cpp @@ -5,7 +5,9 @@ BinarySemaphore::BinarySemaphore() { handle = xSemaphoreCreateBinary(); if(handle == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Semaphore: Binary semaph creation failure" << std::endl; +#endif } // Initiated semaphore must be given before it can be taken. xSemaphoreGive(handle); @@ -18,7 +20,9 @@ BinarySemaphore::~BinarySemaphore() { BinarySemaphore::BinarySemaphore(BinarySemaphore&& s) { handle = xSemaphoreCreateBinary(); if(handle == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Binary semaphore creation failure" << std::endl; +#endif } xSemaphoreGive(handle); } @@ -28,7 +32,9 @@ BinarySemaphore& BinarySemaphore::operator =( if(&s != this) { handle = xSemaphoreCreateBinary(); if(handle == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Binary semaphore creation failure" << std::endl; +#endif } xSemaphoreGive(handle); } diff --git a/osal/FreeRTOS/CountingSemaphUsingTask.cpp b/osal/FreeRTOS/CountingSemaphUsingTask.cpp index 9d309acc..e66f044d 100644 --- a/osal/FreeRTOS/CountingSemaphUsingTask.cpp +++ b/osal/FreeRTOS/CountingSemaphUsingTask.cpp @@ -9,25 +9,31 @@ CountingSemaphoreUsingTask::CountingSemaphoreUsingTask(const uint8_t maxCount, uint8_t initCount): maxCount(maxCount) { if(initCount > maxCount) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "CountingSemaphoreUsingTask: Max count bigger than " "intial cout. Setting initial count to max count." << std::endl; +#endif initCount = maxCount; } handle = TaskManagement::getCurrentTaskHandle(); if(handle == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "CountingSemaphoreUsingTask: Could not retrieve task " "handle. Please ensure the constructor was called inside a " "task." << std::endl; +#endif } uint32_t oldNotificationValue; xTaskNotifyAndQuery(handle, 0, eSetValueWithOverwrite, &oldNotificationValue); if(oldNotificationValue != 0) { +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "CountinSemaphoreUsingTask: Semaphore initiated but " "current notification value is not 0. Please ensure the " "notification value is not used for other purposes!" << std::endl; +#endif } for(int i = 0; i < initCount; i++) { xTaskNotifyGive(handle); diff --git a/osal/FreeRTOS/CountingSemaphore.cpp b/osal/FreeRTOS/CountingSemaphore.cpp index a202e480..2521e52e 100644 --- a/osal/FreeRTOS/CountingSemaphore.cpp +++ b/osal/FreeRTOS/CountingSemaphore.cpp @@ -10,14 +10,18 @@ CountingSemaphore::CountingSemaphore(const uint8_t maxCount, uint8_t initCount): maxCount(maxCount), initCount(initCount) { if(initCount > maxCount) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "CountingSemaphoreUsingTask: Max count bigger than " "intial cout. Setting initial count to max count." << std::endl; +#endif initCount = maxCount; } handle = xSemaphoreCreateCounting(maxCount, initCount); if(handle == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "CountingSemaphore: Creation failure" << std::endl; +#endif } } @@ -25,7 +29,9 @@ CountingSemaphore::CountingSemaphore(CountingSemaphore&& other): maxCount(other.maxCount), initCount(other.initCount) { handle = xSemaphoreCreateCounting(other.maxCount, other.initCount); if(handle == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "CountingSemaphore: Creation failure" << std::endl; +#endif } } @@ -33,7 +39,9 @@ CountingSemaphore& CountingSemaphore::operator =( CountingSemaphore&& other) { handle = xSemaphoreCreateCounting(other.maxCount, other.initCount); if(handle == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "CountingSemaphore: Creation failure" << std::endl; +#endif } return * this; } diff --git a/osal/FreeRTOS/FixedTimeslotTask.cpp b/osal/FreeRTOS/FixedTimeslotTask.cpp index fc5b89fe..6b289df7 100644 --- a/osal/FreeRTOS/FixedTimeslotTask.cpp +++ b/osal/FreeRTOS/FixedTimeslotTask.cpp @@ -37,15 +37,19 @@ void FixedTimeslotTask::taskEntryPoint(void* argument) { } originalTask->taskFunctionality(); +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "Polling task " << originalTask->handle << " returned from taskFunctionality." << std::endl; +#endif } void FixedTimeslotTask::missedDeadlineCounter() { FixedTimeslotTask::deadlineMissedCount++; if (FixedTimeslotTask::deadlineMissedCount % 10 == 0) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "PST missed " << FixedTimeslotTask::deadlineMissedCount << " deadlines." << std::endl; +#endif } } @@ -69,8 +73,10 @@ ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId, return HasReturnvaluesIF::RETURN_OK; } +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Component " << std::hex << componentId << " not found, not adding it to pst" << std::endl; +#endif return HasReturnvaluesIF::RETURN_FAILED; } diff --git a/osal/FreeRTOS/MessageQueue.cpp b/osal/FreeRTOS/MessageQueue.cpp index fdadf8b7..27b9a769 100644 --- a/osal/FreeRTOS/MessageQueue.cpp +++ b/osal/FreeRTOS/MessageQueue.cpp @@ -10,6 +10,7 @@ MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize): maxMessageSize(maxMessageSize) { handle = xQueueCreate(messageDepth, maxMessageSize); +#if CPP_OSTREAM_ENABLED == 1 if (handle == nullptr) { sif::error << "MessageQueue::MessageQueue:" << " Creation failed." << std::endl; @@ -17,7 +18,9 @@ MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize): << std::endl; sif::error << "Specified Maximum Message Size: " << maxMessageSize << std::endl; + } +#endif } MessageQueue::~MessageQueue() { diff --git a/osal/FreeRTOS/Mutex.cpp b/osal/FreeRTOS/Mutex.cpp index 9d9638b5..1722660c 100644 --- a/osal/FreeRTOS/Mutex.cpp +++ b/osal/FreeRTOS/Mutex.cpp @@ -5,7 +5,9 @@ Mutex::Mutex() { handle = xSemaphoreCreateMutex(); if(handle == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Mutex::Mutex(FreeRTOS): Creation failure" << std::endl; +#endif } } diff --git a/osal/FreeRTOS/PeriodicTask.cpp b/osal/FreeRTOS/PeriodicTask.cpp index 2ee7bec0..155f6ac7 100644 --- a/osal/FreeRTOS/PeriodicTask.cpp +++ b/osal/FreeRTOS/PeriodicTask.cpp @@ -13,8 +13,10 @@ PeriodicTask::PeriodicTask(const char *name, TaskPriority setPriority, BaseType_t status = xTaskCreate(taskEntryPoint, name, stackSize, this, setPriority, &handle); if(status != pdPASS){ +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "PeriodicTask Insufficient heap memory remaining. " "Status: " << status << std::endl; +#endif } } @@ -41,8 +43,10 @@ void PeriodicTask::taskEntryPoint(void* argument) { } originalTask->taskFunctionality(); +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "Polling task " << originalTask->handle << " returned from taskFunctionality." << std::endl; +#endif } ReturnValue_t PeriodicTask::startTask() { @@ -99,8 +103,10 @@ ReturnValue_t PeriodicTask::addComponent(object_id_t object) { ExecutableObjectIF* newObject = objectManager->get( object); if (newObject == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "PeriodicTask::addComponent: Invalid object. Make sure" "it implement ExecutableObjectIF" << std::endl; +#endif return HasReturnvaluesIF::RETURN_FAILED; } objectList.push_back(newObject); diff --git a/osal/FreeRTOS/SemaphoreFactory.cpp b/osal/FreeRTOS/SemaphoreFactory.cpp index beb0d096..4db46c69 100644 --- a/osal/FreeRTOS/SemaphoreFactory.cpp +++ b/osal/FreeRTOS/SemaphoreFactory.cpp @@ -32,8 +32,10 @@ SemaphoreIF* SemaphoreFactory::createBinarySemaphore(uint32_t argument) { return new BinarySemaphoreUsingTask(); } else { +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "SemaphoreFactory: Invalid argument, return regular" "binary semaphore" << std::endl; +#endif return new BinarySemaphore(); } } @@ -47,8 +49,10 @@ SemaphoreIF* SemaphoreFactory::createCountingSemaphore(uint8_t maxCount, return new CountingSemaphoreUsingTask(maxCount, initCount); } else { +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "SemaphoreFactory: Invalid argument, return regular" "binary semaphore" << std::endl; +#endif return new CountingSemaphore(maxCount, initCount); } diff --git a/osal/host/Clock.cpp b/osal/host/Clock.cpp index 41321eeb..7a763a60 100644 --- a/osal/host/Clock.cpp +++ b/osal/host/Clock.cpp @@ -14,7 +14,9 @@ MutexIF* Clock::timeMutex = NULL; using SystemClock = std::chrono::system_clock; uint32_t Clock::getTicksPerSecond(void){ +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "Clock::getTicksPerSecond: not implemented yet" << std::endl; +#endif return 0; //return CLOCKS_PER_SEC; //uint32_t ticks = sysconf(_SC_CLK_TCK); @@ -23,7 +25,9 @@ uint32_t Clock::getTicksPerSecond(void){ ReturnValue_t Clock::setClock(const TimeOfDay_t* time) { // do some magic with chrono +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "Clock::setClock: not implemented yet" << std::endl; +#endif return HasReturnvaluesIF::RETURN_OK; } @@ -36,7 +40,9 @@ ReturnValue_t Clock::setClock(const timeval* time) { #else #endif +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "Clock::getUptime: Not implemented for found OS" << std::endl; +#endif return HasReturnvaluesIF::RETURN_FAILED; } @@ -60,7 +66,9 @@ ReturnValue_t Clock::getClock_timeval(timeval* time) { time->tv_usec = timeUnix.tv_nsec / 1000.0; return HasReturnvaluesIF::RETURN_OK; #else +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "Clock::getUptime: Not implemented for found OS" << std::endl; +#endif return HasReturnvaluesIF::RETURN_FAILED; #endif @@ -68,7 +76,9 @@ ReturnValue_t Clock::getClock_timeval(timeval* time) { ReturnValue_t Clock::getClock_usecs(uint64_t* time) { // do some magic with chrono +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "Clock::gerClock_usecs: not implemented yet" << std::endl; +#endif return HasReturnvaluesIF::RETURN_OK; } @@ -90,7 +100,9 @@ timeval Clock::getUptime() { timeval.tv_usec = uptimeSeconds *(double) 1e6 - (timeval.tv_sec *1e6); } #else +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "Clock::getUptime: Not implemented for found OS" << std::endl; +#endif #endif return timeval; } @@ -126,7 +138,9 @@ ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { auto usecond = std::chrono::duration_cast(fraction); time->usecond = usecond.count(); +#if CPP_OSTREAM_ENABLED == 1 //sif::warning << "Clock::getDateAndTime: not implemented yet" << std::endl; +#endif return HasReturnvaluesIF::RETURN_OK; } @@ -148,7 +162,9 @@ ReturnValue_t Clock::convertTimeOfDayToTimeval(const TimeOfDay_t* from, to->tv_usec = from->usecond; //Fails in 2038.. return HasReturnvaluesIF::RETURN_OK; +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "Clock::convertTimeBla: not implemented yet" << std::endl; +#endif return HasReturnvaluesIF::RETURN_OK; } diff --git a/osal/host/FixedTimeslotTask.cpp b/osal/host/FixedTimeslotTask.cpp index 9e892bb5..1fd3cd7f 100644 --- a/osal/host/FixedTimeslotTask.cpp +++ b/osal/host/FixedTimeslotTask.cpp @@ -35,15 +35,19 @@ FixedTimeslotTask::FixedTimeslotTask(const char *name, TaskPriority setPriority, reinterpret_cast(mainThread.native_handle()), ABOVE_NORMAL_PRIORITY_CLASS); if(result != 0) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "FixedTimeslotTask: Windows SetPriorityClass failed with code " << GetLastError() << std::endl; +#endif } result = SetThreadPriority( reinterpret_cast(mainThread.native_handle()), THREAD_PRIORITY_NORMAL); if(result != 0) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "FixedTimeslotTask: Windows SetPriorityClass failed with code " << GetLastError() << std::endl; +#endif } #elif defined(LINUX) // TODO: we can just copy and paste the code from the linux OSAL here. @@ -70,8 +74,10 @@ void FixedTimeslotTask::taskEntryPoint(void* argument) { } this->taskFunctionality(); +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "FixedTimeslotTask::taskEntryPoint: " "Returned from taskFunctionality." << std::endl; +#endif } ReturnValue_t FixedTimeslotTask::startTask() { @@ -134,8 +140,10 @@ ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId, return HasReturnvaluesIF::RETURN_OK; } +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Component " << std::hex << componentId << " not found, not adding it to pst" << std::endl; +#endif return HasReturnvaluesIF::RETURN_FAILED; } diff --git a/osal/host/MessageQueue.cpp b/osal/host/MessageQueue.cpp index d662d782..0c048120 100644 --- a/osal/host/MessageQueue.cpp +++ b/osal/host/MessageQueue.cpp @@ -10,8 +10,10 @@ MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize): queueLock = MutexFactory::instance()->createMutex(); auto result = QueueMapManager::instance()->addMessageQueue(this, &mqId); if(result != HasReturnvaluesIF::RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::MessageQueue:" << " Could not be created" << std::endl; +#endif } } @@ -137,8 +139,10 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo, targetQueue->messageQueue.push(*mqmMessage); } else { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::sendMessageFromMessageQueue: Message" "is not MessageQueueMessage!" << std::endl; +#endif } } diff --git a/osal/host/PeriodicTask.cpp b/osal/host/PeriodicTask.cpp index bfa6c3fd..09acd2cb 100644 --- a/osal/host/PeriodicTask.cpp +++ b/osal/host/PeriodicTask.cpp @@ -33,15 +33,19 @@ PeriodicTask::PeriodicTask(const char *name, TaskPriority setPriority, reinterpret_cast(mainThread.native_handle()), ABOVE_NORMAL_PRIORITY_CLASS); if(result != 0) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "PeriodicTask: Windows SetPriorityClass failed with code " << GetLastError() << std::endl; +#endif } result = SetThreadPriority( reinterpret_cast(mainThread.native_handle()), THREAD_PRIORITY_NORMAL); if(result != 0) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "PeriodicTask: Windows SetPriorityClass failed with code " << GetLastError() << std::endl; +#endif } #elif defined(LINUX) // we can just copy and paste the code from linux here. @@ -69,8 +73,10 @@ void PeriodicTask::taskEntryPoint(void* argument) { } this->taskFunctionality(); +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "PeriodicTask::taskEntryPoint: " "Returned from taskFunctionality." << std::endl; +#endif } ReturnValue_t PeriodicTask::startTask() { diff --git a/osal/host/QueueMapManager.cpp b/osal/host/QueueMapManager.cpp index 621f46bc..620f8add 100644 --- a/osal/host/QueueMapManager.cpp +++ b/osal/host/QueueMapManager.cpp @@ -26,8 +26,10 @@ ReturnValue_t QueueMapManager::addMessageQueue( auto returnPair = queueMap.emplace(currentId, queueToInsert); if(not returnPair.second) { // this should never happen for the atomic variable. +#if CPP_OSTREAM_ENABLED == 1 sif::error << "QueueMapManager: This ID is already inside the map!" << std::endl; +#endif return HasReturnvaluesIF::RETURN_FAILED; } if (id != nullptr) { @@ -44,8 +46,10 @@ MessageQueueIF* QueueMapManager::getMessageQueue( return queueIter->second; } else { +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "QueueMapManager::getQueueHandle: The ID " << messageQueueId << " does not exists in the map" << std::endl; +#endif return nullptr; } } diff --git a/osal/host/SemaphoreFactory.cpp b/osal/host/SemaphoreFactory.cpp index b19b2c75..840dacef 100644 --- a/osal/host/SemaphoreFactory.cpp +++ b/osal/host/SemaphoreFactory.cpp @@ -21,16 +21,20 @@ SemaphoreFactory* SemaphoreFactory::instance() { SemaphoreIF* SemaphoreFactory::createBinarySemaphore(uint32_t arguments) { // Just gonna wait for full C++20 for now. +#if CPP_OSTREAM_ENABLED == 1 sif::error << "SemaphoreFactory: Binary Semaphore not implemented yet." " Returning nullptr!\n" << std::flush; +#endif return nullptr; } SemaphoreIF* SemaphoreFactory::createCountingSemaphore(const uint8_t maxCount, uint8_t initCount, uint32_t arguments) { // Just gonna wait for full C++20 for now. +#if CPP_OSTREAM_ENABLED == 1 sif::error << "SemaphoreFactory: Counting Semaphore not implemented yet." " Returning nullptr!\n" << std::flush; +#endif return nullptr; } diff --git a/osal/linux/BinarySemaphore.cpp b/osal/linux/BinarySemaphore.cpp index b81fa109..22d35e3a 100644 --- a/osal/linux/BinarySemaphore.cpp +++ b/osal/linux/BinarySemaphore.cpp @@ -43,8 +43,10 @@ ReturnValue_t BinarySemaphore::acquire(TimeoutType timeoutType, timeOut.tv_nsec = nseconds - timeOut.tv_sec * 1000000000; result = sem_timedwait(&handle, &timeOut); if(result != 0 and errno == EINVAL) { +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "BinarySemaphore::acquire: Invalid time value possible" << std::endl; +#endif } } if(result == 0) { @@ -62,8 +64,10 @@ ReturnValue_t BinarySemaphore::acquire(TimeoutType timeoutType, return SemaphoreIF::SEMAPHORE_INVALID; case(EINTR): // Call was interrupted by signal handler +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "BinarySemaphore::acquire: Signal handler interrupted." "Code " << strerror(errno) << std::endl; +#endif /* No break */ default: return HasReturnvaluesIF::RETURN_FAILED; @@ -126,8 +130,10 @@ void BinarySemaphore::initSemaphore(uint8_t initCount) { // Value exceeds SEM_VALUE_MAX case(ENOSYS): // System does not support process-shared semaphores +#if CPP_OSTREAM_ENABLED == 1 sif::error << "BinarySemaphore: Init failed with" << strerror(errno) << std::endl; +#endif } } } diff --git a/osal/linux/Clock.cpp b/osal/linux/Clock.cpp index 6cddda35..e4e7df86 100644 --- a/osal/linux/Clock.cpp +++ b/osal/linux/Clock.cpp @@ -69,7 +69,9 @@ timeval Clock::getUptime() { timeval uptime; auto result = getUptime(&uptime); if(result != HasReturnvaluesIF::RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Clock::getUptime: Error getting uptime" << std::endl; +#endif } return uptime; } diff --git a/osal/linux/CountingSemaphore.cpp b/osal/linux/CountingSemaphore.cpp index 18339399..22cb1615 100644 --- a/osal/linux/CountingSemaphore.cpp +++ b/osal/linux/CountingSemaphore.cpp @@ -4,8 +4,10 @@ CountingSemaphore::CountingSemaphore(const uint8_t maxCount, uint8_t initCount): maxCount(maxCount), initCount(initCount) { if(initCount > maxCount) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "CountingSemaphoreUsingTask: Max count bigger than " "intial cout. Setting initial count to max count." << std::endl; +#endif initCount = maxCount; } diff --git a/osal/linux/FixedTimeslotTask.cpp b/osal/linux/FixedTimeslotTask.cpp index 247a34ed..0635b560 100644 --- a/osal/linux/FixedTimeslotTask.cpp +++ b/osal/linux/FixedTimeslotTask.cpp @@ -47,8 +47,10 @@ ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId, return HasReturnvaluesIF::RETURN_OK; } +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Component " << std::hex << componentId << " not found, not adding it to pst" << std::dec << std::endl; +#endif return HasReturnvaluesIF::RETURN_FAILED; } @@ -91,7 +93,9 @@ void FixedTimeslotTask::taskFunctionality() { void FixedTimeslotTask::missedDeadlineCounter() { FixedTimeslotTask::deadlineMissedCount++; if (FixedTimeslotTask::deadlineMissedCount % 10 == 0) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "PST missed " << FixedTimeslotTask::deadlineMissedCount << " deadlines." << std::endl; +#endif } } diff --git a/osal/linux/MessageQueue.cpp b/osal/linux/MessageQueue.cpp index cfadb793..28dfb9c7 100644 --- a/osal/linux/MessageQueue.cpp +++ b/osal/linux/MessageQueue.cpp @@ -10,7 +10,6 @@ #include - MessageQueue::MessageQueue(uint32_t messageDepth, size_t maxMessageSize): id(MessageQueueIF::NO_QUEUE),lastPartner(MessageQueueIF::NO_QUEUE), defaultDestination(MessageQueueIF::NO_QUEUE), @@ -43,13 +42,17 @@ MessageQueue::MessageQueue(uint32_t messageDepth, size_t maxMessageSize): MessageQueue::~MessageQueue() { int status = mq_close(this->id); if(status != 0){ +#if CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::Destructor: mq_close Failed with status: " << strerror(errno) < Apply changes with: sudo sysctl -p */ +#if CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::MessageQueue: Default MQ size " << defaultMqMaxMsg << " is too small for requested size " << messageDepth << std::endl; sif::error << "This error can be fixed by setting the maximum " "allowed message size higher!" << std::endl; +#endif } break; @@ -95,8 +102,10 @@ ReturnValue_t MessageQueue::handleError(mq_attr* attributes, //We unlink the other queue int status = mq_unlink(name); if (status != 0) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "mq_unlink Failed with status: " << strerror(errno) << std::endl; +#endif } else { // Successful unlinking, try to open again @@ -114,9 +123,11 @@ ReturnValue_t MessageQueue::handleError(mq_attr* attributes, default: // Failed either the first time or the second time +#if CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::MessageQueue: Creating Queue " << std::hex << name << std::dec << " failed with status: " << strerror(errno) << std::endl; +#endif } return HasReturnvaluesIF::RETURN_FAILED; @@ -151,15 +162,19 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message, ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) { if(message == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::receiveMessage: Message is " "nullptr!" << std::endl; +#endif return HasReturnvaluesIF::RETURN_FAILED; } if(message->getMaximumMessageSize() < maxMessageSize) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::receiveMessage: Message size " << message->getMaximumMessageSize() << " too small to receive data!" << std::endl; +#endif return HasReturnvaluesIF::RETURN_FAILED; } @@ -187,8 +202,10 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) { return MessageQueueIF::EMPTY; case EBADF: //mqdes doesn't represent a valid queue open for reading. +#if CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::receive: configuration error " << strerror(errno) << std::endl; +#endif /*NO BREAK*/ case EINVAL: /* @@ -200,8 +217,10 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) { * queue, and the QNX extended option MQ_READBUF_DYNAMIC hasn't * been set in the queue's mq_flags. */ +#if CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::receive: configuration error " << strerror(errno) << std::endl; +#endif /*NO BREAK*/ case EMSGSIZE: /* @@ -213,8 +232,10 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) { * given msg_len is too short for the message that would have * been received. */ +#if CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::receive: configuration error " << strerror(errno) << std::endl; +#endif /*NO BREAK*/ case EINTR: //The operation was interrupted by a signal. @@ -237,8 +258,10 @@ ReturnValue_t MessageQueue::flush(uint32_t* count) { switch(errno){ case EBADF: //mqdes doesn't represent a valid message queue. +#if CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::flush configuration error, " "called flush with an invalid queue ID" << std::endl; +#endif /*NO BREAK*/ case EINVAL: //mq_attr is NULL @@ -253,8 +276,10 @@ ReturnValue_t MessageQueue::flush(uint32_t* count) { switch(errno){ case EBADF: //mqdes doesn't represent a valid message queue. +#if CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::flush configuration error, " "called flush with an invalid queue ID" << std::endl; +#endif /*NO BREAK*/ case EINVAL: /* @@ -306,8 +331,10 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo, MessageQueueMessageIF *message, MessageQueueId_t sentFrom, bool ignoreFault) { if(message == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::sendMessageFromMessageQueue: Message is " "nullptr!" << std::endl; +#endif return HasReturnvaluesIF::RETURN_FAILED; } @@ -335,11 +362,13 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo, case EBADF: { //mq_des doesn't represent a valid message queue descriptor, //or mq_des wasn't opened for writing. +#if CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::sendMessage: Configuration error, MQ" << " destination invalid." << std::endl; sif::error << strerror(errno) << " in " <<"mq_send to: " << sendTo << " sent from " << sentFrom << std::endl; +#endif return DESTINVATION_INVALID; } case EINTR: @@ -354,14 +383,18 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo, * - MQ_PRIO_RESTRICT is set in the mq_attr of mq_des, and * msg_prio is greater than the priority of the calling process. */ +#if CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::sendMessage: Configuration error " << strerror(errno) << " in mq_send" << std::endl; +#endif /*NO BREAK*/ case EMSGSIZE: // The msg_len is greater than the msgsize associated with //the specified queue. +#if CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::sendMessage: Size error [" << strerror(errno) << "] in mq_send" << std::endl; +#endif /*NO BREAK*/ default: return HasReturnvaluesIF::RETURN_FAILED; diff --git a/osal/linux/Mutex.cpp b/osal/linux/Mutex.cpp index b27ff8c0..e2012634 100644 --- a/osal/linux/Mutex.cpp +++ b/osal/linux/Mutex.cpp @@ -12,24 +12,32 @@ Mutex::Mutex() { pthread_mutexattr_t mutexAttr; int status = pthread_mutexattr_init(&mutexAttr); if (status != 0) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Mutex: Attribute init failed with: " << strerror(status) << std::endl; +#endif } status = pthread_mutexattr_setprotocol(&mutexAttr, PTHREAD_PRIO_INHERIT); if (status != 0) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Mutex: Attribute set PRIO_INHERIT failed with: " << strerror(status) << std::endl; +#endif } status = pthread_mutex_init(&mutex, &mutexAttr); if (status != 0) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Mutex: creation with name, id " << mutex.__data.__count << ", " << " failed with " << strerror(status) << std::endl; +#endif } // After a mutex attributes object has been used to initialize one or more // mutexes, any function affecting the attributes object // (including destruction) shall not affect any previously initialized mutexes. status = pthread_mutexattr_destroy(&mutexAttr); if (status != 0) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Mutex: Attribute destroy failed with " << strerror(status) << std::endl; +#endif } } diff --git a/osal/linux/PeriodicPosixTask.cpp b/osal/linux/PeriodicPosixTask.cpp index 3c1df6bb..1c69124d 100644 --- a/osal/linux/PeriodicPosixTask.cpp +++ b/osal/linux/PeriodicPosixTask.cpp @@ -25,8 +25,10 @@ ReturnValue_t PeriodicPosixTask::addComponent(object_id_t object) { ExecutableObjectIF* newObject = objectManager->get( object); if (newObject == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "PeriodicTask::addComponent: Invalid object. Make sure" << " it implements ExecutableObjectIF!" << std::endl; +#endif return HasReturnvaluesIF::RETURN_FAILED; } objectList.push_back(newObject); @@ -42,7 +44,9 @@ ReturnValue_t PeriodicPosixTask::sleepFor(uint32_t ms) { ReturnValue_t PeriodicPosixTask::startTask(void) { started = true; +#if CPP_OSTREAM_ENABLED == 1 //sif::info << stackSize << std::endl; +#endif PosixThread::createTask(&taskEntryPoint,this); return HasReturnvaluesIF::RETURN_OK; } @@ -67,12 +71,16 @@ void PeriodicPosixTask::taskFunctionality(void) { char name[20] = {0}; int status = pthread_getname_np(pthread_self(), name, sizeof(name)); if(status == 0) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "PeriodicPosixTask " << name << ": Deadline " "missed." << std::endl; +#endif } else { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "PeriodicPosixTask X: Deadline missed. " << status << std::endl; +#endif } if (this->deadlineMissedFunc != nullptr) { this->deadlineMissedFunc(); diff --git a/osal/linux/PosixThread.cpp b/osal/linux/PosixThread.cpp index 55d74de3..80bf52c2 100644 --- a/osal/linux/PosixThread.cpp +++ b/osal/linux/PosixThread.cpp @@ -48,8 +48,10 @@ void PosixThread::suspend() { sigaddset(&waitSignal, SIGUSR1); sigwait(&waitSignal, &caughtSig); if (caughtSig != SIGUSR1) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "FixedTimeslotTask: Unknown Signal received: " << caughtSig << std::endl; +#endif } } @@ -118,7 +120,9 @@ uint64_t PosixThread::getCurrentMonotonicTimeMs(){ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) { +#if CPP_OSTREAM_ENABLED == 1 //sif::debug << "PosixThread::createTask" << std::endl; +#endif /* * The attr argument points to a pthread_attr_t structure whose contents are used at thread creation time to determine attributes for the new @@ -129,53 +133,69 @@ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) { pthread_attr_t attributes; int status = pthread_attr_init(&attributes); if(status != 0){ +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Posix Thread attribute init failed with: " << strerror(status) << std::endl; +#endif } void* stackPointer; status = posix_memalign(&stackPointer, sysconf(_SC_PAGESIZE), stackSize); if(status != 0){ +#if CPP_OSTREAM_ENABLED == 1 sif::error << "PosixThread::createTask: Stack init failed with: " << strerror(status) << std::endl; +#endif if(errno == ENOMEM) { uint64_t stackMb = stackSize/10e6; +#if CPP_OSTREAM_ENABLED == 1 sif::error << "PosixThread::createTask: Insufficient memory for" " the requested " << stackMb << " MB" << std::endl; +#endif } else if(errno == EINVAL) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "PosixThread::createTask: Wrong alignment argument!" << std::endl; +#endif } return; } status = pthread_attr_setstack(&attributes, stackPointer, stackSize); if(status != 0){ +#if CPP_OSTREAM_ENABLED == 1 sif::error << "PosixThread::createTask: pthread_attr_setstack " " failed with: " << strerror(status) << std::endl; sif::error << "Make sure the specified stack size is valid and is " "larger than the minimum allowed stack size." << std::endl; +#endif } status = pthread_attr_setinheritsched(&attributes, PTHREAD_EXPLICIT_SCHED); if(status != 0){ +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Posix Thread attribute setinheritsched failed with: " << strerror(status) << std::endl; +#endif } // TODO FIFO -> This needs root privileges for the process status = pthread_attr_setschedpolicy(&attributes,SCHED_FIFO); if(status != 0){ +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Posix Thread attribute schedule policy failed with: " << strerror(status) << std::endl; +#endif } sched_param scheduleParams; scheduleParams.__sched_priority = priority; status = pthread_attr_setschedparam(&attributes, &scheduleParams); if(status != 0){ +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Posix Thread attribute schedule params failed with: " << strerror(status) << std::endl; +#endif } //Set Signal Mask for suspend until startTask is called @@ -184,36 +204,48 @@ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) { sigaddset(&waitSignal, SIGUSR1); status = pthread_sigmask(SIG_BLOCK, &waitSignal, NULL); if(status != 0){ +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Posix Thread sigmask failed failed with: " << strerror(status) << " errno: " << strerror(errno) << std::endl; +#endif } status = pthread_create(&thread,&attributes,fnc_,arg_); if(status != 0){ +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Posix Thread create failed with: " << strerror(status) << std::endl; +#endif } status = pthread_setname_np(thread,name); if(status != 0){ +#if CPP_OSTREAM_ENABLED == 1 sif::error << "PosixThread::createTask: setname failed with: " << strerror(status) << std::endl; +#endif if(status == ERANGE) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "PosixThread::createTask: Task name length longer" " than 16 chars. Truncating.." << std::endl; +#endif name[15] = '\0'; status = pthread_setname_np(thread,name); if(status != 0){ +#if CPP_OSTREAM_ENABLED == 1 sif::error << "PosixThread::createTask: Setting name" " did not work.." << std::endl; +#endif } } } status = pthread_attr_destroy(&attributes); if(status!=0){ +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Posix Thread attribute destroy failed with: " << strerror(status) << std::endl; +#endif } } diff --git a/osal/linux/TcUnixUdpPollingTask.cpp b/osal/linux/TcUnixUdpPollingTask.cpp index af99ec91..9cbb1d02 100644 --- a/osal/linux/TcUnixUdpPollingTask.cpp +++ b/osal/linux/TcUnixUdpPollingTask.cpp @@ -39,14 +39,18 @@ ReturnValue_t TcUnixUdpPollingTask::performOperation(uint8_t opCode) { reinterpret_cast(&senderAddress), &senderSockLen); if(bytesReceived < 0) { // handle error +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TcSocketPollingTask::performOperation: Reception" "error." << std::endl; +#endif handleReadError(); continue; } +#if CPP_OSTREAM_ENABLED == 1 // sif::debug << "TcSocketPollingTask::performOperation: " << bytesReceived // << " bytes received" << std::endl; +#endif ReturnValue_t result = handleSuccessfullTcRead(bytesReceived); if(result != HasReturnvaluesIF::RETURN_FAILED) { @@ -65,9 +69,11 @@ ReturnValue_t TcUnixUdpPollingTask::handleSuccessfullTcRead(size_t bytesRead) { receptionBuffer.data(), bytesRead); // arrayprinter::print(receptionBuffer.data(), bytesRead); if (result != HasReturnvaluesIF::RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TcSerialPollingTask::transferPusToSoftwareBus: Data " "storage failed" << std::endl; sif::error << "Packet size: " << bytesRead << std::endl; +#endif return HasReturnvaluesIF::RETURN_FAILED; } @@ -75,8 +81,10 @@ ReturnValue_t TcUnixUdpPollingTask::handleSuccessfullTcRead(size_t bytesRead) { result = MessageQueueSenderIF::sendMessage(targetTcDestination, &message); if (result != HasReturnvaluesIF::RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Serial Polling: Sending message to queue failed" << std::endl; +#endif tcStore->deleteData(storeId); } return result; @@ -85,15 +93,19 @@ ReturnValue_t TcUnixUdpPollingTask::handleSuccessfullTcRead(size_t bytesRead) { ReturnValue_t TcUnixUdpPollingTask::initialize() { tcStore = objectManager->get(objects::TC_STORE); if (tcStore == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TcSerialPollingTask::initialize: TC Store uninitialized!" << std::endl; +#endif return ObjectManagerIF::CHILD_INIT_FAILED; } tmtcBridge = objectManager->get(tmtcBridgeId); if(tmtcBridge == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TcSocketPollingTask::TcSocketPollingTask: Invalid" " TMTC bridge object!" << std::endl; +#endif return ObjectManagerIF::CHILD_INIT_FAILED; } @@ -115,8 +127,10 @@ void TcUnixUdpPollingTask::setTimeout(double timeoutSeconds) { int result = setsockopt(serverUdpSocket, SOL_SOCKET, SO_RCVTIMEO, &tval, sizeof(receptionTimeout)); if(result == -1) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TcSocketPollingTask::TcSocketPollingTask: Setting " "receive timeout failed with " << strerror(errno) << std::endl; +#endif } } @@ -126,13 +140,17 @@ void TcUnixUdpPollingTask::handleReadError() { case(EAGAIN): { // todo: When working in timeout mode, this will occur more often // and is not an error. +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TcUnixUdpPollingTask::handleReadError: Timeout." << std::endl; +#endif break; } default: { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TcUnixUdpPollingTask::handleReadError: " << strerror(errno) << std::endl; +#endif } } } diff --git a/osal/linux/Timer.cpp b/osal/linux/Timer.cpp index bae631d7..0142025e 100644 --- a/osal/linux/Timer.cpp +++ b/osal/linux/Timer.cpp @@ -10,8 +10,10 @@ Timer::Timer() { sigEvent.sigev_value.sival_ptr = &timerId; int status = timer_create(CLOCK_MONOTONIC, &sigEvent, &timerId); if(status!=0){ +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Timer creation failed with: " << status << " errno: " << errno << std::endl; +#endif } } diff --git a/osal/linux/TmTcUnixUdpBridge.cpp b/osal/linux/TmTcUnixUdpBridge.cpp index ab28623e..769e8aff 100644 --- a/osal/linux/TmTcUnixUdpBridge.cpp +++ b/osal/linux/TmTcUnixUdpBridge.cpp @@ -26,8 +26,10 @@ TmTcUnixUdpBridge::TmTcUnixUdpBridge(object_id_t objectId, //clientSocket = socket(AF_INET, SOCK_DGRAM, 0); serverSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if(serverSocket < 0) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcUnixUdpBridge::TmTcUnixUdpBridge: Could not open" " UDP socket!" << std::endl; +#endif handleSocketError(); return; } @@ -51,9 +53,11 @@ TmTcUnixUdpBridge::TmTcUnixUdpBridge(object_id_t objectId, reinterpret_cast(&serverAddress), serverAddressLen); if(result == -1) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcUnixUdpBridge::TmTcUnixUdpBridge: Could not bind " "local port " << setServerPort << " to server socket!" << std::endl; +#endif handleBindError(); return; } @@ -74,18 +78,24 @@ ReturnValue_t TmTcUnixUdpBridge::sendTm(const uint8_t *data, size_t dataLen) { } // char ipAddress [15]; +#if CPP_OSTREAM_ENABLED == 1 // sif::debug << "IP Address Sender: "<< inet_ntop(AF_INET, // &clientAddress.sin_addr.s_addr, ipAddress, 15) << std::endl; +#endif ssize_t bytesSent = sendto(serverSocket, data, dataLen, flags, reinterpret_cast(&clientAddress), clientAddressLen); if(bytesSent < 0) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcUnixUdpBridge::sendTm: Send operation failed." << std::endl; +#endif handleSendError(); } +#if CPP_OSTREAM_ENABLED == 1 // sif::debug << "TmTcUnixUdpBridge::sendTm: " << bytesSent << " bytes were" // " sent." << std::endl; +#endif return HasReturnvaluesIF::RETURN_OK; } @@ -93,10 +103,12 @@ void TmTcUnixUdpBridge::checkAndSetClientAddress(sockaddr_in& newAddress) { MutexHelper lock(mutex, MutexIF::TimeoutType::WAITING, 10); // char ipAddress [15]; +#if CPP_OSTREAM_ENABLED == 1 // sif::debug << "IP Address Sender: "<< inet_ntop(AF_INET, // &newAddress.sin_addr.s_addr, ipAddress, 15) << std::endl; // sif::debug << "IP Address Old: " << inet_ntop(AF_INET, // &clientAddress.sin_addr.s_addr, ipAddress, 15) << std::endl; +#endif // Set new IP address if it has changed. if(clientAddress.sin_addr.s_addr != newAddress.sin_addr.s_addr) { @@ -117,12 +129,16 @@ void TmTcUnixUdpBridge::handleSocketError() { case(ENOBUFS): case(ENOMEM): case(EPROTONOSUPPORT): +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcUnixBridge::handleSocketError: Socket creation failed" << " with " << strerror(errno) << std::endl; +#endif break; default: +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcUnixBridge::handleSocketError: Unknown error" << std::endl; +#endif break; } } @@ -135,10 +151,12 @@ void TmTcUnixUdpBridge::handleBindError() { Ephermeral ports can be shown with following command: sysctl -A | grep ip_local_port_range */ +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcUnixBridge::handleBindError: Port access issue." "Ports 1-1024 are reserved on UNIX systems and require root " "rights while ephermeral ports should not be used as well." << std::endl; +#endif } break; case(EADDRINUSE): @@ -153,13 +171,17 @@ void TmTcUnixUdpBridge::handleBindError() { case(ENOMEM): case(ENOTDIR): case(EROFS): { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcUnixBridge::handleBindError: Socket creation failed" << " with " << strerror(errno) << std::endl; +#endif break; } default: +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcUnixBridge::handleBindError: Unknown error" << std::endl; +#endif break; } } @@ -167,8 +189,10 @@ void TmTcUnixUdpBridge::handleBindError() { void TmTcUnixUdpBridge::handleSendError() { switch(errno) { default: +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcUnixBridge::handleSendError: " << strerror(errno) << std::endl; +#endif } } diff --git a/osal/rtems/MessageQueue.cpp b/osal/rtems/MessageQueue.cpp index 839182a6..eff8a0fb 100644 --- a/osal/rtems/MessageQueue.cpp +++ b/osal/rtems/MessageQueue.cpp @@ -9,9 +9,11 @@ MessageQueue::MessageQueue(size_t message_depth, size_t max_message_size) : rtems_status_code status = rtems_message_queue_create(name, message_depth, max_message_size, 0, &(this->id)); if (status != RTEMS_SUCCESSFUL) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::MessageQueue: Creating Queue " << std::hex << name << std::dec << " failed with status:" << (uint32_t) status << std::endl; +#endif this->id = 0; } } diff --git a/osal/rtems/MultiObjectTask.cpp b/osal/rtems/MultiObjectTask.cpp index 970d01e1..a315681b 100644 --- a/osal/rtems/MultiObjectTask.cpp +++ b/osal/rtems/MultiObjectTask.cpp @@ -30,8 +30,10 @@ ReturnValue_t MultiObjectTask::startTask() { rtems_status_code status = rtems_task_start(id, MultiObjectTask::taskEntryPoint, rtems_task_argument((void *) this)); if (status != RTEMS_SUCCESSFUL) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "ObjectTask::startTask for " << std::hex << this->getId() << std::dec << " failed." << std::endl; +#endif } switch(status){ case RTEMS_SUCCESSFUL: @@ -63,7 +65,9 @@ void MultiObjectTask::taskFunctionality() { char nameSpace[8] = { 0 }; char* ptr = rtems_object_get_name(getId(), sizeof(nameSpace), nameSpace); +#if CPP_OSTREAM_ENABLED == 1 sif::error << "ObjectTask: " << ptr << " Deadline missed." << std::endl; +#endif if (this->deadlineMissedFunc != nullptr) { this->deadlineMissedFunc(); } diff --git a/osal/rtems/Mutex.cpp b/osal/rtems/Mutex.cpp index a5ec9635..5278a076 100644 --- a/osal/rtems/Mutex.cpp +++ b/osal/rtems/Mutex.cpp @@ -10,16 +10,20 @@ Mutex::Mutex() : RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_INHERIT_PRIORITY, 0, &mutexId); if (status != RTEMS_SUCCESSFUL) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Mutex: creation with name, id " << mutexName << ", " << mutexId << " failed with " << status << std::endl; +#endif } } Mutex::~Mutex() { rtems_status_code status = rtems_semaphore_delete(mutexId); if (status != RTEMS_SUCCESSFUL) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Mutex: deletion for id " << mutexId << " failed with " << status << std::endl; +#endif } } diff --git a/osal/rtems/PollingTask.cpp b/osal/rtems/PollingTask.cpp index db7864fe..591ba743 100644 --- a/osal/rtems/PollingTask.cpp +++ b/osal/rtems/PollingTask.cpp @@ -35,15 +35,19 @@ rtems_task PollingTask::taskEntryPoint(rtems_task_argument argument) { PollingTask *originalTask(reinterpret_cast(argument)); //The task's functionality is called. originalTask->taskFunctionality(); +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "Polling task " << originalTask->getId() << " returned from taskFunctionality." << std::endl; +#endif } void PollingTask::missedDeadlineCounter() { PollingTask::deadlineMissedCount++; if (PollingTask::deadlineMissedCount % 10 == 0) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "PST missed " << PollingTask::deadlineMissedCount << " deadlines." << std::endl; +#endif } } @@ -51,8 +55,10 @@ ReturnValue_t PollingTask::startTask() { rtems_status_code status = rtems_task_start(id, PollingTask::taskEntryPoint, rtems_task_argument((void *) this)); if (status != RTEMS_SUCCESSFUL) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "PollingTask::startTask for " << std::hex << this->getId() << std::dec << " failed." << std::endl; +#endif } switch(status){ case RTEMS_SUCCESSFUL: @@ -75,8 +81,10 @@ ReturnValue_t PollingTask::addSlot(object_id_t componentId, return HasReturnvaluesIF::RETURN_OK; } +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Component " << std::hex << componentId << " not found, not adding it to pst" << std::endl; +#endif return HasReturnvaluesIF::RETURN_FAILED; } diff --git a/osal/rtems/TaskBase.cpp b/osal/rtems/TaskBase.cpp index 4e0c8f00..7e3bd57a 100644 --- a/osal/rtems/TaskBase.cpp +++ b/osal/rtems/TaskBase.cpp @@ -22,9 +22,11 @@ TaskBase::TaskBase(rtems_task_priority set_priority, size_t stack_size, } ReturnValue_t result = convertReturnCode(status); if (result != HasReturnvaluesIF::RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TaskBase::TaskBase: createTask with name " << std::hex << osalName << std::dec << " failed with return code " << (uint32_t) status << std::endl; +#endif this->id = 0; } } diff --git a/osal/windows/TcWinUdpPollingTask.cpp b/osal/windows/TcWinUdpPollingTask.cpp index 06deafd1..e5931609 100644 --- a/osal/windows/TcWinUdpPollingTask.cpp +++ b/osal/windows/TcWinUdpPollingTask.cpp @@ -43,13 +43,17 @@ ReturnValue_t TcWinUdpPollingTask::performOperation(uint8_t opCode) { &senderAddressSize); if(bytesReceived == SOCKET_ERROR) { // handle error +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TcWinUdpPollingTask::performOperation: Reception" " error." << std::endl; +#endif handleReadError(); continue; } +#if CPP_OSTREAM_ENABLED == 1 //sif::debug << "TcWinUdpPollingTask::performOperation: " << bytesReceived // << " bytes received" << std::endl; +#endif ReturnValue_t result = handleSuccessfullTcRead(bytesReceived); if(result != HasReturnvaluesIF::RETURN_FAILED) { @@ -68,9 +72,11 @@ ReturnValue_t TcWinUdpPollingTask::handleSuccessfullTcRead(size_t bytesRead) { receptionBuffer.data(), bytesRead); // arrayprinter::print(receptionBuffer.data(), bytesRead); if (result != HasReturnvaluesIF::RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TcSerialPollingTask::transferPusToSoftwareBus: Data " "storage failed" << std::endl; sif::error << "Packet size: " << bytesRead << std::endl; +#endif return HasReturnvaluesIF::RETURN_FAILED; } @@ -78,8 +84,10 @@ ReturnValue_t TcWinUdpPollingTask::handleSuccessfullTcRead(size_t bytesRead) { result = MessageQueueSenderIF::sendMessage(targetTcDestination, &message); if (result != HasReturnvaluesIF::RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Serial Polling: Sending message to queue failed" << std::endl; +#endif tcStore->deleteData(storeId); } return result; @@ -88,21 +96,27 @@ ReturnValue_t TcWinUdpPollingTask::handleSuccessfullTcRead(size_t bytesRead) { ReturnValue_t TcWinUdpPollingTask::initialize() { tcStore = objectManager->get(objects::TC_STORE); if (tcStore == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TcSerialPollingTask::initialize: TC Store uninitialized!" << std::endl; +#endif return ObjectManagerIF::CHILD_INIT_FAILED; } tmtcBridge = objectManager->get(tmtcBridgeId); if(tmtcBridge == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TcSocketPollingTask::TcSocketPollingTask: Invalid" " TMTC bridge object!" << std::endl; +#endif return ObjectManagerIF::CHILD_INIT_FAILED; } serverUdpSocket = tmtcBridge->serverSocket; +#if CPP_OSTREAM_ENABLED == 1 //sif::info << "TcWinUdpPollingTask::initialize: Server UDP socket " // << serverUdpSocket << std::endl; +#endif return HasReturnvaluesIF::RETURN_OK; } @@ -119,8 +133,10 @@ void TcWinUdpPollingTask::setTimeout(double timeoutSeconds) { int result = setsockopt(serverUdpSocket, SOL_SOCKET, SO_RCVTIMEO, reinterpret_cast(&timeoutMs), sizeof(DWORD)); if(result == -1) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TcWinUdpPollingTask::TcSocketPollingTask: Setting " "receive timeout failed with " << strerror(errno) << std::endl; +#endif } } @@ -128,23 +144,31 @@ void TcWinUdpPollingTask::handleReadError() { int error = WSAGetLastError(); switch(error) { case(WSANOTINITIALISED): { +#if CPP_OSTREAM_ENABLED == 1 sif::info << "TcWinUdpPollingTask::handleReadError: WSANOTINITIALISED: " << "WSAStartup(...) call " << "necessary" << std::endl; +#endif break; } case(WSAEFAULT): { +#if CPP_OSTREAM_ENABLED == 1 sif::info << "TcWinUdpPollingTask::handleReadError: WSADEFAULT: " << "Bad address " << std::endl; +#endif break; } case(WSAEINVAL): { +#if CPP_OSTREAM_ENABLED == 1 sif::info << "TcWinUdpPollingTask::handleReadError: WSAEINVAL: " << "Invalid input parameters. " << std::endl; +#endif break; } default: { +#if CPP_OSTREAM_ENABLED == 1 sif::info << "TcWinUdpPollingTask::handleReadError: Error code: " << error << std::endl; +#endif break; } } diff --git a/osal/windows/TmTcWinUdpBridge.cpp b/osal/windows/TmTcWinUdpBridge.cpp index e1ba132e..b9945168 100644 --- a/osal/windows/TmTcWinUdpBridge.cpp +++ b/osal/windows/TmTcWinUdpBridge.cpp @@ -15,8 +15,10 @@ TmTcWinUdpBridge::TmTcWinUdpBridge(object_id_t objectId, if (err != 0) { /* Tell the user that we could not find a usable */ /* Winsock DLL. */ +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcWinUdpBridge::TmTcWinUdpBridge:" "WSAStartup failed with error: " << err << std::endl; +#endif return; } @@ -34,8 +36,10 @@ TmTcWinUdpBridge::TmTcWinUdpBridge(object_id_t objectId, //clientSocket = socket(AF_INET, SOCK_DGRAM, 0); serverSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if(serverSocket == INVALID_SOCKET) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcWinUdpBridge::TmTcWinUdpBridge: Could not open" " UDP socket!" << std::endl; +#endif handleSocketError(); return; } @@ -59,9 +63,11 @@ TmTcWinUdpBridge::TmTcWinUdpBridge(object_id_t objectId, reinterpret_cast(&serverAddress), serverAddressLen); if(result != 0) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcWinUdpBridge::TmTcWinUdpBridge: Could not bind " "local port " << setServerPort << " to server socket!" << std::endl; +#endif handleBindError(); } } @@ -77,19 +83,25 @@ ReturnValue_t TmTcWinUdpBridge::sendTm(const uint8_t *data, size_t dataLen) { //clientAddressLen = sizeof(serverAddress); // char ipAddress [15]; +#if CPP_OSTREAM_ENABLED == 1 // sif::debug << "IP Address Sender: "<< inet_ntop(AF_INET, // &clientAddress.sin_addr.s_addr, ipAddress, 15) << std::endl; +#endif ssize_t bytesSent = sendto(serverSocket, reinterpret_cast(data), dataLen, flags, reinterpret_cast(&clientAddress), clientAddressLen); if(bytesSent == SOCKET_ERROR) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcWinUdpBridge::sendTm: Send operation failed." << std::endl; +#endif handleSendError(); } +#if CPP_OSTREAM_ENABLED == 1 // sif::debug << "TmTcUnixUdpBridge::sendTm: " << bytesSent << " bytes were" // " sent." << std::endl; +#endif return HasReturnvaluesIF::RETURN_OK; } @@ -97,10 +109,12 @@ void TmTcWinUdpBridge::checkAndSetClientAddress(sockaddr_in newAddress) { MutexHelper lock(mutex, MutexIF::TimeoutType::WAITING, 10); // char ipAddress [15]; +#if CPP_OSTREAM_ENABLED == 1 // sif::debug << "IP Address Sender: "<< inet_ntop(AF_INET, // &newAddress.sin_addr.s_addr, ipAddress, 15) << std::endl; // sif::debug << "IP Address Old: " << inet_ntop(AF_INET, // &clientAddress.sin_addr.s_addr, ipAddress, 15) << std::endl; +#endif registerCommConnect(); // Set new IP address if it has changed. @@ -114,8 +128,10 @@ void TmTcWinUdpBridge::handleSocketError() { int errCode = WSAGetLastError(); switch(errCode) { case(WSANOTINITIALISED): { +#if CPP_OSTREAM_ENABLED == 1 sif::info << "TmTcWinUdpBridge::handleSocketError: WSANOTINITIALISED: " << "WSAStartup(...) call necessary" << std::endl; +#endif break; } default: { @@ -123,8 +139,10 @@ void TmTcWinUdpBridge::handleSocketError() { https://docs.microsoft.com/en-us/windows/win32/winsock/ windows-sockets-error-codes-2 */ +#if CPP_OSTREAM_ENABLED == 1 sif::info << "TmTcWinUdpBridge::handleSocketError: Error code: " << errCode << std::endl; +#endif break; } } @@ -134,13 +152,17 @@ void TmTcWinUdpBridge::handleBindError() { int errCode = WSAGetLastError(); switch(errCode) { case(WSANOTINITIALISED): { +#if CPP_OSTREAM_ENABLED == 1 sif::info << "TmTcWinUdpBridge::handleBindError: WSANOTINITIALISED: " << "WSAStartup(...) call " << "necessary" << std::endl; +#endif break; } case(WSAEADDRINUSE): { +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "TmTcWinUdpBridge::handleBindError: WSAEADDRINUSE: " << "Port is already in use!" << std::endl; +#endif break; } default: { @@ -148,8 +170,10 @@ void TmTcWinUdpBridge::handleBindError() { https://docs.microsoft.com/en-us/windows/win32/winsock/ windows-sockets-error-codes-2 */ +#if CPP_OSTREAM_ENABLED == 1 sif::info << "TmTcWinUdpBridge::handleBindError: Error code: " << errCode << std::endl; +#endif break; } } @@ -159,13 +183,17 @@ void TmTcWinUdpBridge::handleSendError() { int errCode = WSAGetLastError(); switch(errCode) { case(WSANOTINITIALISED): { +#if CPP_OSTREAM_ENABLED == 1 sif::info << "TmTcWinUdpBridge::handleSendError: WSANOTINITIALISED: " << "WSAStartup(...) call necessary" << std::endl; +#endif break; } case(WSAEADDRNOTAVAIL): { +#if CPP_OSTREAM_ENABLED == 1 sif::info << "TmTcWinUdpBridge::handleSendError: WSAEADDRNOTAVAIL: " << "Check target address. " << std::endl; +#endif break; } default: { @@ -173,8 +201,10 @@ void TmTcWinUdpBridge::handleSendError() { https://docs.microsoft.com/en-us/windows/win32/winsock/ windows-sockets-error-codes-2 */ +#if CPP_OSTREAM_ENABLED == 1 sif::info << "TmTcWinUdpBridge::handleSendError: Error code: " << errCode << std::endl; +#endif break; } } diff --git a/parameters/ParameterHelper.cpp b/parameters/ParameterHelper.cpp index 23d1a1f3..5014e44c 100644 --- a/parameters/ParameterHelper.cpp +++ b/parameters/ParameterHelper.cpp @@ -48,8 +48,10 @@ ReturnValue_t ParameterHelper::handleParameterMessage(CommandMessage *message) { ConstStorageAccessor accessor(storeId); result = storage->getData(storeId, accessor); if (result != HasReturnvaluesIF::RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "ParameterHelper::handleParameterMessage: Getting" << " store data failed for load command." << std::endl; +#endif break; } diff --git a/pus/CService201HealthCommanding.cpp b/pus/CService201HealthCommanding.cpp index edacd73a..f2c579d5 100644 --- a/pus/CService201HealthCommanding.cpp +++ b/pus/CService201HealthCommanding.cpp @@ -22,7 +22,9 @@ ReturnValue_t CService201HealthCommanding::isValidSubservice(uint8_t subservice) case(Subservice::COMMAND_ANNOUNCE_HEALTH_ALL): return RETURN_OK; default: +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Invalid Subservice" << std::endl; +#endif return AcceptsTelecommandsIF::INVALID_SUBSERVICE; } } diff --git a/pus/Service1TelecommandVerification.cpp b/pus/Service1TelecommandVerification.cpp index 86b0dcde..9194ab24 100644 --- a/pus/Service1TelecommandVerification.cpp +++ b/pus/Service1TelecommandVerification.cpp @@ -51,8 +51,10 @@ ReturnValue_t Service1TelecommandVerification::sendVerificationReport( result = generateSuccessReport(message); } if(result != HasReturnvaluesIF::RETURN_OK){ +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Service1TelecommandVerification::sendVerificationReport: " "Sending verification packet failed !" << std::endl; +#endif } return result; } @@ -88,9 +90,11 @@ ReturnValue_t Service1TelecommandVerification::initialize() { AcceptsTelemetryIF* funnel = objectManager-> get(targetDestination); if(funnel == nullptr){ +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Service1TelecommandVerification::initialize: Specified" " TM funnel invalid. Make sure it is set up and implements" " AcceptsTelemetryIF." << std::endl; +#endif return ObjectManagerIF::CHILD_INIT_FAILED; } tmQueue->setDefaultDestination(funnel->getReportReceptionQueue()); diff --git a/pus/Service2DeviceAccess.cpp b/pus/Service2DeviceAccess.cpp index 3648b7eb..f79c0a79 100644 --- a/pus/Service2DeviceAccess.cpp +++ b/pus/Service2DeviceAccess.cpp @@ -25,7 +25,9 @@ ReturnValue_t Service2DeviceAccess::isValidSubservice(uint8_t subservice) { case Subservice::COMMAND_TOGGLE_WIRETAPPING: return HasReturnvaluesIF::RETURN_OK; default: +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Invalid Subservice" << std::endl; +#endif return AcceptsTelecommandsIF::INVALID_SUBSERVICE; } } @@ -125,9 +127,11 @@ void Service2DeviceAccess::handleUnrequestedReply(CommandMessage* reply) { static_cast(Subservice::REPLY_RAW)); break; default: +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Unknown message in Service2DeviceAccess::" "handleUnrequestedReply with command ID " << reply->getCommand() << std::endl; +#endif break; } //Must be reached by all cases to clear message @@ -143,9 +147,11 @@ void Service2DeviceAccess::sendWiretappingTm(CommandMessage *reply, size_t size = 0; ReturnValue_t result = IPCStore->getData(storeAddress, &data, &size); if(result != HasReturnvaluesIF::RETURN_OK){ +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Service2DeviceAccess::sendWiretappingTm: Data Lost in " "handleUnrequestedReply with failure ID "<< result << std::endl; +#endif return; } diff --git a/pus/Service3Housekeeping.cpp b/pus/Service3Housekeeping.cpp index 175af026..d52ab50d 100644 --- a/pus/Service3Housekeeping.cpp +++ b/pus/Service3Housekeeping.cpp @@ -222,8 +222,10 @@ ReturnValue_t Service3Housekeeping::handleReply(const CommandMessage* reply, } default: +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Service3Housekeeping::handleReply: Invalid reply with " << "reply command " << command << "!" << std::endl; +#endif return CommandingServiceBase::INVALID_REPLY; } return HasReturnvaluesIF::RETURN_OK; @@ -249,16 +251,20 @@ void Service3Housekeeping::handleUnrequestedReply( } default: +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Service3Housekeeping::handleUnrequestedReply: Invalid " << "reply with " << "reply command " << command << "!" << std::endl; +#endif return; } if(result != HasReturnvaluesIF::RETURN_OK) { // Configuration error +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "Service3Housekeeping::handleUnrequestedReply:" << "Could not generate reply!" << std::endl; +#endif } } diff --git a/pus/Service5EventReporting.cpp b/pus/Service5EventReporting.cpp index e0b34a5b..21bf2780 100644 --- a/pus/Service5EventReporting.cpp +++ b/pus/Service5EventReporting.cpp @@ -37,8 +37,10 @@ ReturnValue_t Service5EventReporting::performService() { } } } +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "Service5EventReporting::generateEventReport:" " Too many events" << std::endl; +#endif return HasReturnvaluesIF::RETURN_OK; } @@ -53,8 +55,10 @@ ReturnValue_t Service5EventReporting::generateEventReport( ReturnValue_t result = tmPacket.sendPacket( requestQueue->getDefaultDestination(),requestQueue->getId()); if(result != HasReturnvaluesIF::RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "Service5EventReporting::generateEventReport:" " Could not send TM packet" << std::endl; +#endif } return result; } diff --git a/pus/Service8FunctionManagement.cpp b/pus/Service8FunctionManagement.cpp index d710c56e..df25dd85 100644 --- a/pus/Service8FunctionManagement.cpp +++ b/pus/Service8FunctionManagement.cpp @@ -60,9 +60,11 @@ ReturnValue_t Service8FunctionManagement::prepareCommand( ReturnValue_t Service8FunctionManagement::prepareDirectCommand( CommandMessage *message, const uint8_t *tcData, size_t tcDataLen) { if(tcDataLen < sizeof(object_id_t) + sizeof(ActionId_t)) { +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "Service8FunctionManagement::prepareDirectCommand:" << " TC size smaller thant minimum size of direct command." << std::endl; +#endif return CommandingServiceBase::INVALID_TC; } @@ -125,8 +127,10 @@ ReturnValue_t Service8FunctionManagement::handleDataReply( const uint8_t * buffer = nullptr; ReturnValue_t result = IPCStore->getData(storeId, &buffer, &size); if(result != RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Service 8: Could not retrieve data for data reply" << std::endl; +#endif return result; } DataReply dataReply(objectId, actionId, buffer, size); @@ -135,8 +139,10 @@ ReturnValue_t Service8FunctionManagement::handleDataReply( auto deletionResult = IPCStore->deleteData(storeId); if(deletionResult != HasReturnvaluesIF::RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "Service8FunctionManagement::handleReply: Deletion" << " of data in pool failed." << std::endl; +#endif } return result; } diff --git a/serialize/SerialBufferAdapter.cpp b/serialize/SerialBufferAdapter.cpp index 1c11afd4..303de742 100644 --- a/serialize/SerialBufferAdapter.cpp +++ b/serialize/SerialBufferAdapter.cpp @@ -95,8 +95,10 @@ ReturnValue_t SerialBufferAdapter::deSerialize(const uint8_t** buffer, template uint8_t * SerialBufferAdapter::getBuffer() { if(buffer == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Wrong access function for stored type !" " Use getConstBuffer()." << std::endl; +#endif return nullptr; } return buffer; @@ -105,8 +107,10 @@ uint8_t * SerialBufferAdapter::getBuffer() { template const uint8_t * SerialBufferAdapter::getConstBuffer() { if(constBuffer == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "SerialBufferAdapter::getConstBuffer:" " Buffers are unitialized!" << std::endl; +#endif return nullptr; } return constBuffer; diff --git a/storagemanager/ConstStorageAccessor.cpp b/storagemanager/ConstStorageAccessor.cpp index 842f1ce8..0beef64f 100644 --- a/storagemanager/ConstStorageAccessor.cpp +++ b/storagemanager/ConstStorageAccessor.cpp @@ -46,7 +46,9 @@ const uint8_t* ConstStorageAccessor::data() const { size_t ConstStorageAccessor::size() const { if(internalState == AccessState::UNINIT) { +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "StorageAccessor: Not initialized!" << std::endl; +#endif } return size_; } @@ -54,12 +56,16 @@ size_t ConstStorageAccessor::size() const { ReturnValue_t ConstStorageAccessor::getDataCopy(uint8_t *pointer, size_t maxSize) { if(internalState == AccessState::UNINIT) { +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "StorageAccessor: Not initialized!" << std::endl; +#endif return HasReturnvaluesIF::RETURN_FAILED; } if(size_ > maxSize) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "StorageAccessor: Supplied buffer not large enough" << std::endl; +#endif return HasReturnvaluesIF::RETURN_FAILED; } std::copy(constDataPointer, constDataPointer + size_, pointer); @@ -76,7 +82,9 @@ store_address_t ConstStorageAccessor::getId() const { void ConstStorageAccessor::print() const { if(internalState == AccessState::UNINIT or constDataPointer == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "StorageAccessor: Not initialized!" << std::endl; +#endif return; } arrayprinter::print(constDataPointer, size_); diff --git a/storagemanager/LocalPool.cpp b/storagemanager/LocalPool.cpp index 74e362d4..b2d5ffc4 100644 --- a/storagemanager/LocalPool.cpp +++ b/storagemanager/LocalPool.cpp @@ -8,8 +8,10 @@ LocalPool::LocalPool(object_id_t setObjectId, const LocalPoolConfig& poolConfig, NUMBER_OF_POOLS(poolConfig.size()), spillsToHigherPools(spillsToHigherPools) { if(NUMBER_OF_POOLS == 0) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "LocalPool::LocalPool: Passed pool configuration is " << " invalid!" << std::endl; +#endif } max_pools_t index = 0; for (const auto& currentPoolConfig: poolConfig) { @@ -118,8 +120,10 @@ ReturnValue_t LocalPool::modifyData(store_address_t storeId, ReturnValue_t LocalPool::deleteData(store_address_t storeId) { #if FSFW_VERBOSE_PRINTOUT == 2 +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "Delete: Pool: " << std::dec << storeId.poolIndex << " Index: " << storeId.packetIndex << std::endl; +#endif #endif ReturnValue_t status = RETURN_OK; @@ -134,8 +138,10 @@ ReturnValue_t LocalPool::deleteData(store_address_t storeId) { } else { //pool_index or packet_index is too large +#if CPP_OSTREAM_ENABLED == 1 sif::error << "LocalPool::deleteData: Illegal store ID, no deletion!" << std::endl; +#endif status = ILLEGAL_STORAGE_ID; } return status; @@ -158,8 +164,10 @@ ReturnValue_t LocalPool::deleteData(uint8_t *ptr, size_t size, result = deleteData(localId); #if FSFW_VERBOSE_PRINTOUT == 2 if (deltaAddress % elementSizes[n] != 0) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "LocalPool::deleteData: Address not aligned!" << std::endl; +#endif } #endif break; @@ -186,8 +194,10 @@ ReturnValue_t LocalPool::initialize() { //Check if any pool size is large than the maximum allowed. for (uint8_t count = 0; count < NUMBER_OF_POOLS; count++) { if (elementSizes[count] >= STORAGE_FREE) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "LocalPool::initialize: Pool is too large! " "Max. allowed size is: " << (STORAGE_FREE - 1) << std::endl; +#endif return StorageManagerIF::POOL_TOO_LARGE; } } @@ -209,8 +219,10 @@ ReturnValue_t LocalPool::reserveSpace(const size_t size, store_address_t *storeId, bool ignoreFault) { ReturnValue_t status = getPoolIndex(size, &storeId->poolIndex); if (status != RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "LocalPool( " << std::hex << getObjectId() << std::dec << " )::reserveSpace: Packet too large." << std::endl; +#endif return status; } status = findEmpty(storeId->poolIndex, &storeId->packetIndex); @@ -224,9 +236,11 @@ ReturnValue_t LocalPool::reserveSpace(const size_t size, } if (status == RETURN_OK) { #if FSFW_VERBOSE_PRINTOUT == 2 +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "Reserve: Pool: " << std::dec << storeId->poolIndex << " Index: " << storeId->packetIndex << std::endl; +#endif #endif sizeLists[storeId->poolIndex][storeId->packetIndex] = size; } @@ -266,8 +280,10 @@ ReturnValue_t LocalPool::getPoolIndex(size_t packetSize, uint16_t *poolIndex, uint16_t startAtIndex) { for (uint16_t n = startAtIndex; n < NUMBER_OF_POOLS; n++) { #if FSFW_VERBOSE_PRINTOUT == 2 +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "LocalPool " << getObjectId() << "::getPoolIndex: Pool: " << n << ", Element Size: " << elementSizes[n] << std::endl; +#endif #endif if (elementSizes[n] >= packetSize) { *poolIndex = n; diff --git a/storagemanager/PoolManager.cpp b/storagemanager/PoolManager.cpp index 3b7b549b..7612fbc0 100644 --- a/storagemanager/PoolManager.cpp +++ b/storagemanager/PoolManager.cpp @@ -26,9 +26,11 @@ ReturnValue_t PoolManager::reserveSpace(const size_t size, ReturnValue_t PoolManager::deleteData( store_address_t storeId) { #if FSFW_VERBOSE_PRINTOUT == 2 +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "PoolManager( " << translateObject(getObjectId()) << " )::deleteData from store " << storeId.poolIndex << ". id is "<< storeId.packetIndex << std::endl; +#endif #endif MutexHelper mutexHelper(mutex, MutexIF::TimeoutType::WAITING, mutexTimeoutMs); diff --git a/storagemanager/StorageAccessor.cpp b/storagemanager/StorageAccessor.cpp index 9c2f936a..373407b0 100644 --- a/storagemanager/StorageAccessor.cpp +++ b/storagemanager/StorageAccessor.cpp @@ -26,12 +26,16 @@ StorageAccessor::StorageAccessor(StorageAccessor&& other): ReturnValue_t StorageAccessor::getDataCopy(uint8_t *pointer, size_t maxSize) { if(internalState == AccessState::UNINIT) { +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "StorageAccessor: Not initialized!" << std::endl; +#endif return HasReturnvaluesIF::RETURN_FAILED; } if(size_ > maxSize) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "StorageAccessor: Supplied buffer not large " "enough" << std::endl; +#endif return HasReturnvaluesIF::RETURN_FAILED; } std::copy(dataPointer, dataPointer + size_, pointer); @@ -40,7 +44,9 @@ ReturnValue_t StorageAccessor::getDataCopy(uint8_t *pointer, size_t maxSize) { uint8_t* StorageAccessor::data() { if(internalState == AccessState::UNINIT) { +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "StorageAccessor: Not initialized!" << std::endl; +#endif } return dataPointer; } @@ -48,12 +54,16 @@ uint8_t* StorageAccessor::data() { ReturnValue_t StorageAccessor::write(uint8_t *data, size_t size, uint16_t offset) { if(internalState == AccessState::UNINIT) { +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "StorageAccessor: Not initialized!" << std::endl; +#endif return HasReturnvaluesIF::RETURN_FAILED; } if(offset + size > size_) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "StorageAccessor: Data too large for pool " "entry!" << std::endl; +#endif return HasReturnvaluesIF::RETURN_FAILED; } std::copy(data, data + size, dataPointer + offset); diff --git a/subsystem/SubsystemBase.cpp b/subsystem/SubsystemBase.cpp index f60c8847..4ae50858 100644 --- a/subsystem/SubsystemBase.cpp +++ b/subsystem/SubsystemBase.cpp @@ -86,8 +86,10 @@ void SubsystemBase::executeTable(HybridIterator tableIter, object_id_t object = tableIter.value->getObject(); if ((iter = childrenMap.find(object)) == childrenMap.end()) { //illegal table entry, should only happen due to misconfigured mode table +#if CPP_OSTREAM_ENABLED == 1 sif::debug << std::hex << getObjectId() << ": invalid mode table entry" << std::endl; +#endif continue; } diff --git a/tasks/FixedSlotSequence.cpp b/tasks/FixedSlotSequence.cpp index e5db4301..9d15a9c7 100644 --- a/tasks/FixedSlotSequence.cpp +++ b/tasks/FixedSlotSequence.cpp @@ -91,8 +91,10 @@ void FixedSlotSequence::addSlot(object_id_t componentId, uint32_t slotTimeMs, ReturnValue_t FixedSlotSequence::checkSequence() const { if(slotList.empty()) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "FixedSlotSequence::checkSequence:" << " Slot list is empty!" << std::endl; +#endif return HasReturnvaluesIF::RETURN_FAILED; } @@ -100,8 +102,10 @@ ReturnValue_t FixedSlotSequence::checkSequence() const { ReturnValue_t result = customCheckFunction(slotList); if(result != HasReturnvaluesIF::RETURN_OK) { // Continue for now but print error output. +#if CPP_OSTREAM_ENABLED == 1 sif::error << "FixedSlotSequence::checkSequence:" << " Custom check failed!" << std::endl; +#endif } } @@ -112,21 +116,27 @@ ReturnValue_t FixedSlotSequence::checkSequence() const { errorCount++; } else if (slot.pollingTimeMs < time) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "FixedSlotSequence::checkSequence: Time: " << slot.pollingTimeMs << " is smaller than previous with " << time << std::endl; +#endif errorCount++; } else { // All ok, print slot. +#if CPP_OSTREAM_ENABLED == 1 //sif::info << "Current slot polling time: " << std::endl; //sif::info << std::dec << slotIt->pollingTimeMs << std::endl; +#endif } time = slot.pollingTimeMs; } +#if CPP_OSTREAM_ENABLED == 1 //sif::info << "Number of elements in slot list: " // << slotList.size() << std::endl; +#endif if (errorCount > 0) { return HasReturnvaluesIF::RETURN_FAILED; } @@ -149,8 +159,10 @@ ReturnValue_t FixedSlotSequence::intializeSequenceAfterTaskCreation() const { } } if (count > 0) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "FixedSlotSequence::intializeSequenceAfterTaskCreation:" "Counted " << count << " failed initializations!" << std::endl; +#endif return HasReturnvaluesIF::RETURN_FAILED; } return HasReturnvaluesIF::RETURN_OK; diff --git a/tcdistribution/CCSDSDistributor.cpp b/tcdistribution/CCSDSDistributor.cpp index ddd63308..742dd648 100644 --- a/tcdistribution/CCSDSDistributor.cpp +++ b/tcdistribution/CCSDSDistributor.cpp @@ -11,21 +11,27 @@ CCSDSDistributor::CCSDSDistributor(uint16_t setDefaultApid, CCSDSDistributor::~CCSDSDistributor() {} TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() { +#if CPP_OSTREAM_ENABLED == 1 // sif::debug << "CCSDSDistributor::selectDestination received: " << // this->currentMessage.getStorageId().pool_index << ", " << // this->currentMessage.getStorageId().packet_index << std::endl; +#endif const uint8_t* packet = nullptr; size_t size = 0; ReturnValue_t result = this->tcStore->getData(currentMessage.getStorageId(), &packet, &size ); if(result != HasReturnvaluesIF::RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "CCSDSDistributor::selectDestination: Getting data from" " store failed!" << std::endl; +#endif } SpacePacketBase currentPacket(packet); +#if CPP_OSTREAM_ENABLED == 1 // sif:: info << "CCSDSDistributor::selectDestination has packet with APID " // << std::hex << currentPacket.getAPID() << std::dec << std::endl; +#endif TcMqMapIter position = this->queueMap.find(currentPacket.getAPID()); if ( position != this->queueMap.end() ) { return position; @@ -70,8 +76,10 @@ ReturnValue_t CCSDSDistributor::initialize() { ReturnValue_t status = this->TcDistributor::initialize(); this->tcStore = objectManager->get( objects::TC_STORE ); if (this->tcStore == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "CCSDSDistributor::initialize: Could not initialize" " TC store!" << std::endl; +#endif status = RETURN_FAILED; } return status; diff --git a/tcdistribution/PUSDistributor.cpp b/tcdistribution/PUSDistributor.cpp index 8e5b94cc..3a214268 100644 --- a/tcdistribution/PUSDistributor.cpp +++ b/tcdistribution/PUSDistributor.cpp @@ -13,9 +13,11 @@ PUSDistributor::PUSDistributor(uint16_t setApid, object_id_t setObjectId, PUSDistributor::~PUSDistributor() {} PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() { +#if CPP_OSTREAM_ENABLED == 1 // sif:: debug << "PUSDistributor::handlePacket received: " // << this->current_packet_id.store_index << ", " // << this->current_packet_id.packet_index << std::endl; +#endif TcMqMapIter queueMapIt = this->queueMap.end(); if(this->currentPacket == nullptr) { return queueMapIt; @@ -25,9 +27,11 @@ PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() { tcStatus = checker.checkPacket(currentPacket); #ifdef DEBUG if(tcStatus != HasReturnvaluesIF::RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "PUSDistributor::handlePacket: Packet format " << "invalid, code "<< static_cast(tcStatus) << std::endl; +#endif } #endif uint32_t queue_id = currentPacket->getService(); @@ -40,8 +44,10 @@ PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() { if (queueMapIt == this->queueMap.end()) { tcStatus = DESTINATION_NOT_FOUND; #ifdef DEBUG +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "PUSDistributor::handlePacket: Destination not found, " << "code "<< static_cast(tcStatus) << std::endl; +#endif #endif } @@ -57,12 +63,16 @@ PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() { ReturnValue_t PUSDistributor::registerService(AcceptsTelecommandsIF* service) { uint16_t serviceId = service->getIdentifier(); +#if CPP_OSTREAM_ENABLED == 1 // sif::info << "Service ID: " << (int)serviceId << std::endl; +#endif MessageQueueId_t queue = service->getRequestQueue(); auto returnPair = queueMap.emplace(serviceId, queue); if (not returnPair.second) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "PUSDistributor::registerService: Service ID already" " exists in map." << std::endl; +#endif return SERVICE_ID_ALREADY_EXISTS; } return HasReturnvaluesIF::RETURN_OK; @@ -104,9 +114,11 @@ ReturnValue_t PUSDistributor::initialize() { CCSDSDistributorIF* ccsdsDistributor = objectManager->get(packetSource); if (ccsdsDistributor == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "PUSDistributor::initialize: Packet source invalid." << " Make sure it exists and implements CCSDSDistributorIF!" << std::endl; +#endif return RETURN_FAILED; } return ccsdsDistributor->registerApplication(this); diff --git a/tcdistribution/TcDistributor.cpp b/tcdistribution/TcDistributor.cpp index 06e1817f..0bd4a906 100644 --- a/tcdistribution/TcDistributor.cpp +++ b/tcdistribution/TcDistributor.cpp @@ -39,6 +39,7 @@ ReturnValue_t TcDistributor::handlePacket() { } void TcDistributor::print() { +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "Distributor content is: " << std::endl << "ID\t| Message Queue ID" << std::endl; sif::debug << std::setfill('0') << std::setw(8) << std::hex; @@ -47,7 +48,7 @@ void TcDistributor::print() { << std::endl; } sif::debug << std::setfill(' ') << std::dec; - +#endif } ReturnValue_t TcDistributor::callbackAfterSending(ReturnValue_t queueStatus) { diff --git a/timemanager/Stopwatch.cpp b/timemanager/Stopwatch.cpp index 302e2ac0..b3d080ba 100644 --- a/timemanager/Stopwatch.cpp +++ b/timemanager/Stopwatch.cpp @@ -28,13 +28,17 @@ double Stopwatch::stopSeconds() { void Stopwatch::display() { if(displayMode == StopwatchDisplayMode::MILLIS) { +#if CPP_OSTREAM_ENABLED == 1 sif::info << "Stopwatch: Operation took " << (elapsedTime.tv_sec * 1000 + elapsedTime.tv_usec / 1000) << " milliseconds" << std::endl; +#endif } else if(displayMode == StopwatchDisplayMode::SECONDS) { +#if CPP_OSTREAM_ENABLED == 1 sif::info <<"Stopwatch: Operation took " << std::setprecision(3) << std::fixed << timevalOperations::toDouble(elapsedTime) << " seconds" << std::endl; +#endif } } diff --git a/tmtcpacket/pus/TcPacketBase.cpp b/tmtcpacket/pus/TcPacketBase.cpp index eaa8416a..1a28419c 100644 --- a/tmtcpacket/pus/TcPacketBase.cpp +++ b/tmtcpacket/pus/TcPacketBase.cpp @@ -63,7 +63,9 @@ uint8_t TcPacketBase::getPusVersionNumber() { } void TcPacketBase::print() { +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "TcPacketBase::print: " << std::endl; +#endif arrayprinter::print(getWholeData(), getFullSize()); } diff --git a/tmtcpacket/pus/TcPacketStored.cpp b/tmtcpacket/pus/TcPacketStored.cpp index fffc86ae..021b6d67 100644 --- a/tmtcpacket/pus/TcPacketStored.cpp +++ b/tmtcpacket/pus/TcPacketStored.cpp @@ -23,8 +23,10 @@ TcPacketStored::TcPacketStored(uint16_t apid, uint8_t service, ReturnValue_t returnValue = this->store->getFreeElement(&this->storeAddress, (TC_PACKET_MIN_SIZE + size), &pData); if (returnValue != this->store->RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "TcPacketStored: Could not get free element from store!" << std::endl; +#endif return; } this->setData(pData); @@ -39,7 +41,9 @@ ReturnValue_t TcPacketStored::getData(const uint8_t ** dataPtr, size_t* dataSize) { auto result = this->store->getData(storeAddress, dataPtr, dataSize); if(result != HasReturnvaluesIF::RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "TcPacketStored: Could not get data!" << std::endl; +#endif } return result; } @@ -61,8 +65,10 @@ bool TcPacketStored::checkAndSetStore() { if (this->store == nullptr) { this->store = objectManager->get(objects::TC_STORE); if (this->store == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TcPacketStored::TcPacketStored: TC Store not found!" << std::endl; +#endif return false; } } diff --git a/tmtcpacket/pus/TmPacketBase.cpp b/tmtcpacket/pus/TmPacketBase.cpp index 2c8bfd63..bf892ccf 100644 --- a/tmtcpacket/pus/TmPacketBase.cpp +++ b/tmtcpacket/pus/TmPacketBase.cpp @@ -57,7 +57,9 @@ void TmPacketBase::setData(const uint8_t* p_Data) { } void TmPacketBase::print() { +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "TmPacketBase::print: " << std::endl; +#endif arrayprinter::print(getWholeData(), getFullSize()); } @@ -65,8 +67,10 @@ bool TmPacketBase::checkAndSetStamper() { if (timeStamper == NULL) { timeStamper = objectManager->get(timeStamperId); if (timeStamper == NULL) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TmPacketBase::checkAndSetStamper: Stamper not found!" << std::endl; +#endif return false; } } diff --git a/tmtcpacket/pus/TmPacketStored.cpp b/tmtcpacket/pus/TmPacketStored.cpp index 0fb789aa..21f237bd 100644 --- a/tmtcpacket/pus/TmPacketStored.cpp +++ b/tmtcpacket/pus/TmPacketStored.cpp @@ -105,8 +105,10 @@ bool TmPacketStored::checkAndSetStore() { if (store == nullptr) { store = objectManager->get(objects::TM_STORE); if (store == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TmPacketStored::TmPacketStored: TM Store not found!" << std::endl; +#endif return false; } } diff --git a/tmtcservices/CommandingServiceBase.cpp b/tmtcservices/CommandingServiceBase.cpp index ed765ecc..2be6e2ce 100644 --- a/tmtcservices/CommandingServiceBase.cpp +++ b/tmtcservices/CommandingServiceBase.cpp @@ -75,8 +75,10 @@ ReturnValue_t CommandingServiceBase::initialize() { packetSource); if (packetForwarding == nullptr or distributor == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "CommandingServiceBase::intialize: Packet source or " "packet destination invalid!" << std::endl; +#endif return ObjectManagerIF::CHILD_INIT_FAILED; } @@ -88,8 +90,10 @@ ReturnValue_t CommandingServiceBase::initialize() { TCStore = objectManager->get(objects::TC_STORE); if (IPCStore == nullptr or TCStore == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "CommandingServiceBase::intialize: IPC store or TC store " "not initialized yet!" << std::endl; +#endif return ObjectManagerIF::CHILD_INIT_FAILED; } diff --git a/tmtcservices/PusServiceBase.cpp b/tmtcservices/PusServiceBase.cpp index cb5a1247..1b03a7f0 100644 --- a/tmtcservices/PusServiceBase.cpp +++ b/tmtcservices/PusServiceBase.cpp @@ -25,9 +25,11 @@ ReturnValue_t PusServiceBase::performOperation(uint8_t opCode) { handleRequestQueue(); ReturnValue_t result = this->performService(); if (result != RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "PusService " << (uint16_t) this->serviceId << ": performService returned with " << (int16_t) result << std::endl; +#endif return RETURN_FAILED; } return RETURN_OK; @@ -43,11 +45,13 @@ void PusServiceBase::handleRequestQueue() { for (uint8_t count = 0; count < PUS_SERVICE_MAX_RECEPTION; count++) { ReturnValue_t status = this->requestQueue->receiveMessage(&message); // if(status != MessageQueueIF::EMPTY) { +#if CPP_OSTREAM_ENABLED == 1 // sif::debug << "PusServiceBase::performOperation: Receiving from " // << "MQ ID: " << std::hex << "0x" << std::setw(8) // << std::setfill('0') << this->requestQueue->getId() // << std::dec << " returned: " << status << std::setfill(' ') // << std::endl; +#endif // } if (status == RETURN_OK) { @@ -79,9 +83,11 @@ void PusServiceBase::handleRequestQueue() { break; } else { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "PusServiceBase::performOperation: Service " << this->serviceId << ": Error receiving packet. Code: " << std::hex << status << std::dec << std::endl; +#endif } } } @@ -104,10 +110,12 @@ ReturnValue_t PusServiceBase::initialize() { PUSDistributorIF* distributor = objectManager->get( packetSource); if (destService == nullptr or distributor == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "PusServiceBase::PusServiceBase: Service " << this->serviceId << ": Configuration error. Make sure " << "packetSource and packetDestination are defined correctly" << std::endl; +#endif return ObjectManagerIF::CHILD_INIT_FAILED; } this->requestQueue->setDefaultDestination( diff --git a/tmtcservices/TmTcBridge.cpp b/tmtcservices/TmTcBridge.cpp index b4e9967b..954e3e75 100644 --- a/tmtcservices/TmTcBridge.cpp +++ b/tmtcservices/TmTcBridge.cpp @@ -23,9 +23,11 @@ ReturnValue_t TmTcBridge::setNumberOfSentPacketsPerCycle( return RETURN_OK; } else { +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "TmTcBridge::setNumberOfSentPacketsPerCycle: Number of " << "packets sent per cycle exceeds limits. " << "Keeping default value." << std::endl; +#endif return RETURN_FAILED; } } @@ -37,9 +39,11 @@ ReturnValue_t TmTcBridge::setMaxNumberOfPacketsStored( return RETURN_OK; } else { +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "TmTcBridge::setMaxNumberOfPacketsStored: Number of " << "packets stored exceeds limits. " << "Keeping default value." << std::endl; +#endif return RETURN_FAILED; } } @@ -47,21 +51,27 @@ ReturnValue_t TmTcBridge::setMaxNumberOfPacketsStored( ReturnValue_t TmTcBridge::initialize() { tcStore = objectManager->get(tcStoreId); if (tcStore == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcBridge::initialize: TC store invalid. Make sure" "it is created and set up properly." << std::endl; +#endif return ObjectManagerIF::CHILD_INIT_FAILED; } tmStore = objectManager->get(tmStoreId); if (tmStore == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcBridge::initialize: TM store invalid. Make sure" "it is created and set up properly." << std::endl; +#endif return ObjectManagerIF::CHILD_INIT_FAILED; } AcceptsTelecommandsIF* tcDistributor = objectManager->get(tcDestination); if (tcDistributor == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcBridge::initialize: TC Distributor invalid" << std::endl; +#endif return ObjectManagerIF::CHILD_INIT_FAILED; } @@ -75,13 +85,17 @@ ReturnValue_t TmTcBridge::performOperation(uint8_t operationCode) { ReturnValue_t result; result = handleTc(); if(result != RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "TmTcBridge::performOperation: " << "Error handling TCs" << std::endl; +#endif } result = handleTm(); if (result != RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "TmTcBridge::performOperation: " << "Error handling TMs" << std::endl; +#endif } return result; } @@ -94,9 +108,11 @@ ReturnValue_t TmTcBridge::handleTm() { ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; ReturnValue_t result = handleTmQueue(); if(result != RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcBridge::handleTm: Error handling TM queue with " << "error code 0x" << std::hex << result << std::dec << "!" << std::endl; +#endif status = result; } @@ -104,8 +120,10 @@ ReturnValue_t TmTcBridge::handleTm() { (packetSentCounter < sentPacketsPerCycle)) { result = handleStoredTm(); if(result != RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcBridge::handleTm: Error handling stored TMs!" << std::endl; +#endif status = result; } } @@ -122,7 +140,9 @@ ReturnValue_t TmTcBridge::handleTmQueue() { result == HasReturnvaluesIF::RETURN_OK; result = tmTcReceptionQueue->receiveMessage(&message)) { +#if CPP_OSTREAM_ENABLED == 1 //sif::info << (int) packetSentCounter << std::endl; +#endif if(communicationLinkUp == false or packetSentCounter >= sentPacketsPerCycle) { storeDownlinkData(&message); @@ -151,8 +171,10 @@ ReturnValue_t TmTcBridge::storeDownlinkData(TmTcMessage *message) { store_address_t storeId = 0; if(tmFifo->full()) { +#if CPP_OSTREAM_ENABLED == 1 sif::debug << "TmTcBridge::storeDownlinkData: TM downlink max. number " << "of stored packet IDs reached! " << std::endl; +#endif if(overwriteOld) { tmFifo->retrieve(&storeId); tmStore->deleteData(storeId); @@ -171,8 +193,10 @@ ReturnValue_t TmTcBridge::storeDownlinkData(TmTcMessage *message) { ReturnValue_t TmTcBridge::handleStoredTm() { ReturnValue_t status = RETURN_OK; while(not tmFifo->empty() and packetSentCounter < sentPacketsPerCycle) { +#if CPP_OSTREAM_ENABLED == 1 //sif::info << "TMTC Bridge: Sending stored TM data. There are " // << (int) tmFifo->size() << " left to send\r\n" << std::flush; +#endif store_address_t storeId; const uint8_t* data = nullptr; @@ -185,8 +209,10 @@ ReturnValue_t TmTcBridge::handleStoredTm() { result = sendTm(data,size); if(result != RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "TMTC Bridge: Could not send stored downlink data" << std::endl; +#endif status = result; } packetSentCounter ++; @@ -201,13 +227,17 @@ ReturnValue_t TmTcBridge::handleStoredTm() { void TmTcBridge::registerCommConnect() { if(not communicationLinkUp) { +#if CPP_OSTREAM_ENABLED == 1 //sif::info << "TMTC Bridge: Registered Comm Link Connect" << std::endl; +#endif communicationLinkUp = true; } } void TmTcBridge::registerCommDisconnect() { +#if CPP_OSTREAM_ENABLED == 1 //sif::info << "TMTC Bridge: Registered Comm Link Disconnect" << std::endl; +#endif if(communicationLinkUp) { communicationLinkUp = false; } diff --git a/tmtcservices/VerificationReporter.cpp b/tmtcservices/VerificationReporter.cpp index 7e40bd27..3bd1f067 100644 --- a/tmtcservices/VerificationReporter.cpp +++ b/tmtcservices/VerificationReporter.cpp @@ -27,9 +27,11 @@ void VerificationReporter::sendSuccessReport(uint8_t set_report_id, ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); if (status != HasReturnvaluesIF::RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "VerificationReporter::sendSuccessReport: Error writing " << "to queue. Code: " << std::hex << status << std::dec << std::endl; +#endif } } @@ -44,9 +46,11 @@ void VerificationReporter::sendSuccessReport(uint8_t set_report_id, ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); if (status != HasReturnvaluesIF::RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "VerificationReporter::sendSuccessReport: Error writing " << "to queue. Code: " << std::hex << status << std::dec << std::endl; +#endif } } @@ -64,9 +68,11 @@ void VerificationReporter::sendFailureReport(uint8_t report_id, ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); if (status != HasReturnvaluesIF::RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "VerificationReporter::sendFailureReport: Error writing " << "to queue. Code: " << std::hex << "0x" << status << std::dec << std::endl; +#endif } } @@ -82,24 +88,30 @@ void VerificationReporter::sendFailureReport(uint8_t report_id, ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); if (status != HasReturnvaluesIF::RETURN_OK) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "VerificationReporter::sendFailureReport: Error writing " << "to queue. Code: " << std::hex << "0x" << status << std::dec << std::endl; +#endif } } void VerificationReporter::initialize() { if(messageReceiver == objects::NO_OBJECT) { +#if CPP_OSTREAM_ENABLED == 1 sif::warning << "VerificationReporter::initialize: Verification message" " receiver object ID not set yet in Factory!" << std::endl; +#endif return; } AcceptsVerifyMessageIF* temp = objectManager->get( messageReceiver); if (temp == nullptr) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "VerificationReporter::initialize: Message " << "receiver invalid. Make sure it is set up properly and " << "implementsAcceptsVerifyMessageIF" << std::endl; +#endif return; } this->acknowledgeQueue = temp->getVerificationQueue(); diff --git a/unittest/internal/InternalUnitTester.cpp b/unittest/internal/InternalUnitTester.cpp index 503a71ec..6771b17e 100644 --- a/unittest/internal/InternalUnitTester.cpp +++ b/unittest/internal/InternalUnitTester.cpp @@ -13,13 +13,17 @@ InternalUnitTester::InternalUnitTester() {} InternalUnitTester::~InternalUnitTester() {} ReturnValue_t InternalUnitTester::performTests() { +#if CPP_OSTREAM_ENABLED == 1 sif::info << "Running internal unit tests.." << std::endl; +#endif testserialize::test_serialization(); testmq::testMq(); testsemaph::testBinSemaph(); testsemaph::testCountingSemaph(); testmutex::testMutex(); +#if CPP_OSTREAM_ENABLED == 1 sif::info << "Internal unit tests finished." << std::endl; +#endif return RETURN_OK; } diff --git a/unittest/internal/UnittDefinitions.cpp b/unittest/internal/UnittDefinitions.cpp index 6265e9fd..292c4b8a 100644 --- a/unittest/internal/UnittDefinitions.cpp +++ b/unittest/internal/UnittDefinitions.cpp @@ -1,7 +1,9 @@ #include "UnittDefinitions.h" ReturnValue_t unitt::put_error(std::string errorId) { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Unit Tester error: Failed at test ID " << errorId << "\n" << std::flush; +#endif return HasReturnvaluesIF::RETURN_FAILED; } diff --git a/unittest/internal/osal/IntTestSemaphore.cpp b/unittest/internal/osal/IntTestSemaphore.cpp index 5a82f78c..908326d4 100644 --- a/unittest/internal/osal/IntTestSemaphore.cpp +++ b/unittest/internal/osal/IntTestSemaphore.cpp @@ -94,8 +94,10 @@ void testsemaph::testBinSemaphoreImplementation(SemaphoreIF* binSemaph, result = binSemaph->acquire(SemaphoreIF::TimeoutType::WAITING, 10); //dur_millis_t time = stopwatch.stop(); // if(abs(time - 10) > 2) { +#if CPP_OSTREAM_ENABLED == 1 // sif::error << "UnitTester: Semaphore timeout measured incorrect." // << std::endl; +#endif // unitt::put_error(id); // } } diff --git a/unittest/user/testcfg/pollingsequence/PollingSequenceFactory.cpp b/unittest/user/testcfg/pollingsequence/PollingSequenceFactory.cpp index f836a746..443b2bbb 100644 --- a/unittest/user/testcfg/pollingsequence/PollingSequenceFactory.cpp +++ b/unittest/user/testcfg/pollingsequence/PollingSequenceFactory.cpp @@ -15,8 +15,10 @@ ReturnValue_t pst::pollingSequenceInitDefault( return HasReturnvaluesIF::RETURN_OK; } else { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "pst::pollingSequenceInitDefault: Sequence invalid!" << std::endl; +#endif return HasReturnvaluesIF::RETURN_FAILED; } } diff --git a/unittest/user/unittest/core/CatchDefinitions.cpp b/unittest/user/unittest/core/CatchDefinitions.cpp index 0b66558a..6504700c 100644 --- a/unittest/user/unittest/core/CatchDefinitions.cpp +++ b/unittest/user/unittest/core/CatchDefinitions.cpp @@ -5,7 +5,9 @@ StorageManagerIF* tglob::getIpcStoreHandle() { if(objectManager != nullptr) { return objectManager->get(objects::IPC_STORE); } else { +#if CPP_OSTREAM_ENABLED == 1 sif::error << "Global object manager uninitialized" << std::endl; +#endif return nullptr; } } From afda3b2fa063b8d45b5b725ad2a36822041dc4d8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 3 Jan 2021 14:00:29 +0100 Subject: [PATCH 19/50] small tweak --- objectmanager/ObjectManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/objectmanager/ObjectManager.cpp b/objectmanager/ObjectManager.cpp index 12f4ef4f..a7e3ac4c 100644 --- a/objectmanager/ObjectManager.cpp +++ b/objectmanager/ObjectManager.cpp @@ -81,8 +81,8 @@ void ObjectManager::initialize() { for (auto const& it : objectList) { result = it.second->initialize(); if ( result != RETURN_OK ) { - object_id_t var = it.first; #if CPP_OSTREAM_ENABLED == 1 + object_id_t var = it.first; sif::error << "ObjectManager::initialize: Object 0x" << std::hex << std::setw(8) << std::setfill('0')<< var << " failed to " "initialize with code 0x" << result << std::dec << From 4515c0d3cd5c4eb00218767da8d75c72448e1f23 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 3 Jan 2021 14:08:40 +0100 Subject: [PATCH 20/50] exlcuding ostream headers --- datapool/PoolEntry.cpp | 1 + health/HealthTableIF.h | 2 ++ objectmanager/ObjectManager.cpp | 3 +++ serviceinterface/ServiceInterfaceBuffer.cpp | 9 +++++++-- serviceinterface/ServiceInterfaceBuffer.h | 4 ++++ serviceinterface/ServiceInterfaceStream.cpp | 4 ++++ serviceinterface/ServiceInterfaceStream.h | 5 +++++ 7 files changed, 26 insertions(+), 2 deletions(-) diff --git a/datapool/PoolEntry.cpp b/datapool/PoolEntry.cpp index b1ccb260..369799c2 100644 --- a/datapool/PoolEntry.cpp +++ b/datapool/PoolEntry.cpp @@ -3,6 +3,7 @@ #include "../serviceinterface/ServiceInterfaceStream.h" #include "../globalfunctions/arrayprinter.h" #include +#include template PoolEntry::PoolEntry(std::initializer_list initValue, uint8_t setLength, diff --git a/health/HealthTableIF.h b/health/HealthTableIF.h index d61e6761..727c4496 100644 --- a/health/HealthTableIF.h +++ b/health/HealthTableIF.h @@ -5,6 +5,8 @@ #include "../objectmanager/ObjectManagerIF.h" #include "../returnvalues/HasReturnvaluesIF.h" +#include + class HealthTableIF: public ManagesHealthIF { public: virtual ~HealthTableIF() {} diff --git a/objectmanager/ObjectManager.cpp b/objectmanager/ObjectManager.cpp index a7e3ac4c..251dbc70 100644 --- a/objectmanager/ObjectManager.cpp +++ b/objectmanager/ObjectManager.cpp @@ -1,6 +1,9 @@ #include "ObjectManager.h" #include "../serviceinterface/ServiceInterfaceStream.h" + +#if CPP_OSTREAM_ENABLED == 1 #include +#endif #include ObjectManager::ObjectManager( void (*setProducer)() ): diff --git a/serviceinterface/ServiceInterfaceBuffer.cpp b/serviceinterface/ServiceInterfaceBuffer.cpp index 222c1e2c..abe296cb 100644 --- a/serviceinterface/ServiceInterfaceBuffer.cpp +++ b/serviceinterface/ServiceInterfaceBuffer.cpp @@ -1,7 +1,10 @@ -#include "../timemanager/Clock.h" #include "ServiceInterfaceBuffer.h" + +#if CPP_OSTREAM_ENABLED == 1 + +#include "../timemanager/Clock.h" + #include "serviceInterfaceDefintions.h" -#include #include #include @@ -252,3 +255,5 @@ void ServiceInterfaceBuffer::initSocket() { } #endif //ML505 + +#endif /* CPP_OSTREAM_ENABLED == 1 */ diff --git a/serviceinterface/ServiceInterfaceBuffer.h b/serviceinterface/ServiceInterfaceBuffer.h index 8f2a601c..d13143cd 100644 --- a/serviceinterface/ServiceInterfaceBuffer.h +++ b/serviceinterface/ServiceInterfaceBuffer.h @@ -3,6 +3,9 @@ #include "../returnvalues/HasReturnvaluesIF.h" #include + +#if CPP_OSTREAM_ENABLED == 1 + #include #include #include @@ -147,5 +150,6 @@ private: }; #endif //ML505 +#endif /* CPP_OSTREAM_ENABLED == 1 */ #endif /* FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACEBUFFER_H_ */ diff --git a/serviceinterface/ServiceInterfaceStream.cpp b/serviceinterface/ServiceInterfaceStream.cpp index 05643460..c618d989 100644 --- a/serviceinterface/ServiceInterfaceStream.cpp +++ b/serviceinterface/ServiceInterfaceStream.cpp @@ -1,5 +1,7 @@ #include "ServiceInterfaceStream.h" +#if CPP_OSTREAM_ENABLED == 1 + ServiceInterfaceStream::ServiceInterfaceStream(std::string setMessage, bool addCrToPreamble, bool buffered, bool errStream, uint16_t port) : std::ostream(&streambuf), @@ -13,3 +15,5 @@ std::string* ServiceInterfaceStream::getPreamble() { return streambuf.getPreamble(); } +#endif + diff --git a/serviceinterface/ServiceInterfaceStream.h b/serviceinterface/ServiceInterfaceStream.h index cd2adf85..ddeded80 100644 --- a/serviceinterface/ServiceInterfaceStream.h +++ b/serviceinterface/ServiceInterfaceStream.h @@ -2,6 +2,9 @@ #define FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACESTREAM_H_ #include "ServiceInterfaceBuffer.h" + +#if CPP_OSTREAM_ENABLED == 1 + #include #include @@ -48,4 +51,6 @@ extern ServiceInterfaceStream warning; extern ServiceInterfaceStream error; } +#endif /* CPP_OSTREAM_ENABLED == 1 */ + #endif /* FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACESTREAM_H_ */ From 2edf15831202666468599a2880933a4398ab0681 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 3 Jan 2021 14:16:52 +0100 Subject: [PATCH 21/50] correct preprocessor define now used --- container/SharedRingBuffer.cpp | 2 +- controller/ExtendedControllerBase.cpp | 2 +- datalinklayer/Clcw.cpp | 2 +- datalinklayer/DataLinkLayer.cpp | 4 +-- datalinklayer/MapPacketExtraction.cpp | 12 +++---- datalinklayer/TcTransferFrame.cpp | 2 +- datalinklayer/TcTransferFrameLocal.cpp | 2 +- datalinklayer/VirtualChannelReception.cpp | 2 +- datapool/PoolDataSetBase.cpp | 10 +++--- datapool/PoolEntry.cpp | 6 ++-- datapoollocal/HasLocalDataPoolIF.h | 2 +- datapoollocal/LocalDataPoolManager.cpp | 28 +++++++-------- datapoollocal/LocalDataPoolManager.h | 4 +-- datapoollocal/LocalPoolDataSetBase.cpp | 8 ++--- datapoollocal/LocalPoolObjectBase.cpp | 8 ++--- datapoollocal/LocalPoolVariable.tpp | 8 ++--- datapoollocal/LocalPoolVector.tpp | 12 +++---- datapoollocal/PoolReadHelper.h | 2 +- .../PollingSequenceFactory.cpp | 2 +- devicehandlers/DeviceHandlerBase.cpp | 20 +++++------ .../DeviceHandlerFailureIsolation.cpp | 4 +-- events/EventManager.cpp | 6 ++-- fdir/FailureIsolationBase.cpp | 8 ++--- globalfunctions/arrayprinter.cpp | 8 ++--- health/HealthHelper.cpp | 8 ++--- internalError/InternalErrorReporter.cpp | 2 +- ipc/MessageQueueMessage.cpp | 4 +-- ipc/MutexHelper.h | 4 +-- memory/MemoryHelper.cpp | 2 +- monitoring/MonitoringMessageContent.h | 2 +- objectmanager/ObjectManager.cpp | 22 ++++++------ objectmanager/ObjectManagerIF.h | 2 +- osal/FreeRTOS/BinSemaphUsingTask.cpp | 2 +- osal/FreeRTOS/BinarySemaphore.cpp | 6 ++-- osal/FreeRTOS/CountingSemaphUsingTask.cpp | 6 ++-- osal/FreeRTOS/CountingSemaphore.cpp | 8 ++--- osal/FreeRTOS/FixedTimeslotTask.cpp | 6 ++-- osal/FreeRTOS/MessageQueue.cpp | 2 +- osal/FreeRTOS/Mutex.cpp | 2 +- osal/FreeRTOS/PeriodicTask.cpp | 6 ++-- osal/FreeRTOS/SemaphoreFactory.cpp | 4 +-- osal/host/Clock.cpp | 16 ++++----- osal/host/FixedTimeslotTask.cpp | 8 ++--- osal/host/MessageQueue.cpp | 4 +-- osal/host/PeriodicTask.cpp | 6 ++-- osal/host/QueueMapManager.cpp | 4 +-- osal/host/SemaphoreFactory.cpp | 4 +-- osal/linux/BinarySemaphore.cpp | 6 ++-- osal/linux/Clock.cpp | 2 +- osal/linux/CountingSemaphore.cpp | 2 +- osal/linux/FixedTimeslotTask.cpp | 4 +-- osal/linux/MessageQueue.cpp | 34 +++++++++---------- osal/linux/Mutex.cpp | 8 ++--- osal/linux/PeriodicPosixTask.cpp | 8 ++--- osal/linux/PosixThread.cpp | 32 ++++++++--------- osal/linux/TcUnixUdpPollingTask.cpp | 18 +++++----- osal/linux/Timer.cpp | 2 +- osal/linux/TmTcUnixUdpBridge.cpp | 24 ++++++------- osal/rtems/MessageQueue.cpp | 2 +- osal/rtems/MultiObjectTask.cpp | 4 +-- osal/rtems/Mutex.cpp | 4 +-- osal/rtems/PollingTask.cpp | 8 ++--- osal/rtems/TaskBase.cpp | 2 +- osal/windows/TcWinUdpPollingTask.cpp | 24 ++++++------- osal/windows/TmTcWinUdpBridge.cpp | 30 ++++++++-------- parameters/ParameterHelper.cpp | 2 +- pus/CService201HealthCommanding.cpp | 2 +- pus/Service1TelecommandVerification.cpp | 4 +-- pus/Service2DeviceAccess.cpp | 6 ++-- pus/Service3Housekeeping.cpp | 6 ++-- pus/Service5EventReporting.cpp | 4 +-- pus/Service8FunctionManagement.cpp | 6 ++-- serialize/SerialBufferAdapter.cpp | 4 +-- serviceinterface/ServiceInterfaceBuffer.cpp | 4 +-- serviceinterface/ServiceInterfaceBuffer.h | 4 +-- serviceinterface/ServiceInterfaceStream.cpp | 2 +- serviceinterface/ServiceInterfaceStream.h | 4 +-- storagemanager/ConstStorageAccessor.cpp | 8 ++--- storagemanager/LocalPool.cpp | 16 ++++----- storagemanager/PoolManager.cpp | 2 +- storagemanager/StorageAccessor.cpp | 10 +++--- subsystem/SubsystemBase.cpp | 2 +- tasks/FixedSlotSequence.cpp | 12 +++---- tcdistribution/CCSDSDistributor.cpp | 8 ++--- tcdistribution/PUSDistributor.cpp | 12 +++---- tcdistribution/TcDistributor.cpp | 2 +- timemanager/Stopwatch.cpp | 4 +-- tmtcpacket/pus/TcPacketBase.cpp | 2 +- tmtcpacket/pus/TcPacketStored.cpp | 6 ++-- tmtcpacket/pus/TmPacketBase.cpp | 4 +-- tmtcpacket/pus/TmPacketStored.cpp | 2 +- tmtcservices/CommandingServiceBase.cpp | 4 +-- tmtcservices/PusServiceBase.cpp | 8 ++--- tmtcservices/TmTcBridge.cpp | 30 ++++++++-------- tmtcservices/VerificationReporter.cpp | 12 +++---- unittest/internal/InternalUnitTester.cpp | 4 +-- unittest/internal/UnittDefinitions.cpp | 2 +- unittest/internal/osal/IntTestSemaphore.cpp | 2 +- .../PollingSequenceFactory.cpp | 2 +- .../user/unittest/core/CatchDefinitions.cpp | 2 +- 100 files changed, 356 insertions(+), 356 deletions(-) diff --git a/container/SharedRingBuffer.cpp b/container/SharedRingBuffer.cpp index 340bce37..769ce000 100644 --- a/container/SharedRingBuffer.cpp +++ b/container/SharedRingBuffer.cpp @@ -47,7 +47,7 @@ ReturnValue_t SharedRingBuffer::initialize() { DynamicFIFO* SharedRingBuffer::getReceiveSizesFIFO() { if(receiveSizesFIFO == nullptr) { // Configuration error. -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "SharedRingBuffer::getReceiveSizesFIFO: Ring buffer" << " was not configured to have sizes FIFO, returning nullptr!" << std::endl; diff --git a/controller/ExtendedControllerBase.cpp b/controller/ExtendedControllerBase.cpp index f9f7534d..017acafe 100644 --- a/controller/ExtendedControllerBase.cpp +++ b/controller/ExtendedControllerBase.cpp @@ -107,7 +107,7 @@ MessageQueueId_t ExtendedControllerBase::getCommandQueue() const { } LocalPoolDataSetBase* ExtendedControllerBase::getDataSetHandle(sid_t sid) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "ExtendedControllerBase::getDataSetHandle: No child " << " implementation provided, returning nullptr!" << std::endl; #endif diff --git a/datalinklayer/Clcw.cpp b/datalinklayer/Clcw.cpp index 19aa4e7b..13971929 100644 --- a/datalinklayer/Clcw.cpp +++ b/datalinklayer/Clcw.cpp @@ -55,7 +55,7 @@ void Clcw::setBitLock(bool bitLock) { } void Clcw::print() { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "Clcw::print: Clcw is: " << std::hex << getAsWhole() << std::dec << std::endl; #endif } diff --git a/datalinklayer/DataLinkLayer.cpp b/datalinklayer/DataLinkLayer.cpp index 6a383851..1bdaa4f5 100644 --- a/datalinklayer/DataLinkLayer.cpp +++ b/datalinklayer/DataLinkLayer.cpp @@ -98,7 +98,7 @@ ReturnValue_t DataLinkLayer::processFrame(uint16_t length) { receivedDataLength = length; ReturnValue_t status = allFramesReception(); if (status != RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "DataLinkLayer::processFrame: frame reception failed. " "Error code: " << std::hex << status << std::dec << std::endl; #endif @@ -126,7 +126,7 @@ ReturnValue_t DataLinkLayer::initialize() { if ( virtualChannels.begin() != virtualChannels.end() ) { clcw->setVirtualChannel( virtualChannels.begin()->second->getChannelId() ); } else { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "DataLinkLayer::initialize: No VC assigned to this DLL instance! " << std::endl; #endif return RETURN_FAILED; diff --git a/datalinklayer/MapPacketExtraction.cpp b/datalinklayer/MapPacketExtraction.cpp index 0bf79f42..cdc9ae27 100644 --- a/datalinklayer/MapPacketExtraction.cpp +++ b/datalinklayer/MapPacketExtraction.cpp @@ -29,7 +29,7 @@ ReturnValue_t MapPacketExtraction::extractPackets(TcTransferFrame* frame) { bufferPosition = &packetBuffer[packetLength]; status = RETURN_OK; } else { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MapPacketExtraction::extractPackets. Packet too large! Size: " << packetLength << std::endl; @@ -53,7 +53,7 @@ ReturnValue_t MapPacketExtraction::extractPackets(TcTransferFrame* frame) { } status = RETURN_OK; } else { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MapPacketExtraction::extractPackets. Packet too large! Size: " << packetLength << std::endl; @@ -62,7 +62,7 @@ ReturnValue_t MapPacketExtraction::extractPackets(TcTransferFrame* frame) { status = CONTENT_TOO_LARGE; } } else { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MapPacketExtraction::extractPackets. Illegal segment! Last flag: " << (int) lastSegmentationFlag << std::endl; @@ -72,7 +72,7 @@ ReturnValue_t MapPacketExtraction::extractPackets(TcTransferFrame* frame) { } break; default: -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MapPacketExtraction::extractPackets. Illegal segmentationFlag: " << (int) segmentationFlag << std::endl; @@ -143,11 +143,11 @@ ReturnValue_t MapPacketExtraction::initialize() { } void MapPacketExtraction::printPacketBuffer(void) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "DLL: packet_buffer contains: " << std::endl; #endif for (uint32_t i = 0; i < this->packetLength; ++i) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "packet_buffer[" << std::dec << i << "]: 0x" << std::hex << (uint16_t) this->packetBuffer[i] << std::endl; #endif diff --git a/datalinklayer/TcTransferFrame.cpp b/datalinklayer/TcTransferFrame.cpp index 0050994a..ee094dc3 100644 --- a/datalinklayer/TcTransferFrame.cpp +++ b/datalinklayer/TcTransferFrame.cpp @@ -87,7 +87,7 @@ uint8_t* TcTransferFrame::getFullDataField() { } void TcTransferFrame::print() { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "Raw Frame: " << std::hex << std::endl; for (uint16_t count = 0; count < this->getFullSize(); count++ ) { sif::debug << (uint16_t)this->getFullFrame()[count] << " "; diff --git a/datalinklayer/TcTransferFrameLocal.cpp b/datalinklayer/TcTransferFrameLocal.cpp index 1ef772a2..de8f568f 100644 --- a/datalinklayer/TcTransferFrameLocal.cpp +++ b/datalinklayer/TcTransferFrameLocal.cpp @@ -37,7 +37,7 @@ TcTransferFrameLocal::TcTransferFrameLocal(bool bypass, bool controlCommand, uin this->getFullFrame()[getFullSize()-2] = (crc & 0xFF00) >> 8; this->getFullFrame()[getFullSize()-1] = (crc & 0x00FF); } else { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "TcTransferFrameLocal: dataSize too large: " << dataSize << std::endl; #endif } diff --git a/datalinklayer/VirtualChannelReception.cpp b/datalinklayer/VirtualChannelReception.cpp index 8ad65740..3a56fe1e 100644 --- a/datalinklayer/VirtualChannelReception.cpp +++ b/datalinklayer/VirtualChannelReception.cpp @@ -102,7 +102,7 @@ uint8_t VirtualChannelReception::getChannelId() const { ReturnValue_t VirtualChannelReception::initialize() { ReturnValue_t returnValue = RETURN_FAILED; if ((slidingWindowWidth > 254) || (slidingWindowWidth % 2 != 0)) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "VirtualChannelReception::initialize: Illegal sliding window width: " << (int) slidingWindowWidth << std::endl; #endif diff --git a/datapool/PoolDataSetBase.cpp b/datapool/PoolDataSetBase.cpp index f2c2b867..5fb1c3c7 100644 --- a/datapool/PoolDataSetBase.cpp +++ b/datapool/PoolDataSetBase.cpp @@ -13,21 +13,21 @@ PoolDataSetBase::~PoolDataSetBase() {} ReturnValue_t PoolDataSetBase::registerVariable( PoolVariableIF *variable) { if (state != States::STATE_SET_UNINITIALISED) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "DataSet::registerVariable: " "Call made in wrong position." << std::endl; #endif return DataSetIF::DATA_SET_UNINITIALISED; } if (variable == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "DataSet::registerVariable: " "Pool variable is nullptr." << std::endl; #endif return DataSetIF::POOL_VAR_NULL; } if (fillCount >= maxFillCount) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "DataSet::registerVariable: " "DataSet is full." << std::endl; #endif @@ -53,7 +53,7 @@ ReturnValue_t PoolDataSetBase::read(uint32_t lockTimeout) { unlockDataPool(); } else { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "DataSet::read(): " "Call made in wrong position. Don't forget to commit" " member datasets!" << std::endl; @@ -146,7 +146,7 @@ ReturnValue_t PoolDataSetBase::handleUnreadDatasetCommit(uint32_t lockTimeout) { } else if (registeredVariables[count]->getDataPoolId() != PoolVariableIF::NO_PARAMETER) { if (result != COMMITING_WITHOUT_READING) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "DataSet::commit(): commit-without-read call made " "with non write-only variable." << std::endl; #endif diff --git a/datapool/PoolEntry.cpp b/datapool/PoolEntry.cpp index 369799c2..58375162 100644 --- a/datapool/PoolEntry.cpp +++ b/datapool/PoolEntry.cpp @@ -13,7 +13,7 @@ PoolEntry::PoolEntry(std::initializer_list initValue, uint8_t setLength, std::memset(this->address, 0, this->getByteSize()); } else if (initValue.size() != setLength){ -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "PoolEntry: setLength is not equal to initializer list" "length! Performing zero initialization with given setLength" << std::endl; @@ -70,12 +70,12 @@ bool PoolEntry::getValid() { template void PoolEntry::print() { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "Pool Entry Validity: " << (this->valid? " (valid) " : " (invalid) ") << std::endl; #endif arrayprinter::print(reinterpret_cast(address), length); -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << std::dec << std::endl; #endif } diff --git a/datapoollocal/HasLocalDataPoolIF.h b/datapoollocal/HasLocalDataPoolIF.h index e94af167..7707fab8 100644 --- a/datapoollocal/HasLocalDataPoolIF.h +++ b/datapoollocal/HasLocalDataPoolIF.h @@ -89,7 +89,7 @@ public: * @return */ virtual LocalPoolObjectBase* getPoolObjectHandle(lp_id_t localPoolId) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "HasLocalDataPoolIF::getPoolObjectHandle: Not overriden" << ". Returning nullptr!" << std::endl; #endif diff --git a/datapoollocal/LocalDataPoolManager.cpp b/datapoollocal/LocalDataPoolManager.cpp index 0eb6f5f5..24516aad 100644 --- a/datapoollocal/LocalDataPoolManager.cpp +++ b/datapoollocal/LocalDataPoolManager.cpp @@ -21,7 +21,7 @@ LocalDataPoolManager::LocalDataPoolManager(HasLocalDataPoolIF* owner, MessageQueueIF* queueToUse, bool appendValidityBuffer): appendValidityBuffer(appendValidityBuffer) { if(owner == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "LocalDataPoolManager::LocalDataPoolManager: " << "Invalid supplied owner!" << std::endl; #endif @@ -30,7 +30,7 @@ LocalDataPoolManager::LocalDataPoolManager(HasLocalDataPoolIF* owner, this->owner = owner; mutex = MutexFactory::instance()->createMutex(); if(mutex == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "LocalDataPoolManager::LocalDataPoolManager: " << "Could not create mutex." << std::endl; #endif @@ -43,7 +43,7 @@ LocalDataPoolManager::~LocalDataPoolManager() {} ReturnValue_t LocalDataPoolManager::initialize(MessageQueueIF* queueToUse) { if(queueToUse == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "LocalDataPoolManager::initialize: " << std::hex << "0x" << owner->getObjectId() << ". Supplied " << "queue invalid!" << std::dec << std::endl; @@ -53,7 +53,7 @@ ReturnValue_t LocalDataPoolManager::initialize(MessageQueueIF* queueToUse) { ipcStore = objectManager->get(objects::IPC_STORE); if(ipcStore == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "LocalDataPoolManager::initialize: " << std::hex << "0x" << owner->getObjectId() << ": Could not " << "set IPC store." <getHkQueue(); } else { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "LocalDataPoolManager::LocalDataPoolManager: " << "Default HK destination object is invalid!" << std::endl; #endif @@ -95,7 +95,7 @@ ReturnValue_t LocalDataPoolManager::initializeHousekeepingPoolEntriesOnce() { } return result; } -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "HousekeepingManager: The map should only be initialized " << "once!" << std::endl; #endif @@ -351,7 +351,7 @@ ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(sid_t sid, AcceptsHkPacketsIF* hkReceiverObject = objectManager->get(packetDestination); if(hkReceiverObject == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "LocalDataPoolManager::subscribeForPeriodicPacket:" << " Invalid receiver!"<< std::endl; #endif @@ -383,7 +383,7 @@ ReturnValue_t LocalDataPoolManager::subscribeForUpdatePackets(sid_t sid, AcceptsHkPacketsIF* hkReceiverObject = objectManager->get(packetDestination); if(hkReceiverObject == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "LocalDataPoolManager::subscribeForPeriodicPacket:" << " Invalid receiver!"<< std::endl; #endif @@ -591,7 +591,7 @@ ReturnValue_t LocalDataPoolManager::printPoolEntry( lp_id_t localPoolId) { auto poolIter = localPoolMap.find(localPoolId); if (poolIter == localPoolMap.end()) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "HousekeepingManager::fechPoolEntry:" << " Pool entry not found." << std::endl; #endif @@ -614,7 +614,7 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid, MessageQueueId_t destination) { if(dataSet == nullptr) { // Configuration error. -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "HousekeepingManager::generateHousekeepingPacket:" << " Set ID not found or dataset not assigned!" << std::endl; #endif @@ -698,7 +698,7 @@ void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver& receiver) { sid, dataSet, true); if(result != HasReturnvaluesIF::RETURN_OK) { // configuration error -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "LocalDataPoolManager::performHkOperation:" << "0x" << std::hex << std::setfill('0') << std::setw(8) << owner->getObjectId() << " Error generating " @@ -748,7 +748,7 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid, // Get and check dataset first. LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid); if(dataSet == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "HousekeepingManager::generateHousekeepingPacket:" << " Set ID not found" << std::endl; #endif @@ -776,7 +776,7 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid, ReturnValue_t result = ipcStore->getFreeElement(&storeId, expectedSize,&storePtr); if(result != HasReturnvaluesIF::RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "HousekeepingManager::generateHousekeepingPacket: " << "Could not get free element from IPC store." << std::endl; #endif @@ -788,7 +788,7 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid, result = setPacket.serialize(&storePtr, &size, expectedSize, SerializeIF::Endianness::BIG); if(expectedSize != size) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "HousekeepingManager::generateSetStructurePacket: " << "Expected size is not equal to serialized size" << std::endl; #endif diff --git a/datapoollocal/LocalDataPoolManager.h b/datapoollocal/LocalDataPoolManager.h index 37ae8152..0e98b90c 100644 --- a/datapoollocal/LocalDataPoolManager.h +++ b/datapoollocal/LocalDataPoolManager.h @@ -375,7 +375,7 @@ ReturnValue_t LocalDataPoolManager::fetchPoolEntry(lp_id_t localPoolId, PoolEntry **poolEntry) { auto poolIter = localPoolMap.find(localPoolId); if (poolIter == localPoolMap.end()) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "HousekeepingManager::fechPoolEntry: Pool entry " "not found." << std::endl; #endif @@ -384,7 +384,7 @@ ReturnValue_t LocalDataPoolManager::fetchPoolEntry(lp_id_t localPoolId, *poolEntry = dynamic_cast< PoolEntry* >(poolIter->second); if(*poolEntry == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "HousekeepingManager::fetchPoolEntry:" " Pool entry not found." << std::endl; #endif diff --git a/datapoollocal/LocalPoolDataSetBase.cpp b/datapoollocal/LocalPoolDataSetBase.cpp index 8e13b602..dbe34dfd 100644 --- a/datapoollocal/LocalPoolDataSetBase.cpp +++ b/datapoollocal/LocalPoolDataSetBase.cpp @@ -12,7 +12,7 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner, PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) { if(hkOwner == nullptr) { // Configuration error. -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "LocalPoolDataSetBase::LocalPoolDataSetBase: Owner " << "invalid!" << std::endl; #endif @@ -149,7 +149,7 @@ ReturnValue_t LocalPoolDataSetBase::serializeLocalPoolIds(uint8_t** buffer, auto result = SerializeAdapter::serialize(¤tPoolId, buffer, size, maxSize, streamEndianness); if(result != HasReturnvaluesIF::RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "LocalDataSet::serializeLocalPoolIds: Serialization" " error!" << std::endl; #endif @@ -210,7 +210,7 @@ ReturnValue_t LocalPoolDataSetBase::serialize(uint8_t **buffer, size_t *size, void LocalPoolDataSetBase::bitSetter(uint8_t* byte, uint8_t position) const { if(position > 7) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "Pool Raw Access: Bit setting invalid position" << std::endl; #endif @@ -262,7 +262,7 @@ sid_t LocalPoolDataSetBase::getSid() const { bool LocalPoolDataSetBase::bitGetter(const uint8_t* byte, uint8_t position) const { if(position > 7) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "Pool Raw Access: Bit setting invalid position" << std::endl; #endif diff --git a/datapoollocal/LocalPoolObjectBase.cpp b/datapoollocal/LocalPoolObjectBase.cpp index 5abef424..4b57dede 100644 --- a/datapoollocal/LocalPoolObjectBase.cpp +++ b/datapoollocal/LocalPoolObjectBase.cpp @@ -5,13 +5,13 @@ LocalPoolObjectBase::LocalPoolObjectBase(lp_id_t poolId, pool_rwm_t setReadWriteMode): localPoolId(poolId), readWriteMode(setReadWriteMode) { if(poolId == PoolVariableIF::NO_PARAMETER) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "LocalPoolVar::LocalPoolVar: 0 passed as pool ID, " << "which is the NO_PARAMETER value!" << std::endl; #endif } if(hkOwner == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "LocalPoolVar::LocalPoolVar: The supplied pool " << "owner is a invalid!" << std::endl; #endif @@ -27,7 +27,7 @@ LocalPoolObjectBase::LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId, DataSetIF *dataSet, pool_rwm_t setReadWriteMode): localPoolId(poolId), readWriteMode(setReadWriteMode) { if(poolId == PoolVariableIF::NO_PARAMETER) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "LocalPoolVar::LocalPoolVar: 0 passed as pool ID, " << "which is the NO_PARAMETER value!" << std::endl; #endif @@ -35,7 +35,7 @@ LocalPoolObjectBase::LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId, HasLocalDataPoolIF* hkOwner = objectManager->get(poolOwner); if(hkOwner == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "LocalPoolVariable: The supplied pool owner did not " << "implement the correct interface" << " HasLocalDataPoolIF!" << std::endl; diff --git a/datapoollocal/LocalPoolVariable.tpp b/datapoollocal/LocalPoolVariable.tpp index 38e9cf4b..aa5e5393 100644 --- a/datapoollocal/LocalPoolVariable.tpp +++ b/datapoollocal/LocalPoolVariable.tpp @@ -33,7 +33,7 @@ inline ReturnValue_t LocalPoolVariable::read(dur_millis_t lockTimeout) { template inline ReturnValue_t LocalPoolVariable::readWithoutLock() { if(readWriteMode == pool_rwm_t::VAR_WRITE) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "LocalPoolVar: Invalid read write " "mode for read() call." << std::endl; #endif @@ -43,7 +43,7 @@ inline ReturnValue_t LocalPoolVariable::readWithoutLock() { PoolEntry* poolEntry = nullptr; ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry); if(result != RETURN_OK or poolEntry == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PoolVector: Read of local pool variable of object " << std::hex << std::setw(8) << std::setfill('0') << hkManager->getOwner() << " and lp ID " << localPoolId @@ -66,7 +66,7 @@ inline ReturnValue_t LocalPoolVariable::commit(dur_millis_t lockTimeout) { template inline ReturnValue_t LocalPoolVariable::commitWithoutLock() { if(readWriteMode == pool_rwm_t::VAR_READ) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "LocalPoolVariable: Invalid read write " "mode for commit() call." << std::endl; #endif @@ -75,7 +75,7 @@ inline ReturnValue_t LocalPoolVariable::commitWithoutLock() { PoolEntry* poolEntry = nullptr; ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry); if(result != RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PoolVector: Read of local pool variable of object " "0x" << std::hex << std::setw(8) << std::setfill('0') << hkManager->getOwner() << " and lp ID 0x" << localPoolId << diff --git a/datapoollocal/LocalPoolVector.tpp b/datapoollocal/LocalPoolVector.tpp index dc91fb9b..5c3b0ce0 100644 --- a/datapoollocal/LocalPoolVector.tpp +++ b/datapoollocal/LocalPoolVector.tpp @@ -32,7 +32,7 @@ inline ReturnValue_t LocalPoolVector::read(uint32_t lockTimeout) template inline ReturnValue_t LocalPoolVector::readWithoutLock() { if(readWriteMode == pool_rwm_t::VAR_WRITE) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "LocalPoolVar: Invalid read write " "mode for read() call." << std::endl; #endif @@ -44,7 +44,7 @@ inline ReturnValue_t LocalPoolVector::readWithoutLock() { memset(this->value, 0, vectorSize * sizeof(T)); if(result != RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PoolVector: Read of local pool variable of object " "0x" << std::hex << std::setw(8) << std::setfill('0') << hkManager->getOwner() << "and lp ID 0x" << localPoolId << @@ -68,7 +68,7 @@ inline ReturnValue_t LocalPoolVector::commit( template inline ReturnValue_t LocalPoolVector::commitWithoutLock() { if(readWriteMode == pool_rwm_t::VAR_READ) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "LocalPoolVar: Invalid read write " "mode for commit() call." << std::endl; #endif @@ -77,7 +77,7 @@ inline ReturnValue_t LocalPoolVector::commitWithoutLock() { PoolEntry* poolEntry = nullptr; ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry); if(result != RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PoolVector: Read of local pool variable of object " "0x" << std::hex << std::setw(8) << std::setfill('0') << hkManager->getOwner() << " and lp ID 0x" << localPoolId << @@ -97,7 +97,7 @@ inline T& LocalPoolVector::operator [](int i) { } // If this happens, I have to set some value. I consider this // a configuration error, but I wont exit here. -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "LocalPoolVector: Invalid index. Setting or returning" " last value!" << std::endl; #endif @@ -111,7 +111,7 @@ inline const T& LocalPoolVector::operator [](int i) const { } // If this happens, I have to set some value. I consider this // a configuration error, but I wont exit here. -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "LocalPoolVector: Invalid index. Setting or returning" " last value!" << std::endl; #endif diff --git a/datapoollocal/PoolReadHelper.h b/datapoollocal/PoolReadHelper.h index bf962c95..a059685b 100644 --- a/datapoollocal/PoolReadHelper.h +++ b/datapoollocal/PoolReadHelper.h @@ -14,7 +14,7 @@ public: if(readObject != nullptr) { readResult = readObject->read(mutexTimeout); #if FSFW_PRINT_VERBOSITY_LEVEL == 1 -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PoolReadHelper: Read failed!" << std::endl; #endif #endif diff --git a/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.cpp b/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.cpp index 443b2bbb..b7f1fb3e 100644 --- a/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.cpp +++ b/defaultcfg/fsfwconfig/pollingsequence/PollingSequenceFactory.cpp @@ -15,7 +15,7 @@ ReturnValue_t pst::pollingSequenceInitDefault( return HasReturnvaluesIF::RETURN_OK; } else { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "pst::pollingSequenceInitDefault: Sequence invalid!" << std::endl; #endif diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index da2b823d..1af6932a 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -39,7 +39,7 @@ DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId, cookieInfo.state = COOKIE_UNUSED; cookieInfo.pendingCommand = deviceCommandMap.end(); if (comCookie == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "DeviceHandlerBase: ObjectID 0x" << std::hex << std::setw(8) << std::setfill('0') << this->getObjectId() << std::dec << ": Do not pass nullptr as a cookie, consider " @@ -132,7 +132,7 @@ ReturnValue_t DeviceHandlerBase::initialize() { communicationInterface = objectManager->get( deviceCommunicationId); if (communicationInterface == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "DeviceHandlerBase::initialize: Communication interface " "invalid." << std::endl; sif::error << "Make sure it is set up properly and implements" @@ -143,7 +143,7 @@ ReturnValue_t DeviceHandlerBase::initialize() { result = communicationInterface->initializeInterface(comCookie); if (result != RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "DeviceHandlerBase::initialize: Initializing " "communication interface failed!" << std::endl; #endif @@ -152,7 +152,7 @@ ReturnValue_t DeviceHandlerBase::initialize() { IPCStore = objectManager->get(objects::IPC_STORE); if (IPCStore == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "DeviceHandlerBase::initialize: IPC store not set up in " "factory." << std::endl; #endif @@ -164,7 +164,7 @@ ReturnValue_t DeviceHandlerBase::initialize() { AcceptsDeviceResponsesIF>(rawDataReceiverId); if (rawReceiver == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "DeviceHandlerBase::initialize: Raw receiver object " "ID set but no valid object found." << std::endl; sif::error << "Make sure the raw receiver object is set up properly" @@ -178,7 +178,7 @@ ReturnValue_t DeviceHandlerBase::initialize() { if(powerSwitcherId != objects::NO_OBJECT) { powerSwitcher = objectManager->get(powerSwitcherId); if (powerSwitcher == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "DeviceHandlerBase::initialize: Power switcher " << "object ID set but no valid object found." << std::endl; sif::error << "Make sure the raw receiver object is set up properly" @@ -720,7 +720,7 @@ void DeviceHandlerBase::parseReply(const uint8_t* receivedData, case RETURN_OK: handleReply(receivedData, foundId, foundLen); if(foundLen == 0) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "DeviceHandlerBase::parseReply: foundLen is 0!" " Packet parsing will be stuck." << std::endl; #endif @@ -734,7 +734,7 @@ void DeviceHandlerBase::parseReply(const uint8_t* receivedData, foundId); } if(foundLen == 0) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "DeviceHandlerBase::parseReply: foundLen is 0!" " Packet parsing will be stuck." << std::endl; #endif @@ -1291,7 +1291,7 @@ void DeviceHandlerBase::buildInternalCommand(void) { result = buildNormalDeviceCommand(&deviceCommandId); if (result == BUSY) { //so we can track misconfigurations -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << std::hex << getObjectId() << ": DHB::buildInternalCommand: Busy" << std::dec << std::endl; @@ -1320,7 +1320,7 @@ void DeviceHandlerBase::buildInternalCommand(void) { result = COMMAND_NOT_SUPPORTED; } else if (iter->second.isExecuting) { //so we can track misconfigurations -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << std::hex << getObjectId() << ": DHB::buildInternalCommand: Command " << deviceCommandId << " isExecuting" << std::dec diff --git a/devicehandlers/DeviceHandlerFailureIsolation.cpp b/devicehandlers/DeviceHandlerFailureIsolation.cpp index c7f87859..5f7ab89f 100644 --- a/devicehandlers/DeviceHandlerFailureIsolation.cpp +++ b/devicehandlers/DeviceHandlerFailureIsolation.cpp @@ -169,7 +169,7 @@ void DeviceHandlerFailureIsolation::clearFaultCounters() { ReturnValue_t DeviceHandlerFailureIsolation::initialize() { ReturnValue_t result = FailureIsolationBase::initialize(); if (result != HasReturnvaluesIF::RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "DeviceHandlerFailureIsolation::initialize: Could not" " initialize FailureIsolationBase." << std::endl; #endif @@ -252,7 +252,7 @@ bool DeviceHandlerFailureIsolation::isFdirInActionOrAreWeFaulty( if (owner == nullptr) { // Configuration error. -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "DeviceHandlerFailureIsolation::" << "isFdirInActionOrAreWeFaulty: Owner not set!" << std::endl; #endif diff --git a/events/EventManager.cpp b/events/EventManager.cpp index 6742ff86..65e19d10 100644 --- a/events/EventManager.cpp +++ b/events/EventManager.cpp @@ -122,7 +122,7 @@ void EventManager::printEvent(EventMessage* message) { case severity::INFO: #if DEBUG_INFO_EVENT == 1 string = translateObject(message->getReporter()); -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "EVENT: "; if (string != 0) { sif::info << string; @@ -133,12 +133,12 @@ void EventManager::printEvent(EventMessage* message) { << std::dec << message->getEventId() << std::hex << ") P1: 0x" << message->getParameter1() << " P2: 0x" << message->getParameter2() << std::dec << std::endl; -#endif /* CPP_OSTREAM_ENABLED == 1 */ +#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ #endif /* DEBUG_INFO_EVENT == 1 */ break; default: string = translateObject(message->getReporter()); -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "EventManager: "; if (string != 0) { sif::debug << string; diff --git a/fdir/FailureIsolationBase.cpp b/fdir/FailureIsolationBase.cpp index fed301b5..69cb0f01 100644 --- a/fdir/FailureIsolationBase.cpp +++ b/fdir/FailureIsolationBase.cpp @@ -21,7 +21,7 @@ ReturnValue_t FailureIsolationBase::initialize() { EventManagerIF* manager = objectManager->get( objects::EVENT_MANAGER); if (manager == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "FailureIsolationBase::initialize: Event Manager has not" " been initialized!" << std::endl; #endif @@ -38,7 +38,7 @@ ReturnValue_t FailureIsolationBase::initialize() { } owner = objectManager->get(ownerId); if (owner == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "FailureIsolationBase::intialize: Owner object " "invalid. Make sure it implements HasHealthIF" << std::endl; #endif @@ -49,11 +49,11 @@ ReturnValue_t FailureIsolationBase::initialize() { ConfirmsFailuresIF* parentIF = objectManager->get( faultTreeParent); if (parentIF == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "FailureIsolationBase::intialize: Parent object" << "invalid." << std::endl; #endif -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Make sure it implements ConfirmsFailuresIF." << std::endl; #endif diff --git a/globalfunctions/arrayprinter.cpp b/globalfunctions/arrayprinter.cpp index c14cc7c6..d0b0a3bf 100644 --- a/globalfunctions/arrayprinter.cpp +++ b/globalfunctions/arrayprinter.cpp @@ -4,7 +4,7 @@ void arrayprinter::print(const uint8_t *data, size_t size, OutputType type, bool printInfo, size_t maxCharPerLine) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 if(printInfo) { sif::info << "Printing data with size " << size << ": "; } @@ -23,7 +23,7 @@ void arrayprinter::print(const uint8_t *data, size_t size, OutputType type, void arrayprinter::printHex(const uint8_t *data, size_t size, size_t maxCharPerLine) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << std::hex; for(size_t i = 0; i < size; i++) { sif::info << "0x" << static_cast(data[i]); @@ -42,7 +42,7 @@ void arrayprinter::printHex(const uint8_t *data, size_t size, void arrayprinter::printDec(const uint8_t *data, size_t size, size_t maxCharPerLine) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << std::dec; for(size_t i = 0; i < size; i++) { sif::info << static_cast(data[i]); @@ -58,7 +58,7 @@ void arrayprinter::printDec(const uint8_t *data, size_t size, } void arrayprinter::printBin(const uint8_t *data, size_t size) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "\n" << std::flush; for(size_t i = 0; i < size; i++) { sif::info << "Byte " << i + 1 << ": 0b"<< diff --git a/health/HealthHelper.cpp b/health/HealthHelper.cpp index de795a6c..231d616e 100644 --- a/health/HealthHelper.cpp +++ b/health/HealthHelper.cpp @@ -41,7 +41,7 @@ ReturnValue_t HealthHelper::initialize() { eventSender = objectManager->get(objectId); if (healthTable == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "HealthHelper::initialize: Health table object needs" "to be created in factory." << std::endl; #endif @@ -49,7 +49,7 @@ ReturnValue_t HealthHelper::initialize() { } if(eventSender == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "HealthHelper::initialize: Owner has to implement " "ReportingProxyIF." << std::endl; #endif @@ -83,7 +83,7 @@ void HealthHelper::informParent(HasHealthIF::HealthState health, health, oldHealth); if (MessageQueueSenderIF::sendMessage(parentQueue, &information, owner->getCommandQueue()) != HasReturnvaluesIF::RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "HealthHelper::informParent: sending health reply failed." << std::endl; #endif @@ -104,7 +104,7 @@ void HealthHelper::handleSetHealthCommand(CommandMessage* command) { } if (MessageQueueSenderIF::sendMessage(command->getSender(), &reply, owner->getCommandQueue()) != HasReturnvaluesIF::RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "HealthHelper::handleHealthCommand: sending health " "reply failed." << std::endl; #endif diff --git a/internalError/InternalErrorReporter.cpp b/internalError/InternalErrorReporter.cpp index a2dc529d..48b6f851 100644 --- a/internalError/InternalErrorReporter.cpp +++ b/internalError/InternalErrorReporter.cpp @@ -32,7 +32,7 @@ ReturnValue_t InternalErrorReporter::performOperation(uint8_t opCode) { #if FSFW_ENHANCED_PRINTOUT == 1 if(diagnosticPrintout) { if((newQueueHits > 0) or (newTmHits > 0) or (newStoreHits > 0)) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "InternalErrorReporter::performOperation: Errors " << "occured!" << std::endl; sif::debug << "Queue errors: " << newQueueHits << std::endl; diff --git a/ipc/MessageQueueMessage.cpp b/ipc/MessageQueueMessage.cpp index cdd4d943..e97778c3 100644 --- a/ipc/MessageQueueMessage.cpp +++ b/ipc/MessageQueueMessage.cpp @@ -15,7 +15,7 @@ MessageQueueMessage::MessageQueueMessage(uint8_t* data, size_t size) : this->messageSize = this->HEADER_SIZE + size; } else { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "MessageQueueMessage: Passed size larger than maximum" "allowed size! Setting content to 0" << std::endl; #endif @@ -54,7 +54,7 @@ void MessageQueueMessage::setSender(MessageQueueId_t setId) { } void MessageQueueMessage::print(bool printWholeMessage) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "MessageQueueMessage content: " << std::endl; #endif if(printWholeMessage) { diff --git a/ipc/MutexHelper.h b/ipc/MutexHelper.h index bd2f5187..befa69bc 100644 --- a/ipc/MutexHelper.h +++ b/ipc/MutexHelper.h @@ -12,13 +12,13 @@ public: ReturnValue_t status = mutex->lockMutex(timeoutType, timeoutMs); if(status == MutexIF::MUTEX_TIMEOUT) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MutexHelper: Lock of mutex failed with timeout of " << timeoutMs << " milliseconds!" << std::endl; #endif } else if(status != HasReturnvaluesIF::RETURN_OK){ -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MutexHelper: Lock of Mutex failed with code " << status << std::endl; #endif diff --git a/memory/MemoryHelper.cpp b/memory/MemoryHelper.cpp index 1d2a62a9..42ac2654 100644 --- a/memory/MemoryHelper.cpp +++ b/memory/MemoryHelper.cpp @@ -16,7 +16,7 @@ ReturnValue_t MemoryHelper::handleMemoryCommand(CommandMessage* message) { lastSender = message->getSender(); lastCommand = message->getCommand(); if (busy) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "MemHelper: Busy!" << std::endl; #endif } diff --git a/monitoring/MonitoringMessageContent.h b/monitoring/MonitoringMessageContent.h index 44661e4c..2822743a 100644 --- a/monitoring/MonitoringMessageContent.h +++ b/monitoring/MonitoringMessageContent.h @@ -72,7 +72,7 @@ private: if (timeStamper == nullptr) { timeStamper = objectManager->get( timeStamperId ); if ( timeStamper == nullptr ) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MonitoringReportContent::checkAndSetStamper: " "Stamper not found!" << std::endl; #endif diff --git a/objectmanager/ObjectManager.cpp b/objectmanager/ObjectManager.cpp index 251dbc70..69dd905b 100644 --- a/objectmanager/ObjectManager.cpp +++ b/objectmanager/ObjectManager.cpp @@ -1,7 +1,7 @@ #include "ObjectManager.h" #include "../serviceinterface/ServiceInterfaceStream.h" -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 #include #endif #include @@ -21,13 +21,13 @@ ObjectManager::~ObjectManager() { ReturnValue_t ObjectManager::insert( object_id_t id, SystemObjectIF* object) { auto returnPair = objectList.emplace(id, object); if (returnPair.second) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 // sif::debug << "ObjectManager::insert: Object " << std::hex // << (int)id << std::dec << " inserted." << std::endl; #endif return this->RETURN_OK; } else { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "ObjectManager::insert: Object id " << std::hex << static_cast id << std::dec << " is already in use!" << std::endl; @@ -41,13 +41,13 @@ ReturnValue_t ObjectManager::insert( object_id_t id, SystemObjectIF* object) { ReturnValue_t ObjectManager::remove( object_id_t id ) { if ( this->getSystemObject(id) != NULL ) { this->objectList.erase( id ); -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 //sif::debug << "ObjectManager::removeObject: Object " << std::hex // << (int)id << std::dec << " removed." << std::endl; #endif return RETURN_OK; } else { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "ObjectManager::removeObject: Requested object " << std::hex << (int)id << std::dec << " not found." << std::endl; #endif @@ -72,7 +72,7 @@ ObjectManager::ObjectManager() : produceObjects(nullptr) { void ObjectManager::initialize() { if(produceObjects == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "ObjectManager::initialize: Passed produceObjects " "functions is nullptr!" << std::endl; #endif @@ -84,7 +84,7 @@ void ObjectManager::initialize() { for (auto const& it : objectList) { result = it.second->initialize(); if ( result != RETURN_OK ) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 object_id_t var = it.first; sif::error << "ObjectManager::initialize: Object 0x" << std::hex << std::setw(8) << std::setfill('0')<< var << " failed to " @@ -95,7 +95,7 @@ void ObjectManager::initialize() { } } if (errorCount > 0) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "ObjectManager::ObjectManager: Counted " << errorCount << " failed initializations." << std::endl; #endif @@ -105,7 +105,7 @@ void ObjectManager::initialize() { for (auto const& it : objectList) { result = it.second->checkObjectConnections(); if ( result != RETURN_OK ) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "ObjectManager::ObjectManager: Object " << std::hex << (int) it.first << " connection check failed with code 0x" << result << std::dec << std::endl; @@ -114,7 +114,7 @@ void ObjectManager::initialize() { } } if (errorCount > 0) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "ObjectManager::ObjectManager: Counted " << errorCount << " failed connection checks." << std::endl; #endif @@ -122,7 +122,7 @@ void ObjectManager::initialize() { } void ObjectManager::printList() { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "ObjectManager: Object List contains:" << std::endl; for (auto const& it : objectList) { sif::debug << std::hex << it.first << " | " << it.second << std::endl; diff --git a/objectmanager/ObjectManagerIF.h b/objectmanager/ObjectManagerIF.h index 16700625..8bebb609 100644 --- a/objectmanager/ObjectManagerIF.h +++ b/objectmanager/ObjectManagerIF.h @@ -86,7 +86,7 @@ extern ObjectManagerIF *objectManager; template T* ObjectManagerIF::get( object_id_t id ) { if(objectManager == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "ObjectManagerIF: Global object manager has not " "been initialized yet!" << std::endl; #endif diff --git a/osal/FreeRTOS/BinSemaphUsingTask.cpp b/osal/FreeRTOS/BinSemaphUsingTask.cpp index d9f4a3cb..7d609aee 100644 --- a/osal/FreeRTOS/BinSemaphUsingTask.cpp +++ b/osal/FreeRTOS/BinSemaphUsingTask.cpp @@ -8,7 +8,7 @@ BinarySemaphoreUsingTask::BinarySemaphoreUsingTask() { handle = TaskManagement::getCurrentTaskHandle(); if(handle == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Could not retrieve task handle. Please ensure the" "constructor was called inside a task." << std::endl; #endif diff --git a/osal/FreeRTOS/BinarySemaphore.cpp b/osal/FreeRTOS/BinarySemaphore.cpp index 3915afe9..c0349b7c 100644 --- a/osal/FreeRTOS/BinarySemaphore.cpp +++ b/osal/FreeRTOS/BinarySemaphore.cpp @@ -5,7 +5,7 @@ BinarySemaphore::BinarySemaphore() { handle = xSemaphoreCreateBinary(); if(handle == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Semaphore: Binary semaph creation failure" << std::endl; #endif } @@ -20,7 +20,7 @@ BinarySemaphore::~BinarySemaphore() { BinarySemaphore::BinarySemaphore(BinarySemaphore&& s) { handle = xSemaphoreCreateBinary(); if(handle == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Binary semaphore creation failure" << std::endl; #endif } @@ -32,7 +32,7 @@ BinarySemaphore& BinarySemaphore::operator =( if(&s != this) { handle = xSemaphoreCreateBinary(); if(handle == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Binary semaphore creation failure" << std::endl; #endif } diff --git a/osal/FreeRTOS/CountingSemaphUsingTask.cpp b/osal/FreeRTOS/CountingSemaphUsingTask.cpp index e66f044d..750ea9d6 100644 --- a/osal/FreeRTOS/CountingSemaphUsingTask.cpp +++ b/osal/FreeRTOS/CountingSemaphUsingTask.cpp @@ -9,7 +9,7 @@ CountingSemaphoreUsingTask::CountingSemaphoreUsingTask(const uint8_t maxCount, uint8_t initCount): maxCount(maxCount) { if(initCount > maxCount) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "CountingSemaphoreUsingTask: Max count bigger than " "intial cout. Setting initial count to max count." << std::endl; #endif @@ -18,7 +18,7 @@ CountingSemaphoreUsingTask::CountingSemaphoreUsingTask(const uint8_t maxCount, handle = TaskManagement::getCurrentTaskHandle(); if(handle == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "CountingSemaphoreUsingTask: Could not retrieve task " "handle. Please ensure the constructor was called inside a " "task." << std::endl; @@ -29,7 +29,7 @@ CountingSemaphoreUsingTask::CountingSemaphoreUsingTask(const uint8_t maxCount, xTaskNotifyAndQuery(handle, 0, eSetValueWithOverwrite, &oldNotificationValue); if(oldNotificationValue != 0) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "CountinSemaphoreUsingTask: Semaphore initiated but " "current notification value is not 0. Please ensure the " "notification value is not used for other purposes!" << std::endl; diff --git a/osal/FreeRTOS/CountingSemaphore.cpp b/osal/FreeRTOS/CountingSemaphore.cpp index 2521e52e..40884d27 100644 --- a/osal/FreeRTOS/CountingSemaphore.cpp +++ b/osal/FreeRTOS/CountingSemaphore.cpp @@ -10,7 +10,7 @@ CountingSemaphore::CountingSemaphore(const uint8_t maxCount, uint8_t initCount): maxCount(maxCount), initCount(initCount) { if(initCount > maxCount) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "CountingSemaphoreUsingTask: Max count bigger than " "intial cout. Setting initial count to max count." << std::endl; #endif @@ -19,7 +19,7 @@ CountingSemaphore::CountingSemaphore(const uint8_t maxCount, uint8_t initCount): handle = xSemaphoreCreateCounting(maxCount, initCount); if(handle == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "CountingSemaphore: Creation failure" << std::endl; #endif } @@ -29,7 +29,7 @@ CountingSemaphore::CountingSemaphore(CountingSemaphore&& other): maxCount(other.maxCount), initCount(other.initCount) { handle = xSemaphoreCreateCounting(other.maxCount, other.initCount); if(handle == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "CountingSemaphore: Creation failure" << std::endl; #endif } @@ -39,7 +39,7 @@ CountingSemaphore& CountingSemaphore::operator =( CountingSemaphore&& other) { handle = xSemaphoreCreateCounting(other.maxCount, other.initCount); if(handle == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "CountingSemaphore: Creation failure" << std::endl; #endif } diff --git a/osal/FreeRTOS/FixedTimeslotTask.cpp b/osal/FreeRTOS/FixedTimeslotTask.cpp index 6b289df7..aa7e6c59 100644 --- a/osal/FreeRTOS/FixedTimeslotTask.cpp +++ b/osal/FreeRTOS/FixedTimeslotTask.cpp @@ -37,7 +37,7 @@ void FixedTimeslotTask::taskEntryPoint(void* argument) { } originalTask->taskFunctionality(); -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "Polling task " << originalTask->handle << " returned from taskFunctionality." << std::endl; #endif @@ -46,7 +46,7 @@ void FixedTimeslotTask::taskEntryPoint(void* argument) { void FixedTimeslotTask::missedDeadlineCounter() { FixedTimeslotTask::deadlineMissedCount++; if (FixedTimeslotTask::deadlineMissedCount % 10 == 0) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PST missed " << FixedTimeslotTask::deadlineMissedCount << " deadlines." << std::endl; #endif @@ -73,7 +73,7 @@ ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId, return HasReturnvaluesIF::RETURN_OK; } -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Component " << std::hex << componentId << " not found, not adding it to pst" << std::endl; #endif diff --git a/osal/FreeRTOS/MessageQueue.cpp b/osal/FreeRTOS/MessageQueue.cpp index 27b9a769..c0c82cf1 100644 --- a/osal/FreeRTOS/MessageQueue.cpp +++ b/osal/FreeRTOS/MessageQueue.cpp @@ -10,7 +10,7 @@ MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize): maxMessageSize(maxMessageSize) { handle = xQueueCreate(messageDepth, maxMessageSize); -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 if (handle == nullptr) { sif::error << "MessageQueue::MessageQueue:" << " Creation failed." << std::endl; diff --git a/osal/FreeRTOS/Mutex.cpp b/osal/FreeRTOS/Mutex.cpp index 1722660c..0b85ca13 100644 --- a/osal/FreeRTOS/Mutex.cpp +++ b/osal/FreeRTOS/Mutex.cpp @@ -5,7 +5,7 @@ Mutex::Mutex() { handle = xSemaphoreCreateMutex(); if(handle == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Mutex::Mutex(FreeRTOS): Creation failure" << std::endl; #endif } diff --git a/osal/FreeRTOS/PeriodicTask.cpp b/osal/FreeRTOS/PeriodicTask.cpp index 155f6ac7..3e830c7f 100644 --- a/osal/FreeRTOS/PeriodicTask.cpp +++ b/osal/FreeRTOS/PeriodicTask.cpp @@ -13,7 +13,7 @@ PeriodicTask::PeriodicTask(const char *name, TaskPriority setPriority, BaseType_t status = xTaskCreate(taskEntryPoint, name, stackSize, this, setPriority, &handle); if(status != pdPASS){ -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "PeriodicTask Insufficient heap memory remaining. " "Status: " << status << std::endl; #endif @@ -43,7 +43,7 @@ void PeriodicTask::taskEntryPoint(void* argument) { } originalTask->taskFunctionality(); -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "Polling task " << originalTask->handle << " returned from taskFunctionality." << std::endl; #endif @@ -103,7 +103,7 @@ ReturnValue_t PeriodicTask::addComponent(object_id_t object) { ExecutableObjectIF* newObject = objectManager->get( object); if (newObject == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PeriodicTask::addComponent: Invalid object. Make sure" "it implement ExecutableObjectIF" << std::endl; #endif diff --git a/osal/FreeRTOS/SemaphoreFactory.cpp b/osal/FreeRTOS/SemaphoreFactory.cpp index 4db46c69..df005f6a 100644 --- a/osal/FreeRTOS/SemaphoreFactory.cpp +++ b/osal/FreeRTOS/SemaphoreFactory.cpp @@ -32,7 +32,7 @@ SemaphoreIF* SemaphoreFactory::createBinarySemaphore(uint32_t argument) { return new BinarySemaphoreUsingTask(); } else { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "SemaphoreFactory: Invalid argument, return regular" "binary semaphore" << std::endl; #endif @@ -49,7 +49,7 @@ SemaphoreIF* SemaphoreFactory::createCountingSemaphore(uint8_t maxCount, return new CountingSemaphoreUsingTask(maxCount, initCount); } else { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "SemaphoreFactory: Invalid argument, return regular" "binary semaphore" << std::endl; #endif diff --git a/osal/host/Clock.cpp b/osal/host/Clock.cpp index 7a763a60..2bc78785 100644 --- a/osal/host/Clock.cpp +++ b/osal/host/Clock.cpp @@ -14,7 +14,7 @@ MutexIF* Clock::timeMutex = NULL; using SystemClock = std::chrono::system_clock; uint32_t Clock::getTicksPerSecond(void){ -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "Clock::getTicksPerSecond: not implemented yet" << std::endl; #endif return 0; @@ -25,7 +25,7 @@ uint32_t Clock::getTicksPerSecond(void){ ReturnValue_t Clock::setClock(const TimeOfDay_t* time) { // do some magic with chrono -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "Clock::setClock: not implemented yet" << std::endl; #endif return HasReturnvaluesIF::RETURN_OK; @@ -40,7 +40,7 @@ ReturnValue_t Clock::setClock(const timeval* time) { #else #endif -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "Clock::getUptime: Not implemented for found OS" << std::endl; #endif return HasReturnvaluesIF::RETURN_FAILED; @@ -66,7 +66,7 @@ ReturnValue_t Clock::getClock_timeval(timeval* time) { time->tv_usec = timeUnix.tv_nsec / 1000.0; return HasReturnvaluesIF::RETURN_OK; #else -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "Clock::getUptime: Not implemented for found OS" << std::endl; #endif return HasReturnvaluesIF::RETURN_FAILED; @@ -76,7 +76,7 @@ ReturnValue_t Clock::getClock_timeval(timeval* time) { ReturnValue_t Clock::getClock_usecs(uint64_t* time) { // do some magic with chrono -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "Clock::gerClock_usecs: not implemented yet" << std::endl; #endif return HasReturnvaluesIF::RETURN_OK; @@ -100,7 +100,7 @@ timeval Clock::getUptime() { timeval.tv_usec = uptimeSeconds *(double) 1e6 - (timeval.tv_sec *1e6); } #else -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "Clock::getUptime: Not implemented for found OS" << std::endl; #endif #endif @@ -138,7 +138,7 @@ ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { auto usecond = std::chrono::duration_cast(fraction); time->usecond = usecond.count(); -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 //sif::warning << "Clock::getDateAndTime: not implemented yet" << std::endl; #endif return HasReturnvaluesIF::RETURN_OK; @@ -162,7 +162,7 @@ ReturnValue_t Clock::convertTimeOfDayToTimeval(const TimeOfDay_t* from, to->tv_usec = from->usecond; //Fails in 2038.. return HasReturnvaluesIF::RETURN_OK; -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "Clock::convertTimeBla: not implemented yet" << std::endl; #endif return HasReturnvaluesIF::RETURN_OK; diff --git a/osal/host/FixedTimeslotTask.cpp b/osal/host/FixedTimeslotTask.cpp index 1fd3cd7f..272d99b9 100644 --- a/osal/host/FixedTimeslotTask.cpp +++ b/osal/host/FixedTimeslotTask.cpp @@ -35,7 +35,7 @@ FixedTimeslotTask::FixedTimeslotTask(const char *name, TaskPriority setPriority, reinterpret_cast(mainThread.native_handle()), ABOVE_NORMAL_PRIORITY_CLASS); if(result != 0) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "FixedTimeslotTask: Windows SetPriorityClass failed with code " << GetLastError() << std::endl; #endif @@ -44,7 +44,7 @@ FixedTimeslotTask::FixedTimeslotTask(const char *name, TaskPriority setPriority, reinterpret_cast(mainThread.native_handle()), THREAD_PRIORITY_NORMAL); if(result != 0) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "FixedTimeslotTask: Windows SetPriorityClass failed with code " << GetLastError() << std::endl; #endif @@ -74,7 +74,7 @@ void FixedTimeslotTask::taskEntryPoint(void* argument) { } this->taskFunctionality(); -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "FixedTimeslotTask::taskEntryPoint: " "Returned from taskFunctionality." << std::endl; #endif @@ -140,7 +140,7 @@ ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId, return HasReturnvaluesIF::RETURN_OK; } -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Component " << std::hex << componentId << " not found, not adding it to pst" << std::endl; #endif diff --git a/osal/host/MessageQueue.cpp b/osal/host/MessageQueue.cpp index 0c048120..dfc045e8 100644 --- a/osal/host/MessageQueue.cpp +++ b/osal/host/MessageQueue.cpp @@ -10,7 +10,7 @@ MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize): queueLock = MutexFactory::instance()->createMutex(); auto result = QueueMapManager::instance()->addMessageQueue(this, &mqId); if(result != HasReturnvaluesIF::RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::MessageQueue:" << " Could not be created" << std::endl; #endif @@ -139,7 +139,7 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo, targetQueue->messageQueue.push(*mqmMessage); } else { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::sendMessageFromMessageQueue: Message" "is not MessageQueueMessage!" << std::endl; #endif diff --git a/osal/host/PeriodicTask.cpp b/osal/host/PeriodicTask.cpp index 09acd2cb..1f427546 100644 --- a/osal/host/PeriodicTask.cpp +++ b/osal/host/PeriodicTask.cpp @@ -33,7 +33,7 @@ PeriodicTask::PeriodicTask(const char *name, TaskPriority setPriority, reinterpret_cast(mainThread.native_handle()), ABOVE_NORMAL_PRIORITY_CLASS); if(result != 0) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PeriodicTask: Windows SetPriorityClass failed with code " << GetLastError() << std::endl; #endif @@ -42,7 +42,7 @@ PeriodicTask::PeriodicTask(const char *name, TaskPriority setPriority, reinterpret_cast(mainThread.native_handle()), THREAD_PRIORITY_NORMAL); if(result != 0) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PeriodicTask: Windows SetPriorityClass failed with code " << GetLastError() << std::endl; #endif @@ -73,7 +73,7 @@ void PeriodicTask::taskEntryPoint(void* argument) { } this->taskFunctionality(); -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "PeriodicTask::taskEntryPoint: " "Returned from taskFunctionality." << std::endl; #endif diff --git a/osal/host/QueueMapManager.cpp b/osal/host/QueueMapManager.cpp index 620f8add..7ffd4758 100644 --- a/osal/host/QueueMapManager.cpp +++ b/osal/host/QueueMapManager.cpp @@ -26,7 +26,7 @@ ReturnValue_t QueueMapManager::addMessageQueue( auto returnPair = queueMap.emplace(currentId, queueToInsert); if(not returnPair.second) { // this should never happen for the atomic variable. -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "QueueMapManager: This ID is already inside the map!" << std::endl; #endif @@ -46,7 +46,7 @@ MessageQueueIF* QueueMapManager::getMessageQueue( return queueIter->second; } else { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "QueueMapManager::getQueueHandle: The ID " << messageQueueId << " does not exists in the map" << std::endl; #endif diff --git a/osal/host/SemaphoreFactory.cpp b/osal/host/SemaphoreFactory.cpp index 840dacef..3d3fe17f 100644 --- a/osal/host/SemaphoreFactory.cpp +++ b/osal/host/SemaphoreFactory.cpp @@ -21,7 +21,7 @@ SemaphoreFactory* SemaphoreFactory::instance() { SemaphoreIF* SemaphoreFactory::createBinarySemaphore(uint32_t arguments) { // Just gonna wait for full C++20 for now. -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "SemaphoreFactory: Binary Semaphore not implemented yet." " Returning nullptr!\n" << std::flush; #endif @@ -31,7 +31,7 @@ SemaphoreIF* SemaphoreFactory::createBinarySemaphore(uint32_t arguments) { SemaphoreIF* SemaphoreFactory::createCountingSemaphore(const uint8_t maxCount, uint8_t initCount, uint32_t arguments) { // Just gonna wait for full C++20 for now. -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "SemaphoreFactory: Counting Semaphore not implemented yet." " Returning nullptr!\n" << std::flush; #endif diff --git a/osal/linux/BinarySemaphore.cpp b/osal/linux/BinarySemaphore.cpp index 22d35e3a..0a6bb29f 100644 --- a/osal/linux/BinarySemaphore.cpp +++ b/osal/linux/BinarySemaphore.cpp @@ -43,7 +43,7 @@ ReturnValue_t BinarySemaphore::acquire(TimeoutType timeoutType, timeOut.tv_nsec = nseconds - timeOut.tv_sec * 1000000000; result = sem_timedwait(&handle, &timeOut); if(result != 0 and errno == EINVAL) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "BinarySemaphore::acquire: Invalid time value possible" << std::endl; #endif @@ -64,7 +64,7 @@ ReturnValue_t BinarySemaphore::acquire(TimeoutType timeoutType, return SemaphoreIF::SEMAPHORE_INVALID; case(EINTR): // Call was interrupted by signal handler -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "BinarySemaphore::acquire: Signal handler interrupted." "Code " << strerror(errno) << std::endl; #endif @@ -130,7 +130,7 @@ void BinarySemaphore::initSemaphore(uint8_t initCount) { // Value exceeds SEM_VALUE_MAX case(ENOSYS): // System does not support process-shared semaphores -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "BinarySemaphore: Init failed with" << strerror(errno) << std::endl; #endif diff --git a/osal/linux/Clock.cpp b/osal/linux/Clock.cpp index e4e7df86..54dad839 100644 --- a/osal/linux/Clock.cpp +++ b/osal/linux/Clock.cpp @@ -69,7 +69,7 @@ timeval Clock::getUptime() { timeval uptime; auto result = getUptime(&uptime); if(result != HasReturnvaluesIF::RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Clock::getUptime: Error getting uptime" << std::endl; #endif } diff --git a/osal/linux/CountingSemaphore.cpp b/osal/linux/CountingSemaphore.cpp index 22cb1615..0bb71831 100644 --- a/osal/linux/CountingSemaphore.cpp +++ b/osal/linux/CountingSemaphore.cpp @@ -4,7 +4,7 @@ CountingSemaphore::CountingSemaphore(const uint8_t maxCount, uint8_t initCount): maxCount(maxCount), initCount(initCount) { if(initCount > maxCount) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "CountingSemaphoreUsingTask: Max count bigger than " "intial cout. Setting initial count to max count." << std::endl; #endif diff --git a/osal/linux/FixedTimeslotTask.cpp b/osal/linux/FixedTimeslotTask.cpp index 0635b560..a545eeb7 100644 --- a/osal/linux/FixedTimeslotTask.cpp +++ b/osal/linux/FixedTimeslotTask.cpp @@ -47,7 +47,7 @@ ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId, return HasReturnvaluesIF::RETURN_OK; } -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Component " << std::hex << componentId << " not found, not adding it to pst" << std::dec << std::endl; #endif @@ -93,7 +93,7 @@ void FixedTimeslotTask::taskFunctionality() { void FixedTimeslotTask::missedDeadlineCounter() { FixedTimeslotTask::deadlineMissedCount++; if (FixedTimeslotTask::deadlineMissedCount % 10 == 0) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PST missed " << FixedTimeslotTask::deadlineMissedCount << " deadlines." << std::endl; #endif diff --git a/osal/linux/MessageQueue.cpp b/osal/linux/MessageQueue.cpp index 28dfb9c7..e7b09b4f 100644 --- a/osal/linux/MessageQueue.cpp +++ b/osal/linux/MessageQueue.cpp @@ -42,14 +42,14 @@ MessageQueue::MessageQueue(uint32_t messageDepth, size_t maxMessageSize): MessageQueue::~MessageQueue() { int status = mq_close(this->id); if(status != 0){ -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::Destructor: mq_close Failed with status: " << strerror(errno) < Apply changes with: sudo sysctl -p */ -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::MessageQueue: Default MQ size " << defaultMqMaxMsg << " is too small for requested size " << messageDepth << std::endl; @@ -102,7 +102,7 @@ ReturnValue_t MessageQueue::handleError(mq_attr* attributes, //We unlink the other queue int status = mq_unlink(name); if (status != 0) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "mq_unlink Failed with status: " << strerror(errno) << std::endl; #endif @@ -123,7 +123,7 @@ ReturnValue_t MessageQueue::handleError(mq_attr* attributes, default: // Failed either the first time or the second time -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::MessageQueue: Creating Queue " << std::hex << name << std::dec << " failed with status: " << strerror(errno) << std::endl; @@ -162,7 +162,7 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message, ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) { if(message == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::receiveMessage: Message is " "nullptr!" << std::endl; #endif @@ -170,7 +170,7 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) { } if(message->getMaximumMessageSize() < maxMessageSize) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::receiveMessage: Message size " << message->getMaximumMessageSize() << " too small to receive data!" << std::endl; @@ -202,7 +202,7 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) { return MessageQueueIF::EMPTY; case EBADF: //mqdes doesn't represent a valid queue open for reading. -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::receive: configuration error " << strerror(errno) << std::endl; #endif @@ -217,7 +217,7 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) { * queue, and the QNX extended option MQ_READBUF_DYNAMIC hasn't * been set in the queue's mq_flags. */ -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::receive: configuration error " << strerror(errno) << std::endl; #endif @@ -232,7 +232,7 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) { * given msg_len is too short for the message that would have * been received. */ -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::receive: configuration error " << strerror(errno) << std::endl; #endif @@ -258,7 +258,7 @@ ReturnValue_t MessageQueue::flush(uint32_t* count) { switch(errno){ case EBADF: //mqdes doesn't represent a valid message queue. -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::flush configuration error, " "called flush with an invalid queue ID" << std::endl; #endif @@ -276,7 +276,7 @@ ReturnValue_t MessageQueue::flush(uint32_t* count) { switch(errno){ case EBADF: //mqdes doesn't represent a valid message queue. -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::flush configuration error, " "called flush with an invalid queue ID" << std::endl; #endif @@ -331,7 +331,7 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo, MessageQueueMessageIF *message, MessageQueueId_t sentFrom, bool ignoreFault) { if(message == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::sendMessageFromMessageQueue: Message is " "nullptr!" << std::endl; #endif @@ -362,7 +362,7 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo, case EBADF: { //mq_des doesn't represent a valid message queue descriptor, //or mq_des wasn't opened for writing. -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::sendMessage: Configuration error, MQ" << " destination invalid." << std::endl; sif::error << strerror(errno) << " in " @@ -383,7 +383,7 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo, * - MQ_PRIO_RESTRICT is set in the mq_attr of mq_des, and * msg_prio is greater than the priority of the calling process. */ -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::sendMessage: Configuration error " << strerror(errno) << " in mq_send" << std::endl; #endif @@ -391,7 +391,7 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo, case EMSGSIZE: // The msg_len is greater than the msgsize associated with //the specified queue. -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::sendMessage: Size error [" << strerror(errno) << "] in mq_send" << std::endl; #endif diff --git a/osal/linux/Mutex.cpp b/osal/linux/Mutex.cpp index e2012634..c642b132 100644 --- a/osal/linux/Mutex.cpp +++ b/osal/linux/Mutex.cpp @@ -12,20 +12,20 @@ Mutex::Mutex() { pthread_mutexattr_t mutexAttr; int status = pthread_mutexattr_init(&mutexAttr); if (status != 0) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Mutex: Attribute init failed with: " << strerror(status) << std::endl; #endif } status = pthread_mutexattr_setprotocol(&mutexAttr, PTHREAD_PRIO_INHERIT); if (status != 0) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Mutex: Attribute set PRIO_INHERIT failed with: " << strerror(status) << std::endl; #endif } status = pthread_mutex_init(&mutex, &mutexAttr); if (status != 0) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Mutex: creation with name, id " << mutex.__data.__count << ", " << " failed with " << strerror(status) << std::endl; #endif @@ -35,7 +35,7 @@ Mutex::Mutex() { // (including destruction) shall not affect any previously initialized mutexes. status = pthread_mutexattr_destroy(&mutexAttr); if (status != 0) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Mutex: Attribute destroy failed with " << strerror(status) << std::endl; #endif } diff --git a/osal/linux/PeriodicPosixTask.cpp b/osal/linux/PeriodicPosixTask.cpp index 1c69124d..a8f2de60 100644 --- a/osal/linux/PeriodicPosixTask.cpp +++ b/osal/linux/PeriodicPosixTask.cpp @@ -25,7 +25,7 @@ ReturnValue_t PeriodicPosixTask::addComponent(object_id_t object) { ExecutableObjectIF* newObject = objectManager->get( object); if (newObject == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PeriodicTask::addComponent: Invalid object. Make sure" << " it implements ExecutableObjectIF!" << std::endl; #endif @@ -44,7 +44,7 @@ ReturnValue_t PeriodicPosixTask::sleepFor(uint32_t ms) { ReturnValue_t PeriodicPosixTask::startTask(void) { started = true; -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 //sif::info << stackSize << std::endl; #endif PosixThread::createTask(&taskEntryPoint,this); @@ -71,13 +71,13 @@ void PeriodicPosixTask::taskFunctionality(void) { char name[20] = {0}; int status = pthread_getname_np(pthread_self(), name, sizeof(name)); if(status == 0) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PeriodicPosixTask " << name << ": Deadline " "missed." << std::endl; #endif } else { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PeriodicPosixTask X: Deadline missed. " << status << std::endl; #endif diff --git a/osal/linux/PosixThread.cpp b/osal/linux/PosixThread.cpp index 80bf52c2..a0e540cf 100644 --- a/osal/linux/PosixThread.cpp +++ b/osal/linux/PosixThread.cpp @@ -48,7 +48,7 @@ void PosixThread::suspend() { sigaddset(&waitSignal, SIGUSR1); sigwait(&waitSignal, &caughtSig); if (caughtSig != SIGUSR1) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "FixedTimeslotTask: Unknown Signal received: " << caughtSig << std::endl; #endif @@ -120,7 +120,7 @@ uint64_t PosixThread::getCurrentMonotonicTimeMs(){ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 //sif::debug << "PosixThread::createTask" << std::endl; #endif /* @@ -133,7 +133,7 @@ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) { pthread_attr_t attributes; int status = pthread_attr_init(&attributes); if(status != 0){ -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Posix Thread attribute init failed with: " << strerror(status) << std::endl; #endif @@ -141,19 +141,19 @@ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) { void* stackPointer; status = posix_memalign(&stackPointer, sysconf(_SC_PAGESIZE), stackSize); if(status != 0){ -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PosixThread::createTask: Stack init failed with: " << strerror(status) << std::endl; #endif if(errno == ENOMEM) { uint64_t stackMb = stackSize/10e6; -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PosixThread::createTask: Insufficient memory for" " the requested " << stackMb << " MB" << std::endl; #endif } else if(errno == EINVAL) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PosixThread::createTask: Wrong alignment argument!" << std::endl; #endif @@ -163,7 +163,7 @@ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) { status = pthread_attr_setstack(&attributes, stackPointer, stackSize); if(status != 0){ -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PosixThread::createTask: pthread_attr_setstack " " failed with: " << strerror(status) << std::endl; sif::error << "Make sure the specified stack size is valid and is " @@ -173,7 +173,7 @@ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) { status = pthread_attr_setinheritsched(&attributes, PTHREAD_EXPLICIT_SCHED); if(status != 0){ -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Posix Thread attribute setinheritsched failed with: " << strerror(status) << std::endl; #endif @@ -182,7 +182,7 @@ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) { // TODO FIFO -> This needs root privileges for the process status = pthread_attr_setschedpolicy(&attributes,SCHED_FIFO); if(status != 0){ -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Posix Thread attribute schedule policy failed with: " << strerror(status) << std::endl; #endif @@ -192,7 +192,7 @@ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) { scheduleParams.__sched_priority = priority; status = pthread_attr_setschedparam(&attributes, &scheduleParams); if(status != 0){ -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Posix Thread attribute schedule params failed with: " << strerror(status) << std::endl; #endif @@ -204,7 +204,7 @@ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) { sigaddset(&waitSignal, SIGUSR1); status = pthread_sigmask(SIG_BLOCK, &waitSignal, NULL); if(status != 0){ -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Posix Thread sigmask failed failed with: " << strerror(status) << " errno: " << strerror(errno) << std::endl; #endif @@ -213,7 +213,7 @@ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) { status = pthread_create(&thread,&attributes,fnc_,arg_); if(status != 0){ -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Posix Thread create failed with: " << strerror(status) << std::endl; #endif @@ -221,19 +221,19 @@ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) { status = pthread_setname_np(thread,name); if(status != 0){ -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PosixThread::createTask: setname failed with: " << strerror(status) << std::endl; #endif if(status == ERANGE) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PosixThread::createTask: Task name length longer" " than 16 chars. Truncating.." << std::endl; #endif name[15] = '\0'; status = pthread_setname_np(thread,name); if(status != 0){ -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PosixThread::createTask: Setting name" " did not work.." << std::endl; #endif @@ -243,7 +243,7 @@ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) { status = pthread_attr_destroy(&attributes); if(status!=0){ -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Posix Thread attribute destroy failed with: " << strerror(status) << std::endl; #endif diff --git a/osal/linux/TcUnixUdpPollingTask.cpp b/osal/linux/TcUnixUdpPollingTask.cpp index 9cbb1d02..a8387e87 100644 --- a/osal/linux/TcUnixUdpPollingTask.cpp +++ b/osal/linux/TcUnixUdpPollingTask.cpp @@ -39,7 +39,7 @@ ReturnValue_t TcUnixUdpPollingTask::performOperation(uint8_t opCode) { reinterpret_cast(&senderAddress), &senderSockLen); if(bytesReceived < 0) { // handle error -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TcSocketPollingTask::performOperation: Reception" "error." << std::endl; #endif @@ -47,7 +47,7 @@ ReturnValue_t TcUnixUdpPollingTask::performOperation(uint8_t opCode) { continue; } -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 // sif::debug << "TcSocketPollingTask::performOperation: " << bytesReceived // << " bytes received" << std::endl; #endif @@ -69,7 +69,7 @@ ReturnValue_t TcUnixUdpPollingTask::handleSuccessfullTcRead(size_t bytesRead) { receptionBuffer.data(), bytesRead); // arrayprinter::print(receptionBuffer.data(), bytesRead); if (result != HasReturnvaluesIF::RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TcSerialPollingTask::transferPusToSoftwareBus: Data " "storage failed" << std::endl; sif::error << "Packet size: " << bytesRead << std::endl; @@ -81,7 +81,7 @@ ReturnValue_t TcUnixUdpPollingTask::handleSuccessfullTcRead(size_t bytesRead) { result = MessageQueueSenderIF::sendMessage(targetTcDestination, &message); if (result != HasReturnvaluesIF::RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Serial Polling: Sending message to queue failed" << std::endl; #endif @@ -93,7 +93,7 @@ ReturnValue_t TcUnixUdpPollingTask::handleSuccessfullTcRead(size_t bytesRead) { ReturnValue_t TcUnixUdpPollingTask::initialize() { tcStore = objectManager->get(objects::TC_STORE); if (tcStore == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TcSerialPollingTask::initialize: TC Store uninitialized!" << std::endl; #endif @@ -102,7 +102,7 @@ ReturnValue_t TcUnixUdpPollingTask::initialize() { tmtcBridge = objectManager->get(tmtcBridgeId); if(tmtcBridge == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TcSocketPollingTask::TcSocketPollingTask: Invalid" " TMTC bridge object!" << std::endl; #endif @@ -127,7 +127,7 @@ void TcUnixUdpPollingTask::setTimeout(double timeoutSeconds) { int result = setsockopt(serverUdpSocket, SOL_SOCKET, SO_RCVTIMEO, &tval, sizeof(receptionTimeout)); if(result == -1) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TcSocketPollingTask::TcSocketPollingTask: Setting " "receive timeout failed with " << strerror(errno) << std::endl; #endif @@ -140,14 +140,14 @@ void TcUnixUdpPollingTask::handleReadError() { case(EAGAIN): { // todo: When working in timeout mode, this will occur more often // and is not an error. -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TcUnixUdpPollingTask::handleReadError: Timeout." << std::endl; #endif break; } default: { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TcUnixUdpPollingTask::handleReadError: " << strerror(errno) << std::endl; #endif diff --git a/osal/linux/Timer.cpp b/osal/linux/Timer.cpp index 0142025e..fe0fbebb 100644 --- a/osal/linux/Timer.cpp +++ b/osal/linux/Timer.cpp @@ -10,7 +10,7 @@ Timer::Timer() { sigEvent.sigev_value.sival_ptr = &timerId; int status = timer_create(CLOCK_MONOTONIC, &sigEvent, &timerId); if(status!=0){ -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Timer creation failed with: " << status << " errno: " << errno << std::endl; #endif diff --git a/osal/linux/TmTcUnixUdpBridge.cpp b/osal/linux/TmTcUnixUdpBridge.cpp index 769e8aff..1d318d3b 100644 --- a/osal/linux/TmTcUnixUdpBridge.cpp +++ b/osal/linux/TmTcUnixUdpBridge.cpp @@ -26,7 +26,7 @@ TmTcUnixUdpBridge::TmTcUnixUdpBridge(object_id_t objectId, //clientSocket = socket(AF_INET, SOCK_DGRAM, 0); serverSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if(serverSocket < 0) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcUnixUdpBridge::TmTcUnixUdpBridge: Could not open" " UDP socket!" << std::endl; #endif @@ -53,7 +53,7 @@ TmTcUnixUdpBridge::TmTcUnixUdpBridge(object_id_t objectId, reinterpret_cast(&serverAddress), serverAddressLen); if(result == -1) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcUnixUdpBridge::TmTcUnixUdpBridge: Could not bind " "local port " << setServerPort << " to server socket!" << std::endl; @@ -78,7 +78,7 @@ ReturnValue_t TmTcUnixUdpBridge::sendTm(const uint8_t *data, size_t dataLen) { } // char ipAddress [15]; -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 // sif::debug << "IP Address Sender: "<< inet_ntop(AF_INET, // &clientAddress.sin_addr.s_addr, ipAddress, 15) << std::endl; #endif @@ -86,13 +86,13 @@ ReturnValue_t TmTcUnixUdpBridge::sendTm(const uint8_t *data, size_t dataLen) { ssize_t bytesSent = sendto(serverSocket, data, dataLen, flags, reinterpret_cast(&clientAddress), clientAddressLen); if(bytesSent < 0) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcUnixUdpBridge::sendTm: Send operation failed." << std::endl; #endif handleSendError(); } -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 // sif::debug << "TmTcUnixUdpBridge::sendTm: " << bytesSent << " bytes were" // " sent." << std::endl; #endif @@ -103,7 +103,7 @@ void TmTcUnixUdpBridge::checkAndSetClientAddress(sockaddr_in& newAddress) { MutexHelper lock(mutex, MutexIF::TimeoutType::WAITING, 10); // char ipAddress [15]; -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 // sif::debug << "IP Address Sender: "<< inet_ntop(AF_INET, // &newAddress.sin_addr.s_addr, ipAddress, 15) << std::endl; // sif::debug << "IP Address Old: " << inet_ntop(AF_INET, @@ -129,13 +129,13 @@ void TmTcUnixUdpBridge::handleSocketError() { case(ENOBUFS): case(ENOMEM): case(EPROTONOSUPPORT): -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcUnixBridge::handleSocketError: Socket creation failed" << " with " << strerror(errno) << std::endl; #endif break; default: -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcUnixBridge::handleSocketError: Unknown error" << std::endl; #endif @@ -151,7 +151,7 @@ void TmTcUnixUdpBridge::handleBindError() { Ephermeral ports can be shown with following command: sysctl -A | grep ip_local_port_range */ -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcUnixBridge::handleBindError: Port access issue." "Ports 1-1024 are reserved on UNIX systems and require root " "rights while ephermeral ports should not be used as well." @@ -171,14 +171,14 @@ void TmTcUnixUdpBridge::handleBindError() { case(ENOMEM): case(ENOTDIR): case(EROFS): { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcUnixBridge::handleBindError: Socket creation failed" << " with " << strerror(errno) << std::endl; #endif break; } default: -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcUnixBridge::handleBindError: Unknown error" << std::endl; #endif @@ -189,7 +189,7 @@ void TmTcUnixUdpBridge::handleBindError() { void TmTcUnixUdpBridge::handleSendError() { switch(errno) { default: -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcUnixBridge::handleSendError: " << strerror(errno) << std::endl; #endif diff --git a/osal/rtems/MessageQueue.cpp b/osal/rtems/MessageQueue.cpp index eff8a0fb..bfaf3569 100644 --- a/osal/rtems/MessageQueue.cpp +++ b/osal/rtems/MessageQueue.cpp @@ -9,7 +9,7 @@ MessageQueue::MessageQueue(size_t message_depth, size_t max_message_size) : rtems_status_code status = rtems_message_queue_create(name, message_depth, max_message_size, 0, &(this->id)); if (status != RTEMS_SUCCESSFUL) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "MessageQueue::MessageQueue: Creating Queue " << std::hex << name << std::dec << " failed with status:" << (uint32_t) status << std::endl; diff --git a/osal/rtems/MultiObjectTask.cpp b/osal/rtems/MultiObjectTask.cpp index a315681b..b111f724 100644 --- a/osal/rtems/MultiObjectTask.cpp +++ b/osal/rtems/MultiObjectTask.cpp @@ -30,7 +30,7 @@ ReturnValue_t MultiObjectTask::startTask() { rtems_status_code status = rtems_task_start(id, MultiObjectTask::taskEntryPoint, rtems_task_argument((void *) this)); if (status != RTEMS_SUCCESSFUL) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "ObjectTask::startTask for " << std::hex << this->getId() << std::dec << " failed." << std::endl; #endif @@ -65,7 +65,7 @@ void MultiObjectTask::taskFunctionality() { char nameSpace[8] = { 0 }; char* ptr = rtems_object_get_name(getId(), sizeof(nameSpace), nameSpace); -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "ObjectTask: " << ptr << " Deadline missed." << std::endl; #endif if (this->deadlineMissedFunc != nullptr) { diff --git a/osal/rtems/Mutex.cpp b/osal/rtems/Mutex.cpp index 5278a076..71c5782f 100644 --- a/osal/rtems/Mutex.cpp +++ b/osal/rtems/Mutex.cpp @@ -10,7 +10,7 @@ Mutex::Mutex() : RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_INHERIT_PRIORITY, 0, &mutexId); if (status != RTEMS_SUCCESSFUL) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Mutex: creation with name, id " << mutexName << ", " << mutexId << " failed with " << status << std::endl; #endif @@ -20,7 +20,7 @@ Mutex::Mutex() : Mutex::~Mutex() { rtems_status_code status = rtems_semaphore_delete(mutexId); if (status != RTEMS_SUCCESSFUL) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Mutex: deletion for id " << mutexId << " failed with " << status << std::endl; #endif diff --git a/osal/rtems/PollingTask.cpp b/osal/rtems/PollingTask.cpp index 591ba743..0ebf63e2 100644 --- a/osal/rtems/PollingTask.cpp +++ b/osal/rtems/PollingTask.cpp @@ -35,7 +35,7 @@ rtems_task PollingTask::taskEntryPoint(rtems_task_argument argument) { PollingTask *originalTask(reinterpret_cast(argument)); //The task's functionality is called. originalTask->taskFunctionality(); -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "Polling task " << originalTask->getId() << " returned from taskFunctionality." << std::endl; #endif @@ -44,7 +44,7 @@ rtems_task PollingTask::taskEntryPoint(rtems_task_argument argument) { void PollingTask::missedDeadlineCounter() { PollingTask::deadlineMissedCount++; if (PollingTask::deadlineMissedCount % 10 == 0) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PST missed " << PollingTask::deadlineMissedCount << " deadlines." << std::endl; #endif @@ -55,7 +55,7 @@ ReturnValue_t PollingTask::startTask() { rtems_status_code status = rtems_task_start(id, PollingTask::taskEntryPoint, rtems_task_argument((void *) this)); if (status != RTEMS_SUCCESSFUL) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PollingTask::startTask for " << std::hex << this->getId() << std::dec << " failed." << std::endl; #endif @@ -81,7 +81,7 @@ ReturnValue_t PollingTask::addSlot(object_id_t componentId, return HasReturnvaluesIF::RETURN_OK; } -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Component " << std::hex << componentId << " not found, not adding it to pst" << std::endl; #endif diff --git a/osal/rtems/TaskBase.cpp b/osal/rtems/TaskBase.cpp index 7e3bd57a..6abfcca8 100644 --- a/osal/rtems/TaskBase.cpp +++ b/osal/rtems/TaskBase.cpp @@ -22,7 +22,7 @@ TaskBase::TaskBase(rtems_task_priority set_priority, size_t stack_size, } ReturnValue_t result = convertReturnCode(status); if (result != HasReturnvaluesIF::RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TaskBase::TaskBase: createTask with name " << std::hex << osalName << std::dec << " failed with return code " << (uint32_t) status << std::endl; diff --git a/osal/windows/TcWinUdpPollingTask.cpp b/osal/windows/TcWinUdpPollingTask.cpp index e5931609..4fd88c93 100644 --- a/osal/windows/TcWinUdpPollingTask.cpp +++ b/osal/windows/TcWinUdpPollingTask.cpp @@ -43,14 +43,14 @@ ReturnValue_t TcWinUdpPollingTask::performOperation(uint8_t opCode) { &senderAddressSize); if(bytesReceived == SOCKET_ERROR) { // handle error -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TcWinUdpPollingTask::performOperation: Reception" " error." << std::endl; #endif handleReadError(); continue; } -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 //sif::debug << "TcWinUdpPollingTask::performOperation: " << bytesReceived // << " bytes received" << std::endl; #endif @@ -72,7 +72,7 @@ ReturnValue_t TcWinUdpPollingTask::handleSuccessfullTcRead(size_t bytesRead) { receptionBuffer.data(), bytesRead); // arrayprinter::print(receptionBuffer.data(), bytesRead); if (result != HasReturnvaluesIF::RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TcSerialPollingTask::transferPusToSoftwareBus: Data " "storage failed" << std::endl; sif::error << "Packet size: " << bytesRead << std::endl; @@ -84,7 +84,7 @@ ReturnValue_t TcWinUdpPollingTask::handleSuccessfullTcRead(size_t bytesRead) { result = MessageQueueSenderIF::sendMessage(targetTcDestination, &message); if (result != HasReturnvaluesIF::RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Serial Polling: Sending message to queue failed" << std::endl; #endif @@ -96,7 +96,7 @@ ReturnValue_t TcWinUdpPollingTask::handleSuccessfullTcRead(size_t bytesRead) { ReturnValue_t TcWinUdpPollingTask::initialize() { tcStore = objectManager->get(objects::TC_STORE); if (tcStore == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TcSerialPollingTask::initialize: TC Store uninitialized!" << std::endl; #endif @@ -105,7 +105,7 @@ ReturnValue_t TcWinUdpPollingTask::initialize() { tmtcBridge = objectManager->get(tmtcBridgeId); if(tmtcBridge == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TcSocketPollingTask::TcSocketPollingTask: Invalid" " TMTC bridge object!" << std::endl; #endif @@ -113,7 +113,7 @@ ReturnValue_t TcWinUdpPollingTask::initialize() { } serverUdpSocket = tmtcBridge->serverSocket; -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 //sif::info << "TcWinUdpPollingTask::initialize: Server UDP socket " // << serverUdpSocket << std::endl; #endif @@ -133,7 +133,7 @@ void TcWinUdpPollingTask::setTimeout(double timeoutSeconds) { int result = setsockopt(serverUdpSocket, SOL_SOCKET, SO_RCVTIMEO, reinterpret_cast(&timeoutMs), sizeof(DWORD)); if(result == -1) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TcWinUdpPollingTask::TcSocketPollingTask: Setting " "receive timeout failed with " << strerror(errno) << std::endl; #endif @@ -144,28 +144,28 @@ void TcWinUdpPollingTask::handleReadError() { int error = WSAGetLastError(); switch(error) { case(WSANOTINITIALISED): { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "TcWinUdpPollingTask::handleReadError: WSANOTINITIALISED: " << "WSAStartup(...) call " << "necessary" << std::endl; #endif break; } case(WSAEFAULT): { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "TcWinUdpPollingTask::handleReadError: WSADEFAULT: " << "Bad address " << std::endl; #endif break; } case(WSAEINVAL): { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "TcWinUdpPollingTask::handleReadError: WSAEINVAL: " << "Invalid input parameters. " << std::endl; #endif break; } default: { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "TcWinUdpPollingTask::handleReadError: Error code: " << error << std::endl; #endif diff --git a/osal/windows/TmTcWinUdpBridge.cpp b/osal/windows/TmTcWinUdpBridge.cpp index b9945168..69a48f3e 100644 --- a/osal/windows/TmTcWinUdpBridge.cpp +++ b/osal/windows/TmTcWinUdpBridge.cpp @@ -15,7 +15,7 @@ TmTcWinUdpBridge::TmTcWinUdpBridge(object_id_t objectId, if (err != 0) { /* Tell the user that we could not find a usable */ /* Winsock DLL. */ -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcWinUdpBridge::TmTcWinUdpBridge:" "WSAStartup failed with error: " << err << std::endl; #endif @@ -36,7 +36,7 @@ TmTcWinUdpBridge::TmTcWinUdpBridge(object_id_t objectId, //clientSocket = socket(AF_INET, SOCK_DGRAM, 0); serverSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if(serverSocket == INVALID_SOCKET) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcWinUdpBridge::TmTcWinUdpBridge: Could not open" " UDP socket!" << std::endl; #endif @@ -63,7 +63,7 @@ TmTcWinUdpBridge::TmTcWinUdpBridge(object_id_t objectId, reinterpret_cast(&serverAddress), serverAddressLen); if(result != 0) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcWinUdpBridge::TmTcWinUdpBridge: Could not bind " "local port " << setServerPort << " to server socket!" << std::endl; @@ -83,7 +83,7 @@ ReturnValue_t TmTcWinUdpBridge::sendTm(const uint8_t *data, size_t dataLen) { //clientAddressLen = sizeof(serverAddress); // char ipAddress [15]; -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 // sif::debug << "IP Address Sender: "<< inet_ntop(AF_INET, // &clientAddress.sin_addr.s_addr, ipAddress, 15) << std::endl; #endif @@ -92,13 +92,13 @@ ReturnValue_t TmTcWinUdpBridge::sendTm(const uint8_t *data, size_t dataLen) { reinterpret_cast(data), dataLen, flags, reinterpret_cast(&clientAddress), clientAddressLen); if(bytesSent == SOCKET_ERROR) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcWinUdpBridge::sendTm: Send operation failed." << std::endl; #endif handleSendError(); } -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 // sif::debug << "TmTcUnixUdpBridge::sendTm: " << bytesSent << " bytes were" // " sent." << std::endl; #endif @@ -109,7 +109,7 @@ void TmTcWinUdpBridge::checkAndSetClientAddress(sockaddr_in newAddress) { MutexHelper lock(mutex, MutexIF::TimeoutType::WAITING, 10); // char ipAddress [15]; -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 // sif::debug << "IP Address Sender: "<< inet_ntop(AF_INET, // &newAddress.sin_addr.s_addr, ipAddress, 15) << std::endl; // sif::debug << "IP Address Old: " << inet_ntop(AF_INET, @@ -128,7 +128,7 @@ void TmTcWinUdpBridge::handleSocketError() { int errCode = WSAGetLastError(); switch(errCode) { case(WSANOTINITIALISED): { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "TmTcWinUdpBridge::handleSocketError: WSANOTINITIALISED: " << "WSAStartup(...) call necessary" << std::endl; #endif @@ -139,7 +139,7 @@ void TmTcWinUdpBridge::handleSocketError() { https://docs.microsoft.com/en-us/windows/win32/winsock/ windows-sockets-error-codes-2 */ -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "TmTcWinUdpBridge::handleSocketError: Error code: " << errCode << std::endl; #endif @@ -152,14 +152,14 @@ void TmTcWinUdpBridge::handleBindError() { int errCode = WSAGetLastError(); switch(errCode) { case(WSANOTINITIALISED): { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "TmTcWinUdpBridge::handleBindError: WSANOTINITIALISED: " << "WSAStartup(...) call " << "necessary" << std::endl; #endif break; } case(WSAEADDRINUSE): { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "TmTcWinUdpBridge::handleBindError: WSAEADDRINUSE: " << "Port is already in use!" << std::endl; #endif @@ -170,7 +170,7 @@ void TmTcWinUdpBridge::handleBindError() { https://docs.microsoft.com/en-us/windows/win32/winsock/ windows-sockets-error-codes-2 */ -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "TmTcWinUdpBridge::handleBindError: Error code: " << errCode << std::endl; #endif @@ -183,14 +183,14 @@ void TmTcWinUdpBridge::handleSendError() { int errCode = WSAGetLastError(); switch(errCode) { case(WSANOTINITIALISED): { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "TmTcWinUdpBridge::handleSendError: WSANOTINITIALISED: " << "WSAStartup(...) call necessary" << std::endl; #endif break; } case(WSAEADDRNOTAVAIL): { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "TmTcWinUdpBridge::handleSendError: WSAEADDRNOTAVAIL: " << "Check target address. " << std::endl; #endif @@ -201,7 +201,7 @@ void TmTcWinUdpBridge::handleSendError() { https://docs.microsoft.com/en-us/windows/win32/winsock/ windows-sockets-error-codes-2 */ -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "TmTcWinUdpBridge::handleSendError: Error code: " << errCode << std::endl; #endif diff --git a/parameters/ParameterHelper.cpp b/parameters/ParameterHelper.cpp index 5014e44c..4ad5cdf2 100644 --- a/parameters/ParameterHelper.cpp +++ b/parameters/ParameterHelper.cpp @@ -48,7 +48,7 @@ ReturnValue_t ParameterHelper::handleParameterMessage(CommandMessage *message) { ConstStorageAccessor accessor(storeId); result = storage->getData(storeId, accessor); if (result != HasReturnvaluesIF::RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "ParameterHelper::handleParameterMessage: Getting" << " store data failed for load command." << std::endl; #endif diff --git a/pus/CService201HealthCommanding.cpp b/pus/CService201HealthCommanding.cpp index f2c579d5..ca761f14 100644 --- a/pus/CService201HealthCommanding.cpp +++ b/pus/CService201HealthCommanding.cpp @@ -22,7 +22,7 @@ ReturnValue_t CService201HealthCommanding::isValidSubservice(uint8_t subservice) case(Subservice::COMMAND_ANNOUNCE_HEALTH_ALL): return RETURN_OK; default: -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Invalid Subservice" << std::endl; #endif return AcceptsTelecommandsIF::INVALID_SUBSERVICE; diff --git a/pus/Service1TelecommandVerification.cpp b/pus/Service1TelecommandVerification.cpp index 9194ab24..9e86c752 100644 --- a/pus/Service1TelecommandVerification.cpp +++ b/pus/Service1TelecommandVerification.cpp @@ -51,7 +51,7 @@ ReturnValue_t Service1TelecommandVerification::sendVerificationReport( result = generateSuccessReport(message); } if(result != HasReturnvaluesIF::RETURN_OK){ -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Service1TelecommandVerification::sendVerificationReport: " "Sending verification packet failed !" << std::endl; #endif @@ -90,7 +90,7 @@ ReturnValue_t Service1TelecommandVerification::initialize() { AcceptsTelemetryIF* funnel = objectManager-> get(targetDestination); if(funnel == nullptr){ -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Service1TelecommandVerification::initialize: Specified" " TM funnel invalid. Make sure it is set up and implements" " AcceptsTelemetryIF." << std::endl; diff --git a/pus/Service2DeviceAccess.cpp b/pus/Service2DeviceAccess.cpp index f79c0a79..72db82df 100644 --- a/pus/Service2DeviceAccess.cpp +++ b/pus/Service2DeviceAccess.cpp @@ -25,7 +25,7 @@ ReturnValue_t Service2DeviceAccess::isValidSubservice(uint8_t subservice) { case Subservice::COMMAND_TOGGLE_WIRETAPPING: return HasReturnvaluesIF::RETURN_OK; default: -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Invalid Subservice" << std::endl; #endif return AcceptsTelecommandsIF::INVALID_SUBSERVICE; @@ -127,7 +127,7 @@ void Service2DeviceAccess::handleUnrequestedReply(CommandMessage* reply) { static_cast(Subservice::REPLY_RAW)); break; default: -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Unknown message in Service2DeviceAccess::" "handleUnrequestedReply with command ID " << reply->getCommand() << std::endl; @@ -147,7 +147,7 @@ void Service2DeviceAccess::sendWiretappingTm(CommandMessage *reply, size_t size = 0; ReturnValue_t result = IPCStore->getData(storeAddress, &data, &size); if(result != HasReturnvaluesIF::RETURN_OK){ -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Service2DeviceAccess::sendWiretappingTm: Data Lost in " "handleUnrequestedReply with failure ID "<< result << std::endl; diff --git a/pus/Service3Housekeeping.cpp b/pus/Service3Housekeeping.cpp index d52ab50d..ba7ff6ee 100644 --- a/pus/Service3Housekeeping.cpp +++ b/pus/Service3Housekeeping.cpp @@ -222,7 +222,7 @@ ReturnValue_t Service3Housekeeping::handleReply(const CommandMessage* reply, } default: -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Service3Housekeeping::handleReply: Invalid reply with " << "reply command " << command << "!" << std::endl; #endif @@ -251,7 +251,7 @@ void Service3Housekeeping::handleUnrequestedReply( } default: -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Service3Housekeeping::handleUnrequestedReply: Invalid " << "reply with " << "reply command " << command << "!" << std::endl; @@ -261,7 +261,7 @@ void Service3Housekeeping::handleUnrequestedReply( if(result != HasReturnvaluesIF::RETURN_OK) { // Configuration error -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "Service3Housekeeping::handleUnrequestedReply:" << "Could not generate reply!" << std::endl; #endif diff --git a/pus/Service5EventReporting.cpp b/pus/Service5EventReporting.cpp index 21bf2780..29eb7f20 100644 --- a/pus/Service5EventReporting.cpp +++ b/pus/Service5EventReporting.cpp @@ -37,7 +37,7 @@ ReturnValue_t Service5EventReporting::performService() { } } } -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "Service5EventReporting::generateEventReport:" " Too many events" << std::endl; #endif @@ -55,7 +55,7 @@ ReturnValue_t Service5EventReporting::generateEventReport( ReturnValue_t result = tmPacket.sendPacket( requestQueue->getDefaultDestination(),requestQueue->getId()); if(result != HasReturnvaluesIF::RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "Service5EventReporting::generateEventReport:" " Could not send TM packet" << std::endl; #endif diff --git a/pus/Service8FunctionManagement.cpp b/pus/Service8FunctionManagement.cpp index df25dd85..49fa6ebe 100644 --- a/pus/Service8FunctionManagement.cpp +++ b/pus/Service8FunctionManagement.cpp @@ -60,7 +60,7 @@ ReturnValue_t Service8FunctionManagement::prepareCommand( ReturnValue_t Service8FunctionManagement::prepareDirectCommand( CommandMessage *message, const uint8_t *tcData, size_t tcDataLen) { if(tcDataLen < sizeof(object_id_t) + sizeof(ActionId_t)) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "Service8FunctionManagement::prepareDirectCommand:" << " TC size smaller thant minimum size of direct command." << std::endl; @@ -127,7 +127,7 @@ ReturnValue_t Service8FunctionManagement::handleDataReply( const uint8_t * buffer = nullptr; ReturnValue_t result = IPCStore->getData(storeId, &buffer, &size); if(result != RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Service 8: Could not retrieve data for data reply" << std::endl; #endif @@ -139,7 +139,7 @@ ReturnValue_t Service8FunctionManagement::handleDataReply( auto deletionResult = IPCStore->deleteData(storeId); if(deletionResult != HasReturnvaluesIF::RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "Service8FunctionManagement::handleReply: Deletion" << " of data in pool failed." << std::endl; #endif diff --git a/serialize/SerialBufferAdapter.cpp b/serialize/SerialBufferAdapter.cpp index 303de742..53b8c3d5 100644 --- a/serialize/SerialBufferAdapter.cpp +++ b/serialize/SerialBufferAdapter.cpp @@ -95,7 +95,7 @@ ReturnValue_t SerialBufferAdapter::deSerialize(const uint8_t** buffer, template uint8_t * SerialBufferAdapter::getBuffer() { if(buffer == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Wrong access function for stored type !" " Use getConstBuffer()." << std::endl; #endif @@ -107,7 +107,7 @@ uint8_t * SerialBufferAdapter::getBuffer() { template const uint8_t * SerialBufferAdapter::getConstBuffer() { if(constBuffer == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "SerialBufferAdapter::getConstBuffer:" " Buffers are unitialized!" << std::endl; #endif diff --git a/serviceinterface/ServiceInterfaceBuffer.cpp b/serviceinterface/ServiceInterfaceBuffer.cpp index abe296cb..20ea61dd 100644 --- a/serviceinterface/ServiceInterfaceBuffer.cpp +++ b/serviceinterface/ServiceInterfaceBuffer.cpp @@ -1,6 +1,6 @@ #include "ServiceInterfaceBuffer.h" -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 #include "../timemanager/Clock.h" @@ -256,4 +256,4 @@ void ServiceInterfaceBuffer::initSocket() { #endif //ML505 -#endif /* CPP_OSTREAM_ENABLED == 1 */ +#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ diff --git a/serviceinterface/ServiceInterfaceBuffer.h b/serviceinterface/ServiceInterfaceBuffer.h index d13143cd..b1a50848 100644 --- a/serviceinterface/ServiceInterfaceBuffer.h +++ b/serviceinterface/ServiceInterfaceBuffer.h @@ -4,7 +4,7 @@ #include "../returnvalues/HasReturnvaluesIF.h" #include -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 #include #include @@ -150,6 +150,6 @@ private: }; #endif //ML505 -#endif /* CPP_OSTREAM_ENABLED == 1 */ +#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ #endif /* FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACEBUFFER_H_ */ diff --git a/serviceinterface/ServiceInterfaceStream.cpp b/serviceinterface/ServiceInterfaceStream.cpp index c618d989..59526536 100644 --- a/serviceinterface/ServiceInterfaceStream.cpp +++ b/serviceinterface/ServiceInterfaceStream.cpp @@ -1,6 +1,6 @@ #include "ServiceInterfaceStream.h" -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 ServiceInterfaceStream::ServiceInterfaceStream(std::string setMessage, bool addCrToPreamble, bool buffered, bool errStream, uint16_t port) : diff --git a/serviceinterface/ServiceInterfaceStream.h b/serviceinterface/ServiceInterfaceStream.h index ddeded80..c18c6c2e 100644 --- a/serviceinterface/ServiceInterfaceStream.h +++ b/serviceinterface/ServiceInterfaceStream.h @@ -3,7 +3,7 @@ #include "ServiceInterfaceBuffer.h" -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 #include #include @@ -51,6 +51,6 @@ extern ServiceInterfaceStream warning; extern ServiceInterfaceStream error; } -#endif /* CPP_OSTREAM_ENABLED == 1 */ +#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ #endif /* FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACESTREAM_H_ */ diff --git a/storagemanager/ConstStorageAccessor.cpp b/storagemanager/ConstStorageAccessor.cpp index 0beef64f..39530ac9 100644 --- a/storagemanager/ConstStorageAccessor.cpp +++ b/storagemanager/ConstStorageAccessor.cpp @@ -46,7 +46,7 @@ const uint8_t* ConstStorageAccessor::data() const { size_t ConstStorageAccessor::size() const { if(internalState == AccessState::UNINIT) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "StorageAccessor: Not initialized!" << std::endl; #endif } @@ -56,13 +56,13 @@ size_t ConstStorageAccessor::size() const { ReturnValue_t ConstStorageAccessor::getDataCopy(uint8_t *pointer, size_t maxSize) { if(internalState == AccessState::UNINIT) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "StorageAccessor: Not initialized!" << std::endl; #endif return HasReturnvaluesIF::RETURN_FAILED; } if(size_ > maxSize) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "StorageAccessor: Supplied buffer not large enough" << std::endl; #endif @@ -82,7 +82,7 @@ store_address_t ConstStorageAccessor::getId() const { void ConstStorageAccessor::print() const { if(internalState == AccessState::UNINIT or constDataPointer == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "StorageAccessor: Not initialized!" << std::endl; #endif return; diff --git a/storagemanager/LocalPool.cpp b/storagemanager/LocalPool.cpp index b2d5ffc4..cc7c9266 100644 --- a/storagemanager/LocalPool.cpp +++ b/storagemanager/LocalPool.cpp @@ -8,7 +8,7 @@ LocalPool::LocalPool(object_id_t setObjectId, const LocalPoolConfig& poolConfig, NUMBER_OF_POOLS(poolConfig.size()), spillsToHigherPools(spillsToHigherPools) { if(NUMBER_OF_POOLS == 0) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "LocalPool::LocalPool: Passed pool configuration is " << " invalid!" << std::endl; #endif @@ -120,7 +120,7 @@ ReturnValue_t LocalPool::modifyData(store_address_t storeId, ReturnValue_t LocalPool::deleteData(store_address_t storeId) { #if FSFW_VERBOSE_PRINTOUT == 2 -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "Delete: Pool: " << std::dec << storeId.poolIndex << " Index: " << storeId.packetIndex << std::endl; #endif @@ -138,7 +138,7 @@ ReturnValue_t LocalPool::deleteData(store_address_t storeId) { } else { //pool_index or packet_index is too large -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "LocalPool::deleteData: Illegal store ID, no deletion!" << std::endl; #endif @@ -164,7 +164,7 @@ ReturnValue_t LocalPool::deleteData(uint8_t *ptr, size_t size, result = deleteData(localId); #if FSFW_VERBOSE_PRINTOUT == 2 if (deltaAddress % elementSizes[n] != 0) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "LocalPool::deleteData: Address not aligned!" << std::endl; #endif @@ -194,7 +194,7 @@ ReturnValue_t LocalPool::initialize() { //Check if any pool size is large than the maximum allowed. for (uint8_t count = 0; count < NUMBER_OF_POOLS; count++) { if (elementSizes[count] >= STORAGE_FREE) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "LocalPool::initialize: Pool is too large! " "Max. allowed size is: " << (STORAGE_FREE - 1) << std::endl; #endif @@ -219,7 +219,7 @@ ReturnValue_t LocalPool::reserveSpace(const size_t size, store_address_t *storeId, bool ignoreFault) { ReturnValue_t status = getPoolIndex(size, &storeId->poolIndex); if (status != RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "LocalPool( " << std::hex << getObjectId() << std::dec << " )::reserveSpace: Packet too large." << std::endl; #endif @@ -236,7 +236,7 @@ ReturnValue_t LocalPool::reserveSpace(const size_t size, } if (status == RETURN_OK) { #if FSFW_VERBOSE_PRINTOUT == 2 -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "Reserve: Pool: " << std::dec << storeId->poolIndex << " Index: " << storeId->packetIndex << std::endl; @@ -280,7 +280,7 @@ ReturnValue_t LocalPool::getPoolIndex(size_t packetSize, uint16_t *poolIndex, uint16_t startAtIndex) { for (uint16_t n = startAtIndex; n < NUMBER_OF_POOLS; n++) { #if FSFW_VERBOSE_PRINTOUT == 2 -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "LocalPool " << getObjectId() << "::getPoolIndex: Pool: " << n << ", Element Size: " << elementSizes[n] << std::endl; #endif diff --git a/storagemanager/PoolManager.cpp b/storagemanager/PoolManager.cpp index 7612fbc0..4e8014fd 100644 --- a/storagemanager/PoolManager.cpp +++ b/storagemanager/PoolManager.cpp @@ -26,7 +26,7 @@ ReturnValue_t PoolManager::reserveSpace(const size_t size, ReturnValue_t PoolManager::deleteData( store_address_t storeId) { #if FSFW_VERBOSE_PRINTOUT == 2 -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "PoolManager( " << translateObject(getObjectId()) << " )::deleteData from store " << storeId.poolIndex << ". id is "<< storeId.packetIndex << std::endl; diff --git a/storagemanager/StorageAccessor.cpp b/storagemanager/StorageAccessor.cpp index 373407b0..fec5d75e 100644 --- a/storagemanager/StorageAccessor.cpp +++ b/storagemanager/StorageAccessor.cpp @@ -26,13 +26,13 @@ StorageAccessor::StorageAccessor(StorageAccessor&& other): ReturnValue_t StorageAccessor::getDataCopy(uint8_t *pointer, size_t maxSize) { if(internalState == AccessState::UNINIT) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "StorageAccessor: Not initialized!" << std::endl; #endif return HasReturnvaluesIF::RETURN_FAILED; } if(size_ > maxSize) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "StorageAccessor: Supplied buffer not large " "enough" << std::endl; #endif @@ -44,7 +44,7 @@ ReturnValue_t StorageAccessor::getDataCopy(uint8_t *pointer, size_t maxSize) { uint8_t* StorageAccessor::data() { if(internalState == AccessState::UNINIT) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "StorageAccessor: Not initialized!" << std::endl; #endif } @@ -54,13 +54,13 @@ uint8_t* StorageAccessor::data() { ReturnValue_t StorageAccessor::write(uint8_t *data, size_t size, uint16_t offset) { if(internalState == AccessState::UNINIT) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "StorageAccessor: Not initialized!" << std::endl; #endif return HasReturnvaluesIF::RETURN_FAILED; } if(offset + size > size_) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "StorageAccessor: Data too large for pool " "entry!" << std::endl; #endif diff --git a/subsystem/SubsystemBase.cpp b/subsystem/SubsystemBase.cpp index 4ae50858..bcfa4b0e 100644 --- a/subsystem/SubsystemBase.cpp +++ b/subsystem/SubsystemBase.cpp @@ -86,7 +86,7 @@ void SubsystemBase::executeTable(HybridIterator tableIter, object_id_t object = tableIter.value->getObject(); if ((iter = childrenMap.find(object)) == childrenMap.end()) { //illegal table entry, should only happen due to misconfigured mode table -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << std::hex << getObjectId() << ": invalid mode table entry" << std::endl; #endif diff --git a/tasks/FixedSlotSequence.cpp b/tasks/FixedSlotSequence.cpp index 9d15a9c7..54b6ae6d 100644 --- a/tasks/FixedSlotSequence.cpp +++ b/tasks/FixedSlotSequence.cpp @@ -91,7 +91,7 @@ void FixedSlotSequence::addSlot(object_id_t componentId, uint32_t slotTimeMs, ReturnValue_t FixedSlotSequence::checkSequence() const { if(slotList.empty()) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "FixedSlotSequence::checkSequence:" << " Slot list is empty!" << std::endl; #endif @@ -102,7 +102,7 @@ ReturnValue_t FixedSlotSequence::checkSequence() const { ReturnValue_t result = customCheckFunction(slotList); if(result != HasReturnvaluesIF::RETURN_OK) { // Continue for now but print error output. -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "FixedSlotSequence::checkSequence:" << " Custom check failed!" << std::endl; #endif @@ -116,7 +116,7 @@ ReturnValue_t FixedSlotSequence::checkSequence() const { errorCount++; } else if (slot.pollingTimeMs < time) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "FixedSlotSequence::checkSequence: Time: " << slot.pollingTimeMs << " is smaller than previous with " << time << std::endl; @@ -125,7 +125,7 @@ ReturnValue_t FixedSlotSequence::checkSequence() const { } else { // All ok, print slot. -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 //sif::info << "Current slot polling time: " << std::endl; //sif::info << std::dec << slotIt->pollingTimeMs << std::endl; #endif @@ -133,7 +133,7 @@ ReturnValue_t FixedSlotSequence::checkSequence() const { time = slot.pollingTimeMs; } -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 //sif::info << "Number of elements in slot list: " // << slotList.size() << std::endl; #endif @@ -159,7 +159,7 @@ ReturnValue_t FixedSlotSequence::intializeSequenceAfterTaskCreation() const { } } if (count > 0) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "FixedSlotSequence::intializeSequenceAfterTaskCreation:" "Counted " << count << " failed initializations!" << std::endl; #endif diff --git a/tcdistribution/CCSDSDistributor.cpp b/tcdistribution/CCSDSDistributor.cpp index 742dd648..b795854f 100644 --- a/tcdistribution/CCSDSDistributor.cpp +++ b/tcdistribution/CCSDSDistributor.cpp @@ -11,7 +11,7 @@ CCSDSDistributor::CCSDSDistributor(uint16_t setDefaultApid, CCSDSDistributor::~CCSDSDistributor() {} TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 // sif::debug << "CCSDSDistributor::selectDestination received: " << // this->currentMessage.getStorageId().pool_index << ", " << // this->currentMessage.getStorageId().packet_index << std::endl; @@ -21,14 +21,14 @@ TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() { ReturnValue_t result = this->tcStore->getData(currentMessage.getStorageId(), &packet, &size ); if(result != HasReturnvaluesIF::RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "CCSDSDistributor::selectDestination: Getting data from" " store failed!" << std::endl; #endif } SpacePacketBase currentPacket(packet); -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 // sif:: info << "CCSDSDistributor::selectDestination has packet with APID " // << std::hex << currentPacket.getAPID() << std::dec << std::endl; #endif @@ -76,7 +76,7 @@ ReturnValue_t CCSDSDistributor::initialize() { ReturnValue_t status = this->TcDistributor::initialize(); this->tcStore = objectManager->get( objects::TC_STORE ); if (this->tcStore == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "CCSDSDistributor::initialize: Could not initialize" " TC store!" << std::endl; #endif diff --git a/tcdistribution/PUSDistributor.cpp b/tcdistribution/PUSDistributor.cpp index 3a214268..00fd9029 100644 --- a/tcdistribution/PUSDistributor.cpp +++ b/tcdistribution/PUSDistributor.cpp @@ -13,7 +13,7 @@ PUSDistributor::PUSDistributor(uint16_t setApid, object_id_t setObjectId, PUSDistributor::~PUSDistributor() {} PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 // sif:: debug << "PUSDistributor::handlePacket received: " // << this->current_packet_id.store_index << ", " // << this->current_packet_id.packet_index << std::endl; @@ -27,7 +27,7 @@ PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() { tcStatus = checker.checkPacket(currentPacket); #ifdef DEBUG if(tcStatus != HasReturnvaluesIF::RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "PUSDistributor::handlePacket: Packet format " << "invalid, code "<< static_cast(tcStatus) << std::endl; @@ -44,7 +44,7 @@ PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() { if (queueMapIt == this->queueMap.end()) { tcStatus = DESTINATION_NOT_FOUND; #ifdef DEBUG -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "PUSDistributor::handlePacket: Destination not found, " << "code "<< static_cast(tcStatus) << std::endl; #endif @@ -63,13 +63,13 @@ PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() { ReturnValue_t PUSDistributor::registerService(AcceptsTelecommandsIF* service) { uint16_t serviceId = service->getIdentifier(); -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 // sif::info << "Service ID: " << (int)serviceId << std::endl; #endif MessageQueueId_t queue = service->getRequestQueue(); auto returnPair = queueMap.emplace(serviceId, queue); if (not returnPair.second) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PUSDistributor::registerService: Service ID already" " exists in map." << std::endl; #endif @@ -114,7 +114,7 @@ ReturnValue_t PUSDistributor::initialize() { CCSDSDistributorIF* ccsdsDistributor = objectManager->get(packetSource); if (ccsdsDistributor == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PUSDistributor::initialize: Packet source invalid." << " Make sure it exists and implements CCSDSDistributorIF!" << std::endl; diff --git a/tcdistribution/TcDistributor.cpp b/tcdistribution/TcDistributor.cpp index 0bd4a906..df069556 100644 --- a/tcdistribution/TcDistributor.cpp +++ b/tcdistribution/TcDistributor.cpp @@ -39,7 +39,7 @@ ReturnValue_t TcDistributor::handlePacket() { } void TcDistributor::print() { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "Distributor content is: " << std::endl << "ID\t| Message Queue ID" << std::endl; sif::debug << std::setfill('0') << std::setw(8) << std::hex; diff --git a/timemanager/Stopwatch.cpp b/timemanager/Stopwatch.cpp index b3d080ba..f79d2eeb 100644 --- a/timemanager/Stopwatch.cpp +++ b/timemanager/Stopwatch.cpp @@ -28,13 +28,13 @@ double Stopwatch::stopSeconds() { void Stopwatch::display() { if(displayMode == StopwatchDisplayMode::MILLIS) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "Stopwatch: Operation took " << (elapsedTime.tv_sec * 1000 + elapsedTime.tv_usec / 1000) << " milliseconds" << std::endl; #endif } else if(displayMode == StopwatchDisplayMode::SECONDS) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info <<"Stopwatch: Operation took " << std::setprecision(3) << std::fixed << timevalOperations::toDouble(elapsedTime) << " seconds" << std::endl; diff --git a/tmtcpacket/pus/TcPacketBase.cpp b/tmtcpacket/pus/TcPacketBase.cpp index 1a28419c..ca3e2a99 100644 --- a/tmtcpacket/pus/TcPacketBase.cpp +++ b/tmtcpacket/pus/TcPacketBase.cpp @@ -63,7 +63,7 @@ uint8_t TcPacketBase::getPusVersionNumber() { } void TcPacketBase::print() { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "TcPacketBase::print: " << std::endl; #endif arrayprinter::print(getWholeData(), getFullSize()); diff --git a/tmtcpacket/pus/TcPacketStored.cpp b/tmtcpacket/pus/TcPacketStored.cpp index 021b6d67..f320386c 100644 --- a/tmtcpacket/pus/TcPacketStored.cpp +++ b/tmtcpacket/pus/TcPacketStored.cpp @@ -23,7 +23,7 @@ TcPacketStored::TcPacketStored(uint16_t apid, uint8_t service, ReturnValue_t returnValue = this->store->getFreeElement(&this->storeAddress, (TC_PACKET_MIN_SIZE + size), &pData); if (returnValue != this->store->RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "TcPacketStored: Could not get free element from store!" << std::endl; #endif @@ -41,7 +41,7 @@ ReturnValue_t TcPacketStored::getData(const uint8_t ** dataPtr, size_t* dataSize) { auto result = this->store->getData(storeAddress, dataPtr, dataSize); if(result != HasReturnvaluesIF::RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "TcPacketStored: Could not get data!" << std::endl; #endif } @@ -65,7 +65,7 @@ bool TcPacketStored::checkAndSetStore() { if (this->store == nullptr) { this->store = objectManager->get(objects::TC_STORE); if (this->store == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TcPacketStored::TcPacketStored: TC Store not found!" << std::endl; #endif diff --git a/tmtcpacket/pus/TmPacketBase.cpp b/tmtcpacket/pus/TmPacketBase.cpp index bf892ccf..c8e4b430 100644 --- a/tmtcpacket/pus/TmPacketBase.cpp +++ b/tmtcpacket/pus/TmPacketBase.cpp @@ -57,7 +57,7 @@ void TmPacketBase::setData(const uint8_t* p_Data) { } void TmPacketBase::print() { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "TmPacketBase::print: " << std::endl; #endif arrayprinter::print(getWholeData(), getFullSize()); @@ -67,7 +67,7 @@ bool TmPacketBase::checkAndSetStamper() { if (timeStamper == NULL) { timeStamper = objectManager->get(timeStamperId); if (timeStamper == NULL) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TmPacketBase::checkAndSetStamper: Stamper not found!" << std::endl; #endif diff --git a/tmtcpacket/pus/TmPacketStored.cpp b/tmtcpacket/pus/TmPacketStored.cpp index 21f237bd..0fd2a4a0 100644 --- a/tmtcpacket/pus/TmPacketStored.cpp +++ b/tmtcpacket/pus/TmPacketStored.cpp @@ -105,7 +105,7 @@ bool TmPacketStored::checkAndSetStore() { if (store == nullptr) { store = objectManager->get(objects::TM_STORE); if (store == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TmPacketStored::TmPacketStored: TM Store not found!" << std::endl; #endif diff --git a/tmtcservices/CommandingServiceBase.cpp b/tmtcservices/CommandingServiceBase.cpp index 2be6e2ce..259f2ccb 100644 --- a/tmtcservices/CommandingServiceBase.cpp +++ b/tmtcservices/CommandingServiceBase.cpp @@ -75,7 +75,7 @@ ReturnValue_t CommandingServiceBase::initialize() { packetSource); if (packetForwarding == nullptr or distributor == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "CommandingServiceBase::intialize: Packet source or " "packet destination invalid!" << std::endl; #endif @@ -90,7 +90,7 @@ ReturnValue_t CommandingServiceBase::initialize() { TCStore = objectManager->get(objects::TC_STORE); if (IPCStore == nullptr or TCStore == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "CommandingServiceBase::intialize: IPC store or TC store " "not initialized yet!" << std::endl; #endif diff --git a/tmtcservices/PusServiceBase.cpp b/tmtcservices/PusServiceBase.cpp index 1b03a7f0..0a5cb202 100644 --- a/tmtcservices/PusServiceBase.cpp +++ b/tmtcservices/PusServiceBase.cpp @@ -25,7 +25,7 @@ ReturnValue_t PusServiceBase::performOperation(uint8_t opCode) { handleRequestQueue(); ReturnValue_t result = this->performService(); if (result != RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PusService " << (uint16_t) this->serviceId << ": performService returned with " << (int16_t) result << std::endl; @@ -45,7 +45,7 @@ void PusServiceBase::handleRequestQueue() { for (uint8_t count = 0; count < PUS_SERVICE_MAX_RECEPTION; count++) { ReturnValue_t status = this->requestQueue->receiveMessage(&message); // if(status != MessageQueueIF::EMPTY) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 // sif::debug << "PusServiceBase::performOperation: Receiving from " // << "MQ ID: " << std::hex << "0x" << std::setw(8) // << std::setfill('0') << this->requestQueue->getId() @@ -83,7 +83,7 @@ void PusServiceBase::handleRequestQueue() { break; } else { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PusServiceBase::performOperation: Service " << this->serviceId << ": Error receiving packet. Code: " << std::hex << status << std::dec << std::endl; @@ -110,7 +110,7 @@ ReturnValue_t PusServiceBase::initialize() { PUSDistributorIF* distributor = objectManager->get( packetSource); if (destService == nullptr or distributor == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PusServiceBase::PusServiceBase: Service " << this->serviceId << ": Configuration error. Make sure " << "packetSource and packetDestination are defined correctly" diff --git a/tmtcservices/TmTcBridge.cpp b/tmtcservices/TmTcBridge.cpp index 954e3e75..2513071a 100644 --- a/tmtcservices/TmTcBridge.cpp +++ b/tmtcservices/TmTcBridge.cpp @@ -23,7 +23,7 @@ ReturnValue_t TmTcBridge::setNumberOfSentPacketsPerCycle( return RETURN_OK; } else { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "TmTcBridge::setNumberOfSentPacketsPerCycle: Number of " << "packets sent per cycle exceeds limits. " << "Keeping default value." << std::endl; @@ -39,7 +39,7 @@ ReturnValue_t TmTcBridge::setMaxNumberOfPacketsStored( return RETURN_OK; } else { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "TmTcBridge::setMaxNumberOfPacketsStored: Number of " << "packets stored exceeds limits. " << "Keeping default value." << std::endl; @@ -51,7 +51,7 @@ ReturnValue_t TmTcBridge::setMaxNumberOfPacketsStored( ReturnValue_t TmTcBridge::initialize() { tcStore = objectManager->get(tcStoreId); if (tcStore == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcBridge::initialize: TC store invalid. Make sure" "it is created and set up properly." << std::endl; #endif @@ -59,7 +59,7 @@ ReturnValue_t TmTcBridge::initialize() { } tmStore = objectManager->get(tmStoreId); if (tmStore == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcBridge::initialize: TM store invalid. Make sure" "it is created and set up properly." << std::endl; #endif @@ -68,7 +68,7 @@ ReturnValue_t TmTcBridge::initialize() { AcceptsTelecommandsIF* tcDistributor = objectManager->get(tcDestination); if (tcDistributor == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcBridge::initialize: TC Distributor invalid" << std::endl; #endif @@ -85,14 +85,14 @@ ReturnValue_t TmTcBridge::performOperation(uint8_t operationCode) { ReturnValue_t result; result = handleTc(); if(result != RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "TmTcBridge::performOperation: " << "Error handling TCs" << std::endl; #endif } result = handleTm(); if (result != RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "TmTcBridge::performOperation: " << "Error handling TMs" << std::endl; #endif @@ -108,7 +108,7 @@ ReturnValue_t TmTcBridge::handleTm() { ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; ReturnValue_t result = handleTmQueue(); if(result != RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcBridge::handleTm: Error handling TM queue with " << "error code 0x" << std::hex << result << std::dec << "!" << std::endl; @@ -120,7 +120,7 @@ ReturnValue_t TmTcBridge::handleTm() { (packetSentCounter < sentPacketsPerCycle)) { result = handleStoredTm(); if(result != RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TmTcBridge::handleTm: Error handling stored TMs!" << std::endl; #endif @@ -140,7 +140,7 @@ ReturnValue_t TmTcBridge::handleTmQueue() { result == HasReturnvaluesIF::RETURN_OK; result = tmTcReceptionQueue->receiveMessage(&message)) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 //sif::info << (int) packetSentCounter << std::endl; #endif if(communicationLinkUp == false or @@ -171,7 +171,7 @@ ReturnValue_t TmTcBridge::storeDownlinkData(TmTcMessage *message) { store_address_t storeId = 0; if(tmFifo->full()) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "TmTcBridge::storeDownlinkData: TM downlink max. number " << "of stored packet IDs reached! " << std::endl; #endif @@ -193,7 +193,7 @@ ReturnValue_t TmTcBridge::storeDownlinkData(TmTcMessage *message) { ReturnValue_t TmTcBridge::handleStoredTm() { ReturnValue_t status = RETURN_OK; while(not tmFifo->empty() and packetSentCounter < sentPacketsPerCycle) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 //sif::info << "TMTC Bridge: Sending stored TM data. There are " // << (int) tmFifo->size() << " left to send\r\n" << std::flush; #endif @@ -209,7 +209,7 @@ ReturnValue_t TmTcBridge::handleStoredTm() { result = sendTm(data,size); if(result != RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "TMTC Bridge: Could not send stored downlink data" << std::endl; #endif @@ -227,7 +227,7 @@ ReturnValue_t TmTcBridge::handleStoredTm() { void TmTcBridge::registerCommConnect() { if(not communicationLinkUp) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 //sif::info << "TMTC Bridge: Registered Comm Link Connect" << std::endl; #endif communicationLinkUp = true; @@ -235,7 +235,7 @@ void TmTcBridge::registerCommConnect() { } void TmTcBridge::registerCommDisconnect() { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 //sif::info << "TMTC Bridge: Registered Comm Link Disconnect" << std::endl; #endif if(communicationLinkUp) { diff --git a/tmtcservices/VerificationReporter.cpp b/tmtcservices/VerificationReporter.cpp index 3bd1f067..ff6f54f9 100644 --- a/tmtcservices/VerificationReporter.cpp +++ b/tmtcservices/VerificationReporter.cpp @@ -27,7 +27,7 @@ void VerificationReporter::sendSuccessReport(uint8_t set_report_id, ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); if (status != HasReturnvaluesIF::RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "VerificationReporter::sendSuccessReport: Error writing " << "to queue. Code: " << std::hex << status << std::dec << std::endl; @@ -46,7 +46,7 @@ void VerificationReporter::sendSuccessReport(uint8_t set_report_id, ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); if (status != HasReturnvaluesIF::RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "VerificationReporter::sendSuccessReport: Error writing " << "to queue. Code: " << std::hex << status << std::dec << std::endl; @@ -68,7 +68,7 @@ void VerificationReporter::sendFailureReport(uint8_t report_id, ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); if (status != HasReturnvaluesIF::RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "VerificationReporter::sendFailureReport: Error writing " << "to queue. Code: " << std::hex << "0x" << status << std::dec << std::endl; @@ -88,7 +88,7 @@ void VerificationReporter::sendFailureReport(uint8_t report_id, ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); if (status != HasReturnvaluesIF::RETURN_OK) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "VerificationReporter::sendFailureReport: Error writing " << "to queue. Code: " << std::hex << "0x" << status << std::dec << std::endl; @@ -98,7 +98,7 @@ void VerificationReporter::sendFailureReport(uint8_t report_id, void VerificationReporter::initialize() { if(messageReceiver == objects::NO_OBJECT) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "VerificationReporter::initialize: Verification message" " receiver object ID not set yet in Factory!" << std::endl; #endif @@ -107,7 +107,7 @@ void VerificationReporter::initialize() { AcceptsVerifyMessageIF* temp = objectManager->get( messageReceiver); if (temp == nullptr) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "VerificationReporter::initialize: Message " << "receiver invalid. Make sure it is set up properly and " << "implementsAcceptsVerifyMessageIF" << std::endl; diff --git a/unittest/internal/InternalUnitTester.cpp b/unittest/internal/InternalUnitTester.cpp index 6771b17e..bd41969c 100644 --- a/unittest/internal/InternalUnitTester.cpp +++ b/unittest/internal/InternalUnitTester.cpp @@ -13,7 +13,7 @@ InternalUnitTester::InternalUnitTester() {} InternalUnitTester::~InternalUnitTester() {} ReturnValue_t InternalUnitTester::performTests() { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "Running internal unit tests.." << std::endl; #endif testserialize::test_serialization(); @@ -21,7 +21,7 @@ ReturnValue_t InternalUnitTester::performTests() { testsemaph::testBinSemaph(); testsemaph::testCountingSemaph(); testmutex::testMutex(); -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "Internal unit tests finished." << std::endl; #endif return RETURN_OK; diff --git a/unittest/internal/UnittDefinitions.cpp b/unittest/internal/UnittDefinitions.cpp index 292c4b8a..7138e6c6 100644 --- a/unittest/internal/UnittDefinitions.cpp +++ b/unittest/internal/UnittDefinitions.cpp @@ -1,7 +1,7 @@ #include "UnittDefinitions.h" ReturnValue_t unitt::put_error(std::string errorId) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Unit Tester error: Failed at test ID " << errorId << "\n" << std::flush; #endif diff --git a/unittest/internal/osal/IntTestSemaphore.cpp b/unittest/internal/osal/IntTestSemaphore.cpp index 908326d4..43990c2c 100644 --- a/unittest/internal/osal/IntTestSemaphore.cpp +++ b/unittest/internal/osal/IntTestSemaphore.cpp @@ -94,7 +94,7 @@ void testsemaph::testBinSemaphoreImplementation(SemaphoreIF* binSemaph, result = binSemaph->acquire(SemaphoreIF::TimeoutType::WAITING, 10); //dur_millis_t time = stopwatch.stop(); // if(abs(time - 10) > 2) { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 // sif::error << "UnitTester: Semaphore timeout measured incorrect." // << std::endl; #endif diff --git a/unittest/user/testcfg/pollingsequence/PollingSequenceFactory.cpp b/unittest/user/testcfg/pollingsequence/PollingSequenceFactory.cpp index 443b2bbb..b7f1fb3e 100644 --- a/unittest/user/testcfg/pollingsequence/PollingSequenceFactory.cpp +++ b/unittest/user/testcfg/pollingsequence/PollingSequenceFactory.cpp @@ -15,7 +15,7 @@ ReturnValue_t pst::pollingSequenceInitDefault( return HasReturnvaluesIF::RETURN_OK; } else { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "pst::pollingSequenceInitDefault: Sequence invalid!" << std::endl; #endif diff --git a/unittest/user/unittest/core/CatchDefinitions.cpp b/unittest/user/unittest/core/CatchDefinitions.cpp index 6504700c..00daf015 100644 --- a/unittest/user/unittest/core/CatchDefinitions.cpp +++ b/unittest/user/unittest/core/CatchDefinitions.cpp @@ -5,7 +5,7 @@ StorageManagerIF* tglob::getIpcStoreHandle() { if(objectManager != nullptr) { return objectManager->get(objects::IPC_STORE); } else { -#if CPP_OSTREAM_ENABLED == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Global object manager uninitialized" << std::endl; #endif return nullptr; From 695a767164573b73a3360e9bf10a70773236ef2c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 3 Jan 2021 14:33:17 +0100 Subject: [PATCH 22/50] some include fixes --- globalfunctions/arrayprinter.cpp | 2 +- objectmanager/ObjectManager.cpp | 2 +- serviceinterface/ServiceInterfaceStream.h | 1 + storagemanager/ConstStorageAccessor.cpp | 2 ++ storagemanager/StorageAccessor.cpp | 2 ++ 5 files changed, 7 insertions(+), 2 deletions(-) diff --git a/globalfunctions/arrayprinter.cpp b/globalfunctions/arrayprinter.cpp index d0b0a3bf..c273b250 100644 --- a/globalfunctions/arrayprinter.cpp +++ b/globalfunctions/arrayprinter.cpp @@ -33,7 +33,7 @@ void arrayprinter::printHex(const uint8_t *data, size_t size, sif::info << std::endl; } - + } } sif::info << std::dec; sif::info << "]" << std::endl; diff --git a/objectmanager/ObjectManager.cpp b/objectmanager/ObjectManager.cpp index 69dd905b..882d2762 100644 --- a/objectmanager/ObjectManager.cpp +++ b/objectmanager/ObjectManager.cpp @@ -29,7 +29,7 @@ ReturnValue_t ObjectManager::insert( object_id_t id, SystemObjectIF* object) { } else { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "ObjectManager::insert: Object id " << std::hex - << static_cast id << std::dec + << static_cast(id) << std::dec << " is already in use!" << std::endl; sif::error << "Terminating program." << std::endl; #endif diff --git a/serviceinterface/ServiceInterfaceStream.h b/serviceinterface/ServiceInterfaceStream.h index c18c6c2e..f3cb2cd0 100644 --- a/serviceinterface/ServiceInterfaceStream.h +++ b/serviceinterface/ServiceInterfaceStream.h @@ -2,6 +2,7 @@ #define FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACESTREAM_H_ #include "ServiceInterfaceBuffer.h" +#include #if FSFW_CPP_OSTREAM_ENABLED == 1 diff --git a/storagemanager/ConstStorageAccessor.cpp b/storagemanager/ConstStorageAccessor.cpp index 39530ac9..aab84862 100644 --- a/storagemanager/ConstStorageAccessor.cpp +++ b/storagemanager/ConstStorageAccessor.cpp @@ -4,6 +4,8 @@ #include "../serviceinterface/ServiceInterfaceStream.h" #include "../globalfunctions/arrayprinter.h" +#include + ConstStorageAccessor::ConstStorageAccessor(store_address_t storeId): storeId(storeId) {} diff --git a/storagemanager/StorageAccessor.cpp b/storagemanager/StorageAccessor.cpp index fec5d75e..a7b4fae4 100644 --- a/storagemanager/StorageAccessor.cpp +++ b/storagemanager/StorageAccessor.cpp @@ -2,6 +2,8 @@ #include "StorageManagerIF.h" #include "../serviceinterface/ServiceInterfaceStream.h" +#include + StorageAccessor::StorageAccessor(store_address_t storeId): ConstStorageAccessor(storeId) { } From 98af84c1455f57e96cf300a9746d759930e31f78 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 3 Jan 2021 14:41:54 +0100 Subject: [PATCH 23/50] additional tweask --- datapoollocal/LocalPoolVariable.h | 2 ++ datapoollocal/LocalPoolVariable.tpp | 2 ++ serialize/EndianConverter.h | 1 - 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/datapoollocal/LocalPoolVariable.h b/datapoollocal/LocalPoolVariable.h index 7b7e443e..84be54b1 100644 --- a/datapoollocal/LocalPoolVariable.h +++ b/datapoollocal/LocalPoolVariable.h @@ -157,10 +157,12 @@ protected: */ ReturnValue_t commitWithoutLock() override; +#if FSFW_CPP_OSTREAM_ENABLED == 1 // std::ostream is the type for object std::cout template friend std::ostream& operator<< (std::ostream &out, const LocalPoolVariable &var); +#endif private: }; diff --git a/datapoollocal/LocalPoolVariable.tpp b/datapoollocal/LocalPoolVariable.tpp index aa5e5393..cd5117c8 100644 --- a/datapoollocal/LocalPoolVariable.tpp +++ b/datapoollocal/LocalPoolVariable.tpp @@ -106,12 +106,14 @@ inline ReturnValue_t LocalPoolVariable::deSerialize(const uint8_t** buffer, return SerializeAdapter::deSerialize(&value, buffer, size, streamEndianness); } +#if FSFW_CPP_OSTREAM_ENABLED == 1 template inline std::ostream& operator<< (std::ostream &out, const LocalPoolVariable &var) { out << var.value; return out; } +#endif template inline LocalPoolVariable::operator T() const { diff --git a/serialize/EndianConverter.h b/serialize/EndianConverter.h index c888a905..8f3c7a7e 100644 --- a/serialize/EndianConverter.h +++ b/serialize/EndianConverter.h @@ -3,7 +3,6 @@ #include "../osal/Endiness.h" #include -#include /** * Helper class to convert variables or bitstreams between machine From 8c8965177f5007a770e323311e287bf0ab186ad9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 3 Jan 2021 15:04:37 +0100 Subject: [PATCH 24/50] new amalgated header --- serviceinterface/ServiceInterface.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 serviceinterface/ServiceInterface.h diff --git a/serviceinterface/ServiceInterface.h b/serviceinterface/ServiceInterface.h new file mode 100644 index 00000000..0c7c4383 --- /dev/null +++ b/serviceinterface/ServiceInterface.h @@ -0,0 +1,12 @@ +#ifndef FSFW_SERVICEINTERFACE_SERVICEINTERFACE_H_ +#define FSFW_SERVICEINTERFACE_SERVICEINTERFACE_H_ + +#include + +#if FSFW_CPP_OSTREAM_ENABLED == 1 +#include +#else +#include +#endif + +#endif /* FSFW_SERVICEINTERFACE_SERVICEINTERFACE_H_ */ From 59d327f8b6f27eea4e3694541505ae86b96a81f7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 3 Jan 2021 15:15:03 +0100 Subject: [PATCH 25/50] console init for printf on windows --- serviceinterface/ServiceInterfacePrinter.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/serviceinterface/ServiceInterfacePrinter.cpp b/serviceinterface/ServiceInterfacePrinter.cpp index 369edd0f..e8eb498f 100644 --- a/serviceinterface/ServiceInterfacePrinter.cpp +++ b/serviceinterface/ServiceInterfacePrinter.cpp @@ -9,8 +9,23 @@ fsfw::PrintLevel printLevel = fsfw::PrintLevel::DEBUG; uint8_t printBuffer[fsfwconfig::FSFW_PRINT_BUFFER_SIZE]; +#if defined(WIN32) && FSFW_COLORED_OUTPUT == 1 +bool consoleInitialized = false; +#endif void fsfwPrint(fsfw::PrintLevel printType, const char* fmt, va_list arg) { + +#if defined(WIN32) && FSFW_COLORED_OUTPUT == 1 + if(not consoleInitialized) { + HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); + DWORD dwMode = 0; + GetConsoleMode(hOut, &dwMode); + dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING; + SetConsoleMode(hOut, dwMode); + } + consoleInitialized = true; +#endif + size_t len = 0; char* bufferPosition = reinterpret_cast(printBuffer); From c94a396ffb478a96b67269bc72bbb6f63dcc88fd Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 3 Jan 2021 15:31:44 +0100 Subject: [PATCH 26/50] changelog update --- CHANGELOG | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 2d901791..298ef0d4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -70,3 +70,15 @@ now ### Commanding Service Base - CSB uses the new fsfwconfig::FSFW_CSB_FIFO_DEPTH variable to determine the FIFO depth for each CSB instance. This variable has to be set in the FSFWConfig.h file + +### Service Interface + +- Proper printf support contained in ServiceInterfacePrinter.h +- CPP ostream support now optional (can reduce executable size by 150 - 250 kB) +- Amalagated header which determines automatically which service interface to use depending on FSFWConfig.h configuration. + Users can just use #include +- If CPP streams are excluded, sif:: calls won't work anymore and need to be replaced by their printf counterparts. + For the fsfw, this can be done by checking the processor define FSFW_CPP_OSTREAM_ENABLED from FSFWConfig.h. + For mission code, developers need to replace sif:: calls by the printf counterparts, but only if the CPP stream are excluded. + If this is not the case, everything should work as usual. +- \ No newline at end of file From e9da8e79f32fc2dfc34b779aa069c0c1faae339a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 3 Jan 2021 22:00:40 +0100 Subject: [PATCH 27/50] updated testcfg --- unittest/user/testcfg/FSFWConfig.h | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/unittest/user/testcfg/FSFWConfig.h b/unittest/user/testcfg/FSFWConfig.h index 6b0def90..261e3d6d 100644 --- a/unittest/user/testcfg/FSFWConfig.h +++ b/unittest/user/testcfg/FSFWConfig.h @@ -4,17 +4,26 @@ #include #include -//! Used to determine whether C++ ostreams are used -//! Those can lead to code bloat. +//! Used to determine whether C++ ostreams are used which can increase +//! the binary size significantly. If this is disabled, +//! the C stdio functions can be used alternatively #define FSFW_CPP_OSTREAM_ENABLED 1 -//! Reduced printout to further decrease code size +//! More FSFW related printouts. //! Be careful, this also turns off most diagnostic prinouts! #define FSFW_ENHANCED_PRINTOUT 0 +//! Can be used to completely disable printouts, even the C stdio ones. +#if FSFW_CPP_OSTREAM_ENABLED == 0 && FSFW_ENHANCED_PRINTOUT == 0 + #define FSFW_DISABLE_PRINTOUT 0 +#endif + //! Can be used to enable additional debugging printouts for developing the FSFW #define FSFW_PRINT_VERBOSITY_LEVEL 0 +//! Can be used to disable the ANSI color sequences for C stdio. +#define FSFW_COLORED_OUTPUT 1 + //! If FSFW_OBJ_EVENT_TRANSLATION is set to one, //! additional output which requires the translation files translateObjects //! and translateEvents (and their compiled source files) @@ -49,7 +58,9 @@ static constexpr size_t FSFW_EVENTMGMR_RANGEMATCHERS = 120; //! also determines how many commands a CSB service can handle in one cycle //! simulataneously. This will increase the required RAM for //! each CSB service ! -static constexpr uint8_t FSFW_CSB_FIFO_DEPTH = 3; +static constexpr uint8_t FSFW_CSB_FIFO_DEPTH = 6; + +static constexpr size_t FSFW_PRINT_BUFFER_SIZE = 124; } #endif /* CONFIG_FSFWCONFIG_H_ */ From e9a8313df7e5f4ae8f5afb732ef461bd348fcbb5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 3 Jan 2021 23:18:10 +0100 Subject: [PATCH 28/50] repaired unit tests --- container/FixedOrderedMultimap.h | 1 + .../tests/container/TestPlacementFactory.cpp | 93 ++--- .../tests/storagemanager/TestNewAccessor.cpp | 321 +++++++++--------- unittest/tests/storagemanager/TestPool.cpp | 2 - 4 files changed, 209 insertions(+), 208 deletions(-) diff --git a/container/FixedOrderedMultimap.h b/container/FixedOrderedMultimap.h index 96bc0073..acf2368a 100644 --- a/container/FixedOrderedMultimap.h +++ b/container/FixedOrderedMultimap.h @@ -3,6 +3,7 @@ #include "ArrayList.h" #include +#include /** * @brief An associative container which allows multiple entries of the same key. diff --git a/unittest/tests/container/TestPlacementFactory.cpp b/unittest/tests/container/TestPlacementFactory.cpp index 5edbb9d2..14cf8eb4 100644 --- a/unittest/tests/container/TestPlacementFactory.cpp +++ b/unittest/tests/container/TestPlacementFactory.cpp @@ -1,45 +1,48 @@ -//#include -//#include -//#include -//#include -// -//#include -//#include "../../core/CatchDefinitions.h" -// -//TEST_CASE( "PlacementFactory Tests", "[TestPlacementFactory]") { -// INFO("PlacementFactory Tests"); -// -// const uint16_t element_sizes[3] = {sizeof(uint16_t), sizeof(uint32_t), sizeof(uint64_t)}; -// const uint16_t n_elements[3] = {1, 1, 1}; -// LocalPool<3> storagePool(0x1, element_sizes, n_elements, false, true); -// PlacementFactory factory(&storagePool); -// -// SECTION("Pool overload"){ -// store_address_t address; -// uint8_t* ptr = nullptr; -// REQUIRE(storagePool.getFreeElement(&address, sizeof(ArrayList), &ptr) -// == static_cast(StorageManagerIF::DATA_TOO_LARGE)); -// ArrayList* list2 = factory.generate >(80); -// REQUIRE(list2 == nullptr); -// } -// -// SECTION("Test generate and destroy"){ -// uint64_t* number = factory.generate(32000); -// REQUIRE(number != nullptr); -// REQUIRE(*number == 32000); -// store_address_t address; -// uint8_t* ptr = nullptr; -// REQUIRE(storagePool.getFreeElement(&address, sizeof(uint64_t), &ptr) -// == static_cast(StorageManagerIF::DATA_TOO_LARGE)); -// uint64_t* number2 = factory.generate(12345); -// REQUIRE(number2 == nullptr); -// REQUIRE(factory.destroy(number) == static_cast(HasReturnvaluesIF::RETURN_OK)); -// REQUIRE(storagePool.getFreeElement(&address, sizeof(uint64_t), &ptr) -// == static_cast(HasReturnvaluesIF::RETURN_OK)); -// REQUIRE(storagePool.deleteData(address) == static_cast(HasReturnvaluesIF::RETURN_OK)); -// -// //Check that PlacementFactory checks for nullptr -// ptr = nullptr; -// REQUIRE(factory.destroy(ptr) == static_cast(HasReturnvaluesIF::RETURN_FAILED)); -// } -//} +#include +#include +#include +#include + +#include +#include + +TEST_CASE( "PlacementFactory Tests", "[TestPlacementFactory]") { + INFO("PlacementFactory Tests"); + + LocalPool::LocalPoolConfig poolCfg= {{1, sizeof(uint16_t)}, + {1, sizeof(uint32_t)}, {1, sizeof(uint64_t)} + }; + //const uint16_t element_sizes[3] = {sizeof(uint16_t), sizeof(uint32_t), sizeof(uint64_t)}; + //const uint16_t n_elements[3] = {1, 1, 1}; + LocalPool storagePool(0x1, poolCfg, false, true); + PlacementFactory factory(&storagePool); + + SECTION("Pool overload"){ + store_address_t address; + uint8_t* ptr = nullptr; + REQUIRE(storagePool.getFreeElement(&address, sizeof(ArrayList), &ptr) + == static_cast(StorageManagerIF::DATA_TOO_LARGE)); + ArrayList* list2 = factory.generate >(80); + REQUIRE(list2 == nullptr); + } + + SECTION("Test generate and destroy"){ + uint64_t* number = factory.generate(32000); + REQUIRE(number != nullptr); + REQUIRE(*number == 32000); + store_address_t address; + uint8_t* ptr = nullptr; + REQUIRE(storagePool.getFreeElement(&address, sizeof(uint64_t), &ptr) + == static_cast(StorageManagerIF::DATA_TOO_LARGE)); + uint64_t* number2 = factory.generate(12345); + REQUIRE(number2 == nullptr); + REQUIRE(factory.destroy(number) == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(storagePool.getFreeElement(&address, sizeof(uint64_t), &ptr) + == static_cast(HasReturnvaluesIF::RETURN_OK)); + REQUIRE(storagePool.deleteData(address) == static_cast(HasReturnvaluesIF::RETURN_OK)); + + //Check that PlacementFactory checks for nullptr + ptr = nullptr; + REQUIRE(factory.destroy(ptr) == static_cast(HasReturnvaluesIF::RETURN_FAILED)); + } +} diff --git a/unittest/tests/storagemanager/TestNewAccessor.cpp b/unittest/tests/storagemanager/TestNewAccessor.cpp index 7bd0dee2..87ea00ca 100644 --- a/unittest/tests/storagemanager/TestNewAccessor.cpp +++ b/unittest/tests/storagemanager/TestNewAccessor.cpp @@ -1,161 +1,160 @@ -//#include -//#include -//#include "../../core/CatchDefinitions.h" -//#include -// -//TEST_CASE( "New Accessor" , "[NewAccessor]") { -// uint16_t numberOfElements[1] = {1}; -// uint16_t sizeofElements[1] = {10}; -// LocalPool<1> SimplePool = LocalPool<1>(0, sizeofElements, numberOfElements); -// std::array testDataArray; -// std::array receptionArray; -// store_address_t testStoreId; -// ReturnValue_t result = retval::CATCH_FAILED; -// -// for(size_t i = 0; i < testDataArray.size(); i++) { -// testDataArray[i] = i; -// } -// size_t size = 10; -// -// SECTION ("Simple tests getter functions") { -// result = SimplePool.addData(&testStoreId, testDataArray.data(), size); -// REQUIRE(result == retval::CATCH_OK); -// auto resultPair = SimplePool.getData(testStoreId); -// REQUIRE(resultPair.first == retval::CATCH_OK); -// resultPair.second.getDataCopy(receptionArray.data(), 20); -// CHECK(resultPair.second.getId() == testStoreId); -// CHECK(resultPair.second.size() == 10); -// for(size_t i = 0; i < size; i++) { -// CHECK(receptionArray[i] == i ); -// } -// -// std::copy(resultPair.second.data(), resultPair.second.data() + -// resultPair.second.size(), receptionArray.data()); -// for(size_t i = 0; i < size; i++) { -// CHECK(receptionArray[i] == i ); -// } -// -// { -// auto resultPairLoc = SimplePool.getData(testStoreId); -// REQUIRE(resultPairLoc.first == retval::CATCH_OK); -// // data should be deleted when accessor goes out of scope. -// } -// resultPair = SimplePool.getData(testStoreId); -// REQUIRE(resultPair.first == (int) StorageManagerIF::DATA_DOES_NOT_EXIST); -// -// result = SimplePool.addData(&testStoreId, testDataArray.data(), size); -// REQUIRE(result == retval::CATCH_OK); -// { -// ConstStorageAccessor constAccessor(testStoreId); -// result = SimplePool.getData(testStoreId, constAccessor); -// REQUIRE(result == retval::CATCH_OK); -// constAccessor.getDataCopy(receptionArray.data(), 20); -// for(size_t i = 0; i < size; i++) { -// CHECK(receptionArray[i] == i ); -// } -// // likewise, data should be deleted when accessor gets out of scope. -// } -// resultPair = SimplePool.getData(testStoreId); -// REQUIRE(resultPair.first == (int) StorageManagerIF::DATA_DOES_NOT_EXIST); -// -// result = SimplePool.addData(&testStoreId, testDataArray.data(), size); -// { -// resultPair = SimplePool.getData(testStoreId); -// REQUIRE(resultPair.first == retval::CATCH_OK); -// resultPair.second.release(); -// // now data should not be deleted anymore -// } -// resultPair = SimplePool.getData(testStoreId); -// REQUIRE(resultPair.first == retval::CATCH_OK); -// resultPair.second.getDataCopy(receptionArray.data(), 20); -// for(size_t i = 0; i < size; i++) { -// CHECK(receptionArray[i] == i ); -// } -// } -// -// -// SECTION("Simple tests modify functions") { -// result = SimplePool.addData(&testStoreId, testDataArray.data(), size); -// REQUIRE(result == retval::CATCH_OK); -// { -// StorageAccessor accessor(testStoreId); -// result = SimplePool.modifyData(testStoreId, accessor); -// REQUIRE(result == retval::CATCH_OK); -// CHECK(accessor.getId() == testStoreId); -// CHECK(accessor.size() == 10); -// accessor.getDataCopy(receptionArray.data(), 20); -// for(size_t i = 0; i < size; i++) { -// CHECK(receptionArray[i] == i ); -// } -// std::copy(accessor.data(), accessor.data() + -// accessor.size(), receptionArray.data()); -// for(size_t i = 0; i < size; i++) { -// CHECK(receptionArray[i] == i ); -// } -// // data should be deleted when accessor goes out of scope -// } -// auto resultPair = SimplePool.getData(testStoreId); -// REQUIRE(resultPair.first == (int) StorageManagerIF::DATA_DOES_NOT_EXIST); -// -// result = SimplePool.addData(&testStoreId, testDataArray.data(), size); -// REQUIRE(result == retval::CATCH_OK); -// { -// auto resultPairLoc = SimplePool.modifyData(testStoreId); -// REQUIRE(resultPairLoc.first == retval::CATCH_OK); -// CHECK(resultPairLoc.second.getId() == testStoreId); -// CHECK(resultPairLoc.second.size() == 10); -// resultPairLoc.second.getDataCopy(receptionArray.data(), 20); -// for(size_t i = 0; i < size; i++) { -// CHECK(receptionArray[i] == i ); -// } -// std::copy(resultPairLoc.second.data(), resultPairLoc.second.data() + -// resultPairLoc.second.size(), receptionArray.data()); -// for(size_t i = 0; i < size; i++) { -// CHECK(receptionArray[i] == i ); -// } -// resultPairLoc.second.release(); -// // data should not be deleted when accessor goes out of scope -// } -// resultPair = SimplePool.getData(testStoreId); -// REQUIRE(resultPair.first == retval::CATCH_OK); -// } -// -// -// SECTION("Write tests") { -// result = SimplePool.addData(&testStoreId, testDataArray.data(), size); -// REQUIRE(result == retval::CATCH_OK); -// { -// auto resultPair = SimplePool.modifyData(testStoreId); -// REQUIRE(resultPair.first == retval::CATCH_OK); -// testDataArray[9] = 42; -// resultPair.second.write(testDataArray.data(), 10, 0); -// // now data should not be deleted -// resultPair.second.release(); -// } -// auto resultConstPair = SimplePool.getData(testStoreId); -// REQUIRE(resultConstPair.first == retval::CATCH_OK); -// -// resultConstPair.second.getDataCopy(receptionArray.data(), 10); -// for(size_t i = 0; i < size-1; i++) { -// CHECK(receptionArray[i] == i ); -// } -// CHECK(receptionArray[9] == 42 ); -// -// auto resultPair = SimplePool.modifyData(testStoreId); -// REQUIRE(resultPair.first == retval::CATCH_OK); -// result = resultPair.second.write(testDataArray.data(), 20, 0); -// REQUIRE(result == retval::CATCH_FAILED); -// result = resultPair.second.write(testDataArray.data(), 10, 5); -// REQUIRE(result == retval::CATCH_FAILED); -// -// memset(testDataArray.data(), 42, 5); -// result = resultPair.second.write(testDataArray.data(), 5, 5); -// REQUIRE(result == retval::CATCH_OK); -// resultConstPair = SimplePool.getData(testStoreId); -// resultPair.second.getDataCopy(receptionArray.data(), 20); -// for(size_t i = 5; i < 10; i++) { -// CHECK(receptionArray[i] == 42 ); -// } -// -// } -//} +#include +#include +#include +#include + +TEST_CASE( "New Accessor" , "[NewAccessor]") { + LocalPool::LocalPoolConfig poolCfg = {{1, 10}}; + LocalPool SimplePool = LocalPool(0, poolCfg); + std::array testDataArray; + std::array receptionArray; + store_address_t testStoreId; + ReturnValue_t result = retval::CATCH_FAILED; + + for(size_t i = 0; i < testDataArray.size(); i++) { + testDataArray[i] = i; + } + size_t size = 10; + + SECTION ("Simple tests getter functions") { + result = SimplePool.addData(&testStoreId, testDataArray.data(), size); + REQUIRE(result == retval::CATCH_OK); + auto resultPair = SimplePool.getData(testStoreId); + REQUIRE(resultPair.first == retval::CATCH_OK); + resultPair.second.getDataCopy(receptionArray.data(), 20); + CHECK(resultPair.second.getId() == testStoreId); + CHECK(resultPair.second.size() == 10); + for(size_t i = 0; i < size; i++) { + CHECK(receptionArray[i] == i ); + } + + std::copy(resultPair.second.data(), resultPair.second.data() + + resultPair.second.size(), receptionArray.data()); + for(size_t i = 0; i < size; i++) { + CHECK(receptionArray[i] == i ); + } + + { + auto resultPairLoc = SimplePool.getData(testStoreId); + REQUIRE(resultPairLoc.first == retval::CATCH_OK); + // data should be deleted when accessor goes out of scope. + } + resultPair = SimplePool.getData(testStoreId); + REQUIRE(resultPair.first == (int) StorageManagerIF::DATA_DOES_NOT_EXIST); + + result = SimplePool.addData(&testStoreId, testDataArray.data(), size); + REQUIRE(result == retval::CATCH_OK); + { + ConstStorageAccessor constAccessor(testStoreId); + result = SimplePool.getData(testStoreId, constAccessor); + REQUIRE(result == retval::CATCH_OK); + constAccessor.getDataCopy(receptionArray.data(), 20); + for(size_t i = 0; i < size; i++) { + CHECK(receptionArray[i] == i ); + } + // likewise, data should be deleted when accessor gets out of scope. + } + resultPair = SimplePool.getData(testStoreId); + REQUIRE(resultPair.first == (int) StorageManagerIF::DATA_DOES_NOT_EXIST); + + result = SimplePool.addData(&testStoreId, testDataArray.data(), size); + { + resultPair = SimplePool.getData(testStoreId); + REQUIRE(resultPair.first == retval::CATCH_OK); + resultPair.second.release(); + // now data should not be deleted anymore + } + resultPair = SimplePool.getData(testStoreId); + REQUIRE(resultPair.first == retval::CATCH_OK); + resultPair.second.getDataCopy(receptionArray.data(), 20); + for(size_t i = 0; i < size; i++) { + CHECK(receptionArray[i] == i ); + } + } + + + SECTION("Simple tests modify functions") { + result = SimplePool.addData(&testStoreId, testDataArray.data(), size); + REQUIRE(result == retval::CATCH_OK); + { + StorageAccessor accessor(testStoreId); + result = SimplePool.modifyData(testStoreId, accessor); + REQUIRE(result == retval::CATCH_OK); + CHECK(accessor.getId() == testStoreId); + CHECK(accessor.size() == 10); + accessor.getDataCopy(receptionArray.data(), 20); + for(size_t i = 0; i < size; i++) { + CHECK(receptionArray[i] == i ); + } + std::copy(accessor.data(), accessor.data() + + accessor.size(), receptionArray.data()); + for(size_t i = 0; i < size; i++) { + CHECK(receptionArray[i] == i ); + } + // data should be deleted when accessor goes out of scope + } + auto resultPair = SimplePool.getData(testStoreId); + REQUIRE(resultPair.first == (int) StorageManagerIF::DATA_DOES_NOT_EXIST); + + result = SimplePool.addData(&testStoreId, testDataArray.data(), size); + REQUIRE(result == retval::CATCH_OK); + { + auto resultPairLoc = SimplePool.modifyData(testStoreId); + REQUIRE(resultPairLoc.first == retval::CATCH_OK); + CHECK(resultPairLoc.second.getId() == testStoreId); + CHECK(resultPairLoc.second.size() == 10); + resultPairLoc.second.getDataCopy(receptionArray.data(), 20); + for(size_t i = 0; i < size; i++) { + CHECK(receptionArray[i] == i ); + } + std::copy(resultPairLoc.second.data(), resultPairLoc.second.data() + + resultPairLoc.second.size(), receptionArray.data()); + for(size_t i = 0; i < size; i++) { + CHECK(receptionArray[i] == i ); + } + resultPairLoc.second.release(); + // data should not be deleted when accessor goes out of scope + } + resultPair = SimplePool.getData(testStoreId); + REQUIRE(resultPair.first == retval::CATCH_OK); + } + + + SECTION("Write tests") { + result = SimplePool.addData(&testStoreId, testDataArray.data(), size); + REQUIRE(result == retval::CATCH_OK); + { + auto resultPair = SimplePool.modifyData(testStoreId); + REQUIRE(resultPair.first == retval::CATCH_OK); + testDataArray[9] = 42; + resultPair.second.write(testDataArray.data(), 10, 0); + // now data should not be deleted + resultPair.second.release(); + } + auto resultConstPair = SimplePool.getData(testStoreId); + REQUIRE(resultConstPair.first == retval::CATCH_OK); + + resultConstPair.second.getDataCopy(receptionArray.data(), 10); + for(size_t i = 0; i < size-1; i++) { + CHECK(receptionArray[i] == i ); + } + CHECK(receptionArray[9] == 42 ); + + auto resultPair = SimplePool.modifyData(testStoreId); + REQUIRE(resultPair.first == retval::CATCH_OK); + result = resultPair.second.write(testDataArray.data(), 20, 0); + REQUIRE(result == retval::CATCH_FAILED); + result = resultPair.second.write(testDataArray.data(), 10, 5); + REQUIRE(result == retval::CATCH_FAILED); + + memset(testDataArray.data(), 42, 5); + result = resultPair.second.write(testDataArray.data(), 5, 5); + REQUIRE(result == retval::CATCH_OK); + resultConstPair = SimplePool.getData(testStoreId); + resultPair.second.getDataCopy(receptionArray.data(), 20); + for(size_t i = 5; i < 10; i++) { + CHECK(receptionArray[i] == 42 ); + } + + } +} diff --git a/unittest/tests/storagemanager/TestPool.cpp b/unittest/tests/storagemanager/TestPool.cpp index dcfb6c03..50bde01a 100644 --- a/unittest/tests/storagemanager/TestPool.cpp +++ b/unittest/tests/storagemanager/TestPool.cpp @@ -8,8 +8,6 @@ TEST_CASE( "Local Pool Simple Tests [1 Pool]" , "[TestPool]") { -// uint16_t numberOfElements[1] = {1}; -// uint16_t sizeofElements[1] = {10}; LocalPool::LocalPoolConfig config = {{1, 10}}; LocalPool simplePool(0, config); std::array testDataArray; From 49c6cd947300bef7db1622a547af7ce5fdf7980b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 3 Jan 2021 23:27:49 +0100 Subject: [PATCH 29/50] added local pool owner base --- unittest/tests/datapoollocal/LocalPoolOwnerBase.h | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 unittest/tests/datapoollocal/LocalPoolOwnerBase.h diff --git a/unittest/tests/datapoollocal/LocalPoolOwnerBase.h b/unittest/tests/datapoollocal/LocalPoolOwnerBase.h new file mode 100644 index 00000000..5e62234b --- /dev/null +++ b/unittest/tests/datapoollocal/LocalPoolOwnerBase.h @@ -0,0 +1,8 @@ +#ifndef FSFW_UNITTEST_TESTS_DATAPOOLLOCAL_LOCALPOOLOWNERBASE_H_ +#define FSFW_UNITTEST_TESTS_DATAPOOLLOCAL_LOCALPOOLOWNERBASE_H_ + + + + + +#endif /* FSFW_UNITTEST_TESTS_DATAPOOLLOCAL_LOCALPOOLOWNERBASE_H_ */ From 8e3aef5df05669d686d1ec0a6a899e3c6a369d7a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 4 Jan 2021 00:21:44 +0100 Subject: [PATCH 30/50] adding new tests for local pool variable --- unittest/tests/CMakeLists.txt | 1 + unittest/tests/datapoollocal/CMakeLists.txt | 3 + .../tests/datapoollocal/LocalPoolOwnerBase.h | 75 +++++++++++++++++++ .../datapoollocal/LocalPoolVariableTest.cpp | 37 +++++++++ .../user/testcfg/objects/systemObjectList.h | 14 +++- 5 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 unittest/tests/datapoollocal/CMakeLists.txt create mode 100644 unittest/tests/datapoollocal/LocalPoolVariableTest.cpp diff --git a/unittest/tests/CMakeLists.txt b/unittest/tests/CMakeLists.txt index 97074417..180e1a51 100644 --- a/unittest/tests/CMakeLists.txt +++ b/unittest/tests/CMakeLists.txt @@ -2,5 +2,6 @@ add_subdirectory(action) add_subdirectory(container) add_subdirectory(osal) add_subdirectory(serialize) +add_subdirectory(datapoollocal) add_subdirectory(storagemanager) diff --git a/unittest/tests/datapoollocal/CMakeLists.txt b/unittest/tests/datapoollocal/CMakeLists.txt new file mode 100644 index 00000000..569a8d5f --- /dev/null +++ b/unittest/tests/datapoollocal/CMakeLists.txt @@ -0,0 +1,3 @@ +target_sources(${TARGET_NAME} PRIVATE + LocalPoolVariableTest.cpp +) diff --git a/unittest/tests/datapoollocal/LocalPoolOwnerBase.h b/unittest/tests/datapoollocal/LocalPoolOwnerBase.h index 5e62234b..b73c5299 100644 --- a/unittest/tests/datapoollocal/LocalPoolOwnerBase.h +++ b/unittest/tests/datapoollocal/LocalPoolOwnerBase.h @@ -1,8 +1,83 @@ #ifndef FSFW_UNITTEST_TESTS_DATAPOOLLOCAL_LOCALPOOLOWNERBASE_H_ #define FSFW_UNITTEST_TESTS_DATAPOOLLOCAL_LOCALPOOLOWNERBASE_H_ +#include +#include +#include +#include +#include + +namespace lpool { +static constexpr lp_id_t uint8VarId = 0; +static constexpr lp_id_t floatVarId = 1; +} +class LocalPoolOwnerBase: public SystemObject, public HasLocalDataPoolIF { +public: + LocalPoolOwnerBase( + object_id_t objectId = objects::TEST_LOCAL_POOL_OWNER_BASE): + SystemObject(objectId), hkManager(this, messageQueue) { + messageQueue = QueueFactory::instance()->createMessageQueue(10); + } + ~LocalPoolOwnerBase() { + QueueFactory::instance()->deleteMessageQueue(messageQueue); + } + + object_id_t getObjectId() const override { + return SystemObject::getObjectId(); + } + + ReturnValue_t initializeHkManager() { + return hkManager.initialize(messageQueue); + + } + + ReturnValue_t initializeHkManagerAfterTaskCreation() { + return hkManager.initializeAfterTaskCreation(); + } + + /** Command queue for housekeeping messages. */ + MessageQueueId_t getCommandQueue() const override { + return messageQueue->getId(); + } + + virtual ReturnValue_t initializeLocalDataPool( + LocalDataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) { + // Default initialization empty for now. + localDataPoolMap.emplace(lpool::uint8VarId, new PoolEntry({0})); + localDataPoolMap.emplace(lpool::floatVarId, new PoolEntry({0})); + return HasReturnvaluesIF::RETURN_OK; + } + + LocalDataPoolManager* getHkManagerHandle() override { + return &hkManager; + } + + uint32_t getPeriodicOperationFrequency() const override { + return 0; + } + + /** + * This function is used by the pool manager to get a valid dataset + * from a SID + * @param sid Corresponding structure ID + * @return + */ + virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override { + // empty for now + return nullptr; + } +private: + + lp_var_t testUint8 = lp_var_t(this, lpool::uint8VarId); + lp_var_t testFloat = lp_var_t(this, lpool::floatVarId); + + MessageQueueIF* messageQueue = nullptr; + LocalDataPoolManager hkManager; + +}; #endif /* FSFW_UNITTEST_TESTS_DATAPOOLLOCAL_LOCALPOOLOWNERBASE_H_ */ diff --git a/unittest/tests/datapoollocal/LocalPoolVariableTest.cpp b/unittest/tests/datapoollocal/LocalPoolVariableTest.cpp new file mode 100644 index 00000000..0c233193 --- /dev/null +++ b/unittest/tests/datapoollocal/LocalPoolVariableTest.cpp @@ -0,0 +1,37 @@ +#include "LocalPoolOwnerBase.h" + +#include +#include +#include + + +TEST_CASE("LocalPoolVariable" , "[LocPoolVarTest]") { + LocalPoolOwnerBase poolOwner(objects::TEST_LOCAL_POOL_OWNER_BASE); + REQUIRE(poolOwner.initializeHkManager() == retval::CATCH_OK); + REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() + == retval::CATCH_OK); + + // very basic test. + lp_var_t testVariable = lp_var_t( + objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId); + REQUIRE(testVariable.read() == retval::CATCH_OK); + CHECK(testVariable.value == 0); + testVariable.value = 5; + REQUIRE(testVariable.commit() == retval::CATCH_OK); + REQUIRE(testVariable.read() == retval::CATCH_OK); + REQUIRE(testVariable.value == 5); + + // not try to use a local pool variable which does not exist + lp_var_t invalidVariable = lp_var_t( + objects::TEST_LOCAL_POOL_OWNER_BASE, 0xffffffff); + REQUIRE(invalidVariable.read() == + static_cast(HasLocalDataPoolIF::POOL_ENTRY_NOT_FOUND)); + + // now try to access with wrong type + lp_var_t invalidVariable2 = lp_var_t( + objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId); + REQUIRE(invalidVariable2.read() == + static_cast(HasLocalDataPoolIF::POOL_ENTRY_TYPE_CONFLICT)); +} + + diff --git a/unittest/user/testcfg/objects/systemObjectList.h b/unittest/user/testcfg/objects/systemObjectList.h index 0e034aff..da95617c 100644 --- a/unittest/user/testcfg/objects/systemObjectList.h +++ b/unittest/user/testcfg/objects/systemObjectList.h @@ -9,7 +9,19 @@ namespace objects { enum sourceObjects: uint32_t { /* All addresses between start and end are reserved for the FSFW */ FSFW_CONFIG_RESERVED_START = PUS_SERVICE_1_VERIFICATION, - FSFW_CONFIG_RESERVED_END = TM_STORE + FSFW_CONFIG_RESERVED_END = TM_STORE, + + CCSDS_DISTRIBUTOR = 10, + PUS_DISTRIBUTOR = 11, + TM_FUNNEL = 12, + + UDP_BRIDGE = 15, + UDP_POLLING_TASK = 16, + + TEST_ECHO_COM_IF = 20, + TEST_DEVICE = 21, + + TEST_LOCAL_POOL_OWNER_BASE = 25 }; } From cca5689a18425627559308e87dfde34f22cc28d0 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 4 Jan 2021 15:17:11 +0100 Subject: [PATCH 31/50] clock improvements for rtems --- osal/rtems/Clock.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/osal/rtems/Clock.cpp b/osal/rtems/Clock.cpp index dda15464..8bd7ac37 100644 --- a/osal/rtems/Clock.cpp +++ b/osal/rtems/Clock.cpp @@ -37,15 +37,24 @@ ReturnValue_t Clock::setClock(const TimeOfDay_t* time) { } ReturnValue_t Clock::setClock(const timeval* time) { - //TODO This routine uses _TOD_Set which is not timespec newTime; newTime.tv_sec = time->tv_sec; + if(time->tv_usec < 0) { + // better returnvalue. + return HasReturnvaluesIF::RETURN_FAILED; + } newTime.tv_nsec = time->tv_usec * TOD_NANOSECONDS_PER_MICROSECOND; - //SHOULDDO: Not sure if we need to protect this call somehow (by thread lock or something). - //Uli: rtems docu says you can call this from an ISR, not sure if this means no protetion needed - //TODO Second parameter is ISR_lock_Context - _TOD_Set(&newTime,nullptr); - return HasReturnvaluesIF::RETURN_OK; + + ISR_lock_Context context; + _TOD_Lock(); + _TOD_Acquire(&context); + Status_Control status = _TOD_Set(&newTime, &context); + _TOD_Unlock(); + if(status == STATUS_SUCCESSFUL) { + return HasReturnvaluesIF::RETURN_OK; + } + // better returnvalue + return HasReturnvaluesIF::RETURN_FAILED; } ReturnValue_t Clock::getClock_timeval(timeval* time) { @@ -95,6 +104,7 @@ ReturnValue_t Clock::getClock_usecs(uint64_t* time) { } ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { + // TIsn't this a bug? Are RTEMS ticks always microseconds? rtems_time_of_day* timeRtems = reinterpret_cast(time); rtems_status_code status = rtems_clock_get_tod(timeRtems); switch (status) { From 3c041388d6705bccda5790ceeb5545ed9e48613d Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 4 Jan 2021 15:31:06 +0100 Subject: [PATCH 32/50] bugfix --- serviceinterface/ServiceInterfaceBuffer.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/serviceinterface/ServiceInterfaceBuffer.cpp b/serviceinterface/ServiceInterfaceBuffer.cpp index 20ea61dd..5846d233 100644 --- a/serviceinterface/ServiceInterfaceBuffer.cpp +++ b/serviceinterface/ServiceInterfaceBuffer.cpp @@ -28,18 +28,21 @@ ServiceInterfaceBuffer::ServiceInterfaceBuffer(std::string setMessage, } #if FSFW_COLORED_OUTPUT == 1 - if(setMessage.find("DEBUG")) { + if(setMessage.find("DEBUG") != std::string::npos) { colorPrefix = fsfw::ANSI_COLOR_MAGENTA; } - else if(setMessage.find("INFO")) { + else if(setMessage.find("INFO") != std::string::npos) { colorPrefix = fsfw::ANSI_COLOR_GREEN; } - else if(setMessage.find("WARNING")) { + else if(setMessage.find("WARNING") != std::string::npos) { colorPrefix = fsfw::ANSI_COLOR_YELLOW; } - else if(setMessage.find("ERROR")) { + else if(setMessage.find("ERROR") != std::string::npos) { colorPrefix = fsfw::ANSI_COLOR_RED; } + else { + colorPrefix = fsfw::ANSI_COLOR_RESET; + } #ifdef WIN32 HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); From 85764ba94c3f4edf1cbabc260cb94dd916b2d72f Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 5 Jan 2021 17:30:15 +0100 Subject: [PATCH 33/50] added include --- unittest/tests/storagemanager/TestNewAccessor.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/unittest/tests/storagemanager/TestNewAccessor.cpp b/unittest/tests/storagemanager/TestNewAccessor.cpp index 87ea00ca..10d05c6b 100644 --- a/unittest/tests/storagemanager/TestNewAccessor.cpp +++ b/unittest/tests/storagemanager/TestNewAccessor.cpp @@ -2,6 +2,7 @@ #include #include #include +#include TEST_CASE( "New Accessor" , "[NewAccessor]") { LocalPool::LocalPoolConfig poolCfg = {{1, 10}}; @@ -147,7 +148,7 @@ TEST_CASE( "New Accessor" , "[NewAccessor]") { result = resultPair.second.write(testDataArray.data(), 10, 5); REQUIRE(result == retval::CATCH_FAILED); - memset(testDataArray.data(), 42, 5); + std::memset(testDataArray.data(), 42, 5); result = resultPair.second.write(testDataArray.data(), 5, 5); REQUIRE(result == retval::CATCH_OK); resultConstPair = SimplePool.getData(testStoreId); From a05cf8d4ab54066f6cc9f6450f80f98577fad1af Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 5 Jan 2021 22:46:17 +0100 Subject: [PATCH 34/50] updated tests --- .../datapoollocal/LocalPoolVariableTest.cpp | 50 ++++++++++++------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/unittest/tests/datapoollocal/LocalPoolVariableTest.cpp b/unittest/tests/datapoollocal/LocalPoolVariableTest.cpp index 0c233193..f52ff925 100644 --- a/unittest/tests/datapoollocal/LocalPoolVariableTest.cpp +++ b/unittest/tests/datapoollocal/LocalPoolVariableTest.cpp @@ -11,27 +11,39 @@ TEST_CASE("LocalPoolVariable" , "[LocPoolVarTest]") { REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() == retval::CATCH_OK); - // very basic test. - lp_var_t testVariable = lp_var_t( - objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId); - REQUIRE(testVariable.read() == retval::CATCH_OK); - CHECK(testVariable.value == 0); - testVariable.value = 5; - REQUIRE(testVariable.commit() == retval::CATCH_OK); - REQUIRE(testVariable.read() == retval::CATCH_OK); - REQUIRE(testVariable.value == 5); + SECTION("Basic Tests") { + // very basic test. + lp_var_t testVariable = lp_var_t( + objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId); + REQUIRE(testVariable.read() == retval::CATCH_OK); + CHECK(testVariable.value == 0); + testVariable.value = 5; + REQUIRE(testVariable.commit() == retval::CATCH_OK); + REQUIRE(testVariable.read() == retval::CATCH_OK); + REQUIRE(testVariable.value == 5); - // not try to use a local pool variable which does not exist - lp_var_t invalidVariable = lp_var_t( - objects::TEST_LOCAL_POOL_OWNER_BASE, 0xffffffff); - REQUIRE(invalidVariable.read() == - static_cast(HasLocalDataPoolIF::POOL_ENTRY_NOT_FOUND)); + CHECK(not testVariable.isValid()); + + // not try to use a local pool variable which does not exist + lp_var_t invalidVariable = lp_var_t( + objects::TEST_LOCAL_POOL_OWNER_BASE, 0xffffffff); + REQUIRE(invalidVariable.read() == + static_cast(HasLocalDataPoolIF::POOL_ENTRY_NOT_FOUND)); + + // now try to access with wrong type + lp_var_t invalidVariable2 = lp_var_t( + objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId); + REQUIRE(invalidVariable2.read() == + static_cast(HasLocalDataPoolIF::POOL_ENTRY_TYPE_CONFLICT)); + + // now try to access with wrong type + lp_var_t readOnlyVar = lp_var_t( + objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId, + nullptr, pool_rwm_t::VAR_READ); + REQUIRE(readOnlyVar.commit() == + static_cast(PoolVariableIF::INVALID_READ_WRITE_MODE)); + } - // now try to access with wrong type - lp_var_t invalidVariable2 = lp_var_t( - objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId); - REQUIRE(invalidVariable2.read() == - static_cast(HasLocalDataPoolIF::POOL_ENTRY_TYPE_CONFLICT)); } From b241ef6aad5861dc570548fd17bdf856e3332984 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 5 Jan 2021 22:51:49 +0100 Subject: [PATCH 35/50] continued tests --- unittest/tests/datapoollocal/LocalPoolOwnerBase.h | 2 ++ .../tests/datapoollocal/LocalPoolVariableTest.cpp | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/unittest/tests/datapoollocal/LocalPoolOwnerBase.h b/unittest/tests/datapoollocal/LocalPoolOwnerBase.h index b73c5299..40f657be 100644 --- a/unittest/tests/datapoollocal/LocalPoolOwnerBase.h +++ b/unittest/tests/datapoollocal/LocalPoolOwnerBase.h @@ -10,6 +10,7 @@ namespace lpool { static constexpr lp_id_t uint8VarId = 0; static constexpr lp_id_t floatVarId = 1; +static constexpr lp_id_t uint32VarId = 2; } @@ -74,6 +75,7 @@ private: lp_var_t testUint8 = lp_var_t(this, lpool::uint8VarId); lp_var_t testFloat = lp_var_t(this, lpool::floatVarId); + lp_var_t testUint32 = lp_var_t(this, lpool::uint32VarId); MessageQueueIF* messageQueue = nullptr; LocalDataPoolManager hkManager; diff --git a/unittest/tests/datapoollocal/LocalPoolVariableTest.cpp b/unittest/tests/datapoollocal/LocalPoolVariableTest.cpp index f52ff925..faca03e3 100644 --- a/unittest/tests/datapoollocal/LocalPoolVariableTest.cpp +++ b/unittest/tests/datapoollocal/LocalPoolVariableTest.cpp @@ -23,6 +23,8 @@ TEST_CASE("LocalPoolVariable" , "[LocPoolVarTest]") { REQUIRE(testVariable.value == 5); CHECK(not testVariable.isValid()); + testVariable.setValid(true); + CHECK(testVariable.isValid()); // not try to use a local pool variable which does not exist lp_var_t invalidVariable = lp_var_t( @@ -36,12 +38,20 @@ TEST_CASE("LocalPoolVariable" , "[LocPoolVarTest]") { REQUIRE(invalidVariable2.read() == static_cast(HasLocalDataPoolIF::POOL_ENTRY_TYPE_CONFLICT)); - // now try to access with wrong type - lp_var_t readOnlyVar = lp_var_t( + lp_var_t readOnlyVar = lp_var_t( objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId, nullptr, pool_rwm_t::VAR_READ); REQUIRE(readOnlyVar.commit() == static_cast(PoolVariableIF::INVALID_READ_WRITE_MODE)); + lp_var_t writeOnlyVar = lp_var_t( + objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId, + nullptr, pool_rwm_t::VAR_WRITE); + REQUIRE(writeOnlyVar.read() == static_cast( + PoolVariableIF::INVALID_READ_WRITE_MODE)); + + lp_var_t uint32tVar = lp_var_t( + objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint32VarId); + sif::info << "LocalPoolVariable printout: " < Date: Wed, 6 Jan 2021 16:26:08 +0100 Subject: [PATCH 36/50] local pool variabel tweaks and fixes --- datapoollocal/LocalPoolVariable.tpp | 34 +++++++++++++++++------------ 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/datapoollocal/LocalPoolVariable.tpp b/datapoollocal/LocalPoolVariable.tpp index cd5117c8..dd6219b1 100644 --- a/datapoollocal/LocalPoolVariable.tpp +++ b/datapoollocal/LocalPoolVariable.tpp @@ -34,7 +34,7 @@ template inline ReturnValue_t LocalPoolVariable::readWithoutLock() { if(readWriteMode == pool_rwm_t::VAR_WRITE) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "LocalPoolVar: Invalid read write " + sif::warning << "LocalPoolVariable: Invalid read write " "mode for read() call." << std::endl; #endif return PoolVariableIF::INVALID_READ_WRITE_MODE; @@ -44,7 +44,7 @@ inline ReturnValue_t LocalPoolVariable::readWithoutLock() { ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry); if(result != RETURN_OK or poolEntry == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "PoolVector: Read of local pool variable of object " + sif::error << "PoolPoolVariable: Read of local pool variable of object " << std::hex << std::setw(8) << std::setfill('0') << hkManager->getOwner() << " and lp ID " << localPoolId << std::dec << " failed." << std::setfill(' ') << std::endl; @@ -67,7 +67,7 @@ template inline ReturnValue_t LocalPoolVariable::commitWithoutLock() { if(readWriteMode == pool_rwm_t::VAR_READ) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "LocalPoolVariable: Invalid read write " + sif::warning << "LocalPoolVariable: Invalid read write " "mode for commit() call." << std::endl; #endif return PoolVariableIF::INVALID_READ_WRITE_MODE; @@ -76,10 +76,10 @@ inline ReturnValue_t LocalPoolVariable::commitWithoutLock() { ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry); if(result != RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "PoolVector: Read of local pool variable of object " - "0x" << std::hex << std::setw(8) << std::setfill('0') << - hkManager->getOwner() << " and lp ID 0x" << localPoolId << - std::dec << " failed.\n" << std::flush; + sif::error << "PoolPoolVariable: Read of local pool variable of " + << "object " << std::hex << std::setw(8) << std::setfill('0') + << hkManager->getOwner() << " and lp ID " << localPoolId + << std::dec << " failed." << std::endl; #endif return result; } @@ -89,8 +89,9 @@ inline ReturnValue_t LocalPoolVariable::commitWithoutLock() { } template -inline ReturnValue_t LocalPoolVariable::serialize(uint8_t** buffer, size_t* size, - const size_t max_size, SerializeIF::Endianness streamEndianness) const { +inline ReturnValue_t LocalPoolVariable::serialize(uint8_t** buffer, + size_t* size, const size_t max_size, + SerializeIF::Endianness streamEndianness) const { return SerializeAdapter::serialize(&value, buffer, size ,max_size, streamEndianness); } @@ -121,7 +122,8 @@ inline LocalPoolVariable::operator T() const { } template -inline LocalPoolVariable & LocalPoolVariable::operator=(const T& newValue) { +inline LocalPoolVariable & LocalPoolVariable::operator=( + const T& newValue) { value = newValue; return *this; } @@ -134,7 +136,8 @@ inline LocalPoolVariable& LocalPoolVariable::operator =( } template -inline bool LocalPoolVariable::operator ==(const LocalPoolVariable &other) const { +inline bool LocalPoolVariable::operator ==( + const LocalPoolVariable &other) const { return this->value == other.value; } @@ -145,7 +148,8 @@ inline bool LocalPoolVariable::operator ==(const T &other) const { template -inline bool LocalPoolVariable::operator !=(const LocalPoolVariable &other) const { +inline bool LocalPoolVariable::operator !=( + const LocalPoolVariable &other) const { return not (*this == other); } @@ -156,7 +160,8 @@ inline bool LocalPoolVariable::operator !=(const T &other) const { template -inline bool LocalPoolVariable::operator <(const LocalPoolVariable &other) const { +inline bool LocalPoolVariable::operator <( + const LocalPoolVariable &other) const { return this->value < other.value; } @@ -167,7 +172,8 @@ inline bool LocalPoolVariable::operator <(const T &other) const { template -inline bool LocalPoolVariable::operator >(const LocalPoolVariable &other) const { +inline bool LocalPoolVariable::operator >( + const LocalPoolVariable &other) const { return not (*this < other); } From 16458f6a1e42fa75c4ca0155f22117bd0acf2b0b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 6 Jan 2021 18:20:38 +0100 Subject: [PATCH 37/50] continued tests --- datapoollocal/LocalPoolVariable.tpp | 4 ++-- datapoollocal/LocalPoolVector.tpp | 20 +++++++++---------- .../datapoollocal/LocalPoolVariableTest.cpp | 11 ++++++++++ 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/datapoollocal/LocalPoolVariable.tpp b/datapoollocal/LocalPoolVariable.tpp index dd6219b1..153a13d0 100644 --- a/datapoollocal/LocalPoolVariable.tpp +++ b/datapoollocal/LocalPoolVariable.tpp @@ -46,7 +46,7 @@ inline ReturnValue_t LocalPoolVariable::readWithoutLock() { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PoolPoolVariable: Read of local pool variable of object " << std::hex << std::setw(8) << std::setfill('0') - << hkManager->getOwner() << " and lp ID " << localPoolId + << hkManager->getOwner() << " and lp ID 0x" << localPoolId << std::dec << " failed." << std::setfill(' ') << std::endl; #endif return result; @@ -78,7 +78,7 @@ inline ReturnValue_t LocalPoolVariable::commitWithoutLock() { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PoolPoolVariable: Read of local pool variable of " << "object " << std::hex << std::setw(8) << std::setfill('0') - << hkManager->getOwner() << " and lp ID " << localPoolId + << hkManager->getOwner() << " and lp ID 0x" << localPoolId << std::dec << " failed." << std::endl; #endif return result; diff --git a/datapoollocal/LocalPoolVector.tpp b/datapoollocal/LocalPoolVector.tpp index 5c3b0ce0..a010a8bb 100644 --- a/datapoollocal/LocalPoolVector.tpp +++ b/datapoollocal/LocalPoolVector.tpp @@ -33,7 +33,7 @@ template inline ReturnValue_t LocalPoolVector::readWithoutLock() { if(readWriteMode == pool_rwm_t::VAR_WRITE) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "LocalPoolVar: Invalid read write " + sif::warning << "LocalPoolVector: Invalid read write " "mode for read() call." << std::endl; #endif return PoolVariableIF::INVALID_READ_WRITE_MODE; @@ -45,10 +45,10 @@ inline ReturnValue_t LocalPoolVector::readWithoutLock() { if(result != RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "PoolVector: Read of local pool variable of object " - "0x" << std::hex << std::setw(8) << std::setfill('0') << - hkManager->getOwner() << "and lp ID 0x" << localPoolId << - std::dec << " failed." << std::endl; + sif::error << "LocalPoolVector: Read of local pool variable of object " + << std::hex << std::setw(8) << std::setfill('0') + << hkManager->getOwner() << "and lp ID 0x" << localPoolId + << std::dec << " failed." << std::endl; #endif return result; } @@ -69,7 +69,7 @@ template inline ReturnValue_t LocalPoolVector::commitWithoutLock() { if(readWriteMode == pool_rwm_t::VAR_READ) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "LocalPoolVar: Invalid read write " + sif::warning << "LocalPoolVector: Invalid read write " "mode for commit() call." << std::endl; #endif return PoolVariableIF::INVALID_READ_WRITE_MODE; @@ -78,10 +78,10 @@ inline ReturnValue_t LocalPoolVector::commitWithoutLock() { ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry); if(result != RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "PoolVector: Read of local pool variable of object " - "0x" << std::hex << std::setw(8) << std::setfill('0') << - hkManager->getOwner() << " and lp ID 0x" << localPoolId << - std::dec << " failed.\n" << std::flush; + sif::error << "LocalPoolVector: Read of local pool variable of object " + << std::hex << std::setw(8) << std::setfill('0') + << hkManager->getOwner() << " and lp ID " << localPoolId + << std::dec << " failed." << std::endl; #endif return result; } diff --git a/unittest/tests/datapoollocal/LocalPoolVariableTest.cpp b/unittest/tests/datapoollocal/LocalPoolVariableTest.cpp index faca03e3..2a7f9863 100644 --- a/unittest/tests/datapoollocal/LocalPoolVariableTest.cpp +++ b/unittest/tests/datapoollocal/LocalPoolVariableTest.cpp @@ -26,12 +26,23 @@ TEST_CASE("LocalPoolVariable" , "[LocPoolVarTest]") { testVariable.setValid(true); CHECK(testVariable.isValid()); + gp_id_t globPoolId(objects::TEST_LOCAL_POOL_OWNER_BASE, + lpool::uint8VarId); + lp_var_t testVariable2 = lp_var_t(globPoolId); + REQUIRE(testVariable.read() == retval::CATCH_OK); + REQUIRE(testVariable == 5); + } + + SECTION("ErrorHandling") { + // not try to use a local pool variable which does not exist lp_var_t invalidVariable = lp_var_t( objects::TEST_LOCAL_POOL_OWNER_BASE, 0xffffffff); REQUIRE(invalidVariable.read() == static_cast(HasLocalDataPoolIF::POOL_ENTRY_NOT_FOUND)); + REQUIRE(invalidVariable.commit() == + static_cast(HasLocalDataPoolIF::POOL_ENTRY_NOT_FOUND)); // now try to access with wrong type lp_var_t invalidVariable2 = lp_var_t( objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId); From dc8dd770e7e9500da1ce5813a954ea5c8111ca8f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 6 Jan 2021 19:07:35 +0100 Subject: [PATCH 38/50] added more tests --- .../datapoollocal/LocalPoolVariableTest.cpp | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/unittest/tests/datapoollocal/LocalPoolVariableTest.cpp b/unittest/tests/datapoollocal/LocalPoolVariableTest.cpp index 2a7f9863..e60d5a6b 100644 --- a/unittest/tests/datapoollocal/LocalPoolVariableTest.cpp +++ b/unittest/tests/datapoollocal/LocalPoolVariableTest.cpp @@ -29,8 +29,25 @@ TEST_CASE("LocalPoolVariable" , "[LocPoolVarTest]") { gp_id_t globPoolId(objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId); lp_var_t testVariable2 = lp_var_t(globPoolId); - REQUIRE(testVariable.read() == retval::CATCH_OK); - REQUIRE(testVariable == 5); + REQUIRE(testVariable2.read() == retval::CATCH_OK); + CHECK(testVariable2 == 5); + CHECK(testVariable == testVariable2); + testVariable = 10; + CHECK(testVariable != 5); + //CHECK(not testVariable != testVariable2); + uint8_t variableRaw = 0; + uint8_t* varPtr = &variableRaw; + size_t maxSize = testVariable.getSerializedSize(); + CHECK(maxSize == 1); + size_t serSize = 0; + CHECK(testVariable.serialize(&varPtr, &serSize, maxSize, + SerializeIF::Endianness::MACHINE) == retval::CATCH_OK); + CHECK(variableRaw == 10); + const uint8_t* varConstPtr = &variableRaw; + testVariable = 5; + CHECK(testVariable.deSerialize(&varConstPtr, &serSize, + SerializeIF::Endianness::MACHINE) == retval::CATCH_OK); + CHECK(testVariable == 10); } SECTION("ErrorHandling") { From 8807772d134c04dc495627ebeef7d4f45cb31057 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 6 Jan 2021 19:16:41 +0100 Subject: [PATCH 39/50] 100 % line coverage reached --- .../tests/datapoollocal/LocalPoolVariableTest.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/unittest/tests/datapoollocal/LocalPoolVariableTest.cpp b/unittest/tests/datapoollocal/LocalPoolVariableTest.cpp index e60d5a6b..b173089c 100644 --- a/unittest/tests/datapoollocal/LocalPoolVariableTest.cpp +++ b/unittest/tests/datapoollocal/LocalPoolVariableTest.cpp @@ -48,6 +48,17 @@ TEST_CASE("LocalPoolVariable" , "[LocPoolVarTest]") { CHECK(testVariable.deSerialize(&varConstPtr, &serSize, SerializeIF::Endianness::MACHINE) == retval::CATCH_OK); CHECK(testVariable == 10); + CHECK(testVariable != testVariable2); + CHECK(testVariable2 < testVariable); + CHECK(testVariable2 < 10); + CHECK(testVariable > 5); + CHECK(testVariable > testVariable2); + variableRaw = static_cast(testVariable2); + CHECK(variableRaw == 5); + + CHECK(testVariable == 10); + testVariable = testVariable2; + CHECK(testVariable == 5); } SECTION("ErrorHandling") { From db7d28f8526c7a6998f712b5ed4f904f757f011a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 6 Jan 2021 19:32:33 +0100 Subject: [PATCH 40/50] test update --- datapoollocal/LocalPoolVariable.h | 1 + datapoollocal/LocalPoolVariable.tpp | 21 +++- unittest/internal/UnittDefinitions.h | 1 + unittest/tests/action/TestActionHelper.cpp | 2 + .../datapoollocal/LocalPoolVariableTest.cpp | 2 + unittest/user/CMakeLists.txt | 108 ++++++++++++++++-- unittest/user/unittest/core/CMakeLists.txt | 6 + .../user/unittest/core/CatchDefinitions.cpp | 3 + unittest/user/unittest/core/CatchFactory.cpp | 22 +++- unittest/user/unittest/core/CatchRunner.cpp | 13 +-- unittest/user/unittest/core/CatchSetup.cpp | 14 +-- unittest/user/unittest/core/printChar.cpp | 2 +- 12 files changed, 164 insertions(+), 31 deletions(-) diff --git a/datapoollocal/LocalPoolVariable.h b/datapoollocal/LocalPoolVariable.h index 84be54b1..21ee2764 100644 --- a/datapoollocal/LocalPoolVariable.h +++ b/datapoollocal/LocalPoolVariable.h @@ -7,6 +7,7 @@ #include "../datapool/PoolVariableIF.h" #include "../datapool/DataSetIF.h" +#include "../serviceinterface/ServiceInterface.h" #include "../objectmanager/ObjectManagerIF.h" #include "../serialize/SerializeAdapter.h" diff --git a/datapoollocal/LocalPoolVariable.tpp b/datapoollocal/LocalPoolVariable.tpp index 153a13d0..f35c8be2 100644 --- a/datapoollocal/LocalPoolVariable.tpp +++ b/datapoollocal/LocalPoolVariable.tpp @@ -35,8 +35,11 @@ inline ReturnValue_t LocalPoolVariable::readWithoutLock() { if(readWriteMode == pool_rwm_t::VAR_WRITE) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "LocalPoolVariable: Invalid read write " - "mode for read() call." << std::endl; -#endif + "mode for read call." << std::endl; +#else + fsfw::printWarning("LocalPoolVariable: Invalid read write " + "mode for read call."); +#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ return PoolVariableIF::INVALID_READ_WRITE_MODE; } @@ -48,7 +51,11 @@ inline ReturnValue_t LocalPoolVariable::readWithoutLock() { << std::hex << std::setw(8) << std::setfill('0') << hkManager->getOwner() << " and lp ID 0x" << localPoolId << std::dec << " failed." << std::setfill(' ') << std::endl; -#endif +#else + fsfw::printError("LocalPoolVariable: Read of local pool variable of " + "object 0x%08x and lp ID 0x08x failed.", hkManager->getOwner(), + localPoolId); +#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ return result; } this->value = *(poolEntry->address); @@ -69,7 +76,7 @@ inline ReturnValue_t LocalPoolVariable::commitWithoutLock() { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "LocalPoolVariable: Invalid read write " "mode for commit() call." << std::endl; -#endif +#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ return PoolVariableIF::INVALID_READ_WRITE_MODE; } PoolEntry* poolEntry = nullptr; @@ -80,7 +87,11 @@ inline ReturnValue_t LocalPoolVariable::commitWithoutLock() { << "object " << std::hex << std::setw(8) << std::setfill('0') << hkManager->getOwner() << " and lp ID 0x" << localPoolId << std::dec << " failed." << std::endl; -#endif +#else + fsfw::printError("LocalPoolVariable: Read of local pool variable of " + "object 0x%08x and lp ID 0x08x failed.", hkManager->getOwner(), + localPoolId); +#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ return result; } *(poolEntry->address) = this->value; diff --git a/unittest/internal/UnittDefinitions.h b/unittest/internal/UnittDefinitions.h index ea36fea4..d319f4bc 100644 --- a/unittest/internal/UnittDefinitions.h +++ b/unittest/internal/UnittDefinitions.h @@ -5,6 +5,7 @@ #include "../../serviceinterface/ServiceInterfaceStream.h" #include #include +#include namespace tv { // POD test values diff --git a/unittest/tests/action/TestActionHelper.cpp b/unittest/tests/action/TestActionHelper.cpp index 3109eba1..3957bba2 100644 --- a/unittest/tests/action/TestActionHelper.cpp +++ b/unittest/tests/action/TestActionHelper.cpp @@ -7,6 +7,8 @@ #include +#include + TEST_CASE( "Action Helper" , "[ActionHelper]") { ActionHelperOwnerMockBase testDhMock; diff --git a/unittest/tests/datapoollocal/LocalPoolVariableTest.cpp b/unittest/tests/datapoollocal/LocalPoolVariableTest.cpp index b173089c..cf4f4b6b 100644 --- a/unittest/tests/datapoollocal/LocalPoolVariableTest.cpp +++ b/unittest/tests/datapoollocal/LocalPoolVariableTest.cpp @@ -90,7 +90,9 @@ TEST_CASE("LocalPoolVariable" , "[LocPoolVarTest]") { lp_var_t uint32tVar = lp_var_t( objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint32VarId); +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "LocalPoolVariable printout: " < #include StorageManagerIF* tglob::getIpcStoreHandle() { @@ -7,6 +8,8 @@ StorageManagerIF* tglob::getIpcStoreHandle() { } else { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Global object manager uninitialized" << std::endl; +#else + fsfw::printError("Global object manager uninitialized"); #endif return nullptr; } diff --git a/unittest/user/unittest/core/CatchFactory.cpp b/unittest/user/unittest/core/CatchFactory.cpp index 3177212f..0597f08c 100644 --- a/unittest/user/unittest/core/CatchFactory.cpp +++ b/unittest/user/unittest/core/CatchFactory.cpp @@ -1,11 +1,15 @@ +#include +#include #include "CatchFactory.h" #include #include - #include #include #include +#include +#include +#include /** * @brief Produces system objects. @@ -50,7 +54,23 @@ void Factory::produce(void) { } void Factory::setStaticFrameworkObjectIds() { + PusServiceBase::packetSource = objects::NO_OBJECT; + PusServiceBase::packetDestination = objects::NO_OBJECT; + CommandingServiceBase::defaultPacketSource = objects::NO_OBJECT; + CommandingServiceBase::defaultPacketDestination = objects::NO_OBJECT; + + VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; + + DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT; + DeviceHandlerBase::rawDataReceiverId = objects::PUS_SERVICE_2_DEVICE_ACCESS; + + LocalDataPoolManager::defaultHkDestination = objects::NO_OBJECT; + + DeviceHandlerFailureIsolation::powerConfirmationId = objects::NO_OBJECT; + + TmPacketStored::timeStamperId = objects::NO_OBJECT; } + diff --git a/unittest/user/unittest/core/CatchRunner.cpp b/unittest/user/unittest/core/CatchRunner.cpp index 35c53cd4..886d641f 100644 --- a/unittest/user/unittest/core/CatchRunner.cpp +++ b/unittest/user/unittest/core/CatchRunner.cpp @@ -1,17 +1,16 @@ /** - * @file CatchSource.cpp + * @file CatchRunner.cpp * @brief Source file to compile catch framework. * @details All tests should be written in other files. * For eclipse console output, install ANSI Escape in Console * from the eclipse market place to get colored characters. */ -#ifndef NO_UNIT_TEST_FRAMEWORK +#include -#define CATCH_CONFIG_RUNNER -#include +#define CATCH_CONFIG_COLOUR_WINDOWS -#if CUSTOM_UNITTEST_RUNNER == 0 +#include extern int customSetup(); @@ -25,7 +24,3 @@ int main( int argc, char* argv[] ) { return result; } -#endif - - -#endif diff --git a/unittest/user/unittest/core/CatchSetup.cpp b/unittest/user/unittest/core/CatchSetup.cpp index c93cf032..bda31400 100644 --- a/unittest/user/unittest/core/CatchSetup.cpp +++ b/unittest/user/unittest/core/CatchSetup.cpp @@ -1,21 +1,20 @@ -#include +#include "CatchFactory.h" #include "CatchDefinitions.h" -#include #ifdef GCOV #include #endif -#include "../../objectmanager/ObjectManager.h" -#include "../../objectmanager/ObjectManagerIF.h" -#include "../../storagemanager/StorageManagerIF.h" -#include "../../serviceinterface/ServiceInterfaceStream.h" +#include +#include +#include +#include /* Global instantiations normally done in main.cpp */ /* Initialize Data Pool */ - +#if FSFW_CPP_OSTREAM_ENABLED == 1 namespace sif { /* Set up output streams */ ServiceInterfaceStream debug("DEBUG"); @@ -23,6 +22,7 @@ ServiceInterfaceStream info("INFO"); ServiceInterfaceStream error("ERROR"); ServiceInterfaceStream warning("WARNING"); } +#endif /* Global object manager */ ObjectManagerIF *objectManager; diff --git a/unittest/user/unittest/core/printChar.cpp b/unittest/user/unittest/core/printChar.cpp index 755a13b2..5d4f1b17 100644 --- a/unittest/user/unittest/core/printChar.cpp +++ b/unittest/user/unittest/core/printChar.cpp @@ -1,4 +1,4 @@ -#include +#include "printChar.h" #include void printChar(const char* character, bool errStream) { From 91cf5f176400a12c18e66ef53bf7efe1fab9265f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 6 Jan 2021 19:49:58 +0100 Subject: [PATCH 41/50] added way to completely disable printouts --- datapoollocal/LocalPoolVariable.tpp | 15 +++++---- serviceinterface/ServiceInterfacePrinter.cpp | 32 ++++++++++++++------ serviceinterface/ServiceInterfacePrinter.h | 2 ++ unittest/internal/UnittDefinitions.cpp | 6 ++-- unittest/internal/UnittDefinitions.h | 2 +- 5 files changed, 38 insertions(+), 19 deletions(-) diff --git a/datapoollocal/LocalPoolVariable.tpp b/datapoollocal/LocalPoolVariable.tpp index f35c8be2..f70e4e91 100644 --- a/datapoollocal/LocalPoolVariable.tpp +++ b/datapoollocal/LocalPoolVariable.tpp @@ -38,7 +38,7 @@ inline ReturnValue_t LocalPoolVariable::readWithoutLock() { "mode for read call." << std::endl; #else fsfw::printWarning("LocalPoolVariable: Invalid read write " - "mode for read call."); + "mode for read call.\n\r"); #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ return PoolVariableIF::INVALID_READ_WRITE_MODE; } @@ -53,8 +53,8 @@ inline ReturnValue_t LocalPoolVariable::readWithoutLock() { << std::dec << " failed." << std::setfill(' ') << std::endl; #else fsfw::printError("LocalPoolVariable: Read of local pool variable of " - "object 0x%08x and lp ID 0x08x failed.", hkManager->getOwner(), - localPoolId); + "object 0x%08x and lp ID 0x%08x failed.\n\r", + hkManager->getOwner(), localPoolId); #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ return result; } @@ -75,7 +75,10 @@ inline ReturnValue_t LocalPoolVariable::commitWithoutLock() { if(readWriteMode == pool_rwm_t::VAR_READ) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "LocalPoolVariable: Invalid read write " - "mode for commit() call." << std::endl; + "mode for commit call." << std::endl; +#else + fsfw::printWarning("LocalPoolVariable: Invalid read write " + "mode for commit call.\n\r"); #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ return PoolVariableIF::INVALID_READ_WRITE_MODE; } @@ -89,8 +92,8 @@ inline ReturnValue_t LocalPoolVariable::commitWithoutLock() { << std::dec << " failed." << std::endl; #else fsfw::printError("LocalPoolVariable: Read of local pool variable of " - "object 0x%08x and lp ID 0x08x failed.", hkManager->getOwner(), - localPoolId); + "object 0x%08x and lp ID 0x%08x failed.\n\r", + hkManager->getOwner(), localPoolId); #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ return result; } diff --git a/serviceinterface/ServiceInterfacePrinter.cpp b/serviceinterface/ServiceInterfacePrinter.cpp index e8eb498f..15e738a8 100644 --- a/serviceinterface/ServiceInterfacePrinter.cpp +++ b/serviceinterface/ServiceInterfacePrinter.cpp @@ -6,12 +6,14 @@ #include #include - fsfw::PrintLevel printLevel = fsfw::PrintLevel::DEBUG; -uint8_t printBuffer[fsfwconfig::FSFW_PRINT_BUFFER_SIZE]; #if defined(WIN32) && FSFW_COLORED_OUTPUT == 1 bool consoleInitialized = false; -#endif +#endif /* defined(WIN32) && FSFW_COLORED_OUTPUT == 1 */ + + +#if FSFW_DISABLE_PRINTOUT == 0 +uint8_t printBuffer[fsfwconfig::FSFW_PRINT_BUFFER_SIZE]; void fsfwPrint(fsfw::PrintLevel printType, const char* fmt, va_list arg) { @@ -81,13 +83,6 @@ void fsfwPrint(fsfw::PrintLevel printType, const char* fmt, va_list arg) { printf("%s", printBuffer); } -void fsfw::setPrintLevel(PrintLevel printLevel_) { - printLevel = printLevel_; -} - -fsfw::PrintLevel fsfw::getPrintLevel() { - return printLevel; -} void fsfw::printInfo(const char *fmt, ...) { va_list args; @@ -116,3 +111,20 @@ void fsfw::printError(const char *fmt, ...) { fsfwPrint(fsfw::PrintLevel::ERROR_TYPE, fmt, args); va_end(args); } + +#else + +void fsfw::printInfo(const char *fmt, ...) {} +void fsfw::printWarning(const char *fmt, ...) {} +void fsfw::printDebug(const char *fmt, ...) {} +void fsfw::printError(const char *fmt, ...) {} + +#endif /* FSFW_DISABLE_PRINTOUT == 0 */ + +void fsfw::setPrintLevel(PrintLevel printLevel_) { + printLevel = printLevel_; +} + +fsfw::PrintLevel fsfw::getPrintLevel() { + return printLevel; +} diff --git a/serviceinterface/ServiceInterfacePrinter.h b/serviceinterface/ServiceInterfacePrinter.h index 8b81ee7a..a60b6332 100644 --- a/serviceinterface/ServiceInterfacePrinter.h +++ b/serviceinterface/ServiceInterfacePrinter.h @@ -1,4 +1,6 @@ +#if FSFW_DISABLE_PRINTOUT == 0 #include +#endif namespace fsfw { diff --git a/unittest/internal/UnittDefinitions.cpp b/unittest/internal/UnittDefinitions.cpp index 7138e6c6..d20771a4 100644 --- a/unittest/internal/UnittDefinitions.cpp +++ b/unittest/internal/UnittDefinitions.cpp @@ -3,7 +3,9 @@ ReturnValue_t unitt::put_error(std::string errorId) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Unit Tester error: Failed at test ID " - << errorId << "\n" << std::flush; -#endif + << errorId << std::endl; +#else + fsfw::printError("Unit Tester error: Failed at test ID 0x%08x", errorId); +#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ return HasReturnvaluesIF::RETURN_FAILED; } diff --git a/unittest/internal/UnittDefinitions.h b/unittest/internal/UnittDefinitions.h index d319f4bc..3e14fec5 100644 --- a/unittest/internal/UnittDefinitions.h +++ b/unittest/internal/UnittDefinitions.h @@ -2,7 +2,7 @@ #define UNITTEST_INTERNAL_UNITTDEFINITIONS_H_ #include "../../returnvalues/HasReturnvaluesIF.h" -#include "../../serviceinterface/ServiceInterfaceStream.h" +#include "../../serviceinterface/ServiceInterface.h" #include #include #include From dacdfc62d3841a89be5aa4988e35784737027dd1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 6 Jan 2021 21:14:23 +0100 Subject: [PATCH 42/50] a lot of bugfixes and important api change --- datapool/PoolDataSetBase.cpp | 34 ++++++---- datapool/PoolDataSetBase.h | 23 ++++--- datapool/PoolDataSetIF.h | 5 +- datapool/PoolEntry.cpp | 2 + datapool/ReadCommitIF.h | 11 ++-- datapoollocal/LocalPoolDataSetBase.cpp | 65 +++++++++++++++---- datapoollocal/LocalPoolDataSetBase.h | 21 +++++- datapoollocal/LocalPoolVariable.h | 19 +++++- datapoollocal/LocalPoolVariable.tpp | 19 ++++-- datapoollocal/LocalPoolVector.h | 14 ++-- datapoollocal/LocalPoolVector.tpp | 13 ++-- devicehandlers/DeviceHandlerBase.cpp | 3 +- events/EventManager.cpp | 8 ++- events/EventManager.h | 4 ++ internalError/InternalErrorReporter.cpp | 29 +++++---- internalError/InternalErrorReporter.h | 8 ++- ipc/MutexIF.h | 2 +- osal/host/Clock.cpp | 4 +- osal/host/Mutex.cpp | 6 +- power/Fuse.cpp | 7 +- power/PowerSensor.cpp | 3 +- unittest/internal/osal/IntTestMutex.cpp | 2 +- unittest/tests/datapoollocal/DataSetTest.cpp | 21 ++++++ .../tests/datapoollocal/LocalPoolOwnerBase.h | 39 +++++++++-- .../datapoollocal/LocalPoolVariableTest.cpp | 29 ++++++++- .../datapoollocal/LocalPoolVectorTest.cpp | 16 +++++ 26 files changed, 314 insertions(+), 93 deletions(-) create mode 100644 unittest/tests/datapoollocal/DataSetTest.cpp create mode 100644 unittest/tests/datapoollocal/LocalPoolVectorTest.cpp diff --git a/datapool/PoolDataSetBase.cpp b/datapool/PoolDataSetBase.cpp index 5fb1c3c7..05797012 100644 --- a/datapool/PoolDataSetBase.cpp +++ b/datapool/PoolDataSetBase.cpp @@ -38,11 +38,12 @@ ReturnValue_t PoolDataSetBase::registerVariable( return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t PoolDataSetBase::read(uint32_t lockTimeout) { +ReturnValue_t PoolDataSetBase::read(MutexIF::TimeoutType timeoutType, + uint32_t lockTimeout) { ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; ReturnValue_t error = result; if (state == States::STATE_SET_UNINITIALISED) { - lockDataPool(lockTimeout); + lockDataPool(timeoutType, lockTimeout); for (uint16_t count = 0; count < fillCount; count++) { result = readVariable(count); if(result != RETURN_OK) { @@ -86,7 +87,8 @@ ReturnValue_t PoolDataSetBase::readVariable(uint16_t count) { != PoolVariableIF::NO_PARAMETER) { if(protectEveryReadCommitCall) { - result = registeredVariables[count]->read(mutexTimeout); + result = registeredVariables[count]->read( + MutexIF::TimeoutType::WAITING, mutexTimeout); } else { result = registeredVariables[count]->readWithoutLock(); @@ -99,25 +101,28 @@ ReturnValue_t PoolDataSetBase::readVariable(uint16_t count) { return result; } -ReturnValue_t PoolDataSetBase::commit(uint32_t lockTimeout) { +ReturnValue_t PoolDataSetBase::commit(MutexIF::TimeoutType timeoutType, + uint32_t lockTimeout) { if (state == States::STATE_SET_WAS_READ) { - handleAlreadyReadDatasetCommit(lockTimeout); + handleAlreadyReadDatasetCommit(timeoutType, lockTimeout); return HasReturnvaluesIF::RETURN_OK; } else { - return handleUnreadDatasetCommit(lockTimeout); + return handleUnreadDatasetCommit(timeoutType, lockTimeout); } } -void PoolDataSetBase::handleAlreadyReadDatasetCommit(uint32_t lockTimeout) { - lockDataPool(lockTimeout); +void PoolDataSetBase::handleAlreadyReadDatasetCommit( + MutexIF::TimeoutType timeoutType, uint32_t lockTimeout) { + lockDataPool(timeoutType, lockTimeout); for (uint16_t count = 0; count < fillCount; count++) { if (registeredVariables[count]->getReadWriteMode() != PoolVariableIF::VAR_READ && registeredVariables[count]->getDataPoolId() != PoolVariableIF::NO_PARAMETER) { if(protectEveryReadCommitCall) { - registeredVariables[count]->commit(mutexTimeout); + registeredVariables[count]->commit( + MutexIF::TimeoutType::WAITING, mutexTimeout); } else { registeredVariables[count]->commitWithoutLock(); @@ -128,16 +133,18 @@ void PoolDataSetBase::handleAlreadyReadDatasetCommit(uint32_t lockTimeout) { unlockDataPool(); } -ReturnValue_t PoolDataSetBase::handleUnreadDatasetCommit(uint32_t lockTimeout) { +ReturnValue_t PoolDataSetBase::handleUnreadDatasetCommit( + MutexIF::TimeoutType timeoutType, uint32_t lockTimeout) { ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - lockDataPool(lockTimeout); + lockDataPool(timeoutType, lockTimeout); for (uint16_t count = 0; count < fillCount; count++) { if (registeredVariables[count]->getReadWriteMode() == PoolVariableIF::VAR_WRITE && registeredVariables[count]->getDataPoolId() != PoolVariableIF::NO_PARAMETER) { if(protectEveryReadCommitCall) { - result = registeredVariables[count]->commit(mutexTimeout); + result = registeredVariables[count]->commit( + MutexIF::TimeoutType::WAITING, mutexTimeout); } else { result = registeredVariables[count]->commitWithoutLock(); @@ -160,7 +167,8 @@ ReturnValue_t PoolDataSetBase::handleUnreadDatasetCommit(uint32_t lockTimeout) { } -ReturnValue_t PoolDataSetBase::lockDataPool(uint32_t timeoutMs) { +ReturnValue_t PoolDataSetBase::lockDataPool(MutexIF::TimeoutType timeoutType, + uint32_t lockTimeout) { return HasReturnvaluesIF::RETURN_OK; } diff --git a/datapool/PoolDataSetBase.h b/datapool/PoolDataSetBase.h index 7c1d84a4..0528f40f 100644 --- a/datapool/PoolDataSetBase.h +++ b/datapool/PoolDataSetBase.h @@ -62,8 +62,9 @@ public: * - @c SET_WAS_ALREADY_READ if read() is called twice without calling * commit() in between */ - virtual ReturnValue_t read(uint32_t lockTimeout = - MutexIF::BLOCKING) override; + virtual ReturnValue_t read( + MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING, + uint32_t lockTimeout = 20) override; /** * @brief The commit call initializes writing back the registered variables. * @details @@ -82,8 +83,9 @@ public: * - @c COMMITING_WITHOUT_READING if set was not read yet and * contains non write-only variables */ - virtual ReturnValue_t commit(uint32_t lockTimeout = - MutexIF::BLOCKING) override; + virtual ReturnValue_t commit( + MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING, + uint32_t lockTimeout = 20) override; /** * Register the passed pool variable instance into the data set. @@ -97,8 +99,9 @@ public: * thread-safety. Default implementation is empty * @return Always returns -@c RETURN_OK */ - virtual ReturnValue_t lockDataPool(uint32_t timeoutMs = - MutexIF::BLOCKING) override; + virtual ReturnValue_t lockDataPool( + MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING, + uint32_t timeoutMs = 20) override; /** * Provides the means to unlock the underlying data structure to ensure * thread-safety. Default implementation is empty @@ -160,8 +163,12 @@ private: uint32_t mutexTimeout = 20; ReturnValue_t readVariable(uint16_t count); - void handleAlreadyReadDatasetCommit(uint32_t lockTimeout); - ReturnValue_t handleUnreadDatasetCommit(uint32_t lockTimeout); + void handleAlreadyReadDatasetCommit( + MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING, + uint32_t timeoutMs = 20); + ReturnValue_t handleUnreadDatasetCommit( + MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING, + uint32_t timeoutMs = 20); }; #endif /* FSFW_DATAPOOL_POOLDATASETBASE_H_ */ diff --git a/datapool/PoolDataSetIF.h b/datapool/PoolDataSetIF.h index 99c06cfd..1f52871d 100644 --- a/datapool/PoolDataSetIF.h +++ b/datapool/PoolDataSetIF.h @@ -18,7 +18,10 @@ public: * thread-safety * @return Lock operation result */ - virtual ReturnValue_t lockDataPool(dur_millis_t timeoutMs) = 0; + virtual ReturnValue_t lockDataPool( + MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING, + uint32_t timeoutMs = 20) = 0; + /** * @brief Unlock call corresponding to the lock call. * @return Unlock operation result diff --git a/datapool/PoolEntry.cpp b/datapool/PoolEntry.cpp index 58375162..5f5f56f2 100644 --- a/datapool/PoolEntry.cpp +++ b/datapool/PoolEntry.cpp @@ -88,8 +88,10 @@ Type PoolEntry::getType() { template class PoolEntry; template class PoolEntry; template class PoolEntry; +template class PoolEntry; template class PoolEntry; template class PoolEntry; template class PoolEntry; +template class PoolEntry; template class PoolEntry; template class PoolEntry; diff --git a/datapool/ReadCommitIF.h b/datapool/ReadCommitIF.h index 0cdce371..efe51594 100644 --- a/datapool/ReadCommitIF.h +++ b/datapool/ReadCommitIF.h @@ -2,6 +2,7 @@ #define FSFW_DATAPOOL_READCOMMITIF_H_ #include +#include /** * @brief Common interface for all software objects which employ read-commit @@ -10,8 +11,10 @@ class ReadCommitIF { public: virtual ~ReadCommitIF() {} - virtual ReturnValue_t read(uint32_t mutexTimeout) = 0; - virtual ReturnValue_t commit(uint32_t mutexTimeout) = 0; + virtual ReturnValue_t read(MutexIF::TimeoutType timeoutType, + uint32_t timeoutMs) = 0; + virtual ReturnValue_t commit(MutexIF::TimeoutType timeoutType, + uint32_t timeoutMs) = 0; protected: @@ -19,11 +22,11 @@ protected: //! members with commit and read semantics where the lock is only necessary //! once. virtual ReturnValue_t readWithoutLock() { - return read(20); + return read(MutexIF::TimeoutType::WAITING, 20); } virtual ReturnValue_t commitWithoutLock() { - return commit(20); + return commit(MutexIF::TimeoutType::WAITING, 20); } }; diff --git a/datapoollocal/LocalPoolDataSetBase.cpp b/datapoollocal/LocalPoolDataSetBase.cpp index dbe34dfd..af492146 100644 --- a/datapoollocal/LocalPoolDataSetBase.cpp +++ b/datapoollocal/LocalPoolDataSetBase.cpp @@ -1,4 +1,6 @@ #include "LocalPoolDataSetBase.h" + +#include "../serviceinterface/ServiceInterface.h" #include "../datapoollocal/LocalDataPoolManager.h" #include "../housekeeping/PeriodicHousekeepingHelper.h" #include "../serialize/SerializeAdapter.h" @@ -15,7 +17,10 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner, #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "LocalPoolDataSetBase::LocalPoolDataSetBase: Owner " << "invalid!" << std::endl; -#endif +#else + fsfw::printError("LocalPoolDataSetBase::LocalPoolDataSetBase: Owner " + "invalid!\n\r"); +#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ return; } hkManager = hkOwner->getHkManagerHandle(); @@ -44,13 +49,26 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(sid_t sid, mutex = MutexFactory::instance()->createMutex(); } +LocalPoolDataSetBase::LocalPoolDataSetBase( + PoolVariableIF **registeredVariablesArray, + const size_t maxNumberOfVariables, bool protectFunctions): + PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) { + if(protectFunctions) { + mutex = MutexFactory::instance()->createMutex(); + } + +} + + LocalPoolDataSetBase::~LocalPoolDataSetBase() { } -ReturnValue_t LocalPoolDataSetBase::lockDataPool(uint32_t timeoutMs) { +ReturnValue_t LocalPoolDataSetBase::lockDataPool( + MutexIF::TimeoutType timeoutType, + uint32_t timeoutMs) { if(hkManager != nullptr) { - MutexIF* mutex = hkManager->getMutexHandle(); - return mutex->lockMutex(MutexIF::TimeoutType::WAITING, timeoutMs); + MutexIF* poolMutex = hkManager->getMutexHandle(); + return poolMutex->lockMutex(timeoutType, timeoutMs); } return HasReturnvaluesIF::RETURN_OK; } @@ -150,9 +168,12 @@ ReturnValue_t LocalPoolDataSetBase::serializeLocalPoolIds(uint8_t** buffer, size, maxSize, streamEndianness); if(result != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "LocalDataSet::serializeLocalPoolIds: Serialization" - " error!" << std::endl; -#endif + sif::warning << "LocalPoolDataSetBase::serializeLocalPoolIds: " + << "Serialization error!" << std::endl; +#else + fsfw::printWarning("LocalPoolDataSetBase::serializeLocalPoolIds: " + "Serialization error!\n\r"); +#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ return result; } } @@ -211,8 +232,11 @@ ReturnValue_t LocalPoolDataSetBase::serialize(uint8_t **buffer, size_t *size, void LocalPoolDataSetBase::bitSetter(uint8_t* byte, uint8_t position) const { if(position > 7) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "Pool Raw Access: Bit setting invalid position" + sif::warning << "LocalPoolDataSetBase::bitSetter: Invalid position!" << std::endl; +#else + fsfw::printWarning("LocalPoolDataSetBase::bitSetter: " + "Invalid position!\n\r"); #endif return; } @@ -244,14 +268,19 @@ void LocalPoolDataSetBase::initializePeriodicHelper( } void LocalPoolDataSetBase::setChanged(bool changed) { - // TODO: Make this configurable? - MutexHelper(mutex, MutexIF::TimeoutType::WAITING, 20); + if(mutex == nullptr) { + this->changed = changed; + return; + } + MutexHelper(mutex, MutexIF::TimeoutType::WAITING, mutexTimeout); this->changed = changed; } bool LocalPoolDataSetBase::hasChanged() const { - // TODO: Make this configurable? - MutexHelper(mutex, MutexIF::TimeoutType::WAITING, 20); + if(mutex == nullptr) { + return changed; + } + MutexHelper(mutex, MutexIF::TimeoutType::WAITING, mutexTimeout); return changed; } @@ -273,18 +302,22 @@ bool LocalPoolDataSetBase::bitGetter(const uint8_t* byte, } bool LocalPoolDataSetBase::isValid() const { + if(mutex == nullptr) { + return this->valid; + } MutexHelper(mutex, MutexIF::TimeoutType::WAITING, 5); return this->valid; } void LocalPoolDataSetBase::setValidity(bool valid, bool setEntriesRecursively) { - MutexHelper(mutex, MutexIF::TimeoutType::WAITING, 5); + mutex->lockMutex(timeoutType, mutexTimeout); if(setEntriesRecursively) { for(size_t idx = 0; idx < this->getFillCount(); idx++) { registeredVariables[idx] -> setValid(valid); } } this->valid = valid; + mutex->unlockMutex(); } void LocalPoolDataSetBase::setReadCommitProtectionBehaviour( @@ -292,3 +325,9 @@ void LocalPoolDataSetBase::setReadCommitProtectionBehaviour( PoolDataSetBase::setReadCommitProtectionBehaviour(protectEveryReadCommit, mutexTimeout); } + +void LocalPoolDataSetBase::setDataSetMutexTimeout( + MutexIF::TimeoutType timeoutType, uint32_t mutexTimeout) { + this->timeoutType = timeoutType; + this->mutexTimeout = mutexTimeout; +} diff --git a/datapoollocal/LocalPoolDataSetBase.h b/datapoollocal/LocalPoolDataSetBase.h index d9b6a221..b44f607f 100644 --- a/datapoollocal/LocalPoolDataSetBase.h +++ b/datapoollocal/LocalPoolDataSetBase.h @@ -67,6 +67,15 @@ public: LocalPoolDataSetBase(sid_t sid, PoolVariableIF** registeredVariablesArray, const size_t maxNumberOfVariables); + /** + * Simple constructor, if the dataset is not owner permanently by + * a class with a HK manager. + * @param registeredVariablesArray + * @param maxNumberOfVariables + */ + LocalPoolDataSetBase(PoolVariableIF** registeredVariablesArray, + const size_t maxNumberOfVariables, bool protectFunctions = true); + /** * @brief The destructor automatically manages writing the valid * information of variables. @@ -87,6 +96,9 @@ public: void setReadCommitProtectionBehaviour(bool protectEveryReadCommit, uint32_t mutexTimeout = 20); + void setDataSetMutexTimeout(MutexIF::TimeoutType timeoutType, + uint32_t mutexTimeout); + void setValidityBufferGeneration(bool withValidityBuffer); sid_t getSid() const; @@ -138,7 +150,12 @@ public: protected: sid_t sid; + MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; uint32_t mutexTimeout = 20; + /** + * This mutex is required because the dataset can potentially be accessed + * by multiple threads for information like change status or validity. + */ MutexIF* mutex = nullptr; bool diagnostic = false; @@ -183,7 +200,9 @@ protected: * @details * It makes use of the lockDataPool method offered by the DataPool class. */ - ReturnValue_t lockDataPool(uint32_t timeoutMs) override; + ReturnValue_t lockDataPool(MutexIF::TimeoutType timeoutType, + uint32_t timeoutMs) override; + /** * @brief This is a small helper function to facilitate * unlocking the global data pool diff --git a/datapoollocal/LocalPoolVariable.h b/datapoollocal/LocalPoolVariable.h index 21ee2764..c81967a1 100644 --- a/datapoollocal/LocalPoolVariable.h +++ b/datapoollocal/LocalPoolVariable.h @@ -106,7 +106,9 @@ public: * at once to avoid the overhead of unnecessary lock und unlock operations. * */ - ReturnValue_t read(dur_millis_t lockTimeout = MutexIF::BLOCKING) override; + ReturnValue_t read(MutexIF::TimeoutType timeoutType = + MutexIF::TimeoutType::WAITING, + uint32_t timeoutMs = 20) override; /** * @brief The commit call copies the array values back to the data pool. * @details @@ -116,8 +118,21 @@ public: * It is recommended to use DataSets to read and commit multiple variables * at once to avoid the overhead of unnecessary lock und unlock operations. */ - ReturnValue_t commit(dur_millis_t lockTimeout = MutexIF::BLOCKING) override; + ReturnValue_t commit(MutexIF::TimeoutType timeoutType = + MutexIF::TimeoutType::WAITING, + uint32_t timeoutMs = 20) override; + /** + * @brief This commit function can be used to set the pool variable valid + * as well. + * @param setValid + * @param timeoutType + * @param timeoutMs + * @return + */ + ReturnValue_t commit(bool setValid, MutexIF::TimeoutType timeoutType = + MutexIF::TimeoutType::WAITING, + uint32_t timeoutMs = 20); LocalPoolVariable &operator=(const T& newValue); LocalPoolVariable &operator=(const LocalPoolVariable& newPoolVariable); diff --git a/datapoollocal/LocalPoolVariable.tpp b/datapoollocal/LocalPoolVariable.tpp index f70e4e91..9387acc5 100644 --- a/datapoollocal/LocalPoolVariable.tpp +++ b/datapoollocal/LocalPoolVariable.tpp @@ -24,9 +24,9 @@ inline LocalPoolVariable::LocalPoolVariable(gp_id_t globalPoolId, template -inline ReturnValue_t LocalPoolVariable::read(dur_millis_t lockTimeout) { - MutexHelper(hkManager->getMutexHandle(), MutexIF::TimeoutType::WAITING, - lockTimeout); +inline ReturnValue_t LocalPoolVariable::read( + MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) { + MutexHelper(hkManager->getMutexHandle(), timeoutType, timeoutMs); return readWithoutLock(); } @@ -64,9 +64,16 @@ inline ReturnValue_t LocalPoolVariable::readWithoutLock() { } template -inline ReturnValue_t LocalPoolVariable::commit(dur_millis_t lockTimeout) { - MutexHelper(hkManager->getMutexHandle(), MutexIF::TimeoutType::WAITING, - lockTimeout); +inline ReturnValue_t LocalPoolVariable::commit(bool setValid, + MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) { + this->setValid(setValid); + return commit(timeoutType, timeoutMs); +} + +template +inline ReturnValue_t LocalPoolVariable::commit( + MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) { + MutexHelper(hkManager->getMutexHandle(), timeoutType, timeoutMs); return commitWithoutLock(); } diff --git a/datapoollocal/LocalPoolVector.h b/datapoollocal/LocalPoolVector.h index 58face3c..773a52cc 100644 --- a/datapoollocal/LocalPoolVector.h +++ b/datapoollocal/LocalPoolVector.h @@ -7,7 +7,7 @@ #include "../datapool/PoolVariableIF.h" #include "../datapoollocal/LocalDataPoolManager.h" #include "../serialize/SerializeAdapter.h" -#include "../serviceinterface/ServiceInterfaceStream.h" +#include "../serviceinterface/ServiceInterface.h" /** @@ -123,7 +123,9 @@ public: * It is recommended to use DataSets to read and commit multiple variables * at once to avoid the overhead of unnecessary lock und unlock operations. */ - ReturnValue_t read(uint32_t lockTimeout = MutexIF::BLOCKING) override; + ReturnValue_t read(MutexIF::TimeoutType timeoutType = + MutexIF::TimeoutType::WAITING, + uint32_t timeoutMs = 20) override; /** * @brief The commit call copies the array values back to the data pool. * @details @@ -133,7 +135,9 @@ public: * It is recommended to use DataSets to read and commit multiple variables * at once to avoid the overhead of unnecessary lock und unlock operations. */ - ReturnValue_t commit(uint32_t lockTimeout = MutexIF::BLOCKING) override; + ReturnValue_t commit(MutexIF::TimeoutType timeoutType = + MutexIF::TimeoutType::WAITING, + uint32_t timeoutMs = 20) override; protected: /** @@ -157,12 +161,12 @@ protected: private: - +#if FSFW_CPP_OSTREAM_ENABLED == 1 // std::ostream is the type for object std::cout template friend std::ostream& operator<< (std::ostream &out, const LocalPoolVector &var); - +#endif }; diff --git a/datapoollocal/LocalPoolVector.tpp b/datapoollocal/LocalPoolVector.tpp index a010a8bb..6af80de6 100644 --- a/datapoollocal/LocalPoolVector.tpp +++ b/datapoollocal/LocalPoolVector.tpp @@ -24,9 +24,9 @@ inline LocalPoolVector::LocalPoolVector(gp_id_t globalPoolId, dataSet, setReadWriteMode) {} template -inline ReturnValue_t LocalPoolVector::read(uint32_t lockTimeout) { - MutexHelper(hkManager->getMutexHandle(), MutexIF::TimeoutType::WAITING, - lockTimeout); +inline ReturnValue_t LocalPoolVector::read( + MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) { + MutexHelper(hkManager->getMutexHandle(), timeoutType, timeoutMs); return readWithoutLock(); } template @@ -59,9 +59,8 @@ inline ReturnValue_t LocalPoolVector::readWithoutLock() { template inline ReturnValue_t LocalPoolVector::commit( - uint32_t lockTimeout) { - MutexHelper(hkManager->getMutexHandle(), MutexIF::TimeoutType::WAITING, - lockTimeout); + MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) { + MutexHelper(hkManager->getMutexHandle(), timeoutType, timeoutMs); return commitWithoutLock(); } @@ -153,6 +152,7 @@ inline ReturnValue_t LocalPoolVector::deSerialize( return result; } +#if FSFW_CPP_OSTREAM_ENABLED == 1 template inline std::ostream& operator<< (std::ostream &out, const LocalPoolVector &var) { @@ -166,5 +166,6 @@ inline std::ostream& operator<< (std::ostream &out, out << "]"; return out; } +#endif #endif /* FSFW_DATAPOOLLOCAL_LOCALPOOLVECTOR_TPP_ */ diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index 1af6932a..580f8c0d 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -229,7 +229,8 @@ ReturnValue_t DeviceHandlerBase::initialize() { if(result == HasReturnvaluesIF::RETURN_OK) { thermalSet->heaterRequest.value = ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL; - thermalSet->commit(PoolVariableIF::VALID); + thermalSet->heaterRequest.setValid(true); + thermalSet->commit(); } } diff --git a/events/EventManager.cpp b/events/EventManager.cpp index 65e19d10..e25e574f 100644 --- a/events/EventManager.cpp +++ b/events/EventManager.cpp @@ -162,9 +162,15 @@ void EventManager::printEvent(EventMessage* message) { #endif void EventManager::lockMutex() { - mutex->lockMutex(MutexIF::BLOCKING); + mutex->lockMutex(timeoutType, timeoutMs); } void EventManager::unlockMutex() { mutex->unlockMutex(); } + +void EventManager::setMutexTimeout(MutexIF::TimeoutType timeoutType, + uint32_t timeoutMs) { + this->timeoutType = timeoutType; + this->timeoutMs = timeoutMs; +} diff --git a/events/EventManager.h b/events/EventManager.h index c6bd07be..abce9b8b 100644 --- a/events/EventManager.h +++ b/events/EventManager.h @@ -29,6 +29,8 @@ public: EventManager(object_id_t setObjectId); virtual ~EventManager(); + void setMutexTimeout(MutexIF::TimeoutType timeoutType, uint32_t timeoutMs); + MessageQueueId_t getEventReportQueue(); ReturnValue_t registerListener(MessageQueueId_t listener, bool forwardAllButSelected = false); @@ -51,6 +53,8 @@ protected: std::map listenerList; MutexIF* mutex = nullptr; + MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; + uint32_t timeoutMs = 20; static const uint8_t N_POOLS = 3; LocalPool factoryBackend; diff --git a/internalError/InternalErrorReporter.cpp b/internalError/InternalErrorReporter.cpp index 48b6f851..6842da8e 100644 --- a/internalError/InternalErrorReporter.cpp +++ b/internalError/InternalErrorReporter.cpp @@ -23,7 +23,7 @@ void InternalErrorReporter::setDiagnosticPrintout(bool enable) { } ReturnValue_t InternalErrorReporter::performOperation(uint8_t opCode) { - internalErrorDataset.read(INTERNAL_ERROR_MUTEX_TIMEOUT); + internalErrorDataset.read(timeoutType, timeoutMs); uint32_t newQueueHits = getAndResetQueueHits(); uint32_t newTmHits = getAndResetTmHits(); @@ -46,8 +46,8 @@ ReturnValue_t InternalErrorReporter::performOperation(uint8_t opCode) { internalErrorDataset.queueHits.value += newQueueHits; internalErrorDataset.storeHits.value += newStoreHits; internalErrorDataset.tmHits.value += newTmHits; - - internalErrorDataset.commit(INTERNAL_ERROR_MUTEX_TIMEOUT); + internalErrorDataset.setValidity(true, true); + internalErrorDataset.commit(timeoutType, timeoutMs); poolManager.performHkOperation(); @@ -69,7 +69,7 @@ void InternalErrorReporter::lostTm() { uint32_t InternalErrorReporter::getAndResetQueueHits() { uint32_t value; - mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); + mutex->lockMutex(timeoutType, timeoutMs); value = queueHits; queueHits = 0; mutex->unlockMutex(); @@ -78,21 +78,21 @@ uint32_t InternalErrorReporter::getAndResetQueueHits() { uint32_t InternalErrorReporter::getQueueHits() { uint32_t value; - mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); + mutex->lockMutex(timeoutType, timeoutMs); value = queueHits; mutex->unlockMutex(); return value; } void InternalErrorReporter::incrementQueueHits() { - mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); + mutex->lockMutex(timeoutType, timeoutMs); queueHits++; mutex->unlockMutex(); } uint32_t InternalErrorReporter::getAndResetTmHits() { uint32_t value; - mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); + mutex->lockMutex(timeoutType, timeoutMs); value = tmHits; tmHits = 0; mutex->unlockMutex(); @@ -101,14 +101,14 @@ uint32_t InternalErrorReporter::getAndResetTmHits() { uint32_t InternalErrorReporter::getTmHits() { uint32_t value; - mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); + mutex->lockMutex(timeoutType, timeoutMs); value = tmHits; mutex->unlockMutex(); return value; } void InternalErrorReporter::incrementTmHits() { - mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); + mutex->lockMutex(timeoutType, timeoutMs); tmHits++; mutex->unlockMutex(); } @@ -119,7 +119,7 @@ void InternalErrorReporter::storeFull() { uint32_t InternalErrorReporter::getAndResetStoreHits() { uint32_t value; - mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); + mutex->lockMutex(timeoutType, timeoutMs); value = storeHits; storeHits = 0; mutex->unlockMutex(); @@ -128,14 +128,14 @@ uint32_t InternalErrorReporter::getAndResetStoreHits() { uint32_t InternalErrorReporter::getStoreHits() { uint32_t value; - mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); + mutex->lockMutex(timeoutType, timeoutMs); value = storeHits; mutex->unlockMutex(); return value; } void InternalErrorReporter::incrementStoreHits() { - mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); + mutex->lockMutex(timeoutType, timeoutMs); storeHits++; mutex->unlockMutex(); } @@ -190,3 +190,8 @@ ReturnValue_t InternalErrorReporter::initializeAfterTaskCreation() { return poolManager.initializeAfterTaskCreation(); } +void InternalErrorReporter::setMutexTimeout(MutexIF::TimeoutType timeoutType, + uint32_t timeoutMs) { + this->timeoutType = timeoutType; + this->timeoutMs = timeoutMs; +} diff --git a/internalError/InternalErrorReporter.h b/internalError/InternalErrorReporter.h index 8d33c06e..c85057d6 100644 --- a/internalError/InternalErrorReporter.h +++ b/internalError/InternalErrorReporter.h @@ -22,7 +22,6 @@ class InternalErrorReporter: public SystemObject, public InternalErrorReporterIF, public HasLocalDataPoolIF { public: - static constexpr uint8_t INTERNAL_ERROR_MUTEX_TIMEOUT = 20; InternalErrorReporter(object_id_t setObjectId, uint32_t messageQueueDepth = 5); @@ -34,6 +33,9 @@ public: */ void setDiagnosticPrintout(bool enable); + void setMutexTimeout(MutexIF::TimeoutType timeoutType, + uint32_t timeoutMs); + virtual ~InternalErrorReporter(); virtual object_id_t getObjectId() const override; @@ -61,7 +63,11 @@ protected: LocalDataPoolManager poolManager; PeriodicTaskIF* executingTask = nullptr; + MutexIF* mutex = nullptr; + MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; + uint32_t timeoutMs = 20; + sid_t internalErrorSid; InternalErrorDataset internalErrorDataset; diff --git a/ipc/MutexIF.h b/ipc/MutexIF.h index 5673e4d7..084b702b 100644 --- a/ipc/MutexIF.h +++ b/ipc/MutexIF.h @@ -14,7 +14,7 @@ public: /** * Different types of timeout for the mutex lock. */ - enum TimeoutType { + enum class TimeoutType { POLLING, //!< If mutex is not available, return immediately WAITING, //!< Wait a specified time for the mutex to become available BLOCKING //!< Block indefinitely until the mutex becomes available. diff --git a/osal/host/Clock.cpp b/osal/host/Clock.cpp index 2bc78785..88bf51d2 100644 --- a/osal/host/Clock.cpp +++ b/osal/host/Clock.cpp @@ -202,7 +202,7 @@ ReturnValue_t Clock::setLeapSeconds(const uint16_t leapSeconds_) { if(checkOrCreateClockMutex()!=HasReturnvaluesIF::RETURN_OK){ return HasReturnvaluesIF::RETURN_FAILED; } - ReturnValue_t result = timeMutex->lockMutex(MutexIF::BLOCKING); + ReturnValue_t result = timeMutex->lockMutex(); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } @@ -217,7 +217,7 @@ ReturnValue_t Clock::getLeapSeconds(uint16_t* leapSeconds_) { if(timeMutex == nullptr){ return HasReturnvaluesIF::RETURN_FAILED; } - ReturnValue_t result = timeMutex->lockMutex(MutexIF::BLOCKING); + ReturnValue_t result = timeMutex->lockMutex(); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } diff --git a/osal/host/Mutex.cpp b/osal/host/Mutex.cpp index ad8873df..892028b2 100644 --- a/osal/host/Mutex.cpp +++ b/osal/host/Mutex.cpp @@ -4,16 +4,16 @@ Mutex::Mutex() {} ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType, uint32_t timeoutMs) { - if(timeoutType == MutexIF::BLOCKING) { + if(timeoutType == TimeoutType::BLOCKING) { mutex.lock(); return HasReturnvaluesIF::RETURN_OK; } - else if(timeoutType == MutexIF::POLLING) { + else if(timeoutType == TimeoutType::POLLING) { if(mutex.try_lock()) { return HasReturnvaluesIF::RETURN_OK; } } - else if(timeoutMs > MutexIF::POLLING){ + else if(timeoutType == TimeoutType::WAITING){ auto chronoMs = std::chrono::milliseconds(timeoutMs); if(mutex.try_lock_for(chronoMs)) { return HasReturnvaluesIF::RETURN_OK; diff --git a/power/Fuse.cpp b/power/Fuse.cpp index 1c30d83f..b6e0a7f1 100644 --- a/power/Fuse.cpp +++ b/power/Fuse.cpp @@ -65,8 +65,8 @@ ReturnValue_t Fuse::check() { set.read(); if (!healthHelper.healthTable->isHealthy(getObjectId())) { setAllMonitorsToUnchecked(); - set.commit(PoolVariableIF::INVALID); - return RETURN_OK; + set.setValidity(false, true); + return set.commit(); } ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; checkFuseState(); @@ -206,7 +206,8 @@ float Fuse::getPower() { void Fuse::setDataPoolEntriesInvalid() { set.read(); - set.commit(PoolVariableIF::INVALID); + set.setValidity(false, true); + set.commit(); } ReturnValue_t Fuse::getParameter(uint8_t domainId, uint16_t parameterId, diff --git a/power/PowerSensor.cpp b/power/PowerSensor.cpp index 1ef041e3..fb181d9f 100644 --- a/power/PowerSensor.cpp +++ b/power/PowerSensor.cpp @@ -97,7 +97,8 @@ void PowerSensor::checkCommandQueue() { void PowerSensor::setDataPoolEntriesInvalid() { powerSensorSet.read(); - powerSensorSet.commit(PoolVariableIF::INVALID); + powerSensorSet.setValidity(false, true); + powerSensorSet.commit(); } float PowerSensor::getPower() { diff --git a/unittest/internal/osal/IntTestMutex.cpp b/unittest/internal/osal/IntTestMutex.cpp index 3316de74..2a1584b8 100644 --- a/unittest/internal/osal/IntTestMutex.cpp +++ b/unittest/internal/osal/IntTestMutex.cpp @@ -13,7 +13,7 @@ void testmutex::testMutex() { std::string id = "[testMutex]"; MutexIF* mutex = MutexFactory::instance()->createMutex(); - auto result = mutex->lockMutex(MutexIF::POLLING); + auto result = mutex->lockMutex(MutexIF::TimeoutType::POLLING); if(result != HasReturnvaluesIF::RETURN_OK) { unitt::put_error(id); } diff --git a/unittest/tests/datapoollocal/DataSetTest.cpp b/unittest/tests/datapoollocal/DataSetTest.cpp new file mode 100644 index 00000000..ccb7603d --- /dev/null +++ b/unittest/tests/datapoollocal/DataSetTest.cpp @@ -0,0 +1,21 @@ +#include "LocalPoolOwnerBase.h" + +#include +#include +#include + +TEST_CASE("LocalDataSet" , "[LocDataSetTest]") { + LocalPoolOwnerBase* poolOwner = objectManager-> + get(objects::TEST_LOCAL_POOL_OWNER_BASE); + REQUIRE(poolOwner != nullptr); + REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK); + REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation() + == retval::CATCH_OK); + + SECTION("BasicTest") { + //StaticLocalDataSet<3> localSet = StaticLocalDataSet<3>() + } +} + + + diff --git a/unittest/tests/datapoollocal/LocalPoolOwnerBase.h b/unittest/tests/datapoollocal/LocalPoolOwnerBase.h index 40f657be..c665cb7f 100644 --- a/unittest/tests/datapoollocal/LocalPoolOwnerBase.h +++ b/unittest/tests/datapoollocal/LocalPoolOwnerBase.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -11,9 +12,12 @@ namespace lpool { static constexpr lp_id_t uint8VarId = 0; static constexpr lp_id_t floatVarId = 1; static constexpr lp_id_t uint32VarId = 2; +static constexpr lp_id_t uint16Vec3Id = 3; +static constexpr lp_id_t int64Vec2Id = 4; } + class LocalPoolOwnerBase: public SystemObject, public HasLocalDataPoolIF { public: LocalPoolOwnerBase( @@ -31,12 +35,19 @@ public: } ReturnValue_t initializeHkManager() { - return hkManager.initialize(messageQueue); - + if(not initialized) { + initialized = true; + return hkManager.initialize(messageQueue); + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t initializeHkManagerAfterTaskCreation() { - return hkManager.initializeAfterTaskCreation(); + if(not initializedAfterTaskCreation) { + initializedAfterTaskCreation = true; + return hkManager.initializeAfterTaskCreation(); + } + return HasReturnvaluesIF::RETURN_OK; } /** Command queue for housekeeping messages. */ @@ -44,12 +55,22 @@ public: return messageQueue->getId(); } + // This is called by initializeAfterTaskCreation of the HK manager. virtual ReturnValue_t initializeLocalDataPool( LocalDataPool& localDataPoolMap, LocalDataPoolManager& poolManager) { // Default initialization empty for now. - localDataPoolMap.emplace(lpool::uint8VarId, new PoolEntry({0})); - localDataPoolMap.emplace(lpool::floatVarId, new PoolEntry({0})); + localDataPoolMap.emplace(lpool::uint8VarId, + new PoolEntry({0})); + localDataPoolMap.emplace(lpool::floatVarId, + new PoolEntry({0})); + localDataPoolMap.emplace(lpool::uint32VarId, + new PoolEntry({0})); + + localDataPoolMap.emplace(lpool::uint16Vec3Id, + new PoolEntry({0, 0, 0})); + localDataPoolMap.emplace(lpool::int64Vec2Id, + new PoolEntry({0, 0})); return HasReturnvaluesIF::RETURN_OK; } @@ -77,9 +98,17 @@ private: lp_var_t testFloat = lp_var_t(this, lpool::floatVarId); lp_var_t testUint32 = lp_var_t(this, lpool::uint32VarId); + lp_vec_t testUint16Vec = lp_vec_t(this, + lpool::uint16Vec3Id); + lp_vec_t testInt64Vec = lp_vec_t(this, + lpool::int64Vec2Id); + MessageQueueIF* messageQueue = nullptr; LocalDataPoolManager hkManager; + bool initialized = false; + bool initializedAfterTaskCreation = false; + }; #endif /* FSFW_UNITTEST_TESTS_DATAPOOLLOCAL_LOCALPOOLOWNERBASE_H_ */ diff --git a/unittest/tests/datapoollocal/LocalPoolVariableTest.cpp b/unittest/tests/datapoollocal/LocalPoolVariableTest.cpp index cf4f4b6b..eb5abf35 100644 --- a/unittest/tests/datapoollocal/LocalPoolVariableTest.cpp +++ b/unittest/tests/datapoollocal/LocalPoolVariableTest.cpp @@ -6,9 +6,11 @@ TEST_CASE("LocalPoolVariable" , "[LocPoolVarTest]") { - LocalPoolOwnerBase poolOwner(objects::TEST_LOCAL_POOL_OWNER_BASE); - REQUIRE(poolOwner.initializeHkManager() == retval::CATCH_OK); - REQUIRE(poolOwner.initializeHkManagerAfterTaskCreation() + LocalPoolOwnerBase* poolOwner = objectManager-> + get(objects::TEST_LOCAL_POOL_OWNER_BASE); + REQUIRE(poolOwner != nullptr); + REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK); + REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation() == retval::CATCH_OK); SECTION("Basic Tests") { @@ -26,6 +28,18 @@ TEST_CASE("LocalPoolVariable" , "[LocPoolVarTest]") { testVariable.setValid(true); CHECK(testVariable.isValid()); + testVariable.setReadWriteMode(pool_rwm_t::VAR_READ); + CHECK(testVariable.getReadWriteMode() == pool_rwm_t::VAR_READ); + testVariable.setReadWriteMode(pool_rwm_t::VAR_READ_WRITE); + + testVariable.setDataPoolId(22); + CHECK(testVariable.getDataPoolId() == 22); + testVariable.setDataPoolId(lpool::uint8VarId); + + testVariable.setChanged(true); + CHECK(testVariable.hasChanged()); + testVariable.setChanged(false); + gp_id_t globPoolId(objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint8VarId); lp_var_t testVariable2 = lp_var_t(globPoolId); @@ -93,6 +107,15 @@ TEST_CASE("LocalPoolVariable" , "[LocPoolVarTest]") { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "LocalPoolVariable printout: " < OK + lp_var_t invalidObjectVar = lp_var_t( + 0xffffffff, lpool::uint8VarId); + gp_id_t globPoolId(0xffffffff, + lpool::uint8VarId); + lp_var_t invalidObjectVar2 = lp_var_t(globPoolId); + lp_var_t invalidObjectVar3 = lp_var_t(nullptr, + lpool::uint8VarId); } } diff --git a/unittest/tests/datapoollocal/LocalPoolVectorTest.cpp b/unittest/tests/datapoollocal/LocalPoolVectorTest.cpp new file mode 100644 index 00000000..c86a2681 --- /dev/null +++ b/unittest/tests/datapoollocal/LocalPoolVectorTest.cpp @@ -0,0 +1,16 @@ +#include "LocalPoolOwnerBase.h" + +#include +#include +#include + +TEST_CASE("LocalPoolVector" , "[LocPoolVecTest]") { + LocalPoolOwnerBase* poolOwner = objectManager-> + get(objects::TEST_LOCAL_POOL_OWNER_BASE); + REQUIRE(poolOwner != nullptr); + REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK); + REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation() + == retval::CATCH_OK); +} + + From 2b287dfc3ac227af78f68a003948b92656cd4005 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 6 Jan 2021 21:33:54 +0100 Subject: [PATCH 43/50] freertos and pool read helper fix --- datapoollocal/PoolReadHelper.h | 9 ++++++--- osal/FreeRTOS/Clock.cpp | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/datapoollocal/PoolReadHelper.h b/datapoollocal/PoolReadHelper.h index a059685b..c89fff98 100644 --- a/datapoollocal/PoolReadHelper.h +++ b/datapoollocal/PoolReadHelper.h @@ -9,10 +9,12 @@ */ class PoolReadHelper { public: - PoolReadHelper(ReadCommitIF* readObject, uint32_t mutexTimeout = 20): + PoolReadHelper(ReadCommitIF* readObject, + MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING, + uint32_t mutexTimeout = 20): readObject(readObject), mutexTimeout(mutexTimeout) { if(readObject != nullptr) { - readResult = readObject->read(mutexTimeout); + readResult = readObject->read(timeoutType, mutexTimeout); #if FSFW_PRINT_VERBOSITY_LEVEL == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PoolReadHelper: Read failed!" << std::endl; @@ -27,7 +29,7 @@ public: ~PoolReadHelper() { if(readObject != nullptr) { - readObject->commit(mutexTimeout); + readObject->commit(timeoutType, mutexTimeout); } } @@ -35,6 +37,7 @@ public: private: ReadCommitIF* readObject = nullptr; ReturnValue_t readResult = HasReturnvaluesIF::RETURN_OK; + MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; uint32_t mutexTimeout = 20; }; diff --git a/osal/FreeRTOS/Clock.cpp b/osal/FreeRTOS/Clock.cpp index d3f4e68e..9c0a0267 100644 --- a/osal/FreeRTOS/Clock.cpp +++ b/osal/FreeRTOS/Clock.cpp @@ -163,7 +163,7 @@ ReturnValue_t Clock::setLeapSeconds(const uint16_t leapSeconds_) { if (checkOrCreateClockMutex() != HasReturnvaluesIF::RETURN_OK) { return HasReturnvaluesIF::RETURN_FAILED; } - ReturnValue_t result = timeMutex->lockMutex(MutexIF::BLOCKING); + ReturnValue_t result = timeMutex->lockMutex(MutexIF::TimeoutType::BLOCKING); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } @@ -178,7 +178,7 @@ ReturnValue_t Clock::getLeapSeconds(uint16_t* leapSeconds_) { if (timeMutex == NULL) { return HasReturnvaluesIF::RETURN_FAILED; } - ReturnValue_t result = timeMutex->lockMutex(MutexIF::BLOCKING); + ReturnValue_t result = timeMutex->lockMutex(MutexIF::TimeoutType::BLOCKING); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } From fcb33201a4c40ae868d82fcff1060fc6fdf2c342 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 6 Jan 2021 21:45:35 +0100 Subject: [PATCH 44/50] fixed linux osal --- osal/linux/Clock.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/osal/linux/Clock.cpp b/osal/linux/Clock.cpp index 54dad839..35cbfae0 100644 --- a/osal/linux/Clock.cpp +++ b/osal/linux/Clock.cpp @@ -182,7 +182,7 @@ ReturnValue_t Clock::setLeapSeconds(const uint16_t leapSeconds_) { if(checkOrCreateClockMutex()!=HasReturnvaluesIF::RETURN_OK){ return HasReturnvaluesIF::RETURN_FAILED; } - ReturnValue_t result = timeMutex->lockMutex(MutexIF::BLOCKING); + ReturnValue_t result = timeMutex->lockMutex(MutexIF::TimeoutType::BLOCKING); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } @@ -197,7 +197,7 @@ ReturnValue_t Clock::getLeapSeconds(uint16_t* leapSeconds_) { if(timeMutex==NULL){ return HasReturnvaluesIF::RETURN_FAILED; } - ReturnValue_t result = timeMutex->lockMutex(MutexIF::BLOCKING); + ReturnValue_t result = timeMutex->lockMutex(MutexIF::TimeoutType::BLOCKING); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } @@ -209,13 +209,13 @@ ReturnValue_t Clock::getLeapSeconds(uint16_t* leapSeconds_) { } ReturnValue_t Clock::checkOrCreateClockMutex(){ - if(timeMutex==NULL){ + if(timeMutex == nullptr){ MutexFactory* mutexFactory = MutexFactory::instance(); - if (mutexFactory == NULL) { + if (mutexFactory == nullptr) { return HasReturnvaluesIF::RETURN_FAILED; } timeMutex = mutexFactory->createMutex(); - if (timeMutex == NULL) { + if (timeMutex == nullptr) { return HasReturnvaluesIF::RETURN_FAILED; } } From 8aaf45049faa4677208d3486ce4e6c2946416ee2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 6 Jan 2021 21:49:40 +0100 Subject: [PATCH 45/50] major bugfix in rtems osal --- osal/rtems/Mutex.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osal/rtems/Mutex.cpp b/osal/rtems/Mutex.cpp index 71c5782f..7dd512fa 100644 --- a/osal/rtems/Mutex.cpp +++ b/osal/rtems/Mutex.cpp @@ -30,11 +30,11 @@ Mutex::~Mutex() { ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType = TimeoutType::BLOCKING, uint32_t timeoutMs) { rtems_status_code status = RTEMS_INVALID_ID; - if(timeoutMs == MutexIF::TimeoutType::BLOCKING) { + if(timeoutType == MutexIF::TimeoutType::BLOCKING) { status = rtems_semaphore_obtain(mutexId, RTEMS_WAIT, RTEMS_NO_TIMEOUT); } - else if(timeoutMs == MutexIF::TimeoutType::POLLING) { + else if(timeoutType == MutexIF::TimeoutType::POLLING) { timeoutMs = RTEMS_NO_TIMEOUT; status = rtems_semaphore_obtain(mutexId, RTEMS_NO_WAIT, 0); From 007526c0502d7db92d37dcdc080bf4c08c5f9030 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 7 Jan 2021 19:10:07 +0100 Subject: [PATCH 46/50] new f unctions for read error reporting, bugfix --- datapool/PoolVariableIF.h | 1 + datapoollocal/LocalDataPoolManager.h | 11 +++++- datapoollocal/LocalPoolVariable.h | 1 + datapoollocal/LocalPoolVariable.tpp | 58 ++++++++++++++++++---------- 4 files changed, 48 insertions(+), 23 deletions(-) diff --git a/datapool/PoolVariableIF.h b/datapool/PoolVariableIF.h index 9740fc12..444e19d0 100644 --- a/datapool/PoolVariableIF.h +++ b/datapool/PoolVariableIF.h @@ -25,6 +25,7 @@ class PoolVariableIF : public SerializeIF, public: static constexpr uint8_t INTERFACE_ID = CLASS_ID::POOL_VARIABLE_IF; static constexpr ReturnValue_t INVALID_READ_WRITE_MODE = MAKE_RETURN_CODE(0xA0); + static constexpr ReturnValue_t INVALID_POOL_ENTRY = MAKE_RETURN_CODE(0xA1); static constexpr bool VALID = 1; static constexpr bool INVALID = 0; diff --git a/datapoollocal/LocalDataPoolManager.h b/datapoollocal/LocalDataPoolManager.h index 0e98b90c..bcb8f0af 100644 --- a/datapoollocal/LocalDataPoolManager.h +++ b/datapoollocal/LocalDataPoolManager.h @@ -3,6 +3,7 @@ #include "HasLocalDataPoolIF.h" +#include "../serviceinterface/ServiceInterface.h" #include "../housekeeping/HousekeepingPacketDownlink.h" #include "../housekeeping/HousekeepingMessage.h" #include "../housekeeping/PeriodicHousekeepingHelper.h" @@ -378,6 +379,9 @@ ReturnValue_t LocalDataPoolManager::fetchPoolEntry(lp_id_t localPoolId, #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "HousekeepingManager::fechPoolEntry: Pool entry " "not found." << std::endl; +#else + fsfw::printWarning("HousekeepingManager::fechPoolEntry: Pool entry " + "not found."); #endif return HasLocalDataPoolIF::POOL_ENTRY_NOT_FOUND; } @@ -385,8 +389,11 @@ ReturnValue_t LocalDataPoolManager::fetchPoolEntry(lp_id_t localPoolId, *poolEntry = dynamic_cast< PoolEntry* >(poolIter->second); if(*poolEntry == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << "HousekeepingManager::fetchPoolEntry:" - " Pool entry not found." << std::endl; + sif::warning << "HousekeepingManager::fetchPoolEntry:" + " Pool entry type conflict." << std::endl; +#else + fsfw::printWarning("HousekeepingManager::fetchPoolEntry:" + " Pool entry type conflict."); #endif return HasLocalDataPoolIF::POOL_ENTRY_TYPE_CONFLICT; } diff --git a/datapoollocal/LocalPoolVariable.h b/datapoollocal/LocalPoolVariable.h index c81967a1..ca0aede9 100644 --- a/datapoollocal/LocalPoolVariable.h +++ b/datapoollocal/LocalPoolVariable.h @@ -181,6 +181,7 @@ protected: #endif private: + void reportReadCommitError(bool read, object_id_t objectId, lp_id_t lpId); }; #include "LocalPoolVariable.tpp" diff --git a/datapoollocal/LocalPoolVariable.tpp b/datapoollocal/LocalPoolVariable.tpp index 9387acc5..c20e9230 100644 --- a/datapoollocal/LocalPoolVariable.tpp +++ b/datapoollocal/LocalPoolVariable.tpp @@ -46,18 +46,17 @@ inline ReturnValue_t LocalPoolVariable::readWithoutLock() { PoolEntry* poolEntry = nullptr; ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry); if(result != RETURN_OK or poolEntry == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "PoolPoolVariable: Read of local pool variable of object " - << std::hex << std::setw(8) << std::setfill('0') - << hkManager->getOwner() << " and lp ID 0x" << localPoolId - << std::dec << " failed." << std::setfill(' ') << std::endl; -#else - fsfw::printError("LocalPoolVariable: Read of local pool variable of " - "object 0x%08x and lp ID 0x%08x failed.\n\r", - hkManager->getOwner(), localPoolId); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ + object_id_t ownerObjectId = hkManager->getOwner()->getObjectId(); + reportReadCommitError(true, ownerObjectId, localPoolId); return result; } + + if(poolEntry->address == nullptr) { + object_id_t ownerObjectId = hkManager->getOwner()->getObjectId(); + reportReadCommitError(true, ownerObjectId, localPoolId); + return PoolVariableIF::INVALID_POOL_ENTRY; + } + this->value = *(poolEntry->address); this->valid = poolEntry->valid; return RETURN_OK; @@ -91,19 +90,12 @@ inline ReturnValue_t LocalPoolVariable::commitWithoutLock() { } PoolEntry* poolEntry = nullptr; ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry); - if(result != RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "PoolPoolVariable: Read of local pool variable of " - << "object " << std::hex << std::setw(8) << std::setfill('0') - << hkManager->getOwner() << " and lp ID 0x" << localPoolId - << std::dec << " failed." << std::endl; -#else - fsfw::printError("LocalPoolVariable: Read of local pool variable of " - "object 0x%08x and lp ID 0x%08x failed.\n\r", - hkManager->getOwner(), localPoolId); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ + if(result != RETURN_OK or poolEntry == nullptr) { + object_id_t ownerObjectId = hkManager->getOwner()->getObjectId(); + reportReadCommitError(false, ownerObjectId, localPoolId); return result; } + *(poolEntry->address) = this->value; poolEntry->valid = this->valid; return RETURN_OK; @@ -203,4 +195,28 @@ inline bool LocalPoolVariable::operator >(const T &other) const { return not (*this < other); } +template +inline void LocalPoolVariable::reportReadCommitError(bool read, + object_id_t objectId, lp_id_t lpId) { + const char* type = nullptr; + if(read) { + type = "read"; + } + else { + type = "commit"; + } + +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::warning << "PoolPoolVariable: " << type << " of local pool " + <<"variable of object " << std::hex << std::setw(8) + << std::setfill('0') << objectId << " and lp ID 0x" << lpId + << std::dec << " failed." << std::endl; +#else + fsfw::printWarning("LocalPoolVariable: %s of local pool variable of " + "object 0x%08x and lp ID 0x%08x failed.\n\r", + type, objectId, lpId); +#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ +} + + #endif /* FSFW_DATAPOOLLOCAL_LOCALPOOLVARIABLE_TPP_ */ From 3be51762cccb8964ab3d19e379f1d427a99710b7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 7 Jan 2021 20:23:23 +0100 Subject: [PATCH 47/50] improved error handling significantly --- datapoollocal/LocalPoolObjectBase.cpp | 41 +++++++++++++++++++++++++++ datapoollocal/LocalPoolObjectBase.h | 2 ++ datapoollocal/LocalPoolVariable.h | 3 -- datapoollocal/LocalPoolVariable.tpp | 41 +++++++-------------------- datapoollocal/LocalPoolVector.tpp | 23 +++++++-------- 5 files changed, 64 insertions(+), 46 deletions(-) diff --git a/datapoollocal/LocalPoolObjectBase.cpp b/datapoollocal/LocalPoolObjectBase.cpp index 4b57dede..b84569b8 100644 --- a/datapoollocal/LocalPoolObjectBase.cpp +++ b/datapoollocal/LocalPoolObjectBase.cpp @@ -79,3 +79,44 @@ bool LocalPoolObjectBase::hasChanged() const { void LocalPoolObjectBase::setReadWriteMode(pool_rwm_t newReadWriteMode) { this->readWriteMode = newReadWriteMode; } + +void LocalPoolObjectBase::reportReadCommitError(const char* variableType, + ReturnValue_t error, bool read, object_id_t objectId, lp_id_t lpId) { +#if FSFW_DISABLE_PRINTOUT == 0 + const char* type = nullptr; + if(read) { + type = "read"; + } + else { + type = "commit"; + } + + const char* errMsg = nullptr; + if(error == HasLocalDataPoolIF::POOL_ENTRY_NOT_FOUND) { + errMsg = "Pool entry not found"; + } + else if(error == HasLocalDataPoolIF::POOL_ENTRY_TYPE_CONFLICT) { + errMsg = "Pool entry type conflict"; + } + else if(error == PoolVariableIF::INVALID_READ_WRITE_MODE) { + errMsg = "Pool variable wrong read-write mode"; + } + else if(error == PoolVariableIF::INVALID_POOL_ENTRY) { + errMsg = "Pool entry invalid"; + } + else { + errMsg = "Unknown error code"; + } + +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::warning << variableType << ": " << type << " call | " << errMsg + << " | Owner: " << std::hex << std::setw(8) + << std::setfill('0') << objectId << " LPID: 0x" << lpId + << std::dec << std::endl; +#else + fsfw::printWarning("LocalPoolVariable: %s of local pool variable of " + "object 0x%08x and lp ID 0x%08x failed.\n\r", + type, objectId, lpId); +#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ +#endif /* FSFW_DISABLE_PRINTOUT == 0 */ +} diff --git a/datapoollocal/LocalPoolObjectBase.h b/datapoollocal/LocalPoolObjectBase.h index 7165fc24..25ca594d 100644 --- a/datapoollocal/LocalPoolObjectBase.h +++ b/datapoollocal/LocalPoolObjectBase.h @@ -56,6 +56,8 @@ protected: //! @brief Pointer to the class which manages the HK pool. LocalDataPoolManager* hkManager; + void reportReadCommitError(const char* variableType, + ReturnValue_t error, bool read, object_id_t objectId, lp_id_t lpId); }; diff --git a/datapoollocal/LocalPoolVariable.h b/datapoollocal/LocalPoolVariable.h index ca0aede9..22019c2f 100644 --- a/datapoollocal/LocalPoolVariable.h +++ b/datapoollocal/LocalPoolVariable.h @@ -179,9 +179,6 @@ protected: friend std::ostream& operator<< (std::ostream &out, const LocalPoolVariable &var); #endif - -private: - void reportReadCommitError(bool read, object_id_t objectId, lp_id_t lpId); }; #include "LocalPoolVariable.tpp" diff --git a/datapoollocal/LocalPoolVariable.tpp b/datapoollocal/LocalPoolVariable.tpp index c20e9230..4d472c31 100644 --- a/datapoollocal/LocalPoolVariable.tpp +++ b/datapoollocal/LocalPoolVariable.tpp @@ -45,16 +45,20 @@ inline ReturnValue_t LocalPoolVariable::readWithoutLock() { PoolEntry* poolEntry = nullptr; ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry); - if(result != RETURN_OK or poolEntry == nullptr) { + if(result != RETURN_OK) { object_id_t ownerObjectId = hkManager->getOwner()->getObjectId(); - reportReadCommitError(true, ownerObjectId, localPoolId); + reportReadCommitError("LocalPoolVariable", result, + false, ownerObjectId, localPoolId); return result; } + // Actually this should never happen.. if(poolEntry->address == nullptr) { + result = PoolVariableIF::INVALID_POOL_ENTRY; object_id_t ownerObjectId = hkManager->getOwner()->getObjectId(); - reportReadCommitError(true, ownerObjectId, localPoolId); - return PoolVariableIF::INVALID_POOL_ENTRY; + reportReadCommitError("LocalPoolVariable", result, + false, ownerObjectId, localPoolId); + return result; } this->value = *(poolEntry->address); @@ -90,9 +94,10 @@ inline ReturnValue_t LocalPoolVariable::commitWithoutLock() { } PoolEntry* poolEntry = nullptr; ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry); - if(result != RETURN_OK or poolEntry == nullptr) { + if(result != RETURN_OK) { object_id_t ownerObjectId = hkManager->getOwner()->getObjectId(); - reportReadCommitError(false, ownerObjectId, localPoolId); + reportReadCommitError("LocalPoolVariable", result, + false, ownerObjectId, localPoolId); return result; } @@ -195,28 +200,4 @@ inline bool LocalPoolVariable::operator >(const T &other) const { return not (*this < other); } -template -inline void LocalPoolVariable::reportReadCommitError(bool read, - object_id_t objectId, lp_id_t lpId) { - const char* type = nullptr; - if(read) { - type = "read"; - } - else { - type = "commit"; - } - -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "PoolPoolVariable: " << type << " of local pool " - <<"variable of object " << std::hex << std::setw(8) - << std::setfill('0') << objectId << " and lp ID 0x" << lpId - << std::dec << " failed." << std::endl; -#else - fsfw::printWarning("LocalPoolVariable: %s of local pool variable of " - "object 0x%08x and lp ID 0x%08x failed.\n\r", - type, objectId, lpId); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ -} - - #endif /* FSFW_DATAPOOLLOCAL_LOCALPOOLVARIABLE_TPP_ */ diff --git a/datapoollocal/LocalPoolVector.tpp b/datapoollocal/LocalPoolVector.tpp index 6af80de6..99e37a87 100644 --- a/datapoollocal/LocalPoolVector.tpp +++ b/datapoollocal/LocalPoolVector.tpp @@ -44,12 +44,9 @@ inline ReturnValue_t LocalPoolVector::readWithoutLock() { memset(this->value, 0, vectorSize * sizeof(T)); if(result != RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "LocalPoolVector: Read of local pool variable of object " - << std::hex << std::setw(8) << std::setfill('0') - << hkManager->getOwner() << "and lp ID 0x" << localPoolId - << std::dec << " failed." << std::endl; -#endif + object_id_t targetObjectId = hkManager->getOwner()->getObjectId(); + reportReadCommitError("LocalPoolVector", result, true, targetObjectId, + localPoolId); return result; } std::memcpy(this->value, poolEntry->address, poolEntry->getByteSize()); @@ -69,19 +66,19 @@ inline ReturnValue_t LocalPoolVector::commitWithoutLock() { if(readWriteMode == pool_rwm_t::VAR_READ) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "LocalPoolVector: Invalid read write " - "mode for commit() call." << std::endl; + "mode for commit call." << std::endl; +#else + sif::warning << "LocalPoolVector: Invalid read write " + "mode for commit call." << std::endl; #endif return PoolVariableIF::INVALID_READ_WRITE_MODE; } PoolEntry* poolEntry = nullptr; ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry); if(result != RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "LocalPoolVector: Read of local pool variable of object " - << std::hex << std::setw(8) << std::setfill('0') - << hkManager->getOwner() << " and lp ID " << localPoolId - << std::dec << " failed." << std::endl; -#endif + object_id_t targetObjectId = hkManager->getOwner()->getObjectId(); + reportReadCommitError("LocalPoolVector", result, true, targetObjectId, + localPoolId); return result; } std::memcpy(poolEntry->address, this->value, poolEntry->getByteSize()); From 44a5430555766db0d6bae8a1dca7221c122c80a9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 7 Jan 2021 20:28:03 +0100 Subject: [PATCH 48/50] pool vector improvements --- datapoollocal/LocalPoolVector.tpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/datapoollocal/LocalPoolVector.tpp b/datapoollocal/LocalPoolVector.tpp index 99e37a87..88ba084a 100644 --- a/datapoollocal/LocalPoolVector.tpp +++ b/datapoollocal/LocalPoolVector.tpp @@ -32,10 +32,10 @@ inline ReturnValue_t LocalPoolVector::read( template inline ReturnValue_t LocalPoolVector::readWithoutLock() { if(readWriteMode == pool_rwm_t::VAR_WRITE) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "LocalPoolVector: Invalid read write " - "mode for read() call." << std::endl; -#endif + object_id_t targetObjectId = hkManager->getOwner()->getObjectId(); + reportReadCommitError("LocalPoolVector", + PoolVariableIF::INVALID_READ_WRITE_MODE, true, targetObjectId, + localPoolId); return PoolVariableIF::INVALID_READ_WRITE_MODE; } @@ -64,20 +64,17 @@ inline ReturnValue_t LocalPoolVector::commit( template inline ReturnValue_t LocalPoolVector::commitWithoutLock() { if(readWriteMode == pool_rwm_t::VAR_READ) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "LocalPoolVector: Invalid read write " - "mode for commit call." << std::endl; -#else - sif::warning << "LocalPoolVector: Invalid read write " - "mode for commit call." << std::endl; -#endif + object_id_t targetObjectId = hkManager->getOwner()->getObjectId(); + reportReadCommitError("LocalPoolVector", + PoolVariableIF::INVALID_READ_WRITE_MODE, false, targetObjectId, + localPoolId); return PoolVariableIF::INVALID_READ_WRITE_MODE; } PoolEntry* poolEntry = nullptr; ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry); if(result != RETURN_OK) { object_id_t targetObjectId = hkManager->getOwner()->getObjectId(); - reportReadCommitError("LocalPoolVector", result, true, targetObjectId, + reportReadCommitError("LocalPoolVector", result, false, targetObjectId, localPoolId); return result; } From d3fbe4a3b96184b1f1620041fd7f433cf902b56e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 7 Jan 2021 20:29:38 +0100 Subject: [PATCH 49/50] local pool variable error handling improved --- datapoollocal/LocalPoolVariable.tpp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/datapoollocal/LocalPoolVariable.tpp b/datapoollocal/LocalPoolVariable.tpp index 4d472c31..3cf0fc84 100644 --- a/datapoollocal/LocalPoolVariable.tpp +++ b/datapoollocal/LocalPoolVariable.tpp @@ -33,13 +33,10 @@ inline ReturnValue_t LocalPoolVariable::read( template inline ReturnValue_t LocalPoolVariable::readWithoutLock() { if(readWriteMode == pool_rwm_t::VAR_WRITE) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "LocalPoolVariable: Invalid read write " - "mode for read call." << std::endl; -#else - fsfw::printWarning("LocalPoolVariable: Invalid read write " - "mode for read call.\n\r"); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ + object_id_t targetObjectId = hkManager->getOwner()->getObjectId(); + reportReadCommitError("LocalPoolVector", + PoolVariableIF::INVALID_READ_WRITE_MODE, true, targetObjectId, + localPoolId); return PoolVariableIF::INVALID_READ_WRITE_MODE; } @@ -83,13 +80,10 @@ inline ReturnValue_t LocalPoolVariable::commit( template inline ReturnValue_t LocalPoolVariable::commitWithoutLock() { if(readWriteMode == pool_rwm_t::VAR_READ) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "LocalPoolVariable: Invalid read write " - "mode for commit call." << std::endl; -#else - fsfw::printWarning("LocalPoolVariable: Invalid read write " - "mode for commit call.\n\r"); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ + object_id_t targetObjectId = hkManager->getOwner()->getObjectId(); + reportReadCommitError("LocalPoolVector", + PoolVariableIF::INVALID_READ_WRITE_MODE, false, targetObjectId, + localPoolId); return PoolVariableIF::INVALID_READ_WRITE_MODE; } PoolEntry* poolEntry = nullptr; From d3405ee34063eca17a529dcf521ff860d91e5b50 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 7 Jan 2021 20:30:52 +0100 Subject: [PATCH 50/50] whitespace --- datapoollocal/LocalPoolVariable.tpp | 1 + 1 file changed, 1 insertion(+) diff --git a/datapoollocal/LocalPoolVariable.tpp b/datapoollocal/LocalPoolVariable.tpp index 3cf0fc84..d9d45d38 100644 --- a/datapoollocal/LocalPoolVariable.tpp +++ b/datapoollocal/LocalPoolVariable.tpp @@ -86,6 +86,7 @@ inline ReturnValue_t LocalPoolVariable::commitWithoutLock() { localPoolId); return PoolVariableIF::INVALID_READ_WRITE_MODE; } + PoolEntry* poolEntry = nullptr; ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry); if(result != RETURN_OK) {