From 0514ab4d050628773b7279cccf5880593bb3ee3c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 15 Jan 2021 18:15:52 +0100 Subject: [PATCH 01/11] doc --- serviceinterface/ServiceInterfaceStream.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/serviceinterface/ServiceInterfaceStream.h b/serviceinterface/ServiceInterfaceStream.h index e3c0ea7a..0ea44f0b 100644 --- a/serviceinterface/ServiceInterfaceStream.h +++ b/serviceinterface/ServiceInterfaceStream.h @@ -39,6 +39,11 @@ public: */ std::string* getPreamble(); + /** + * Can be used to determine if the stream was configured to add CR characters in addition + * to newline characters. + * @return + */ bool crAdditionEnabled() const; protected: From aa7ea35b80e86c3d5e7d8b2bb0f374b55480d351 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 16 Jan 2021 14:24:59 +0100 Subject: [PATCH 02/11] cyan instead of magenta for debug now --- serviceinterface/ServiceInterfaceBuffer.cpp | 2 +- serviceinterface/ServiceInterfacePrinter.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/serviceinterface/ServiceInterfaceBuffer.cpp b/serviceinterface/ServiceInterfaceBuffer.cpp index 3f624564..ccc051c3 100644 --- a/serviceinterface/ServiceInterfaceBuffer.cpp +++ b/serviceinterface/ServiceInterfaceBuffer.cpp @@ -29,7 +29,7 @@ ServiceInterfaceBuffer::ServiceInterfaceBuffer(std::string setMessage, #if FSFW_COLORED_OUTPUT == 1 if(setMessage.find("DEBUG") != std::string::npos) { - colorPrefix = sif::ANSI_COLOR_MAGENTA; + colorPrefix = sif::ANSI_COLOR_CYAN; } else if(setMessage.find("INFO") != std::string::npos) { colorPrefix = sif::ANSI_COLOR_GREEN; diff --git a/serviceinterface/ServiceInterfacePrinter.cpp b/serviceinterface/ServiceInterfacePrinter.cpp index a12f49e3..ce797f1c 100644 --- a/serviceinterface/ServiceInterfacePrinter.cpp +++ b/serviceinterface/ServiceInterfacePrinter.cpp @@ -45,7 +45,7 @@ void fsfwPrint(sif::PrintLevel printType, const char* fmt, va_list arg) { len += sprintf(bufferPosition, sif::ANSI_COLOR_GREEN); } else if(printType == sif::PrintLevel::DEBUG_LEVEL) { - len += sprintf(bufferPosition, sif::ANSI_COLOR_MAGENTA); + len += sprintf(bufferPosition, sif::ANSI_COLOR_CYAN); } else if(printType == sif::PrintLevel::WARNING_LEVEL) { len += sprintf(bufferPosition, sif::ANSI_COLOR_YELLOW); From 2c21400aed50fab873a4ca75be24777bfef00bc7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 18 Jan 2021 19:43:44 +0100 Subject: [PATCH 03/11] important bugfix --- action/ActionMessage.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/action/ActionMessage.cpp b/action/ActionMessage.cpp index b0bcabaa..4e56feea 100644 --- a/action/ActionMessage.cpp +++ b/action/ActionMessage.cpp @@ -1,3 +1,4 @@ +#include #include "ActionMessage.h" #include "../objectmanager/ObjectManagerIF.h" #include "../storagemanager/StorageManagerIF.h" @@ -53,7 +54,7 @@ void ActionMessage::setDataReply(CommandMessage* message, ActionId_t actionId, void ActionMessage::setCompletionReply(CommandMessage* message, ActionId_t fid, ReturnValue_t result) { - if (result == HasReturnvaluesIF::RETURN_OK) { + if (result == HasReturnvaluesIF::RETURN_OK or result == HasActionsIF::EXECUTION_FINISHED) { message->setCommand(COMPLETION_SUCCESS); } else { message->setCommand(COMPLETION_FAILED); From 74def820c6ee13c81c08fa799785d75a14f88baa Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 18 Jan 2021 20:03:03 +0100 Subject: [PATCH 04/11] improved naming convention --- storagemanager/LocalPool.cpp | 12 ++++++++---- storagemanager/LocalPool.h | 27 +++++++++++++++++---------- storagemanager/StorageManagerIF.h | 10 ++++++++-- 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/storagemanager/LocalPool.cpp b/storagemanager/LocalPool.cpp index cc7c9266..b72f21ca 100644 --- a/storagemanager/LocalPool.cpp +++ b/storagemanager/LocalPool.cpp @@ -348,16 +348,20 @@ void LocalPool::getFillCount(uint8_t *buffer, uint8_t *bytesWritten) { } -void LocalPool::clearPage(max_pools_t pageIndex) { - if(pageIndex >= NUMBER_OF_POOLS) { +void LocalPool::clearPool(max_pools_t poolIndex) { + if(poolIndex >= NUMBER_OF_POOLS) { return; } // Mark the storage as free - for(auto& size: sizeLists[pageIndex]) { + for(auto& size: sizeLists[poolIndex]) { size = STORAGE_FREE; } // Set all the page content to 0. - std::memset(store[pageIndex].data(), 0, elementSizes[pageIndex]); + std::memset(store[poolIndex].data(), 0, elementSizes[poolIndex]); +} + +LocalPool::max_pools_t LocalPool::getNumberOfPools() const { + return NUMBER_OF_POOLS; } diff --git a/storagemanager/LocalPool.h b/storagemanager/LocalPool.h index db771152..4d3994bb 100644 --- a/storagemanager/LocalPool.h +++ b/storagemanager/LocalPool.h @@ -60,15 +60,6 @@ public: }; using LocalPoolConfig = std::multiset; - /** - * @brief This definition generally sets the number of - * different sized pools. It is derived from the number of pairs - * inside the LocalPoolConfig set on object creation. - * @details - * This must be less than the maximum number of pools (currently 0xff). - */ - const max_pools_t NUMBER_OF_POOLS; - /** * @brief This is the default constructor for a pool manager instance. * @details @@ -143,9 +134,15 @@ public: void getFillCount(uint8_t* buffer, uint8_t* bytesWritten) override; void clearStore() override; - void clearPage(max_pools_t pageIndex) override; + void clearPool(max_pools_t poolIndex) override; ReturnValue_t initialize() override; + + /** + * Get number pools. Each pool has pages with a specific bucket size. + * @return + */ + max_pools_t getNumberOfPools() const override; protected: /** * With this helper method, a free element of @c size is reserved. @@ -158,6 +155,16 @@ protected: store_address_t* address, bool ignoreFault); private: + + /** + * @brief This definition generally sets the number of + * different sized pools. It is derived from the number of pairs + * inside the LocalPoolConfig set on object creation. + * @details + * This must be less than the maximum number of pools (currently 0xff). + */ + const max_pools_t NUMBER_OF_POOLS; + /** * Indicates that this element is free. * This value limits the maximum size of a pool. diff --git a/storagemanager/StorageManagerIF.h b/storagemanager/StorageManagerIF.h index 62251933..cd878c6f 100644 --- a/storagemanager/StorageManagerIF.h +++ b/storagemanager/StorageManagerIF.h @@ -171,10 +171,10 @@ public: virtual void clearStore() = 0; /** - * Clears a page in the store. Use with care! + * Clears a pool in the store with the given pool index. Use with care! * @param pageIndex */ - virtual void clearPage(uint8_t pageIndex) = 0; + virtual void clearPool(uint8_t poolIndex) = 0; /** * Get the fill count of the pool. The exact form will be implementation @@ -185,6 +185,12 @@ public: virtual void getFillCount(uint8_t* buffer, uint8_t* bytesWritten) = 0; virtual size_t getTotalSize(size_t* additionalSize) = 0; + + /** + * Get number of pools. + * @return + */ + virtual max_pools_t getNumberOfPools() const = 0; }; #endif /* FSFW_STORAGEMANAGER_STORAGEMANAGERIF_H_ */ From f7b70984c19ef8752bfef7173a4cc12a3c352acb Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 18 Jan 2021 20:20:01 +0100 Subject: [PATCH 05/11] updated doc --- storagemanager/StorageManagerIF.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/storagemanager/StorageManagerIF.h b/storagemanager/StorageManagerIF.h index cd878c6f..7aeca5d3 100644 --- a/storagemanager/StorageManagerIF.h +++ b/storagemanager/StorageManagerIF.h @@ -177,10 +177,13 @@ public: virtual void clearPool(uint8_t poolIndex) = 0; /** - * Get the fill count of the pool. The exact form will be implementation - * dependant. + * Get the fill count of the pool. Each character inside the provided + * buffer will be assigned to a rounded percentage fill count for each + * page. The last written byte (at the index bytesWritten - 1) + * will contain the total fill count of the pool as a mean of the + * percentages of single pages. * @param buffer - * @param bytesWritten + * @param maxSize */ virtual void getFillCount(uint8_t* buffer, uint8_t* bytesWritten) = 0; From f4a60a03236da519ff89ef0a4ecc829e6789df23 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 19 Jan 2021 14:37:52 +0100 Subject: [PATCH 06/11] less confusing code --- events/EventManager.cpp | 1 + events/EventManagerIF.h | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/events/EventManager.cpp b/events/EventManager.cpp index e25e574f..5b2b31b5 100644 --- a/events/EventManager.cpp +++ b/events/EventManager.cpp @@ -6,6 +6,7 @@ #include "../ipc/QueueFactory.h" #include "../ipc/MutexFactory.h" +MessageQueueId_t EventManagerIF::eventmanagerQueue = MessageQueueIF::NO_QUEUE; // If one checks registerListener calls, there are around 40 (to max 50) // objects registering for certain events. diff --git a/events/EventManagerIF.h b/events/EventManagerIF.h index 253e6910..ea22f8ae 100644 --- a/events/EventManagerIF.h +++ b/events/EventManagerIF.h @@ -1,11 +1,12 @@ -#ifndef EVENTMANAGERIF_H_ -#define EVENTMANAGERIF_H_ +#ifndef FSFW_EVENTS_EVENTMANAGERIF_H_ +#define FSFW_EVENTS_EVENTMANAGERIF_H_ #include "EventMessage.h" #include "eventmatching/eventmatching.h" #include "../objectmanager/ObjectManagerIF.h" #include "../ipc/MessageQueueSenderIF.h" #include "../ipc/MessageQueueIF.h" +#include "../serviceinterface/ServiceInterface.h" class EventManagerIF { public: @@ -41,11 +42,19 @@ public: static void triggerEvent(EventMessage* message, MessageQueueId_t sentFrom = 0) { - static MessageQueueId_t eventmanagerQueue = MessageQueueIF::NO_QUEUE; if (eventmanagerQueue == MessageQueueIF::NO_QUEUE) { EventManagerIF *eventmanager = objectManager->get( objects::EVENT_MANAGER); if (eventmanager == nullptr) { +#if FSFW_VERBOSE_LEVEL >= 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::warning << "EventManagerIF::triggerEvent: EventManager invalid or not found!" + << std::endl; +#else + sif::printWarning("EventManagerIF::triggerEvent: " + "EventManager invalid or not found!"); +#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ +#endif /* FSFW_VERBOSE_LEVEL >= 1 */ return; } eventmanagerQueue = eventmanager->getEventReportQueue(); @@ -53,6 +62,10 @@ public: MessageQueueSenderIF::sendMessage(eventmanagerQueue, message, sentFrom); } +private: + //! Initialized by EventManager (C++11 does not allow header-only static member initialization). + static MessageQueueId_t eventmanagerQueue; + }; -#endif /* EVENTMANAGERIF_H_ */ +#endif /* FSFW_EVENTS_EVENTMANAGERIF_H_ */ From b6888a81855159796594f128eb81e335a3d19872 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 19 Jan 2021 15:04:47 +0100 Subject: [PATCH 07/11] better naming --- storagemanager/LocalPool.cpp | 36 +++++++++++++++---------------- storagemanager/LocalPool.h | 18 ++++++++-------- storagemanager/StorageManagerIF.h | 10 ++++----- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/storagemanager/LocalPool.cpp b/storagemanager/LocalPool.cpp index b72f21ca..2742de77 100644 --- a/storagemanager/LocalPool.cpp +++ b/storagemanager/LocalPool.cpp @@ -5,15 +5,15 @@ LocalPool::LocalPool(object_id_t setObjectId, const LocalPoolConfig& poolConfig, bool registered, bool spillsToHigherPools): SystemObject(setObjectId, registered), - NUMBER_OF_POOLS(poolConfig.size()), + NUMBER_OF_SUBPOOLS(poolConfig.size()), spillsToHigherPools(spillsToHigherPools) { - if(NUMBER_OF_POOLS == 0) { + if(NUMBER_OF_SUBPOOLS == 0) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "LocalPool::LocalPool: Passed pool configuration is " << " invalid!" << std::endl; #endif } - max_pools_t index = 0; + max_subpools_t index = 0; for (const auto& currentPoolConfig: poolConfig) { this->numberOfElements[index] = currentPoolConfig.first; this->elementSizes[index] = currentPoolConfig.second; @@ -98,7 +98,7 @@ ReturnValue_t LocalPool::modifyData(store_address_t storeId, ReturnValue_t LocalPool::modifyData(store_address_t storeId, uint8_t **packetPtr, size_t *size) { ReturnValue_t status = RETURN_FAILED; - if (storeId.poolIndex >= NUMBER_OF_POOLS) { + if (storeId.poolIndex >= NUMBER_OF_SUBPOOLS) { return ILLEGAL_STORAGE_ID; } if ((storeId.packetIndex >= numberOfElements[storeId.poolIndex])) { @@ -151,7 +151,7 @@ ReturnValue_t LocalPool::deleteData(uint8_t *ptr, size_t size, store_address_t *storeId) { store_address_t localId; ReturnValue_t result = ILLEGAL_ADDRESS; - for (uint16_t n = 0; n < NUMBER_OF_POOLS; n++) { + for (uint16_t n = 0; n < NUMBER_OF_SUBPOOLS; n++) { //Not sure if new allocates all stores in order. so better be careful. if ((store[n].data() <= ptr) and (&store[n][numberOfElements[n]*elementSizes[n]] > ptr)) { @@ -192,7 +192,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++) { + for (uint8_t count = 0; count < NUMBER_OF_SUBPOOLS; count++) { if (elementSizes[count] >= STORAGE_FREE) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "LocalPool::initialize: Pool is too large! " @@ -263,8 +263,8 @@ void LocalPool::write(store_address_t storeId, const uint8_t *data, sizeLists[storeId.poolIndex][storeId.packetIndex] = size; } -LocalPool::size_type LocalPool::getPageSize(max_pools_t poolIndex) { - if (poolIndex < NUMBER_OF_POOLS) { +LocalPool::size_type LocalPool::getPageSize(max_subpools_t poolIndex) { + if (poolIndex < NUMBER_OF_SUBPOOLS) { return elementSizes[poolIndex]; } else { @@ -278,7 +278,7 @@ void LocalPool::setToSpillToHigherPools(bool enable) { ReturnValue_t LocalPool::getPoolIndex(size_t packetSize, uint16_t *poolIndex, uint16_t startAtIndex) { - for (uint16_t n = startAtIndex; n < NUMBER_OF_POOLS; n++) { + for (uint16_t n = startAtIndex; n < NUMBER_OF_SUBPOOLS; n++) { #if FSFW_VERBOSE_PRINTOUT == 2 #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "LocalPool " << getObjectId() << "::getPoolIndex: Pool: " @@ -313,7 +313,7 @@ ReturnValue_t LocalPool::findEmpty(n_pool_elem_t poolIndex, uint16_t *element) { size_t LocalPool::getTotalSize(size_t* additionalSize) { size_t totalSize = 0; size_t sizesSize = 0; - for(uint8_t idx = 0; idx < NUMBER_OF_POOLS; idx ++) { + for(uint8_t idx = 0; idx < NUMBER_OF_SUBPOOLS; idx ++) { totalSize += elementSizes[idx] * numberOfElements[idx]; sizesSize += numberOfElements[idx] * sizeof(size_type); } @@ -331,7 +331,7 @@ void LocalPool::getFillCount(uint8_t *buffer, uint8_t *bytesWritten) { uint16_t reservedHits = 0; uint8_t idx = 0; uint16_t sum = 0; - for(; idx < NUMBER_OF_POOLS; idx ++) { + for(; idx < NUMBER_OF_SUBPOOLS; idx ++) { for(const auto& size: sizeLists[idx]) { if(size != STORAGE_FREE) { reservedHits++; @@ -343,25 +343,25 @@ void LocalPool::getFillCount(uint8_t *buffer, uint8_t *bytesWritten) { sum += buffer[idx]; reservedHits = 0; } - buffer[idx] = sum / NUMBER_OF_POOLS; + buffer[idx] = sum / NUMBER_OF_SUBPOOLS; *bytesWritten += 1; } -void LocalPool::clearPool(max_pools_t poolIndex) { - if(poolIndex >= NUMBER_OF_POOLS) { +void LocalPool::clearSubPool(max_subpools_t subpoolIndex) { + if(subpoolIndex >= NUMBER_OF_SUBPOOLS) { return; } // Mark the storage as free - for(auto& size: sizeLists[poolIndex]) { + for(auto& size: sizeLists[subpoolIndex]) { size = STORAGE_FREE; } // Set all the page content to 0. - std::memset(store[poolIndex].data(), 0, elementSizes[poolIndex]); + std::memset(store[subpoolIndex].data(), 0, elementSizes[subpoolIndex]); } -LocalPool::max_pools_t LocalPool::getNumberOfPools() const { - return NUMBER_OF_POOLS; +LocalPool::max_subpools_t LocalPool::getNumberOfSubPools() const { + return NUMBER_OF_SUBPOOLS; } diff --git a/storagemanager/LocalPool.h b/storagemanager/LocalPool.h index 4d3994bb..a58f911b 100644 --- a/storagemanager/LocalPool.h +++ b/storagemanager/LocalPool.h @@ -134,15 +134,15 @@ public: void getFillCount(uint8_t* buffer, uint8_t* bytesWritten) override; void clearStore() override; - void clearPool(max_pools_t poolIndex) override; + void clearSubPool(max_subpools_t poolIndex) override; ReturnValue_t initialize() override; /** - * Get number pools. Each pool has pages with a specific bucket size. + * Get number sub pools. Each pool has pages with a specific bucket size. * @return */ - max_pools_t getNumberOfPools() const override; + max_subpools_t getNumberOfSubPools() const override; protected: /** * With this helper method, a free element of @c size is reserved. @@ -163,7 +163,7 @@ private: * @details * This must be less than the maximum number of pools (currently 0xff). */ - const max_pools_t NUMBER_OF_POOLS; + const max_subpools_t NUMBER_OF_SUBPOOLS; /** * Indicates that this element is free. @@ -177,20 +177,20 @@ private: * must be set in ascending order on construction. */ std::vector elementSizes = - std::vector(NUMBER_OF_POOLS); + std::vector(NUMBER_OF_SUBPOOLS); /** * @brief n_elements stores the number of elements per pool. * @details These numbers are maintained for internal pool management. */ std::vector numberOfElements = - std::vector(NUMBER_OF_POOLS); + std::vector(NUMBER_OF_SUBPOOLS); /** * @brief store represents the actual memory pool. * @details It is an array of pointers to memory, which was allocated with * a @c new call on construction. */ std::vector> store = - std::vector>(NUMBER_OF_POOLS); + std::vector>(NUMBER_OF_SUBPOOLS); /** * @brief The size_list attribute stores the size values of every pool element. @@ -198,7 +198,7 @@ private: * is also dynamically allocated there. */ std::vector> sizeLists = - std::vector>(NUMBER_OF_POOLS); + std::vector>(NUMBER_OF_SUBPOOLS); //! A variable to determine whether higher n pools are used if //! the store is full. @@ -217,7 +217,7 @@ private: * @param pool_index The pool in which to look. * @return Returns the size of an element or 0. */ - size_type getPageSize(max_pools_t poolIndex); + size_type getPageSize(max_subpools_t poolIndex); /** * @brief This helper method looks up a fitting pool for a given size. diff --git a/storagemanager/StorageManagerIF.h b/storagemanager/StorageManagerIF.h index 7aeca5d3..da7ce01d 100644 --- a/storagemanager/StorageManagerIF.h +++ b/storagemanager/StorageManagerIF.h @@ -29,7 +29,7 @@ using ConstAccessorPair = std::pair; class StorageManagerIF : public HasReturnvaluesIF { public: using size_type = size_t; - using max_pools_t = uint8_t; + using max_subpools_t = uint8_t; static const uint8_t INTERFACE_ID = CLASS_ID::STORAGE_MANAGER_IF; //!< The unique ID for return codes for this interface. static const ReturnValue_t DATA_TOO_LARGE = MAKE_RETURN_CODE(1); //!< This return code indicates that the data to be stored is too large for the store. @@ -149,10 +149,10 @@ public: virtual ReturnValue_t modifyData(store_address_t packet_id, uint8_t** packet_ptr, size_t* size) = 0; /** - * This method reserves an element of \c size. + * This method reserves an element of @c size. * * It returns the packet id of this element as well as a direct pointer to the - * data of the element. It must be assured that exactly \c size data is + * data of the element. It must be assured that exactly @c size data is * written to p_data! * @param storageId A pointer to the storageId to retrieve. * @param size The size of the space to be reserved. @@ -174,7 +174,7 @@ public: * Clears a pool in the store with the given pool index. Use with care! * @param pageIndex */ - virtual void clearPool(uint8_t poolIndex) = 0; + virtual void clearSubPool(uint8_t poolIndex) = 0; /** * Get the fill count of the pool. Each character inside the provided @@ -193,7 +193,7 @@ public: * Get number of pools. * @return */ - virtual max_pools_t getNumberOfPools() const = 0; + virtual max_subpools_t getNumberOfSubPools() const = 0; }; #endif /* FSFW_STORAGEMANAGER_STORAGEMANAGERIF_H_ */ From ca22ff5d8e8b9ab1e9fd3e6ddffccb52d44509ca Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 19 Jan 2021 15:06:21 +0100 Subject: [PATCH 08/11] more renaming --- storagemanager/LocalPool.cpp | 16 ++++++++-------- storagemanager/LocalPool.h | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/storagemanager/LocalPool.cpp b/storagemanager/LocalPool.cpp index 2742de77..2b733548 100644 --- a/storagemanager/LocalPool.cpp +++ b/storagemanager/LocalPool.cpp @@ -127,7 +127,7 @@ ReturnValue_t LocalPool::deleteData(store_address_t storeId) { #endif ReturnValue_t status = RETURN_OK; - size_type pageSize = getPageSize(storeId.poolIndex); + size_type pageSize = getSubpoolElementSize(storeId.poolIndex); if ((pageSize != 0) and (storeId.packetIndex < numberOfElements[storeId.poolIndex])) { uint16_t packetPosition = getRawPosition(storeId); @@ -217,7 +217,7 @@ void LocalPool::clearStore() { ReturnValue_t LocalPool::reserveSpace(const size_t size, store_address_t *storeId, bool ignoreFault) { - ReturnValue_t status = getPoolIndex(size, &storeId->poolIndex); + ReturnValue_t status = getSubPoolIndex(size, &storeId->poolIndex); if (status != RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "LocalPool( " << std::hex << getObjectId() << std::dec @@ -227,7 +227,7 @@ ReturnValue_t LocalPool::reserveSpace(const size_t size, } status = findEmpty(storeId->poolIndex, &storeId->packetIndex); while (status != RETURN_OK && spillsToHigherPools) { - status = getPoolIndex(size, &storeId->poolIndex, storeId->poolIndex + 1); + status = getSubPoolIndex(size, &storeId->poolIndex, storeId->poolIndex + 1); if (status != RETURN_OK) { //We don't find any fitting pool anymore. break; @@ -263,9 +263,9 @@ void LocalPool::write(store_address_t storeId, const uint8_t *data, sizeLists[storeId.poolIndex][storeId.packetIndex] = size; } -LocalPool::size_type LocalPool::getPageSize(max_subpools_t poolIndex) { - if (poolIndex < NUMBER_OF_SUBPOOLS) { - return elementSizes[poolIndex]; +LocalPool::size_type LocalPool::getSubpoolElementSize(max_subpools_t subpoolIndex) { + if (subpoolIndex < NUMBER_OF_SUBPOOLS) { + return elementSizes[subpoolIndex]; } else { return 0; @@ -276,7 +276,7 @@ void LocalPool::setToSpillToHigherPools(bool enable) { this->spillsToHigherPools = enable; } -ReturnValue_t LocalPool::getPoolIndex(size_t packetSize, uint16_t *poolIndex, +ReturnValue_t LocalPool::getSubPoolIndex(size_t packetSize, uint16_t *subpoolIndex, uint16_t startAtIndex) { for (uint16_t n = startAtIndex; n < NUMBER_OF_SUBPOOLS; n++) { #if FSFW_VERBOSE_PRINTOUT == 2 @@ -286,7 +286,7 @@ ReturnValue_t LocalPool::getPoolIndex(size_t packetSize, uint16_t *poolIndex, #endif #endif if (elementSizes[n] >= packetSize) { - *poolIndex = n; + *subpoolIndex = n; return RETURN_OK; } } diff --git a/storagemanager/LocalPool.h b/storagemanager/LocalPool.h index a58f911b..6a666485 100644 --- a/storagemanager/LocalPool.h +++ b/storagemanager/LocalPool.h @@ -217,7 +217,7 @@ private: * @param pool_index The pool in which to look. * @return Returns the size of an element or 0. */ - size_type getPageSize(max_subpools_t poolIndex); + size_type getSubpoolElementSize(max_subpools_t subpoolIndex); /** * @brief This helper method looks up a fitting pool for a given size. @@ -228,7 +228,7 @@ private: * @return - @c RETURN_OK on success, * - @c DATA_TOO_LARGE otherwise. */ - ReturnValue_t getPoolIndex(size_t packetSize, uint16_t* poolIndex, + ReturnValue_t getSubPoolIndex(size_t packetSize, uint16_t* subpoolIndex, uint16_t startAtIndex = 0); /** * @brief This helper method calculates the true array position in store From 583d354fb5af3d68615f6597fb3ead4f57ce6f89 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 19 Jan 2021 15:48:50 +0100 Subject: [PATCH 09/11] removed include --- action/ActionMessage.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/action/ActionMessage.cpp b/action/ActionMessage.cpp index 34b7913e..1c00dee0 100644 --- a/action/ActionMessage.cpp +++ b/action/ActionMessage.cpp @@ -1,4 +1,3 @@ -#include #include "ActionMessage.h" #include "HasActionsIF.h" From 7b82a7c1a787f68cb39cd565db418d79e73e47ef Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 22 Jan 2021 12:21:45 +0100 Subject: [PATCH 10/11] added stopwatch printf support --- timemanager/Stopwatch.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/timemanager/Stopwatch.cpp b/timemanager/Stopwatch.cpp index f79d2eeb..5d67e6c1 100644 --- a/timemanager/Stopwatch.cpp +++ b/timemanager/Stopwatch.cpp @@ -1,5 +1,5 @@ #include "Stopwatch.h" -#include "../serviceinterface/ServiceInterfaceStream.h" +#include "../serviceinterface/ServiceInterface.h" #include Stopwatch::Stopwatch(bool displayOnDestruction, @@ -28,9 +28,13 @@ double Stopwatch::stopSeconds() { void Stopwatch::display() { if(displayMode == StopwatchDisplayMode::MILLIS) { + dur_millis_t timeMillis = static_cast( + elapsedTime.tv_sec * 1000 + elapsedTime.tv_usec / 1000); #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "Stopwatch: Operation took " << (elapsedTime.tv_sec * 1000 + - elapsedTime.tv_usec / 1000) << " milliseconds" << std::endl; + sif::info << "Stopwatch: Operation took " << timeMillis << " milliseconds" << std::endl; +#else + sif::printInfo("Stopwatch: Operation took %lu milliseconds\n\r", + static_cast(timeMillis)); #endif } else if(displayMode == StopwatchDisplayMode::SECONDS) { @@ -38,6 +42,9 @@ void Stopwatch::display() { sif::info <<"Stopwatch: Operation took " << std::setprecision(3) << std::fixed << timevalOperations::toDouble(elapsedTime) << " seconds" << std::endl; +#else + sif::printInfo("Stopwatch: Operation took %.3f seconds\n\r", + static_cast(timevalOperations::toDouble(elapsedTime))); #endif } } From bdd1bdb080c06ca9d26cfb946622cd0ad6e95bb4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 24 Jan 2021 16:53:58 +0100 Subject: [PATCH 11/11] bugfix --- housekeeping/HousekeepingMessage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/housekeeping/HousekeepingMessage.cpp b/housekeeping/HousekeepingMessage.cpp index 221f0a6f..5d732961 100644 --- a/housekeeping/HousekeepingMessage.cpp +++ b/housekeeping/HousekeepingMessage.cpp @@ -176,7 +176,7 @@ void HousekeepingMessage::setUpdateNotificationVariableCommand( void HousekeepingMessage::setUpdateSnapshotSetCommand(CommandMessage *command, sid_t sid, store_address_t storeId) { - command->setCommand(UPDATE_SNAPSHOT_VARIABLE); + command->setCommand(UPDATE_SNAPSHOT_SET); setSid(command, sid); command->setParameter3(storeId.raw); }