From 6be6d593a32476fb811eeee983ae7ea61fe5c36c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 4 Feb 2021 13:46:27 +0100 Subject: [PATCH] minor tweaks --- datapoollocal/LocalDataPoolManager.cpp | 8 ++++++-- datapoollocal/LocalPoolDataSetBase.cpp | 1 + devicehandlers/DeviceHandlerBase.cpp | 17 +++++++---------- osal/host/QueueMapManager.cpp | 23 ++++++++++++++--------- osal/host/QueueMapManager.h | 2 +- 5 files changed, 29 insertions(+), 22 deletions(-) diff --git a/datapoollocal/LocalDataPoolManager.cpp b/datapoollocal/LocalDataPoolManager.cpp index dd0096846..e13337da4 100644 --- a/datapoollocal/LocalDataPoolManager.cpp +++ b/datapoollocal/LocalDataPoolManager.cpp @@ -881,6 +881,7 @@ void LocalDataPoolManager::printWarningOrError(sif::OutputTypes outputType, } if(outputType == sif::OutputTypes::OUT_WARNING) { +#if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "LocalDataPoolManager::" << functionName << ": Object ID 0x" << std::setw(8) << std::setfill('0') @@ -889,9 +890,11 @@ void LocalDataPoolManager::printWarningOrError(sif::OutputTypes outputType, #else sif::printWarning("LocalDataPoolManager::%s: Object ID 0x%08x | %s\n", functionName, owner->getObjectId(), errorPrint); -#endif +#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ +#endif /* FSFW_VERBOSE_LEVEL >= 1 */ } else if(outputType == sif::OutputTypes::OUT_ERROR) { +#if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "LocalDataPoolManager::" << functionName << ": Object ID 0x" << std::setw(8) << std::setfill('0') @@ -900,7 +903,8 @@ void LocalDataPoolManager::printWarningOrError(sif::OutputTypes outputType, #else sif::printError("LocalDataPoolManager::%s: Object ID 0x%08x | %s\n", functionName, owner->getObjectId(), errorPrint); -#endif +#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ +#endif /* FSFW_VERBOSE_LEVEL >= 1 */ } } diff --git a/datapoollocal/LocalPoolDataSetBase.cpp b/datapoollocal/LocalPoolDataSetBase.cpp index d5c0556cf..00293645b 100644 --- a/datapoollocal/LocalPoolDataSetBase.cpp +++ b/datapoollocal/LocalPoolDataSetBase.cpp @@ -51,6 +51,7 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(sid_t sid, AccessPoolManagerIF* accessor = HasLocalDpIFUserAttorney::getAccessorHandle(hkOwner); if(accessor != nullptr) { mutexIfSingleDataCreator = accessor->getLocalPoolMutex(); + poolManager = accessor->getPoolManagerHandle(); } } diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index a1ad95483..35d34bf9b 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -435,8 +435,7 @@ ReturnValue_t DeviceHandlerBase::insertInReplyMap(DeviceCommandId_t replyId, } } -ReturnValue_t DeviceHandlerBase::insertInCommandMap( - DeviceCommandId_t deviceCommand) { +ReturnValue_t DeviceHandlerBase::insertInCommandMap(DeviceCommandId_t deviceCommand) { DeviceCommandInfo info; info.expectedReplies = 0; info.isExecuting = false; @@ -701,13 +700,11 @@ void DeviceHandlerBase::parseReply(const uint8_t* receivedData, ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; DeviceCommandId_t foundId = DeviceHandlerIF::NO_COMMAND_ID; size_t foundLen = 0; - // The loop may not execute more often than the number of received bytes - // (worst case). This approach avoids infinite loops due to buggy - // scanForReply routines. + /* The loop may not execute more often than the number of received bytes + (worst case). This approach avoids infinite loops due to buggy scanForReply routines. */ uint32_t remainingLength = receivedDataLen; for (uint32_t count = 0; count < receivedDataLen; count++) { - result = scanForReply(receivedData, remainingLength, &foundId, - &foundLen); + result = scanForReply(receivedData, remainingLength, &foundId, &foundLen); switch (result) { case RETURN_OK: handleReply(receivedData, foundId, foundLen); @@ -790,9 +787,9 @@ void DeviceHandlerBase::handleReply(const uint8_t* receivedData, replyToReply(iter, result); } else { - // Other completion failure messages are created by timeout. - // Powering down the device might take some time during which periodic - // replies may still come in. + /* Other completion failure messages are created by timeout. + Powering down the device might take some time during which periodic + replies may still come in. */ if (mode != _MODE_WAIT_OFF) { triggerEvent(DEVICE_UNREQUESTED_REPLY, foundId); } diff --git a/osal/host/QueueMapManager.cpp b/osal/host/QueueMapManager.cpp index 7ffd47583..9fb8b7a30 100644 --- a/osal/host/QueueMapManager.cpp +++ b/osal/host/QueueMapManager.cpp @@ -18,17 +18,19 @@ QueueMapManager* QueueMapManager::instance() { ReturnValue_t QueueMapManager::addMessageQueue( MessageQueueIF* queueToInsert, MessageQueueId_t* id) { - // Not thread-safe, but it is assumed all message queues are created - // at software initialization now. If this is to be made thread-safe in - // the future, it propably would be sufficient to lock the increment - // operation here + /* Not thread-safe, but it is assumed all message queues are created at software initialization + now. If this is to be made thread-safe in the future, it propably would be sufficient to lock + the increment operation here. */ uint32_t currentId = queueCounter++; auto returnPair = queueMap.emplace(currentId, queueToInsert); if(not returnPair.second) { - // this should never happen for the atomic variable. + /* This should never happen for the atomic variable. */ #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "QueueMapManager: This ID is already inside the map!" - << std::endl; + sif::error << "QueueMapManager::addMessageQueue This ID is already " + "inside the map!" << std::endl; +#else + sif::printError("QueueMapManager::addMessageQueue This ID is already " + "inside the map!\n"); #endif return HasReturnvaluesIF::RETURN_FAILED; } @@ -47,8 +49,11 @@ MessageQueueIF* QueueMapManager::getMessageQueue( } else { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "QueueMapManager::getQueueHandle: The ID " << - messageQueueId << " does not exists in the map" << std::endl; + sif::warning << "QueueMapManager::getQueueHandle: The ID " << messageQueueId << + " does not exists in the map!" << std::endl; +#else + sif::printWarning("QueueMapManager::getQueueHandle: The ID %d does not exist in the map!\n", + messageQueueId); #endif return nullptr; } diff --git a/osal/host/QueueMapManager.h b/osal/host/QueueMapManager.h index d7d5c9154..3610ca638 100644 --- a/osal/host/QueueMapManager.h +++ b/osal/host/QueueMapManager.h @@ -36,7 +36,7 @@ public: private: //! External instantiation is forbidden. QueueMapManager(); - uint32_t queueCounter = 1; + uint32_t queueCounter = 0; MutexIF* mapLock; QueueMap queueMap; static QueueMapManager* mqManagerInstance;