From 403d83f32cedcd6c655e95e25e4f421df9e94971 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 3 Sep 2020 13:01:14 +0200 Subject: [PATCH 001/192] removed commented out code --- devicehandlers/DeviceHandlerBase.cpp | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index 820a2cce..45cf3781 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -1129,19 +1129,6 @@ ReturnValue_t DeviceHandlerBase::handleDeviceHandlerMessage( } replyReturnvalueToCommand(RETURN_OK); return RETURN_OK; -// case DeviceHandlerMessage::CMD_SWITCH_IOBOARD: -// if (mode != MODE_OFF) { -// replyReturnvalueToCommand(WRONG_MODE_FOR_COMMAND); -// } else { -// result = switchCookieChannel( -// DeviceHandlerMessage::getIoBoardObjectId(message)); -// if (result == RETURN_OK) { -// replyReturnvalueToCommand(RETURN_OK); -// } else { -// replyReturnvalueToCommand(CANT_SWITCH_IO_ADDRESS); -// } -// } -// return RETURN_OK; case DeviceHandlerMessage::CMD_RAW: if ((mode != MODE_RAW)) { DeviceHandlerMessage::clear(message); From 31c16382fc5d40cccc9ca3a58a8a60cef5d7a04f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 4 Sep 2020 14:28:43 +0200 Subject: [PATCH 002/192] took over changed for fixed slot sequence --- osal/FreeRTOS/FixedTimeslotTask.h | 8 +-- tasks/FixedSequenceSlot.cpp | 4 +- tasks/FixedSequenceSlot.h | 9 ++-- tasks/FixedSlotSequence.cpp | 29 ++++++++--- tasks/FixedSlotSequence.h | 81 ++++++++++++++++++------------- 5 files changed, 80 insertions(+), 51 deletions(-) diff --git a/osal/FreeRTOS/FixedTimeslotTask.h b/osal/FreeRTOS/FixedTimeslotTask.h index c46de5b7..7d2cdb70 100644 --- a/osal/FreeRTOS/FixedTimeslotTask.h +++ b/osal/FreeRTOS/FixedTimeslotTask.h @@ -1,7 +1,7 @@ -#ifndef FRAMEWORK_OSAL_FREERTOS_FIXEDTIMESLOTTASK_H_ -#define FRAMEWORK_OSAL_FREERTOS_FIXEDTIMESLOTTASK_H_ +#ifndef FSFW_OSAL_FREERTOS_FIXEDTIMESLOTTASK_H_ +#define FSFW_OSAL_FREERTOS_FIXEDTIMESLOTTASK_H_ -#include "../../osal/FreeRTOS/FreeRTOSTaskIF.h" +#include "FreeRTOSTaskIF.h" #include "../../tasks/FixedSlotSequence.h" #include "../../tasks/FixedTimeslotTaskIF.h" #include "../../tasks/Typedef.h" @@ -98,4 +98,4 @@ protected: void handleMissedDeadline(); }; -#endif /* POLLINGTASK_H_ */ +#endif /* FSFW_OSAL_FREERTOS_FIXEDTIMESLOTTASK_H_ */ diff --git a/tasks/FixedSequenceSlot.cpp b/tasks/FixedSequenceSlot.cpp index d7aeff0a..f5d82178 100644 --- a/tasks/FixedSequenceSlot.cpp +++ b/tasks/FixedSequenceSlot.cpp @@ -1,5 +1,5 @@ -#include "../objectmanager/SystemObjectIF.h" -#include "../tasks/FixedSequenceSlot.h" +#include "FixedSequenceSlot.h" +#include "PeriodicTaskIF.h" #include FixedSequenceSlot::FixedSequenceSlot(object_id_t handlerId, uint32_t setTime, diff --git a/tasks/FixedSequenceSlot.h b/tasks/FixedSequenceSlot.h index 151173e9..1744ec19 100644 --- a/tasks/FixedSequenceSlot.h +++ b/tasks/FixedSequenceSlot.h @@ -1,8 +1,9 @@ -#ifndef FRAMEWORK_TASKS_FIXEDSEQUENCESLOT_H_ -#define FRAMEWORK_TASKS_FIXEDSEQUENCESLOT_H_ +#ifndef FSFW_TASKS_FIXEDSEQUENCESLOT_H_ +#define FSFW_TASKS_FIXEDSEQUENCESLOT_H_ +#include "ExecutableObjectIF.h" #include "../objectmanager/ObjectManagerIF.h" -#include "../tasks/ExecutableObjectIF.h" + class PeriodicTaskIF; /** @@ -56,4 +57,4 @@ public: }; -#endif /* FIXEDSEQUENCESLOT_H_ */ +#endif /* FSFW_TASKS_FIXEDSEQUENCESLOT_H_ */ diff --git a/tasks/FixedSlotSequence.cpp b/tasks/FixedSlotSequence.cpp index 59859ce5..e5db4301 100644 --- a/tasks/FixedSlotSequence.cpp +++ b/tasks/FixedSlotSequence.cpp @@ -1,5 +1,5 @@ +#include "FixedSlotSequence.h" #include "../serviceinterface/ServiceInterfaceStream.h" -#include "../tasks/FixedSlotSequence.h" #include FixedSlotSequence::FixedSlotSequence(uint32_t setLengthMs) : @@ -91,21 +91,31 @@ void FixedSlotSequence::addSlot(object_id_t componentId, uint32_t slotTimeMs, ReturnValue_t FixedSlotSequence::checkSequence() const { if(slotList.empty()) { - sif::error << "Fixed Slot Sequence: Slot list is empty!" << std::endl; + sif::error << "FixedSlotSequence::checkSequence:" + << " Slot list is empty!" << std::endl; return HasReturnvaluesIF::RETURN_FAILED; } - uint32_t count = 0; + if(customCheckFunction != nullptr) { + ReturnValue_t result = customCheckFunction(slotList); + if(result != HasReturnvaluesIF::RETURN_OK) { + // Continue for now but print error output. + sif::error << "FixedSlotSequence::checkSequence:" + << " Custom check failed!" << std::endl; + } + } + + uint32_t errorCount = 0; uint32_t time = 0; for(const auto& slot: slotList) { if (slot.executableObject == nullptr) { - count++; + errorCount++; } else if (slot.pollingTimeMs < time) { - sif::error << "FixedSlotSequence::initialize: Time: " + sif::error << "FixedSlotSequence::checkSequence: Time: " << slot.pollingTimeMs << " is smaller than previous with " << time << std::endl; - count++; + errorCount++; } else { // All ok, print slot. @@ -117,7 +127,7 @@ ReturnValue_t FixedSlotSequence::checkSequence() const { } //sif::info << "Number of elements in slot list: " // << slotList.size() << std::endl; - if (count > 0) { + if (errorCount > 0) { return HasReturnvaluesIF::RETURN_FAILED; } return HasReturnvaluesIF::RETURN_OK; @@ -145,3 +155,8 @@ ReturnValue_t FixedSlotSequence::intializeSequenceAfterTaskCreation() const { } return HasReturnvaluesIF::RETURN_OK; } + +void FixedSlotSequence::addCustomCheck(ReturnValue_t + (*customCheckFunction)(const SlotList&)) { + this->customCheckFunction = customCheckFunction; +} diff --git a/tasks/FixedSlotSequence.h b/tasks/FixedSlotSequence.h index 1140dd25..19a05f21 100644 --- a/tasks/FixedSlotSequence.h +++ b/tasks/FixedSlotSequence.h @@ -1,26 +1,30 @@ -#ifndef FRAMEWORK_TASKS_FIXEDSLOTSEQUENCE_H_ -#define FRAMEWORK_TASKS_FIXEDSLOTSEQUENCE_H_ +#ifndef FSFW_TASKS_FIXEDSLOTSEQUENCE_H_ +#define FSFW_TASKS_FIXEDSLOTSEQUENCE_H_ +#include "FixedSequenceSlot.h" #include "../objectmanager/SystemObject.h" -#include "../tasks/FixedSequenceSlot.h" #include /** - * @brief This class is the representation of a Polling Sequence Table in software. + * @brief This class is the representation of a + * Polling Sequence Table in software. * @details * The FixedSlotSequence object maintains the dynamic execution of - * device handler objects. + * objects with stricter timing requirements for the FixedTimeslotTask. * - * The main idea is to create a list of device handlers, to announce all - * handlers to thepolling sequence and to maintain a list of - * polling slot objects. This slot list represents the Polling Sequence Table - * in software. + * The main idea is to create a list of executable objects (for example + * device handlers), to announce all handlers to the polling sequence and to + * maintain a list of polling slot objects. + * This slot list represents the Polling Sequence Table in software. * * Each polling slot contains information to indicate when and - * which device handler shall be executed within a given polling period. - * The sequence is then executed by iterating through this slot list. - * Handlers are invoking by calling a certain function stored in the handler list. + * which executable object shall be executed within a given polling period. + * When adding a slot, a pointer to the executing task, a pointer to the + * executable object and a step number can be passed. The step number will be + * passed to the periodic handler. + * The sequence is executed by iterating through the slot sequence and + * executing the executable object in the correct timeslot. */ class FixedSlotSequence { public: @@ -29,41 +33,44 @@ public: /** * @brief The constructor of the FixedSlotSequence object. - * - * @details The constructor takes two arguments, the period length and the init function. - * * @param setLength The period length, expressed in ms. */ FixedSlotSequence(uint32_t setLengthMs); /** * @brief The destructor of the FixedSlotSequence object. - * - * @details The destructor frees all allocated memory by iterating through the slotList - * and deleting all allocated resources. + * @details + * The destructor frees all allocated memory by iterating through the + * slotList and deleting all allocated resources. */ virtual ~FixedSlotSequence(); /** * @brief This is a method to add an PollingSlot object to slotList. * - * @details Here, a polling slot object is added to the slot list. It is appended - * to the end of the list. The list is currently NOT reordered. - * Afterwards, the iterator current is set to the beginning of the list. - * @param Object ID of the object to add - * @param setTime Value between (0 to 1) * slotLengthMs, when a FixedTimeslotTask - * will be called inside the slot period. - * @param setSequenceId ID which can be used to distinguish - * different task operations + * @details + * Here, a polling slot object is added to the slot list. It is appended + * to the end of the list. The list is currently NOT reordered. + * Afterwards, the iterator current is set to the beginning of the list. + * @param handlerId ID of the object to add + * @param setTime + * Value between (0 to 1) * slotLengthMs, when a FixedTimeslotTask + * will be called inside the slot period. + * @param setSequenceId + * ID which can be used to distinguish different task operations. This + * value will be passed to the executable function. * @param * @param */ void addSlot(object_id_t handlerId, uint32_t setTime, int8_t setSequenceId, - ExecutableObjectIF* executableObject, PeriodicTaskIF* executingTask); + ExecutableObjectIF* executableObject, + PeriodicTaskIF* executingTask); /** - * Checks if the current slot shall be executed immediately after the one before. - * This allows to distinguish between grouped and not grouped handlers. + * @brief Checks if the current slot shall be executed immediately + * after the one before. + * @details + * This allows to distinguish between grouped and separated handlers. * @return - @c true if the slot has the same polling time as the previous * - @c false else */ @@ -128,12 +135,18 @@ public: * @brief Check and initialize slot list. * @details * Checks if timing is ok (must be ascending) and if all handlers were found. - * Also calls any initialization steps which are required after task - * creation. * @return */ ReturnValue_t checkSequence() const; + void addCustomCheck(ReturnValue_t (*customCheckFunction)(const SlotList &)); + + /** + * @brief Perform any initialization steps required after the executing + * task has been created. This function should be called from the + * executing task! + * @return + */ ReturnValue_t intializeSequenceAfterTaskCreation() const; protected: @@ -151,9 +164,9 @@ protected: */ SlotList slotList; - uint32_t lengthMs; + ReturnValue_t (*customCheckFunction)(const SlotList&) = nullptr; - bool isEmpty = false; + uint32_t lengthMs; }; -#endif /* FIXEDSLOTSEQUENCE_H_ */ +#endif /* FSFW_TASKS_FIXEDSLOTSEQUENCE_H_ */ From 6980245c984c69f052c8d1ba2ad1c5c240f50c56 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 4 Sep 2020 14:30:04 +0200 Subject: [PATCH 003/192] added line break --- osal/linux/FixedTimeslotTask.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/osal/linux/FixedTimeslotTask.cpp b/osal/linux/FixedTimeslotTask.cpp index b634b4cf..cffdd1c5 100644 --- a/osal/linux/FixedTimeslotTask.cpp +++ b/osal/linux/FixedTimeslotTask.cpp @@ -63,6 +63,7 @@ void FixedTimeslotTask::taskFunctionality() { } pst.intializeSequenceAfterTaskCreation(); + //The start time for the first entry is read. uint64_t lastWakeTime = getCurrentMonotonicTimeMs(); uint64_t interval = pst.getIntervalToNextSlotMs(); From 9d1f292af0f2973f595b0db09957a45a94782662 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 4 Sep 2020 14:32:32 +0200 Subject: [PATCH 004/192] changed taken over --- osal/linux/FixedTimeslotTask.cpp | 2 +- osal/linux/FixedTimeslotTask.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/osal/linux/FixedTimeslotTask.cpp b/osal/linux/FixedTimeslotTask.cpp index cffdd1c5..247a34ed 100644 --- a/osal/linux/FixedTimeslotTask.cpp +++ b/osal/linux/FixedTimeslotTask.cpp @@ -1,5 +1,5 @@ +#include "FixedTimeslotTask.h" #include "../../serviceinterface/ServiceInterfaceStream.h" -#include "../../osal/linux/FixedTimeslotTask.h" #include diff --git a/osal/linux/FixedTimeslotTask.h b/osal/linux/FixedTimeslotTask.h index 0148922d..5c5c1814 100644 --- a/osal/linux/FixedTimeslotTask.h +++ b/osal/linux/FixedTimeslotTask.h @@ -1,9 +1,9 @@ -#ifndef FRAMEWORK_OSAL_LINUX_FIXEDTIMESLOTTASK_H_ -#define FRAMEWORK_OSAL_LINUX_FIXEDTIMESLOTTASK_H_ +#ifndef FSFW_OSAL_LINUX_FIXEDTIMESLOTTASK_H_ +#define FSFW_OSAL_LINUX_FIXEDTIMESLOTTASK_H_ +#include "PosixThread.h" #include "../../tasks/FixedTimeslotTaskIF.h" #include "../../tasks/FixedSlotSequence.h" -#include "../../osal/linux/PosixThread.h" #include class FixedTimeslotTask: public FixedTimeslotTaskIF, public PosixThread { @@ -74,4 +74,4 @@ private: bool started; }; -#endif /* FRAMEWORK_OSAL_LINUX_FIXEDTIMESLOTTASK_H_ */ +#endif /* FSFW_OSAL_LINUX_FIXEDTIMESLOTTASK_H_ */ From 94b45d7407bd6413926184e8ec8f746fda648cfe Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 4 Sep 2020 14:49:27 +0200 Subject: [PATCH 005/192] changed taken over --- osal/linux/PeriodicPosixTask.cpp | 35 +++++++++++++++++--------------- osal/linux/PeriodicPosixTask.h | 4 ++-- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/osal/linux/PeriodicPosixTask.cpp b/osal/linux/PeriodicPosixTask.cpp index bbf33b01..3c1df6bb 100644 --- a/osal/linux/PeriodicPosixTask.cpp +++ b/osal/linux/PeriodicPosixTask.cpp @@ -1,8 +1,7 @@ #include "../../tasks/ExecutableObjectIF.h" #include "../../serviceinterface/ServiceInterfaceStream.h" -#include "../../osal/linux/PeriodicPosixTask.h" - #include +#include "PeriodicPosixTask.h" PeriodicPosixTask::PeriodicPosixTask(const char* name_, int priority_, size_t stackSize_, uint32_t period_, void(deadlineMissedFunc_)()): @@ -26,14 +25,14 @@ ReturnValue_t PeriodicPosixTask::addComponent(object_id_t object) { ExecutableObjectIF* newObject = objectManager->get( object); if (newObject == nullptr) { - sif::error << "PeriodicTask::addComponent: Invalid object. Make sure" - "it implements ExecutableObjectIF" << std::endl; + sif::error << "PeriodicTask::addComponent: Invalid object. Make sure" + << " it implements ExecutableObjectIF!" << std::endl; return HasReturnvaluesIF::RETURN_FAILED; } objectList.push_back(newObject); newObject->setTaskIF(this); - return newObject->initializeAfterTaskCreation(); + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t PeriodicPosixTask::sleepFor(uint32_t ms) { @@ -49,27 +48,31 @@ ReturnValue_t PeriodicPosixTask::startTask(void) { } void PeriodicPosixTask::taskFunctionality(void) { - if(!started){ + if(not started) { suspend(); } + for (auto const &object: objectList) { + object->initializeAfterTaskCreation(); + } + uint64_t lastWakeTime = getCurrentMonotonicTimeMs(); //The task's "infinite" inner loop is entered. while (1) { - for (ObjectList::iterator it = objectList.begin(); - it != objectList.end(); ++it) { - (*it)->performOperation(); + for (auto const &object: objectList) { + object->performOperation(); } - if(!PosixThread::delayUntil(&lastWakeTime,periodMs)){ + + if(not PosixThread::delayUntil(&lastWakeTime, periodMs)){ char name[20] = {0}; - int status = pthread_getname_np(pthread_self(),name,sizeof(name)); - if(status == 0){ - //sif::error << "PeriodicPosixTask " << name << ": Deadline " - // "missed." << std::endl; + int status = pthread_getname_np(pthread_self(), name, sizeof(name)); + if(status == 0) { + sif::error << "PeriodicPosixTask " << name << ": Deadline " + "missed." << std::endl; } else { - //sif::error << "PeriodicPosixTask X: Deadline missed. " << - // status << std::endl; + sif::error << "PeriodicPosixTask X: Deadline missed. " << + status << std::endl; } if (this->deadlineMissedFunc != nullptr) { this->deadlineMissedFunc(); diff --git a/osal/linux/PeriodicPosixTask.h b/osal/linux/PeriodicPosixTask.h index 38825bbf..ffee236b 100644 --- a/osal/linux/PeriodicPosixTask.h +++ b/osal/linux/PeriodicPosixTask.h @@ -3,7 +3,7 @@ #include "../../tasks/PeriodicTaskIF.h" #include "../../objectmanager/ObjectManagerIF.h" -#include "../../osal/linux/PosixThread.h" +#include "PosixThread.h" #include "../../tasks/ExecutableObjectIF.h" #include @@ -32,7 +32,7 @@ public: * The address of the task object is passed as an argument * to the system call. */ - ReturnValue_t startTask(void) override; + ReturnValue_t startTask() override; /** * Adds an object to the list of objects to be executed. * The objects are executed in the order added. From f4a50677751b01417a476dc1f309b5074e337601 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 4 Sep 2020 14:53:27 +0200 Subject: [PATCH 006/192] update fw class Ids --- returnvalues/FwClassIds.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/returnvalues/FwClassIds.h b/returnvalues/FwClassIds.h index 12877b40..781320e3 100644 --- a/returnvalues/FwClassIds.h +++ b/returnvalues/FwClassIds.h @@ -67,7 +67,7 @@ enum { DLE_ENCODER, //DLEE 61 PUS_PARSER, //PUSP 62 SERIAL_ANALYZER, //SERA 63 - PUS_SERVICE_9, + PUS_SERVICE_9, // PUS9 64 FW_CLASS_ID_COUNT //is actually count + 1 ! }; From 147ab94149e2dff309ea628b5d77e74ed9a58208 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 4 Sep 2020 15:13:32 +0200 Subject: [PATCH 007/192] include guard improvements --- container/SharedRingBuffer.cpp | 2 +- container/SharedRingBuffer.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/container/SharedRingBuffer.cpp b/container/SharedRingBuffer.cpp index 490988e5..800e75d3 100644 --- a/container/SharedRingBuffer.cpp +++ b/container/SharedRingBuffer.cpp @@ -1,4 +1,4 @@ -#include "../container/SharedRingBuffer.h" +#include "SharedRingBuffer.h" #include "../ipc/MutexFactory.h" #include "../ipc/MutexHelper.h" diff --git a/container/SharedRingBuffer.h b/container/SharedRingBuffer.h index 394dcaaa..80c068b3 100644 --- a/container/SharedRingBuffer.h +++ b/container/SharedRingBuffer.h @@ -1,7 +1,7 @@ -#ifndef FRAMEWORK_CONTAINER_SHAREDRINGBUFFER_H_ -#define FRAMEWORK_CONTAINER_SHAREDRINGBUFFER_H_ +#ifndef FSFW_CONTAINER_SHAREDRINGBUFFER_H_ +#define FSFW_CONTAINER_SHAREDRINGBUFFER_H_ -#include "../container/SimpleRingBuffer.h" +#include "SimpleRingBuffer.h" #include "../ipc/MutexIF.h" #include "../objectmanager/SystemObject.h" #include "../timemanager/Clock.h" @@ -65,4 +65,4 @@ private: -#endif /* FRAMEWORK_CONTAINER_SHAREDRINGBUFFER_H_ */ +#endif /* FSFW_CONTAINER_SHAREDRINGBUFFER_H_ */ From fff0131c9b27b25d8705ce42837f432035b51741 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 4 Sep 2020 15:20:07 +0200 Subject: [PATCH 008/192] taken over changes --- health/HealthHelper.cpp | 2 +- health/HealthHelper.h | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/health/HealthHelper.cpp b/health/HealthHelper.cpp index 61718f99..cced11d9 100644 --- a/health/HealthHelper.cpp +++ b/health/HealthHelper.cpp @@ -1,4 +1,4 @@ -#include "../health/HealthHelper.h" +#include "HealthHelper.h" #include "../serviceinterface/ServiceInterfaceStream.h" HealthHelper::HealthHelper(HasHealthIF* owner, object_id_t objectId) : diff --git a/health/HealthHelper.h b/health/HealthHelper.h index d8b81ca9..d1f1945c 100644 --- a/health/HealthHelper.h +++ b/health/HealthHelper.h @@ -1,11 +1,12 @@ -#ifndef FRAMEWORK_HEALTH_HEALTHHELPER_H_ -#define FRAMEWORK_HEALTH_HEALTHHELPER_H_ +#ifndef FSFW_HEALTH_HEALTHHELPER_H_ +#define FSFW_HEALTH_HEALTHHELPER_H_ + +#include "HasHealthIF.h" +#include "HealthMessage.h" +#include "HealthTableIF.h" #include "../events/EventManagerIF.h" #include "../events/EventReportingProxyIF.h" -#include "../health/HasHealthIF.h" -#include "../health/HealthMessage.h" -#include "../health/HealthTableIF.h" #include "../ipc/MessageQueueIF.h" #include "../objectmanager/ObjectManagerIF.h" #include "../returnvalues/HasReturnvaluesIF.h" @@ -118,4 +119,4 @@ private: void handleSetHealthCommand(CommandMessage *message); }; -#endif /* HEALTHHELPER_H_ */ +#endif /* FSFW_HEALTH_HEALTHHELPER_H_ */ From cfa952d9829b4b686ab615b5383c5fa59de285d1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 4 Sep 2020 15:33:36 +0200 Subject: [PATCH 009/192] hybrid iterator same to FSFW --- container/HybridIterator.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/container/HybridIterator.h b/container/HybridIterator.h index 630bae28..8d020cb9 100644 --- a/container/HybridIterator.h +++ b/container/HybridIterator.h @@ -1,8 +1,8 @@ #ifndef FRAMEWORK_CONTAINER_HYBRIDITERATOR_H_ #define FRAMEWORK_CONTAINER_HYBRIDITERATOR_H_ -#include "../container/ArrayList.h" -#include "../container/SinglyLinkedList.h" +#include "ArrayList.h" +#include "SinglyLinkedList.h" template class HybridIterator: public LinkedElement::Iterator, From be89e7ebb73f273077c4211eb01078e01d8f537a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 4 Sep 2020 15:36:53 +0200 Subject: [PATCH 010/192] taken over from upstream with little tweak --- serialize/SerializeIF.h | 81 ++++++++++++++++++++++++++++------------- 1 file changed, 55 insertions(+), 26 deletions(-) diff --git a/serialize/SerializeIF.h b/serialize/SerializeIF.h index 6d5a0dda..3c0540f9 100644 --- a/serialize/SerializeIF.h +++ b/serialize/SerializeIF.h @@ -1,34 +1,19 @@ -#ifndef SERIALIZEIF_H_ -#define SERIALIZEIF_H_ +#ifndef FSFW_SERIALIZE_SERIALIZEIF_H_ +#define FSFW_SERIALIZE_SERIALIZEIF_H_ #include "../returnvalues/HasReturnvaluesIF.h" #include /** * @defgroup serialize Serialization - * Contains serialisation services. + * Contains serialization services. */ /** - * @brief An interface for alle classes which require - * translation of objects data into data streams and vice-versa. + * @brief Translation of objects into data streams and from data streams. * @details - * If the target architecture is little endian (e.g. ARM), any data types - * created might have the wrong endianess if they are to be used for the FSFW. - * Depending on the system architecture, endian correctness must be assured, - * This is important for incoming and outgoing data. The internal handling - * of data should be performed in the native system endianness. - * There are three ways to copy data (with different options to ensure - * endian correctness): - * - * 1. Use the @c AutoSerializeAdapter::deSerialize function (with - * the endian flag) - * 2. Perform a bitshift operation (with correct order) - * 3. @c memcpy (with @c EndianSwapper if necessary) - * - * When serializing for downlink, the packets are generally serialized - * assuming big endian data format like seen in TmPacketStored.cpp for example. - * + * Also provides options to convert from/to data with different endianness. + * variables. * @ingroup serialize */ class SerializeIF { @@ -38,21 +23,65 @@ public: }; static const uint8_t INTERFACE_ID = CLASS_ID::SERIALIZE_IF; - static const ReturnValue_t BUFFER_TOO_SHORT = MAKE_RETURN_CODE(1); - static const ReturnValue_t STREAM_TOO_SHORT = MAKE_RETURN_CODE(2); - static const ReturnValue_t TOO_MANY_ELEMENTS = MAKE_RETURN_CODE(3); + static const ReturnValue_t BUFFER_TOO_SHORT = MAKE_RETURN_CODE(1); // !< The given buffer in serialize is too short + static const ReturnValue_t STREAM_TOO_SHORT = MAKE_RETURN_CODE(2); // !< The input stream in deserialize is too short + static const ReturnValue_t TOO_MANY_ELEMENTS = MAKE_RETURN_CODE(3);// !< There are too many elements to be deserialized virtual ~SerializeIF() { } - + /** + * @brief + * Function to serialize the object into a buffer with maxSize. Size represents the written amount. + * If a part of the buffer has been used already, size must be set to the used amount of bytes. + * + * @details + * Implementations of this function must increase the size variable and move the buffer pointer. + * MaxSize must be checked by implementations of this function + * and BUFFER_TOO_SHORT has to be returned if size would be larger than maxSize. + * + * Custom implementations might use additional return values. + * + * @param[in/out] buffer Buffer to serialize into, will be set to the current write location + * @param[in/out] size Size that has been used in the buffer already, will be increased by the function + * @param[in] maxSize The size of the buffer that is allowed to be used for serialize. + * @param[in] streamEndianness Endianness of the serialized data according to SerializeIF::Endianness + * @return + * - @ยข BUFFER_TOO_SHORT The given buffer in is too short + * - @c RETURN_FAILED Generic error + * - @c RETURN_OK Successful serialization + */ virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const = 0; + /** + * Gets the size of a object if it would be serialized in a buffer + * @return Size of serialized object + */ virtual size_t getSerializedSize() const = 0; + /** + * @brief + * Deserializes a object from a given buffer of given size. + * + * @details + * Buffer must be moved to the current read location by the implementation + * of this function. Size must be decreased by the implementation. + * Implementations are not allowed to alter the buffer as indicated by const pointer. + * + * Custom implementations might use additional return values. + * + * @param[in/out] buffer Buffer to deSerialize from. Will be moved by the function. + * @param[in/out] size Remaining size of the buffer to read from. Will be decreased by function. + * @param[in] streamEndianness Endianness as in according to SerializeIF::Endianness + * @return + * - @c STREAM_TOO_SHORT The input stream is too short to deSerialize the object + * - @c TOO_MANY_ELEMENTS The buffer has more inputs than expected + * - @c RETURN_FAILED Generic Error + * - @c RETURN_OK Successful deserialization + */ virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, Endianness streamEndianness) = 0; }; -#endif /* SERIALIZEIF_H_ */ +#endif /* FSFW_SERIALIZE_SERIALIZEIF_H_ */ From 37764f7ca710f3ae0ab3b41b7e6b72ea6ba3a14b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 4 Sep 2020 15:39:17 +0200 Subject: [PATCH 011/192] include guard fixed --- serialize/EndianConverter.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/serialize/EndianConverter.h b/serialize/EndianConverter.h index f981751d..c888a905 100644 --- a/serialize/EndianConverter.h +++ b/serialize/EndianConverter.h @@ -1,5 +1,5 @@ -#ifndef ENDIANSWAPPER_H_ -#define ENDIANSWAPPER_H_ +#ifndef FSFW_SERIALIZE_ENDIANCONVERTER_H_ +#define FSFW_SERIALIZE_ENDIANCONVERTER_H_ #include "../osal/Endiness.h" #include @@ -121,4 +121,4 @@ public: } }; -#endif /* ENDIANSWAPPER_H_ */ +#endif /* FSFW_SERIALIZE_ENDIANCONVERTER_H_ */ From 0d69e9beca4b0f35b2c0aea86d5c6df983e9ccaa Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 4 Sep 2020 15:42:15 +0200 Subject: [PATCH 012/192] taken over serial uffer adapter from upstream --- serialize/SerialBufferAdapter.cpp | 258 +++++++++++++++--------------- serialize/SerialBufferAdapter.h | 156 +++++++++--------- 2 files changed, 207 insertions(+), 207 deletions(-) diff --git a/serialize/SerialBufferAdapter.cpp b/serialize/SerialBufferAdapter.cpp index 1c11afd4..812cd34b 100644 --- a/serialize/SerialBufferAdapter.cpp +++ b/serialize/SerialBufferAdapter.cpp @@ -1,129 +1,129 @@ -#include "../serialize/SerialBufferAdapter.h" -#include "../serviceinterface/ServiceInterfaceStream.h" -#include - -template -SerialBufferAdapter::SerialBufferAdapter(const uint8_t* buffer, - count_t bufferLength, bool serializeLength) : - serializeLength(serializeLength), - constBuffer(buffer), buffer(nullptr), - bufferLength(bufferLength) {} - -template -SerialBufferAdapter::SerialBufferAdapter(uint8_t* buffer, - count_t bufferLength, bool serializeLength) : - serializeLength(serializeLength), constBuffer(buffer), buffer(buffer), - bufferLength(bufferLength) {} - - -template -SerialBufferAdapter::~SerialBufferAdapter() { -} - -template -ReturnValue_t SerialBufferAdapter::serialize(uint8_t** buffer, - size_t* size, size_t maxSize, Endianness streamEndianness) const { - if (serializeLength) { - ReturnValue_t result = SerializeAdapter::serialize(&bufferLength, - buffer, size, maxSize, streamEndianness); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - } - - if (*size + bufferLength > maxSize) { - return BUFFER_TOO_SHORT; - } - - if (this->constBuffer != nullptr) { - std::memcpy(*buffer, this->constBuffer, bufferLength); - } - else if (this->buffer != nullptr) { - // This will propably be never reached, constBuffer should always be - // set if non-const buffer is set. - std::memcpy(*buffer, this->buffer, bufferLength); - } - else { - return HasReturnvaluesIF::RETURN_FAILED; - } - *size += bufferLength; - (*buffer) += bufferLength; - return HasReturnvaluesIF::RETURN_OK; - -} - -template -size_t SerialBufferAdapter::getSerializedSize() const { - if (serializeLength) { - return bufferLength + SerializeAdapter::getSerializedSize(&bufferLength); - } else { - return bufferLength; - } -} - -template -ReturnValue_t SerialBufferAdapter::deSerialize(const uint8_t** buffer, - size_t* size, Endianness streamEndianness) { - if (this->buffer == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; - } - - if(serializeLength){ - count_t lengthField = 0; - ReturnValue_t result = SerializeAdapter::deSerialize(&lengthField, - buffer, size, streamEndianness); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - if(lengthField > bufferLength) { - return TOO_MANY_ELEMENTS; - } - bufferLength = lengthField; - } - - if (bufferLength <= *size) { - *size -= bufferLength; - std::memcpy(this->buffer, *buffer, bufferLength); - (*buffer) += bufferLength; - return HasReturnvaluesIF::RETURN_OK; - } - else { - return STREAM_TOO_SHORT; - } -} - -template -uint8_t * SerialBufferAdapter::getBuffer() { - if(buffer == nullptr) { - sif::error << "Wrong access function for stored type !" - " Use getConstBuffer()." << std::endl; - return nullptr; - } - return buffer; -} - -template -const uint8_t * SerialBufferAdapter::getConstBuffer() { - if(constBuffer == nullptr) { - sif::error << "SerialBufferAdapter::getConstBuffer:" - " Buffers are unitialized!" << std::endl; - return nullptr; - } - return constBuffer; -} - -template -void SerialBufferAdapter::setBuffer(uint8_t* buffer, - count_t bufferLength) { - this->buffer = buffer; - this->constBuffer = buffer; - this->bufferLength = bufferLength; -} - - -//forward Template declaration for linker -template class SerialBufferAdapter; -template class SerialBufferAdapter; -template class SerialBufferAdapter; -template class SerialBufferAdapter; - +#include "../serialize/SerialBufferAdapter.h" +#include "../serviceinterface/ServiceInterfaceStream.h" +#include + +template +SerialBufferAdapter::SerialBufferAdapter(const uint8_t* buffer, + count_t bufferLength, bool serializeLength) : + serializeLength(serializeLength), + constBuffer(buffer), buffer(nullptr), + bufferLength(bufferLength) {} + +template +SerialBufferAdapter::SerialBufferAdapter(uint8_t* buffer, + count_t bufferLength, bool serializeLength) : + serializeLength(serializeLength), constBuffer(buffer), buffer(buffer), + bufferLength(bufferLength) {} + + +template +SerialBufferAdapter::~SerialBufferAdapter() { +} + +template +ReturnValue_t SerialBufferAdapter::serialize(uint8_t** buffer, + size_t* size, size_t maxSize, Endianness streamEndianness) const { + if (serializeLength) { + ReturnValue_t result = SerializeAdapter::serialize(&bufferLength, + buffer, size, maxSize, streamEndianness); + if(result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + } + + if (*size + bufferLength > maxSize) { + return BUFFER_TOO_SHORT; + } + + if (this->constBuffer != nullptr) { + std::memcpy(*buffer, this->constBuffer, bufferLength); + } + else if (this->buffer != nullptr) { + // This will propably be never reached, constBuffer should always be + // set if non-const buffer is set. + std::memcpy(*buffer, this->buffer, bufferLength); + } + else { + return HasReturnvaluesIF::RETURN_FAILED; + } + *size += bufferLength; + (*buffer) += bufferLength; + return HasReturnvaluesIF::RETURN_OK; + +} + +template +size_t SerialBufferAdapter::getSerializedSize() const { + if (serializeLength) { + return bufferLength + SerializeAdapter::getSerializedSize(&bufferLength); + } else { + return bufferLength; + } +} + +template +ReturnValue_t SerialBufferAdapter::deSerialize(const uint8_t** buffer, + size_t* size, Endianness streamEndianness) { + if (this->buffer == nullptr) { + return HasReturnvaluesIF::RETURN_FAILED; + } + + if(serializeLength){ + count_t lengthField = 0; + ReturnValue_t result = SerializeAdapter::deSerialize(&lengthField, + buffer, size, streamEndianness); + if(result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + if(lengthField > bufferLength) { + return TOO_MANY_ELEMENTS; + } + bufferLength = lengthField; + } + + if (bufferLength <= *size) { + *size -= bufferLength; + std::memcpy(this->buffer, *buffer, bufferLength); + (*buffer) += bufferLength; + return HasReturnvaluesIF::RETURN_OK; + } + else { + return STREAM_TOO_SHORT; + } +} + +template +uint8_t * SerialBufferAdapter::getBuffer() { + if(buffer == nullptr) { + sif::error << "Wrong access function for stored type !" + " Use getConstBuffer()." << std::endl; + return nullptr; + } + return buffer; +} + +template +const uint8_t * SerialBufferAdapter::getConstBuffer() { + if(constBuffer == nullptr) { + sif::error << "SerialBufferAdapter::getConstBuffer:" + " Buffers are unitialized!" << std::endl; + return nullptr; + } + return constBuffer; +} + +template +void SerialBufferAdapter::setBuffer(uint8_t* buffer, + count_t bufferLength) { + this->buffer = buffer; + this->constBuffer = buffer; + this->bufferLength = bufferLength; +} + + +//forward Template declaration for linker +template class SerialBufferAdapter; +template class SerialBufferAdapter; +template class SerialBufferAdapter; +template class SerialBufferAdapter; + diff --git a/serialize/SerialBufferAdapter.h b/serialize/SerialBufferAdapter.h index 9a89e18b..c3dfcd8f 100644 --- a/serialize/SerialBufferAdapter.h +++ b/serialize/SerialBufferAdapter.h @@ -1,78 +1,78 @@ -#ifndef SERIALBUFFERADAPTER_H_ -#define SERIALBUFFERADAPTER_H_ - -#include "../serialize/SerializeIF.h" -#include "../serialize/SerializeAdapter.h" - -/** - * This adapter provides an interface for SerializeIF to serialize or deserialize - * buffers with no length header but a known size. - * - * Additionally, the buffer length can be serialized too and will be put in - * front of the serialized buffer. - * - * Can be used with SerialLinkedListAdapter by declaring a SerializeElement with - * SerialElement>. - * Right now, the SerialBufferAdapter must always - * be initialized with the buffer and size ! - * - * \ingroup serialize - */ -template -class SerialBufferAdapter: public SerializeIF { -public: - - /** - * Constructor for constant uint8_t buffer. Length field can be serialized optionally. - * Type of length can be supplied as template type. - * @param buffer - * @param bufferLength - * @param serializeLength - */ - SerialBufferAdapter(const uint8_t* buffer, count_t bufferLength, - bool serializeLength = false); - - /** - * Constructor for non-constant uint8_t buffer. - * Length field can be serialized optionally. - * Type of length can be supplied as template type. - * @param buffer - * @param bufferLength - * @param serializeLength Length field will be serialized with size count_t - */ - SerialBufferAdapter(uint8_t* buffer, count_t bufferLength, - bool serializeLength = false); - - virtual ~SerialBufferAdapter(); - - virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size, - size_t maxSize, Endianness streamEndianness) const override; - - virtual size_t getSerializedSize() const override; - - /** - * @brief This function deserializes a buffer into the member buffer. - * @details - * If a length field is present, it is ignored, as the size should have - * been set in the constructor. If the size is not known beforehand, - * consider using SerialFixedArrayListAdapter instead. - * @param buffer [out] Resulting buffer - * @param size remaining size to deserialize, should be larger than buffer - * + size field size - * @param bigEndian - * @return - */ - virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, - Endianness streamEndianness) override; - - uint8_t * getBuffer(); - const uint8_t * getConstBuffer(); - void setBuffer(uint8_t* buffer, count_t bufferLength); -private: - bool serializeLength = false; - const uint8_t *constBuffer = nullptr; - uint8_t *buffer = nullptr; - count_t bufferLength = 0; -}; - -#endif /* SERIALBUFFERADAPTER_H_ */ +#ifndef SERIALBUFFERADAPTER_H_ +#define SERIALBUFFERADAPTER_H_ + +#include "../serialize/SerializeIF.h" +#include "../serialize/SerializeAdapter.h" + +/** + * This adapter provides an interface for SerializeIF to serialize or deserialize + * buffers with no length header but a known size. + * + * Additionally, the buffer length can be serialized too and will be put in + * front of the serialized buffer. + * + * Can be used with SerialLinkedListAdapter by declaring a SerializeElement with + * SerialElement>. + * Right now, the SerialBufferAdapter must always + * be initialized with the buffer and size ! + * + * \ingroup serialize + */ +template +class SerialBufferAdapter: public SerializeIF { +public: + + /** + * Constructor for constant uint8_t buffer. Length field can be serialized optionally. + * Type of length can be supplied as template type. + * @param buffer + * @param bufferLength + * @param serializeLength + */ + SerialBufferAdapter(const uint8_t* buffer, count_t bufferLength, + bool serializeLength = false); + + /** + * Constructor for non-constant uint8_t buffer. + * Length field can be serialized optionally. + * Type of length can be supplied as template type. + * @param buffer + * @param bufferLength + * @param serializeLength Length field will be serialized with size count_t + */ + SerialBufferAdapter(uint8_t* buffer, count_t bufferLength, + bool serializeLength = false); + + virtual ~SerialBufferAdapter(); + + virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size, + size_t maxSize, Endianness streamEndianness) const override; + + virtual size_t getSerializedSize() const override; + + /** + * @brief This function deserializes a buffer into the member buffer. + * @details + * If a length field is present, it is ignored, as the size should have + * been set in the constructor. If the size is not known beforehand, + * consider using SerialFixedArrayListAdapter instead. + * @param buffer [out] Resulting buffer + * @param size remaining size to deserialize, should be larger than buffer + * + size field size + * @param bigEndian + * @return + */ + virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, + Endianness streamEndianness) override; + + uint8_t * getBuffer(); + const uint8_t * getConstBuffer(); + void setBuffer(uint8_t* buffer, count_t bufferLength); +private: + bool serializeLength = false; + const uint8_t *constBuffer = nullptr; + uint8_t *buffer = nullptr; + count_t bufferLength = 0; +}; + +#endif /* SERIALBUFFERADAPTER_H_ */ From f2f7a5de87b728868e13d96765846e50349a789f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 4 Sep 2020 15:47:33 +0200 Subject: [PATCH 013/192] taken over convergence changes --- serialize/SerialFixedArrayListAdapter.h | 30 ++++++++++--------------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/serialize/SerialFixedArrayListAdapter.h b/serialize/SerialFixedArrayListAdapter.h index c866df86..70ca987a 100644 --- a/serialize/SerialFixedArrayListAdapter.h +++ b/serialize/SerialFixedArrayListAdapter.h @@ -1,8 +1,8 @@ -#ifndef SERIALFIXEDARRAYLISTADAPTER_H_ -#define SERIALFIXEDARRAYLISTADAPTER_H_ +#ifndef FSFW_SERIALIZE_SERIALFIXEDARRAYLISTADAPTER_H_ +#define FSFW_SERIALIZE_SERIALFIXEDARRAYLISTADAPTER_H_ +#include "SerialArrayListAdapter.h" #include "../container/FixedArrayList.h" -#include "../serialize/SerialArrayListAdapter.h" /** * @brief This adapter provides an interface for SerializeIF to serialize and @@ -13,18 +13,11 @@ * The sequence of objects is defined in the constructor by * using the setStart and setNext functions. * - * - Buffers with a size header inside that class can be declared with - * @code - * SerialFixedArrayListAdapter mySerialFixedArrayList(...). - * @endcode - * - * - MAX_SIZE: specifies the maximum allowed number of elements - * in FixedArrayList. - * - BUFFER_TYPE: specifies the data type of the buffer - * - count_t: specifies the type/size of the length field - * which defaults to one byte. - * + * @tparam BUFFER_TYPE: Specifies the data type of the buffer + * @tparam MAX_SIZE: Specifies the maximum allowed number of elements + * (not bytes!) + * @tparam count_t: specifies the type/size of the length field which defaults + * to one byte. * @ingroup serialize */ template @@ -33,7 +26,7 @@ class SerialFixedArrayListAdapter : public SerializeIF { public: /** - * Constructor Arguments are forwarded to FixedArrayList constructor. + * Constructor arguments are forwarded to FixedArrayList constructor. * Refer to the fixed array list constructors for different options. * @param args */ @@ -49,7 +42,8 @@ public: } size_t getSerializedSize() const { - return SerialArrayListAdapter::getSerializedSize(this); + return SerialArrayListAdapter:: + getSerializedSize(this); } ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, @@ -60,4 +54,4 @@ public: }; -#endif /* SERIALFIXEDARRAYLISTADAPTER_H_ */ +#endif /* FSFW_SERIALIZE_SERIALFIXEDARRAYLISTADAPTER_H_ */ From 305d8ef84079a9e0e0861b4708147e3b562d2e10 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 4 Sep 2020 15:56:52 +0200 Subject: [PATCH 014/192] taken over changes --- serialize/SerializeAdapter.h | 71 +++++++----------------------------- 1 file changed, 14 insertions(+), 57 deletions(-) diff --git a/serialize/SerializeAdapter.h b/serialize/SerializeAdapter.h index 3e84bdf9..24f6111e 100644 --- a/serialize/SerializeAdapter.h +++ b/serialize/SerializeAdapter.h @@ -1,11 +1,12 @@ -#ifndef SERIALIZEADAPTER_H_ -#define SERIALIZEADAPTER_H_ +#ifndef FSFW_SERIALIZE_SERIALIZEADAPTER_H_ +#define FSFW_SERIALIZE_SERIALIZEADAPTER_H_ + +#include "EndianConverter.h" +#include "SerializeIF.h" #include "../container/IsDerivedFrom.h" #include "../returnvalues/HasReturnvaluesIF.h" -#include "../serialize/EndianConverter.h" -#include "../serialize/SerializeIF.h" -#include +#include /** * @brief These adapters provides an interface to use the SerializeIF functions @@ -13,56 +14,11 @@ * serialization of classes with different multiple different data types * into buffers and vice-versa. * @details - * - * A report class is converted into a TM buffer. The report class implements a - * serialize functions and calls the AutoSerializeAdapter::serialize function - * repeatedly on all object data fields. The getSerializedSize function is - * implemented by calling the AutoSerializeAdapter::getSerializedSize function - * repeatedly on all data fields. - * - * The AutoSerializeAdapter functions can also be used as an alternative to - * memcpy to retrieve data out of a buffer directly into a class variable - * with data type T while being able to specify endianness. The boolean - * bigEndian specifies whether an endian swap is performed on the data before - * serialization or deserialization. - * - * There are three ways to retrieve data out of a buffer to be used in the FSFW - * to use regular aligned (big endian) data. Examples: - * - * 1. Use the AutoSerializeAdapter::deSerialize function - * The pointer *buffer will be incremented automatically by the typeSize - * of the object, so this function can be called on &buffer repeatedly - * without adjusting pointer position. Set bigEndian parameter to true - * to perform endian swapping, if necessary - * @code - * uint16_t data; - * int32_t dataLen = sizeof(data); - * ReturnValue_t result = - * AutoSerializeAdapter::deSerialize(&data,&buffer,&dataLen,true); - * @endcode - * - * 2. Perform a bitshift operation. Watch for for endianness: - * @code - * uint16_t data; - * data = buffer[targetByte1] << 8 | buffer[targetByte2]; - * data = EndianSwapper::swap(data); //optional, or swap order above - * @endcode - * - * 3. memcpy or std::copy can also be used, but watch out if system - * endianness is different from required data endianness. - * Perform endian-swapping if necessary. - * @code - * uint16_t data; - * memcpy(&data,buffer + positionOfTargetByte1,sizeof(data)); - * data = EndianSwapper::swap(data); //optional - * @endcode - * - * When serializing for downlink, the packets are generally serialized assuming - * big endian data format like seen in TmPacketStored.cpp for example. + * The correct serialization or deserialization function is chosen at + * compile time with template type deduction. * * @ingroup serialize */ - class SerializeAdapter { public: template @@ -88,9 +44,10 @@ private: class InternalSerializeAdapter { public: static ReturnValue_t serialize(const T *object, uint8_t **buffer, - size_t *size, size_t max_size, SerializeIF::Endianness streamEndianness) { + size_t *size, size_t max_size, + SerializeIF::Endianness streamEndianness) { size_t ignoredSize = 0; - if (size == NULL) { + if (size == nullptr) { size = &ignoredSize; } //TODO check integer overflow of *size @@ -108,7 +65,7 @@ private: tmp = *object; break; } - memcpy(*buffer, &tmp, sizeof(T)); + std::memcpy(*buffer, &tmp, sizeof(T)); *size += sizeof(T); (*buffer) += sizeof(T); return HasReturnvaluesIF::RETURN_OK; @@ -122,7 +79,7 @@ private: T tmp; if (*size >= sizeof(T)) { *size -= sizeof(T); - memcpy(&tmp, *buffer, sizeof(T)); + std::memcpy(&tmp, *buffer, sizeof(T)); switch (streamEndianness) { case SerializeIF::Endianness::BIG: *object = EndianConverter::convertBigEndian(tmp); @@ -156,7 +113,7 @@ private: size_t *size, size_t max_size, SerializeIF::Endianness streamEndianness) const { size_t ignoredSize = 0; - if (size == NULL) { + if (size == nullptr) { size = &ignoredSize; } return object->serialize(buffer, size, max_size, streamEndianness); From 721b981df2df5ea852d0ad8a0381b488099f2d32 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 4 Sep 2020 16:01:18 +0200 Subject: [PATCH 015/192] changes taken over --- serialize/SerialLinkedListAdapter.h | 51 +++++++++++++---------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/serialize/SerialLinkedListAdapter.h b/serialize/SerialLinkedListAdapter.h index 987fa70e..430a21ac 100644 --- a/serialize/SerialLinkedListAdapter.h +++ b/serialize/SerialLinkedListAdapter.h @@ -1,17 +1,10 @@ -/** - * @file SerialLinkedListAdapter.h - * @brief This file defines the SerialLinkedListAdapter class. - * @date 22.07.2014 - * @author baetz - */ -#ifndef SERIALLINKEDLISTADAPTER_H_ -#define SERIALLINKEDLISTADAPTER_H_ +#ifndef FSFW_SERIALIZE_SERIALLINKEDLISTADAPTER_H_ +#define FSFW_SERIALIZE_SERIALLINKEDLISTADAPTER_H_ #include "../container/SinglyLinkedList.h" -#include "../serialize/SerializeAdapter.h" -#include "../serialize/SerializeElement.h" -#include "../serialize/SerializeIF.h" -//This is where we need the SerializeAdapter! +#include "SerializeAdapter.h" +#include "SerializeElement.h" +#include "SerializeIF.h" /** * @brief Implement the conversion of object data to data streams @@ -22,7 +15,7 @@ * SerializeElement members inside the class * implementing this adapter. * - The element type can also be a SerialBufferAdapter to - * de-/serialize buffers with a known size + * de-/serialize buffers. * - The element type can also be a SerialFixedArrayListAdapter to * de-/serialize buffers with a size header, which is scanned automatically. * @@ -37,21 +30,12 @@ * supplying a buffer with the data which is converted into an object. * The size of data to serialize can be supplied and is * decremented in the function. Range checking is done internally. - * + * @author baetz * @ingroup serialize */ template class SerialLinkedListAdapter: public SinglyLinkedList, public SerializeIF { public: - /** - * Copying is forbidden by deleting the copy constructor and the copy - * assignment operator because of the pointers to the linked list members. - * Unless the child class implements an own copy constructor or - * copy assignment operator, these operation will throw a compiler error. - * @param - */ - SerialLinkedListAdapter(const SerialLinkedListAdapter &) = delete; - SerialLinkedListAdapter& operator=(const SerialLinkedListAdapter&) = delete; SerialLinkedListAdapter(typename LinkedElement::Iterator start, bool printCount = false) : @@ -85,7 +69,7 @@ public: uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) { ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - while ((result == HasReturnvaluesIF::RETURN_OK) && (element != NULL)) { + while ((result == HasReturnvaluesIF::RETURN_OK) and (element != nullptr)) { result = element->value->serialize(buffer, size, maxSize, streamEndianness); element = element->getNext(); @@ -104,7 +88,7 @@ public: static size_t getSerializedSize(const LinkedElement *element) { size_t size = 0; - while (element != NULL) { + while (element != nullptr) { size += element->value->getSerializedSize(); element = element->getNext(); } @@ -114,20 +98,31 @@ public: virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) override { - return deSerialize(SinglyLinkedList::start, buffer, size, streamEndianness); + return deSerialize(SinglyLinkedList::start, buffer, size, + streamEndianness); } static ReturnValue_t deSerialize(LinkedElement* element, const uint8_t** buffer, size_t* size, Endianness streamEndianness) { ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - while ((result == HasReturnvaluesIF::RETURN_OK) && (element != NULL)) { + while ((result == HasReturnvaluesIF::RETURN_OK) and (element != nullptr)) { result = element->value->deSerialize(buffer, size, streamEndianness); element = element->getNext(); } return result; } + /** + * Copying is forbidden by deleting the copy constructor and the copy + * assignment operator because of the pointers to the linked list members. + * Unless the child class implements an own copy constructor or + * copy assignment operator, these operation will throw a compiler error. + * @param + */ + SerialLinkedListAdapter(const SerialLinkedListAdapter &) = delete; + SerialLinkedListAdapter& operator=(const SerialLinkedListAdapter&) = delete; + bool printCount; }; -#endif /* SERIALLINKEDLISTADAPTER_H_ */ +#endif /* FSFW_SERIALIZE_SERIALLINKEDLISTADAPTER_H_ */ From 1803030640f2201a006a3e3e30e8029cf001464b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 4 Sep 2020 16:04:11 +0200 Subject: [PATCH 016/192] taken over serialize element changes --- serialize/SerializeElement.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/serialize/SerializeElement.h b/serialize/SerializeElement.h index 8c3472b2..47080292 100644 --- a/serialize/SerializeElement.h +++ b/serialize/SerializeElement.h @@ -1,8 +1,8 @@ -#ifndef SERIALIZEELEMENT_H_ -#define SERIALIZEELEMENT_H_ +#ifndef FSFW_SERIALIZE_SERIALIZEELEMENT_H_ +#define FSFW_SERIALIZE_SERIALIZEELEMENT_H_ +#include "SerializeAdapter.h" #include "../container/SinglyLinkedList.h" -#include "../serialize/SerializeAdapter.h" #include /** @@ -12,7 +12,7 @@ * Used by declaring any arbitrary datatype with SerializeElement myVariable, * inside a SerialLinkedListAdapter implementation and setting the sequence * of objects with setNext() and setStart(). - * Serilization and Deserialization is then performed automatically in + * Serialization and Deserialization is then performed automatically in * specified sequence order. * @ingroup serialize */ @@ -27,7 +27,7 @@ public: SerializeElement() : LinkedElement(this) { } - T entry; + ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const override { return SerializeAdapter::serialize(&entry, buffer, size, maxSize, @@ -52,9 +52,12 @@ public: entry = newValue; return *this; } + T* operator->() { return &entry; } + + T entry; }; -#endif /* SERIALIZEELEMENT_H_ */ +#endif /* FSFW_SERIALIZE_SERIALIZEELEMENT_H_ */ From faeeca8707857dc75451f06fb78e1c5bffd22b63 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 4 Sep 2020 16:07:54 +0200 Subject: [PATCH 017/192] seiralize folder converged --- serialize/SerialArrayListAdapter.h | 33 +++++++++++++----------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/serialize/SerialArrayListAdapter.h b/serialize/SerialArrayListAdapter.h index 69afdd4a..daa3fe7f 100644 --- a/serialize/SerialArrayListAdapter.h +++ b/serialize/SerialArrayListAdapter.h @@ -1,18 +1,13 @@ -/** - * @file SerialArrayListAdapter.h - * @brief This file defines the SerialArrayListAdapter class. - * @date 22.07.2014 - * @author baetz - */ -#ifndef SERIALARRAYLISTADAPTER_H_ -#define SERIALARRAYLISTADAPTER_H_ +#ifndef FSFW_SERIALIZE_SERIALARRAYLISTADAPTER_H_ +#define FSFW_SERIALIZE_SERIALARRAYLISTADAPTER_H_ +#include "SerializeIF.h" #include "../container/ArrayList.h" -#include "../serialize/SerializeIF.h" #include /** * Also serializes length field ! + * @author baetz * @ingroup serialize */ template @@ -26,8 +21,9 @@ public: return serialize(adaptee, buffer, size, maxSize, streamEndianness); } - static ReturnValue_t serialize(const ArrayList* list, uint8_t** buffer, size_t* size, - size_t maxSize, Endianness streamEndianness) { + static ReturnValue_t serialize(const ArrayList* list, + uint8_t** buffer, size_t* size, size_t maxSize, + Endianness streamEndianness) { ReturnValue_t result = SerializeAdapter::serialize(&list->size, buffer, size, maxSize, streamEndianness); count_t i = 0; @@ -59,14 +55,19 @@ public: return deSerialize(adaptee, buffer, size, streamEndianness); } - static ReturnValue_t deSerialize(ArrayList* list, const uint8_t** buffer, size_t* size, + static ReturnValue_t deSerialize(ArrayList* list, + const uint8_t** buffer, size_t* size, Endianness streamEndianness) { count_t tempSize = 0; ReturnValue_t result = SerializeAdapter::deSerialize(&tempSize, buffer, size, streamEndianness); + if(result != HasReturnvaluesIF::RETURN_OK) { + return result; + } if (tempSize > list->maxSize()) { return SerializeIF::TOO_MANY_ELEMENTS; } + list->size = tempSize; count_t i = 0; while ((result == HasReturnvaluesIF::RETURN_OK) && (i < list->size)) { @@ -78,14 +79,8 @@ public: return result; } - - static void swapArrayListEndianness(ArrayList* list) { - list->swapArrayListEndianness(); - } private: ArrayList *adaptee; }; - - -#endif /* SERIALARRAYLISTADAPTER_H_ */ +#endif /* FSFW_SERIALIZE_SERIALARRAYLISTADAPTER_H_ */ From 05814dc805e3901aecdfd353c6e63712e9ed2c27 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 5 Sep 2020 15:58:53 +0200 Subject: [PATCH 018/192] added way to start DH immediately, bugfix in event manager --- devicehandlers/DeviceHandlerBase.cpp | 8 +++ devicehandlers/DeviceHandlerBase.h | 52 +++++++++++-------- .../DeviceHandlerFailureIsolation.cpp | 8 +++ events/EventManagerIF.h | 22 +++++--- modes/HasModesIF.h | 12 ++--- 5 files changed, 66 insertions(+), 36 deletions(-) diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index 45cf3781..86fd01b1 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -1385,6 +1385,10 @@ ReturnValue_t DeviceHandlerBase::initializeAfterTaskCreation() { pstIntervalMs = executingTask->getPeriodMs(); } this->hkManager.initializeAfterTaskCreation(); + + if(setStartupImmediately) { + startTransition(MODE_ON, SUBMODE_NONE); + } return HasReturnvaluesIF::RETURN_OK; } @@ -1402,6 +1406,10 @@ object_id_t DeviceHandlerBase::getObjectId() const { return SystemObject::getObjectId(); } +void DeviceHandlerBase::setStartUpImmediately() { + this->setStartupImmediately = true; +} + dur_millis_t DeviceHandlerBase::getPeriodicOperationFrequency() const { return pstIntervalMs; } diff --git a/devicehandlers/DeviceHandlerBase.h b/devicehandlers/DeviceHandlerBase.h index f809953e..c3748172 100644 --- a/devicehandlers/DeviceHandlerBase.h +++ b/devicehandlers/DeviceHandlerBase.h @@ -104,6 +104,16 @@ public: void setHkDestination(object_id_t hkDestination); void setThermalStateRequestPoolIds(uint32_t thermalStatePoolId, uint32_t thermalRequestPoolId); + /** + * @brief Helper function to easy device handler development. + * This will instruct the transition to MODE_ON immediately + * (leading to doStartUp() being called for the transition to the ON mode), + * so external mode commanding is not necessary anymore. + * + * This has to be called before the task is started! + * (e.g. in the task factory) + */ + void setStartUpImmediately(); /** * @brief This function is the device handler base core component and is @@ -149,6 +159,14 @@ public: * @return */ virtual ReturnValue_t initialize(); + + /** + * @brief Intialization steps performed after all tasks have been created. + * This function will be called by the executing task. + * @return + */ + virtual ReturnValue_t initializeAfterTaskCreation() override; + /** Destructor. */ virtual ~DeviceHandlerBase(); @@ -945,14 +963,17 @@ protected: virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, uint32_t *msToReachTheMode); - virtual void startTransition(Mode_t mode, Submode_t submode); - virtual void setToExternalControl(); - virtual void announceMode(bool recursive); + + /* HasModesIF overrides */ + virtual void startTransition(Mode_t mode, Submode_t submode) override; + virtual void setToExternalControl() override; + virtual void announceMode(bool recursive) override; virtual ReturnValue_t letChildHandleMessage(CommandMessage *message); /** - * Overwrites SystemObject::triggerEvent in order to inform FDIR"Helper" faster about executed events. + * Overwrites SystemObject::triggerEvent in order to inform FDIR"Helper" + * faster about executed events. * This is a bit sneaky, but improves responsiveness of the device FDIR. * @param event The event to be thrown * @param parameter1 Optional parameter 1 @@ -1044,6 +1065,8 @@ private: */ uint32_t timeoutStart = 0; + bool setStartupImmediately = false; + /** * Delay for the current mode transition, used for time out */ @@ -1162,7 +1185,6 @@ private: ReturnValue_t getStorageData(store_address_t storageAddress, uint8_t **data, uint32_t *len); - /** * @param modeTo either @c MODE_ON, MODE_NORMAL or MODE_RAW NOTHING ELSE!!! */ @@ -1173,28 +1195,14 @@ private: */ void callChildStatemachine(); - /** - * Switches the channel of the cookie used for the communication - * - * - * @param newChannel the object Id of the channel to switch to - * @return - * - @c RETURN_OK when cookie was changed - * - @c RETURN_FAILED when cookies could not be changed, - * e.g. because the newChannel is not enabled - * - @c returnvalues of RMAPChannelIF::isActive() - */ - ReturnValue_t switchCookieChannel(object_id_t newChannelId); - ReturnValue_t handleDeviceHandlerMessage(CommandMessage *message); - virtual ReturnValue_t initializeAfterTaskCreation() override; virtual DataSetIF* getDataSetHandle(sid_t sid) override; - void parseReply(const uint8_t* receivedData, - size_t receivedDataLen); - virtual dur_millis_t getPeriodicOperationFrequency() const override; + + void parseReply(const uint8_t* receivedData, + size_t receivedDataLen); }; #endif /* FRAMEWORK_DEVICEHANDLERS_DEVICEHANDLERBASE_H_ */ diff --git a/devicehandlers/DeviceHandlerFailureIsolation.cpp b/devicehandlers/DeviceHandlerFailureIsolation.cpp index 9fbe71d8..24fe15a0 100644 --- a/devicehandlers/DeviceHandlerFailureIsolation.cpp +++ b/devicehandlers/DeviceHandlerFailureIsolation.cpp @@ -247,6 +247,14 @@ bool DeviceHandlerFailureIsolation::isFdirInActionOrAreWeFaulty( } return true; } + + if (owner == nullptr) { + // Configuration error. + sif::error << "DeviceHandlerFailureIsolation::" + << "isFdirInActionOrAreWeFaulty: Owner not set!" << std::endl; + return false; + } + if (owner->getHealth() == HasHealthIF::FAULTY || owner->getHealth() == HasHealthIF::PERMANENT_FAULTY) { //Ignore all events in case device is already faulty. diff --git a/events/EventManagerIF.h b/events/EventManagerIF.h index f9ac420b..253e6910 100644 --- a/events/EventManagerIF.h +++ b/events/EventManagerIF.h @@ -1,10 +1,11 @@ #ifndef EVENTMANAGERIF_H_ #define EVENTMANAGERIF_H_ -#include "eventmatching/eventmatching.h" #include "EventMessage.h" +#include "eventmatching/eventmatching.h" #include "../objectmanager/ObjectManagerIF.h" #include "../ipc/MessageQueueSenderIF.h" +#include "../ipc/MessageQueueIF.h" class EventManagerIF { public: @@ -16,7 +17,8 @@ public: virtual MessageQueueId_t getEventReportQueue() = 0; - virtual ReturnValue_t registerListener(MessageQueueId_t listener, bool forwardAllButSelected = false) = 0; + virtual ReturnValue_t registerListener(MessageQueueId_t listener, + bool forwardAllButSelected = false) = 0; virtual ReturnValue_t subscribeToEvent(MessageQueueId_t listener, EventId_t event) = 0; virtual ReturnValue_t subscribeToAllEventsFrom(MessageQueueId_t listener, @@ -31,18 +33,22 @@ public: bool reporterInverted = false) = 0; static void triggerEvent(object_id_t reportingObject, Event event, - uint32_t parameter1 = 0, uint32_t parameter2 = 0, MessageQueueId_t sentFrom = 0) { + uint32_t parameter1 = 0, uint32_t parameter2 = 0, + MessageQueueId_t sentFrom = 0) { EventMessage message(event, reportingObject, parameter1, parameter2); triggerEvent(&message, sentFrom); } - static void triggerEvent(EventMessage* message, MessageQueueId_t sentFrom = 0) { - static MessageQueueId_t eventmanagerQueue = 0; - if (eventmanagerQueue == 0) { + + 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 != NULL) { - eventmanagerQueue = eventmanager->getEventReportQueue(); + if (eventmanager == nullptr) { + return; } + eventmanagerQueue = eventmanager->getEventReportQueue(); } MessageQueueSenderIF::sendMessage(eventmanagerQueue, message, sentFrom); } diff --git a/modes/HasModesIF.h b/modes/HasModesIF.h index c3abaaaf..39a50c2a 100644 --- a/modes/HasModesIF.h +++ b/modes/HasModesIF.h @@ -46,12 +46,12 @@ protected: uint32_t *msToReachTheMode) { return HasReturnvaluesIF::RETURN_FAILED; } - virtual void startTransition(Mode_t mode, Submode_t submode) { - } - virtual void setToExternalControl() { - } - virtual void announceMode(bool recursive) { - } + + virtual void startTransition(Mode_t mode, Submode_t submode) {} + + virtual void setToExternalControl() {} + + virtual void announceMode(bool recursive) {} }; #endif /* HASMODESIF_H_ */ From 39b675cf9984a1b22c215979821073a81202b273 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 5 Sep 2020 20:39:10 +0200 Subject: [PATCH 019/192] repairing host osal --- osal/host/FixedTimeslotTask.cpp | 7 +++++-- osal/host/MessageQueue.cpp | 10 ++++++---- osal/host/MessageQueue.h | 3 ++- osal/host/Mutex.cpp | 7 +++---- osal/host/Mutex.h | 5 +++-- osal/host/QueueMapManager.cpp | 2 +- osal/host/SemaphoreFactory.cpp | 3 --- 7 files changed, 20 insertions(+), 17 deletions(-) diff --git a/osal/host/FixedTimeslotTask.cpp b/osal/host/FixedTimeslotTask.cpp index 1139badb..1257eb16 100644 --- a/osal/host/FixedTimeslotTask.cpp +++ b/osal/host/FixedTimeslotTask.cpp @@ -122,8 +122,11 @@ void FixedTimeslotTask::taskFunctionality() { ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId, uint32_t slotTimeMs, int8_t executionStep) { - if (objectManager->get(componentId) != nullptr) { - pollingSeqTable.addSlot(componentId, slotTimeMs, executionStep, this); + ExecutableObjectIF* executableObject = objectManager-> + get(componentId); + if (executableObject!= nullptr) { + pollingSeqTable.addSlot(componentId, slotTimeMs, executionStep, + executableObject, this); return HasReturnvaluesIF::RETURN_OK; } diff --git a/osal/host/MessageQueue.cpp b/osal/host/MessageQueue.cpp index 8a34282c..59825084 100644 --- a/osal/host/MessageQueue.cpp +++ b/osal/host/MessageQueue.cpp @@ -61,7 +61,7 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) { } // not sure this will work.. //*message = std::move(messageQueue.front()); - MutexHelper mutexLock(queueLock, 20); + MutexHelper mutexLock(queueLock, MutexIF::TimeoutType::WAITING, 20); MessageQueueMessage* currentMessage = &messageQueue.front(); std::copy(currentMessage->getBuffer(), currentMessage->getBuffer() + messageSize, message->getBuffer()); @@ -126,7 +126,8 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo, } if(targetQueue->messageQueue.size() < targetQueue->messageDepth) { - MutexHelper mutexLock(targetQueue->queueLock, 20); + MutexHelper mutexLock(targetQueue->queueLock, + MutexIF::TimeoutType::WAITING, 20); // not ideal, works for now though. MessageQueueMessage* mqmMessage = dynamic_cast(message); @@ -146,8 +147,9 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo, return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t MessageQueue::lockQueue(dur_millis_t lockTimeout) { - return queueLock->lockMutex(lockTimeout); +ReturnValue_t MessageQueue::lockQueue(MutexIF::TimeoutType timeoutType, + dur_millis_t lockTimeout) { + return queueLock->lockMutex(timeoutType, lockTimeout); } ReturnValue_t MessageQueue::unlockQueue() { diff --git a/osal/host/MessageQueue.h b/osal/host/MessageQueue.h index 21a01663..97a9e491 100644 --- a/osal/host/MessageQueue.h +++ b/osal/host/MessageQueue.h @@ -182,7 +182,8 @@ public: bool isDefaultDestinationSet() const override; - ReturnValue_t lockQueue(dur_millis_t lockTimeout); + ReturnValue_t lockQueue(MutexIF::TimeoutType timeoutType, + dur_millis_t lockTimeout); ReturnValue_t unlockQueue(); protected: /** diff --git a/osal/host/Mutex.cpp b/osal/host/Mutex.cpp index 2718f2b9..8471cab8 100644 --- a/osal/host/Mutex.cpp +++ b/osal/host/Mutex.cpp @@ -1,10 +1,9 @@ -#include "../../osal/host/Mutex.h" +#include "Mutex.h" #include "../../serviceinterface/ServiceInterfaceStream.h" -const uint32_t MutexIF::POLLING = 0; -const uint32_t MutexIF::BLOCKING = 0xffffffff; +Mutex::Mutex() {} -ReturnValue_t Mutex::lockMutex(uint32_t timeoutMs) { +ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType, uint32_t timeoutMs) { if(timeoutMs == MutexIF::BLOCKING) { mutex.lock(); locked = true; diff --git a/osal/host/Mutex.h b/osal/host/Mutex.h index 4461e5f2..b755bc30 100644 --- a/osal/host/Mutex.h +++ b/osal/host/Mutex.h @@ -15,8 +15,9 @@ */ class Mutex : public MutexIF { public: - Mutex() = default; - ReturnValue_t lockMutex(uint32_t timeoutMs = MutexIF::BLOCKING) override; + Mutex(); + ReturnValue_t lockMutex(TimeoutType timeoutType = + TimeoutType::BLOCKING, uint32_t timeoutMs = 0) override; ReturnValue_t unlockMutex() override; std::timed_mutex* getMutexHandle(); diff --git a/osal/host/QueueMapManager.cpp b/osal/host/QueueMapManager.cpp index 47687bc1..a466c3f8 100644 --- a/osal/host/QueueMapManager.cpp +++ b/osal/host/QueueMapManager.cpp @@ -37,7 +37,7 @@ ReturnValue_t QueueMapManager::addMessageQueue( MessageQueueIF* QueueMapManager::getMessageQueue( MessageQueueId_t messageQueueId) const { - MutexHelper(mapLock, 50); + MutexHelper(MutexIF::TimeoutType::WAITING, mapLock, 50); auto queueIter = queueMap.find(messageQueueId); if(queueIter != queueMap.end()) { return queueIter->second; diff --git a/osal/host/SemaphoreFactory.cpp b/osal/host/SemaphoreFactory.cpp index c354c47c..b19b2c75 100644 --- a/osal/host/SemaphoreFactory.cpp +++ b/osal/host/SemaphoreFactory.cpp @@ -3,9 +3,6 @@ #include "../../osal/linux/CountingSemaphore.h" #include "../../serviceinterface/ServiceInterfaceStream.h" -const uint32_t SemaphoreIF::POLLING = 0; -const uint32_t SemaphoreIF::BLOCKING = 0xFFFFFFFF; - SemaphoreFactory* SemaphoreFactory::factoryInstance = nullptr; SemaphoreFactory::SemaphoreFactory() { From 80e60566d82c5a6ed35c91af6f3d6cc21866dd7f Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 5 Sep 2020 21:11:27 +0200 Subject: [PATCH 020/192] compiling and working again --- osal/host/FixedTimeslotTask.cpp | 9 ++++++--- osal/host/FixedTimeslotTask.h | 2 +- osal/host/QueueMapManager.cpp | 2 +- timemanager/CCSDSTime.cpp | 4 ++++ 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/osal/host/FixedTimeslotTask.cpp b/osal/host/FixedTimeslotTask.cpp index 1257eb16..e78c974a 100644 --- a/osal/host/FixedTimeslotTask.cpp +++ b/osal/host/FixedTimeslotTask.cpp @@ -90,9 +90,12 @@ ReturnValue_t FixedTimeslotTask::sleepFor(uint32_t ms) { } void FixedTimeslotTask::taskFunctionality() { + pollingSeqTable.intializeSequenceAfterTaskCreation(); + // A local iterator for the Polling Sequence Table is created to // find the start time for the first entry. - FixedSlotSequence::SlotListIter slotListIter = pollingSeqTable.current; + auto slotListIter = pollingSeqTable.current; + // Get start time for first entry. chron_ms interval(slotListIter->pollingTimeMs); auto currentStartTime { @@ -124,7 +127,7 @@ ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId, uint32_t slotTimeMs, int8_t executionStep) { ExecutableObjectIF* executableObject = objectManager-> get(componentId); - if (executableObject!= nullptr) { + if (executableObject != nullptr) { pollingSeqTable.addSlot(componentId, slotTimeMs, executionStep, executableObject, this); return HasReturnvaluesIF::RETURN_OK; @@ -135,7 +138,7 @@ ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId, return HasReturnvaluesIF::RETURN_FAILED; } -ReturnValue_t FixedTimeslotTask::checkAndInitializeSequence() const { +ReturnValue_t FixedTimeslotTask::checkSequence() const { return pollingSeqTable.checkSequence(); } diff --git a/osal/host/FixedTimeslotTask.h b/osal/host/FixedTimeslotTask.h index 3ea97b97..9985e2ee 100644 --- a/osal/host/FixedTimeslotTask.h +++ b/osal/host/FixedTimeslotTask.h @@ -61,7 +61,7 @@ public: ReturnValue_t addSlot(object_id_t componentId, uint32_t slotTimeMs, int8_t executionStep); - ReturnValue_t checkAndInitializeSequence() const; + ReturnValue_t checkSequence() const override; uint32_t getPeriodMs() const; diff --git a/osal/host/QueueMapManager.cpp b/osal/host/QueueMapManager.cpp index a466c3f8..6007e9f3 100644 --- a/osal/host/QueueMapManager.cpp +++ b/osal/host/QueueMapManager.cpp @@ -37,7 +37,7 @@ ReturnValue_t QueueMapManager::addMessageQueue( MessageQueueIF* QueueMapManager::getMessageQueue( MessageQueueId_t messageQueueId) const { - MutexHelper(MutexIF::TimeoutType::WAITING, mapLock, 50); + MutexHelper(mapLock, MutexIF::TimeoutType::WAITING, 50); auto queueIter = queueMap.find(messageQueueId); if(queueIter != queueMap.end()) { return queueIter->second; diff --git a/timemanager/CCSDSTime.cpp b/timemanager/CCSDSTime.cpp index 130b3175..12ecf34a 100644 --- a/timemanager/CCSDSTime.cpp +++ b/timemanager/CCSDSTime.cpp @@ -3,6 +3,10 @@ #include #include +#ifndef SCNu8 + #define SCNu8 "hhu" +#endif + CCSDSTime::CCSDSTime() { } From 883103af2b4de3e099180e1fb999af974675e7ff Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 5 Sep 2020 21:13:07 +0200 Subject: [PATCH 021/192] queue map manager update --- osal/host/QueueMapManager.cpp | 3 ++- osal/host/QueueMapManager.h | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/osal/host/QueueMapManager.cpp b/osal/host/QueueMapManager.cpp index 6007e9f3..1b2094e9 100644 --- a/osal/host/QueueMapManager.cpp +++ b/osal/host/QueueMapManager.cpp @@ -1,6 +1,7 @@ +#include "QueueMapManager.h" + #include "../../ipc/MutexFactory.h" #include "../../ipc/MutexHelper.h" -#include "../../osal/host/QueueMapManager.h" QueueMapManager* QueueMapManager::mqManagerInstance = nullptr; diff --git a/osal/host/QueueMapManager.h b/osal/host/QueueMapManager.h index 823fd4c2..d7d5c915 100644 --- a/osal/host/QueueMapManager.h +++ b/osal/host/QueueMapManager.h @@ -1,5 +1,5 @@ -#ifndef FRAMEWORK_OSAL_HOST_QUEUEMAP_H_ -#define FRAMEWORK_OSAL_HOST_QUEUEMAP_H_ +#ifndef FSFW_OSAL_HOST_QUEUEMAPMANAGER_H_ +#define FSFW_OSAL_HOST_QUEUEMAPMANAGER_H_ #include "../../ipc/MessageQueueSenderIF.h" #include "../../osal/host/MessageQueue.h" @@ -44,4 +44,4 @@ private: -#endif /* FRAMEWORK_OSAL_HOST_QUEUEMAP_H_ */ +#endif /* FSFW_OSAL_HOST_QUEUEMAPMANAGER_H_ */ From c43ae66205f6fc4c594075660d34b0f6317569fa Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 5 Sep 2020 21:18:30 +0200 Subject: [PATCH 022/192] some tweaks --- osal/host/MessageQueue.cpp | 8 +++++--- osal/host/Mutex.h | 6 +++--- osal/host/PeriodicTask.cpp | 6 +++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/osal/host/MessageQueue.cpp b/osal/host/MessageQueue.cpp index 59825084..bced3713 100644 --- a/osal/host/MessageQueue.cpp +++ b/osal/host/MessageQueue.cpp @@ -1,6 +1,7 @@ -#include "../../osal/host/MessageQueue.h" +#include "MessageQueue.h" +#include "QueueMapManager.h" + #include "../../serviceinterface/ServiceInterfaceStream.h" -#include "../../osal/host/QueueMapManager.h" #include "../../ipc/MutexFactory.h" #include "../../ipc/MutexHelper.h" @@ -9,7 +10,8 @@ MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize): queueLock = MutexFactory::instance()->createMutex(); auto result = QueueMapManager::instance()->addMessageQueue(this, &mqId); if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "MessageQueue: Could not be created" << std::endl; + sif::error << "MessageQueue::MessageQueue:" + << " Could not be created" << std::endl; } } diff --git a/osal/host/Mutex.h b/osal/host/Mutex.h index b755bc30..24dafbbd 100644 --- a/osal/host/Mutex.h +++ b/osal/host/Mutex.h @@ -1,5 +1,5 @@ -#ifndef FRAMEWORK_OSAL_FREERTOS_MUTEX_H_ -#define FRAMEWORK_OSAL_FREERTOS_MUTEX_H_ +#ifndef FSFW_OSAL_HOSTED_MUTEX_H_ +#define FSFW_OSAL_HOSTED_MUTEX_H_ #include "../../ipc/MutexIF.h" @@ -26,4 +26,4 @@ private: std::timed_mutex mutex; }; -#endif /* FRAMEWORK_FREERTOS_MUTEX_H_ */ +#endif /* FSFW_OSAL_HOSTED_MUTEX_H_ */ diff --git a/osal/host/PeriodicTask.cpp b/osal/host/PeriodicTask.cpp index 0b5f8bbe..f4ee079b 100644 --- a/osal/host/PeriodicTask.cpp +++ b/osal/host/PeriodicTask.cpp @@ -1,7 +1,7 @@ -#include "../../ipc/MutexFactory.h" -#include "../../osal/host/Mutex.h" -#include "../../osal/host/PeriodicTask.h" +#include "Mutex.h" +#include "PeriodicTask.h" +#include "../../ipc/MutexFactory.h" #include "../../serviceinterface/ServiceInterfaceStream.h" #include "../../tasks/ExecutableObjectIF.h" From 7a24f899158ad8b6a3a74ff2da8a0ba530dc8539 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 5 Sep 2020 21:19:15 +0200 Subject: [PATCH 023/192] removed comment --- osal/host/TaskFactory.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/osal/host/TaskFactory.cpp b/osal/host/TaskFactory.cpp index 37df981a..bc65504c 100644 --- a/osal/host/TaskFactory.cpp +++ b/osal/host/TaskFactory.cpp @@ -25,8 +25,6 @@ PeriodicTaskIF* TaskFactory::createPeriodicTask(TaskName name_, TaskPriority taskPriority_,TaskStackSize stackSize_, TaskPeriod periodInSeconds_, TaskDeadlineMissedFunction deadLineMissedFunction_) { - // This is going to be interesting. Time now learn the C++ threading library - // :-) return new PeriodicTask(name_, taskPriority_, stackSize_, periodInSeconds_, deadLineMissedFunction_); } @@ -35,8 +33,6 @@ FixedTimeslotTaskIF* TaskFactory::createFixedTimeslotTask(TaskName name_, TaskPriority taskPriority_,TaskStackSize stackSize_, TaskPeriod periodInSeconds_, TaskDeadlineMissedFunction deadLineMissedFunction_) { - // This is going to be interesting. Time now learn the C++ threading library - // :-) return new FixedTimeslotTask(name_, taskPriority_, stackSize_, periodInSeconds_, deadLineMissedFunction_); } From cb970b1883b35412b64145ddff4f1c5eb1604529 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 5 Sep 2020 21:24:59 +0200 Subject: [PATCH 024/192] task IF is set now --- osal/host/PeriodicTask.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/osal/host/PeriodicTask.cpp b/osal/host/PeriodicTask.cpp index f4ee079b..3157ffb7 100644 --- a/osal/host/PeriodicTask.cpp +++ b/osal/host/PeriodicTask.cpp @@ -101,13 +101,14 @@ void PeriodicTask::taskFunctionality() { if(terminateThread.load()) { break; } - for (ObjectList::iterator it = objectList.begin(); - it != objectList.end(); ++it) { - (*it)->performOperation(); + for (const auto& object: objectList) { + object->performOperation(); } if(not delayForInterval(¤tStartTime, periodChrono)) { +#ifdef DEBUG sif::warning << "PeriodicTask: " << taskName << " missed deadline!\n" << std::flush; +#endif if(deadlineMissedFunc != nullptr) { this->deadlineMissedFunc(); } @@ -121,6 +122,7 @@ ReturnValue_t PeriodicTask::addComponent(object_id_t object) { if (newObject == nullptr) { return HasReturnvaluesIF::RETURN_FAILED; } + newObject->setTaskIF(this); objectList.push_back(newObject); return HasReturnvaluesIF::RETURN_OK; } From c7606b7b1e870b510488da7d72c0dbe9b47e6ddb Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 5 Sep 2020 21:51:17 +0200 Subject: [PATCH 025/192] updating and cleaning pool files --- datapool/PoolDataSetBase.h | 11 ++++++----- datapool/PoolDataSetIF.h | 7 ++++--- datapool/PoolEntry.cpp | 3 ++- datapool/PoolEntry.h | 8 ++++---- datapool/PoolEntryIF.h | 6 +++--- datapool/PoolRawAccessHelper.cpp | 9 +-------- datapool/PoolRawAccessHelper.h | 10 ++-------- datapoolglob/DataPoolAdmin.cpp | 9 +++++---- datapoolglob/DataPoolAdmin.h | 13 +++++++------ datapoolglob/GlobalPoolVector.h | 6 +++--- datapoolglob/GlobalPoolVector.tpp | 4 ++-- datapoollocal/HasLocalDataPoolIF.h | 7 ++++--- datapoollocal/LocalDataSet.h | 9 +++++---- 13 files changed, 48 insertions(+), 54 deletions(-) diff --git a/datapool/PoolDataSetBase.h b/datapool/PoolDataSetBase.h index 66662413..a8931d62 100644 --- a/datapool/PoolDataSetBase.h +++ b/datapool/PoolDataSetBase.h @@ -1,7 +1,8 @@ -#ifndef FRAMEWORK_DATAPOOL_DATASETBASE_H_ -#define FRAMEWORK_DATAPOOL_DATASETBASE_H_ -#include "../datapool/PoolDataSetIF.h" -#include "../datapool/PoolVariableIF.h" +#ifndef FSFW_DATAPOOL_POOLDATASETBASE_H_ +#define FSFW_DATAPOOL_POOLDATASETBASE_H_ + +#include "PoolDataSetIF.h" +#include "PoolVariableIF.h" #include "../ipc/MutexIF.h" /** @@ -148,4 +149,4 @@ private: ReturnValue_t handleUnreadDatasetCommit(uint32_t lockTimeout); }; -#endif /* FRAMEWORK_DATAPOOL_POOLPOOLDATASETBASE_H_ */ +#endif /* FSFW_DATAPOOL_POOLDATASETBASE_H_ */ diff --git a/datapool/PoolDataSetIF.h b/datapool/PoolDataSetIF.h index 44ca468b..78c05d43 100644 --- a/datapool/PoolDataSetIF.h +++ b/datapool/PoolDataSetIF.h @@ -1,5 +1,6 @@ -#ifndef FRAMEWORK_DATAPOOL_POOLDATASETIF_H_ -#define FRAMEWORK_DATAPOOL_POOLDATASETIF_H_ +#ifndef FSFW_DATAPOOL_POOLDATASETIF_H_ +#define FSFW_DATAPOOL_POOLDATASETIF_H_ + #include "DataSetIF.h" class PoolDataSetIF: public DataSetIF { @@ -25,4 +26,4 @@ public: virtual bool isValid() const = 0; }; -#endif /* FRAMEWORK_DATAPOOL_POOLDATASETIF_H_ */ +#endif /* FSFW_DATAPOOL_POOLDATASETIF_H_ */ diff --git a/datapool/PoolEntry.cpp b/datapool/PoolEntry.cpp index b0506b82..fb73328c 100644 --- a/datapool/PoolEntry.cpp +++ b/datapool/PoolEntry.cpp @@ -1,4 +1,5 @@ -#include "../datapool/PoolEntry.h" +#include "PoolEntry.h" + #include "../serviceinterface/ServiceInterfaceStream.h" #include "../globalfunctions/arrayprinter.h" #include diff --git a/datapool/PoolEntry.h b/datapool/PoolEntry.h index 6a3daacf..033db40d 100644 --- a/datapool/PoolEntry.h +++ b/datapool/PoolEntry.h @@ -1,7 +1,7 @@ -#ifndef FRAMEWORK_DATAPOOL_POOLENTRY_H_ -#define FRAMEWORK_DATAPOOL_POOLENTRY_H_ +#ifndef FSFW_DATAPOOL_POOLENTRY_H_ +#define FSFW_DATAPOOL_POOLENTRY_H_ -#include "../datapool/PoolEntryIF.h" +#include "PoolEntryIF.h" #include #include @@ -127,4 +127,4 @@ public: Type getType(); }; -#endif /* POOLENTRY_H_ */ +#endif /* FSFW_DATAPOOL_POOLENTRY_H_ */ diff --git a/datapool/PoolEntryIF.h b/datapool/PoolEntryIF.h index 462de18b..d9db5237 100644 --- a/datapool/PoolEntryIF.h +++ b/datapool/PoolEntryIF.h @@ -1,5 +1,5 @@ -#ifndef FRAMEWORK_DATAPOOL_POOLENTRYIF_H_ -#define FRAMEWORK_DATAPOOL_POOLENTRYIF_H_ +#ifndef FSFW_DATAPOOL_POOLENTRYIF_H_ +#define FSFW_DATAPOOL_POOLENTRYIF_H_ #include "../globalfunctions/Type.h" #include @@ -60,4 +60,4 @@ public: virtual Type getType() = 0; }; -#endif /* POOLENTRYIF_H_ */ +#endif /* FSFW_DATAPOOL_POOLENTRYIF_H_ */ diff --git a/datapool/PoolRawAccessHelper.cpp b/datapool/PoolRawAccessHelper.cpp index 3696a21d..5a6827b6 100644 --- a/datapool/PoolRawAccessHelper.cpp +++ b/datapool/PoolRawAccessHelper.cpp @@ -1,11 +1,4 @@ -/** - * @file PoolRawAccessHelper.cpp - * - * @date 22.12.2019 - * @author R. Mueller - */ - -#include "../datapool/PoolRawAccessHelper.h" +#include "PoolRawAccessHelper.h" #include "../datapoolglob/GlobalDataSet.h" #include "../serialize/SerializeAdapter.h" #include "../serviceinterface/ServiceInterfaceStream.h" diff --git a/datapool/PoolRawAccessHelper.h b/datapool/PoolRawAccessHelper.h index db25acdf..6ff3e955 100644 --- a/datapool/PoolRawAccessHelper.h +++ b/datapool/PoolRawAccessHelper.h @@ -1,11 +1,5 @@ -/** - * @file PoolRawAccessHelper.h - * - * @date 22.12.2019 - */ - -#ifndef FRAMEWORK_DATAPOOL_POOLRAWACCESSHELPER_H_ -#define FRAMEWORK_DATAPOOL_POOLRAWACCESSHELPER_H_ +#ifndef FSFW_DATAPOOL_POOLRAWACCESSHELPER_H_ +#define FSFW_DATAPOOL_POOLRAWACCESSHELPER_H_ #include "../returnvalues/HasReturnvaluesIF.h" #include "../datapoolglob/GlobalDataSet.h" diff --git a/datapoolglob/DataPoolAdmin.cpp b/datapoolglob/DataPoolAdmin.cpp index 029a336d..6ede0841 100644 --- a/datapoolglob/DataPoolAdmin.cpp +++ b/datapoolglob/DataPoolAdmin.cpp @@ -1,7 +1,8 @@ -#include "../datapoolglob/DataPoolAdmin.h" -#include "../datapoolglob/GlobalDataSet.h" -#include "../datapoolglob/GlobalDataPool.h" -#include "../datapoolglob/PoolRawAccess.h" +#include "DataPoolAdmin.h" +#include "GlobalDataSet.h" +#include "GlobalDataPool.h" +#include "PoolRawAccess.h" + #include "../ipc/CommandMessage.h" #include "../ipc/QueueFactory.h" #include "../parameters/ParameterMessage.h" diff --git a/datapoolglob/DataPoolAdmin.h b/datapoolglob/DataPoolAdmin.h index a08f322d..d8871b65 100644 --- a/datapoolglob/DataPoolAdmin.h +++ b/datapoolglob/DataPoolAdmin.h @@ -1,5 +1,7 @@ -#ifndef DATAPOOLADMIN_H_ -#define DATAPOOLADMIN_H_ +#ifndef FSFW_DATAPOOLGLOB_DATAPOOLADMIN_H_ +#define FSFW_DATAPOOLGLOB_DATAPOOLADMIN_H_ + +#include "DataPoolParameterWrapper.h" #include "../objectmanager/SystemObject.h" #include "../returnvalues/HasReturnvaluesIF.h" @@ -7,10 +9,9 @@ #include "../action/HasActionsIF.h" #include "../ipc/MessageQueueIF.h" #include "../parameters/ReceivesParameterMessagesIF.h" - -#include "../memory/MemoryHelper.h" #include "../action/SimpleActionHelper.h" -#include "../datapoolglob/DataPoolParameterWrapper.h" +#include "../memory/MemoryHelper.h" + class DataPoolAdmin: public HasActionsIF, public ExecutableObjectIF, @@ -56,4 +57,4 @@ private: Command_t initialCommand); }; -#endif /* DATAPOOLADMIN_H_ */ +#endif /* FSFW_DATAPOOLGLOB_DATAPOOLADMIN_H_ */ diff --git a/datapoolglob/GlobalPoolVector.h b/datapoolglob/GlobalPoolVector.h index 6b592fc6..0f5daacd 100644 --- a/datapoolglob/GlobalPoolVector.h +++ b/datapoolglob/GlobalPoolVector.h @@ -1,5 +1,5 @@ -#ifndef GLOBALPOOLVECTOR_H_ -#define GLOBALPOOLVECTOR_H_ +#ifndef FSFW_DATAPOOLGLOB_GLOBALPOOLVECTOR_H_ +#define FSFW_DATAPOOLGLOB_GLOBALPOOLVECTOR_H_ #include "../datapool/DataSetIF.h" #include "../datapool/PoolEntry.h" @@ -182,4 +182,4 @@ private: template using gp_vec_t = GlobPoolVector; -#endif /* POOLVECTOR_H_ */ +#endif /* FSFW_DATAPOOLGLOB_GLOBALPOOLVECTOR_H_ */ diff --git a/datapoolglob/GlobalPoolVector.tpp b/datapoolglob/GlobalPoolVector.tpp index ccf33138..013a682a 100644 --- a/datapoolglob/GlobalPoolVector.tpp +++ b/datapoolglob/GlobalPoolVector.tpp @@ -1,5 +1,5 @@ -#ifndef GLOBALPOOLVECTOR_TPP_ -#define GLOBALPOOLVECTOR_TPP_ +#ifndef FSFW_DATAPOOLGLOB_GLOBALPOOLVECTOR_TPP_ +#define FSFW_DATAPOOLGLOB_GLOBALPOOLVECTOR_TPP_ template diff --git a/datapoollocal/HasLocalDataPoolIF.h b/datapoollocal/HasLocalDataPoolIF.h index 9eb1c9f1..3e6b843f 100644 --- a/datapoollocal/HasLocalDataPoolIF.h +++ b/datapoollocal/HasLocalDataPoolIF.h @@ -1,5 +1,6 @@ -#ifndef FRAMEWORK_DATAPOOL_HASHKPOOLPARAMETERSIF_H_ -#define FRAMEWORK_DATAPOOL_HASHKPOOLPARAMETERSIF_H_ +#ifndef FSFW_DATAPOOLLOCAL_HASLOCALDATAPOOLIF_H_ +#define FSFW_DATAPOOLLOCAL_HASLOCALDATAPOOLIF_H_ + #include "../datapool/PoolEntryIF.h" #include "../ipc/MessageQueueSenderIF.h" #include "../housekeeping/HousekeepingMessage.h" @@ -89,4 +90,4 @@ public: }; }; -#endif /* FRAMEWORK_DATAPOOL_HASHKPOOLPARAMETERSIF_H_ */ +#endif /* FSFW_DATAPOOLLOCAL_HASLOCALDATAPOOLIF_H_ */ diff --git a/datapoollocal/LocalDataSet.h b/datapoollocal/LocalDataSet.h index 5641ebfb..0368f26d 100644 --- a/datapoollocal/LocalDataSet.h +++ b/datapoollocal/LocalDataSet.h @@ -1,6 +1,7 @@ -#ifndef FRAMEWORK_DATAPOOLLOCAL_LOCALDATASET_H_ -#define FRAMEWORK_DATAPOOLLOCAL_LOCALDATASET_H_ -#include "../datapoollocal/LocalPoolDataSetBase.h" +#ifndef FSFW_DATAPOOLLOCAL_LOCALDATASET_H_ +#define FSFW_DATAPOOLLOCAL_LOCALDATASET_H_ + +#include "LocalPoolDataSetBase.h" #include class LocalDataSet: public LocalPoolDataSetBase { @@ -17,4 +18,4 @@ private: std::vector poolVarList; }; -#endif /* FRAMEWORK_DATAPOOLLOCAL_LOCALDATASET_H_ */ +#endif /* FSFW_DATAPOOLLOCAL_LOCALDATASET_H_ */ From f698275a0bafc6494780f9b65858ca7d920e8e5a Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 5 Sep 2020 21:59:17 +0200 Subject: [PATCH 026/192] removed seconds typedef, confusing --- datapoollocal/HasLocalDataPoolIF.h | 4 +++- datapoollocal/LocalPoolDataSetBase.h | 9 +++++---- datapoollocal/SharedLocalDataSet.h | 9 +++++---- datapoollocal/StaticLocalDataSet.h | 12 +++++++----- timemanager/Clock.h | 1 - timemanager/Stopwatch.cpp | 2 +- timemanager/Stopwatch.h | 2 +- 7 files changed, 22 insertions(+), 17 deletions(-) diff --git a/datapoollocal/HasLocalDataPoolIF.h b/datapoollocal/HasLocalDataPoolIF.h index 3e6b843f..4b49ee11 100644 --- a/datapoollocal/HasLocalDataPoolIF.h +++ b/datapoollocal/HasLocalDataPoolIF.h @@ -4,6 +4,8 @@ #include "../datapool/PoolEntryIF.h" #include "../ipc/MessageQueueSenderIF.h" #include "../housekeeping/HousekeepingMessage.h" +#include "../timemanager/Clock.h" + #include class LocalDataPoolManager; @@ -85,7 +87,7 @@ public: return HasReturnvaluesIF::RETURN_FAILED; }; virtual ReturnValue_t changeCollectionInterval(sid_t sid, - dur_seconds_t newInterval) { + float newIntervalSeconds) { return HasReturnvaluesIF::RETURN_FAILED; }; }; diff --git a/datapoollocal/LocalPoolDataSetBase.h b/datapoollocal/LocalPoolDataSetBase.h index bd127db4..77c1df1b 100644 --- a/datapoollocal/LocalPoolDataSetBase.h +++ b/datapoollocal/LocalPoolDataSetBase.h @@ -1,8 +1,9 @@ -#ifndef FRAMEWORK_DATAPOOLLOCAL_LOCALPOOLDATASETBASE_H_ -#define FRAMEWORK_DATAPOOLLOCAL_LOCALPOOLDATASETBASE_H_ +#ifndef FSFW_DATAPOOLLOCAL_LOCALPOOLDATASETBASE_H_ +#define FSFW_DATAPOOLLOCAL_LOCALPOOLDATASETBASE_H_ + +#include "HasLocalDataPoolIF.h" #include "../datapool/DataSetIF.h" #include "../datapool/PoolDataSetBase.h" -#include "../datapoollocal/HasLocalDataPoolIF.h" #include "../serialize/SerializeIF.h" #include @@ -130,4 +131,4 @@ private: }; -#endif /* FRAMEWORK_DATAPOOLLOCAL_LOCALPOOLDATASETBASE_H_ */ +#endif /* FSFW_DATAPOOLLOCAL_LOCALPOOLDATASETBASE_H_ */ diff --git a/datapoollocal/SharedLocalDataSet.h b/datapoollocal/SharedLocalDataSet.h index f6748e4d..b1f9aa3d 100644 --- a/datapoollocal/SharedLocalDataSet.h +++ b/datapoollocal/SharedLocalDataSet.h @@ -1,7 +1,8 @@ -#ifndef FRAMEWORK_DATAPOOLLOCAL_SHAREDLOCALDATASET_H_ -#define FRAMEWORK_DATAPOOLLOCAL_SHAREDLOCALDATASET_H_ +#ifndef FSFW_DATAPOOLLOCAL_SHAREDLOCALDATASET_H_ +#define FSFW_DATAPOOLLOCAL_SHAREDLOCALDATASET_H_ + +#include "LocalPoolDataSetBase.h" #include "../datapool/SharedDataSetIF.h" -#include "../datapoollocal/LocalPoolDataSetBase.h" #include "../objectmanager/SystemObject.h" #include @@ -28,4 +29,4 @@ private: -#endif /* FRAMEWORK_DATAPOOLLOCAL_SHAREDLOCALDATASET_H_ */ +#endif /* FSFW_DATAPOOLLOCAL_SHAREDLOCALDATASET_H_ */ diff --git a/datapoollocal/StaticLocalDataSet.h b/datapoollocal/StaticLocalDataSet.h index b3e8422c..7c2f0039 100644 --- a/datapoollocal/StaticLocalDataSet.h +++ b/datapoollocal/StaticLocalDataSet.h @@ -1,5 +1,6 @@ -#ifndef FRAMEWORK_DATAPOOLLOCAL_STATICLOCALDATASET_H_ -#define FRAMEWORK_DATAPOOLLOCAL_STATICLOCALDATASET_H_ +#ifndef FSFW_DATAPOOLLOCAL_STATICLOCALDATASET_H_ +#define FSFW_DATAPOOLLOCAL_STATICLOCALDATASET_H_ + #include "LocalPoolDataSetBase.h" #include "../objectmanager/SystemObjectIF.h" #include @@ -16,12 +17,13 @@ template class StaticLocalDataSet: public LocalPoolDataSetBase { public: - StaticLocalDataSet(sid_t sid): - LocalPoolDataSetBase(sid, poolVarList.data(), NUM_VARIABLES) { + StaticLocalDataSet(sid_t sid): LocalPoolDataSetBase(sid, nullptr, + NUM_VARIABLES) { + this->setContainer(poolVarList.data()); } private: std::array poolVarList; }; -#endif /* FRAMEWORK_DATAPOOLLOCAL_STATICLOCALDATASET_H_ */ +#endif /* FSFW_DATAPOOLLOCAL_STATICLOCALDATASET_H_ */ diff --git a/timemanager/Clock.h b/timemanager/Clock.h index 9463b5a6..acb68e2e 100644 --- a/timemanager/Clock.h +++ b/timemanager/Clock.h @@ -10,7 +10,6 @@ //! Don't use these for time points, type is not large enough for UNIX epoch. using dur_millis_t = uint32_t; -using dur_seconds_t = double; class Clock { public: diff --git a/timemanager/Stopwatch.cpp b/timemanager/Stopwatch.cpp index 637c5078..28ae4543 100644 --- a/timemanager/Stopwatch.cpp +++ b/timemanager/Stopwatch.cpp @@ -18,7 +18,7 @@ dur_millis_t Stopwatch::stop() { return elapsedTime.tv_sec * 1000 + elapsedTime.tv_usec / 1000; } -dur_seconds_t Stopwatch::stopSeconds() { +double Stopwatch::stopSeconds() { stopInternal(); return timevalOperations::toDouble(elapsedTime); } diff --git a/timemanager/Stopwatch.h b/timemanager/Stopwatch.h index 191929dc..49b686f9 100644 --- a/timemanager/Stopwatch.h +++ b/timemanager/Stopwatch.h @@ -45,7 +45,7 @@ public: * Calculates the elapsed time since start and returns it * @return elapsed time in seconds (double precision) */ - dur_seconds_t stopSeconds(); + double stopSeconds(); /** * Displays the elapsed times on the osstream, depending on internal display From 08ffbfefae6ea75186a6b405afacc1b9e73e0f55 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sun, 6 Sep 2020 09:33:02 +0200 Subject: [PATCH 027/192] added windows udp bridge --- osal/host/FixedTimeslotTask.cpp | 17 +++++----- osal/host/Mutex.h | 6 ++-- osal/host/TmTcWinUdpBridge.cpp | 57 ++++++++++++++++++++++++++++++++ osal/host/TmTcWinUdpBridge.h | 47 ++++++++++++++++++++++++++ osal/linux/TmTcUnixUdpBridge.cpp | 2 +- 5 files changed, 116 insertions(+), 13 deletions(-) create mode 100644 osal/host/TmTcWinUdpBridge.cpp create mode 100644 osal/host/TmTcWinUdpBridge.h diff --git a/osal/host/FixedTimeslotTask.cpp b/osal/host/FixedTimeslotTask.cpp index e78c974a..3c31eb76 100644 --- a/osal/host/FixedTimeslotTask.cpp +++ b/osal/host/FixedTimeslotTask.cpp @@ -1,9 +1,7 @@ -#include "../../osal/host/FixedTimeslotTask.h" +#include "FixedTimeslotTask.h" +#include "Mutex.h" #include "../../ipc/MutexFactory.h" -#include "../../osal/host/Mutex.h" -#include "../../osal/host/FixedTimeslotTask.h" - #include "../../serviceinterface/ServiceInterfaceStream.h" #include "../../tasks/ExecutableObjectIF.h" @@ -35,15 +33,15 @@ FixedTimeslotTask::FixedTimeslotTask(const char *name, TaskPriority setPriority, reinterpret_cast(mainThread.native_handle()), ABOVE_NORMAL_PRIORITY_CLASS); if(result != 0) { - sif::error << "FixedTimeslotTask: Windows SetPriorityClass failed with code " - << GetLastError() << std::endl; + sif::error << "FixedTimeslotTask: Windows SetPriorityClass failed with " + << "code " << GetLastError() << std::endl; } result = SetThreadPriority( reinterpret_cast(mainThread.native_handle()), THREAD_PRIORITY_NORMAL); if(result != 0) { - sif::error << "FixedTimeslotTask: Windows SetPriorityClass failed with code " - << GetLastError() << std::endl; + sif::error << "FixedTimeslotTask: Windows SetPriorityClass failed with " + "code " << GetLastError() << std::endl; } #elif defined(LINUX) // we can just copy and paste the code from linux here. @@ -60,7 +58,8 @@ FixedTimeslotTask::~FixedTimeslotTask(void) { } void FixedTimeslotTask::taskEntryPoint(void* argument) { - FixedTimeslotTask *originalTask(reinterpret_cast(argument)); + FixedTimeslotTask *originalTask( + reinterpret_cast(argument)); if (not originalTask->started) { // we have to suspend/block here until the task is started. diff --git a/osal/host/Mutex.h b/osal/host/Mutex.h index 24dafbbd..af56b8f7 100644 --- a/osal/host/Mutex.h +++ b/osal/host/Mutex.h @@ -1,5 +1,5 @@ -#ifndef FSFW_OSAL_HOSTED_MUTEX_H_ -#define FSFW_OSAL_HOSTED_MUTEX_H_ +#ifndef FSFW_OSAL_HOST_MUTEX_H_ +#define FSFW_OSAL_HOST_MUTEX_H_ #include "../../ipc/MutexIF.h" @@ -26,4 +26,4 @@ private: std::timed_mutex mutex; }; -#endif /* FSFW_OSAL_HOSTED_MUTEX_H_ */ +#endif /* FSFW_OSAL_HOST_MUTEX_H_ */ diff --git a/osal/host/TmTcWinUdpBridge.cpp b/osal/host/TmTcWinUdpBridge.cpp new file mode 100644 index 00000000..b7b43b13 --- /dev/null +++ b/osal/host/TmTcWinUdpBridge.cpp @@ -0,0 +1,57 @@ +#include "TmTcWinUdpBridge.h" + +TmTcWinUdpBridge::TmTcWinUdpBridge(object_id_t objectId, + object_id_t tcDestination, object_id_t tmStoreId, object_id_t tcStoreId, + uint16_t serverPort, uint16_t clientPort): + TmTcBridge(objectId, tcDestination, tmStoreId, tcStoreId) { + mutex = MutexFactory::instance()->createMutex(); + + uint16_t setServerPort = DEFAULT_UDP_SERVER_PORT; + if(serverPort != 0xFFFF) { + setServerPort = serverPort; + } + + uint16_t setClientPort = DEFAULT_UDP_CLIENT_PORT; + if(clientPort != 0xFFFF) { + setClientPort = clientPort; + } + + // Set up UDP socket: https://man7.org/linux/man-pages/man7/ip.7.html + //clientSocket = socket(AF_INET, SOCK_DGRAM, 0); + serverSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + if(socket < 0) { + sif::error << "TmTcUnixUdpBridge::TmTcUnixUdpBridge: Could not open" + " UDP socket!" << std::endl; + handleSocketError(); + return; + } + + serverAddress.sin_family = AF_INET; + + // Accept packets from any interface. + //serverAddress.sin_addr.s_addr = inet_addr("127.73.73.0"); + serverAddress.sin_addr.s_addr = htonl(INADDR_ANY); + serverAddress.sin_port = htons(setServerPort); + //serverAddressLen = sizeof(serverAddress); + setsockopt(serverSocket, SOL_SOCKET, SO_REUSEADDR, + reinterpret_cast(&serverSocketOptions), + sizeof(serverSocketOptions)); + + clientAddress.sin_family = AF_INET; + clientAddress.sin_addr.s_addr = htonl(INADDR_ANY); + clientAddress.sin_port = htons(setClientPort); + //clientAddressLen = sizeof(clientAddress); + + int result = bind(serverSocket, + reinterpret_cast(&serverAddress), + serverAddressLen); + if(result == -1) { + sif::error << "TmTcUnixUdpBridge::TmTcUnixUdpBridge: Could not bind " + "local port " << setServerPort << " to server socket!" + << std::endl; + handleBindError(); + return; + } +} + + diff --git a/osal/host/TmTcWinUdpBridge.h b/osal/host/TmTcWinUdpBridge.h new file mode 100644 index 00000000..66463065 --- /dev/null +++ b/osal/host/TmTcWinUdpBridge.h @@ -0,0 +1,47 @@ +#ifndef FSFW_OSAL_HOST_TMTCWINUDPBRIDGE_H_ +#define FSFW_OSAL_HOST_TMTCWINUDPBRIDGE_H_ + +#include "../../tmtcservices/TmTcBridge.h" +#include + +class TmTcWinUdpBridge: public TmTcBridge { + friend class TcWinUdpPollingTask; +public: + // The ports chosen here should not be used by any other process. + // List of used ports on Linux: /etc/services + static constexpr uint16_t DEFAULT_UDP_SERVER_PORT = 7301; + static constexpr uint16_t DEFAULT_UDP_CLIENT_PORT = 7302; + + TmTcWinUdpBridge(object_id_t objectId, object_id_t tcDestination, + object_id_t tmStoreId, object_id_t tcStoreId, + uint16_t serverPort = 0xFFFF,uint16_t clientPort = 0xFFFF); + virtual~ TmTcWinUdpBridge(); + + void checkAndSetClientAddress(sockaddr_in clientAddress); + +protected: + virtual ReturnValue_t sendTm(const uint8_t * data, size_t dataLen) override; + +private: + SOCKET serverSocket = 0; + + const int serverSocketOptions = 0; + + struct sockaddr_in clientAddress; + //socklen_t clientAddressLen = 0; + + struct sockaddr_in serverAddress; + //socklen_t serverAddressLen = 0; + + //! Access to the client address is mutex protected as it is set + //! by another task. + MutexIF* mutex; + + void handleSocketError(); + void handleBindError(); + void handleSendError(); +}; + + + +#endif /* FSFW_OSAL_HOST_TMTCWINUDPBRIDGE_H_ */ diff --git a/osal/linux/TmTcUnixUdpBridge.cpp b/osal/linux/TmTcUnixUdpBridge.cpp index 3e9674f3..d0c9517f 100644 --- a/osal/linux/TmTcUnixUdpBridge.cpp +++ b/osal/linux/TmTcUnixUdpBridge.cpp @@ -24,7 +24,7 @@ TmTcUnixUdpBridge::TmTcUnixUdpBridge(object_id_t objectId, // Set up UDP socket: https://man7.org/linux/man-pages/man7/ip.7.html //clientSocket = socket(AF_INET, SOCK_DGRAM, 0); serverSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - if(socket < 0) { + if(serverSocket < 0) { sif::error << "TmTcUnixUdpBridge::TmTcUnixUdpBridge: Could not open" " UDP socket!" << std::endl; handleSocketError(); From 0c85b05aca4d7a1adc8f5bf1a85133c845ecc63f Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sun, 6 Sep 2020 09:54:22 +0200 Subject: [PATCH 028/192] continued win bridge --- osal/host/TmTcWinUdpBridge.cpp | 24 ++++++++++++++++++++---- osal/host/TmTcWinUdpBridge.h | 4 ++-- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/osal/host/TmTcWinUdpBridge.cpp b/osal/host/TmTcWinUdpBridge.cpp index b7b43b13..4bb9a3b1 100644 --- a/osal/host/TmTcWinUdpBridge.cpp +++ b/osal/host/TmTcWinUdpBridge.cpp @@ -19,8 +19,8 @@ TmTcWinUdpBridge::TmTcWinUdpBridge(object_id_t objectId, // Set up UDP socket: https://man7.org/linux/man-pages/man7/ip.7.html //clientSocket = socket(AF_INET, SOCK_DGRAM, 0); serverSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - if(socket < 0) { - sif::error << "TmTcUnixUdpBridge::TmTcUnixUdpBridge: Could not open" + if(serverSocket != 0) { + sif::error << "TmTcWinUdpBridge::TmTcWinUdpBridge: Could not open" " UDP socket!" << std::endl; handleSocketError(); return; @@ -32,7 +32,7 @@ TmTcWinUdpBridge::TmTcWinUdpBridge(object_id_t objectId, //serverAddress.sin_addr.s_addr = inet_addr("127.73.73.0"); serverAddress.sin_addr.s_addr = htonl(INADDR_ANY); serverAddress.sin_port = htons(setServerPort); - //serverAddressLen = sizeof(serverAddress); + serverAddressLen = sizeof(serverAddress); setsockopt(serverSocket, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast(&serverSocketOptions), sizeof(serverSocketOptions)); @@ -40,7 +40,7 @@ TmTcWinUdpBridge::TmTcWinUdpBridge(object_id_t objectId, clientAddress.sin_family = AF_INET; clientAddress.sin_addr.s_addr = htonl(INADDR_ANY); clientAddress.sin_port = htons(setClientPort); - //clientAddressLen = sizeof(clientAddress); + clientAddressLen = sizeof(clientAddress); int result = bind(serverSocket, reinterpret_cast(&serverAddress), @@ -54,4 +54,20 @@ TmTcWinUdpBridge::TmTcWinUdpBridge(object_id_t objectId, } } +TmTcWinUdpBridge::~TmTcWinUdpBridge() {} +void TmTcWinUdpBridge::handleSocketError() { +} + +void TmTcWinUdpBridge::handleBindError() { +} + +ReturnValue_t TmTcWinUdpBridge::sendTm(const uint8_t *data, size_t dataLen) { + return HasReturnvaluesIF::RETURN_OK; +} + +void TmTcWinUdpBridge::checkAndSetClientAddress(sockaddr_in clientAddress) { +} + +void TmTcWinUdpBridge::handleSendError() { +} diff --git a/osal/host/TmTcWinUdpBridge.h b/osal/host/TmTcWinUdpBridge.h index 66463065..8e6bb0fd 100644 --- a/osal/host/TmTcWinUdpBridge.h +++ b/osal/host/TmTcWinUdpBridge.h @@ -28,10 +28,10 @@ private: const int serverSocketOptions = 0; struct sockaddr_in clientAddress; - //socklen_t clientAddressLen = 0; + int clientAddressLen = 0; struct sockaddr_in serverAddress; - //socklen_t serverAddressLen = 0; + int serverAddressLen = 0; //! Access to the client address is mutex protected as it is set //! by another task. From b7c4f5ce05ec1c235cbea3b825d21ce4497dd095 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sun, 6 Sep 2020 10:36:39 +0200 Subject: [PATCH 029/192] continued win sockets --- osal/linux/TcUnixUdpPollingTask.cpp | 2 +- osal/linux/TmTcUnixUdpBridge.cpp | 3 +- osal/{host => windows}/TmTcWinUdpBridge.cpp | 73 ++++++++++++++++++--- osal/{host => windows}/TmTcWinUdpBridge.h | 10 +-- 4 files changed, 73 insertions(+), 15 deletions(-) rename osal/{host => windows}/TmTcWinUdpBridge.cpp (54%) rename osal/{host => windows}/TmTcWinUdpBridge.h (88%) diff --git a/osal/linux/TcUnixUdpPollingTask.cpp b/osal/linux/TcUnixUdpPollingTask.cpp index d8a39869..95910b02 100644 --- a/osal/linux/TcUnixUdpPollingTask.cpp +++ b/osal/linux/TcUnixUdpPollingTask.cpp @@ -1,4 +1,4 @@ -#include "../../osal/linux/TcUnixUdpPollingTask.h" +#include "TcUnixUdpPollingTask.h" #include "../../globalfunctions/arrayprinter.h" TcUnixUdpPollingTask::TcUnixUdpPollingTask(object_id_t objectId, diff --git a/osal/linux/TmTcUnixUdpBridge.cpp b/osal/linux/TmTcUnixUdpBridge.cpp index d0c9517f..2549a4b7 100644 --- a/osal/linux/TmTcUnixUdpBridge.cpp +++ b/osal/linux/TmTcUnixUdpBridge.cpp @@ -1,10 +1,11 @@ -#include "../../osal/linux/TmTcUnixUdpBridge.h" +#include "TmTcUnixUdpBridge.h" #include "../../serviceinterface/ServiceInterfaceStream.h" #include "../../ipc/MutexHelper.h" #include #include + TmTcUnixUdpBridge::TmTcUnixUdpBridge(object_id_t objectId, object_id_t tcDestination, object_id_t tmStoreId, object_id_t tcStoreId, uint16_t serverPort, uint16_t clientPort): diff --git a/osal/host/TmTcWinUdpBridge.cpp b/osal/windows/TmTcWinUdpBridge.cpp similarity index 54% rename from osal/host/TmTcWinUdpBridge.cpp rename to osal/windows/TmTcWinUdpBridge.cpp index 4bb9a3b1..c5902e88 100644 --- a/osal/host/TmTcWinUdpBridge.cpp +++ b/osal/windows/TmTcWinUdpBridge.cpp @@ -6,6 +6,18 @@ TmTcWinUdpBridge::TmTcWinUdpBridge(object_id_t objectId, TmTcBridge(objectId, tcDestination, tmStoreId, tcStoreId) { mutex = MutexFactory::instance()->createMutex(); + // Initiates Winsock DLL. + WSAData wsaData; + WORD wVersionRequested = MAKEWORD(2, 2); + int err = WSAStartup(wVersionRequested, &wsaData); + if (err != 0) { + /* Tell the user that we could not find a usable */ + /* Winsock DLL. */ + sif::error << "TmTcWinUdpBridge::TmTcWinUdpBridge:" + "WSAStartup failed with error: " << err << std::endl; + return; + } + uint16_t setServerPort = DEFAULT_UDP_SERVER_PORT; if(serverPort != 0xFFFF) { setServerPort = serverPort; @@ -45,8 +57,8 @@ TmTcWinUdpBridge::TmTcWinUdpBridge(object_id_t objectId, int result = bind(serverSocket, reinterpret_cast(&serverAddress), serverAddressLen); - if(result == -1) { - sif::error << "TmTcUnixUdpBridge::TmTcUnixUdpBridge: Could not bind " + if(result != 0) { + sif::error << "TmTcWinUdpBridge::TmTcWinUdpBridge: Could not bind " "local port " << setServerPort << " to server socket!" << std::endl; handleBindError(); @@ -54,12 +66,8 @@ TmTcWinUdpBridge::TmTcWinUdpBridge(object_id_t objectId, } } -TmTcWinUdpBridge::~TmTcWinUdpBridge() {} - -void TmTcWinUdpBridge::handleSocketError() { -} - -void TmTcWinUdpBridge::handleBindError() { +TmTcWinUdpBridge::~TmTcWinUdpBridge() { + WSACleanup(); } ReturnValue_t TmTcWinUdpBridge::sendTm(const uint8_t *data, size_t dataLen) { @@ -69,5 +77,52 @@ ReturnValue_t TmTcWinUdpBridge::sendTm(const uint8_t *data, size_t dataLen) { void TmTcWinUdpBridge::checkAndSetClientAddress(sockaddr_in clientAddress) { } -void TmTcWinUdpBridge::handleSendError() { +void TmTcWinUdpBridge::handleSocketError() { + int errCode = WSAGetLastError(); + switch(errCode) { + case(WSANOTINITIALISED): { + sif::info << "TmTcWinUdpBridge::handleSocketError: WSANOTINITIALISED: " + << "WSAStartup(...) call " << "necessary" << std::endl; + break; + } + default: { + sif::info << "TmTcWinUdpBridge::handleSocketError: Error code: " + << errCode << std::endl; + break; + } + } } + +void TmTcWinUdpBridge::handleBindError() { + int errCode = WSAGetLastError(); + switch(errCode) { + case(WSANOTINITIALISED): { + sif::info << "TmTcWinUdpBridge::handleBindError: WSANOTINITIALISED: " + << "WSAStartup(...) call " << "necessary" << std::endl; + break; + } + default: { + sif::info << "TmTcWinUdpBridge::handleBindError: Error code: " + << errCode << std::endl; + break; + } + } +} + +void TmTcWinUdpBridge::handleSendError() { + int errCode = WSAGetLastError(); + switch(errCode) { + case(WSANOTINITIALISED): { + sif::info << "TmTcWinUdpBridge::handleSendError: WSANOTINITIALISED: " + << "WSAStartup(...) call " << "necessary" << std::endl; + break; + } + default: { + sif::info << "TmTcWinUdpBridge::handleSendError: Error code: " + << errCode << std::endl; + break; + } + } +} + +#endif diff --git a/osal/host/TmTcWinUdpBridge.h b/osal/windows/TmTcWinUdpBridge.h similarity index 88% rename from osal/host/TmTcWinUdpBridge.h rename to osal/windows/TmTcWinUdpBridge.h index 8e6bb0fd..8188039c 100644 --- a/osal/host/TmTcWinUdpBridge.h +++ b/osal/windows/TmTcWinUdpBridge.h @@ -1,14 +1,15 @@ -#ifndef FSFW_OSAL_HOST_TMTCWINUDPBRIDGE_H_ -#define FSFW_OSAL_HOST_TMTCWINUDPBRIDGE_H_ +#ifndef FSFW_OSAL_WINDOWS_TMTCWINUDPBRIDGE_H_ +#define FSFW_OSAL_WINDOWS_TMTCWINUDPBRIDGE_H_ #include "../../tmtcservices/TmTcBridge.h" -#include + +#include +#include class TmTcWinUdpBridge: public TmTcBridge { friend class TcWinUdpPollingTask; public: // The ports chosen here should not be used by any other process. - // List of used ports on Linux: /etc/services static constexpr uint16_t DEFAULT_UDP_SERVER_PORT = 7301; static constexpr uint16_t DEFAULT_UDP_CLIENT_PORT = 7302; @@ -45,3 +46,4 @@ private: #endif /* FSFW_OSAL_HOST_TMTCWINUDPBRIDGE_H_ */ + From 3e0819f954d3eb6b6fb090f7b0d157d867f4ed6c Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sun, 6 Sep 2020 11:48:32 +0200 Subject: [PATCH 030/192] some bugfixes --- fsfw.mk | 4 + osal/host/PeriodicTask.cpp | 4 + osal/host/QueueMapManager.cpp | 14 ++- osal/windows/TcWinUdpPollingTask.cpp | 147 +++++++++++++++++++++++++++ osal/windows/TcWinUdpPollingTask.h | 67 ++++++++++++ osal/windows/TmTcWinUdpBridge.cpp | 4 +- 6 files changed, 234 insertions(+), 6 deletions(-) create mode 100644 osal/windows/TcWinUdpPollingTask.cpp create mode 100644 osal/windows/TcWinUdpPollingTask.h diff --git a/fsfw.mk b/fsfw.mk index a548b6a8..b8e9ff98 100644 --- a/fsfw.mk +++ b/fsfw.mk @@ -37,6 +37,10 @@ else ifeq ($(OS_FSFW),freeRTOS) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/osal/FreeRTOS/*.cpp) else ifeq ($(OS_FSFW),host) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/osal/host/*.cpp) +ifeq ($(OS),Windows_NT) +CXXSRC += $(wildcard $(FRAMEWORK_PATH)/osal/windows/*.cpp) +endif + else $(error invalid OS_FSFW specified, valid OS_FSFW are rtems, linux, freeRTOS, host) endif diff --git a/osal/host/PeriodicTask.cpp b/osal/host/PeriodicTask.cpp index 3157ffb7..f7807a17 100644 --- a/osal/host/PeriodicTask.cpp +++ b/osal/host/PeriodicTask.cpp @@ -96,6 +96,10 @@ void PeriodicTask::taskFunctionality() { }; auto nextStartTime{ currentStartTime }; + for (const auto& object: objectList) { + object->initializeAfterTaskCreation(); + } + /* Enter the loop that defines the task behavior. */ for (;;) { if(terminateThread.load()) { diff --git a/osal/host/QueueMapManager.cpp b/osal/host/QueueMapManager.cpp index 1b2094e9..c3d94584 100644 --- a/osal/host/QueueMapManager.cpp +++ b/osal/host/QueueMapManager.cpp @@ -44,9 +44,17 @@ MessageQueueIF* QueueMapManager::getMessageQueue( return queueIter->second; } else { - sif::warning << "QueueMapManager::getQueueHandle: The ID" << - messageQueueId << " does not exists in the map" << std::endl; - return nullptr; + if(messageQueueId == MessageQueueIF::NO_QUEUE) { + sif::error << "QueueMapManager::getQueueHandle: Configuration" + << " error, NO_QUEUE was passed to this function!" + << std::endl; + } + else { + sif::warning << "QueueMapManager::getQueueHandle: The ID " + << messageQueueId << " does not exists in the map." + << std::endl; + } + return nullptr; } } diff --git a/osal/windows/TcWinUdpPollingTask.cpp b/osal/windows/TcWinUdpPollingTask.cpp new file mode 100644 index 00000000..661d596a --- /dev/null +++ b/osal/windows/TcWinUdpPollingTask.cpp @@ -0,0 +1,147 @@ +#include "TcWinUdpPollingTask.h" +#include "../../globalfunctions/arrayprinter.h" +#include "../../serviceinterface/ServiceInterfaceStream.h" + +#include +#include + +TcWinUdpPollingTask::TcWinUdpPollingTask(object_id_t objectId, + object_id_t tmtcUnixUdpBridge, size_t frameSize, + double timeoutSeconds): SystemObject(objectId), + tmtcBridgeId(tmtcUnixUdpBridge) { + if(frameSize > 0) { + this->frameSize = frameSize; + } + else { + this->frameSize = DEFAULT_MAX_FRAME_SIZE; + } + + // Set up reception buffer with specified frame size. + // For now, it is assumed that only one frame is held in the buffer! + receptionBuffer.reserve(this->frameSize); + receptionBuffer.resize(this->frameSize); + + if(timeoutSeconds == -1) { + receptionTimeout = DEFAULT_TIMEOUT; + } + else { + receptionTimeout = timevalOperations::toTimeval(timeoutSeconds); + } +} + +TcWinUdpPollingTask::~TcWinUdpPollingTask() {} + +ReturnValue_t TcWinUdpPollingTask::performOperation(uint8_t opCode) { + // Poll for new UDP datagrams in permanent loop. + while(1) { + //! Sender Address is cached here. + struct sockaddr_in senderAddress; + int senderAddressSize = sizeof(senderAddress); + ssize_t bytesReceived = recvfrom(serverUdpSocket, + reinterpret_cast(receptionBuffer.data()), frameSize, + receptionFlags, reinterpret_cast(&senderAddress), + &senderAddressSize); + if(bytesReceived == SOCKET_ERROR) { + // handle error + sif::error << "TcWinUdpPollingTask::performOperation: Reception" + " error." << std::endl; + handleReadError(); + continue; + } + sif::debug << "TcSocketPollingTask::performOperation: " << bytesReceived + << " bytes received" << std::endl; + + ReturnValue_t result = handleSuccessfullTcRead(bytesReceived); + if(result != HasReturnvaluesIF::RETURN_FAILED) { + + } + tmtcBridge->registerCommConnect(); + tmtcBridge->checkAndSetClientAddress(senderAddress); + } + return HasReturnvaluesIF::RETURN_OK; +} + + +ReturnValue_t TcWinUdpPollingTask::handleSuccessfullTcRead(size_t bytesRead) { + store_address_t storeId; + ReturnValue_t result = tcStore->addData(&storeId, + receptionBuffer.data(), bytesRead); + // arrayprinter::print(receptionBuffer.data(), bytesRead); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "TcSerialPollingTask::transferPusToSoftwareBus: Data " + "storage failed" << std::endl; + sif::error << "Packet size: " << bytesRead << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + + TmTcMessage message(storeId); + + result = MessageQueueSenderIF::sendMessage(targetTcDestination, &message); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Serial Polling: Sending message to queue failed" + << std::endl; + tcStore->deleteData(storeId); + } + return result; +} + +ReturnValue_t TcWinUdpPollingTask::initialize() { + tcStore = objectManager->get(objects::TC_STORE); + if (tcStore == nullptr) { + sif::error << "TcSerialPollingTask::initialize: TC Store uninitialized!" + << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } + + tmtcBridge = objectManager->get(tmtcBridgeId); + if(tmtcBridge == nullptr) { + sif::error << "TcSocketPollingTask::TcSocketPollingTask: Invalid" + " TMTC bridge object!" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } + + serverUdpSocket = tmtcBridge->serverSocket; + //sif::info << "TcWinUdpPollingTask::initialize: Server UDP socket " + // << serverUdpSocket << std::endl; + + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t TcWinUdpPollingTask::initializeAfterTaskCreation() { + // Initialize the destination after task creation. This ensures + // that the destination has already been set in the TMTC bridge. + targetTcDestination = tmtcBridge->getRequestQueue(); + return HasReturnvaluesIF::RETURN_OK; +} + +void TcWinUdpPollingTask::setTimeout(double timeoutSeconds) { + DWORD timeoutMs = timeoutSeconds * 1000.0; + int result = setsockopt(serverUdpSocket, SOL_SOCKET, SO_RCVTIMEO, + reinterpret_cast(&timeoutMs), sizeof(DWORD)); + if(result == -1) { + sif::error << "TcSocketPollingTask::TcSocketPollingTask: Setting " + "receive timeout failed with " << strerror(errno) << std::endl; + } +} + +void TcWinUdpPollingTask::handleReadError() { + int error = WSAGetLastError(); + switch(error) { + case(WSANOTINITIALISED): { + sif::info << "TmTcWinUdpBridge::handleReadError: WSANOTINITIALISED: " + << "WSAStartup(...) call " << "necessary" << std::endl; + break; + } + case(WSAEFAULT): { + sif::info << "TmTcWinUdpBridge::handleReadError: WSADEFAULT: " + << "Bad address " << std::endl; + Sleep(2000); + break; + } + default: { + sif::info << "TmTcWinUdpBridge::handleReadError: Error code: " + << error << std::endl; + break; + } + } +} diff --git a/osal/windows/TcWinUdpPollingTask.h b/osal/windows/TcWinUdpPollingTask.h new file mode 100644 index 00000000..50d39d25 --- /dev/null +++ b/osal/windows/TcWinUdpPollingTask.h @@ -0,0 +1,67 @@ +#ifndef FSFW_OSAL_WINDOWS_TCSOCKETPOLLINGTASK_H_ +#define FSFW_OSAL_WINDOWS_TCSOCKETPOLLINGTASK_H_ + +#include "TmTcWinUdpBridge.h" +#include "../../objectmanager/SystemObject.h" +#include "../../tasks/ExecutableObjectIF.h" +#include "../../storagemanager/StorageManagerIF.h" + +#include + +/** + * @brief This class can be used to implement the polling of a Unix socket, + * using UDP for now. + * @details + * The task will be blocked while the specified number of bytes has not been + * received, so TC reception is handled inside a separate task. + * This class caches the IP address of the sender. It is assumed there + * is only one sender for now. + */ +class TcWinUdpPollingTask: public SystemObject, + public ExecutableObjectIF { + friend class TmTcWinUdpBridge; +public: + static constexpr size_t DEFAULT_MAX_FRAME_SIZE = 2048; + //! 0.5 default milliseconds timeout for now. + static constexpr timeval DEFAULT_TIMEOUT = {.tv_sec = 0, .tv_usec = 500}; + + TcWinUdpPollingTask(object_id_t objectId, object_id_t tmtcUnixUdpBridge, + size_t frameSize = 0, double timeoutSeconds = -1); + virtual~ TcWinUdpPollingTask(); + + /** + * Turn on optional timeout for UDP polling. In the default mode, + * the receive function will block until a packet is received. + * @param timeoutSeconds + */ + void setTimeout(double timeoutSeconds); + + virtual ReturnValue_t performOperation(uint8_t opCode) override; + virtual ReturnValue_t initialize() override; + virtual ReturnValue_t initializeAfterTaskCreation() override; + +protected: + StorageManagerIF* tcStore = nullptr; + +private: + //! TMTC bridge is cached. + object_id_t tmtcBridgeId = objects::NO_OBJECT; + TmTcWinUdpBridge* tmtcBridge = nullptr; + MessageQueueId_t targetTcDestination = MessageQueueIF::NO_QUEUE; + //! Reception flags: https://linux.die.net/man/2/recvfrom. + int receptionFlags = 0; + + //! Server socket, which is member of TMTC bridge and is assigned in + //! constructor + SOCKET serverUdpSocket = 0; + + std::vector receptionBuffer; + + size_t frameSize = 0; + timeval receptionTimeout; + + ReturnValue_t handleSuccessfullTcRead(size_t bytesRead); + void handleReadError(); +}; + +#endif /* FRAMEWORK_OSAL_LINUX_TCSOCKETPOLLINGTASK_H_ */ diff --git a/osal/windows/TmTcWinUdpBridge.cpp b/osal/windows/TmTcWinUdpBridge.cpp index c5902e88..2ea6ae97 100644 --- a/osal/windows/TmTcWinUdpBridge.cpp +++ b/osal/windows/TmTcWinUdpBridge.cpp @@ -31,7 +31,7 @@ TmTcWinUdpBridge::TmTcWinUdpBridge(object_id_t objectId, // Set up UDP socket: https://man7.org/linux/man-pages/man7/ip.7.html //clientSocket = socket(AF_INET, SOCK_DGRAM, 0); serverSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - if(serverSocket != 0) { + if(serverSocket == INVALID_SOCKET) { sif::error << "TmTcWinUdpBridge::TmTcWinUdpBridge: Could not open" " UDP socket!" << std::endl; handleSocketError(); @@ -62,7 +62,6 @@ TmTcWinUdpBridge::TmTcWinUdpBridge(object_id_t objectId, "local port " << setServerPort << " to server socket!" << std::endl; handleBindError(); - return; } } @@ -125,4 +124,3 @@ void TmTcWinUdpBridge::handleSendError() { } } -#endif From 7774434d7a211f212ec376bb8296d6aa9f63aab7 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sun, 6 Sep 2020 11:58:12 +0200 Subject: [PATCH 031/192] windows sockets working --- osal/windows/TmTcWinUdpBridge.cpp | 53 ++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/osal/windows/TmTcWinUdpBridge.cpp b/osal/windows/TmTcWinUdpBridge.cpp index 2ea6ae97..3e273507 100644 --- a/osal/windows/TmTcWinUdpBridge.cpp +++ b/osal/windows/TmTcWinUdpBridge.cpp @@ -1,3 +1,4 @@ +#include #include "TmTcWinUdpBridge.h" TmTcWinUdpBridge::TmTcWinUdpBridge(object_id_t objectId, @@ -70,10 +71,43 @@ TmTcWinUdpBridge::~TmTcWinUdpBridge() { } ReturnValue_t TmTcWinUdpBridge::sendTm(const uint8_t *data, size_t dataLen) { + int flags = 0; + + //clientAddress.sin_addr.s_addr = htons(INADDR_ANY); + //clientAddressLen = sizeof(serverAddress); + +// char ipAddress [15]; +// sif::debug << "IP Address Sender: "<< inet_ntop(AF_INET, +// &clientAddress.sin_addr.s_addr, ipAddress, 15) << std::endl; + + ssize_t bytesSent = sendto(serverSocket, + reinterpret_cast(data), dataLen, flags, + reinterpret_cast(&clientAddress), clientAddressLen); + if(bytesSent == SOCKET_ERROR) { + sif::error << "TmTcWinUdpBridge::sendTm: Send operation failed." + << std::endl; + handleSendError(); + } +// sif::debug << "TmTcUnixUdpBridge::sendTm: " << bytesSent << " bytes were" +// " sent." << std::endl; + return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK; } -void TmTcWinUdpBridge::checkAndSetClientAddress(sockaddr_in clientAddress) { +void TmTcWinUdpBridge::checkAndSetClientAddress(sockaddr_in newAddress) { + MutexHelper lock(mutex, MutexIF::TimeoutType::WAITING, 10); + +// char ipAddress [15]; +// 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; + + // Set new IP address if it has changed. + if(clientAddress.sin_addr.s_addr != newAddress.sin_addr.s_addr) { + clientAddress.sin_addr.s_addr = newAddress.sin_addr.s_addr; + clientAddressLen = sizeof(clientAddress); + } } void TmTcWinUdpBridge::handleSocketError() { @@ -85,6 +119,10 @@ void TmTcWinUdpBridge::handleSocketError() { break; } default: { + /* + https://docs.microsoft.com/en-us/windows/win32/winsock/ + windows-sockets-error-codes-2 + */ sif::info << "TmTcWinUdpBridge::handleSocketError: Error code: " << errCode << std::endl; break; @@ -101,6 +139,10 @@ void TmTcWinUdpBridge::handleBindError() { break; } default: { + /* + https://docs.microsoft.com/en-us/windows/win32/winsock/ + windows-sockets-error-codes-2 + */ sif::info << "TmTcWinUdpBridge::handleBindError: Error code: " << errCode << std::endl; break; @@ -116,7 +158,16 @@ void TmTcWinUdpBridge::handleSendError() { << "WSAStartup(...) call " << "necessary" << std::endl; break; } + case(WSAEADDRNOTAVAIL): { + sif::info << "TmTcWinUdpBridge::handleReadError: WSAEADDRNOTAVAIL: " + << "Check target address. " << std::endl; + break; + } default: { + /* + https://docs.microsoft.com/en-us/windows/win32/winsock/ + windows-sockets-error-codes-2 + */ sif::info << "TmTcWinUdpBridge::handleSendError: Error code: " << errCode << std::endl; break; From 8db9a4a1911862a359d6c9a27569fb4e640670a8 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sun, 6 Sep 2020 12:00:57 +0200 Subject: [PATCH 032/192] some minor tweaks --- osal/windows/TcWinUdpPollingTask.cpp | 9 +++++---- osal/windows/TmTcWinUdpBridge.cpp | 3 +-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/osal/windows/TcWinUdpPollingTask.cpp b/osal/windows/TcWinUdpPollingTask.cpp index 661d596a..7b54bb2c 100644 --- a/osal/windows/TcWinUdpPollingTask.cpp +++ b/osal/windows/TcWinUdpPollingTask.cpp @@ -33,7 +33,7 @@ TcWinUdpPollingTask::~TcWinUdpPollingTask() {} ReturnValue_t TcWinUdpPollingTask::performOperation(uint8_t opCode) { // Poll for new UDP datagrams in permanent loop. - while(1) { + while(true) { //! Sender Address is cached here. struct sockaddr_in senderAddress; int senderAddressSize = sizeof(senderAddress); @@ -48,8 +48,8 @@ ReturnValue_t TcWinUdpPollingTask::performOperation(uint8_t opCode) { handleReadError(); continue; } - sif::debug << "TcSocketPollingTask::performOperation: " << bytesReceived - << " bytes received" << std::endl; + //sif::debug << "TcWinUdpPollingTask::performOperation: " << bytesReceived + // << " bytes received" << std::endl; ReturnValue_t result = handleSuccessfullTcRead(bytesReceived); if(result != HasReturnvaluesIF::RETURN_FAILED) { @@ -135,7 +135,6 @@ void TcWinUdpPollingTask::handleReadError() { case(WSAEFAULT): { sif::info << "TmTcWinUdpBridge::handleReadError: WSADEFAULT: " << "Bad address " << std::endl; - Sleep(2000); break; } default: { @@ -144,4 +143,6 @@ void TcWinUdpPollingTask::handleReadError() { break; } } + // to prevent spam. + Sleep(1000); } diff --git a/osal/windows/TmTcWinUdpBridge.cpp b/osal/windows/TmTcWinUdpBridge.cpp index 3e273507..7e283c2a 100644 --- a/osal/windows/TmTcWinUdpBridge.cpp +++ b/osal/windows/TmTcWinUdpBridge.cpp @@ -41,8 +41,7 @@ TmTcWinUdpBridge::TmTcWinUdpBridge(object_id_t objectId, serverAddress.sin_family = AF_INET; - // Accept packets from any interface. - //serverAddress.sin_addr.s_addr = inet_addr("127.73.73.0"); + // Accept packets from any interface. (potentially insecure). serverAddress.sin_addr.s_addr = htonl(INADDR_ANY); serverAddress.sin_port = htons(setServerPort); serverAddressLen = sizeof(serverAddress); From efa41b29aa2fb45180d7bd6c2805a8ced32378fd Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sun, 6 Sep 2020 12:16:43 +0200 Subject: [PATCH 033/192] added informative comment --- fsfw.mk | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fsfw.mk b/fsfw.mk index b8e9ff98..c5847554 100644 --- a/fsfw.mk +++ b/fsfw.mk @@ -31,14 +31,23 @@ CXXSRC += $(wildcard $(FRAMEWORK_PATH)/osal/*.cpp) # select the OS ifeq ($(OS_FSFW),rtems) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/osal/rtems/*.cpp) + else ifeq ($(OS_FSFW),linux) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/osal/linux/*.cpp) + else ifeq ($(OS_FSFW),freeRTOS) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/osal/FreeRTOS/*.cpp) + else ifeq ($(OS_FSFW),host) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/osal/host/*.cpp) ifeq ($(OS),Windows_NT) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/osal/windows/*.cpp) +else +# For now, the linux UDP bridge sources needs to be included manually by upper makefile +# for host OS because we can't be sure the OS is linux. +# Following lines can be used to do this: +# CXXSRC += $(FRAMEWORK_PATH)/osal/linux/TcUnixUdpPollingTask.cpp +# CXXSRC += $(FRAMEWORK_PATH)/osal/linux/TmTcUnixUdpBridge.cpp endif else From ac2f6c5ed4dff00bf3ce3228896e393813998bf7 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sun, 6 Sep 2020 12:59:59 +0200 Subject: [PATCH 034/192] minor improvements --- osal/linux/TcUnixUdpPollingTask.cpp | 1 + osal/linux/TmTcUnixUdpBridge.cpp | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/osal/linux/TcUnixUdpPollingTask.cpp b/osal/linux/TcUnixUdpPollingTask.cpp index 95910b02..670ba804 100644 --- a/osal/linux/TcUnixUdpPollingTask.cpp +++ b/osal/linux/TcUnixUdpPollingTask.cpp @@ -120,6 +120,7 @@ void TcUnixUdpPollingTask::setTimeout(double timeoutSeconds) { } } +// TODO: sleep after error detection to prevent spam void TcUnixUdpPollingTask::handleReadError() { switch(errno) { case(EAGAIN): { diff --git a/osal/linux/TmTcUnixUdpBridge.cpp b/osal/linux/TmTcUnixUdpBridge.cpp index 2549a4b7..b55291b3 100644 --- a/osal/linux/TmTcUnixUdpBridge.cpp +++ b/osal/linux/TmTcUnixUdpBridge.cpp @@ -101,8 +101,8 @@ void TmTcUnixUdpBridge::checkAndSetClientAddress(sockaddr_in newAddress) { } } -void TmTcUnixUdpBridge::handleSocketError() { +void TmTcUnixUdpBridge::handleSocketError() { // See: https://man7.org/linux/man-pages/man2/socket.2.html switch(errno) { case(EACCES): @@ -163,7 +163,8 @@ void TmTcUnixUdpBridge::handleBindError() { void TmTcUnixUdpBridge::handleSendError() { switch(errno) { default: - sif::error << "Error: " << strerror(errno) << std::endl; + sif::error << "TmTcUnixBridge::handleSendError: " + << strerror(errno) << std::endl; } } From 50ae50d28679e620d0a60392f5b557ae4875995d Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sun, 6 Sep 2020 14:01:41 +0200 Subject: [PATCH 035/192] removed pool raw access helper --- datapool/PoolRawAccessHelper.cpp | 181 ------------------------------- datapool/PoolRawAccessHelper.h | 105 ------------------ 2 files changed, 286 deletions(-) delete mode 100644 datapool/PoolRawAccessHelper.cpp delete mode 100644 datapool/PoolRawAccessHelper.h diff --git a/datapool/PoolRawAccessHelper.cpp b/datapool/PoolRawAccessHelper.cpp deleted file mode 100644 index 5a6827b6..00000000 --- a/datapool/PoolRawAccessHelper.cpp +++ /dev/null @@ -1,181 +0,0 @@ -#include "PoolRawAccessHelper.h" -#include "../datapoolglob/GlobalDataSet.h" -#include "../serialize/SerializeAdapter.h" -#include "../serviceinterface/ServiceInterfaceStream.h" - -#include -#include - -PoolRawAccessHelper::PoolRawAccessHelper(uint32_t * poolIdBuffer_, - uint8_t numberOfParameters_): - poolIdBuffer(reinterpret_cast(poolIdBuffer_)), - numberOfParameters(numberOfParameters_), validBufferIndex(0), - validBufferIndexBit(1) { -} - -PoolRawAccessHelper::~PoolRawAccessHelper() { -} - -ReturnValue_t PoolRawAccessHelper::serialize(uint8_t **buffer, size_t *size, - const size_t max_size, SerializeIF::Endianness streamEndianness) { - SerializationArgs serializationArgs = {buffer, size, max_size, - streamEndianness}; - ReturnValue_t result = RETURN_OK; - size_t remainingParametersSize = numberOfParameters * 4; - for(uint8_t count=0; count < numberOfParameters; count++) { - result = serializeCurrentPoolEntryIntoBuffer(serializationArgs, - &remainingParametersSize, false); - if(result != RETURN_OK) { - return result; - } - } - if(remainingParametersSize != 0) { - sif::debug << "PoolRawAccessHelper: " - "Remaining parameters size not 0 !" << std::endl; - result = RETURN_FAILED; - } - return result; -} - -ReturnValue_t PoolRawAccessHelper::serializeWithValidityMask(uint8_t ** buffer, - size_t * size, const size_t max_size, - SerializeIF::Endianness streamEndianness) { - ReturnValue_t result = RETURN_OK; - SerializationArgs argStruct = {buffer, size, max_size, streamEndianness}; - size_t remainingParametersSize = numberOfParameters * 4; - uint8_t validityMaskSize = ceil((float)numberOfParameters/8.0); - uint8_t validityMask[validityMaskSize]; - memset(validityMask,0, validityMaskSize); - for(uint8_t count = 0; count < numberOfParameters; count++) { - result = serializeCurrentPoolEntryIntoBuffer(argStruct, - &remainingParametersSize,true,validityMask); - if (result != RETURN_OK) { - return result; - } - } - if(remainingParametersSize != 0) { - sif::debug << "PoolRawAccessHelper: Remaining " - "parameters size not 0 !" << std::endl; - result = RETURN_FAILED; - } - - memcpy(*argStruct.buffer, validityMask, validityMaskSize); - *size += validityMaskSize; - validBufferIndex = 1; - validBufferIndexBit = 0; - return result; -} - -ReturnValue_t PoolRawAccessHelper::serializeCurrentPoolEntryIntoBuffer( - SerializationArgs argStruct, size_t * remainingParameters, - bool withValidMask, uint8_t * validityMask) { - uint32_t currentPoolId; - // Deserialize current pool ID from pool ID buffer - ReturnValue_t result = SerializeAdapter::deSerialize(¤tPoolId, - &poolIdBuffer,remainingParameters, SerializeIF::Endianness::MACHINE); - if(result != RETURN_OK) { - sif::debug << std::hex << "PoolRawAccessHelper: Error deSeralizing " - "pool IDs" << std::dec << std::endl; - return result; - } - result = handlePoolEntrySerialization(currentPoolId, argStruct, - withValidMask, validityMask); - return result; -} - -ReturnValue_t PoolRawAccessHelper::handlePoolEntrySerialization( - uint32_t currentPoolId,SerializationArgs argStruct, bool withValidMask, - uint8_t * validityMask) { - ReturnValue_t result = RETURN_FAILED; - uint8_t arrayPosition = 0; - uint8_t counter = 0; - bool poolEntrySerialized = false; - //debug << "Pool Raw Access Helper: Handling Pool ID: " - // << std::hex << currentPoolId << std::endl; - while(not poolEntrySerialized) { - - if(counter > GlobDataSet::DATA_SET_MAX_SIZE) { - sif::error << "PoolRawAccessHelper: Config error, " - "max. number of possible data set variables exceeded" - << std::endl; - return result; - } - counter ++; - - GlobDataSet currentDataSet; - //debug << "Current array position: " << (int)arrayPosition << std::endl; - PoolRawAccess currentPoolRawAccess(currentPoolId, arrayPosition, - ¤tDataSet, PoolVariableIF::VAR_READ); - - result = currentDataSet.read(); - if (result != RETURN_OK) { - sif::debug << std::hex << "PoolRawAccessHelper: Error reading raw " - "dataset with returncode 0x" << result << std::dec << std::endl; - return result; - } - - result = checkRemainingSize(¤tPoolRawAccess, &poolEntrySerialized, - &arrayPosition); - if(result != RETURN_OK) { - sif::error << "Pool Raw Access Helper: Configuration Error at pool ID " - << std::hex << currentPoolId - << ". Size till end smaller than 0" << std::dec << std::endl; - return result; - } - - // set valid mask bit if necessary - if(withValidMask) { - if(currentPoolRawAccess.isValid()) { - handleMaskModification(validityMask); - } - validBufferIndexBit ++; - } - - result = currentDataSet.serialize(argStruct.buffer, argStruct.size, - argStruct.max_size, argStruct.streamEndianness); - if (result != RETURN_OK) { - sif::debug << "Pool Raw Access Helper: Error serializing pool data with " - "ID 0x" << std::hex << currentPoolId << " into send buffer " - "with return code " << result << std::dec << std::endl; - return result; - } - - } - return result; -} - -ReturnValue_t PoolRawAccessHelper::checkRemainingSize(PoolRawAccess* - currentPoolRawAccess, bool * isSerialized, uint8_t * arrayPosition) { - int8_t remainingSize = currentPoolRawAccess->getSizeTillEnd() - - currentPoolRawAccess->getSizeOfType(); - if(remainingSize == 0) { - *isSerialized = true; - } - else if(remainingSize > 0) { - *arrayPosition += 1; - } - else { - return RETURN_FAILED; - } - return RETURN_OK; -} - -void PoolRawAccessHelper::handleMaskModification(uint8_t * validityMask) { - validityMask[validBufferIndex] = - bitSetter(validityMask[validBufferIndex], validBufferIndexBit, true); - if(validBufferIndexBit == 8) { - validBufferIndex ++; - validBufferIndexBit = 1; - } -} - -uint8_t PoolRawAccessHelper::bitSetter(uint8_t byte, uint8_t position, - bool value) { - if(position < 1 or position > 8) { - sif::debug << "Pool Raw Access: Bit setting invalid position" << std::endl; - return byte; - } - uint8_t shiftNumber = position + (6 - 2 * (position - 1)); - byte |= 1UL << shiftNumber; - return byte; -} diff --git a/datapool/PoolRawAccessHelper.h b/datapool/PoolRawAccessHelper.h deleted file mode 100644 index 6ff3e955..00000000 --- a/datapool/PoolRawAccessHelper.h +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef FSFW_DATAPOOL_POOLRAWACCESSHELPER_H_ -#define FSFW_DATAPOOL_POOLRAWACCESSHELPER_H_ - -#include "../returnvalues/HasReturnvaluesIF.h" -#include "../datapoolglob/GlobalDataSet.h" -#include "../datapoolglob/PoolRawAccess.h" - -/** - * @brief This helper function simplifies accessing data pool entries - * via PoolRawAccess - * @details Can be used for a Housekeeping Service - * like ECSS PUS Service 3 if the type of the datapool entries is unknown. - * The provided dataset can be serialized into a provided buffer automatically by - * providing a buffer of pool IDs - * @ingroup data_pool - */ -class PoolRawAccessHelper: public HasReturnvaluesIF { -public: - /** - * Call this constructor if a dataset needs to be serialized via - * Pool Raw Access - * @param dataSet_ This dataset will be used to perform thread-safe reading - * @param poolIdBuffer_ A buffer of uint32_t pool IDs - * @param numberOfParameters_ The number of parameters / pool IDs - */ - PoolRawAccessHelper(uint32_t * poolIdBuffer_, uint8_t numberOfParameters_); - virtual ~PoolRawAccessHelper(); - - /** - * Serialize the datapool entries derived from the pool ID buffer - * directly into a provided buffer - * @param [out] buffer - * @param [out] size Size of the serialized buffer - * @param max_size - * @param bigEndian - * @return @c RETURN_OK On success - * @c RETURN_FAILED on failure - */ - ReturnValue_t serialize(uint8_t ** buffer, size_t * size, - const size_t max_size, SerializeIF::Endianness streamEndianness); - - /** - * Serializes data pool entries into provided buffer with the validity mask buffer - * at the end of the buffer. Every bit of the validity mask denotes - * the validity of a corresponding data pool entry from left to right. - * @param [out] buffer - * @param [out] size Size of the serialized buffer plus size - * of the validity mask - * @return @c RETURN_OK On success - * @c RETURN_FAILED on failure - */ - ReturnValue_t serializeWithValidityMask(uint8_t ** buffer, size_t * size, - const size_t max_size, SerializeIF::Endianness streamEndianness); - - -private: - // DataSet * dataSet; - const uint8_t * poolIdBuffer; - uint8_t numberOfParameters; - - uint8_t validBufferIndex; - uint8_t validBufferIndexBit; - - struct SerializationArgs { - uint8_t ** buffer; - size_t * size; - const size_t max_size; - SerializeIF::Endianness streamEndianness; - }; - /** - * Helper function to serialize single pool entries - * @param pPoolIdBuffer - * @param buffer - * @param remainingParameters - * @param hkDataSize - * @param max_size - * @param bigEndian - * @param withValidMask Can be set optionally to set a - * provided validity mask - * @param validityMask Can be supplied and will be set if - * @c withValidMask is set to true - * @return - */ - ReturnValue_t serializeCurrentPoolEntryIntoBuffer( - SerializationArgs argStruct, size_t * remainingParameters, - bool withValidMask = false, uint8_t * validityMask = nullptr); - - ReturnValue_t handlePoolEntrySerialization(uint32_t currentPoolId, - SerializationArgs argStruct, bool withValidMask = false, - uint8_t * validityMask = nullptr); - - ReturnValue_t checkRemainingSize(PoolRawAccess * currentPoolRawAccess, - bool * isSerialized, uint8_t * arrayPosition); - void handleMaskModification(uint8_t * validityMask); - /** - * Sets specific bit of a byte - * @param byte - * @param position Position of byte to set from 1 to 8 - * @param value Binary value to set - * @return - */ - uint8_t bitSetter(uint8_t byte, uint8_t position, bool value); -}; - -#endif /* FRAMEWORK_DATAPOOL_POOLRAWACCESSHELPER_H_ */ From 673af264724261873f78079e72e5fc109fbf2f63 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sun, 6 Sep 2020 14:57:05 +0200 Subject: [PATCH 036/192] rework/restructuring --- datapool/DataSetIF.h | 7 +++---- datapool/PoolDataSetIF.h | 4 ++++ datapool/PoolVarList.h | 9 +++++---- datapool/PoolVariableIF.h | 6 +++--- {datapool => datapoolglob}/ControllerSet.cpp | 2 +- {datapool => datapoolglob}/ControllerSet.h | 6 +++--- datapoollocal/LocalDataPoolManager.cpp | 6 +++--- datapoollocal/LocalDataPoolManager.h | 8 ++++---- housekeeping/HousekeepingPacketDownlink.h | 5 +++-- 9 files changed, 29 insertions(+), 24 deletions(-) rename {datapool => datapoolglob}/ControllerSet.cpp (79%) rename {datapool => datapoolglob}/ControllerSet.h (59%) diff --git a/datapool/DataSetIF.h b/datapool/DataSetIF.h index b51da3a4..a6634a5c 100644 --- a/datapool/DataSetIF.h +++ b/datapool/DataSetIF.h @@ -1,5 +1,5 @@ -#ifndef DATASETIF_H_ -#define DATASETIF_H_ +#ifndef FSFW_DATAPOOL_DATASETIF_H_ +#define FSFW_DATAPOOL_DATASETIF_H_ #include "../returnvalues/HasReturnvaluesIF.h" #include "../timemanager/Clock.h" @@ -34,7 +34,6 @@ public: */ virtual ~DataSetIF() {} - /** * @brief This operation provides a method to register local data pool * variables to register in a data set by passing itself @@ -45,4 +44,4 @@ public: virtual uint16_t getFillCount() const = 0; }; -#endif /* FRAMEWORK_DATAPOOL_DATASETIF_H_ */ +#endif /* FSFW_DATAPOOL_DATASETIF_H_ */ diff --git a/datapool/PoolDataSetIF.h b/datapool/PoolDataSetIF.h index 78c05d43..aa45fa54 100644 --- a/datapool/PoolDataSetIF.h +++ b/datapool/PoolDataSetIF.h @@ -3,6 +3,10 @@ #include "DataSetIF.h" +/** + * @brief Extendes the DataSetIF by adding abstract functions to lock + * and unlock a data pool and read/commit semantics. + */ class PoolDataSetIF: public DataSetIF { public: virtual~ PoolDataSetIF() {}; diff --git a/datapool/PoolVarList.h b/datapool/PoolVarList.h index 1c8a7be4..0b2b0f06 100644 --- a/datapool/PoolVarList.h +++ b/datapool/PoolVarList.h @@ -1,5 +1,5 @@ -#ifndef POOLVARLIST_H_ -#define POOLVARLIST_H_ +#ifndef FSFW_DATAPOOL_POOLVARLIST_H_ +#define FSFW_DATAPOOL_POOLVARLIST_H_ #include "../datapool/PoolVariableIF.h" #include "../datapoolglob/GlobalPoolVariable.h" @@ -8,7 +8,8 @@ class PoolVarList { private: GlobPoolVar variables[n_var]; public: - PoolVarList( const uint32_t set_id[n_var], DataSetIF* dataSet, PoolVariableIF::ReadWriteMode_t setReadWriteMode ) { + PoolVarList( const uint32_t set_id[n_var], DataSetIF* dataSet, + PoolVariableIF::ReadWriteMode_t setReadWriteMode ) { //I really should have a look at the new init list c++ syntax. if (dataSet == NULL) { return; @@ -25,4 +26,4 @@ public: -#endif /* POOLVARLIST_H_ */ +#endif /* FSFW_DATAPOOL_POOLVARLIST_H_ */ diff --git a/datapool/PoolVariableIF.h b/datapool/PoolVariableIF.h index 2aa269dd..cd15f744 100644 --- a/datapool/PoolVariableIF.h +++ b/datapool/PoolVariableIF.h @@ -1,5 +1,5 @@ -#ifndef FRAMEWORK_DATAPOOL_POOLVARIABLEIF_H_ -#define FRAMEWORK_DATAPOOL_POOLVARIABLEIF_H_ +#ifndef FSFW_DATAPOOL_POOLVARIABLEIF_H_ +#define FSFW_DATAPOOL_POOLVARIABLEIF_H_ #include "../returnvalues/HasReturnvaluesIF.h" #include "../serialize/SerializeIF.h" @@ -96,4 +96,4 @@ protected: using pool_rwm_t = PoolVariableIF::ReadWriteMode_t; -#endif /* POOLVARIABLEIF_H_ */ +#endif /* FSFW_DATAPOOL_POOLVARIABLEIF_H_ */ diff --git a/datapool/ControllerSet.cpp b/datapoolglob/ControllerSet.cpp similarity index 79% rename from datapool/ControllerSet.cpp rename to datapoolglob/ControllerSet.cpp index 4055158b..54fc6e8c 100644 --- a/datapool/ControllerSet.cpp +++ b/datapoolglob/ControllerSet.cpp @@ -1,4 +1,4 @@ -#include "../datapool/ControllerSet.h" +#include ControllerSet::ControllerSet() { diff --git a/datapool/ControllerSet.h b/datapoolglob/ControllerSet.h similarity index 59% rename from datapool/ControllerSet.h rename to datapoolglob/ControllerSet.h index 43e1cbf2..5da11397 100644 --- a/datapool/ControllerSet.h +++ b/datapoolglob/ControllerSet.h @@ -1,5 +1,5 @@ -#ifndef CONTROLLERSET_H_ -#define CONTROLLERSET_H_ +#ifndef FSFW_DATAPOOLGLOB_CONTROLLERSET_H_ +#define FSFW_DATAPOOLGLOB_CONTROLLERSET_H_ #include "../datapoolglob/GlobalDataSet.h" @@ -12,4 +12,4 @@ public: void setInvalid(); }; -#endif /* CONTROLLERSET_H_ */ +#endif /* FSFW_DATAPOOLGLOB_CONTROLLERSET_H_ */ diff --git a/datapoollocal/LocalDataPoolManager.cpp b/datapoollocal/LocalDataPoolManager.cpp index 87a0a3cb..c84b2c69 100644 --- a/datapoollocal/LocalDataPoolManager.cpp +++ b/datapoollocal/LocalDataPoolManager.cpp @@ -1,5 +1,5 @@ -#include "../datapoollocal/LocalDataPoolManager.h" -#include "../datapoollocal/LocalDataSet.h" +#include "LocalDataPoolManager.h" +#include "LocalPoolDataSetBase.h" #include "../housekeeping/AcceptsHkPacketsIF.h" #include "../ipc/MutexFactory.h" #include "../ipc/MutexHelper.h" @@ -185,7 +185,7 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid, " Set ID not found or dataset not assigned!" << std::endl; return HasReturnvaluesIF::RETURN_FAILED; } - sif::info << "hk gen called" << std::endl; + store_address_t storeId; HousekeepingPacketDownlink hkPacket(sid, collectionInterval, dataSetToSerialize->getFillCount(), dataSetToSerialize); diff --git a/datapoollocal/LocalDataPoolManager.h b/datapoollocal/LocalDataPoolManager.h index c851978c..c6567c80 100644 --- a/datapoollocal/LocalDataPoolManager.h +++ b/datapoollocal/LocalDataPoolManager.h @@ -1,14 +1,14 @@ #ifndef FRAMEWORK_DATAPOOLLOCAL_LOCALDATAPOOLMANAGER_H_ #define FRAMEWORK_DATAPOOLLOCAL_LOCALDATAPOOLMANAGER_H_ +#include "HasLocalDataPoolIF.h" + #include "../housekeeping/HousekeepingPacketDownlink.h" +#include "../housekeeping/HousekeepingMessage.h" #include "../datapool/DataSetIF.h" +#include "../datapool/PoolEntry.h" #include "../objectmanager/SystemObjectIF.h" #include "../ipc/MutexIF.h" - -#include "../housekeeping/HousekeepingMessage.h" -#include "../datapool/PoolEntry.h" -#include "../datapoollocal/HasLocalDataPoolIF.h" #include "../ipc/CommandMessage.h" #include "../ipc/MessageQueueIF.h" #include "../ipc/MutexHelper.h" diff --git a/housekeeping/HousekeepingPacketDownlink.h b/housekeeping/HousekeepingPacketDownlink.h index bee0bac1..ee531bae 100644 --- a/housekeeping/HousekeepingPacketDownlink.h +++ b/housekeeping/HousekeepingPacketDownlink.h @@ -1,7 +1,8 @@ -#ifndef FRAMEWORK_HOUSEKEEPING_HOUSEKEEPINGPACKETDOWNLINK_H_ -#define FRAMEWORK_HOUSEKEEPING_HOUSEKEEPINGPACKETDOWNLINK_H_ +#ifndef FSFW_HOUSEKEEPING_HOUSEKEEPINGPACKETDOWNLINK_H_ +#define FSFW_HOUSEKEEPING_HOUSEKEEPINGPACKETDOWNLINK_H_ #include "../datapoollocal/LocalPoolDataSetBase.h" + #include "../housekeeping/HousekeepingMessage.h" #include "../serialize/SerialLinkedListAdapter.h" #include "../storagemanager/StorageManagerIF.h" From 26cbcdbff058a542a30055ba4104b18cb16353a7 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sun, 6 Sep 2020 15:21:02 +0200 Subject: [PATCH 037/192] removed comment --- datapoollocal/SharedLocalDataSet.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/datapoollocal/SharedLocalDataSet.h b/datapoollocal/SharedLocalDataSet.h index b1f9aa3d..2e5a76fa 100644 --- a/datapoollocal/SharedLocalDataSet.h +++ b/datapoollocal/SharedLocalDataSet.h @@ -6,13 +6,6 @@ #include "../objectmanager/SystemObject.h" #include -/** - * Baseline question: If this dataset is shared, is there once instance - * shared among many objects or multiple instances? Maybe be flexible - * and provide both ways? Sharing one instance requires a mutex lock. - * If there are multiple instances, it is not shared anymore, to be fair.. - * Then a regular local data set is sufficient. - */ class SharedLocalDataSet: public SystemObject, public LocalPoolDataSetBase, public SharedDataSetIF { @@ -28,5 +21,4 @@ private: }; - #endif /* FSFW_DATAPOOLLOCAL_SHAREDLOCALDATASET_H_ */ From d99b100ace281a6a371e42ba15c8d260a27159ff Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sun, 6 Sep 2020 18:46:56 +0200 Subject: [PATCH 038/192] debug output removed --- storagemanager/ConstStorageAccessor.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/storagemanager/ConstStorageAccessor.cpp b/storagemanager/ConstStorageAccessor.cpp index 4ada7f80..6235ac40 100644 --- a/storagemanager/ConstStorageAccessor.cpp +++ b/storagemanager/ConstStorageAccessor.cpp @@ -14,7 +14,6 @@ ConstStorageAccessor::ConstStorageAccessor(store_address_t storeId, ConstStorageAccessor::~ConstStorageAccessor() { if(deleteData and store != nullptr) { - sif::debug << "deleting store data" << std::endl; store->deleteData(storeId); } } From e085deb2355e68e4456143988964a152ff96134b Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 7 Sep 2020 15:23:27 +0200 Subject: [PATCH 039/192] fifo fix --- container/FIFO.h | 1 + 1 file changed, 1 insertion(+) diff --git a/container/FIFO.h b/container/FIFO.h index 19f763fc..5a66a334 100644 --- a/container/FIFO.h +++ b/container/FIFO.h @@ -25,6 +25,7 @@ public: * @param other */ FIFO(const FIFO& other): FIFOBase(other) { + this->fifoArray = other.fifoArray; this->setContainer(fifoArray.data()); } From d43ef479b6191923a60b308fa9a3efa7fd1bd249 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 10 Sep 2020 15:02:58 +0200 Subject: [PATCH 040/192] assignment operator added --- container/DynamicFIFO.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/container/DynamicFIFO.h b/container/DynamicFIFO.h index abb53330..86d43f7d 100644 --- a/container/DynamicFIFO.h +++ b/container/DynamicFIFO.h @@ -27,14 +27,27 @@ public: /** * @brief Custom copy constructor which prevents setting the - * underlying pointer wrong. + * underlying pointer wrong. This function allocates memory! + * @details This is a very heavy operation so try to avoid this! + * */ DynamicFIFO(const DynamicFIFO& other): FIFOBase(other), fifoVector(other.maxCapacity) { + this->fifoVector = other.fifoVector; this->setContainer(fifoVector.data()); } - + /** + * @brief Custom assignment operator + * @details This is a very heavy operation so try to avoid this! + * @param other DyamicFIFO to copy from + */ + DynamicFIFO& operator=(const DynamicFIFO& other){ + FIFOBase::operator=(other); + this->fifoVector = other.fifoVector; + this->setContainer(fifoVector.data()); + return *this; + } private: std::vector fifoVector; }; From cefac2db0b9f2672039e83bce27d38a92cdb7933 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 10 Sep 2020 15:03:28 +0200 Subject: [PATCH 041/192] assignment operator added --- container/FIFO.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/container/FIFO.h b/container/FIFO.h index 5a66a334..70113852 100644 --- a/container/FIFO.h +++ b/container/FIFO.h @@ -29,6 +29,17 @@ public: this->setContainer(fifoArray.data()); } + /** + * @brief Custom assignment operator + * @param other + */ + FIFO& operator=(const FIFO& other){ + FIFOBase::operator=(other); + this->fifoArray = other.fifoArray; + this->setContainer(fifoArray.data()); + return *this; + } + private: std::array fifoArray; }; From 18e6de7d6ba75326262918d4bd0dde93e5c6fa0a Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 10 Sep 2020 15:04:43 +0200 Subject: [PATCH 042/192] added compile time check --- container/FixedMap.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/container/FixedMap.h b/container/FixedMap.h index 3da65784..3b09fa3b 100644 --- a/container/FixedMap.h +++ b/container/FixedMap.h @@ -14,6 +14,10 @@ */ template class FixedMap: public SerializeIF { + static_assert (std::is_trivially_copyable::value or + std::is_base_of::value, + "Types used in FixedMap must either be trivial copy-able or a " + "derived class from SerializeIF to be serialize-able"); public: static const uint8_t INTERFACE_ID = CLASS_ID::FIXED_MAP; static const ReturnValue_t KEY_ALREADY_EXISTS = MAKE_RETURN_CODE(0x01); From db3e32655d70fc4b56c69325faee75449190bf01 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 10 Sep 2020 15:05:26 +0200 Subject: [PATCH 043/192] changes taken over from master --- tmtcservices/CommandingServiceBase.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/tmtcservices/CommandingServiceBase.h b/tmtcservices/CommandingServiceBase.h index 29ab967a..23b08acf 100644 --- a/tmtcservices/CommandingServiceBase.h +++ b/tmtcservices/CommandingServiceBase.h @@ -5,9 +5,9 @@ #include "../storagemanager/StorageManagerIF.h" #include "../tasks/ExecutableObjectIF.h" #include "../ipc/MessageQueueIF.h" -#include "../tmtcservices/AcceptsTelecommandsIF.h" +#include "AcceptsTelecommandsIF.h" -#include "../tmtcservices/VerificationReporter.h" +#include "VerificationReporter.h" #include "../ipc/CommandMessage.h" #include "../container/FixedMap.h" #include "../container/FIFO.h" @@ -211,8 +211,7 @@ protected: virtual void doPeriodicOperation(); - - struct CommandInfo { + struct CommandInfo: public SerializeIF{ struct tcInfo { uint8_t ackFlags; uint16_t tcPacketId; @@ -225,6 +224,20 @@ protected: Command_t command; object_id_t objectId; FIFO fifo; + + virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, + size_t maxSize, Endianness streamEndianness) const override{ + return HasReturnvaluesIF::RETURN_FAILED; + }; + + virtual size_t getSerializedSize() const override { + return 0; + }; + + virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, + Endianness streamEndianness) override{ + return HasReturnvaluesIF::RETURN_FAILED; + }; }; using CommandMapIter = FixedMap Date: Thu, 10 Sep 2020 15:15:13 +0200 Subject: [PATCH 044/192] deleted file not needed anymore --- container/IsDerivedFrom.h | 50 --------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 container/IsDerivedFrom.h diff --git a/container/IsDerivedFrom.h b/container/IsDerivedFrom.h deleted file mode 100644 index 8142a378..00000000 --- a/container/IsDerivedFrom.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef ISDERIVEDFROM_H_ -#define ISDERIVEDFROM_H_ - -/** - * These template type checks are based on SFINAE - * (https://en.cppreference.com/w/cpp/language/sfinae) - * - * @tparam D Derived Type - * @tparam B Base Type - */ -template -class IsDerivedFrom { - class No { - }; - class Yes { - No no[3]; - }; - - // This will be chosen if B is the base type - static Yes Test(B*); // declared, but not defined - // This will be chosen for anything else - static No Test(... ); // declared, but not defined - -public: - enum { - Is = sizeof(Test(static_cast(0))) == sizeof(Yes) - }; -}; - -template -struct is_same { - static bool const value = false; -}; - -template -struct is_same { - static bool const value = true; -}; - - -template -struct enable_if { - typedef T type; -}; - -template -struct enable_if { }; - - -#endif /* ISDERIVEDFROM_H_ */ From f663de2418ae1be1064ab4acbf132651c0e5b509 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 10 Sep 2020 15:17:38 +0200 Subject: [PATCH 045/192] taken over changes from master --- serialize/SerializeAdapter.h | 116 +++++++++++++++++++++++++---------- 1 file changed, 83 insertions(+), 33 deletions(-) diff --git a/serialize/SerializeAdapter.h b/serialize/SerializeAdapter.h index 24f6111e..a05b1791 100644 --- a/serialize/SerializeAdapter.h +++ b/serialize/SerializeAdapter.h @@ -1,47 +1,92 @@ -#ifndef FSFW_SERIALIZE_SERIALIZEADAPTER_H_ -#define FSFW_SERIALIZE_SERIALIZEADAPTER_H_ +#ifndef _FSFW_SERIALIZE_SERIALIZEADAPTER_H_ +#define _FSFW_SERIALIZE_SERIALIZEADAPTER_H_ +#include "../returnvalues/HasReturnvaluesIF.h" #include "EndianConverter.h" #include "SerializeIF.h" +#include +#include -#include "../container/IsDerivedFrom.h" -#include "../returnvalues/HasReturnvaluesIF.h" -#include - - /** - * @brief These adapters provides an interface to use the SerializeIF functions - * with arbitrary template objects to facilitate and simplify the - * serialization of classes with different multiple different data types - * into buffers and vice-versa. - * @details - * The correct serialization or deserialization function is chosen at - * compile time with template type deduction. - * - * @ingroup serialize +/** + * \ingroup serialize */ + class SerializeAdapter { public: + /*** + * This function can be used to serialize a trivial copy-able type or a child of SerializeIF. + * The right template to be called is determined in the function itself. + * For objects of non trivial copy-able type this function is almost never called by the user directly. + * Instead helpers for specific types like SerialArrayListAdapter or SerialLinkedListAdapter is the right choice here. + * + * @param[in] object Object to serialize, the used type is deduced from this pointer + * @param[in/out] buffer Buffer to serialize into. Will be moved by the function. + * @param[in/out] size Size of current written buffer. Will be incremented by the function. + * @param[in] maxSize Max size of Buffer + * @param[in] streamEndianness Endianness of serialized element as in according to SerializeIF::Endianness + * @return + * - @c BUFFER_TOO_SHORT The given buffer in is too short + * - @c RETURN_FAILED Generic Error + * - @c RETURN_OK Successful serialization + */ template static ReturnValue_t serialize(const T *object, uint8_t **buffer, - size_t *size, size_t maxSize, SerializeIF::Endianness streamEndianness) { - InternalSerializeAdapter::Is> adapter; + size_t *size, size_t maxSize, + SerializeIF::Endianness streamEndianness) { + InternalSerializeAdapter::value> adapter; return adapter.serialize(object, buffer, size, maxSize, streamEndianness); } + /** + * Function to return the serialized size of the object in the pointer. + * May be a trivially copy-able object or a Child of SerializeIF + * + * @param object Pointer to Object + * @return Serialized size of object + */ template - static uint32_t getSerializedSize(const T *object) { - InternalSerializeAdapter::Is> adapter; + static size_t getSerializedSize(const T *object){ + InternalSerializeAdapter::value> adapter; return adapter.getSerializedSize(object); } + /** + * @brief + * Deserializes a object from a given buffer of given size. + * Object Must be trivially copy-able or a child of SerializeIF. + * + * @details + * Buffer will be moved to the current read location. Size will be decreased by the function. + * + * @param[in/out] buffer Buffer to deSerialize from. Will be moved by the function. + * @param[in/out] size Remaining size of the buffer to read from. Will be decreased by function. + * @param[in] streamEndianness Endianness as in according to SerializeIF::Endianness + * @return + * - @c STREAM_TOO_SHORT The input stream is too short to deSerialize the object + * - @c TOO_MANY_ELEMENTS The buffer has more inputs than expected + * - @c RETURN_FAILED Generic Error + * - @c RETURN_OK Successful deserialization + */ template static ReturnValue_t deSerialize(T *object, const uint8_t **buffer, size_t *size, SerializeIF::Endianness streamEndianness) { - InternalSerializeAdapter::Is> adapter; + InternalSerializeAdapter::value> adapter; return adapter.deSerialize(object, buffer, size, streamEndianness); } private: - template - class InternalSerializeAdapter { + /** + * Internal template to deduce the right function calls at compile time + */ + template class InternalSerializeAdapter; + + /** + * Template to be used if T is not a child of SerializeIF + * + * @tparam T T must be trivially_copyable + */ + template + class InternalSerializeAdapter { + static_assert (std::is_trivially_copyable::value, + "If a type needs to be serialized it must be a child of SerializeIF or trivially copy-able"); public: static ReturnValue_t serialize(const T *object, uint8_t **buffer, size_t *size, size_t max_size, @@ -50,8 +95,9 @@ private: if (size == nullptr) { size = &ignoredSize; } - //TODO check integer overflow of *size - if (sizeof(T) + *size <= max_size) { + //Check remaining size is large enough and check integer overflow of *size + size_t newSize = sizeof(T) + *size; + if ((newSize <= max_size) and (newSize > *size)) { T tmp; switch (streamEndianness) { case SerializeIF::Endianness::BIG: @@ -65,7 +111,7 @@ private: tmp = *object; break; } - std::memcpy(*buffer, &tmp, sizeof(T)); + memcpy(*buffer, &tmp, sizeof(T)); *size += sizeof(T); (*buffer) += sizeof(T); return HasReturnvaluesIF::RETURN_OK; @@ -79,7 +125,7 @@ private: T tmp; if (*size >= sizeof(T)) { *size -= sizeof(T); - std::memcpy(&tmp, *buffer, sizeof(T)); + memcpy(&tmp, *buffer, sizeof(T)); switch (streamEndianness) { case SerializeIF::Endianness::BIG: *object = EndianConverter::convertBigEndian(tmp); @@ -103,14 +149,18 @@ private: uint32_t getSerializedSize(const T *object) { return sizeof(T); } - }; + /** + * Template for objects that inherit from SerializeIF + * + * @tparam T A child of SerializeIF + */ template - class InternalSerializeAdapter { + class InternalSerializeAdapter { public: - ReturnValue_t serialize(const T *object, uint8_t **buffer, - size_t *size, size_t max_size, + ReturnValue_t serialize(const T *object, uint8_t **buffer, size_t *size, + size_t max_size, SerializeIF::Endianness streamEndianness) const { size_t ignoredSize = 0; if (size == nullptr) { @@ -118,7 +168,7 @@ private: } return object->serialize(buffer, size, max_size, streamEndianness); } - uint32_t getSerializedSize(const T *object) const { + size_t getSerializedSize(const T *object) const { return object->getSerializedSize(); } @@ -129,4 +179,4 @@ private: }; }; -#endif /* SERIALIZEADAPTER_H_ */ +#endif /* _FSFW_SERIALIZE_SERIALIZEADAPTER_H_ */ From fd09774fc3577eb3993759d2473112796c87a0cb Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 10 Sep 2020 15:18:45 +0200 Subject: [PATCH 046/192] serialize if update --- serialize/SerializeIF.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/serialize/SerializeIF.h b/serialize/SerializeIF.h index 3c0540f9..a701fe53 100644 --- a/serialize/SerializeIF.h +++ b/serialize/SerializeIF.h @@ -2,7 +2,7 @@ #define FSFW_SERIALIZE_SERIALIZEIF_H_ #include "../returnvalues/HasReturnvaluesIF.h" -#include +#include /** * @defgroup serialize Serialization @@ -10,10 +10,7 @@ */ /** - * @brief Translation of objects into data streams and from data streams. - * @details - * Also provides options to convert from/to data with different endianness. - * variables. + * Translation of objects into data streams and from data streams. * @ingroup serialize */ class SerializeIF { @@ -46,7 +43,7 @@ public: * @param[in] maxSize The size of the buffer that is allowed to be used for serialize. * @param[in] streamEndianness Endianness of the serialized data according to SerializeIF::Endianness * @return - * - @ยข BUFFER_TOO_SHORT The given buffer in is too short + * - @c BUFFER_TOO_SHORT The given buffer in is too short * - @c RETURN_FAILED Generic error * - @c RETURN_OK Successful serialization */ From bbc73a6aaf5d607aca25c04b2bc59a1f7d4b031c Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 10 Sep 2020 15:25:29 +0200 Subject: [PATCH 047/192] taken over serialize adapter changes --- serialize/SerializeAdapter.h | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/serialize/SerializeAdapter.h b/serialize/SerializeAdapter.h index a05b1791..e6cd247e 100644 --- a/serialize/SerializeAdapter.h +++ b/serialize/SerializeAdapter.h @@ -7,17 +7,26 @@ #include #include -/** - * \ingroup serialize + /** + * @brief These adapters provides an interface to use the SerializeIF functions + * with arbitrary template objects to facilitate and simplify the + * serialization of classes with different multiple different data types + * into buffers and vice-versa. + * @details + * The correct serialization or deserialization function is chosen at + * compile time with template type deduction. + * + * @ingroup serialize */ - class SerializeAdapter { public: /*** - * This function can be used to serialize a trivial copy-able type or a child of SerializeIF. + * This function can be used to serialize a trivial copy-able type or a + * child of SerializeIF. * The right template to be called is determined in the function itself. - * For objects of non trivial copy-able type this function is almost never called by the user directly. - * Instead helpers for specific types like SerialArrayListAdapter or SerialLinkedListAdapter is the right choice here. + * For objects of non trivial copy-able type this function is almost never + * called by the user directly. Instead helpers for specific types like + * SerialArrayListAdapter or SerialLinkedListAdapter is the right choice here. * * @param[in] object Object to serialize, the used type is deduced from this pointer * @param[in/out] buffer Buffer to serialize into. Will be moved by the function. @@ -86,7 +95,8 @@ private: template class InternalSerializeAdapter { static_assert (std::is_trivially_copyable::value, - "If a type needs to be serialized it must be a child of SerializeIF or trivially copy-able"); + "If a type needs to be serialized it must be a child of " + "SerializeIF or trivially copy-able"); public: static ReturnValue_t serialize(const T *object, uint8_t **buffer, size_t *size, size_t max_size, @@ -95,7 +105,8 @@ private: if (size == nullptr) { size = &ignoredSize; } - //Check remaining size is large enough and check integer overflow of *size + // Check remaining size is large enough and check integer + // overflow of *size size_t newSize = sizeof(T) + *size; if ((newSize <= max_size) and (newSize > *size)) { T tmp; @@ -111,7 +122,7 @@ private: tmp = *object; break; } - memcpy(*buffer, &tmp, sizeof(T)); + std::memcpy(*buffer, &tmp, sizeof(T)); *size += sizeof(T); (*buffer) += sizeof(T); return HasReturnvaluesIF::RETURN_OK; @@ -125,7 +136,7 @@ private: T tmp; if (*size >= sizeof(T)) { *size -= sizeof(T); - memcpy(&tmp, *buffer, sizeof(T)); + std::memcpy(&tmp, *buffer, sizeof(T)); switch (streamEndianness) { case SerializeIF::Endianness::BIG: *object = EndianConverter::convertBigEndian(tmp); From 96e471add600b1829d08958e87b505d37e45a8e3 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 10 Sep 2020 15:51:11 +0200 Subject: [PATCH 048/192] merged fixed map changes --- container/FixedMap.h | 76 +++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 47 deletions(-) diff --git a/container/FixedMap.h b/container/FixedMap.h index 3b09fa3b..475d4091 100644 --- a/container/FixedMap.h +++ b/container/FixedMap.h @@ -1,23 +1,27 @@ -#ifndef FIXEDMAP_H_ -#define FIXEDMAP_H_ +#ifndef FSFW_CONTAINER_FIXEDMAP_H_ +#define FSFW_CONTAINER_FIXEDMAP_H_ -#include "../container/ArrayList.h" +#include "ArrayList.h" #include "../returnvalues/HasReturnvaluesIF.h" #include +#include /** - * @brief Map implementation for maps with a pre-defined size. - * @details Can be initialized with desired maximum size. - * Iterator is used to access pair and - * iterate through map entries. Complexity O(n). + * @brief Map implementation for maps with a pre-defined size. + * @details + * Can be initialized with desired maximum size. + * Iterator is used to access pair and iterate through map entries. + * Complexity O(n). + * @warning Iterators return a non-const key_t in the pair. + * @warning A User is not allowed to change the key, otherwise the map is corrupted. * @ingroup container */ template class FixedMap: public SerializeIF { - static_assert (std::is_trivially_copyable::value or - std::is_base_of::value, - "Types used in FixedMap must either be trivial copy-able or a " - "derived class from SerializeIF to be serialize-able"); + static_assert (std::is_trivially_copyable::value or + std::is_base_of::value, + "Types used in FixedMap must either be trivial copy-able or a " + "derived class from SerializeIF to be serialize-able"); public: static const uint8_t INTERFACE_ID = CLASS_ID::FIXED_MAP; static const ReturnValue_t KEY_ALREADY_EXISTS = MAKE_RETURN_CODE(0x01); @@ -55,29 +59,8 @@ public: Iterator(std::pair *pair) : ArrayList, uint32_t>::Iterator(pair) { } - - T operator*() { - return ArrayList, uint32_t>::Iterator::value->second; - } - - // -> operator overloaded, can be used to access value - T *operator->() { - return &ArrayList, uint32_t>::Iterator::value->second; - } - - // Can be used to access the key of the iterator - key_t first() { - return ArrayList, uint32_t>::Iterator::value->first; - } - - // Alternative to access value, similar to std::map implementation - T second() { - return ArrayList, uint32_t>::Iterator::value->second; - } }; - - Iterator begin() const { return Iterator(&theMap[0]); } @@ -90,16 +73,16 @@ public: return _size; } - ReturnValue_t insert(key_t key, T value, Iterator *storedValue = NULL) { + ReturnValue_t insert(key_t key, T value, Iterator *storedValue = nullptr) { if (exists(key) == HasReturnvaluesIF::RETURN_OK) { - return FixedMap::KEY_ALREADY_EXISTS; + return KEY_ALREADY_EXISTS; } if (_size == theMap.maxSize()) { - return FixedMap::MAP_FULL; + return MAP_FULL; } theMap[_size].first = key; theMap[_size].second = value; - if (storedValue != NULL) { + if (storedValue != nullptr) { *storedValue = Iterator(&theMap[_size]); } ++_size; @@ -160,6 +143,15 @@ public: return HasReturnvaluesIF::RETURN_OK; } + bool full() { + if(_size >= theMap.maxSize()) { + return true; + } + else { + return false; + } + } + void clear() { _size = 0; } @@ -168,16 +160,6 @@ public: return theMap.maxSize(); } - - bool full() { - if(_size == theMap.maxSize()) { - return true; - } - else { - return false; - } - } - virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const { ReturnValue_t result = SerializeAdapter::serialize(&this->_size, @@ -226,4 +208,4 @@ public: }; -#endif /* FIXEDMAP_H_ */ +#endif /* FSFW_CONTAINER_FIXEDMAP_H_ */ From f35efa3cbe3926b1e47e8a62faeb81a6dae9a1ef Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 10 Sep 2020 15:52:00 +0200 Subject: [PATCH 049/192] taken over CSB changes --- tmtcservices/CommandingServiceBase.cpp | 76 +++++++++++++------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/tmtcservices/CommandingServiceBase.cpp b/tmtcservices/CommandingServiceBase.cpp index e5a87f18..4cead0e9 100644 --- a/tmtcservices/CommandingServiceBase.cpp +++ b/tmtcservices/CommandingServiceBase.cpp @@ -1,9 +1,9 @@ #include "../tcdistribution/PUSDistributorIF.h" -#include "../tmtcservices/AcceptsTelemetryIF.h" +#include "AcceptsTelemetryIF.h" #include "../objectmanager/ObjectManagerIF.h" -#include "../tmtcservices/CommandingServiceBase.h" -#include "../tmtcservices/TmTcMessage.h" +#include "CommandingServiceBase.h" +#include "TmTcMessage.h" #include "../ipc/QueueFactory.h" #include "../tmtcpacket/pus/TcPacketStored.h" #include "../tmtcpacket/pus/TmPacketStored.h" @@ -122,8 +122,8 @@ void CommandingServiceBase::handleCommandMessage(CommandMessage* reply) { // Implemented by child class, specifies what to do with reply. - ReturnValue_t result = handleReply(reply, iter->command, &iter->state, - &nextCommand, iter->objectId, &isStep); + ReturnValue_t result = handleReply(reply, iter->second.command, &iter->second.state, + &nextCommand, iter->second.objectId, &isStep); /* If the child implementation does not implement special handling for * rejected replies (RETURN_FAILED or INVALID_REPLY is returned), a @@ -132,7 +132,7 @@ void CommandingServiceBase::handleCommandMessage(CommandMessage* reply) { if((reply->getCommand() == CommandMessage::REPLY_REJECTED) and (result == RETURN_FAILED or result == INVALID_REPLY)) { result = reply->getReplyRejectedReason(); - failureParameter1 = iter->command; + failureParameter1 = iter->second.command; } switch (result) { @@ -149,14 +149,14 @@ void CommandingServiceBase::handleCommandMessage(CommandMessage* reply) { default: if (isStep) { verificationReporter.sendFailureReport( - TC_VERIFY::PROGRESS_FAILURE, iter->tcInfo.ackFlags, - iter->tcInfo.tcPacketId, iter->tcInfo.tcSequenceControl, - result, ++iter->step, failureParameter1, + TC_VERIFY::PROGRESS_FAILURE, iter->second.tcInfo.ackFlags, + iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl, + result, ++iter->second.step, failureParameter1, failureParameter2); } else { verificationReporter.sendFailureReport( - TC_VERIFY::COMPLETION_FAILURE, iter->tcInfo.ackFlags, - iter->tcInfo.tcPacketId, iter->tcInfo.tcSequenceControl, + TC_VERIFY::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags, + iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl, result, 0, failureParameter1, failureParameter2); } failureParameter1 = 0; @@ -170,7 +170,7 @@ void CommandingServiceBase::handleCommandMessage(CommandMessage* reply) { void CommandingServiceBase::handleReplyHandlerResult(ReturnValue_t result, CommandMapIter iter, CommandMessage* nextCommand, CommandMessage* reply, bool& isStep) { - iter->command = nextCommand->getCommand(); + iter->second.command = nextCommand->getCommand(); // In case a new command is to be sent immediately, this is performed here. // If no new command is sent, only analyse reply result by initializing @@ -185,14 +185,14 @@ void CommandingServiceBase::handleReplyHandlerResult(ReturnValue_t result, if (isStep and result != NO_STEP_MESSAGE) { verificationReporter.sendSuccessReport( TC_VERIFY::PROGRESS_SUCCESS, - iter->tcInfo.ackFlags, iter->tcInfo.tcPacketId, - iter->tcInfo.tcSequenceControl, ++iter->step); + iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId, + iter->second.tcInfo.tcSequenceControl, ++iter->second.step); } else { verificationReporter.sendSuccessReport( TC_VERIFY::COMPLETION_SUCCESS, - iter->tcInfo.ackFlags, iter->tcInfo.tcPacketId, - iter->tcInfo.tcSequenceControl, 0); + iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId, + iter->second.tcInfo.tcSequenceControl, 0); checkAndExecuteFifo(iter); } } @@ -200,16 +200,16 @@ void CommandingServiceBase::handleReplyHandlerResult(ReturnValue_t result, if (isStep) { nextCommand->clearCommandMessage(); verificationReporter.sendFailureReport( - TC_VERIFY::PROGRESS_FAILURE, iter->tcInfo.ackFlags, - iter->tcInfo.tcPacketId, - iter->tcInfo.tcSequenceControl, sendResult, - ++iter->step, failureParameter1, failureParameter2); + TC_VERIFY::PROGRESS_FAILURE, iter->second.tcInfo.ackFlags, + iter->second.tcInfo.tcPacketId, + iter->second.tcInfo.tcSequenceControl, sendResult, + ++iter->second.step, failureParameter1, failureParameter2); } else { nextCommand->clearCommandMessage(); verificationReporter.sendFailureReport( TC_VERIFY::COMPLETION_FAILURE, - iter->tcInfo.ackFlags, iter->tcInfo.tcPacketId, - iter->tcInfo.tcSequenceControl, sendResult, 0, + iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId, + iter->second.tcInfo.tcSequenceControl, sendResult, 0, failureParameter1, failureParameter2); } failureParameter1 = 0; @@ -248,7 +248,7 @@ void CommandingServiceBase::handleRequestQueue() { iter = commandMap.find(queue); if (iter != commandMap.end()) { - result = iter->fifo.insert(address); + result = iter->second.fifo.insert(address); if (result != RETURN_OK) { rejectPacket(TC_VERIFY::START_FAILURE, &packet, OBJECT_BUSY); } @@ -316,11 +316,11 @@ void CommandingServiceBase::startExecution(TcPacketStored *storedPacket, CommandMapIter iter) { ReturnValue_t result = RETURN_OK; CommandMessage command; - iter->subservice = storedPacket->getSubService(); - result = prepareCommand(&command, iter->subservice, + iter->second.subservice = storedPacket->getSubService(); + result = prepareCommand(&command, iter->second.subservice, storedPacket->getApplicationData(), - storedPacket->getApplicationDataSize(), &iter->state, - iter->objectId); + storedPacket->getApplicationDataSize(), &iter->second.state, + iter->second.objectId); ReturnValue_t sendResult = RETURN_OK; switch (result) { @@ -330,13 +330,13 @@ void CommandingServiceBase::startExecution(TcPacketStored *storedPacket, &command); } if (sendResult == RETURN_OK) { - Clock::getUptime(&iter->uptimeOfStart); - iter->step = 0; - iter->subservice = storedPacket->getSubService(); - iter->command = command.getCommand(); - iter->tcInfo.ackFlags = storedPacket->getAcknowledgeFlags(); - iter->tcInfo.tcPacketId = storedPacket->getPacketId(); - iter->tcInfo.tcSequenceControl = + Clock::getUptime(&iter->second.uptimeOfStart); + iter->second.step = 0; + iter->second.subservice = storedPacket->getSubService(); + iter->second.command = command.getCommand(); + iter->second.tcInfo.ackFlags = storedPacket->getAcknowledgeFlags(); + iter->second.tcInfo.tcPacketId = storedPacket->getPacketId(); + iter->second.tcInfo.tcSequenceControl = storedPacket->getPacketSequenceControl(); acceptPacket(TC_VERIFY::START_SUCCESS, storedPacket); } else { @@ -386,7 +386,7 @@ void CommandingServiceBase::acceptPacket(uint8_t reportId, void CommandingServiceBase::checkAndExecuteFifo(CommandMapIter iter) { store_address_t address; - if (iter->fifo.retrieve(&address) != RETURN_OK) { + if (iter->second.fifo.retrieve(&address) != RETURN_OK) { commandMap.erase(&iter); } else { TcPacketStored newPacket(address); @@ -412,10 +412,10 @@ void CommandingServiceBase::checkTimeout() { Clock::getUptime(&uptime); CommandMapIter iter; for (iter = commandMap.begin(); iter != commandMap.end(); ++iter) { - if ((iter->uptimeOfStart + (timeoutSeconds * 1000)) < uptime) { + if ((iter->second.uptimeOfStart + (timeoutSeconds * 1000)) < uptime) { verificationReporter.sendFailureReport( - TC_VERIFY::COMPLETION_FAILURE, iter->tcInfo.ackFlags, - iter->tcInfo.tcPacketId, iter->tcInfo.tcSequenceControl, + TC_VERIFY::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags, + iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl, TIMEOUT); checkAndExecuteFifo(iter); } From d9dcee3692aa548a94fc614529c954ffcd36b9fe Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 10 Sep 2020 15:55:56 +0200 Subject: [PATCH 050/192] array list changes taken over --- container/ArrayList.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/container/ArrayList.h b/container/ArrayList.h index 9f5e76de..bda60433 100644 --- a/container/ArrayList.h +++ b/container/ArrayList.h @@ -116,7 +116,11 @@ public: return tmp; } - T operator*() { + T& operator*() { + return *value; + } + + const T& operator*() const { return *value; } @@ -124,12 +128,13 @@ public: return value; } - const T *operator->() const{ + const T *operator->() const { return value; } + //SHOULDDO this should be implemented as non-member - bool operator==(const typename ArrayList::Iterator& other) const{ + bool operator==(const typename ArrayList::Iterator& other) const { return (value == other.value); } From e57d4a11ae1db3b965a24e3de5efcae1ffc29781 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 10 Sep 2020 16:01:05 +0200 Subject: [PATCH 051/192] fixed ordered multi map changes integrated --- container/FixedOrderedMultimap.h | 13 +++++-------- container/FixedOrderedMultimap.tpp | 15 +++------------ 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/container/FixedOrderedMultimap.h b/container/FixedOrderedMultimap.h index 41465c33..99825dc4 100644 --- a/container/FixedOrderedMultimap.h +++ b/container/FixedOrderedMultimap.h @@ -1,5 +1,5 @@ -#ifndef FRAMEWORK_CONTAINER_FIXEDORDEREDMULTIMAP_H_ -#define FRAMEWORK_CONTAINER_FIXEDORDEREDMULTIMAP_H_ +#ifndef FSFW_CONTAINER_FIXEDORDEREDMULTIMAP_H_ +#define FSFW_CONTAINER_FIXEDORDEREDMULTIMAP_H_ #include "../container/ArrayList.h" #include @@ -39,10 +39,6 @@ public: Iterator(); /** Initializes iterator to given entry */ Iterator(std::pair *pair); - /** Dereference operator can be used to get value */ - T operator*(); - /** Arrow operator can be used to get pointer to value */ - T *operator->(); }; /** Iterator to start of map */ @@ -160,7 +156,8 @@ private: if (_size <= position) { return; } - memmove(&theMap[position], &theMap[position + 1], + std::memmove(static_cast(&theMap[position]), + static_cast(&theMap[position + 1]), (_size - position - 1) * sizeof(std::pair)); --_size; } @@ -168,4 +165,4 @@ private: #include "FixedOrderedMultimap.tpp" -#endif /* FRAMEWORK_CONTAINER_FIXEDORDEREDMULTIMAP_H_ */ +#endif /* FSFW_CONTAINER_FIXEDORDEREDMULTIMAP_H_ */ diff --git a/container/FixedOrderedMultimap.tpp b/container/FixedOrderedMultimap.tpp index 74edbf9a..5b7b9ead 100644 --- a/container/FixedOrderedMultimap.tpp +++ b/container/FixedOrderedMultimap.tpp @@ -10,11 +10,6 @@ inline FixedOrderedMultimap::Iterator::Iterator( std::pair *pair): ArrayList, uint32_t>::Iterator(pair){} -template -inline T FixedOrderedMultimap::Iterator::operator*() { - return ArrayList, uint32_t>::Iterator::value->second; -} - template inline typename FixedOrderedMultimap::Iterator FixedOrderedMultimap::begin() const { @@ -33,11 +28,6 @@ inline size_t FixedOrderedMultimap::size() const { return _size; } -template -inline T* FixedOrderedMultimap::Iterator::operator->() { - return &ArrayList, uint32_t>::Iterator::value->second; -} - template inline FixedOrderedMultimap::FixedOrderedMultimap( size_t maxSize): theMap(maxSize), _size(0) {} @@ -52,8 +42,9 @@ inline ReturnValue_t FixedOrderedMultimap::insert( uint32_t position = findNicePlace(key); // Compiler might emitt warning because std::pair is not a POD type (yet..) // See: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2342.htm#std::pair-example - // Should still work without issues. - std::memmove(&theMap[position + 1], &theMap[position], + // Circumvent warning by casting to void* + std::memmove(static_cast(&theMap[position + 1]), + static_cast(&theMap[position]), (_size - position) * sizeof(std::pair)); theMap[position].first = key; theMap[position].second = value; From e4d95a4e0991e766725ddcb4158f26341c7d213e Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 10 Sep 2020 16:07:09 +0200 Subject: [PATCH 052/192] subsystem changes taken over --- subsystem/Subsystem.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subsystem/Subsystem.cpp b/subsystem/Subsystem.cpp index 400ecc83..ba1f463c 100644 --- a/subsystem/Subsystem.cpp +++ b/subsystem/Subsystem.cpp @@ -545,7 +545,7 @@ Mode_t Subsystem::getFallbackSequence(Mode_t sequence) { for (FixedMap::Iterator iter = modeSequences.begin(); iter != modeSequences.end(); ++iter) { if (iter.value->first == sequence) { - return iter->fallbackSequence; + return iter->second.fallbackSequence; } } return -1; @@ -554,7 +554,7 @@ Mode_t Subsystem::getFallbackSequence(Mode_t sequence) { bool Subsystem::isFallbackSequence(Mode_t SequenceId) { for (FixedMap::Iterator iter = modeSequences.begin(); iter != modeSequences.end(); iter++) { - if (iter->fallbackSequence == SequenceId) { + if (iter->second.fallbackSequence == SequenceId) { return true; } } From d7bbd4b652ff2e2e4fe63485fe57e5622ec3d82a Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 10 Sep 2020 19:51:17 +0200 Subject: [PATCH 053/192] severla bugfixes, new periodic op divider added --- datapoollocal/LocalDataPoolManager.cpp | 32 ++++++---- datapoollocal/LocalDataPoolManager.h | 5 +- globalfunctions/PeriodicOperationDivider.cpp | 34 +++++++++++ globalfunctions/PeriodicOperationDivider.h | 55 +++++++++++++++++ housekeeping/HousekeepingPacketDownlink.h | 64 +++++--------------- 5 files changed, 127 insertions(+), 63 deletions(-) create mode 100644 globalfunctions/PeriodicOperationDivider.cpp create mode 100644 globalfunctions/PeriodicOperationDivider.h diff --git a/datapoollocal/LocalDataPoolManager.cpp b/datapoollocal/LocalDataPoolManager.cpp index c84b2c69..39434b5a 100644 --- a/datapoollocal/LocalDataPoolManager.cpp +++ b/datapoollocal/LocalDataPoolManager.cpp @@ -177,7 +177,8 @@ const HasLocalDataPoolIF* LocalDataPoolManager::getOwner() const { } ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid, - float collectionInterval, MessageQueueId_t destination) { + /*float collectionInterval, bool reportingEnabled, */ + bool forDownlink, MessageQueueId_t destination) { LocalPoolDataSetBase* dataSetToSerialize = dynamic_cast(owner->getDataSetHandle(sid)); if(dataSetToSerialize == nullptr) { @@ -187,10 +188,13 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid, } store_address_t storeId; - HousekeepingPacketDownlink hkPacket(sid, collectionInterval, - dataSetToSerialize->getFillCount(), dataSetToSerialize); - ReturnValue_t result = serializeHkPacketIntoStore(hkPacket, &storeId); - if(result != HasReturnvaluesIF::RETURN_OK) { + HousekeepingPacketDownlink hkPacket(sid,/* reportingEnabled, + collectionInterval, dataSetToSerialize->getFillCount(), */ + dataSetToSerialize); + size_t serializedSize = 0; + ReturnValue_t result = serializeHkPacketIntoStore(hkPacket, storeId, + forDownlink, &serializedSize); + if(result != HasReturnvaluesIF::RETURN_OK or serializedSize == 0) { return result; } @@ -213,17 +217,21 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid, ReturnValue_t LocalDataPoolManager::serializeHkPacketIntoStore( HousekeepingPacketDownlink& hkPacket, - store_address_t *storeId) { + store_address_t& storeId, bool forDownlink, + size_t* serializedSize) { uint8_t* dataPtr = nullptr; - size_t serializedSize = 0; const size_t maxSize = hkPacket.getSerializedSize(); - ReturnValue_t result = ipcStore->getFreeElement(storeId, - serializedSize, &dataPtr); + ReturnValue_t result = ipcStore->getFreeElement(&storeId, + maxSize, &dataPtr); if(result != HasReturnvaluesIF::RETURN_OK) { return result; } - return hkPacket.serialize(&dataPtr, &serializedSize, maxSize, + if(forDownlink) { + return hkPacket.serialize(&dataPtr, serializedSize, maxSize, + SerializeIF::Endianness::BIG); + } + return hkPacket.serialize(&dataPtr, serializedSize, maxSize, SerializeIF::Endianness::MACHINE); } @@ -265,7 +273,9 @@ void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver* receiver) { if(receiver->intervalCounter >= receiver->hkParameter.collectionIntervalTicks) { ReturnValue_t result = generateHousekeepingPacket( - receiver->dataId.dataSetSid); + receiver->dataId.dataSetSid, true + /*intervalToIntervalSeconds(receiver->isDiagnostics, + receiver->hkParameter.collectionIntervalTicks), true */); if(result != HasReturnvaluesIF::RETURN_OK) { // configuration error sif::debug << "LocalDataPoolManager::performHkOperation:" diff --git a/datapoollocal/LocalDataPoolManager.h b/datapoollocal/LocalDataPoolManager.h index c6567c80..552aaff7 100644 --- a/datapoollocal/LocalDataPoolManager.h +++ b/datapoollocal/LocalDataPoolManager.h @@ -110,7 +110,8 @@ public: * @return */ ReturnValue_t generateHousekeepingPacket(sid_t sid, - float collectionInterval = 0, + bool forDownlink, + /*float collectionInterval, bool reportingEnabled, */ MessageQueueId_t destination = MessageQueueIF::NO_QUEUE); ReturnValue_t generateSetStructurePacket(sid_t sid); @@ -248,7 +249,7 @@ private: void setMinimalSamplingFrequency(float frequencySeconds); ReturnValue_t serializeHkPacketIntoStore( HousekeepingPacketDownlink& hkPacket, - store_address_t *storeId); + store_address_t& storeId, bool forDownlink, size_t* serializedSize); uint32_t intervalSecondsToInterval(bool isDiagnostics, float collectionIntervalSeconds); diff --git a/globalfunctions/PeriodicOperationDivider.cpp b/globalfunctions/PeriodicOperationDivider.cpp new file mode 100644 index 00000000..ad3b8bbd --- /dev/null +++ b/globalfunctions/PeriodicOperationDivider.cpp @@ -0,0 +1,34 @@ +#include "PeriodicOperationDivider.h" + + +PeriodicOperationDivider::PeriodicOperationDivider(uint32_t divider, + bool resetAutomatically): resetAutomatically(resetAutomatically), + counter(divider), divider(divider) { +} + +bool PeriodicOperationDivider::checkAndIncrement() { + if(counter >= divider) { + if(resetAutomatically) { + counter = 0; + } + return true; + } + counter ++; + return false; +} + +void PeriodicOperationDivider::resetCounter() { + counter = 0; +} + +void PeriodicOperationDivider::setDivider(uint32_t newDivider) { + divider = newDivider; +} + +uint32_t PeriodicOperationDivider::getCounter() const { + return counter; +} + +uint32_t PeriodicOperationDivider::getDivider() const { + return divider; +} diff --git a/globalfunctions/PeriodicOperationDivider.h b/globalfunctions/PeriodicOperationDivider.h new file mode 100644 index 00000000..dd970fb8 --- /dev/null +++ b/globalfunctions/PeriodicOperationDivider.h @@ -0,0 +1,55 @@ +#ifndef FSFW_GLOBALFUNCTIONS_PERIODICOPERATIONDIVIDER_H_ +#define FSFW_GLOBALFUNCTIONS_PERIODICOPERATIONDIVIDER_H_ + +#include + +/** + * @brief Lightweight helper class to facilitate periodic operation with + * decreased frequencies. + * @details + * This class is useful to perform operations which have to be performed + * with a reduced frequency, like debugging printouts in high periodic tasks + * or low priority operations. + */ +class PeriodicOperationDivider { +public: + /** + * Initialize with the desired divider and specify whether the internal + * counter will be reset automatically. + * @param divider + * @param resetAutomatically + */ + PeriodicOperationDivider(uint32_t divider, bool resetAutomatically = true); + + /** + * Check whether operation is necessary. + * If an operation is necessary and the class has been + * configured to be reset automatically, the counter will be reset. + * If not, the counter will be incremented. + * @return + * -@c true if the counter is larger or equal to the divider + * -@c false otherwise + */ + bool checkAndIncrement(); + + /** + * Can be used to reset the counter to 0 manually. + */ + void resetCounter(); + uint32_t getCounter() const; + + /** + * Can be used to set a new divider value. + * @param newDivider + */ + void setDivider(uint32_t newDivider); + uint32_t getDivider() const; +private: + bool resetAutomatically = true; + uint32_t counter = 0; + uint32_t divider = 0; +}; + + + +#endif /* FSFW_GLOBALFUNCTIONS_PERIODICOPERATIONDIVIDER_H_ */ diff --git a/housekeeping/HousekeepingPacketDownlink.h b/housekeeping/HousekeepingPacketDownlink.h index ee531bae..0be1551d 100644 --- a/housekeeping/HousekeepingPacketDownlink.h +++ b/housekeeping/HousekeepingPacketDownlink.h @@ -2,8 +2,6 @@ #define FSFW_HOUSEKEEPING_HOUSEKEEPINGPACKETDOWNLINK_H_ #include "../datapoollocal/LocalPoolDataSetBase.h" - -#include "../housekeeping/HousekeepingMessage.h" #include "../serialize/SerialLinkedListAdapter.h" #include "../storagemanager/StorageManagerIF.h" @@ -16,67 +14,33 @@ */ class HousekeepingPacketDownlink: public SerialLinkedListAdapter { public: - HousekeepingPacketDownlink(sid_t sid, float collectionInterval, uint8_t - numberOfParameters, LocalPoolDataSetBase* dataSetPtr): + HousekeepingPacketDownlink(sid_t sid, /*bool reportingStatus, + float collectionInterval, uint8_t numberOfParameters, */ + LocalPoolDataSetBase* dataSetPtr): sourceId(sid.objectId), setId(sid.ownerSetId), - collectionInterval(collectionInterval), - numberOfParameters(numberOfParameters), hkData(dataSetPtr) { + /*reportingStatus(reportingStatus), + collectionInterval(collectionInterval), + numberOfParameters(numberOfParameters), */hkData(dataSetPtr) { setLinks(); } - /** - * Helper functions which can be used to move HK data from the IPC store - * to the telemetry store. TODO: maybe not needed. - * @param formerStore - * @param storeId - * @param newStore - * @param newStoreId [out] - * @return - */ - virtual ReturnValue_t moveToOtherStore(StorageManagerIF* formerStore, - store_address_t storeId, StorageManagerIF* newStore, - store_address_t* newStoreId) { - const uint8_t* dataPtr = nullptr; - size_t hkDataSize = 0; - ReturnValue_t result = formerStore->getData(storeId, &dataPtr, - &hkDataSize); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - - return newStore->addData(newStoreId, dataPtr, hkDataSize); - } - private: void setLinks() { setStart(&sourceId); sourceId.setNext(&setId); - setId.setNext(&collectionInterval); - collectionInterval.setNext(&numberOfParameters); - numberOfParameters.setNext(&hkData); + setId.setNext(&hkData); + //setId.setNext(&reportingStatus); + //reportingStatus.setNext(&collectionInterval); + //collectionInterval.setNext(&numberOfParameters); + //numberOfParameters.setNext(&hkData); } SerializeElement sourceId; SerializeElement setId; - SerializeElement collectionInterval; - SerializeElement numberOfParameters; + //SerializeElement reportingStatus; + //SerializeElement collectionInterval; + //SerializeElement numberOfParameters; LinkedElement hkData; }; #endif /* FRAMEWORK_HOUSEKEEPING_HOUSEKEEPINGPACKETDOWNLINK_H_ */ - - - -// virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size, -// size_t maxSize, Endianness streamEndianness) const override { -// ReturnValue_t result = SerialLinkedListAdapter::serialize(buffer, size, -// maxSize, streamEndianness); -// if(result != HasReturnvaluesIF::RETURN_OK) { -// return result; -// } -// return dataSetPtr->serialize(buffer, size, maxSize, streamEndianness); -// } -// -// virtual size_t getSerializedSize() const override { -// -// } From 2d2d0de35cefdc627e556d33e9537cee4dca36a5 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 10 Sep 2020 20:24:49 +0200 Subject: [PATCH 054/192] local data pool manager bugfixes --- datapoollocal/LocalDataPoolManager.cpp | 19 ++++++++++--------- datapoollocal/LocalDataPoolManager.h | 3 +-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/datapoollocal/LocalDataPoolManager.cpp b/datapoollocal/LocalDataPoolManager.cpp index 39434b5a..f33cd8ab 100644 --- a/datapoollocal/LocalDataPoolManager.cpp +++ b/datapoollocal/LocalDataPoolManager.cpp @@ -177,8 +177,7 @@ const HasLocalDataPoolIF* LocalDataPoolManager::getOwner() const { } ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid, - /*float collectionInterval, bool reportingEnabled, */ - bool forDownlink, MessageQueueId_t destination) { + bool isDiagnostics, bool forDownlink, MessageQueueId_t destination) { LocalPoolDataSetBase* dataSetToSerialize = dynamic_cast(owner->getDataSetHandle(sid)); if(dataSetToSerialize == nullptr) { @@ -188,9 +187,7 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid, } store_address_t storeId; - HousekeepingPacketDownlink hkPacket(sid,/* reportingEnabled, - collectionInterval, dataSetToSerialize->getFillCount(), */ - dataSetToSerialize); + HousekeepingPacketDownlink hkPacket(sid, dataSetToSerialize); size_t serializedSize = 0; ReturnValue_t result = serializeHkPacketIntoStore(hkPacket, storeId, forDownlink, &serializedSize); @@ -200,7 +197,13 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid, // and now we set a HK message and send it the HK packet destination. CommandMessage hkMessage; - HousekeepingMessage::setHkReportMessage(&hkMessage, sid, storeId); + if(isDiagnostics) { + HousekeepingMessage::setHkDiagnosticsMessage(&hkMessage, sid, storeId); + } + else { + HousekeepingMessage::setHkReportMessage(&hkMessage, sid, storeId); + } + if(hkQueue == nullptr) { return QUEUE_OR_DESTINATION_NOT_SET; } @@ -273,9 +276,7 @@ void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver* receiver) { if(receiver->intervalCounter >= receiver->hkParameter.collectionIntervalTicks) { ReturnValue_t result = generateHousekeepingPacket( - receiver->dataId.dataSetSid, true - /*intervalToIntervalSeconds(receiver->isDiagnostics, - receiver->hkParameter.collectionIntervalTicks), true */); + receiver->dataId.dataSetSid, receiver->isDiagnostics, true); if(result != HasReturnvaluesIF::RETURN_OK) { // configuration error sif::debug << "LocalDataPoolManager::performHkOperation:" diff --git a/datapoollocal/LocalDataPoolManager.h b/datapoollocal/LocalDataPoolManager.h index 552aaff7..1ab08903 100644 --- a/datapoollocal/LocalDataPoolManager.h +++ b/datapoollocal/LocalDataPoolManager.h @@ -110,8 +110,7 @@ public: * @return */ ReturnValue_t generateHousekeepingPacket(sid_t sid, - bool forDownlink, - /*float collectionInterval, bool reportingEnabled, */ + bool isDiagnostics, bool forDownlink, MessageQueueId_t destination = MessageQueueIF::NO_QUEUE); ReturnValue_t generateSetStructurePacket(sid_t sid); From 71125c075a267e5f0b8cc6229095827b1e9285da Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 10 Sep 2020 21:05:50 +0200 Subject: [PATCH 055/192] added new setter function --- datapoollocal/LocalPoolDataSetBase.cpp | 9 ++++++++- datapoollocal/LocalPoolDataSetBase.h | 8 ++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/datapoollocal/LocalPoolDataSetBase.cpp b/datapoollocal/LocalPoolDataSetBase.cpp index 8abdc0e3..859f1f2c 100644 --- a/datapoollocal/LocalPoolDataSetBase.cpp +++ b/datapoollocal/LocalPoolDataSetBase.cpp @@ -190,4 +190,11 @@ bool LocalPoolDataSetBase::isValid() const { return this->valid; } - +void LocalPoolDataSetBase::setValidity(bool valid, bool setEntriesRecursively) { + if(setEntriesRecursively) { + for(size_t idx = 0; idx < this->getFillCount(); idx++) { + registeredVariables[idx] -> setValid(valid); + } + } + this->valid = valid; +} diff --git a/datapoollocal/LocalPoolDataSetBase.h b/datapoollocal/LocalPoolDataSetBase.h index 77c1df1b..17c20d4f 100644 --- a/datapoollocal/LocalPoolDataSetBase.h +++ b/datapoollocal/LocalPoolDataSetBase.h @@ -91,6 +91,13 @@ public: size_t* size, size_t maxSize, SerializeIF::Endianness streamEndianness) const; + /** + * Set the dataset valid or invalid + * @param setEntriesRecursively + * If this is true, all contained datasets will also be set recursively. + */ + void setValidity(bool valid, bool setEntriesRecursively); + bool isValid() const override; protected: @@ -131,4 +138,5 @@ private: }; + #endif /* FSFW_DATAPOOLLOCAL_LOCALPOOLDATASETBASE_H_ */ From f9612afe06248d38db5b8b4bb875bd7c66a12598 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 11 Sep 2020 14:06:08 +0200 Subject: [PATCH 056/192] added report status toggler --- datapoollocal/LocalDataPoolManager.cpp | 5 ----- housekeeping/HousekeepingMessage.cpp | 24 +++++++++++++++++++++++- housekeeping/HousekeepingMessage.h | 16 +++++++--------- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/datapoollocal/LocalDataPoolManager.cpp b/datapoollocal/LocalDataPoolManager.cpp index f33cd8ab..c97bbfd2 100644 --- a/datapoollocal/LocalDataPoolManager.cpp +++ b/datapoollocal/LocalDataPoolManager.cpp @@ -140,11 +140,6 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage( CommandMessage* message) { Command_t command = message->getCommand(); switch(command) { - // I think those are the only commands which can be handled here.. - case(HousekeepingMessage::ADD_HK_REPORT_STRUCT): - case(HousekeepingMessage::ADD_DIAGNOSTICS_REPORT_STRUCT): - // We should use OwnsLocalPoolDataIF to specify those functions.. - return HasReturnvaluesIF::RETURN_OK; case(HousekeepingMessage::REPORT_DIAGNOSTICS_REPORT_STRUCTURES): case(HousekeepingMessage::REPORT_HK_REPORT_STRUCTURES): //return generateSetStructurePacket(message->getSid()); diff --git a/housekeeping/HousekeepingMessage.cpp b/housekeeping/HousekeepingMessage.cpp index e354f8ff..f96f4d34 100644 --- a/housekeeping/HousekeepingMessage.cpp +++ b/housekeeping/HousekeepingMessage.cpp @@ -27,6 +27,29 @@ sid_t HousekeepingMessage::getHkReportMessage(const CommandMessage *message, return getSid(message); } +void HousekeepingMessage::setToggleReportingMessage(CommandMessage *message, + sid_t sid, bool enableReporting, bool isDiagnostics) { + if(isDiagnostics) { + if(enableReporting) { + message->setCommand(ENABLE_PERIODIC_DIAGNOSTICS_GENERATION); + } + else { + message->setCommand(DISABLE_PERIODIC_DIAGNOSTICS_GENERATION); + } + } + else { + if(enableReporting) { + message->setCommand(ENABLE_PERIODIC_HK_GENERATION); + } + else { + message->setCommand(DISABLE_PERIODIC_HK_REPORT_GENERATION); + } + } + + setSid(message, sid); +} + + sid_t HousekeepingMessage::getSid(const CommandMessage* message) { sid_t sid; std::memcpy(&sid.raw, message->getData(), sizeof(sid.raw)); @@ -36,4 +59,3 @@ sid_t HousekeepingMessage::getSid(const CommandMessage* message) { void HousekeepingMessage::setSid(CommandMessage *message, sid_t sid) { std::memcpy(message->getData(), &sid.raw, sizeof(sid.raw)); } - diff --git a/housekeeping/HousekeepingMessage.h b/housekeeping/HousekeepingMessage.h index 75b31505..ab8fd7ac 100644 --- a/housekeeping/HousekeepingMessage.h +++ b/housekeeping/HousekeepingMessage.h @@ -58,15 +58,6 @@ public: static constexpr uint8_t MESSAGE_ID = messagetypes::HOUSEKEEPING; - static constexpr Command_t ADD_HK_REPORT_STRUCT = - MAKE_COMMAND_ID(1); - static constexpr Command_t ADD_DIAGNOSTICS_REPORT_STRUCT = - MAKE_COMMAND_ID(2); - - static constexpr Command_t DELETE_HK_REPORT_STRUCT = MAKE_COMMAND_ID(3); - static constexpr Command_t DELETE_DIAGNOSTICS_REPORT_STRUCT = - MAKE_COMMAND_ID(4); - static constexpr Command_t ENABLE_PERIODIC_HK_GENERATION = MAKE_COMMAND_ID(5); static constexpr Command_t DISABLE_PERIODIC_HK_REPORT_GENERATION = @@ -77,6 +68,11 @@ public: static constexpr Command_t DISABLE_PERIODIC_DIAGNOSTICS_GENERATION = MAKE_COMMAND_ID(8); + static constexpr Command_t REPORTING_TOGGLE_SUCCESS = + MAKE_COMMAND_ID(128); + static constexpr Command_t REPORTING_TOGGLE_FAILURE = + MAKE_COMMAND_ID(129); + static constexpr Command_t REPORT_HK_REPORT_STRUCTURES = MAKE_COMMAND_ID(9); static constexpr Command_t REPORT_DIAGNOSTICS_REPORT_STRUCTURES = MAKE_COMMAND_ID(11); @@ -104,6 +100,8 @@ public: static sid_t getSid(const CommandMessage* message); + static void setToggleReportingMessage(CommandMessage* message, sid_t sid, + bool enableReporting, bool isDiagnostics); static void setHkReportMessage(CommandMessage* message, sid_t sid, store_address_t storeId); static void setHkDiagnosticsMessage(CommandMessage* message, sid_t sid, From 2d2316a0c7824defdd1f079f7fd5d23c29f5d27c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 14 Sep 2020 18:01:48 +0200 Subject: [PATCH 057/192] hk message continued --- datapoollocal/LocalDataPoolManager.cpp | 4 +- housekeeping/HousekeepingMessage.cpp | 54 ++++++++++++++++++++++++-- housekeeping/HousekeepingMessage.h | 53 ++++++++++++++----------- 3 files changed, 83 insertions(+), 28 deletions(-) diff --git a/datapoollocal/LocalDataPoolManager.cpp b/datapoollocal/LocalDataPoolManager.cpp index c97bbfd2..619d8365 100644 --- a/datapoollocal/LocalDataPoolManager.cpp +++ b/datapoollocal/LocalDataPoolManager.cpp @@ -193,10 +193,10 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid, // and now we set a HK message and send it the HK packet destination. CommandMessage hkMessage; if(isDiagnostics) { - HousekeepingMessage::setHkDiagnosticsMessage(&hkMessage, sid, storeId); + HousekeepingMessage::setHkDiagnosticsReply(&hkMessage, sid, storeId); } else { - HousekeepingMessage::setHkReportMessage(&hkMessage, sid, storeId); + HousekeepingMessage::setHkReportReply(&hkMessage, sid, storeId); } if(hkQueue == nullptr) { diff --git a/housekeeping/HousekeepingMessage.cpp b/housekeeping/HousekeepingMessage.cpp index f96f4d34..65ba8c94 100644 --- a/housekeeping/HousekeepingMessage.cpp +++ b/housekeeping/HousekeepingMessage.cpp @@ -3,7 +3,7 @@ HousekeepingMessage::~HousekeepingMessage() {} -void HousekeepingMessage::setHkReportMessage(CommandMessage* message, sid_t sid, +void HousekeepingMessage::setHkReportReply(CommandMessage* message, sid_t sid, store_address_t storeId) { message->setCommand(HK_REPORT); message->setMessageSize(HK_MESSAGE_SIZE); @@ -11,7 +11,7 @@ void HousekeepingMessage::setHkReportMessage(CommandMessage* message, sid_t sid, message->setParameter3(storeId.raw); } -void HousekeepingMessage::setHkDiagnosticsMessage(CommandMessage* message, +void HousekeepingMessage::setHkDiagnosticsReply(CommandMessage* message, sid_t sid, store_address_t storeId) { message->setCommand(DIAGNOSTICS_REPORT); message->setMessageSize(HK_MESSAGE_SIZE); @@ -19,7 +19,7 @@ void HousekeepingMessage::setHkDiagnosticsMessage(CommandMessage* message, message->setParameter3(storeId.raw); } -sid_t HousekeepingMessage::getHkReportMessage(const CommandMessage *message, +sid_t HousekeepingMessage::getHkDataReply(const CommandMessage *message, store_address_t *storeIdToSet) { if(storeIdToSet != nullptr) { *storeIdToSet = message->getParameter3(); @@ -27,7 +27,7 @@ sid_t HousekeepingMessage::getHkReportMessage(const CommandMessage *message, return getSid(message); } -void HousekeepingMessage::setToggleReportingMessage(CommandMessage *message, +void HousekeepingMessage::setToggleReportingCommand(CommandMessage *message, sid_t sid, bool enableReporting, bool isDiagnostics) { if(isDiagnostics) { if(enableReporting) { @@ -49,6 +49,52 @@ void HousekeepingMessage::setToggleReportingMessage(CommandMessage *message, setSid(message, sid); } +void HousekeepingMessage::setStructureReportingCommand(CommandMessage *command, + sid_t sid, bool isDiagnostics) { + if(isDiagnostics) { + command->setCommand(REPORT_DIAGNOSTICS_REPORT_STRUCTURES); + } + else { + command->setCommand(REPORT_HK_REPORT_STRUCTURES); + } + + setSid(command, sid); +} + +void HousekeepingMessage::setOneShotReportCommand(CommandMessage *command, + sid_t sid, bool isDiagnostics) { + if(isDiagnostics) { + command->setCommand(GENERATE_ONE_DIAGNOSTICS_REPORT); + } + else { + command->setCommand(GENERATE_ONE_PARAMETER_REPORT); + } + + setSid(command, sid); +} + +void HousekeepingMessage::setCollectionIntervalModificationCommand( + CommandMessage *command, sid_t sid, float collectionInterval, + bool isDiagnostics) { + if(isDiagnostics) { + command->setCommand(MODIFY_DIAGNOSTICS_REPORT_COLLECTION_INTERVAL); + } + else { + command->setCommand(MODIFY_PARAMETER_REPORT_COLLECTION_INTERVAL); + } + command->setParameter3(collectionInterval); + + setSid(command, sid); +} + +sid_t HousekeepingMessage::getCollectionIntervalModificationCommand( + const CommandMessage* command, float* newCollectionInterval) { + if(newCollectionInterval != nullptr) { + *newCollectionInterval = command->getParameter3(); + } + + return getSid(command); +} sid_t HousekeepingMessage::getSid(const CommandMessage* message) { sid_t sid; diff --git a/housekeeping/HousekeepingMessage.h b/housekeeping/HousekeepingMessage.h index ab8fd7ac..81fa2f02 100644 --- a/housekeeping/HousekeepingMessage.h +++ b/housekeeping/HousekeepingMessage.h @@ -1,5 +1,5 @@ -#ifndef FRAMEWORK_HK_HOUSEKEEPINGMESSAGE_H_ -#define FRAMEWORK_HK_HOUSEKEEPINGMESSAGE_H_ +#ifndef FSFW_HOUSEKEEPING_HOUSEKEEPINGMESSAGE_H_ +#define FSFW_HOUSEKEEPING_HOUSEKEEPINGMESSAGE_H_ #include "../ipc/CommandMessage.h" #include "../ipc/FwMessageTypes.h" @@ -49,9 +49,8 @@ public: sizeof(sid_t) + sizeof(uint32_t); /** - * The HK message is initialized with a pointer to a message which holds - * the message data, see CommandMessageIF and getInternalMessage(). - * @param message + * Concrete instance is not used, instead this class operates on + * command message instances. */ HousekeepingMessage() = delete; virtual ~HousekeepingMessage(); @@ -68,11 +67,6 @@ public: static constexpr Command_t DISABLE_PERIODIC_DIAGNOSTICS_GENERATION = MAKE_COMMAND_ID(8); - static constexpr Command_t REPORTING_TOGGLE_SUCCESS = - MAKE_COMMAND_ID(128); - static constexpr Command_t REPORTING_TOGGLE_FAILURE = - MAKE_COMMAND_ID(129); - static constexpr Command_t REPORT_HK_REPORT_STRUCTURES = MAKE_COMMAND_ID(9); static constexpr Command_t REPORT_DIAGNOSTICS_REPORT_STRUCTURES = MAKE_COMMAND_ID(11); @@ -88,33 +82,48 @@ public: static constexpr Command_t GENERATE_ONE_DIAGNOSTICS_REPORT = MAKE_COMMAND_ID(28); - static constexpr Command_t APPEND_PARAMETERS_TO_PARAMETER_REPORT_STRUCTURE = - MAKE_COMMAND_ID(29); - static constexpr Command_t APPEND_PARAMETERS_TO_DIAGNOSTICS_REPORT_STRUCTURE = - MAKE_COMMAND_ID(30); - static constexpr Command_t MODIFY_PARAMETER_REPORT_COLLECTION_INTERVAL = MAKE_COMMAND_ID(31); static constexpr Command_t MODIFY_DIAGNOSTICS_REPORT_COLLECTION_INTERVAL = MAKE_COMMAND_ID(32); + static constexpr Command_t HK_REQUEST_SUCCESS = + MAKE_COMMAND_ID(128); + static constexpr Command_t HK_REQUEST_FAILURE = + MAKE_COMMAND_ID(129); + static sid_t getSid(const CommandMessage* message); - static void setToggleReportingMessage(CommandMessage* message, sid_t sid, + static void setToggleReportingCommand(CommandMessage* command, sid_t sid, bool enableReporting, bool isDiagnostics); - static void setHkReportMessage(CommandMessage* message, sid_t sid, + static void setStructureReportingCommand(CommandMessage* command, sid_t sid, + bool isDiagnostics); + static void setOneShotReportCommand(CommandMessage* command, sid_t sid, + bool isDiagnostics); + static void setCollectionIntervalModificationCommand( + CommandMessage* command, sid_t sid, float collectionInterval, + bool isDiagnostics); + + static void setHkReportReply(CommandMessage* reply, sid_t sid, store_address_t storeId); - static void setHkDiagnosticsMessage(CommandMessage* message, sid_t sid, + static void setHkDiagnosticsReply(CommandMessage* reply, sid_t sid, store_address_t storeId); - //! Get the respective SID and store ID. Command ID can be used beforehand - //! to distinguish between diagnostics and regular HK packets - static sid_t getHkReportMessage(const CommandMessage* message, + /** + * @brief Generic getter function for housekeeping data replies + * @details + * Command ID can be used beforehand to distinguish between diagnostics and + * regular HK packets. This getter function should be used for the + * command IDs 10, 12, 25 and 26. + */ + static sid_t getHkDataReply(const CommandMessage* message, store_address_t * storeIdToSet); + static sid_t getCollectionIntervalModificationCommand( + const CommandMessage* command, float* newCollectionInterval); private: static void setSid(CommandMessage* message, sid_t sid); }; -#endif /* FRAMEWORK_HK_HOUSEKEEPINGMESSAGE_H_ */ +#endif /* FSFW_HOUSEKEEPING_HOUSEKEEPINGMESSAGE_H_ */ From e8de2fc47a1f1c6451ec5a7a6ec3767377289de7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 14 Sep 2020 18:29:19 +0200 Subject: [PATCH 058/192] added srv3 --- events/fwSubsystemIdRanges.h | 1 + pus/Service17Test.h | 6 +- pus/Service3Housekeeping.cpp | 262 +++++++++++++++++++++++++++ pus/Service3Housekeeping.h | 101 +++++++++++ pus/servicepackets/Service3Packets.h | 21 +++ 5 files changed, 388 insertions(+), 3 deletions(-) create mode 100644 pus/Service3Housekeeping.cpp create mode 100644 pus/Service3Housekeeping.h create mode 100644 pus/servicepackets/Service3Packets.h diff --git a/events/fwSubsystemIdRanges.h b/events/fwSubsystemIdRanges.h index a05652c2..3c57c160 100644 --- a/events/fwSubsystemIdRanges.h +++ b/events/fwSubsystemIdRanges.h @@ -19,6 +19,7 @@ enum { SYSTEM_MANAGER_1 = 75, SYSTEM_1 = 79, PUS_SERVICE_1 = 80, + PUS_SERVICE_17 = 83, FW_SUBSYSTEM_ID_RANGE }; } diff --git a/pus/Service17Test.h b/pus/Service17Test.h index 8d6a4377..e2681865 100644 --- a/pus/Service17Test.h +++ b/pus/Service17Test.h @@ -1,5 +1,5 @@ -#ifndef MISSION_PUS_SERVICE17TEST_H_ -#define MISSION_PUS_SERVICE17TEST_H_ +#ifndef FSFW_PUS_SERVICE17TEST_H_ +#define FSFW_PUS_SERVICE17TEST_H_ #include "../tmtcservices/PusServiceBase.h" #include "../objectmanager/SystemObject.h" @@ -41,4 +41,4 @@ protected: uint16_t packetSubCounter = 0; }; -#endif /* MISSION_PUS_SERVICE17TEST_H_ */ +#endif /* FSFW_PUS_SERVICE17TEST_H_ */ diff --git a/pus/Service3Housekeeping.cpp b/pus/Service3Housekeeping.cpp new file mode 100644 index 00000000..db77328a --- /dev/null +++ b/pus/Service3Housekeeping.cpp @@ -0,0 +1,262 @@ +#include "Service3Housekeeping.h" +#include "servicepackets/Service3Packets.h" +#include "../datapoollocal/HasLocalDataPoolIF.h" + + +Service3Housekeeping::Service3Housekeeping(object_id_t objectId, uint16_t apid, + uint8_t serviceId): + CommandingServiceBase(objectId, apid, serviceId, + NUM_OF_PARALLEL_COMMANDS, COMMAND_TIMEOUT_SECONDS) {} + +Service3Housekeeping::~Service3Housekeeping() {} + +ReturnValue_t Service3Housekeeping::isValidSubservice(uint8_t subservice) { + switch(static_cast(subservice)) { + case Subservice::ENABLE_PERIODIC_HK_REPORT_GENERATION: + case Subservice::DISABLE_PERIODIC_HK_REPORT_GENERATION: + case Subservice::ENABLE_PERIODIC_DIAGNOSTICS_REPORT_GENERATION: + case Subservice::DISABLE_PERIODIC_DIAGNOSTICS_REPORT_GENERATION: + case Subservice::REPORT_HK_REPORT_STRUCTURES: + case Subservice::REPORT_DIAGNOSTICS_REPORT_STRUCTURES : + case Subservice::GENERATE_ONE_PARAMETER_REPORT: + case Subservice::GENERATE_ONE_DIAGNOSTICS_REPORT: + case Subservice::MODIFY_PARAMETER_REPORT_COLLECTION_INTERVAL: + case Subservice::MODIFY_DIAGNOSTICS_REPORT_COLLECTION_INTERVAL: + return HasReturnvaluesIF::RETURN_OK; + // Telemetry or invalid subservice. + case Subservice::HK_DEFINITIONS_REPORT: + case Subservice::DIAGNOSTICS_DEFINITION_REPORT: + case Subservice::HK_REPORT: + case Subservice::DIAGNOSTICS_REPORT: + default: + return AcceptsTelecommandsIF::INVALID_SUBSERVICE; + } +} + +ReturnValue_t Service3Housekeeping::getMessageQueueAndObject(uint8_t subservice, + const uint8_t *tcData, size_t tcDataLen, + MessageQueueId_t *id, object_id_t *objectId) { + return HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = checkAndAcquireTargetID(objectId,tcData,tcDataLen); + if(result != RETURN_OK) { + return result; + } + return checkInterfaceAndAcquireMessageQueue(id,objectId); +} + +ReturnValue_t Service3Housekeeping::checkAndAcquireTargetID( + object_id_t* objectIdToSet, const uint8_t* tcData, size_t tcDataLen) { + if(SerializeAdapter::deSerialize(objectIdToSet, &tcData, &tcDataLen, + SerializeIF::Endianness::BIG) != HasReturnvaluesIF::RETURN_OK) { + return CommandingServiceBase::INVALID_TC; + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t Service3Housekeeping::checkInterfaceAndAcquireMessageQueue( + MessageQueueId_t* messageQueueToSet, object_id_t* objectId) { + // check OwnsLocalDataPoolIF property of target + HasLocalDataPoolIF* possibleTarget = + objectManager->get(*objectId); + if(possibleTarget == nullptr){ + return CommandingServiceBase::INVALID_OBJECT; + } + *messageQueueToSet = possibleTarget->getCommandQueue(); + return HasReturnvaluesIF::RETURN_OK; +} + + +ReturnValue_t Service3Housekeeping::prepareCommand(CommandMessage* message, + uint8_t subservice, const uint8_t *tcData, size_t tcDataLen, + uint32_t *state, object_id_t objectId) { + switch(static_cast(subservice)) { + case Subservice::ENABLE_PERIODIC_HK_REPORT_GENERATION: + return prepareReportingTogglingCommand(message, true, false, + tcData, tcDataLen); + case Subservice::DISABLE_PERIODIC_HK_REPORT_GENERATION: + return prepareReportingTogglingCommand(message, false, false, + tcData, tcDataLen); + case Subservice::ENABLE_PERIODIC_DIAGNOSTICS_REPORT_GENERATION: + return prepareReportingTogglingCommand(message, true, true, + tcData, tcDataLen); + case Subservice::DISABLE_PERIODIC_DIAGNOSTICS_REPORT_GENERATION: + return prepareReportingTogglingCommand(message, false, true, + tcData, tcDataLen); + case Subservice::REPORT_HK_REPORT_STRUCTURES: + return prepareStructureReportingCommand(message, false, tcData, + tcDataLen); + case Subservice::REPORT_DIAGNOSTICS_REPORT_STRUCTURES: + return prepareStructureReportingCommand(message, true, tcData, + tcDataLen); + case Subservice::GENERATE_ONE_PARAMETER_REPORT: + return prepareOneShotReportCommand(message, false, tcData, tcDataLen); + case Subservice::GENERATE_ONE_DIAGNOSTICS_REPORT: + return prepareOneShotReportCommand(message, true, tcData, tcDataLen); + case Subservice::MODIFY_PARAMETER_REPORT_COLLECTION_INTERVAL: + return prepareCollectionIntervalModificationCommand(message, false, + tcData, tcDataLen); + case Subservice::MODIFY_DIAGNOSTICS_REPORT_COLLECTION_INTERVAL: + return prepareCollectionIntervalModificationCommand(message, true, + tcData, tcDataLen); + case Subservice::HK_DEFINITIONS_REPORT: + case Subservice::DIAGNOSTICS_DEFINITION_REPORT: + case Subservice::HK_REPORT: + case Subservice::DIAGNOSTICS_REPORT: + // Those are telemetry packets. + return CommandingServiceBase::INVALID_TC; + default: + // should never happen, subservice was already checked. + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t Service3Housekeeping::handleReply(const CommandMessage* reply, + Command_t previousCommand, uint32_t *state, + CommandMessage* optionalNextCommand, object_id_t objectId, + bool *isStep) { + switch(reply->getCommand()) { + case(HousekeepingMessage::HK_REQUEST_SUCCESS): { + return CommandingServiceBase::EXECUTION_COMPLETE; + } + case(HousekeepingMessage::HK_REQUEST_FAILURE): { + failureParameter1 = objectId; + // also provide failure reason (returnvalue) + // will be most commonly invalid SID or the set already has the desired + // reporting status. + return CommandingServiceBase::EXECUTION_COMPLETE; + } + default: + sif::error << "Service3Housekeeping::handleReply: Invalid reply!" + << std::endl; + return CommandingServiceBase::INVALID_REPLY; + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t Service3Housekeeping::prepareReportingTogglingCommand( + CommandMessage *command, bool enableReporting, bool isDiagnostics, + const uint8_t* tcData, size_t tcDataLen) { + if(tcDataLen < sizeof(sid_t)) { + // It is assumed the full SID is sent for now (even if that means + // 4 bytes are redundant) + return CommandingServiceBase::INVALID_TC; + } + + sid_t targetSid; + SerializeAdapter::deSerialize(&targetSid.objectId, &tcData, &tcDataLen, + SerializeIF::Endianness::BIG); + SerializeAdapter::deSerialize(&targetSid.ownerSetId, &tcData, &tcDataLen, + SerializeIF::Endianness::BIG); + + HousekeepingMessage::setToggleReportingCommand(command, targetSid, + enableReporting, isDiagnostics); + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t Service3Housekeeping::prepareStructureReportingCommand( + CommandMessage *command, bool isDiagnostics, const uint8_t* tcData, + size_t tcDataLen) { + if(tcDataLen < sizeof(sid_t)) { + // It is assumed the full SID is sent for now (even if that means + // 4 bytes are redundant) + return CommandingServiceBase::INVALID_TC; + } + + sid_t targetSid; + SerializeAdapter::deSerialize(&targetSid.objectId, &tcData, &tcDataLen, + SerializeIF::Endianness::BIG); + SerializeAdapter::deSerialize(&targetSid.ownerSetId, &tcData, &tcDataLen, + SerializeIF::Endianness::BIG); + + HousekeepingMessage::setStructureReportingCommand(command, targetSid, + isDiagnostics); + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t Service3Housekeeping::prepareOneShotReportCommand( + CommandMessage *command, bool isDiagnostics, const uint8_t *tcData, + size_t tcDataLen) { + if(tcDataLen < sizeof(sid_t)) { + // It is assumed the full SID is sent for now (even if that means + // 4 bytes are redundant) + return CommandingServiceBase::INVALID_TC; + } + + sid_t targetSid; + SerializeAdapter::deSerialize(&targetSid.objectId, &tcData, &tcDataLen, + SerializeIF::Endianness::BIG); + SerializeAdapter::deSerialize(&targetSid.ownerSetId, &tcData, &tcDataLen, + SerializeIF::Endianness::BIG); + HousekeepingMessage::setOneShotReportCommand(command, targetSid, + isDiagnostics); + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t Service3Housekeeping::prepareCollectionIntervalModificationCommand( + CommandMessage *command, bool isDiagnostics, const uint8_t *tcData, + size_t tcDataLen) { + if(tcDataLen < sizeof(sid_t) + sizeof(float)) { + // It is assumed the full SID and the new collection interval as a float + // is sent for now (even if that means 4 bytes are redundant) + return CommandingServiceBase::INVALID_TC; + } + + sid_t targetSid; + float newCollectionInterval = 0; + SerializeAdapter::deSerialize(&targetSid.objectId, &tcData, &tcDataLen, + SerializeIF::Endianness::BIG); + SerializeAdapter::deSerialize(&targetSid.ownerSetId, &tcData, &tcDataLen, + SerializeIF::Endianness::BIG); + SerializeAdapter::deSerialize(&newCollectionInterval, &tcData, &tcDataLen, + SerializeIF::Endianness::BIG); + HousekeepingMessage::setCollectionIntervalModificationCommand(command, + targetSid, newCollectionInterval, isDiagnostics); + return HasReturnvaluesIF::RETURN_OK; +} + +void Service3Housekeeping::handleUnrequestedReply( + CommandMessage* reply) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + switch(reply->getCommand()) { + case(HousekeepingMessage::DIAGNOSTICS_REPORT): { + result = generateHkReport(reply, + static_cast(Subservice::DIAGNOSTICS_REPORT)); + break; + } + case(HousekeepingMessage::HK_REPORT): { + result = generateHkReport(reply, + static_cast(Subservice::HK_REPORT)); + break; + } + default: { + sif::error << "Service3Housekeeping::handleUnrequestedReply: " + << "Invalid reply!" << std::endl; + } + } + + if(result != HasReturnvaluesIF::RETURN_OK) { + // Configuration error + sif::debug << "Service3Housekeeping::handleUnrequestedReply:" + << "Could not generate reply!" << std::endl; + } +} + +MessageQueueId_t Service3Housekeeping::getHkQueue() const { + return commandQueue->getId(); +} + +ReturnValue_t Service3Housekeeping::generateHkReport( + const CommandMessage* hkMessage, uint8_t subserviceId) { + store_address_t storeId; + + sid_t sid = HousekeepingMessage::getHkDataReply(hkMessage, &storeId); + auto resultPair = IPCStore->getData(storeId); + if(resultPair.first != HasReturnvaluesIF::RETURN_OK) { + return resultPair.first; + } + + HkPacket hkPacket(sid, resultPair.second.data(), resultPair.second.size()); + return sendTmPacket(static_cast(subserviceId), + hkPacket.hkData, hkPacket.hkSize, nullptr, 0); +} diff --git a/pus/Service3Housekeeping.h b/pus/Service3Housekeeping.h new file mode 100644 index 00000000..6c5d2469 --- /dev/null +++ b/pus/Service3Housekeeping.h @@ -0,0 +1,101 @@ +#ifndef FSFW_PUS_SERVICE3HOUSEKEEPINGSERVICE_H_ +#define FSFW_PUS_SERVICE3HOUSEKEEPINGSERVICE_H_ + +#include "../housekeeping/AcceptsHkPacketsIF.h" +#include "../housekeeping/HousekeepingMessage.h" +#include "../tmtcservices/CommandingServiceBase.h" + +/** + * @brief Manges spacecraft housekeeping reports and + * sends pool variables (temperature, GPS data ...) to ground. + * + * @details Full Documentation: ECSS-E70-41A or ECSS-E-ST-70-41C. + * Implementation based on PUS-C + * + * The housekeeping service type provides means to control and adapt the + * spacecraft reporting plan according to the mission phases. + * The housekeeping service type provides the visibility of any + * on-board parameters assembled in housekeeping parameter report structures + * or diagnostic parameter report structures as required for the mission. + * The parameter report structures used by the housekeeping service can + * be predefined on-board or created when needed. + * + * @author R. Mueller + * @ingroup pus_services + */ +class Service3Housekeeping: public CommandingServiceBase, + public AcceptsHkPacketsIF { +public: + static constexpr uint8_t NUM_OF_PARALLEL_COMMANDS = 4; + static constexpr uint16_t COMMAND_TIMEOUT_SECONDS = 60; + + Service3Housekeeping(object_id_t objectId, uint16_t apid, uint8_t serviceId); + virtual~ Service3Housekeeping(); +protected: + /* CSB abstract functions implementation . See CSB documentation. */ + ReturnValue_t isValidSubservice(uint8_t subservice) override; + ReturnValue_t getMessageQueueAndObject(uint8_t subservice, + const uint8_t *tcData, size_t tcDataLen, MessageQueueId_t *id, + object_id_t *objectId) override; + ReturnValue_t prepareCommand(CommandMessage* message, + uint8_t subservice, const uint8_t *tcData, size_t tcDataLen, + uint32_t *state, object_id_t objectId) override; + ReturnValue_t handleReply(const CommandMessage* reply, + Command_t previousCommand, uint32_t *state, + CommandMessage* optionalNextCommand, object_id_t objectId, + bool *isStep) override; + + virtual MessageQueueId_t getHkQueue() const; +private: + enum class Subservice { + ENABLE_PERIODIC_HK_REPORT_GENERATION = 5, //!< [EXPORT] : [TC] + DISABLE_PERIODIC_HK_REPORT_GENERATION = 6, //!< [EXPORT] : [TC] + + ENABLE_PERIODIC_DIAGNOSTICS_REPORT_GENERATION = 7, //!< [EXPORT] : [TC] + DISABLE_PERIODIC_DIAGNOSTICS_REPORT_GENERATION = 8, //!< [EXPORT] : [TC] + + //! [EXPORT] : [TC] Report HK structure by supplying SID + REPORT_HK_REPORT_STRUCTURES = 9, + //! [EXPORT] : [TC] Report Diagnostics structure by supplying SID + REPORT_DIAGNOSTICS_REPORT_STRUCTURES = 11, + + //! [EXPORT] : [TM] Report corresponding to Subservice 9 TC + HK_DEFINITIONS_REPORT = 10, + //! [EXPORT] : [TM] Report corresponding to Subservice 11 TC + DIAGNOSTICS_DEFINITION_REPORT = 12, + + //! [EXPORT] : [TM] Core packet. Contains Housekeeping data + HK_REPORT = 25, + //! [EXPORT] : [TM] Core packet. Contains diagnostics data + DIAGNOSTICS_REPORT = 26, + + /* PUS-C */ + GENERATE_ONE_PARAMETER_REPORT = 27, //!< [EXPORT] : [TC] + GENERATE_ONE_DIAGNOSTICS_REPORT = 28, //!< [EXPORT] : [TC] + + MODIFY_PARAMETER_REPORT_COLLECTION_INTERVAL = 31, //!< [EXPORT] : [TC] + MODIFY_DIAGNOSTICS_REPORT_COLLECTION_INTERVAL = 32, //!< [EXPORT] : [TC] + }; + + ReturnValue_t checkAndAcquireTargetID(object_id_t* objectIdToSet, + const uint8_t* tcData, size_t tcDataLen); + ReturnValue_t checkInterfaceAndAcquireMessageQueue( + MessageQueueId_t* messageQueueToSet, object_id_t* objectId); + + ReturnValue_t generateHkReport(const CommandMessage* hkMessage, + uint8_t subserviceId); + ReturnValue_t prepareReportingTogglingCommand(CommandMessage* command, + bool enableReporting, bool isDiagnostics, const uint8_t* tcData, + size_t tcDataLen); + ReturnValue_t prepareStructureReportingCommand(CommandMessage* command, + bool isDiagnostics, const uint8_t* tcData, size_t tcDataLen); + ReturnValue_t prepareOneShotReportCommand(CommandMessage* command, + bool isDiagnostics, const uint8_t* tcData, size_t tcDataLen); + ReturnValue_t prepareCollectionIntervalModificationCommand( + CommandMessage* command, bool isDiagnostics, const uint8_t* tcData, + size_t tcDataLen); + + void handleUnrequestedReply(CommandMessage* reply) override; +}; + +#endif /* FSFW_PUS_SERVICE3HOUSEKEEPINGSERVICE_H_ */ diff --git a/pus/servicepackets/Service3Packets.h b/pus/servicepackets/Service3Packets.h new file mode 100644 index 00000000..05732e11 --- /dev/null +++ b/pus/servicepackets/Service3Packets.h @@ -0,0 +1,21 @@ +#ifndef FSFW_PUS_SERVICEPACKETS_SERVICE3PACKETS_H_ +#define FSFW_PUS_SERVICEPACKETS_SERVICE3PACKETS_H_ + +#include +#include + +/** + * @brief Subservices 25 and 26: TM packets + * @ingroup spacepackets + */ +class HkPacket { //!< [EXPORT] : [SUBSERVICE] 25, 26 +public: + sid_t sid; //!< [EXPORT] : [COMMENT] Structure ID (SID) of housekeeping data. + const uint8_t* hkData; //!< [EXPORT] : [MAXSIZE] Deduced size + size_t hkSize; //!< [EXPORT] : [IGNORE] + + HkPacket(sid_t sid, const uint8_t* data, size_t size): + sid(sid), hkData(data), hkSize(size) {} +}; + +#endif /* FSFW_PUS_SERVICEPACKETS_SERVICE3PACKETS_H_ */ From e707c5e05117b9734f50f4a144987ec51b4dfb65 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 15 Sep 2020 15:58:12 +0200 Subject: [PATCH 059/192] fixes taken over --- ipc/CommandMessage.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ipc/CommandMessage.h b/ipc/CommandMessage.h index ca7b817f..8f5daa04 100644 --- a/ipc/CommandMessage.h +++ b/ipc/CommandMessage.h @@ -8,7 +8,7 @@ /** * @brief Default command message used to pass command messages between tasks. * Primary message type for IPC. Contains sender, 2-byte command ID - * field, and 2 4-byte parameters. + * field, and 3 4-byte parameter * @details * It operates on an external memory which is contained inside a * class implementing MessageQueueMessageIF by taking its address. @@ -23,10 +23,11 @@ class CommandMessage: public MessageQueueMessage, public CommandMessageIF { public: /** - * Default size can accomodate 2 4-byte parameters. + * Default size can accomodate 3 4-byte parameters. */ static constexpr size_t DEFAULT_COMMAND_MESSAGE_SIZE = - CommandMessageIF::MINIMUM_COMMAND_MESSAGE_SIZE + sizeof(uint32_t); + CommandMessageIF::MINIMUM_COMMAND_MESSAGE_SIZE + + 3 * sizeof(uint32_t); /** * @brief Default Constructor, does not initialize anything. From ad98a63e87602790de874b7fa336a2d04d012a1a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 15 Sep 2020 16:02:58 +0200 Subject: [PATCH 060/192] changes taken over from upstream master --- serialize/SerializeIF.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/serialize/SerializeIF.h b/serialize/SerializeIF.h index a701fe53..d72218f0 100644 --- a/serialize/SerializeIF.h +++ b/serialize/SerializeIF.h @@ -2,7 +2,7 @@ #define FSFW_SERIALIZE_SERIALIZEIF_H_ #include "../returnvalues/HasReturnvaluesIF.h" -#include +#include /** * @defgroup serialize Serialization @@ -10,7 +10,10 @@ */ /** - * Translation of objects into data streams and from data streams. + * @brief Translation of objects into data streams and from data streams. + * @details + * Also provides options to convert from/to data with different endianness. + * variables. * @ingroup serialize */ class SerializeIF { From 15891b3cf08b585a9e177447d0d15a5ba7490705 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 15 Sep 2020 16:42:17 +0200 Subject: [PATCH 061/192] fixed some message queue includes --- action/ActionHelper.cpp | 1 + action/SimpleActionHelper.cpp | 1 + devicehandlers/CommunicationMessage.cpp | 4 ++-- health/HealthHelper.cpp | 4 ++-- ipc/MessageQueueIF.h | 14 ++++++++------ ipc/MessageQueueMessage.h | 1 - ipc/MessageQueueMessageIF.h | 17 +++-------------- ipc/MessageQueueSenderIF.h | 3 ++- ipc/QueueFactory.h | 2 ++ ipc/messageQueueDefintions.h | 18 ++++++++++++++++++ modes/ModeHelper.cpp | 9 +++++---- osal/FreeRTOS/MessageQueue.cpp | 8 ++++---- osal/FreeRTOS/MessageQueue.h | 5 +++-- osal/FreeRTOS/QueueFactory.cpp | 1 + 14 files changed, 52 insertions(+), 36 deletions(-) create mode 100644 ipc/messageQueueDefintions.h diff --git a/action/ActionHelper.cpp b/action/ActionHelper.cpp index b43c676d..70c3f0fc 100644 --- a/action/ActionHelper.cpp +++ b/action/ActionHelper.cpp @@ -1,3 +1,4 @@ +#include #include "ActionHelper.h" #include "HasActionsIF.h" #include "../objectmanager/ObjectManagerIF.h" diff --git a/action/SimpleActionHelper.cpp b/action/SimpleActionHelper.cpp index d79a3c97..51e3fa1c 100644 --- a/action/SimpleActionHelper.cpp +++ b/action/SimpleActionHelper.cpp @@ -1,5 +1,6 @@ #include "HasActionsIF.h" #include "SimpleActionHelper.h" + SimpleActionHelper::SimpleActionHelper(HasActionsIF* setOwner, MessageQueueIF* useThisQueue) : ActionHelper(setOwner, useThisQueue), isExecuting(false), lastCommander( diff --git a/devicehandlers/CommunicationMessage.cpp b/devicehandlers/CommunicationMessage.cpp index abdfd3a8..57774270 100644 --- a/devicehandlers/CommunicationMessage.cpp +++ b/devicehandlers/CommunicationMessage.cpp @@ -122,7 +122,7 @@ uint32_t CommunicationMessage::getUint32Data() const{ } void CommunicationMessage::setDataByte(uint8_t byte, uint8_t position) { - if(0 <= position && position <= 3) { + if(position <= 3) { memcpy(getData() + 3 * sizeof(uint32_t) + position * sizeof(uint8_t), &byte, sizeof(byte)); } else { @@ -131,7 +131,7 @@ void CommunicationMessage::setDataByte(uint8_t byte, uint8_t position) { } uint8_t CommunicationMessage::getDataByte(uint8_t position) const { - if(0 <= position && position <= 3) { + if(position <= 3) { uint8_t byte; memcpy(&byte, getData() + 3 * sizeof(uint32_t) + position * sizeof(uint8_t), sizeof(byte)); return byte; diff --git a/health/HealthHelper.cpp b/health/HealthHelper.cpp index cced11d9..d574634d 100644 --- a/health/HealthHelper.cpp +++ b/health/HealthHelper.cpp @@ -71,7 +71,7 @@ void HealthHelper::setHealth(HasHealthIF::HealthState health) { void HealthHelper::informParent(HasHealthIF::HealthState health, HasHealthIF::HealthState oldHealth) { - if (parentQueue == MessageQueueMessageIF::NO_QUEUE) { + if (parentQueue == MessageQueueIF::NO_QUEUE) { return; } CommandMessage information; @@ -86,7 +86,7 @@ void HealthHelper::informParent(HasHealthIF::HealthState health, void HealthHelper::handleSetHealthCommand(CommandMessage* command) { ReturnValue_t result = owner->setHealth(HealthMessage::getHealth(command)); - if (command->getSender() == MessageQueueMessageIF::NO_QUEUE) { + if (command->getSender() == MessageQueueIF::NO_QUEUE) { return; } CommandMessage reply; diff --git a/ipc/MessageQueueIF.h b/ipc/MessageQueueIF.h index 96bd379f..e9a4a00b 100644 --- a/ipc/MessageQueueIF.h +++ b/ipc/MessageQueueIF.h @@ -1,21 +1,23 @@ #ifndef FSFW_IPC_MESSAGEQUEUEIF_H_ #define FSFW_IPC_MESSAGEQUEUEIF_H_ +#include "MessageQueueMessageIF.h" +#include "messageQueueDefintions.h" +#include "../returnvalues/HasReturnvaluesIF.h" + +#include + + // COULDDO: We could support blocking calls // semaphores are being implemented, which makes this idea even more iteresting. - /** * @defgroup message_queue Message Queue * @brief Message Queue related software components */ - -#include "../ipc/MessageQueueMessage.h" -#include "../ipc/MessageQueueSenderIF.h" -#include "../returnvalues/HasReturnvaluesIF.h" class MessageQueueIF { public: - static const MessageQueueId_t NO_QUEUE = MessageQueueMessageIF::NO_QUEUE; //!< Ugly hack. + static const MessageQueueId_t NO_QUEUE = 0; static const uint8_t INTERFACE_ID = CLASS_ID::MESSAGE_QUEUE_IF; //! No new messages on the queue diff --git a/ipc/MessageQueueMessage.h b/ipc/MessageQueueMessage.h index f68e9b9f..5234f64f 100644 --- a/ipc/MessageQueueMessage.h +++ b/ipc/MessageQueueMessage.h @@ -2,7 +2,6 @@ #define FSFW_IPC_MESSAGEQUEUEMESSAGE_H_ #include "../ipc/MessageQueueMessageIF.h" -#include "../ipc/MessageQueueSenderIF.h" #include /** diff --git a/ipc/MessageQueueMessageIF.h b/ipc/MessageQueueMessageIF.h index 91753ced..daf7e8bb 100644 --- a/ipc/MessageQueueMessageIF.h +++ b/ipc/MessageQueueMessageIF.h @@ -1,24 +1,13 @@ #ifndef FRAMEWORK_IPC_MESSAGEQUEUEMESSAGEIF_H_ #define FRAMEWORK_IPC_MESSAGEQUEUEMESSAGEIF_H_ + +#include "messageQueueDefintions.h" #include #include -/* - * TODO: Actually, the definition of this ID to be a uint32_t is not ideal and - * breaks layering. However, it is difficult to keep layering, as the ID is - * stored in many places and sent around in MessageQueueMessage. - * Ideally, one would use the (current) object_id_t only, however, doing a - * lookup of queueIDs for every call does not sound ideal. - * In a first step, I'll circumvent the issue by not touching it, - * maybe in a second step. This also influences Interface design - * (getCommandQueue) and some other issues.. - */ - -typedef uint32_t MessageQueueId_t; - class MessageQueueMessageIF { public: - static const MessageQueueId_t NO_QUEUE = -1; + /** * @brief This constants defines the size of the header, * which is added to every message. diff --git a/ipc/MessageQueueSenderIF.h b/ipc/MessageQueueSenderIF.h index b967bbdf..beb27f50 100644 --- a/ipc/MessageQueueSenderIF.h +++ b/ipc/MessageQueueSenderIF.h @@ -1,6 +1,7 @@ #ifndef FRAMEWORK_IPC_MESSAGEQUEUESENDERIF_H_ #define FRAMEWORK_IPC_MESSAGEQUEUESENDERIF_H_ +#include "../ipc/MessageQueueIF.h" #include "../ipc/MessageQueueMessageIF.h" #include "../objectmanager/ObjectManagerIF.h" @@ -15,7 +16,7 @@ public: */ static ReturnValue_t sendMessage(MessageQueueId_t sendTo, MessageQueueMessageIF* message, - MessageQueueId_t sentFrom = MessageQueueMessageIF::NO_QUEUE, + MessageQueueId_t sentFrom = MessageQueueIF::NO_QUEUE, bool ignoreFault = false); private: MessageQueueSenderIF() {} diff --git a/ipc/QueueFactory.h b/ipc/QueueFactory.h index be554406..5fbfdf2d 100644 --- a/ipc/QueueFactory.h +++ b/ipc/QueueFactory.h @@ -2,7 +2,9 @@ #define FRAMEWORK_IPC_QUEUEFACTORY_H_ #include "MessageQueueIF.h" +#include "MessageQueueMessage.h" #include + /** * Creates message queues. * This class is a "singleton" interface, i.e. it provides an diff --git a/ipc/messageQueueDefintions.h b/ipc/messageQueueDefintions.h new file mode 100644 index 00000000..3d625de1 --- /dev/null +++ b/ipc/messageQueueDefintions.h @@ -0,0 +1,18 @@ +#ifndef FSFW_IPC_MESSAGEQUEUEDEFINTIONS_H_ +#define FSFW_IPC_MESSAGEQUEUEDEFINTIONS_H_ + +#include + +/* + * TODO: Actually, the definition of this ID to be a uint32_t is not ideal and + * breaks layering. However, it is difficult to keep layering, as the ID is + * stored in many places and sent around in MessageQueueMessage. + * Ideally, one would use the (current) object_id_t only, however, doing a + * lookup of queueIDs for every call does not sound ideal. + * In a first step, I'll circumvent the issue by not touching it, + * maybe in a second step. This also influences Interface design + * (getCommandQueue) and some other issues.. + */ +using MessageQueueId_t = uint32_t; + +#endif /* FSFW_IPC_MESSAGEQUEUEDEFINTIONS_H_ */ diff --git a/modes/ModeHelper.cpp b/modes/ModeHelper.cpp index e7fc0bcb..68f009e7 100644 --- a/modes/ModeHelper.cpp +++ b/modes/ModeHelper.cpp @@ -1,3 +1,4 @@ +#include "../ipc/MessageQueueSenderIF.h" #include "../modes/HasModesIF.h" #include "../modes/ModeHelper.h" #include "../serviceinterface/ServiceInterfaceStream.h" @@ -35,7 +36,7 @@ ReturnValue_t ModeHelper::handleModeCommand(CommandMessage* command) { commandedMode = mode; commandedSubmode = submode; - if ((parentQueueId != MessageQueueMessageIF::NO_QUEUE) + if ((parentQueueId != MessageQueueIF::NO_QUEUE) && (theOneWhoCommandedAMode != parentQueueId)) { owner->setToExternalControl(); } @@ -73,13 +74,13 @@ void ModeHelper::modeChanged(Mode_t ownerMode, Submode_t ownerSubmode) { forced = false; sendModeReplyMessage(ownerMode, ownerSubmode); sendModeInfoMessage(ownerMode, ownerSubmode); - theOneWhoCommandedAMode = MessageQueueMessageIF::NO_QUEUE; + theOneWhoCommandedAMode = MessageQueueIF::NO_QUEUE; } void ModeHelper::sendModeReplyMessage(Mode_t ownerMode, Submode_t ownerSubmode) { CommandMessage reply; - if (theOneWhoCommandedAMode != MessageQueueMessageIF::NO_QUEUE) + if (theOneWhoCommandedAMode != MessageQueueIF::NO_QUEUE) { if (ownerMode != commandedMode or ownerSubmode != commandedSubmode) { @@ -101,7 +102,7 @@ void ModeHelper::sendModeInfoMessage(Mode_t ownerMode, Submode_t ownerSubmode) { CommandMessage reply; if (theOneWhoCommandedAMode != parentQueueId - and parentQueueId != MessageQueueMessageIF::NO_QUEUE) + and parentQueueId != MessageQueueIF::NO_QUEUE) { ModeMessage::setModeMessage(&reply, ModeMessage::REPLY_MODE_INFO, ownerMode, ownerSubmode); diff --git a/osal/FreeRTOS/MessageQueue.cpp b/osal/FreeRTOS/MessageQueue.cpp index e3e0ef1c..2dfe5ab6 100644 --- a/osal/FreeRTOS/MessageQueue.cpp +++ b/osal/FreeRTOS/MessageQueue.cpp @@ -1,5 +1,5 @@ #include "MessageQueue.h" - +#include "../../objectmanager/ObjectManagerIF.h" #include "../../serviceinterface/ServiceInterfaceStream.h" // TODO I guess we should have a way of checking if we are in an ISR and then @@ -40,7 +40,7 @@ ReturnValue_t MessageQueue::sendToDefaultFrom(MessageQueueMessageIF* message, } ReturnValue_t MessageQueue::reply(MessageQueueMessageIF* message) { - if (this->lastPartner != MessageQueueMessageIF::NO_QUEUE) { + if (this->lastPartner != MessageQueueIF::NO_QUEUE) { return sendMessageFrom(this->lastPartner, message, this->getId()); } else { return NO_REPLY_PARTNER; @@ -58,8 +58,8 @@ ReturnValue_t MessageQueue::sendMessageFrom(MessageQueueId_t sendTo, ReturnValue_t MessageQueue::handleSendResult(BaseType_t result, bool ignoreFault) { if (result != pdPASS) { if (not ignoreFault) { - InternalErrorReporterIF* internalErrorReporter = - objectManager->get( + InternalErrorReporterIF* internalErrorReporter = objectManager-> + get( objects::INTERNAL_ERROR_REPORTER); if (internalErrorReporter != nullptr) { internalErrorReporter->queueMessageNotSent(); diff --git a/osal/FreeRTOS/MessageQueue.h b/osal/FreeRTOS/MessageQueue.h index e953ec34..b99bf7c8 100644 --- a/osal/FreeRTOS/MessageQueue.h +++ b/osal/FreeRTOS/MessageQueue.h @@ -8,6 +8,7 @@ #include #include +#include // TODO: this class assumes that MessageQueueId_t is the same size as void* // (the FreeRTOS handle type), compiler will catch this but it might be nice @@ -139,8 +140,8 @@ protected: private: bool defaultDestinationSet = false; QueueHandle_t handle; - MessageQueueId_t defaultDestination = 0; - MessageQueueId_t lastPartner = 0; + MessageQueueId_t defaultDestination = MessageQueueIF::NO_QUEUE; + MessageQueueId_t lastPartner = MessageQueueIF::NO_QUEUE; const size_t maxMessageSize; //! Stores the current system context CallContext callContext = CallContext::TASK; diff --git a/osal/FreeRTOS/QueueFactory.cpp b/osal/FreeRTOS/QueueFactory.cpp index cd99afd9..5b3c73dc 100644 --- a/osal/FreeRTOS/QueueFactory.cpp +++ b/osal/FreeRTOS/QueueFactory.cpp @@ -1,3 +1,4 @@ +#include "../../ipc/MessageQueueSenderIF.h" #include "../../ipc/QueueFactory.h" #include "../../osal/FreeRTOS/MessageQueue.h" From 850a4a3e3deddf8a13a9ee52e53262a8e0c7fe41 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 15 Sep 2020 16:44:48 +0200 Subject: [PATCH 062/192] header file renamed --- ipc/MessageQueueIF.h | 2 +- ipc/MessageQueueMessageIF.h | 2 +- ipc/{messageQueueDefintions.h => messageQueueDefinitions.h} | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) rename ipc/{messageQueueDefintions.h => messageQueueDefinitions.h} (79%) diff --git a/ipc/MessageQueueIF.h b/ipc/MessageQueueIF.h index e9a4a00b..44b6f4c0 100644 --- a/ipc/MessageQueueIF.h +++ b/ipc/MessageQueueIF.h @@ -1,8 +1,8 @@ #ifndef FSFW_IPC_MESSAGEQUEUEIF_H_ #define FSFW_IPC_MESSAGEQUEUEIF_H_ +#include #include "MessageQueueMessageIF.h" -#include "messageQueueDefintions.h" #include "../returnvalues/HasReturnvaluesIF.h" #include diff --git a/ipc/MessageQueueMessageIF.h b/ipc/MessageQueueMessageIF.h index daf7e8bb..b5a30c08 100644 --- a/ipc/MessageQueueMessageIF.h +++ b/ipc/MessageQueueMessageIF.h @@ -1,7 +1,7 @@ #ifndef FRAMEWORK_IPC_MESSAGEQUEUEMESSAGEIF_H_ #define FRAMEWORK_IPC_MESSAGEQUEUEMESSAGEIF_H_ -#include "messageQueueDefintions.h" +#include #include #include diff --git a/ipc/messageQueueDefintions.h b/ipc/messageQueueDefinitions.h similarity index 79% rename from ipc/messageQueueDefintions.h rename to ipc/messageQueueDefinitions.h index 3d625de1..d30e6984 100644 --- a/ipc/messageQueueDefintions.h +++ b/ipc/messageQueueDefinitions.h @@ -1,5 +1,5 @@ -#ifndef FSFW_IPC_MESSAGEQUEUEDEFINTIONS_H_ -#define FSFW_IPC_MESSAGEQUEUEDEFINTIONS_H_ +#ifndef FSFW_IPC_MESSAGEQUEUEDEFINITIONS_H_ +#define FSFW_IPC_MESSAGEQUEUEDEFINITIONS_H_ #include @@ -15,4 +15,4 @@ */ using MessageQueueId_t = uint32_t; -#endif /* FSFW_IPC_MESSAGEQUEUEDEFINTIONS_H_ */ +#endif /* FSFW_IPC_MESSAGEQUEUEDEFINITIONS_H_ */ From b8ad17639ceb8b773175749608477d8ff970521c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 15 Sep 2020 17:02:31 +0200 Subject: [PATCH 063/192] include guard fix --- ipc/MessageQueueSenderIF.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ipc/MessageQueueSenderIF.h b/ipc/MessageQueueSenderIF.h index beb27f50..d8ede535 100644 --- a/ipc/MessageQueueSenderIF.h +++ b/ipc/MessageQueueSenderIF.h @@ -1,5 +1,5 @@ -#ifndef FRAMEWORK_IPC_MESSAGEQUEUESENDERIF_H_ -#define FRAMEWORK_IPC_MESSAGEQUEUESENDERIF_H_ +#ifndef FSFW_IPC_MESSAGEQUEUESENDERIF_H_ +#define FSFWw_IPC_MESSAGEQUEUESENDERIF_H_ #include "../ipc/MessageQueueIF.h" #include "../ipc/MessageQueueMessageIF.h" @@ -23,4 +23,4 @@ private: }; -#endif /* FRAMEWORK_IPC_MESSAGEQUEUESENDERIF_H_ */ +#endif /* FSFW_IPC_MESSAGEQUEUESENDERIF_H_ */ From 7643af8607ad9b1ccb27f9bd120a324869807134 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 15 Sep 2020 17:15:22 +0200 Subject: [PATCH 064/192] include guard fix --- ipc/MessageQueueSenderIF.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipc/MessageQueueSenderIF.h b/ipc/MessageQueueSenderIF.h index d8ede535..42d4078f 100644 --- a/ipc/MessageQueueSenderIF.h +++ b/ipc/MessageQueueSenderIF.h @@ -1,5 +1,5 @@ #ifndef FSFW_IPC_MESSAGEQUEUESENDERIF_H_ -#define FSFWw_IPC_MESSAGEQUEUESENDERIF_H_ +#define FSFW_IPC_MESSAGEQUEUESENDERIF_H_ #include "../ipc/MessageQueueIF.h" #include "../ipc/MessageQueueMessageIF.h" From 347d591deff649540ff9dbeee1115c2803c060c3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 15 Sep 2020 17:33:21 +0200 Subject: [PATCH 065/192] uses new define and config file now --- events/Event.h | 2 +- events/EventManager.cpp | 4 ++-- events/EventManager.h | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/events/Event.h b/events/Event.h index e22c9db1..f8410f32 100644 --- a/events/Event.h +++ b/events/Event.h @@ -4,7 +4,7 @@ #include #include "fwSubsystemIdRanges.h" //could be move to more suitable location -#include +#include typedef uint16_t EventId_t; typedef uint8_t EventSeverity_t; diff --git a/events/EventManager.cpp b/events/EventManager.cpp index e71951e3..0971dadc 100644 --- a/events/EventManager.cpp +++ b/events/EventManager.cpp @@ -109,13 +109,13 @@ ReturnValue_t EventManager::unsubscribeFromEventRange(MessageQueueId_t listener, return result; } -#ifdef DEBUG +#if FSFW_DEBUG_OUTPUT == 1 void EventManager::printEvent(EventMessage* message) { const char *string = 0; switch (message->getSeverity()) { case SEVERITY::INFO: -#ifdef DEBUG_INFO_EVENT +#if DEBUG_INFO_EVENT == 1 string = translateObject(message->getReporter()); sif::info << "EVENT: "; if (string != 0) { diff --git a/events/EventManager.h b/events/EventManager.h index 2602aeb2..f03c0241 100644 --- a/events/EventManager.h +++ b/events/EventManager.h @@ -8,9 +8,11 @@ #include "../tasks/ExecutableObjectIF.h" #include "../ipc/MessageQueueIF.h" #include "../ipc/MutexIF.h" +#include + #include -#ifdef DEBUG +#if FSFW_DEBUG_OUTPUT == 1 // forward declaration, should be implemented by mission extern const char* translateObject(object_id_t object); extern const char* translateEvents(Event event); @@ -55,7 +57,7 @@ protected: void notifyListeners(EventMessage *message); -#ifdef DEBUG +#if FSFW_DEBUG_OUTPUT == 1 void printEvent(EventMessage *message); #endif From 0d5724e3d416f837348b764cde3f7f732c2c5af6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 15 Sep 2020 17:34:07 +0200 Subject: [PATCH 066/192] include improvements taken over --- timemanager/CCSDSTime.cpp | 9 +++------ timemanager/CCSDSTime.h | 4 ++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/timemanager/CCSDSTime.cpp b/timemanager/CCSDSTime.cpp index 12ecf34a..f99f8fbb 100644 --- a/timemanager/CCSDSTime.cpp +++ b/timemanager/CCSDSTime.cpp @@ -1,11 +1,8 @@ #include "../timemanager/CCSDSTime.h" -#include -#include -#include +#include +#include +#include -#ifndef SCNu8 - #define SCNu8 "hhu" -#endif CCSDSTime::CCSDSTime() { } diff --git a/timemanager/CCSDSTime.h b/timemanager/CCSDSTime.h index b9efa49c..89fcff92 100644 --- a/timemanager/CCSDSTime.h +++ b/timemanager/CCSDSTime.h @@ -3,9 +3,9 @@ // COULDDO: have calls in Clock.h which return time quality and use timespec accordingly -#include "../timemanager/Clock.h" +#include "Clock.h" #include "../returnvalues/HasReturnvaluesIF.h" -#include +#include bool operator<(const timeval& lhs, const timeval& rhs); bool operator<=(const timeval& lhs, const timeval& rhs); From e5dac30e98f694ad92ea82cc8c15ff7bfc7bd8b2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 15 Sep 2020 17:37:43 +0200 Subject: [PATCH 067/192] new include used now --- timemanager/CCSDSTime.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/timemanager/CCSDSTime.cpp b/timemanager/CCSDSTime.cpp index f99f8fbb..80a4e27c 100644 --- a/timemanager/CCSDSTime.cpp +++ b/timemanager/CCSDSTime.cpp @@ -1,4 +1,5 @@ #include "../timemanager/CCSDSTime.h" +#include #include #include #include @@ -158,7 +159,7 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t* } // Newlib nano can't parse uint8, see SCNu8 documentation and https://sourceware.org/newlib/README // Suggestion: use uint16 all the time. This should work on all systems. -#ifdef NEWLIB_NANO_NO_C99_IO +#if FSFW_NEWLIB_NANO_NO_C99_IO == 1 uint16_t year; uint16_t month; uint16_t day; From 6ef5e3e5501e5d925160306f25e39c3e1cfbb312 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Wed, 16 Sep 2020 21:22:53 +0200 Subject: [PATCH 068/192] queue factory host OS fix --- osal/host/QueueFactory.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osal/host/QueueFactory.cpp b/osal/host/QueueFactory.cpp index da3fea55..7feb1ad6 100644 --- a/osal/host/QueueFactory.cpp +++ b/osal/host/QueueFactory.cpp @@ -1,5 +1,6 @@ +#include "MessageQueue.h" #include "../../ipc/QueueFactory.h" -#include "../../osal/host/MessageQueue.h" +#include "../../ipc/MessageQueueSenderIF.h" #include "../../serviceinterface/ServiceInterfaceStream.h" #include From 0c6514a682a03e4dc74e5b7878960b0af8bf34f3 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 17 Sep 2020 22:31:28 +0200 Subject: [PATCH 069/192] clock uses getUptime again --- osal/linux/Clock.cpp | 27 +++++++++------------------ timemanager/Stopwatch.cpp | 11 +++++++---- timemanager/Stopwatch.h | 2 +- 3 files changed, 17 insertions(+), 23 deletions(-) diff --git a/osal/linux/Clock.cpp b/osal/linux/Clock.cpp index 5f764a6f..b3b09923 100644 --- a/osal/linux/Clock.cpp +++ b/osal/linux/Clock.cpp @@ -75,24 +75,15 @@ timeval Clock::getUptime() { } ReturnValue_t Clock::getUptime(timeval* uptime) { - //TODO This is not posix compatible and delivers only seconds precision - struct sysinfo sysInfo; - int result = sysinfo(&sysInfo); - if(result != 0){ - return HasReturnvaluesIF::RETURN_FAILED; - } - uptime->tv_sec = sysInfo.uptime; - uptime->tv_usec = 0; - - - //Linux specific file read but more precise -// double uptimeSeconds; -// if(std::ifstream("/proc/uptime",std::ios::in) >> uptimeSeconds){ -// uptime->tv_sec = uptimeSeconds; -// uptime->tv_usec = uptimeSeconds *(double) 1e6 - (uptime->tv_sec *1e6); -// } - - return HasReturnvaluesIF::RETURN_OK; + //TODO This is not posix compatible and delivers only seconds precision + // is the OS not called Linux? + //Linux specific file read but more precise + double uptimeSeconds; + if(std::ifstream("/proc/uptime",std::ios::in) >> uptimeSeconds){ + uptime->tv_sec = uptimeSeconds; + uptime->tv_usec = uptimeSeconds *(double) 1e6 - (uptime->tv_sec *1e6); + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t Clock::getUptime(uint32_t* uptimeMs) { diff --git a/timemanager/Stopwatch.cpp b/timemanager/Stopwatch.cpp index 28ae4543..2cd31969 100644 --- a/timemanager/Stopwatch.cpp +++ b/timemanager/Stopwatch.cpp @@ -6,15 +6,18 @@ Stopwatch::Stopwatch(bool displayOnDestruction, StopwatchDisplayMode displayMode): displayOnDestruction( displayOnDestruction), displayMode(displayMode) { // Measures start time on initialization. - Clock::getClock_timeval(&startTime); + Clock::getUptime(&startTime); } void Stopwatch::start() { - Clock::getClock_timeval(&startTime); + Clock::getUptime(&startTime); } -dur_millis_t Stopwatch::stop() { +dur_millis_t Stopwatch::stop(bool display) { stopInternal(); + if(display) { + this->display(); + } return elapsedTime.tv_sec * 1000 + elapsedTime.tv_usec / 1000; } @@ -52,6 +55,6 @@ StopwatchDisplayMode Stopwatch::getDisplayMode() const { void Stopwatch::stopInternal() { timeval endTime; - Clock::getClock_timeval(&endTime); + Clock::getUptime(&endTime); elapsedTime = endTime - startTime; } diff --git a/timemanager/Stopwatch.h b/timemanager/Stopwatch.h index 49b686f9..093f5c9e 100644 --- a/timemanager/Stopwatch.h +++ b/timemanager/Stopwatch.h @@ -40,7 +40,7 @@ public: * Calculates the elapsed time since start and returns it * @return elapsed time in milliseconds (rounded) */ - dur_millis_t stop(); + dur_millis_t stop(bool display = false); /** * Calculates the elapsed time since start and returns it * @return elapsed time in seconds (double precision) From 37f4cc46447906295f11e9e368e32e010eedecad Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Fri, 18 Sep 2020 12:28:29 +0200 Subject: [PATCH 070/192] taken over stopwatch changes --- timemanager/Stopwatch.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/timemanager/Stopwatch.h b/timemanager/Stopwatch.h index 093f5c9e..ea72c66e 100644 --- a/timemanager/Stopwatch.h +++ b/timemanager/Stopwatch.h @@ -1,6 +1,7 @@ -#ifndef FRAMEWORK_TIMEMANAGER_STOPWATCH_H_ -#define FRAMEWORK_TIMEMANAGER_STOPWATCH_H_ -#include "../timemanager/Clock.h" +#ifndef FSFW_TIMEMANAGER_STOPWATCH_H_ +#define FSFW_TIMEMANAGER_STOPWATCH_H_ + +#include "Clock.h" enum class StopwatchDisplayMode { MILLIS, @@ -66,6 +67,4 @@ private: }; - - -#endif /* FRAMEWORK_TIMEMANAGER_STOPWATCH_H_ */ +#endif /* FSFW_TIMEMANAGER_STOPWATCH_H_ */ From e0b2e0b00a578f59ac692c57d1d3b2bc1ea4528c Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Fri, 18 Sep 2020 12:31:11 +0200 Subject: [PATCH 071/192] fxed linux message queues --- osal/linux/MessageQueue.cpp | 4 +++- osal/linux/MessageQueue.h | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/osal/linux/MessageQueue.cpp b/osal/linux/MessageQueue.cpp index 87251724..cfadb793 100644 --- a/osal/linux/MessageQueue.cpp +++ b/osal/linux/MessageQueue.cpp @@ -1,5 +1,6 @@ +#include "MessageQueue.h" #include "../../serviceinterface/ServiceInterfaceStream.h" -#include "../../osal/linux/MessageQueue.h" +#include "../../objectmanager/ObjectManagerIF.h" #include @@ -9,6 +10,7 @@ #include + MessageQueue::MessageQueue(uint32_t messageDepth, size_t maxMessageSize): id(MessageQueueIF::NO_QUEUE),lastPartner(MessageQueueIF::NO_QUEUE), defaultDestination(MessageQueueIF::NO_QUEUE), diff --git a/osal/linux/MessageQueue.h b/osal/linux/MessageQueue.h index c0b77019..239bbbdb 100644 --- a/osal/linux/MessageQueue.h +++ b/osal/linux/MessageQueue.h @@ -1,5 +1,5 @@ -#ifndef MESSAGEQUEUE_H_ -#define MESSAGEQUEUE_H_ +#ifndef FSFW_OSAL_LINUX_MESSAGEQUEUE_H_ +#define FSFW_OSAL_LINUX_MESSAGEQUEUE_H_ #include "../../internalError/InternalErrorReporterIF.h" #include "../../ipc/MessageQueueIF.h" @@ -184,4 +184,4 @@ private: ReturnValue_t handleError(mq_attr* attributes, uint32_t messageDepth); }; -#endif /* MESSAGEQUEUE_H_ */ +#endif /* FSFW_OSAL_LINUX_MESSAGEQUEUE_H_ */ From 19632b8fb1cf4cdedf13795ee5ecaa6158f91f10 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Fri, 18 Sep 2020 12:36:36 +0200 Subject: [PATCH 072/192] linux fixes --- ipc/QueueFactory.h | 6 +++--- osal/linux/Clock.cpp | 2 +- osal/linux/QueueFactory.cpp | 10 ++++++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ipc/QueueFactory.h b/ipc/QueueFactory.h index 5fbfdf2d..9853d256 100644 --- a/ipc/QueueFactory.h +++ b/ipc/QueueFactory.h @@ -1,5 +1,5 @@ -#ifndef FRAMEWORK_IPC_QUEUEFACTORY_H_ -#define FRAMEWORK_IPC_QUEUEFACTORY_H_ +#ifndef FSFW_IPC_QUEUEFACTORY_H_ +#define FSFW_IPC_QUEUEFACTORY_H_ #include "MessageQueueIF.h" #include "MessageQueueMessage.h" @@ -32,4 +32,4 @@ private: static QueueFactory* factoryInstance; }; -#endif /* FRAMEWORK_IPC_QUEUEFACTORY_H_ */ +#endif /* FSFW_IPC_QUEUEFACTORY_H_ */ diff --git a/osal/linux/Clock.cpp b/osal/linux/Clock.cpp index b3b09923..6f2faedb 100644 --- a/osal/linux/Clock.cpp +++ b/osal/linux/Clock.cpp @@ -6,8 +6,8 @@ #include #include #include +#include -//#include uint16_t Clock::leapSeconds = 0; MutexIF* Clock::timeMutex = NULL; diff --git a/osal/linux/QueueFactory.cpp b/osal/linux/QueueFactory.cpp index fb8f6df7..44def48a 100644 --- a/osal/linux/QueueFactory.cpp +++ b/osal/linux/QueueFactory.cpp @@ -1,8 +1,14 @@ #include "../../ipc/QueueFactory.h" +#include "MessageQueue.h" + +#include "../../ipc/messageQueueDefinitions.h" +#include "../../ipc/MessageQueueSenderIF.h" +#include "../../serviceinterface/ServiceInterfaceStream.h" + #include #include -#include "../../osal/linux/MessageQueue.h" -#include "../../serviceinterface/ServiceInterfaceStream.h" + + #include QueueFactory* QueueFactory::factoryInstance = nullptr; From e70e9e3f1f67e007245ab457c1e2f685d5450697 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Fri, 18 Sep 2020 12:57:30 +0200 Subject: [PATCH 073/192] added uptime seconds functions --- osal/FreeRTOS/Clock.cpp | 7 +++++++ osal/host/Clock.cpp | 5 +++++ osal/linux/Clock.cpp | 14 ++++++++++++-- timemanager/Clock.h | 2 ++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/osal/FreeRTOS/Clock.cpp b/osal/FreeRTOS/Clock.cpp index d556444c..42f060b4 100644 --- a/osal/FreeRTOS/Clock.cpp +++ b/osal/FreeRTOS/Clock.cpp @@ -67,6 +67,13 @@ ReturnValue_t Clock::getUptime(uint32_t* uptimeMs) { return HasReturnvaluesIF::RETURN_OK; } + +uint32_t Clock::getUptimeSeconds() { + timeval uptime = getUptime(); + return uptime.tv_sec; +} + + ReturnValue_t Clock::getClock_usecs(uint64_t* time) { timeval time_timeval; ReturnValue_t result = getClock_timeval(&time_timeval); diff --git a/osal/host/Clock.cpp b/osal/host/Clock.cpp index 41321eeb..17d98ba8 100644 --- a/osal/host/Clock.cpp +++ b/osal/host/Clock.cpp @@ -106,6 +106,11 @@ ReturnValue_t Clock::getUptime(uint32_t* uptimeMs) { return HasReturnvaluesIF::RETURN_OK; } +uint32_t Clock::getUptimeSeconds() { + timeval uptime = getUptime(); + return uptime.tv_sec; +} + ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { // do some magic with chrono (C++20!) diff --git a/osal/linux/Clock.cpp b/osal/linux/Clock.cpp index 6f2faedb..468fcb80 100644 --- a/osal/linux/Clock.cpp +++ b/osal/linux/Clock.cpp @@ -1,3 +1,4 @@ +#include #include "../../serviceinterface/ServiceInterfaceStream.h" #include "../../timemanager/Clock.h" @@ -76,8 +77,7 @@ timeval Clock::getUptime() { ReturnValue_t Clock::getUptime(timeval* uptime) { //TODO This is not posix compatible and delivers only seconds precision - // is the OS not called Linux? - //Linux specific file read but more precise + // Linux specific file read but more precise. double uptimeSeconds; if(std::ifstream("/proc/uptime",std::ios::in) >> uptimeSeconds){ uptime->tv_sec = uptimeSeconds; @@ -86,6 +86,16 @@ ReturnValue_t Clock::getUptime(timeval* uptime) { return HasReturnvaluesIF::RETURN_OK; } +uint32_t Clock::getUptimeSeconds() { + //TODO This is not posix compatible and delivers only seconds precision + struct sysinfo sysInfo; + int result = sysinfo(&sysInfo); + if(result != 0){ + return HasReturnvaluesIF::RETURN_FAILED; + } + return sysInfo.uptime; +} + ReturnValue_t Clock::getUptime(uint32_t* uptimeMs) { timeval uptime; ReturnValue_t result = getUptime(&uptime); diff --git a/timemanager/Clock.h b/timemanager/Clock.h index acb68e2e..1ad88305 100644 --- a/timemanager/Clock.h +++ b/timemanager/Clock.h @@ -67,6 +67,8 @@ public: static timeval getUptime(); + static uint32_t getUptimeSeconds(); + /** * Get the time since boot in milliseconds * From 7b0ddb3941729647276cdfe0218d0727d2f6e343 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Fri, 18 Sep 2020 13:09:23 +0200 Subject: [PATCH 074/192] quick fix DHB --- devicehandlers/DeviceHandlerBase.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index 86fd01b1..1f76fc4f 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -1275,10 +1275,14 @@ void DeviceHandlerBase::buildInternalCommand(void) { if (iter == deviceCommandMap.end()) { result = COMMAND_NOT_SUPPORTED; } else if (iter->second.isExecuting) { + //so we can track misconfigurations sif::debug << std::hex << getObjectId() << ": DHB::buildInternalCommand: Command " - << deviceCommandId << " isExecuting" << std::endl; //so we can track misconfigurations - return; //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 + << deviceCommandId << " isExecuting" << std::dec + << std::endl; + // 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; } else { iter->second.sendReplyTo = NO_COMMANDER; iter->second.isExecuting = true; From 57c88059e5be68191b25dac2f179df237b125df2 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Fri, 18 Sep 2020 13:12:07 +0200 Subject: [PATCH 075/192] DHB small improvements --- devicehandlers/DeviceHandlerBase.cpp | 16 ++++++++-------- devicehandlers/DeviceHandlerBase.h | 15 ++++++++------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index 1f76fc4f..0a3aec6d 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -1,18 +1,18 @@ -#include "../devicehandlers/DeviceHandlerBase.h" +#include "DeviceHandlerBase.h" +#include "AcceptsDeviceResponsesIF.h" +#include "DeviceTmReportingWrapper.h" + +#include "../serviceinterface/ServiceInterfaceStream.h" +#include "../datapoolglob/GlobalDataSet.h" +#include "../datapoolglob/GlobalPoolVariable.h" #include "../objectmanager/ObjectManager.h" #include "../storagemanager/StorageManagerIF.h" #include "../thermal/ThermalComponentIF.h" -#include "../devicehandlers/AcceptsDeviceResponsesIF.h" - -#include "../datapoolglob/GlobalDataSet.h" -#include "../datapoolglob/GlobalPoolVariable.h" -#include "../devicehandlers/DeviceTmReportingWrapper.h" #include "../globalfunctions/CRC.h" #include "../housekeeping/HousekeepingMessage.h" #include "../ipc/MessageQueueMessage.h" -#include "../subsystem/SubsystemBase.h" #include "../ipc/QueueFactory.h" -#include "../serviceinterface/ServiceInterfaceStream.h" +#include "../subsystem/SubsystemBase.h" #include diff --git a/devicehandlers/DeviceHandlerBase.h b/devicehandlers/DeviceHandlerBase.h index c3748172..752f7352 100644 --- a/devicehandlers/DeviceHandlerBase.h +++ b/devicehandlers/DeviceHandlerBase.h @@ -1,25 +1,26 @@ -#ifndef FRAMEWORK_DEVICEHANDLERS_DEVICEHANDLERBASE_H_ -#define FRAMEWORK_DEVICEHANDLERS_DEVICEHANDLERBASE_H_ +#ifndef FSFW_DEVICEHANDLERS_DEVICEHANDLERBASE_H_ +#define FSFW_DEVICEHANDLERS_DEVICEHANDLERBASE_H_ + +#include "DeviceHandlerIF.h" +#include "DeviceCommunicationIF.h" +#include "DeviceHandlerFailureIsolation.h" #include "../objectmanager/SystemObject.h" #include "../tasks/ExecutableObjectIF.h" -#include "../devicehandlers/DeviceHandlerIF.h" #include "../returnvalues/HasReturnvaluesIF.h" #include "../action/HasActionsIF.h" #include "../datapool/PoolVariableIF.h" -#include "../devicehandlers/DeviceCommunicationIF.h" #include "../modes/HasModesIF.h" #include "../power/PowerSwitchIF.h" #include "../ipc/MessageQueueIF.h" #include "../tasks/PeriodicTaskIF.h" - #include "../action/ActionHelper.h" #include "../health/HealthHelper.h" #include "../parameters/ParameterHelper.h" #include "../datapool/HkSwitchHelper.h" #include "../datapoollocal/HasLocalDataPoolIF.h" #include "../datapoollocal/LocalDataPoolManager.h" -#include "../devicehandlers/DeviceHandlerFailureIsolation.h" + #include namespace Factory{ @@ -1205,4 +1206,4 @@ private: size_t receivedDataLen); }; -#endif /* FRAMEWORK_DEVICEHANDLERS_DEVICEHANDLERBASE_H_ */ +#endif /* FSFW_DEVICEHANDLERS_DEVICEHANDLERBASE_H_ */ From b429359864f3a25eb33af17f52958fa102ffb8b9 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Fri, 18 Sep 2020 13:14:01 +0200 Subject: [PATCH 076/192] renormalize files --- ipc/messageQueueDefinitions.h | 36 ++--- serialize/SerialBufferAdapter.cpp | 258 +++++++++++++++--------------- serialize/SerialBufferAdapter.h | 156 +++++++++--------- 3 files changed, 225 insertions(+), 225 deletions(-) diff --git a/ipc/messageQueueDefinitions.h b/ipc/messageQueueDefinitions.h index d30e6984..d250da8a 100644 --- a/ipc/messageQueueDefinitions.h +++ b/ipc/messageQueueDefinitions.h @@ -1,18 +1,18 @@ -#ifndef FSFW_IPC_MESSAGEQUEUEDEFINITIONS_H_ -#define FSFW_IPC_MESSAGEQUEUEDEFINITIONS_H_ - -#include - -/* - * TODO: Actually, the definition of this ID to be a uint32_t is not ideal and - * breaks layering. However, it is difficult to keep layering, as the ID is - * stored in many places and sent around in MessageQueueMessage. - * Ideally, one would use the (current) object_id_t only, however, doing a - * lookup of queueIDs for every call does not sound ideal. - * In a first step, I'll circumvent the issue by not touching it, - * maybe in a second step. This also influences Interface design - * (getCommandQueue) and some other issues.. - */ -using MessageQueueId_t = uint32_t; - -#endif /* FSFW_IPC_MESSAGEQUEUEDEFINITIONS_H_ */ +#ifndef FSFW_IPC_MESSAGEQUEUEDEFINITIONS_H_ +#define FSFW_IPC_MESSAGEQUEUEDEFINITIONS_H_ + +#include + +/* + * TODO: Actually, the definition of this ID to be a uint32_t is not ideal and + * breaks layering. However, it is difficult to keep layering, as the ID is + * stored in many places and sent around in MessageQueueMessage. + * Ideally, one would use the (current) object_id_t only, however, doing a + * lookup of queueIDs for every call does not sound ideal. + * In a first step, I'll circumvent the issue by not touching it, + * maybe in a second step. This also influences Interface design + * (getCommandQueue) and some other issues.. + */ +using MessageQueueId_t = uint32_t; + +#endif /* FSFW_IPC_MESSAGEQUEUEDEFINITIONS_H_ */ diff --git a/serialize/SerialBufferAdapter.cpp b/serialize/SerialBufferAdapter.cpp index 812cd34b..1c11afd4 100644 --- a/serialize/SerialBufferAdapter.cpp +++ b/serialize/SerialBufferAdapter.cpp @@ -1,129 +1,129 @@ -#include "../serialize/SerialBufferAdapter.h" -#include "../serviceinterface/ServiceInterfaceStream.h" -#include - -template -SerialBufferAdapter::SerialBufferAdapter(const uint8_t* buffer, - count_t bufferLength, bool serializeLength) : - serializeLength(serializeLength), - constBuffer(buffer), buffer(nullptr), - bufferLength(bufferLength) {} - -template -SerialBufferAdapter::SerialBufferAdapter(uint8_t* buffer, - count_t bufferLength, bool serializeLength) : - serializeLength(serializeLength), constBuffer(buffer), buffer(buffer), - bufferLength(bufferLength) {} - - -template -SerialBufferAdapter::~SerialBufferAdapter() { -} - -template -ReturnValue_t SerialBufferAdapter::serialize(uint8_t** buffer, - size_t* size, size_t maxSize, Endianness streamEndianness) const { - if (serializeLength) { - ReturnValue_t result = SerializeAdapter::serialize(&bufferLength, - buffer, size, maxSize, streamEndianness); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - } - - if (*size + bufferLength > maxSize) { - return BUFFER_TOO_SHORT; - } - - if (this->constBuffer != nullptr) { - std::memcpy(*buffer, this->constBuffer, bufferLength); - } - else if (this->buffer != nullptr) { - // This will propably be never reached, constBuffer should always be - // set if non-const buffer is set. - std::memcpy(*buffer, this->buffer, bufferLength); - } - else { - return HasReturnvaluesIF::RETURN_FAILED; - } - *size += bufferLength; - (*buffer) += bufferLength; - return HasReturnvaluesIF::RETURN_OK; - -} - -template -size_t SerialBufferAdapter::getSerializedSize() const { - if (serializeLength) { - return bufferLength + SerializeAdapter::getSerializedSize(&bufferLength); - } else { - return bufferLength; - } -} - -template -ReturnValue_t SerialBufferAdapter::deSerialize(const uint8_t** buffer, - size_t* size, Endianness streamEndianness) { - if (this->buffer == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; - } - - if(serializeLength){ - count_t lengthField = 0; - ReturnValue_t result = SerializeAdapter::deSerialize(&lengthField, - buffer, size, streamEndianness); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - if(lengthField > bufferLength) { - return TOO_MANY_ELEMENTS; - } - bufferLength = lengthField; - } - - if (bufferLength <= *size) { - *size -= bufferLength; - std::memcpy(this->buffer, *buffer, bufferLength); - (*buffer) += bufferLength; - return HasReturnvaluesIF::RETURN_OK; - } - else { - return STREAM_TOO_SHORT; - } -} - -template -uint8_t * SerialBufferAdapter::getBuffer() { - if(buffer == nullptr) { - sif::error << "Wrong access function for stored type !" - " Use getConstBuffer()." << std::endl; - return nullptr; - } - return buffer; -} - -template -const uint8_t * SerialBufferAdapter::getConstBuffer() { - if(constBuffer == nullptr) { - sif::error << "SerialBufferAdapter::getConstBuffer:" - " Buffers are unitialized!" << std::endl; - return nullptr; - } - return constBuffer; -} - -template -void SerialBufferAdapter::setBuffer(uint8_t* buffer, - count_t bufferLength) { - this->buffer = buffer; - this->constBuffer = buffer; - this->bufferLength = bufferLength; -} - - -//forward Template declaration for linker -template class SerialBufferAdapter; -template class SerialBufferAdapter; -template class SerialBufferAdapter; -template class SerialBufferAdapter; - +#include "../serialize/SerialBufferAdapter.h" +#include "../serviceinterface/ServiceInterfaceStream.h" +#include + +template +SerialBufferAdapter::SerialBufferAdapter(const uint8_t* buffer, + count_t bufferLength, bool serializeLength) : + serializeLength(serializeLength), + constBuffer(buffer), buffer(nullptr), + bufferLength(bufferLength) {} + +template +SerialBufferAdapter::SerialBufferAdapter(uint8_t* buffer, + count_t bufferLength, bool serializeLength) : + serializeLength(serializeLength), constBuffer(buffer), buffer(buffer), + bufferLength(bufferLength) {} + + +template +SerialBufferAdapter::~SerialBufferAdapter() { +} + +template +ReturnValue_t SerialBufferAdapter::serialize(uint8_t** buffer, + size_t* size, size_t maxSize, Endianness streamEndianness) const { + if (serializeLength) { + ReturnValue_t result = SerializeAdapter::serialize(&bufferLength, + buffer, size, maxSize, streamEndianness); + if(result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + } + + if (*size + bufferLength > maxSize) { + return BUFFER_TOO_SHORT; + } + + if (this->constBuffer != nullptr) { + std::memcpy(*buffer, this->constBuffer, bufferLength); + } + else if (this->buffer != nullptr) { + // This will propably be never reached, constBuffer should always be + // set if non-const buffer is set. + std::memcpy(*buffer, this->buffer, bufferLength); + } + else { + return HasReturnvaluesIF::RETURN_FAILED; + } + *size += bufferLength; + (*buffer) += bufferLength; + return HasReturnvaluesIF::RETURN_OK; + +} + +template +size_t SerialBufferAdapter::getSerializedSize() const { + if (serializeLength) { + return bufferLength + SerializeAdapter::getSerializedSize(&bufferLength); + } else { + return bufferLength; + } +} + +template +ReturnValue_t SerialBufferAdapter::deSerialize(const uint8_t** buffer, + size_t* size, Endianness streamEndianness) { + if (this->buffer == nullptr) { + return HasReturnvaluesIF::RETURN_FAILED; + } + + if(serializeLength){ + count_t lengthField = 0; + ReturnValue_t result = SerializeAdapter::deSerialize(&lengthField, + buffer, size, streamEndianness); + if(result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + if(lengthField > bufferLength) { + return TOO_MANY_ELEMENTS; + } + bufferLength = lengthField; + } + + if (bufferLength <= *size) { + *size -= bufferLength; + std::memcpy(this->buffer, *buffer, bufferLength); + (*buffer) += bufferLength; + return HasReturnvaluesIF::RETURN_OK; + } + else { + return STREAM_TOO_SHORT; + } +} + +template +uint8_t * SerialBufferAdapter::getBuffer() { + if(buffer == nullptr) { + sif::error << "Wrong access function for stored type !" + " Use getConstBuffer()." << std::endl; + return nullptr; + } + return buffer; +} + +template +const uint8_t * SerialBufferAdapter::getConstBuffer() { + if(constBuffer == nullptr) { + sif::error << "SerialBufferAdapter::getConstBuffer:" + " Buffers are unitialized!" << std::endl; + return nullptr; + } + return constBuffer; +} + +template +void SerialBufferAdapter::setBuffer(uint8_t* buffer, + count_t bufferLength) { + this->buffer = buffer; + this->constBuffer = buffer; + this->bufferLength = bufferLength; +} + + +//forward Template declaration for linker +template class SerialBufferAdapter; +template class SerialBufferAdapter; +template class SerialBufferAdapter; +template class SerialBufferAdapter; + diff --git a/serialize/SerialBufferAdapter.h b/serialize/SerialBufferAdapter.h index c3dfcd8f..9a89e18b 100644 --- a/serialize/SerialBufferAdapter.h +++ b/serialize/SerialBufferAdapter.h @@ -1,78 +1,78 @@ -#ifndef SERIALBUFFERADAPTER_H_ -#define SERIALBUFFERADAPTER_H_ - -#include "../serialize/SerializeIF.h" -#include "../serialize/SerializeAdapter.h" - -/** - * This adapter provides an interface for SerializeIF to serialize or deserialize - * buffers with no length header but a known size. - * - * Additionally, the buffer length can be serialized too and will be put in - * front of the serialized buffer. - * - * Can be used with SerialLinkedListAdapter by declaring a SerializeElement with - * SerialElement>. - * Right now, the SerialBufferAdapter must always - * be initialized with the buffer and size ! - * - * \ingroup serialize - */ -template -class SerialBufferAdapter: public SerializeIF { -public: - - /** - * Constructor for constant uint8_t buffer. Length field can be serialized optionally. - * Type of length can be supplied as template type. - * @param buffer - * @param bufferLength - * @param serializeLength - */ - SerialBufferAdapter(const uint8_t* buffer, count_t bufferLength, - bool serializeLength = false); - - /** - * Constructor for non-constant uint8_t buffer. - * Length field can be serialized optionally. - * Type of length can be supplied as template type. - * @param buffer - * @param bufferLength - * @param serializeLength Length field will be serialized with size count_t - */ - SerialBufferAdapter(uint8_t* buffer, count_t bufferLength, - bool serializeLength = false); - - virtual ~SerialBufferAdapter(); - - virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size, - size_t maxSize, Endianness streamEndianness) const override; - - virtual size_t getSerializedSize() const override; - - /** - * @brief This function deserializes a buffer into the member buffer. - * @details - * If a length field is present, it is ignored, as the size should have - * been set in the constructor. If the size is not known beforehand, - * consider using SerialFixedArrayListAdapter instead. - * @param buffer [out] Resulting buffer - * @param size remaining size to deserialize, should be larger than buffer - * + size field size - * @param bigEndian - * @return - */ - virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, - Endianness streamEndianness) override; - - uint8_t * getBuffer(); - const uint8_t * getConstBuffer(); - void setBuffer(uint8_t* buffer, count_t bufferLength); -private: - bool serializeLength = false; - const uint8_t *constBuffer = nullptr; - uint8_t *buffer = nullptr; - count_t bufferLength = 0; -}; - -#endif /* SERIALBUFFERADAPTER_H_ */ +#ifndef SERIALBUFFERADAPTER_H_ +#define SERIALBUFFERADAPTER_H_ + +#include "../serialize/SerializeIF.h" +#include "../serialize/SerializeAdapter.h" + +/** + * This adapter provides an interface for SerializeIF to serialize or deserialize + * buffers with no length header but a known size. + * + * Additionally, the buffer length can be serialized too and will be put in + * front of the serialized buffer. + * + * Can be used with SerialLinkedListAdapter by declaring a SerializeElement with + * SerialElement>. + * Right now, the SerialBufferAdapter must always + * be initialized with the buffer and size ! + * + * \ingroup serialize + */ +template +class SerialBufferAdapter: public SerializeIF { +public: + + /** + * Constructor for constant uint8_t buffer. Length field can be serialized optionally. + * Type of length can be supplied as template type. + * @param buffer + * @param bufferLength + * @param serializeLength + */ + SerialBufferAdapter(const uint8_t* buffer, count_t bufferLength, + bool serializeLength = false); + + /** + * Constructor for non-constant uint8_t buffer. + * Length field can be serialized optionally. + * Type of length can be supplied as template type. + * @param buffer + * @param bufferLength + * @param serializeLength Length field will be serialized with size count_t + */ + SerialBufferAdapter(uint8_t* buffer, count_t bufferLength, + bool serializeLength = false); + + virtual ~SerialBufferAdapter(); + + virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size, + size_t maxSize, Endianness streamEndianness) const override; + + virtual size_t getSerializedSize() const override; + + /** + * @brief This function deserializes a buffer into the member buffer. + * @details + * If a length field is present, it is ignored, as the size should have + * been set in the constructor. If the size is not known beforehand, + * consider using SerialFixedArrayListAdapter instead. + * @param buffer [out] Resulting buffer + * @param size remaining size to deserialize, should be larger than buffer + * + size field size + * @param bigEndian + * @return + */ + virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, + Endianness streamEndianness) override; + + uint8_t * getBuffer(); + const uint8_t * getConstBuffer(); + void setBuffer(uint8_t* buffer, count_t bufferLength); +private: + bool serializeLength = false; + const uint8_t *constBuffer = nullptr; + uint8_t *buffer = nullptr; + count_t bufferLength = 0; +}; + +#endif /* SERIALBUFFERADAPTER_H_ */ From 1b5c3786b61ceecdb4e7cf1b7b664e81399dbcf6 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Fri, 18 Sep 2020 13:24:06 +0200 Subject: [PATCH 077/192] taken over serviceinterface folder --- serviceinterface/ServiceInterfaceBuffer.cpp | 2 +- serviceinterface/ServiceInterfaceStream.cpp | 2 +- serviceinterface/ServiceInterfaceStream.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/serviceinterface/ServiceInterfaceBuffer.cpp b/serviceinterface/ServiceInterfaceBuffer.cpp index 880f51e1..68fc4dec 100644 --- a/serviceinterface/ServiceInterfaceBuffer.cpp +++ b/serviceinterface/ServiceInterfaceBuffer.cpp @@ -1,5 +1,5 @@ #include "../timemanager/Clock.h" -#include "../serviceinterface/ServiceInterfaceBuffer.h" +#include "ServiceInterfaceBuffer.h" #include #include diff --git a/serviceinterface/ServiceInterfaceStream.cpp b/serviceinterface/ServiceInterfaceStream.cpp index 8a358999..5b7b9f00 100644 --- a/serviceinterface/ServiceInterfaceStream.cpp +++ b/serviceinterface/ServiceInterfaceStream.cpp @@ -1,4 +1,4 @@ -#include "../serviceinterface/ServiceInterfaceStream.h" +#include "ServiceInterfaceStream.h" 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 051500f5..76fa1bf2 100644 --- a/serviceinterface/ServiceInterfaceStream.h +++ b/serviceinterface/ServiceInterfaceStream.h @@ -1,7 +1,7 @@ #ifndef FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACESTREAM_H_ #define FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACESTREAM_H_ -#include "../serviceinterface/ServiceInterfaceBuffer.h" +#include "ServiceInterfaceBuffer.h" #include #include From 4d4166071ca864ce4e60d0aa92ddcc6b74fa1644 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Fri, 18 Sep 2020 13:28:20 +0200 Subject: [PATCH 078/192] added pus services to framework objects --- objectmanager/frameworkObjects.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/objectmanager/frameworkObjects.h b/objectmanager/frameworkObjects.h index 46d5feea..4a30e70a 100644 --- a/objectmanager/frameworkObjects.h +++ b/objectmanager/frameworkObjects.h @@ -1,10 +1,14 @@ -#ifndef FRAMEWORK_OBJECTMANAGER_FRAMEWORKOBJECTS_H_ -#define FRAMEWORK_OBJECTMANAGER_FRAMEWORKOBJECTS_H_ +#ifndef FSFW_OBJECTMANAGER_FRAMEWORKOBJECTS_H_ +#define FSFW_OBJECTMANAGER_FRAMEWORKOBJECTS_H_ namespace objects { enum framework_objects { // Default verification reporter. - PUS_SERVICE_1 = 0x53000000, + PUS_SERVICE_1 = 0x53000001, + PUS_SERVICE_2 = 0x53000002, + PUS_SERVICE_5 = 0x53000005, + PUS_SERVICE_8 = 0x53000008, + PUS_SERVICE_200 = 0x53000200, //Generic IDs for IPC, modes, health, events HEALTH_TABLE = 0x53010000, @@ -22,4 +26,4 @@ enum framework_objects { -#endif /* FRAMEWORK_OBJECTMANAGER_FRAMEWORKOBJECTS_H_ */ +#endif /* FSFW_OBJECTMANAGER_FRAMEWORKOBJECTS_H_ */ From f50a80fc3c61066d69117d033b59a85722212c09 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Fri, 18 Sep 2020 13:29:42 +0200 Subject: [PATCH 079/192] minor tweaks --- objectmanager/ObjectManager.cpp | 2 +- objectmanager/ObjectManager.h | 27 +++++++++++---------------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/objectmanager/ObjectManager.cpp b/objectmanager/ObjectManager.cpp index a8c84415..5871bfcd 100644 --- a/objectmanager/ObjectManager.cpp +++ b/objectmanager/ObjectManager.cpp @@ -1,4 +1,4 @@ -#include "../objectmanager/ObjectManager.h" +#include "ObjectManager.h" #include "../serviceinterface/ServiceInterfaceStream.h" #include #include diff --git a/objectmanager/ObjectManager.h b/objectmanager/ObjectManager.h index e582584c..69a74f73 100644 --- a/objectmanager/ObjectManager.h +++ b/objectmanager/ObjectManager.h @@ -1,15 +1,8 @@ -/** - * @file ObjectManager.h - * @brief This file contains the implementation of the ObjectManager class - * @date 18.09.2012 - * @author Bastian Baetz - */ +#ifndef FSFW_OBJECTMANAGER_OBJECTMANAGER_H_ +#define FSFW_OBJECTMANAGER_OBJECTMANAGER_H_ -#ifndef OBJECTMANAGER_H_ -#define OBJECTMANAGER_H_ - -#include "../objectmanager/ObjectManagerIF.h" -#include "../objectmanager/SystemObjectIF.h" +#include "ObjectManagerIF.h" +#include "SystemObjectIF.h" #include /** @@ -22,14 +15,15 @@ * most of the system initialization. * As the system is static after initialization, no new objects are * created or inserted into the list after startup. - * \ingroup system_objects + * @ingroup system_objects + * @author Bastian Baetz */ class ObjectManager : public ObjectManagerIF { private: //comparison? /** - * \brief This is the map of all initialized objects in the manager. - * \details Objects in the List must inherit the SystemObjectIF. + * @brief This is the map of all initialized objects in the manager. + * @details Objects in the List must inherit the SystemObjectIF. */ std::map objectList; protected: @@ -54,7 +48,8 @@ public: /** * @brief In the class's destructor, all objects in the list are deleted. */ - //SHOULDDO: If, for some reason, deleting an ObjectManager instance is required, check if this works. + // SHOULDDO: If, for some reason, deleting an ObjectManager instance is + // required, check if this works. virtual ~ObjectManager( void ); ReturnValue_t insert( object_id_t id, SystemObjectIF* object ); ReturnValue_t remove( object_id_t id ); @@ -64,4 +59,4 @@ public: -#endif /* OBJECTMANAGER_H_ */ +#endif /* FSFW_OBJECTMANAGER_OBJECTMANAGER_H_ */ From 3a043b5773de78516ac6efd0c3b483e79ebd729e Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Fri, 18 Sep 2020 13:31:51 +0200 Subject: [PATCH 080/192] object manager tweaks complete --- objectmanager/ObjectManagerIF.h | 9 +++++---- objectmanager/SystemObject.cpp | 4 ++-- objectmanager/SystemObject.h | 19 +++++++++++-------- objectmanager/SystemObjectIF.h | 6 +++--- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/objectmanager/ObjectManagerIF.h b/objectmanager/ObjectManagerIF.h index 16619e23..1f462509 100644 --- a/objectmanager/ObjectManagerIF.h +++ b/objectmanager/ObjectManagerIF.h @@ -1,8 +1,8 @@ -#ifndef FRAMEWORK_OBJECTMANAGER_OBJECTMANAGERIF_H_ -#define FRAMEWORK_OBJECTMANAGER_OBJECTMANAGERIF_H_ +#ifndef FSFW_OBJECTMANAGER_OBJECTMANAGERIF_H_ +#define FSFW_OBJECTMANAGER_OBJECTMANAGERIF_H_ -#include "../objectmanager/frameworkObjects.h" -#include "../objectmanager/SystemObjectIF.h" +#include "frameworkObjects.h" +#include "SystemObjectIF.h" #include "../returnvalues/HasReturnvaluesIF.h" #include "../serviceinterface/ServiceInterfaceStream.h" @@ -79,6 +79,7 @@ public: /** * @brief This is the forward declaration of the global objectManager instance. */ +// maybe but this in the glob namespace to explicitely mark it global? extern ObjectManagerIF *objectManager; /*Documentation can be found in the class method declaration above.*/ diff --git a/objectmanager/SystemObject.cpp b/objectmanager/SystemObject.cpp index 61eaf90a..64330fbc 100644 --- a/objectmanager/SystemObject.cpp +++ b/objectmanager/SystemObject.cpp @@ -1,6 +1,6 @@ +#include "ObjectManager.h" +#include "SystemObject.h" #include "../events/EventManagerIF.h" -#include "../objectmanager/ObjectManager.h" -#include "../objectmanager/SystemObject.h" SystemObject::SystemObject(object_id_t setObjectId, bool doRegister) : objectId(setObjectId), registered(doRegister) { diff --git a/objectmanager/SystemObject.h b/objectmanager/SystemObject.h index ae4b1389..9188693e 100644 --- a/objectmanager/SystemObject.h +++ b/objectmanager/SystemObject.h @@ -1,9 +1,9 @@ -#ifndef SYSTEMOBJECT_H_ -#define SYSTEMOBJECT_H_ +#ifndef FSFW_OBJECTMANAGER_SYSTEMOBJECT_H_ +#define FSFW_OBJECTMANAGER_SYSTEMOBJECT_H_ +#include "SystemObjectIF.h" #include "../events/Event.h" #include "../events/EventReportingProxyIF.h" -#include "../objectmanager/SystemObjectIF.h" #include "../timemanager/Clock.h" /** @@ -13,7 +13,7 @@ * class that is announced to ObjectManager. It automatically includes * itself (and therefore the inheriting class) in the object manager's * list. - * \ingroup system_objects + * @ingroup system_objects */ class SystemObject: public SystemObjectIF { private: @@ -30,14 +30,16 @@ public: * @param parameter1 * @param parameter2 */ - virtual void triggerEvent(Event event, uint32_t parameter1 = 0, uint32_t parameter2 = 0); + virtual void triggerEvent(Event event, uint32_t parameter1 = 0, + uint32_t parameter2 = 0); /** * @brief The class's constructor. * @details In the constructor, the object id is set and the class is * inserted in the object manager. * @param setObjectId The id the object shall have. - * @param doRegister Determines if the object is registered in the global object manager. + * @param doRegister Determines if the object is registered in + * the global object manager. */ SystemObject(object_id_t setObjectId, bool doRegister = true); /** @@ -48,7 +50,8 @@ public: virtual ReturnValue_t initialize() override; virtual ReturnValue_t checkObjectConnections(); - virtual void forwardEvent(Event event, uint32_t parameter1 = 0, uint32_t parameter2 = 0) const; + virtual void forwardEvent(Event event, uint32_t parameter1 = 0, + uint32_t parameter2 = 0) const; }; -#endif /* SYSTEMOBJECT_H_ */ +#endif /* FSFW_OBJECTMANAGER_SYSTEMOBJECT_H_ */ diff --git a/objectmanager/SystemObjectIF.h b/objectmanager/SystemObjectIF.h index 108717af..315fde9b 100644 --- a/objectmanager/SystemObjectIF.h +++ b/objectmanager/SystemObjectIF.h @@ -1,5 +1,5 @@ -#ifndef FRAMEWORK_OBJECTMANAGER_SYSTEMOBJECTIF_H_ -#define FRAMEWORK_OBJECTMANAGER_SYSTEMOBJECTIF_H_ +#ifndef FSFW_OBJECTMANAGER_SYSTEMOBJECTIF_H_ +#define FSFW_OBJECTMANAGER_SYSTEMOBJECTIF_H_ #include "../events/EventReportingProxyIF.h" #include "../returnvalues/HasReturnvaluesIF.h" @@ -59,4 +59,4 @@ public: virtual ReturnValue_t checkObjectConnections() = 0; }; -#endif /* FRAMEWORK_OBJECTMANAGER_SYSTEMOBJECTIF_H_ */ +#endif /* #ifndef FSFW_OBJECTMANAGER_SYSTEMOBJECTIF_H_ */ From 5e3f40a2c1c163eaa36705de597db37b36ec8635 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Fri, 18 Sep 2020 13:40:48 +0200 Subject: [PATCH 081/192] changes taken over from pull request --- objectmanager/ObjectManagerIF.h | 4 ++-- objectmanager/SystemObject.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/objectmanager/ObjectManagerIF.h b/objectmanager/ObjectManagerIF.h index 1f462509..4bd1d915 100644 --- a/objectmanager/ObjectManagerIF.h +++ b/objectmanager/ObjectManagerIF.h @@ -21,7 +21,7 @@ public: static constexpr uint8_t INTERFACE_ID = CLASS_ID::OBJECT_MANAGER_IF; static constexpr ReturnValue_t INSERTION_FAILED = MAKE_RETURN_CODE( 1 ); static constexpr ReturnValue_t NOT_FOUND = MAKE_RETURN_CODE( 2 ); - static constexpr ReturnValue_t CHILD_INIT_FAILED = MAKE_RETURN_CODE( 3 ); + static constexpr ReturnValue_t CHILD_INIT_FAILED = MAKE_RETURN_CODE( 3 ); //!< Can be used if the initialization of a SystemObject failed. static constexpr ReturnValue_t INTERNAL_ERR_REPORTER_UNINIT = MAKE_RETURN_CODE( 4 ); protected: @@ -79,7 +79,7 @@ public: /** * @brief This is the forward declaration of the global objectManager instance. */ -// maybe but this in the glob namespace to explicitely mark it global? +// SHOULDDO: maybe put this in the glob namespace to explicitely mark it global? extern ObjectManagerIF *objectManager; /*Documentation can be found in the class method declaration above.*/ diff --git a/objectmanager/SystemObject.h b/objectmanager/SystemObject.h index 9188693e..d9c4236d 100644 --- a/objectmanager/SystemObject.h +++ b/objectmanager/SystemObject.h @@ -13,6 +13,7 @@ * class that is announced to ObjectManager. It automatically includes * itself (and therefore the inheriting class) in the object manager's * list. + * @author Ulrich Mohr * @ingroup system_objects */ class SystemObject: public SystemObjectIF { From 33e7cca23c3175b7349654e790fadb9a2938546c Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Fri, 18 Sep 2020 15:01:35 +0200 Subject: [PATCH 082/192] several bugfixes amd improvements --- datapoollocal/LocalDataPoolManager.cpp | 5 +- pus/Service3Housekeeping.cpp | 205 ++++++++++++++----------- pus/Service3Housekeeping.h | 18 ++- 3 files changed, 128 insertions(+), 100 deletions(-) diff --git a/datapoollocal/LocalDataPoolManager.cpp b/datapoollocal/LocalDataPoolManager.cpp index 619d8365..77851904 100644 --- a/datapoollocal/LocalDataPoolManager.cpp +++ b/datapoollocal/LocalDataPoolManager.cpp @@ -144,8 +144,11 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage( case(HousekeepingMessage::REPORT_HK_REPORT_STRUCTURES): //return generateSetStructurePacket(message->getSid()); case(HousekeepingMessage::GENERATE_ONE_PARAMETER_REPORT): + return generateHousekeepingPacket(HousekeepingMessage::getSid(message), + false, true); case(HousekeepingMessage::GENERATE_ONE_DIAGNOSTICS_REPORT): - //return generateHousekeepingPacket(message->getSid()); + return generateHousekeepingPacket(HousekeepingMessage::getSid(message), + true, true); default: return CommandMessageIF::UNKNOWN_COMMAND; } diff --git a/pus/Service3Housekeeping.cpp b/pus/Service3Housekeeping.cpp index db77328a..55e687cc 100644 --- a/pus/Service3Housekeeping.cpp +++ b/pus/Service3Housekeeping.cpp @@ -36,7 +36,6 @@ ReturnValue_t Service3Housekeeping::isValidSubservice(uint8_t subservice) { ReturnValue_t Service3Housekeeping::getMessageQueueAndObject(uint8_t subservice, const uint8_t *tcData, size_t tcDataLen, MessageQueueId_t *id, object_id_t *objectId) { - return HasReturnvaluesIF::RETURN_OK; ReturnValue_t result = checkAndAcquireTargetID(objectId,tcData,tcDataLen); if(result != RETURN_OK) { return result; @@ -55,7 +54,7 @@ ReturnValue_t Service3Housekeeping::checkAndAcquireTargetID( ReturnValue_t Service3Housekeeping::checkInterfaceAndAcquireMessageQueue( MessageQueueId_t* messageQueueToSet, object_id_t* objectId) { - // check OwnsLocalDataPoolIF property of target + // check HasLocalDataPoolIF property of target HasLocalDataPoolIF* possibleTarget = objectManager->get(*objectId); if(possibleTarget == nullptr){ @@ -71,33 +70,35 @@ ReturnValue_t Service3Housekeeping::prepareCommand(CommandMessage* message, uint32_t *state, object_id_t objectId) { switch(static_cast(subservice)) { case Subservice::ENABLE_PERIODIC_HK_REPORT_GENERATION: - return prepareReportingTogglingCommand(message, true, false, + return prepareReportingTogglingCommand(message, objectId, true, false, tcData, tcDataLen); case Subservice::DISABLE_PERIODIC_HK_REPORT_GENERATION: - return prepareReportingTogglingCommand(message, false, false, + return prepareReportingTogglingCommand(message, objectId, false, false, tcData, tcDataLen); case Subservice::ENABLE_PERIODIC_DIAGNOSTICS_REPORT_GENERATION: - return prepareReportingTogglingCommand(message, true, true, + return prepareReportingTogglingCommand(message, objectId, true, true, tcData, tcDataLen); case Subservice::DISABLE_PERIODIC_DIAGNOSTICS_REPORT_GENERATION: - return prepareReportingTogglingCommand(message, false, true, + return prepareReportingTogglingCommand(message, objectId, false, true, tcData, tcDataLen); case Subservice::REPORT_HK_REPORT_STRUCTURES: - return prepareStructureReportingCommand(message, false, tcData, + return prepareStructureReportingCommand(message, objectId, false, tcData, tcDataLen); case Subservice::REPORT_DIAGNOSTICS_REPORT_STRUCTURES: - return prepareStructureReportingCommand(message, true, tcData, + return prepareStructureReportingCommand(message, objectId, true, tcData, tcDataLen); case Subservice::GENERATE_ONE_PARAMETER_REPORT: - return prepareOneShotReportCommand(message, false, tcData, tcDataLen); + return prepareOneShotReportCommand(message, objectId, false, + tcData, tcDataLen); case Subservice::GENERATE_ONE_DIAGNOSTICS_REPORT: - return prepareOneShotReportCommand(message, true, tcData, tcDataLen); + return prepareOneShotReportCommand(message, objectId, true, + tcData, tcDataLen); case Subservice::MODIFY_PARAMETER_REPORT_COLLECTION_INTERVAL: - return prepareCollectionIntervalModificationCommand(message, false, - tcData, tcDataLen); + return prepareCollectionIntervalModificationCommand(message, objectId, + false, tcData, tcDataLen); case Subservice::MODIFY_DIAGNOSTICS_REPORT_COLLECTION_INTERVAL: - return prepareCollectionIntervalModificationCommand(message, true, - tcData, tcDataLen); + return prepareCollectionIntervalModificationCommand(message, objectId, + true, tcData, tcDataLen); case Subservice::HK_DEFINITIONS_REPORT: case Subservice::DIAGNOSTICS_DEFINITION_REPORT: case Subservice::HK_REPORT: @@ -111,103 +112,59 @@ ReturnValue_t Service3Housekeeping::prepareCommand(CommandMessage* message, return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t Service3Housekeeping::handleReply(const CommandMessage* reply, - Command_t previousCommand, uint32_t *state, - CommandMessage* optionalNextCommand, object_id_t objectId, - bool *isStep) { - switch(reply->getCommand()) { - case(HousekeepingMessage::HK_REQUEST_SUCCESS): { - return CommandingServiceBase::EXECUTION_COMPLETE; - } - case(HousekeepingMessage::HK_REQUEST_FAILURE): { - failureParameter1 = objectId; - // also provide failure reason (returnvalue) - // will be most commonly invalid SID or the set already has the desired - // reporting status. - return CommandingServiceBase::EXECUTION_COMPLETE; - } - default: - sif::error << "Service3Housekeeping::handleReply: Invalid reply!" - << std::endl; - return CommandingServiceBase::INVALID_REPLY; - } - return HasReturnvaluesIF::RETURN_OK; -} - ReturnValue_t Service3Housekeeping::prepareReportingTogglingCommand( - CommandMessage *command, bool enableReporting, bool isDiagnostics, + CommandMessage *command, object_id_t objectId, + bool enableReporting, bool isDiagnostics, const uint8_t* tcData, size_t tcDataLen) { - if(tcDataLen < sizeof(sid_t)) { - // It is assumed the full SID is sent for now (even if that means - // 4 bytes are redundant) + if(tcDataLen < sizeof(object_id_t)) { + // TC data should consist of object ID and set ID. return CommandingServiceBase::INVALID_TC; } - sid_t targetSid; - SerializeAdapter::deSerialize(&targetSid.objectId, &tcData, &tcDataLen, - SerializeIF::Endianness::BIG); - SerializeAdapter::deSerialize(&targetSid.ownerSetId, &tcData, &tcDataLen, - SerializeIF::Endianness::BIG); - + sid_t targetSid = buildSid(objectId, tcData, tcDataLen); HousekeepingMessage::setToggleReportingCommand(command, targetSid, enableReporting, isDiagnostics); return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t Service3Housekeeping::prepareStructureReportingCommand( - CommandMessage *command, bool isDiagnostics, const uint8_t* tcData, - size_t tcDataLen) { + CommandMessage *command, object_id_t objectId, bool isDiagnostics, + const uint8_t* tcData, size_t tcDataLen) { if(tcDataLen < sizeof(sid_t)) { - // It is assumed the full SID is sent for now (even if that means - // 4 bytes are redundant) + // TC data should consist of object ID and set ID. return CommandingServiceBase::INVALID_TC; } - sid_t targetSid; - SerializeAdapter::deSerialize(&targetSid.objectId, &tcData, &tcDataLen, - SerializeIF::Endianness::BIG); - SerializeAdapter::deSerialize(&targetSid.ownerSetId, &tcData, &tcDataLen, - SerializeIF::Endianness::BIG); - + sid_t targetSid = buildSid(objectId, tcData, tcDataLen); HousekeepingMessage::setStructureReportingCommand(command, targetSid, isDiagnostics); return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t Service3Housekeeping::prepareOneShotReportCommand( - CommandMessage *command, bool isDiagnostics, const uint8_t *tcData, - size_t tcDataLen) { + CommandMessage *command, object_id_t objectId, bool isDiagnostics, + const uint8_t *tcData, size_t tcDataLen) { if(tcDataLen < sizeof(sid_t)) { - // It is assumed the full SID is sent for now (even if that means - // 4 bytes are redundant) + // TC data should consist of object ID and set ID. return CommandingServiceBase::INVALID_TC; } - sid_t targetSid; - SerializeAdapter::deSerialize(&targetSid.objectId, &tcData, &tcDataLen, - SerializeIF::Endianness::BIG); - SerializeAdapter::deSerialize(&targetSid.ownerSetId, &tcData, &tcDataLen, - SerializeIF::Endianness::BIG); + sid_t targetSid = buildSid(objectId, tcData, tcDataLen); HousekeepingMessage::setOneShotReportCommand(command, targetSid, isDiagnostics); return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t Service3Housekeeping::prepareCollectionIntervalModificationCommand( - CommandMessage *command, bool isDiagnostics, const uint8_t *tcData, - size_t tcDataLen) { + CommandMessage *command, object_id_t objectId, bool isDiagnostics, + const uint8_t *tcData, size_t tcDataLen) { if(tcDataLen < sizeof(sid_t) + sizeof(float)) { - // It is assumed the full SID and the new collection interval as a float - // is sent for now (even if that means 4 bytes are redundant) + // SID plus the size of the new collection intervL. return CommandingServiceBase::INVALID_TC; } - sid_t targetSid; + sid_t targetSid = buildSid(objectId, tcData, tcDataLen); float newCollectionInterval = 0; - SerializeAdapter::deSerialize(&targetSid.objectId, &tcData, &tcDataLen, - SerializeIF::Endianness::BIG); - SerializeAdapter::deSerialize(&targetSid.ownerSetId, &tcData, &tcDataLen, - SerializeIF::Endianness::BIG); SerializeAdapter::deSerialize(&newCollectionInterval, &tcData, &tcDataLen, SerializeIF::Endianness::BIG); HousekeepingMessage::setCollectionIntervalModificationCommand(command, @@ -215,25 +172,76 @@ ReturnValue_t Service3Housekeeping::prepareCollectionIntervalModificationCommand return HasReturnvaluesIF::RETURN_OK; } + +ReturnValue_t Service3Housekeeping::handleReply(const CommandMessage* reply, + Command_t previousCommand, uint32_t *state, + CommandMessage* optionalNextCommand, object_id_t objectId, + bool *isStep) { + Command_t command = reply->getCommand(); + switch(command) { + + case(HousekeepingMessage::HK_REPORT): { + ReturnValue_t result = generateHkReport(reply, + static_cast(Subservice::HK_REPORT)); + if(result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + return CommandingServiceBase::EXECUTION_COMPLETE; + } + + case(HousekeepingMessage::DIAGNOSTICS_REPORT): { + ReturnValue_t result = generateHkReport(reply, + static_cast(Subservice::DIAGNOSTICS_REPORT)); + if(result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + return CommandingServiceBase::EXECUTION_COMPLETE; + } + + case(HousekeepingMessage::HK_REQUEST_SUCCESS): { + return CommandingServiceBase::EXECUTION_COMPLETE; + } + + case(HousekeepingMessage::HK_REQUEST_FAILURE): { + failureParameter1 = objectId; + // also provide failure reason (returnvalue) + // will be most commonly invalid SID or the set already has the desired + // reporting status. + return CommandingServiceBase::EXECUTION_COMPLETE; + } + + default: + sif::error << "Service3Housekeeping::handleReply: Invalid reply with " + << "reply command " << command << "!" << std::endl; + return CommandingServiceBase::INVALID_REPLY; + } + return HasReturnvaluesIF::RETURN_OK; +} + void Service3Housekeeping::handleUnrequestedReply( - CommandMessage* reply) { + CommandMessage* reply) { ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - switch(reply->getCommand()) { - case(HousekeepingMessage::DIAGNOSTICS_REPORT): { - result = generateHkReport(reply, - static_cast(Subservice::DIAGNOSTICS_REPORT)); - break; - } - case(HousekeepingMessage::HK_REPORT): { - result = generateHkReport(reply, - static_cast(Subservice::HK_REPORT)); - break; - } - default: { - sif::error << "Service3Housekeeping::handleUnrequestedReply: " - << "Invalid reply!" << std::endl; - } - } + Command_t command = reply->getCommand(); + + switch(command) { + + case(HousekeepingMessage::DIAGNOSTICS_REPORT): { + result = generateHkReport(reply, + static_cast(Subservice::DIAGNOSTICS_REPORT)); + break; + } + + case(HousekeepingMessage::HK_REPORT): { + result = generateHkReport(reply, + static_cast(Subservice::HK_REPORT)); + break; + } + + default: + sif::error << "Service3Housekeeping::handleReply: Invalid reply with " + << "reply command " << command << "!" << std::endl; + return; + } if(result != HasReturnvaluesIF::RETURN_OK) { // Configuration error @@ -260,3 +268,16 @@ ReturnValue_t Service3Housekeeping::generateHkReport( return sendTmPacket(static_cast(subserviceId), hkPacket.hkData, hkPacket.hkSize, nullptr, 0); } + +sid_t Service3Housekeeping::buildSid(object_id_t objectId, + const uint8_t* tcData, size_t tcDataLen) { + sid_t targetSid; + targetSid.objectId = objectId; + // skip deserialization of object ID, was already done. + tcData += sizeof(object_id_t); + tcDataLen -= sizeof(object_id_t); + // size check is expected to be performed beforehand! + SerializeAdapter::deSerialize(&targetSid.ownerSetId, &tcData, &tcDataLen, + SerializeIF::Endianness::BIG); + return targetSid; +} diff --git a/pus/Service3Housekeeping.h b/pus/Service3Housekeeping.h index 6c5d2469..1dab3153 100644 --- a/pus/Service3Housekeeping.h +++ b/pus/Service3Housekeeping.h @@ -85,17 +85,21 @@ private: ReturnValue_t generateHkReport(const CommandMessage* hkMessage, uint8_t subserviceId); ReturnValue_t prepareReportingTogglingCommand(CommandMessage* command, - bool enableReporting, bool isDiagnostics, const uint8_t* tcData, - size_t tcDataLen); + object_id_t objectId, bool enableReporting, bool isDiagnostics, + const uint8_t* tcData, size_t tcDataLen); ReturnValue_t prepareStructureReportingCommand(CommandMessage* command, - bool isDiagnostics, const uint8_t* tcData, size_t tcDataLen); - ReturnValue_t prepareOneShotReportCommand(CommandMessage* command, - bool isDiagnostics, const uint8_t* tcData, size_t tcDataLen); - ReturnValue_t prepareCollectionIntervalModificationCommand( - CommandMessage* command, bool isDiagnostics, const uint8_t* tcData, + object_id_t objectId, bool isDiagnostics, const uint8_t* tcData, size_t tcDataLen); + ReturnValue_t prepareOneShotReportCommand(CommandMessage* command, + object_id_t objectId, bool isDiagnostics, const uint8_t* tcData, + size_t tcDataLen); + ReturnValue_t prepareCollectionIntervalModificationCommand( + CommandMessage* command, object_id_t objectId, bool isDiagnostics, + const uint8_t* tcData, size_t tcDataLen); void handleUnrequestedReply(CommandMessage* reply) override; + sid_t buildSid(object_id_t objectId, const uint8_t* tcData, + size_t tcDataLen); }; #endif /* FSFW_PUS_SERVICE3HOUSEKEEPINGSERVICE_H_ */ From 757d2275ea9f1f19e134e896459fa8a02c9bedcb Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Fri, 18 Sep 2020 15:06:14 +0200 Subject: [PATCH 083/192] internal bugfix --- pus/Service3Housekeeping.cpp | 16 ++++++++-------- pus/Service3Housekeeping.h | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pus/Service3Housekeeping.cpp b/pus/Service3Housekeeping.cpp index 55e687cc..d8e4466b 100644 --- a/pus/Service3Housekeeping.cpp +++ b/pus/Service3Housekeeping.cpp @@ -121,7 +121,7 @@ ReturnValue_t Service3Housekeeping::prepareReportingTogglingCommand( return CommandingServiceBase::INVALID_TC; } - sid_t targetSid = buildSid(objectId, tcData, tcDataLen); + sid_t targetSid = buildSid(objectId, &tcData, &tcDataLen); HousekeepingMessage::setToggleReportingCommand(command, targetSid, enableReporting, isDiagnostics); return HasReturnvaluesIF::RETURN_OK; @@ -135,7 +135,7 @@ ReturnValue_t Service3Housekeeping::prepareStructureReportingCommand( return CommandingServiceBase::INVALID_TC; } - sid_t targetSid = buildSid(objectId, tcData, tcDataLen); + sid_t targetSid = buildSid(objectId, &tcData, &tcDataLen); HousekeepingMessage::setStructureReportingCommand(command, targetSid, isDiagnostics); return HasReturnvaluesIF::RETURN_OK; @@ -149,7 +149,7 @@ ReturnValue_t Service3Housekeeping::prepareOneShotReportCommand( return CommandingServiceBase::INVALID_TC; } - sid_t targetSid = buildSid(objectId, tcData, tcDataLen); + sid_t targetSid = buildSid(objectId, &tcData, &tcDataLen); HousekeepingMessage::setOneShotReportCommand(command, targetSid, isDiagnostics); return HasReturnvaluesIF::RETURN_OK; @@ -163,7 +163,7 @@ ReturnValue_t Service3Housekeeping::prepareCollectionIntervalModificationCommand return CommandingServiceBase::INVALID_TC; } - sid_t targetSid = buildSid(objectId, tcData, tcDataLen); + sid_t targetSid = buildSid(objectId, &tcData, &tcDataLen); float newCollectionInterval = 0; SerializeAdapter::deSerialize(&newCollectionInterval, &tcData, &tcDataLen, SerializeIF::Endianness::BIG); @@ -270,14 +270,14 @@ ReturnValue_t Service3Housekeeping::generateHkReport( } sid_t Service3Housekeeping::buildSid(object_id_t objectId, - const uint8_t* tcData, size_t tcDataLen) { + const uint8_t** tcData, size_t* tcDataLen) { sid_t targetSid; targetSid.objectId = objectId; // skip deserialization of object ID, was already done. - tcData += sizeof(object_id_t); - tcDataLen -= sizeof(object_id_t); + *tcData += sizeof(object_id_t); + *tcDataLen -= sizeof(object_id_t); // size check is expected to be performed beforehand! - SerializeAdapter::deSerialize(&targetSid.ownerSetId, &tcData, &tcDataLen, + SerializeAdapter::deSerialize(&targetSid.ownerSetId, tcData, tcDataLen, SerializeIF::Endianness::BIG); return targetSid; } diff --git a/pus/Service3Housekeeping.h b/pus/Service3Housekeeping.h index 1dab3153..01964bab 100644 --- a/pus/Service3Housekeeping.h +++ b/pus/Service3Housekeeping.h @@ -98,8 +98,8 @@ private: const uint8_t* tcData, size_t tcDataLen); void handleUnrequestedReply(CommandMessage* reply) override; - sid_t buildSid(object_id_t objectId, const uint8_t* tcData, - size_t tcDataLen); + sid_t buildSid(object_id_t objectId, const uint8_t** tcData, + size_t* tcDataLen); }; #endif /* FSFW_PUS_SERVICE3HOUSEKEEPINGSERVICE_H_ */ From ba56f48e8e87f0087b9c5e29846723505abe71cf Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 19 Sep 2020 01:17:43 +0200 Subject: [PATCH 084/192] huge progress on hk + testing --- datapoollocal/LocalDataPoolManager.cpp | 127 ++++++++++++++++--- datapoollocal/LocalDataPoolManager.h | 29 +++-- datapoollocal/LocalPoolDataSetBase.cpp | 16 +++ datapoollocal/LocalPoolDataSetBase.h | 15 ++- datapoollocal/LocalPoolVariable.h | 14 +- datapoollocal/LocalPoolVariable.tpp | 6 +- datapoollocal/LocalPoolVector.h | 10 +- datapoollocal/LocalPoolVector.tpp | 27 ++-- globalfunctions/PeriodicOperationDivider.cpp | 14 +- globalfunctions/PeriodicOperationDivider.h | 12 +- housekeeping/HousekeepingMessage.cpp | 2 +- housekeeping/HousekeepingMessage.h | 10 +- housekeeping/HousekeepingPacketDownlink.h | 16 +-- housekeeping/HousekeepingPacketUpdate.h | 6 +- housekeeping/HousekeepingSetPacket.h | 13 ++ pus/Service3Housekeeping.cpp | 2 +- 16 files changed, 237 insertions(+), 82 deletions(-) create mode 100644 housekeeping/HousekeepingSetPacket.h diff --git a/datapoollocal/LocalDataPoolManager.cpp b/datapoollocal/LocalDataPoolManager.cpp index 77851904..17c7ad1d 100644 --- a/datapoollocal/LocalDataPoolManager.cpp +++ b/datapoollocal/LocalDataPoolManager.cpp @@ -35,7 +35,7 @@ LocalDataPoolManager::LocalDataPoolManager(HasLocalDataPoolIF* owner, AcceptsHkPacketsIF* hkPacketReceiver = objectManager->get(defaultHkDestination); if(hkPacketReceiver != nullptr) { - defaultHkDestinationId = hkPacketReceiver->getHkQueue(); + hkDestinationId = hkPacketReceiver->getHkQueue(); } } } @@ -78,9 +78,6 @@ ReturnValue_t LocalDataPoolManager::initializeHousekeepingPoolEntriesOnce() { ReturnValue_t LocalDataPoolManager::performHkOperation() { for(auto& hkReceiversIter: hkReceiversMap) { HkReceiver* receiver = &hkReceiversIter.second; - if(not receiver->reportingEnabled) { - return HasReturnvaluesIF::RETURN_OK; - } switch(receiver->reportingType) { case(ReportingType::PERIODIC): { @@ -118,7 +115,7 @@ ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(sid_t sid, hkReceiver.dataId.dataSetSid = sid; hkReceiver.reportingType = ReportingType::PERIODIC; hkReceiver.destinationQueue = hkReceiverObject->getHkQueue(); - hkReceiver.reportingEnabled = enableReporting; + if(not isDiagnostics) { hkReceiver.hkParameter.collectionIntervalTicks = intervalSecondsToInterval(isDiagnostics, collectionInterval * @@ -129,7 +126,13 @@ ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(sid_t sid, intervalSecondsToInterval(isDiagnostics, collectionInterval); } - hkReceiver.isDiagnostics = isDiagnostics; + LocalPoolDataSetBase* dataSet = dynamic_cast( + owner->getDataSetHandle(sid)); + if(dataSet != nullptr) { + dataSet->setReportingEnabled(enableReporting); + dataSet->setIsDiagnostic(isDiagnostics); + } + hkReceiver.intervalCounter = 1; hkReceiversMap.emplace(packetDestination, hkReceiver); @@ -139,16 +142,51 @@ ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(sid_t sid, ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage( CommandMessage* message) { Command_t command = message->getCommand(); + sid_t sid = HousekeepingMessage::getSid(message); switch(command) { + case(HousekeepingMessage::ENABLE_PERIODIC_DIAGNOSTICS_GENERATION): + return togglePeriodicGeneration(sid, true, true); + case(HousekeepingMessage::DISABLE_PERIODIC_DIAGNOSTICS_GENERATION): + return togglePeriodicGeneration(sid, false, true); + case(HousekeepingMessage::ENABLE_PERIODIC_HK_REPORT_GENERATION): + return togglePeriodicGeneration(sid, true, false); + case(HousekeepingMessage::DISABLE_PERIODIC_HK_REPORT_GENERATION): + return togglePeriodicGeneration(sid, false, false); + case(HousekeepingMessage::REPORT_DIAGNOSTICS_REPORT_STRUCTURES): case(HousekeepingMessage::REPORT_HK_REPORT_STRUCTURES): - //return generateSetStructurePacket(message->getSid()); + return generateSetStructurePacket(sid); + + case(HousekeepingMessage::MODIFY_DIAGNOSTICS_REPORT_COLLECTION_INTERVAL): + case(HousekeepingMessage::MODIFY_PARAMETER_REPORT_COLLECTION_INTERVAL): { + float newCollIntvl = 0; + HousekeepingMessage::getCollectionIntervalModificationCommand(message, + &newCollIntvl); + if(command == HousekeepingMessage:: + MODIFY_DIAGNOSTICS_REPORT_COLLECTION_INTERVAL) { + return changeCollectionInterval(sid, newCollIntvl, true); + } + else { + return changeCollectionInterval(sid, newCollIntvl, false); + } + } + case(HousekeepingMessage::GENERATE_ONE_PARAMETER_REPORT): - return generateHousekeepingPacket(HousekeepingMessage::getSid(message), - false, true); - case(HousekeepingMessage::GENERATE_ONE_DIAGNOSTICS_REPORT): - return generateHousekeepingPacket(HousekeepingMessage::getSid(message), - true, true); + case(HousekeepingMessage::GENERATE_ONE_DIAGNOSTICS_REPORT): { + LocalPoolDataSetBase* dataSet = dynamic_cast( + owner->getDataSetHandle(sid)); + if(command == HousekeepingMessage::GENERATE_ONE_PARAMETER_REPORT + and dataSet->getIsDiagnostics()) { + return WRONG_HK_PACKET_TYPE; + } + else if(command == HousekeepingMessage::GENERATE_ONE_DIAGNOSTICS_REPORT + and not dataSet->getIsDiagnostics()) { + return WRONG_HK_PACKET_TYPE; + } + return generateHousekeepingPacket(HousekeepingMessage::getSid(message), + dataSet, true); + } + default: return CommandMessageIF::UNKNOWN_COMMAND; } @@ -175,17 +213,17 @@ const HasLocalDataPoolIF* LocalDataPoolManager::getOwner() const { } ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid, - bool isDiagnostics, bool forDownlink, MessageQueueId_t destination) { - LocalPoolDataSetBase* dataSetToSerialize = - dynamic_cast(owner->getDataSetHandle(sid)); - if(dataSetToSerialize == nullptr) { + LocalPoolDataSetBase* dataSet, bool forDownlink, + MessageQueueId_t destination) { + if(dataSet == nullptr) { + // Configuration error. sif::warning << "HousekeepingManager::generateHousekeepingPacket:" " Set ID not found or dataset not assigned!" << std::endl; return HasReturnvaluesIF::RETURN_FAILED; } store_address_t storeId; - HousekeepingPacketDownlink hkPacket(sid, dataSetToSerialize); + HousekeepingPacketDownlink hkPacket(sid, dataSet); size_t serializedSize = 0; ReturnValue_t result = serializeHkPacketIntoStore(hkPacket, storeId, forDownlink, &serializedSize); @@ -195,7 +233,7 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid, // and now we set a HK message and send it the HK packet destination. CommandMessage hkMessage; - if(isDiagnostics) { + if(dataSet->getIsDiagnostics()) { HousekeepingMessage::setHkDiagnosticsReply(&hkMessage, sid, storeId); } else { @@ -206,11 +244,11 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid, return QUEUE_OR_DESTINATION_NOT_SET; } if(destination == MessageQueueIF::NO_QUEUE) { - if(defaultHkDestinationId == MessageQueueIF::NO_QUEUE) { + if(hkDestinationId == MessageQueueIF::NO_QUEUE) { // error, all destinations invalid return HasReturnvaluesIF::RETURN_FAILED; } - destination = defaultHkDestinationId; + destination = hkDestinationId; } return hkQueue->sendMessage(destination, &hkMessage); @@ -273,8 +311,15 @@ void LocalDataPoolManager::setNonDiagnosticIntervalFactor( void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver* receiver) { if(receiver->intervalCounter >= receiver->hkParameter.collectionIntervalTicks) { + sid_t sid = receiver->dataId.dataSetSid; + LocalPoolDataSetBase* dataSet = dynamic_cast( + owner->getDataSetHandle(sid)); + if(not dataSet->getReportingEnabled()) { + return; + } + ReturnValue_t result = generateHousekeepingPacket( - receiver->dataId.dataSetSid, receiver->isDiagnostics, true); + sid, dataSet, true); if(result != HasReturnvaluesIF::RETURN_OK) { // configuration error sif::debug << "LocalDataPoolManager::performHkOperation:" @@ -312,3 +357,43 @@ float LocalDataPoolManager::intervalToIntervalSeconds(bool isDiagnostics, regularMinimumInterval); } } + +ReturnValue_t LocalDataPoolManager::togglePeriodicGeneration(sid_t sid, + bool enable, bool isDiagnostics) { + LocalPoolDataSetBase* dataSet = dynamic_cast( + owner->getDataSetHandle(sid)); + if((dataSet->getIsDiagnostics() and not isDiagnostics) or + (not dataSet->getIsDiagnostics() and isDiagnostics)) { + return WRONG_HK_PACKET_TYPE; + } + + if((dataSet->getReportingEnabled() and enable) or + (not dataSet->getReportingEnabled() and not enable)) { + return REPORTING_STATUS_UNCHANGED; + } + + dataSet->setReportingEnabled(enable); + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t LocalDataPoolManager::changeCollectionInterval(sid_t sid, + float newCollectionInterval, bool isDiagnostics) { + LocalPoolDataSetBase* dataSet = dynamic_cast( + owner->getDataSetHandle(sid)); + bool targetIsDiagnostics = dataSet->getIsDiagnostics(); + if((targetIsDiagnostics and not isDiagnostics) or + (not targetIsDiagnostics and isDiagnostics)) { + return WRONG_HK_PACKET_TYPE; + } + + for(auto& receiver: hkReceiversMap) { + if(receiver.second.reportingType != ReportingType::PERIODIC) { + continue; + } + + uint32_t newInterval = intervalSecondsToInterval(isDiagnostics, + newCollectionInterval); + receiver.second.hkParameter.collectionIntervalTicks = newInterval; + } + return HasReturnvaluesIF::RETURN_OK; +} diff --git a/datapoollocal/LocalDataPoolManager.h b/datapoollocal/LocalDataPoolManager.h index 1ab08903..559b8cc2 100644 --- a/datapoollocal/LocalDataPoolManager.h +++ b/datapoollocal/LocalDataPoolManager.h @@ -23,7 +23,7 @@ class LocalDataSetBase; /** - * @brief This class is the managing instance for local data pool. + * @brief This class is the managing instance for the local data pool. * @details * The actual data pool structure is a member of this class. Any class which * has a local data pool shall have this class as a member and implement @@ -37,7 +37,7 @@ class LocalDataSetBase; * value is stored. The helper classes offer a read() and commit() interface * through the PoolVariableIF which is used to read and update values. * Each pool entry has a valid state too. - * @author R. Mueller + * @author R. Mueller */ class LocalDataPoolManager { template @@ -49,11 +49,13 @@ class LocalDataPoolManager { public: static constexpr uint8_t INTERFACE_ID = CLASS_ID::HOUSEKEEPING_MANAGER; - static constexpr ReturnValue_t POOL_ENTRY_NOT_FOUND = MAKE_RETURN_CODE(0x0); - static constexpr ReturnValue_t POOL_ENTRY_TYPE_CONFLICT = MAKE_RETURN_CODE(0x1); + static constexpr ReturnValue_t POOL_ENTRY_NOT_FOUND = MAKE_RETURN_CODE(0x00); + static constexpr ReturnValue_t POOL_ENTRY_TYPE_CONFLICT = MAKE_RETURN_CODE(0x01); - static constexpr ReturnValue_t QUEUE_OR_DESTINATION_NOT_SET = MAKE_RETURN_CODE(0x2); + static constexpr ReturnValue_t QUEUE_OR_DESTINATION_NOT_SET = MAKE_RETURN_CODE(0x02); + static constexpr ReturnValue_t WRONG_HK_PACKET_TYPE = MAKE_RETURN_CODE(0x03); + static constexpr ReturnValue_t REPORTING_STATUS_UNCHANGED = MAKE_RETURN_CODE(0x04); /** * This constructor is used by a class which wants to implement * a personal local data pool. The queueToUse can be supplied if it @@ -110,8 +112,8 @@ public: * @return */ ReturnValue_t generateHousekeepingPacket(sid_t sid, - bool isDiagnostics, bool forDownlink, - MessageQueueId_t destination = MessageQueueIF::NO_QUEUE); + LocalPoolDataSetBase* dataSet, bool forDownlink, + MessageQueueId_t destination = MessageQueueIF::NO_QUEUE); ReturnValue_t generateSetStructurePacket(sid_t sid); ReturnValue_t handleHousekeepingMessage(CommandMessage* message); @@ -169,7 +171,7 @@ private: /** Default receiver for periodic HK packets */ static object_id_t defaultHkDestination; - MessageQueueId_t defaultHkDestinationId = MessageQueueIF::NO_QUEUE; + MessageQueueId_t hkDestinationId = MessageQueueIF::NO_QUEUE; /** The data pool manager will keep an internal map of HK receivers. */ struct HkReceiver { @@ -185,8 +187,11 @@ private: DataId dataId; ReportingType reportingType = ReportingType::PERIODIC; + // SHOULDDO: it would be nice to also have the object ID instead of + // a queue (or in addition).. but the FSFW is not ready for that yet. + // Also, an object can have multiple queues. MessageQueueId_t destinationQueue = MessageQueueIF::NO_QUEUE; - bool reportingEnabled = true; + /** Different members of this union will be used depending on reporting type */ union HkParameter { @@ -196,7 +201,6 @@ private: bool hkDataChanged; }; HkParameter hkParameter; - bool isDiagnostics; /** General purpose counter which is used for periodic generation. */ uint32_t intervalCounter; }; @@ -245,7 +249,6 @@ private: template ReturnValue_t fetchPoolEntry(lp_id_t localPoolId, PoolEntry **poolEntry); - void setMinimalSamplingFrequency(float frequencySeconds); ReturnValue_t serializeHkPacketIntoStore( HousekeepingPacketDownlink& hkPacket, store_address_t& storeId, bool forDownlink, size_t* serializedSize); @@ -256,6 +259,10 @@ private: uint32_t collectionInterval); void performPeriodicHkGeneration(HkReceiver* hkReceiver); + ReturnValue_t togglePeriodicGeneration(sid_t sid, bool enable, + bool isDiagnostics); + ReturnValue_t changeCollectionInterval(sid_t sid, + float newCollectionInterval, bool isDiagnostics); }; diff --git a/datapoollocal/LocalPoolDataSetBase.cpp b/datapoollocal/LocalPoolDataSetBase.cpp index 859f1f2c..362e8981 100644 --- a/datapoollocal/LocalPoolDataSetBase.cpp +++ b/datapoollocal/LocalPoolDataSetBase.cpp @@ -175,6 +175,22 @@ void LocalPoolDataSetBase::bitSetter(uint8_t* byte, uint8_t position) const { *byte |= 1 << shiftNumber; } +void LocalPoolDataSetBase::setIsDiagnostic(bool isDiagnostics) { + this->isDiagnostics = isDiagnostics; +} + +bool LocalPoolDataSetBase::getIsDiagnostics() const { + return isDiagnostics; +} + +void LocalPoolDataSetBase::setReportingEnabled(bool reportingEnabled) { + this->reportingEnabled = reportingEnabled; +} + +bool LocalPoolDataSetBase::getReportingEnabled() const { + return reportingEnabled; +} + bool LocalPoolDataSetBase::bitGetter(const uint8_t* byte, uint8_t position) const { if(position > 7) { diff --git a/datapoollocal/LocalPoolDataSetBase.h b/datapoollocal/LocalPoolDataSetBase.h index 17c20d4f..69c71d5a 100644 --- a/datapoollocal/LocalPoolDataSetBase.h +++ b/datapoollocal/LocalPoolDataSetBase.h @@ -32,6 +32,7 @@ class LocalDataPoolManager; * @ingroup data_pool */ class LocalPoolDataSetBase: public PoolDataSetBase { + friend class LocalDataPoolManager; public: /** * @brief Constructor for the creator of local pool data. @@ -97,11 +98,23 @@ public: * If this is true, all contained datasets will also be set recursively. */ void setValidity(bool valid, bool setEntriesRecursively); - bool isValid() const override; + void setIsDiagnostic(bool diagnostics); + bool getIsDiagnostics() const; + protected: sid_t sid; + + bool isDiagnostics = false; + + void setReportingEnabled(bool enabled); + bool getReportingEnabled() const; + /** + * Used for periodic generation. + */ + bool reportingEnabled = false; + /** * If the valid state of a dataset is always relevant to the whole * data set we can use this flag. diff --git a/datapoollocal/LocalPoolVariable.h b/datapoollocal/LocalPoolVariable.h index 7107bffe..6047342e 100644 --- a/datapoollocal/LocalPoolVariable.h +++ b/datapoollocal/LocalPoolVariable.h @@ -38,13 +38,14 @@ public: * @param poolId ID of the local pool entry. * @param hkOwner Pointer of the owner. This will generally be the calling * class itself which passes "this". - * @param setReadWriteMode Specify the read-write mode of the pool variable. * @param dataSet The data set in which the variable shall register itself. * If nullptr, the variable is not registered. + * @param setReadWriteMode Specify the read-write mode of the pool variable. + */ LocalPoolVar(lp_id_t poolId, HasLocalDataPoolIF* hkOwner, - pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE, - DataSetIF* dataSet = nullptr); + DataSetIF* dataSet = nullptr, + pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE); /** * This constructor is used by data users like controllers to have @@ -58,13 +59,14 @@ public: * the pool variable in that dataset directly. * @param poolId ID of the local pool entry. * @param hkOwner object ID of the pool owner. - * @param setReadWriteMode Specify the read-write mode of the pool variable. * @param dataSet The data set in which the variable shall register itself. * If nullptr, the variable is not registered. + * @param setReadWriteMode Specify the read-write mode of the pool variable. + * */ LocalPoolVar(lp_id_t poolId, object_id_t poolOwner, - pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE, - DataSetIF* dataSet = nullptr); + DataSetIF* dataSet = nullptr, + pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE); virtual~ LocalPoolVar() {}; diff --git a/datapoollocal/LocalPoolVariable.tpp b/datapoollocal/LocalPoolVariable.tpp index 6e6f27aa..09d10acc 100644 --- a/datapoollocal/LocalPoolVariable.tpp +++ b/datapoollocal/LocalPoolVariable.tpp @@ -7,8 +7,8 @@ template inline LocalPoolVar::LocalPoolVar(lp_id_t poolId, - HasLocalDataPoolIF* hkOwner, pool_rwm_t setReadWriteMode, - DataSetIF* dataSet): + HasLocalDataPoolIF* hkOwner, DataSetIF* dataSet, + pool_rwm_t setReadWriteMode): localPoolId(poolId),readWriteMode(setReadWriteMode) { if(poolId == PoolVariableIF::NO_PARAMETER) { sif::warning << "LocalPoolVector: 0 passed as pool ID, which is the " @@ -27,7 +27,7 @@ inline LocalPoolVar::LocalPoolVar(lp_id_t poolId, template inline LocalPoolVar::LocalPoolVar(lp_id_t poolId, object_id_t poolOwner, - pool_rwm_t setReadWriteMode, DataSetIF *dataSet): + DataSetIF *dataSet, pool_rwm_t setReadWriteMode): readWriteMode(setReadWriteMode) { if(poolId == PoolVariableIF::NO_PARAMETER) { sif::warning << "LocalPoolVector: 0 passed as pool ID, which is the " diff --git a/datapoollocal/LocalPoolVector.h b/datapoollocal/LocalPoolVector.h index 86705bb0..69df192c 100644 --- a/datapoollocal/LocalPoolVector.h +++ b/datapoollocal/LocalPoolVector.h @@ -47,8 +47,9 @@ public: * If nullptr, the variable is not registered. */ LocalPoolVector(lp_id_t poolId, HasLocalDataPoolIF* hkOwner, - pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE, - DataSetIF* dataSet = nullptr); + DataSetIF* dataSet = nullptr, + pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE + ); /** * This constructor is used by data users like controllers to have @@ -65,8 +66,9 @@ public: * If nullptr, the variable is not registered. */ LocalPoolVector(lp_id_t poolId, object_id_t poolOwner, - pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE, - DataSetIF* dataSet = nullptr); + DataSetIF* dataSet = nullptr, + pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE + ); /** * @brief This is the local copy of the data pool entry. diff --git a/datapoollocal/LocalPoolVector.tpp b/datapoollocal/LocalPoolVector.tpp index 7c3d2c1e..2aa6fbb5 100644 --- a/datapoollocal/LocalPoolVector.tpp +++ b/datapoollocal/LocalPoolVector.tpp @@ -7,14 +7,14 @@ template inline LocalPoolVector::LocalPoolVector(lp_id_t poolId, - HasLocalDataPoolIF* hkOwner, pool_rwm_t setReadWriteMode, - DataSetIF* dataSet) : + HasLocalDataPoolIF* hkOwner, DataSetIF* dataSet, + pool_rwm_t setReadWriteMode): localPoolId(poolId), valid(false), readWriteMode(setReadWriteMode) { if(poolId == PoolVariableIF::NO_PARAMETER) { - sif::warning << "LocalPoolVector: 0 passed as pool ID, which is the " - "NO_PARAMETER value!" << std::endl; + sif::warning << "LocalPoolVector: PoolVariableIF::NO_PARAMETER passed " + << "as pool ID, which is the NO_PARAMETER value!" << std::endl; } - memset(this->value, 0, vectorSize * sizeof(T)); + std::memset(this->value, 0, vectorSize * sizeof(T)); hkManager = hkOwner->getHkManagerHandle(); if (dataSet != nullptr) { dataSet->registerVariable(this); @@ -23,17 +23,18 @@ inline LocalPoolVector::LocalPoolVector(lp_id_t poolId, template inline LocalPoolVector::LocalPoolVector(lp_id_t poolId, - object_id_t poolOwner, pool_rwm_t setReadWriteMode, DataSetIF *dataSet): - readWriteMode(readWriteMode) { + object_id_t poolOwner, DataSetIF *dataSet, pool_rwm_t setReadWriteMode): + readWriteMode(setReadWriteMode) { if(poolId == PoolVariableIF::NO_PARAMETER) { - sif::warning << "LocalPoolVector: 0 passed as pool ID, which is the " - "NO_PARAMETER value!" << std::endl; + sif::warning << "LocalPoolVector: PoolVariableIF::NO_PARAMETER passed " + << "as pool ID, which is the NO_PARAMETER value!" << std::endl; } HasLocalDataPoolIF* hkOwner = objectManager->get(poolOwner); if(hkOwner == nullptr) { - sif::error << "LocalPoolVariable: The supplied pool owner did not implement" - "the correct interface HasHkPoolParametersIF!" << std::endl; + sif::error << "LocalPoolVariable: The supplied pool owner did not " + << "implement the correct interface HasHkPoolParametersIF!" + << std::endl; return; } hkManager = hkOwner->getHkManagerHandle(); @@ -67,7 +68,7 @@ inline ReturnValue_t LocalPoolVector::readWithoutLock() { std::dec << " failed." << std::endl; return result; } - memcpy(this->value, poolEntry->address, poolEntry->getByteSize()); + std::memcpy(this->value, poolEntry->address, poolEntry->getByteSize()); this->valid = poolEntry->valid; return RETURN_OK; } @@ -96,7 +97,7 @@ inline ReturnValue_t LocalPoolVector::commitWithoutLock() { std::dec << " failed.\n" << std::flush; return result; } - memcpy(poolEntry->address, this->value, poolEntry->getByteSize()); + std::memcpy(poolEntry->address, this->value, poolEntry->getByteSize()); poolEntry->valid = this->valid; return RETURN_OK; } diff --git a/globalfunctions/PeriodicOperationDivider.cpp b/globalfunctions/PeriodicOperationDivider.cpp index ad3b8bbd..28e98feb 100644 --- a/globalfunctions/PeriodicOperationDivider.cpp +++ b/globalfunctions/PeriodicOperationDivider.cpp @@ -7,16 +7,26 @@ PeriodicOperationDivider::PeriodicOperationDivider(uint32_t divider, } bool PeriodicOperationDivider::checkAndIncrement() { - if(counter >= divider) { + bool opNecessary = check(); + if(opNecessary) { if(resetAutomatically) { counter = 0; } - return true; + return opNecessary; } counter ++; + return opNecessary; +} + +bool PeriodicOperationDivider::check() { + if(counter >= divider) { + return true; + } return false; } + + void PeriodicOperationDivider::resetCounter() { counter = 0; } diff --git a/globalfunctions/PeriodicOperationDivider.h b/globalfunctions/PeriodicOperationDivider.h index dd970fb8..7f7fb469 100644 --- a/globalfunctions/PeriodicOperationDivider.h +++ b/globalfunctions/PeriodicOperationDivider.h @@ -21,17 +21,27 @@ public: */ PeriodicOperationDivider(uint32_t divider, bool resetAutomatically = true); + /** * Check whether operation is necessary. * If an operation is necessary and the class has been * configured to be reset automatically, the counter will be reset. - * If not, the counter will be incremented. + * * @return * -@c true if the counter is larger or equal to the divider * -@c false otherwise */ bool checkAndIncrement(); + /** + * Checks whether an operation is necessary. + * This function will not increment the counter! + * @return + * -@c true if the counter is larger or equal to the divider + * -@c false otherwise + */ + bool check(); + /** * Can be used to reset the counter to 0 manually. */ diff --git a/housekeeping/HousekeepingMessage.cpp b/housekeeping/HousekeepingMessage.cpp index 65ba8c94..a3aab03a 100644 --- a/housekeeping/HousekeepingMessage.cpp +++ b/housekeeping/HousekeepingMessage.cpp @@ -39,7 +39,7 @@ void HousekeepingMessage::setToggleReportingCommand(CommandMessage *message, } else { if(enableReporting) { - message->setCommand(ENABLE_PERIODIC_HK_GENERATION); + message->setCommand(ENABLE_PERIODIC_HK_REPORT_GENERATION); } else { message->setCommand(DISABLE_PERIODIC_HK_REPORT_GENERATION); diff --git a/housekeeping/HousekeepingMessage.h b/housekeeping/HousekeepingMessage.h index 81fa2f02..6a3ca616 100644 --- a/housekeeping/HousekeepingMessage.h +++ b/housekeeping/HousekeepingMessage.h @@ -33,6 +33,14 @@ union sid_t { bool notSet() const { return raw == INVALID_ADDRESS; } + + bool operator==(const sid_t& other) const { + return raw == other.raw; + } + + bool operator!=(const sid_t& other) const { + return not (raw == other.raw); + } }; @@ -57,7 +65,7 @@ public: static constexpr uint8_t MESSAGE_ID = messagetypes::HOUSEKEEPING; - static constexpr Command_t ENABLE_PERIODIC_HK_GENERATION = + static constexpr Command_t ENABLE_PERIODIC_HK_REPORT_GENERATION = MAKE_COMMAND_ID(5); static constexpr Command_t DISABLE_PERIODIC_HK_REPORT_GENERATION = MAKE_COMMAND_ID(6); diff --git a/housekeeping/HousekeepingPacketDownlink.h b/housekeeping/HousekeepingPacketDownlink.h index 0be1551d..ae0cc988 100644 --- a/housekeeping/HousekeepingPacketDownlink.h +++ b/housekeeping/HousekeepingPacketDownlink.h @@ -14,13 +14,8 @@ */ class HousekeepingPacketDownlink: public SerialLinkedListAdapter { public: - HousekeepingPacketDownlink(sid_t sid, /*bool reportingStatus, - float collectionInterval, uint8_t numberOfParameters, */ - LocalPoolDataSetBase* dataSetPtr): - sourceId(sid.objectId), setId(sid.ownerSetId), - /*reportingStatus(reportingStatus), - collectionInterval(collectionInterval), - numberOfParameters(numberOfParameters), */hkData(dataSetPtr) { + HousekeepingPacketDownlink(sid_t sid, LocalPoolDataSetBase* dataSetPtr): + sourceId(sid.objectId), setId(sid.ownerSetId), hkData(dataSetPtr) { setLinks(); } @@ -29,17 +24,10 @@ private: setStart(&sourceId); sourceId.setNext(&setId); setId.setNext(&hkData); - //setId.setNext(&reportingStatus); - //reportingStatus.setNext(&collectionInterval); - //collectionInterval.setNext(&numberOfParameters); - //numberOfParameters.setNext(&hkData); } SerializeElement sourceId; SerializeElement setId; - //SerializeElement reportingStatus; - //SerializeElement collectionInterval; - //SerializeElement numberOfParameters; LinkedElement hkData; }; diff --git a/housekeeping/HousekeepingPacketUpdate.h b/housekeeping/HousekeepingPacketUpdate.h index e7b644f5..eebdc11c 100644 --- a/housekeeping/HousekeepingPacketUpdate.h +++ b/housekeeping/HousekeepingPacketUpdate.h @@ -1,9 +1,9 @@ #ifndef FRAMEWORK_HOUSEKEEPING_HOUSEKEEPINGPACKETUPDATE_H_ #define FRAMEWORK_HOUSEKEEPING_HOUSEKEEPINGPACKETUPDATE_H_ -#include -#include -#include +#include "../serialize/SerialBufferAdapter.h" +#include "../serialize/SerialLinkedListAdapter.h" +#include "../datapoollocal/LocalPoolDataSetBase.h" /** * @brief This helper class will be used to serialize and deserialize diff --git a/housekeeping/HousekeepingSetPacket.h b/housekeeping/HousekeepingSetPacket.h new file mode 100644 index 00000000..9a717420 --- /dev/null +++ b/housekeeping/HousekeepingSetPacket.h @@ -0,0 +1,13 @@ +#ifndef FSFW_HOUSEKEEPING_HOUSEKEEPINGSETPACKET_H_ +#define FSFW_HOUSEKEEPING_HOUSEKEEPINGSETPACKET_H_ + +#include "../serialize/SerialLinkedListAdapter.h" + +class HousekeepingSetPacket: public SerialLinkedListAdapter { + + +}; + + + +#endif /* FSFW_HOUSEKEEPING_HOUSEKEEPINGSETPACKET_H_ */ diff --git a/pus/Service3Housekeeping.cpp b/pus/Service3Housekeeping.cpp index d8e4466b..0d63a4e2 100644 --- a/pus/Service3Housekeeping.cpp +++ b/pus/Service3Housekeeping.cpp @@ -116,7 +116,7 @@ ReturnValue_t Service3Housekeeping::prepareReportingTogglingCommand( CommandMessage *command, object_id_t objectId, bool enableReporting, bool isDiagnostics, const uint8_t* tcData, size_t tcDataLen) { - if(tcDataLen < sizeof(object_id_t)) { + if(tcDataLen < sizeof(sid_t)) { // TC data should consist of object ID and set ID. return CommandingServiceBase::INVALID_TC; } From 9ecbc8199e458e6c56a91c4de91b6217d30d9ea3 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 19 Sep 2020 02:46:29 +0200 Subject: [PATCH 085/192] added periodic helper --- datapoollocal/LocalDataPoolManager.cpp | 92 ++++++++++++--------- datapoollocal/LocalDataPoolManager.h | 3 +- datapoollocal/LocalPoolDataSetBase.cpp | 3 + datapoollocal/LocalPoolDataSetBase.h | 15 ++-- housekeeping/HousekeepingSetPacket.h | 49 ++++++++++- housekeeping/PeriodicHousekeepingHelper.cpp | 47 +++++++++++ housekeeping/PeriodicHousekeepingHelper.h | 35 ++++++++ 7 files changed, 195 insertions(+), 49 deletions(-) create mode 100644 housekeeping/PeriodicHousekeepingHelper.cpp create mode 100644 housekeeping/PeriodicHousekeepingHelper.h diff --git a/datapoollocal/LocalDataPoolManager.cpp b/datapoollocal/LocalDataPoolManager.cpp index 17c7ad1d..48d57a91 100644 --- a/datapoollocal/LocalDataPoolManager.cpp +++ b/datapoollocal/LocalDataPoolManager.cpp @@ -1,3 +1,4 @@ +#include #include "LocalDataPoolManager.h" #include "LocalPoolDataSetBase.h" #include "../housekeeping/AcceptsHkPacketsIF.h" @@ -155,8 +156,8 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage( case(HousekeepingMessage::REPORT_DIAGNOSTICS_REPORT_STRUCTURES): case(HousekeepingMessage::REPORT_HK_REPORT_STRUCTURES): - return generateSetStructurePacket(sid); - + //return generateSetStructurePacket(sid, ); + return HasReturnvaluesIF::RETURN_OK; case(HousekeepingMessage::MODIFY_DIAGNOSTICS_REPORT_COLLECTION_INTERVAL): case(HousekeepingMessage::MODIFY_PARAMETER_REPORT_COLLECTION_INTERVAL): { float newCollIntvl = 0; @@ -274,40 +275,11 @@ ReturnValue_t LocalDataPoolManager::serializeHkPacketIntoStore( SerializeIF::Endianness::MACHINE); } -ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid) { - LocalPoolDataSetBase* dataSet = dynamic_cast( - owner->getDataSetHandle(sid)); - if(dataSet == nullptr) { - sif::warning << "HousekeepingManager::generateHousekeepingPacket:" - " Set ID not found" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - size_t expectedSize = dataSet->getFillCount() * sizeof(lp_id_t); - uint8_t* storePtr = nullptr; - store_address_t storeId; - ReturnValue_t result = ipcStore->getFreeElement(&storeId, - expectedSize,&storePtr); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "HousekeepingManager::generateHousekeepingPacket: " - "Could not get free element from IPC store." << std::endl; - return result; - } - size_t size = 0; - result = dataSet->serializeLocalPoolIds(&storePtr, &size, - expectedSize, SerializeIF::Endianness::BIG); - if(expectedSize != size) { - sif::error << "HousekeepingManager::generateSetStructurePacket: " - "Expected size is not equal to serialized size" << std::endl; - } - return result; -} - void LocalDataPoolManager::setNonDiagnosticIntervalFactor( uint8_t nonDiagInvlFactor) { this->nonDiagnosticIntervalFactor = nonDiagInvlFactor; } - void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver* receiver) { if(receiver->intervalCounter >= receiver->hkParameter.collectionIntervalTicks) { @@ -386,14 +358,56 @@ ReturnValue_t LocalDataPoolManager::changeCollectionInterval(sid_t sid, return WRONG_HK_PACKET_TYPE; } - for(auto& receiver: hkReceiversMap) { - if(receiver.second.reportingType != ReportingType::PERIODIC) { - continue; - } - - uint32_t newInterval = intervalSecondsToInterval(isDiagnostics, - newCollectionInterval); - receiver.second.hkParameter.collectionIntervalTicks = newInterval; + if(dataSet->periodicHelper == nullptr) { + // config error + return HasReturnvaluesIF::RETURN_FAILED; } + + dataSet->periodicHelper->changeCollectionInterval(newCollectionInterval); +// for(auto& receiver: hkReceiversMap) { +// if(receiver.second.reportingType != ReportingType::PERIODIC) { +// continue; +// } +// +// uint32_t newInterval = intervalSecondsToInterval(isDiagnostics, +// newCollectionInterval); +// receiver.second.hkParameter.collectionIntervalTicks = newInterval; +// } return HasReturnvaluesIF::RETURN_OK; } + +ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid, + float collectionInterval, bool isDiagnostics) { + LocalPoolDataSetBase* dataSet = dynamic_cast( + owner->getDataSetHandle(sid)); + if(dataSet == nullptr) { + sif::warning << "HousekeepingManager::generateHousekeepingPacket:" + " Set ID not found" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + + bool valid = dataSet->isValid(); + bool targetIsDiagnostics = dataSet->getIsDiagnostics(); + bool reportingEnabled = dataSet->getReportingEnabled(); + + size_t expectedSize = dataSet->getFillCount() * sizeof(lp_id_t); + uint8_t* storePtr = nullptr; + store_address_t storeId; + HousekeepingSetPacket setPacket = HousekeepingSetPacket(sid, reportingEnabled, + valid, collectionInterval, dataSet); + ReturnValue_t result = ipcStore->getFreeElement(&storeId, + expectedSize,&storePtr); + if(result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "HousekeepingManager::generateHousekeepingPacket: " + "Could not get free element from IPC store." << std::endl; + return result; + } + size_t size = 0; + result = dataSet->serializeLocalPoolIds(&storePtr, &size, + expectedSize, SerializeIF::Endianness::BIG); + if(expectedSize != size) { + sif::error << "HousekeepingManager::generateSetStructurePacket: " + "Expected size is not equal to serialized size" << std::endl; + } + return result; +} diff --git a/datapoollocal/LocalDataPoolManager.h b/datapoollocal/LocalDataPoolManager.h index 559b8cc2..2a5c68b5 100644 --- a/datapoollocal/LocalDataPoolManager.h +++ b/datapoollocal/LocalDataPoolManager.h @@ -114,7 +114,6 @@ public: ReturnValue_t generateHousekeepingPacket(sid_t sid, LocalPoolDataSetBase* dataSet, bool forDownlink, MessageQueueId_t destination = MessageQueueIF::NO_QUEUE); - ReturnValue_t generateSetStructurePacket(sid_t sid); ReturnValue_t handleHousekeepingMessage(CommandMessage* message); @@ -263,6 +262,8 @@ private: bool isDiagnostics); ReturnValue_t changeCollectionInterval(sid_t sid, float newCollectionInterval, bool isDiagnostics); + ReturnValue_t generateSetStructurePacket(sid_t sid, + float collectionInterval, bool isDiagnostics); }; diff --git a/datapoollocal/LocalPoolDataSetBase.cpp b/datapoollocal/LocalPoolDataSetBase.cpp index 362e8981..e0fc6b68 100644 --- a/datapoollocal/LocalPoolDataSetBase.cpp +++ b/datapoollocal/LocalPoolDataSetBase.cpp @@ -17,6 +17,9 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner, hkManager = hkOwner->getHkManagerHandle(); this->sid.objectId = hkOwner->getObjectId(); this->sid.ownerSetId = setId; + + // Data creators get a periodic helper for periodic HK data generation. + periodicHelper = new PeriodicHousekeepingHelper(this); } LocalPoolDataSetBase::LocalPoolDataSetBase(sid_t sid, diff --git a/datapoollocal/LocalPoolDataSetBase.h b/datapoollocal/LocalPoolDataSetBase.h index 69c71d5a..2f7db9fb 100644 --- a/datapoollocal/LocalPoolDataSetBase.h +++ b/datapoollocal/LocalPoolDataSetBase.h @@ -1,6 +1,7 @@ #ifndef FSFW_DATAPOOLLOCAL_LOCALPOOLDATASETBASE_H_ #define FSFW_DATAPOOLLOCAL_LOCALPOOLDATASETBASE_H_ +#include #include "HasLocalDataPoolIF.h" #include "../datapool/DataSetIF.h" #include "../datapool/PoolDataSetBase.h" @@ -33,6 +34,7 @@ class LocalDataPoolManager; */ class LocalPoolDataSetBase: public PoolDataSetBase { friend class LocalDataPoolManager; + friend class PeriodicHousekeepingHelper; public: /** * @brief Constructor for the creator of local pool data. @@ -100,20 +102,19 @@ public: void setValidity(bool valid, bool setEntriesRecursively); bool isValid() const override; - void setIsDiagnostic(bool diagnostics); - bool getIsDiagnostics() const; - protected: sid_t sid; bool isDiagnostics = false; + void setIsDiagnostic(bool diagnostics); + bool getIsDiagnostics() const; - void setReportingEnabled(bool enabled); - bool getReportingEnabled() const; /** * Used for periodic generation. */ - bool reportingEnabled = false; + bool reportingEnabled = false; + void setReportingEnabled(bool enabled); + bool getReportingEnabled() const; /** * If the valid state of a dataset is always relevant to the whole @@ -147,7 +148,7 @@ protected: void bitSetter(uint8_t* byte, uint8_t position) const; bool bitGetter(const uint8_t* byte, uint8_t position) const; private: - + PeriodicHousekeepingHelper* periodicHelper = nullptr; }; diff --git a/housekeeping/HousekeepingSetPacket.h b/housekeeping/HousekeepingSetPacket.h index 9a717420..007b95be 100644 --- a/housekeeping/HousekeepingSetPacket.h +++ b/housekeeping/HousekeepingSetPacket.h @@ -1,13 +1,58 @@ #ifndef FSFW_HOUSEKEEPING_HOUSEKEEPINGSETPACKET_H_ #define FSFW_HOUSEKEEPING_HOUSEKEEPINGSETPACKET_H_ +#include "../housekeeping/HousekeepingMessage.h" #include "../serialize/SerialLinkedListAdapter.h" +#include "../datapoollocal/LocalPoolDataSetBase.h" class HousekeepingSetPacket: public SerialLinkedListAdapter { +public: + HousekeepingSetPacket(sid_t sid, bool reportingEnabled, bool valid, + float collectionInterval, LocalPoolDataSetBase* dataSetPtr): + objectId(sid.objectId), setId(sid.ownerSetId), + reportingEnabled(reportingEnabled), valid(valid), + collectionIntervalSeconds(collectionInterval), dataSet(dataSetPtr) { + } + ReturnValue_t serialize(uint8_t** buffer, size_t* size, + size_t maxSize, Endianness streamEndianness) const override { + ReturnValue_t result = SerialLinkedListAdapter::serialize(buffer, size, + maxSize, streamEndianness); + if(result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + return dataSet->serializeLocalPoolIds(buffer, size ,maxSize, + streamEndianness); + } + size_t getSerializedSize() const override { + size_t linkedSize = SerialLinkedListAdapter::getSerializedSize(); + linkedSize += dataSet->getFillCount() * sizeof(lp_id_t); + return linkedSize; + } + + ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, + Endianness streamEndianness) override { + return HasReturnvaluesIF::RETURN_OK; + } + +private: + + void setLinks() { + setStart(&objectId); + objectId.setNext(&setId); + setId.setNext(&reportingEnabled); + reportingEnabled.setNext(&valid); + valid.setNext(&collectionIntervalSeconds); + collectionIntervalSeconds.setEnd(); + } + + SerializeElement objectId; + SerializeElement setId; + SerializeElement reportingEnabled; + SerializeElement valid; + SerializeElement collectionIntervalSeconds; + LocalPoolDataSetBase* dataSet; }; - - #endif /* FSFW_HOUSEKEEPING_HOUSEKEEPINGSETPACKET_H_ */ diff --git a/housekeeping/PeriodicHousekeepingHelper.cpp b/housekeeping/PeriodicHousekeepingHelper.cpp new file mode 100644 index 00000000..c2ae8126 --- /dev/null +++ b/housekeeping/PeriodicHousekeepingHelper.cpp @@ -0,0 +1,47 @@ +#include "../datapoollocal/LocalPoolDataSetBase.h" +#include "PeriodicHousekeepingHelper.h" +#include + +PeriodicHousekeepingHelper::PeriodicHousekeepingHelper( + LocalPoolDataSetBase* owner): owner(owner) {} + + +void PeriodicHousekeepingHelper::initialize(float collectionInterval, + dur_millis_t minimumPeriodicInterval, bool isDiagnostics, + uint8_t nonDiagIntervalFactor) { + this->minimumPeriodicInterval = minimumPeriodicInterval; + if(not owner->getIsDiagnostics()) { + this->minimumPeriodicInterval = this->minimumPeriodicInterval * + nonDiagIntervalFactor; + } +} + +float PeriodicHousekeepingHelper::getCollectionIntervalInSeconds() { + return intervalToIntervalSeconds(collectionIntervalTicks); +} + +bool PeriodicHousekeepingHelper::checkOpNecessary() { + if(internalTickCounter >= collectionIntervalTicks) { + internalTickCounter = 1; + return true; + } + internalTickCounter++; + return false; +} + +uint32_t PeriodicHousekeepingHelper::intervalSecondsToInterval( + float collectionIntervalSeconds) { + return std::ceil(collectionIntervalSeconds * 1000 + / minimumPeriodicInterval); +} + +float PeriodicHousekeepingHelper::intervalToIntervalSeconds( + uint32_t collectionInterval) { + return static_cast(collectionInterval * + minimumPeriodicInterval); +} + +void PeriodicHousekeepingHelper::changeCollectionInterval( + float newIntervalSeconds) { + collectionIntervalTicks = intervalSecondsToInterval(newIntervalSeconds); +} diff --git a/housekeeping/PeriodicHousekeepingHelper.h b/housekeeping/PeriodicHousekeepingHelper.h new file mode 100644 index 00000000..982e8cf6 --- /dev/null +++ b/housekeeping/PeriodicHousekeepingHelper.h @@ -0,0 +1,35 @@ +#ifndef FSFW_HOUSEKEEPING_PERIODICHOUSEKEEPINGHELPER_H_ +#define FSFW_HOUSEKEEPING_PERIODICHOUSEKEEPINGHELPER_H_ + +#include "../timemanager/Clock.h" +#include + +class LocalPoolDataSetBase; + +class PeriodicHousekeepingHelper { +public: + PeriodicHousekeepingHelper(LocalPoolDataSetBase* owner); + + void initialize(float collectionInterval, + dur_millis_t minimumPeriodicInterval, bool isDiagnostics, + uint8_t nonDiagIntervalFactor); + + void changeCollectionInterval(float newInterval); + float getCollectionIntervalInSeconds(); + bool checkOpNecessary(); +private: + LocalPoolDataSetBase* owner = nullptr; + + + uint32_t intervalSecondsToInterval(float collectionIntervalSeconds); + float intervalToIntervalSeconds(uint32_t collectionInterval); + + dur_millis_t minimumPeriodicInterval = 0; + uint32_t internalTickCounter = 1; + uint32_t collectionIntervalTicks = 0; + +}; + + + +#endif /* FSFW_HOUSEKEEPING_PERIODICHOUSEKEEPINGHELPER_H_ */ From 32c0140cc24c2aee082abf777f9bcda65b6ba43c Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 19 Sep 2020 15:58:34 +0200 Subject: [PATCH 086/192] hk stuff continued --- container/ArrayList.h | 6 +- container/FixedMap.h | 9 + datapoollocal/HasLocalDataPoolIF.h | 5 +- datapoollocal/LocalDataPoolManager.cpp | 199 ++++++++------------ datapoollocal/LocalDataPoolManager.h | 72 +++---- datapoollocal/LocalPoolDataSetBase.cpp | 48 +++-- datapoollocal/LocalPoolDataSetBase.h | 32 +++- datapoollocal/StaticLocalDataSet.h | 18 ++ devicehandlers/DeviceHandlerBase.cpp | 8 +- devicehandlers/DeviceHandlerBase.h | 11 +- housekeeping/HousekeepingMessage.h | 11 +- housekeeping/PeriodicHousekeepingHelper.cpp | 3 +- housekeeping/PeriodicHousekeepingHelper.h | 3 - pus/Service3Housekeeping.cpp | 2 +- tmtcservices/CommandingServiceBase.cpp | 8 +- tmtcservices/VerificationReporter.cpp | 8 +- 16 files changed, 235 insertions(+), 208 deletions(-) diff --git a/container/ArrayList.h b/container/ArrayList.h index bda60433..ae983171 100644 --- a/container/ArrayList.h +++ b/container/ArrayList.h @@ -140,7 +140,11 @@ public: //SHOULDDO this should be implemented as non-member bool operator!=(const typename ArrayList::Iterator& other) const { - return !(*this == other); + // POSSIBLY BUGGY ! Also this is really confusing. Why does + // the operator above use the value while this one + // dereferences itself? + //return not (value == other.value); + return !(*this == other); } }; diff --git a/container/FixedMap.h b/container/FixedMap.h index 475d4091..e5fbb3be 100644 --- a/container/FixedMap.h +++ b/container/FixedMap.h @@ -143,6 +143,15 @@ public: return HasReturnvaluesIF::RETURN_OK; } + bool empty() { + if(_size == 0) { + return true; + } + else { + return false; + } + } + bool full() { if(_size >= theMap.maxSize()) { return true; diff --git a/datapoollocal/HasLocalDataPoolIF.h b/datapoollocal/HasLocalDataPoolIF.h index 4b49ee11..e078f01e 100644 --- a/datapoollocal/HasLocalDataPoolIF.h +++ b/datapoollocal/HasLocalDataPoolIF.h @@ -9,7 +9,8 @@ #include class LocalDataPoolManager; -class DataSetIF; +class LocalPoolDataSetBase; + /** * @brief Type definition for local pool entries. */ @@ -76,7 +77,7 @@ public: * @param sid Corresponding structure ID * @return */ - virtual DataSetIF* getDataSetHandle(sid_t sid) = 0; + virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) = 0; /* These function can be implemented by pool owner, as they are required * by the housekeeping message interface */ diff --git a/datapoollocal/LocalDataPoolManager.cpp b/datapoollocal/LocalDataPoolManager.cpp index 48d57a91..f9a64777 100644 --- a/datapoollocal/LocalDataPoolManager.cpp +++ b/datapoollocal/LocalDataPoolManager.cpp @@ -56,9 +56,6 @@ ReturnValue_t LocalDataPoolManager::initialize(MessageQueueIF* queueToUse) { ReturnValue_t LocalDataPoolManager::initializeAfterTaskCreation( uint8_t nonDiagInvlFactor) { setNonDiagnosticIntervalFactor(nonDiagInvlFactor); - diagnosticMinimumInterval = owner->getPeriodicOperationFrequency(); - regularMinimumInterval = diagnosticMinimumInterval * - nonDiagnosticIntervalFactor; return initializeHousekeepingPoolEntriesOnce(); } @@ -77,12 +74,12 @@ ReturnValue_t LocalDataPoolManager::initializeHousekeepingPoolEntriesOnce() { } ReturnValue_t LocalDataPoolManager::performHkOperation() { - for(auto& hkReceiversIter: hkReceiversMap) { - HkReceiver* receiver = &hkReceiversIter.second; + for(auto& receiver: hkReceiversMap) { + //HkReceiver* receiver = &hkReceiversIter.second; - switch(receiver->reportingType) { + switch(receiver.reportingType) { case(ReportingType::PERIODIC): { - if(receiver->dataId.dataSetSid.notSet()) { + if(receiver.dataType == DataType::LOCAL_POOL_VARIABLE) { // Periodic packets shall only be generated from datasets. continue; } @@ -113,30 +110,19 @@ ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(sid_t sid, } struct HkReceiver hkReceiver; - hkReceiver.dataId.dataSetSid = sid; + hkReceiver.dataId.sid = sid; hkReceiver.reportingType = ReportingType::PERIODIC; hkReceiver.destinationQueue = hkReceiverObject->getHkQueue(); - if(not isDiagnostics) { - hkReceiver.hkParameter.collectionIntervalTicks = - intervalSecondsToInterval(isDiagnostics, collectionInterval * - nonDiagnosticIntervalFactor); - } - else { - hkReceiver.hkParameter.collectionIntervalTicks = - intervalSecondsToInterval(isDiagnostics, collectionInterval); - } - - LocalPoolDataSetBase* dataSet = dynamic_cast( - owner->getDataSetHandle(sid)); + LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid); if(dataSet != nullptr) { dataSet->setReportingEnabled(enableReporting); - dataSet->setIsDiagnostic(isDiagnostics); + dataSet->setDiagnostic(isDiagnostics); + dataSet->initializePeriodicHelper(collectionInterval, + owner->getPeriodicOperationFrequency(), isDiagnostics); } - hkReceiver.intervalCounter = 1; - - hkReceiversMap.emplace(packetDestination, hkReceiver); + hkReceiversMap.push_back(hkReceiver); return HasReturnvaluesIF::RETURN_OK; } @@ -153,7 +139,6 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage( return togglePeriodicGeneration(sid, true, false); case(HousekeepingMessage::DISABLE_PERIODIC_HK_REPORT_GENERATION): return togglePeriodicGeneration(sid, false, false); - case(HousekeepingMessage::REPORT_DIAGNOSTICS_REPORT_STRUCTURES): case(HousekeepingMessage::REPORT_HK_REPORT_STRUCTURES): //return generateSetStructurePacket(sid, ); @@ -174,14 +159,13 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage( case(HousekeepingMessage::GENERATE_ONE_PARAMETER_REPORT): case(HousekeepingMessage::GENERATE_ONE_DIAGNOSTICS_REPORT): { - LocalPoolDataSetBase* dataSet = dynamic_cast( - owner->getDataSetHandle(sid)); + LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid); if(command == HousekeepingMessage::GENERATE_ONE_PARAMETER_REPORT - and dataSet->getIsDiagnostics()) { + and dataSet->isDiagnostics()) { return WRONG_HK_PACKET_TYPE; } else if(command == HousekeepingMessage::GENERATE_ONE_DIAGNOSTICS_REPORT - and not dataSet->getIsDiagnostics()) { + and not dataSet->isDiagnostics()) { return WRONG_HK_PACKET_TYPE; } return generateHousekeepingPacket(HousekeepingMessage::getSid(message), @@ -234,7 +218,7 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid, // and now we set a HK message and send it the HK packet destination. CommandMessage hkMessage; - if(dataSet->getIsDiagnostics()) { + if(dataSet->isDiagnostics()) { HousekeepingMessage::setHkDiagnosticsReply(&hkMessage, sid, storeId); } else { @@ -280,62 +264,40 @@ void LocalDataPoolManager::setNonDiagnosticIntervalFactor( this->nonDiagnosticIntervalFactor = nonDiagInvlFactor; } -void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver* receiver) { - if(receiver->intervalCounter >= - receiver->hkParameter.collectionIntervalTicks) { - sid_t sid = receiver->dataId.dataSetSid; - LocalPoolDataSetBase* dataSet = dynamic_cast( - owner->getDataSetHandle(sid)); - if(not dataSet->getReportingEnabled()) { - return; - } +void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver& receiver) { + sid_t sid = receiver.dataId.sid; + LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid); + if(not dataSet->getReportingEnabled()) { + return; + } - ReturnValue_t result = generateHousekeepingPacket( - sid, dataSet, true); - if(result != HasReturnvaluesIF::RETURN_OK) { - // configuration error - sif::debug << "LocalDataPoolManager::performHkOperation:" - << "0x" << std::setfill('0') << std::setw(8) - << owner->getObjectId() << " Error generating " - << "HK packet" << std::setfill(' ') << std::endl; - } - receiver->intervalCounter = 1; - } - else { - receiver->intervalCounter++; - } + if(dataSet->periodicHelper == nullptr) { + // Configuration error. + return; + } + + if(not dataSet->periodicHelper->checkOpNecessary()) { + return; + } + + ReturnValue_t result = generateHousekeepingPacket( + sid, dataSet, true); + if(result != HasReturnvaluesIF::RETURN_OK) { + // configuration error + sif::debug << "LocalDataPoolManager::performHkOperation:" + << "0x" << std::setfill('0') << std::setw(8) + << owner->getObjectId() << " Error generating " + << "HK packet" << std::setfill(' ') << std::endl; + } } -uint32_t LocalDataPoolManager::intervalSecondsToInterval(bool isDiagnostics, - float collectionIntervalSeconds) { - if(isDiagnostics) { - return std::ceil(collectionIntervalSeconds * 1000 - /diagnosticMinimumInterval); - } - else { - return std::ceil(collectionIntervalSeconds * 1000 - /regularMinimumInterval); - } -} - -float LocalDataPoolManager::intervalToIntervalSeconds(bool isDiagnostics, - uint32_t collectionInterval) { - if(isDiagnostics) { - return static_cast(collectionInterval * - diagnosticMinimumInterval); - } - else { - return static_cast(collectionInterval * - regularMinimumInterval); - } -} ReturnValue_t LocalDataPoolManager::togglePeriodicGeneration(sid_t sid, bool enable, bool isDiagnostics) { LocalPoolDataSetBase* dataSet = dynamic_cast( owner->getDataSetHandle(sid)); - if((dataSet->getIsDiagnostics() and not isDiagnostics) or - (not dataSet->getIsDiagnostics() and isDiagnostics)) { + if((dataSet->isDiagnostics() and not isDiagnostics) or + (not dataSet->isDiagnostics() and isDiagnostics)) { return WRONG_HK_PACKET_TYPE; } @@ -352,7 +314,7 @@ ReturnValue_t LocalDataPoolManager::changeCollectionInterval(sid_t sid, float newCollectionInterval, bool isDiagnostics) { LocalPoolDataSetBase* dataSet = dynamic_cast( owner->getDataSetHandle(sid)); - bool targetIsDiagnostics = dataSet->getIsDiagnostics(); + bool targetIsDiagnostics = dataSet->isDiagnostics(); if((targetIsDiagnostics and not isDiagnostics) or (not targetIsDiagnostics and isDiagnostics)) { return WRONG_HK_PACKET_TYPE; @@ -364,50 +326,49 @@ ReturnValue_t LocalDataPoolManager::changeCollectionInterval(sid_t sid, } dataSet->periodicHelper->changeCollectionInterval(newCollectionInterval); -// for(auto& receiver: hkReceiversMap) { -// if(receiver.second.reportingType != ReportingType::PERIODIC) { -// continue; -// } -// -// uint32_t newInterval = intervalSecondsToInterval(isDiagnostics, -// newCollectionInterval); -// receiver.second.hkParameter.collectionIntervalTicks = newInterval; -// } return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid, - float collectionInterval, bool isDiagnostics) { - LocalPoolDataSetBase* dataSet = dynamic_cast( - owner->getDataSetHandle(sid)); - if(dataSet == nullptr) { - sif::warning << "HousekeepingManager::generateHousekeepingPacket:" - " Set ID not found" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } + bool isDiagnostics) { + LocalPoolDataSetBase* dataSet = dynamic_cast( + owner->getDataSetHandle(sid)); + if(dataSet == nullptr) { + sif::warning << "HousekeepingManager::generateHousekeepingPacket:" + " Set ID not found" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } - bool valid = dataSet->isValid(); - bool targetIsDiagnostics = dataSet->getIsDiagnostics(); - bool reportingEnabled = dataSet->getReportingEnabled(); + bool targetIsDiagnostics = dataSet->isDiagnostics(); + if((targetIsDiagnostics and not isDiagnostics) or + (not targetIsDiagnostics and isDiagnostics)) { + return WRONG_HK_PACKET_TYPE; + } - size_t expectedSize = dataSet->getFillCount() * sizeof(lp_id_t); - uint8_t* storePtr = nullptr; - store_address_t storeId; - HousekeepingSetPacket setPacket = HousekeepingSetPacket(sid, reportingEnabled, - valid, collectionInterval, dataSet); - ReturnValue_t result = ipcStore->getFreeElement(&storeId, - expectedSize,&storePtr); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "HousekeepingManager::generateHousekeepingPacket: " - "Could not get free element from IPC store." << std::endl; - return result; - } - size_t size = 0; - result = dataSet->serializeLocalPoolIds(&storePtr, &size, - expectedSize, SerializeIF::Endianness::BIG); - if(expectedSize != size) { - sif::error << "HousekeepingManager::generateSetStructurePacket: " - "Expected size is not equal to serialized size" << std::endl; - } - return result; + bool valid = dataSet->isValid(); + bool reportingEnabled = dataSet->getReportingEnabled(); + float collectionInterval = + dataSet->periodicHelper->getCollectionIntervalInSeconds(); + + HousekeepingSetPacket setPacket = HousekeepingSetPacket(sid, + reportingEnabled, valid, collectionInterval, dataSet); + size_t expectedSize = setPacket.getSerializedSize(); + uint8_t* storePtr = nullptr; + store_address_t storeId; + ReturnValue_t result = ipcStore->getFreeElement(&storeId, + expectedSize,&storePtr); + if(result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "HousekeepingManager::generateHousekeepingPacket: " + "Could not get free element from IPC store." << std::endl; + return result; + } + + size_t size = 0; + result = setPacket.serialize(&storePtr, &size, expectedSize, + SerializeIF::Endianness::BIG); + if(expectedSize != size) { + sif::error << "HousekeepingManager::generateSetStructurePacket: " + "Expected size is not equal to serialized size" << std::endl; + } + return result; } diff --git a/datapoollocal/LocalDataPoolManager.h b/datapoollocal/LocalDataPoolManager.h index 2a5c68b5..505b9b1a 100644 --- a/datapoollocal/LocalDataPoolManager.h +++ b/datapoollocal/LocalDataPoolManager.h @@ -5,6 +5,7 @@ #include "../housekeeping/HousekeepingPacketDownlink.h" #include "../housekeeping/HousekeepingMessage.h" +#include "../housekeeping/PeriodicHousekeepingHelper.h" #include "../datapool/DataSetIF.h" #include "../datapool/PoolEntry.h" #include "../objectmanager/SystemObjectIF.h" @@ -131,16 +132,15 @@ public: /** * Different types of housekeeping reporting are possible. - * 1. PERIODIC: HK packets are generated in fixed intervals and sent to + * 1. PERIODIC: + * HK packets are generated in fixed intervals and sent to * destination. Fromat will be raw. - * 2. UPDATED: Notification will be sent out if HK data has changed. - * Question: Send Raw data directly or just the message? - * 3. REQUESTED: HK packets are only generated if explicitely requested. + * 2. UPDATE_NOTIFICATION: + * Notification will be sent out if HK data has changed. + * 3. UPDATE_SNAPSHOT: + * HK packets are only generated if explicitely requested. * Propably not necessary, just use multiple local data sets or * shared datasets. - * - * Notifications should also be possible for single variables instead of - * full dataset updates. */ enum class ReportingType: uint8_t { //! Periodic generation of HK packets. @@ -152,6 +152,17 @@ public: UPDATE_SNAPSHOT, }; + /** + * Different data types are possible in the HK receiver map. + * For example, updates can be requested for full datasets or + * for single pool variables. Periodic reporting is only possible for + * data sets. + */ + enum class DataType: uint8_t { + LOCAL_POOL_VARIABLE, + DATA_SET + }; + /* Copying forbidden */ LocalDataPoolManager(const LocalDataPoolManager &) = delete; LocalDataPoolManager operator=(const LocalDataPoolManager&) = delete; @@ -165,8 +176,6 @@ private: HasLocalDataPoolIF* owner = nullptr; uint8_t nonDiagnosticIntervalFactor = 0; - dur_millis_t regularMinimumInterval = 0; - dur_millis_t diagnosticMinimumInterval = 0; /** Default receiver for periodic HK packets */ static object_id_t defaultHkDestination; @@ -174,40 +183,25 @@ private: /** The data pool manager will keep an internal map of HK receivers. */ struct HkReceiver { - /** Different member of this union will be used depending on the - type of data the receiver is interested in (full datasets or - single data variables. */ + /** Object ID of receiver */ + object_id_t objectId = objects::NO_OBJECT; + + DataType dataType = DataType::DATA_SET; union DataId { - DataId(): dataSetSid() {} - /** Will be initialized to INVALID_ADDRESS */ - sid_t dataSetSid; - lp_id_t localPoolId = HasLocalDataPoolIF::NO_POOL_ID; + DataId(): sid() {}; + sid_t sid; + lp_id_t localPoolId; }; DataId dataId; ReportingType reportingType = ReportingType::PERIODIC; - // SHOULDDO: it would be nice to also have the object ID instead of - // a queue (or in addition).. but the FSFW is not ready for that yet. - // Also, an object can have multiple queues. MessageQueueId_t destinationQueue = MessageQueueIF::NO_QUEUE; - - /** Different members of this union will be used depending on reporting - type */ - union HkParameter { - /** This parameter will be used for the PERIODIC type */ - uint32_t collectionIntervalTicks = 0; - /** This parameter will be used for the ON_UPDATE type */ - bool hkDataChanged; - }; - HkParameter hkParameter; - /** General purpose counter which is used for periodic generation. */ - uint32_t intervalCounter; }; - /** Using a multimap as the same object might request multiple datasets */ - using HkReceiversMap = std::multimap; + /** This vector will contain the list of HK receivers. */ + using HkReceivers = std::vector; - HkReceiversMap hkReceiversMap; + HkReceivers hkReceiversMap; /** This is the map holding the actual data. Should only be initialized * once ! */ @@ -252,18 +246,12 @@ private: HousekeepingPacketDownlink& hkPacket, store_address_t& storeId, bool forDownlink, size_t* serializedSize); - uint32_t intervalSecondsToInterval(bool isDiagnostics, - float collectionIntervalSeconds); - float intervalToIntervalSeconds(bool isDiagnostics, - uint32_t collectionInterval); - - void performPeriodicHkGeneration(HkReceiver* hkReceiver); + void performPeriodicHkGeneration(HkReceiver& hkReceiver); ReturnValue_t togglePeriodicGeneration(sid_t sid, bool enable, bool isDiagnostics); ReturnValue_t changeCollectionInterval(sid_t sid, float newCollectionInterval, bool isDiagnostics); - ReturnValue_t generateSetStructurePacket(sid_t sid, - float collectionInterval, bool isDiagnostics); + ReturnValue_t generateSetStructurePacket(sid_t sid, bool isDiagnostics); }; diff --git a/datapoollocal/LocalPoolDataSetBase.cpp b/datapoollocal/LocalPoolDataSetBase.cpp index e0fc6b68..6832005b 100644 --- a/datapoollocal/LocalPoolDataSetBase.cpp +++ b/datapoollocal/LocalPoolDataSetBase.cpp @@ -1,5 +1,6 @@ #include "LocalPoolDataSetBase.h" #include "../datapoollocal/LocalDataPoolManager.h" +#include "../housekeeping/PeriodicHousekeepingHelper.h" #include "../serialize/SerializeAdapter.h" #include @@ -7,13 +8,14 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner, uint32_t setId, PoolVariableIF** registeredVariablesArray, - const size_t maxNumberOfVariables): - PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) { - if(hkOwner == nullptr) { - sif::error << "LocalDataSet::LocalDataSet: Owner can't be nullptr!" - << std::endl; - return; - } + const size_t maxNumberOfVariables): + PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) { + if(hkOwner == nullptr) { + // Configuration error. + sif::error << "LocalPoolDataSetBase::LocalPoolDataSetBase: Owner " + << "invalid!" << std::endl; + return; + } hkManager = hkOwner->getHkManagerHandle(); this->sid.objectId = hkOwner->getObjectId(); this->sid.ownerSetId = setId; @@ -29,8 +31,9 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(sid_t sid, HasLocalDataPoolIF* hkOwner = objectManager->get( sid.objectId); if(hkOwner == nullptr) { - sif::error << "LocalDataSet::LocalDataSet: Owner can't be nullptr!" - << std::endl; + // Configuration error. + sif::error << "LocalPoolDataSetBase::LocalPoolDataSetBase: Owner " + << "invalid!" << std::endl; return; } hkManager = hkOwner->getHkManagerHandle(); @@ -178,12 +181,12 @@ void LocalPoolDataSetBase::bitSetter(uint8_t* byte, uint8_t position) const { *byte |= 1 << shiftNumber; } -void LocalPoolDataSetBase::setIsDiagnostic(bool isDiagnostics) { - this->isDiagnostics = isDiagnostics; +void LocalPoolDataSetBase::setDiagnostic(bool isDiagnostics) { + this->diagnostic = isDiagnostics; } -bool LocalPoolDataSetBase::getIsDiagnostics() const { - return isDiagnostics; +bool LocalPoolDataSetBase::isDiagnostics() const { + return diagnostic; } void LocalPoolDataSetBase::setReportingEnabled(bool reportingEnabled) { @@ -194,6 +197,25 @@ bool LocalPoolDataSetBase::getReportingEnabled() const { return reportingEnabled; } +void LocalPoolDataSetBase::initializePeriodicHelper( + float collectionInterval, dur_millis_t minimumPeriodicInterval, + bool isDiagnostics, uint8_t nonDiagIntervalFactor) { + periodicHelper->initialize(collectionInterval, minimumPeriodicInterval, + isDiagnostics, nonDiagIntervalFactor); +} + +void LocalPoolDataSetBase::setChanged(bool changed) { + this->changed = changed; +} + +bool LocalPoolDataSetBase::isChanged() const { + return changed; +} + +sid_t LocalPoolDataSetBase::getSid() const { + return sid; +} + bool LocalPoolDataSetBase::bitGetter(const uint8_t* byte, uint8_t position) const { if(position > 7) { diff --git a/datapoollocal/LocalPoolDataSetBase.h b/datapoollocal/LocalPoolDataSetBase.h index 2f7db9fb..1b58a211 100644 --- a/datapoollocal/LocalPoolDataSetBase.h +++ b/datapoollocal/LocalPoolDataSetBase.h @@ -1,7 +1,7 @@ #ifndef FSFW_DATAPOOLLOCAL_LOCALPOOLDATASETBASE_H_ #define FSFW_DATAPOOLLOCAL_LOCALPOOLDATASETBASE_H_ -#include + #include "HasLocalDataPoolIF.h" #include "../datapool/DataSetIF.h" #include "../datapool/PoolDataSetBase.h" @@ -10,6 +10,7 @@ #include class LocalDataPoolManager; +class PeriodicHousekeepingHelper; /** * @brief The LocalDataSet class manages a set of locally checked out @@ -38,14 +39,16 @@ class LocalPoolDataSetBase: public PoolDataSetBase { public: /** * @brief Constructor for the creator of local pool data. + * @details + * This constructor also initializes the components required for + * periodic handling. */ LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner, uint32_t setId, PoolVariableIF** registeredVariablesArray, const size_t maxNumberOfVariables); /** - * @brief Constructor for users of local pool data. The passed pool - * owner should implement the HasHkPoolParametersIF. + * @brief Constructor for users of local pool data. * @details * @param sid Unique identifier of dataset consisting of object ID and * set ID. @@ -67,6 +70,8 @@ public: void setValidityBufferGeneration(bool withValidityBuffer); + sid_t getSid() const; + ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, SerializeIF::Endianness streamEndianness) const override; ReturnValue_t deSerialize(const uint8_t** buffer, size_t *size, @@ -102,12 +107,15 @@ public: void setValidity(bool valid, bool setEntriesRecursively); bool isValid() const override; + void setChanged(bool changed); + bool isChanged() const; + protected: sid_t sid; - bool isDiagnostics = false; - void setIsDiagnostic(bool diagnostics); - bool getIsDiagnostics() const; + bool diagnostic = false; + void setDiagnostic(bool diagnostics); + bool isDiagnostics() const; /** * Used for periodic generation. @@ -116,12 +124,22 @@ protected: void setReportingEnabled(bool enabled); bool getReportingEnabled() const; + void initializePeriodicHelper(float collectionInterval, + dur_millis_t minimumPeriodicInterval, + bool isDiagnostics, uint8_t nonDiagIntervalFactor = 5); + /** * If the valid state of a dataset is always relevant to the whole * data set we can use this flag. */ bool valid = false; + /** + * Can be used to mark the dataset as changed, which is used + * by the LocalDataPoolManager to send out update messages. + */ + bool changed = false; + bool withValidityBuffer = true; /** @@ -147,7 +165,7 @@ protected: */ void bitSetter(uint8_t* byte, uint8_t position) const; bool bitGetter(const uint8_t* byte, uint8_t position) const; -private: + PeriodicHousekeepingHelper* periodicHelper = nullptr; }; diff --git a/datapoollocal/StaticLocalDataSet.h b/datapoollocal/StaticLocalDataSet.h index 7c2f0039..2f306898 100644 --- a/datapoollocal/StaticLocalDataSet.h +++ b/datapoollocal/StaticLocalDataSet.h @@ -17,6 +17,24 @@ template class StaticLocalDataSet: public LocalPoolDataSetBase { public: + /** + * Constructor used by data owner and creator like device handlers. + * This constructor also initialized the components required for + * periodic handling. + * @param hkOwner + * @param setId + */ + StaticLocalDataSet(HasLocalDataPoolIF* hkOwner, + uint32_t setId): LocalPoolDataSetBase(hkOwner, setId, nullptr, + NUM_VARIABLES) { + this->setContainer(poolVarList.data()); + } + + /** + * Constructor used by data users like controllers. + * @param hkOwner + * @param setId + */ StaticLocalDataSet(sid_t sid): LocalPoolDataSetBase(sid, nullptr, NUM_VARIABLES) { this->setContainer(poolVarList.data()); diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index 0a3aec6d..227d5b6d 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -391,7 +391,7 @@ ReturnValue_t DeviceHandlerBase::isModeCombinationValid(Mode_t mode, ReturnValue_t DeviceHandlerBase::insertInCommandAndReplyMap( DeviceCommandId_t deviceCommand, uint16_t maxDelayCycles, - PoolDataSetIF* replyDataSet, size_t replyLen, bool periodic, + LocalPoolDataSetBase* replyDataSet, size_t replyLen, bool periodic, bool hasDifferentReplyId, DeviceCommandId_t replyId) { //No need to check, as we may try to insert multiple times. insertInCommandMap(deviceCommand); @@ -405,7 +405,7 @@ ReturnValue_t DeviceHandlerBase::insertInCommandAndReplyMap( } ReturnValue_t DeviceHandlerBase::insertInReplyMap(DeviceCommandId_t replyId, - uint16_t maxDelayCycles, PoolDataSetIF* dataSet, + uint16_t maxDelayCycles, LocalPoolDataSetBase* dataSet, size_t replyLen, bool periodic) { DeviceReplyInfo info; info.maxDelayCycles = maxDelayCycles; @@ -455,7 +455,7 @@ ReturnValue_t DeviceHandlerBase::updateReplyMapEntry(DeviceCommandId_t deviceRep ReturnValue_t DeviceHandlerBase::setReplyDataset(DeviceCommandId_t replyId, - PoolDataSetIF *dataSet) { + LocalPoolDataSetBase *dataSet) { auto replyIter = deviceReplyMap.find(replyId); if(replyIter == deviceReplyMap.end()) { return HasReturnvaluesIF::RETURN_FAILED; @@ -1396,7 +1396,7 @@ ReturnValue_t DeviceHandlerBase::initializeAfterTaskCreation() { return HasReturnvaluesIF::RETURN_OK; } -DataSetIF* DeviceHandlerBase::getDataSetHandle(sid_t sid) { +LocalPoolDataSetBase* DeviceHandlerBase::getDataSetHandle(sid_t sid) { auto iter = deviceReplyMap.find(sid.ownerSetId); if(iter != deviceReplyMap.end()) { return iter->second.dataSet; diff --git a/devicehandlers/DeviceHandlerBase.h b/devicehandlers/DeviceHandlerBase.h index 752f7352..8f1b135b 100644 --- a/devicehandlers/DeviceHandlerBase.h +++ b/devicehandlers/DeviceHandlerBase.h @@ -389,7 +389,8 @@ protected: * - @c RETURN_FAILED else. */ ReturnValue_t insertInCommandAndReplyMap(DeviceCommandId_t deviceCommand, - uint16_t maxDelayCycles, PoolDataSetIF* replyDataSet = nullptr, + uint16_t maxDelayCycles, + LocalPoolDataSetBase* replyDataSet = nullptr, size_t replyLen = 0, bool periodic = false, bool hasDifferentReplyId = false, DeviceCommandId_t replyId = 0); @@ -404,7 +405,7 @@ protected: * - @c RETURN_FAILED else. */ ReturnValue_t insertInReplyMap(DeviceCommandId_t deviceCommand, - uint16_t maxDelayCycles, PoolDataSetIF* dataSet = nullptr, + uint16_t maxDelayCycles, LocalPoolDataSetBase* dataSet = nullptr, size_t replyLen = 0, bool periodic = false); /** @@ -434,7 +435,7 @@ protected: bool periodic = false); ReturnValue_t setReplyDataset(DeviceCommandId_t replyId, - PoolDataSetIF* dataset); + LocalPoolDataSetBase* dataset); /** * @brief Can be implemented by child handler to @@ -663,7 +664,7 @@ protected: //! The dataset used to access housekeeping data related to the //! respective device reply. Will point to a dataset held by //! the child handler (if one is specified) - PoolDataSetIF* dataSet = nullptr; + LocalPoolDataSetBase* dataSet; //! The command that expects this reply. DeviceCommandMap::iterator command; }; @@ -1198,7 +1199,7 @@ private: ReturnValue_t handleDeviceHandlerMessage(CommandMessage *message); - virtual DataSetIF* getDataSetHandle(sid_t sid) override; + virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; virtual dur_millis_t getPeriodicOperationFrequency() const override; diff --git a/housekeeping/HousekeepingMessage.h b/housekeeping/HousekeepingMessage.h index 6a3ca616..e2e894b4 100644 --- a/housekeeping/HousekeepingMessage.h +++ b/housekeeping/HousekeepingMessage.h @@ -3,14 +3,15 @@ #include "../ipc/CommandMessage.h" #include "../ipc/FwMessageTypes.h" +#include "../objectmanager/frameworkObjects.h" #include "../objectmanager/SystemObjectIF.h" #include "../storagemanager/StorageManagerIF.h" -#include union sid_t { - static constexpr uint64_t INVALID_ADDRESS = - std::numeric_limits::max(); - sid_t(): raw(INVALID_ADDRESS) {} + static constexpr uint64_t INVALID_SID = -1; + static constexpr uint32_t INVALID_SET_ID = -1; + static constexpr uint32_t INVALID_OBJECT_ID = objects::NO_OBJECT; + sid_t(): raw(INVALID_SID) {} sid_t(object_id_t objectId, uint32_t setId): objectId(objectId), @@ -31,7 +32,7 @@ union sid_t { uint64_t raw; bool notSet() const { - return raw == INVALID_ADDRESS; + return raw == INVALID_SID; } bool operator==(const sid_t& other) const { diff --git a/housekeeping/PeriodicHousekeepingHelper.cpp b/housekeeping/PeriodicHousekeepingHelper.cpp index c2ae8126..d184489b 100644 --- a/housekeeping/PeriodicHousekeepingHelper.cpp +++ b/housekeeping/PeriodicHousekeepingHelper.cpp @@ -10,10 +10,11 @@ void PeriodicHousekeepingHelper::initialize(float collectionInterval, dur_millis_t minimumPeriodicInterval, bool isDiagnostics, uint8_t nonDiagIntervalFactor) { this->minimumPeriodicInterval = minimumPeriodicInterval; - if(not owner->getIsDiagnostics()) { + if(isDiagnostics) { this->minimumPeriodicInterval = this->minimumPeriodicInterval * nonDiagIntervalFactor; } + collectionIntervalTicks = intervalSecondsToInterval(collectionInterval); } float PeriodicHousekeepingHelper::getCollectionIntervalInSeconds() { diff --git a/housekeeping/PeriodicHousekeepingHelper.h b/housekeeping/PeriodicHousekeepingHelper.h index 982e8cf6..d96eae1d 100644 --- a/housekeeping/PeriodicHousekeepingHelper.h +++ b/housekeeping/PeriodicHousekeepingHelper.h @@ -20,7 +20,6 @@ public: private: LocalPoolDataSetBase* owner = nullptr; - uint32_t intervalSecondsToInterval(float collectionIntervalSeconds); float intervalToIntervalSeconds(uint32_t collectionInterval); @@ -30,6 +29,4 @@ private: }; - - #endif /* FSFW_HOUSEKEEPING_PERIODICHOUSEKEEPINGHELPER_H_ */ diff --git a/pus/Service3Housekeeping.cpp b/pus/Service3Housekeeping.cpp index 0d63a4e2..ebfa4be9 100644 --- a/pus/Service3Housekeeping.cpp +++ b/pus/Service3Housekeeping.cpp @@ -6,7 +6,7 @@ Service3Housekeeping::Service3Housekeeping(object_id_t objectId, uint16_t apid, uint8_t serviceId): CommandingServiceBase(objectId, apid, serviceId, - NUM_OF_PARALLEL_COMMANDS, COMMAND_TIMEOUT_SECONDS) {} + NUM_OF_PARALLEL_COMMANDS, 5) {} Service3Housekeeping::~Service3Housekeeping() {} diff --git a/tmtcservices/CommandingServiceBase.cpp b/tmtcservices/CommandingServiceBase.cpp index 4cead0e9..3a204703 100644 --- a/tmtcservices/CommandingServiceBase.cpp +++ b/tmtcservices/CommandingServiceBase.cpp @@ -387,7 +387,7 @@ void CommandingServiceBase::acceptPacket(uint8_t reportId, void CommandingServiceBase::checkAndExecuteFifo(CommandMapIter iter) { store_address_t address; if (iter->second.fifo.retrieve(&address) != RETURN_OK) { - commandMap.erase(&iter); + commandMap.erase(iter->first); } else { TcPacketStored newPacket(address); startExecution(&newPacket, iter); @@ -411,8 +411,14 @@ void CommandingServiceBase::checkTimeout() { uint32_t uptime; Clock::getUptime(&uptime); CommandMapIter iter; + // TODO: BUG HERE! Problems with comparison operator of iterator. for (iter = commandMap.begin(); iter != commandMap.end(); ++iter) { + if(commandMap.empty()) { + // intermediate solution. + break; + } if ((iter->second.uptimeOfStart + (timeoutSeconds * 1000)) < uptime) { + sif::info << "test" << std::endl; verificationReporter.sendFailureReport( TC_VERIFY::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl, diff --git a/tmtcservices/VerificationReporter.cpp b/tmtcservices/VerificationReporter.cpp index 4f9f4e54..0c53e1a4 100644 --- a/tmtcservices/VerificationReporter.cpp +++ b/tmtcservices/VerificationReporter.cpp @@ -63,8 +63,8 @@ void VerificationReporter::sendFailureReport(uint8_t report_id, ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); if (status != HasReturnvaluesIF::RETURN_OK) { - sif::error << "VerificationReporter::sendFailureReport Error writing " - << "to queue. Code: " << std::hex << status << std::dec + sif::error << "VerificationReporter::sendFailureReport: Error writing " + << "to queue. Code: " << std::hex << "0x" << status << std::dec << std::endl; } } @@ -81,8 +81,8 @@ void VerificationReporter::sendFailureReport(uint8_t report_id, ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); if (status != HasReturnvaluesIF::RETURN_OK) { - sif::error << "VerificationReporter::sendFailureReport Error writing " - << "to queue. Code: " << std::hex << status << std::dec + sif::error << "VerificationReporter::sendFailureReport: Error writing " + << "to queue. Code: " << std::hex << "0x" << status << std::dec << std::endl; } } From 4ab7a0838702698e23590c636b93f375103688f8 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 19 Sep 2020 17:08:08 +0200 Subject: [PATCH 087/192] srv3 continued --- datapoollocal/LocalDataPoolManager.cpp | 45 +++++++++++++++++++------- housekeeping/HousekeepingMessage.cpp | 21 ++++++++++++ housekeeping/HousekeepingMessage.h | 6 ++++ pus/Service3Housekeeping.cpp | 8 ++--- tmtcservices/CommandingServiceBase.cpp | 3 +- 5 files changed, 65 insertions(+), 18 deletions(-) diff --git a/datapoollocal/LocalDataPoolManager.cpp b/datapoollocal/LocalDataPoolManager.cpp index f9a64777..20d6451d 100644 --- a/datapoollocal/LocalDataPoolManager.cpp +++ b/datapoollocal/LocalDataPoolManager.cpp @@ -130,15 +130,28 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage( CommandMessage* message) { Command_t command = message->getCommand(); sid_t sid = HousekeepingMessage::getSid(message); + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; switch(command) { - case(HousekeepingMessage::ENABLE_PERIODIC_DIAGNOSTICS_GENERATION): - return togglePeriodicGeneration(sid, true, true); - case(HousekeepingMessage::DISABLE_PERIODIC_DIAGNOSTICS_GENERATION): - return togglePeriodicGeneration(sid, false, true); - case(HousekeepingMessage::ENABLE_PERIODIC_HK_REPORT_GENERATION): - return togglePeriodicGeneration(sid, true, false); - case(HousekeepingMessage::DISABLE_PERIODIC_HK_REPORT_GENERATION): - return togglePeriodicGeneration(sid, false, false); + case(HousekeepingMessage::ENABLE_PERIODIC_DIAGNOSTICS_GENERATION): { + result = togglePeriodicGeneration(sid, true, true); + break; + } + + case(HousekeepingMessage::DISABLE_PERIODIC_DIAGNOSTICS_GENERATION): { + result = togglePeriodicGeneration(sid, false, true); + break; + } + + case(HousekeepingMessage::ENABLE_PERIODIC_HK_REPORT_GENERATION): { + result = togglePeriodicGeneration(sid, true, false); + break; + } + + case(HousekeepingMessage::DISABLE_PERIODIC_HK_REPORT_GENERATION): { + result = togglePeriodicGeneration(sid, false, false); + break; + } + case(HousekeepingMessage::REPORT_DIAGNOSTICS_REPORT_STRUCTURES): case(HousekeepingMessage::REPORT_HK_REPORT_STRUCTURES): //return generateSetStructurePacket(sid, ); @@ -175,6 +188,16 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage( default: return CommandMessageIF::UNKNOWN_COMMAND; } + + CommandMessage reply; + if(result != HasReturnvaluesIF::RETURN_OK) { + HousekeepingMessage::setHkRequestFailureReply(&reply, sid, result); + } + else { + HousekeepingMessage::setHkRequestSuccessReply(&reply, sid); + } + hkQueue->sendMessage(hkDestinationId, &reply); + return result; } ReturnValue_t LocalDataPoolManager::printPoolEntry( @@ -294,8 +317,7 @@ void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver& receiver) { ReturnValue_t LocalDataPoolManager::togglePeriodicGeneration(sid_t sid, bool enable, bool isDiagnostics) { - LocalPoolDataSetBase* dataSet = dynamic_cast( - owner->getDataSetHandle(sid)); + LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid); if((dataSet->isDiagnostics() and not isDiagnostics) or (not dataSet->isDiagnostics() and isDiagnostics)) { return WRONG_HK_PACKET_TYPE; @@ -312,8 +334,7 @@ ReturnValue_t LocalDataPoolManager::togglePeriodicGeneration(sid_t sid, ReturnValue_t LocalDataPoolManager::changeCollectionInterval(sid_t sid, float newCollectionInterval, bool isDiagnostics) { - LocalPoolDataSetBase* dataSet = dynamic_cast( - owner->getDataSetHandle(sid)); + LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid); bool targetIsDiagnostics = dataSet->isDiagnostics(); if((targetIsDiagnostics and not isDiagnostics) or (not targetIsDiagnostics and isDiagnostics)) { diff --git a/housekeeping/HousekeepingMessage.cpp b/housekeeping/HousekeepingMessage.cpp index a3aab03a..25475072 100644 --- a/housekeeping/HousekeepingMessage.cpp +++ b/housekeeping/HousekeepingMessage.cpp @@ -96,6 +96,27 @@ sid_t HousekeepingMessage::getCollectionIntervalModificationCommand( return getSid(command); } +void HousekeepingMessage::setHkRequestSuccessReply(CommandMessage *reply, + sid_t sid) { + setSid(reply, sid); + reply->setCommand(HK_REQUEST_SUCCESS); +} + +void HousekeepingMessage::setHkRequestFailureReply(CommandMessage *reply, + sid_t sid, ReturnValue_t error) { + setSid(reply, sid); + reply->setCommand(HK_REQUEST_FAILURE); + reply->setParameter3(error); +} + +sid_t HousekeepingMessage::getHkRequestFailureReply(const CommandMessage *reply, + ReturnValue_t *error) { + if(error != nullptr) { + *error = reply->getParameter3(); + } + return getSid(reply); +} + sid_t HousekeepingMessage::getSid(const CommandMessage* message) { sid_t sid; std::memcpy(&sid.raw, message->getData(), sizeof(sid.raw)); diff --git a/housekeeping/HousekeepingMessage.h b/housekeeping/HousekeepingMessage.h index e2e894b4..5c1b4e55 100644 --- a/housekeeping/HousekeepingMessage.h +++ b/housekeeping/HousekeepingMessage.h @@ -118,6 +118,12 @@ public: static void setHkDiagnosticsReply(CommandMessage* reply, sid_t sid, store_address_t storeId); + static void setHkRequestSuccessReply(CommandMessage* reply, sid_t sid); + static void setHkRequestFailureReply(CommandMessage* reply, sid_t sid, + ReturnValue_t error); + static sid_t getHkRequestFailureReply(const CommandMessage* reply, + ReturnValue_t* error); + /** * @brief Generic getter function for housekeeping data replies * @details diff --git a/pus/Service3Housekeeping.cpp b/pus/Service3Housekeeping.cpp index ebfa4be9..ad08c328 100644 --- a/pus/Service3Housekeeping.cpp +++ b/pus/Service3Housekeeping.cpp @@ -6,7 +6,7 @@ Service3Housekeeping::Service3Housekeeping(object_id_t objectId, uint16_t apid, uint8_t serviceId): CommandingServiceBase(objectId, apid, serviceId, - NUM_OF_PARALLEL_COMMANDS, 5) {} + NUM_OF_PARALLEL_COMMANDS, COMMAND_TIMEOUT_SECONDS) {} Service3Housekeeping::~Service3Housekeeping() {} @@ -204,9 +204,9 @@ ReturnValue_t Service3Housekeeping::handleReply(const CommandMessage* reply, case(HousekeepingMessage::HK_REQUEST_FAILURE): { failureParameter1 = objectId; - // also provide failure reason (returnvalue) - // will be most commonly invalid SID or the set already has the desired - // reporting status. + ReturnValue_t error = HasReturnvaluesIF::RETURN_FAILED; + HousekeepingMessage::getHkRequestFailureReply(reply,&error); + failureParameter2 = error; return CommandingServiceBase::EXECUTION_COMPLETE; } diff --git a/tmtcservices/CommandingServiceBase.cpp b/tmtcservices/CommandingServiceBase.cpp index 3a204703..3a124f5d 100644 --- a/tmtcservices/CommandingServiceBase.cpp +++ b/tmtcservices/CommandingServiceBase.cpp @@ -414,11 +414,10 @@ void CommandingServiceBase::checkTimeout() { // TODO: BUG HERE! Problems with comparison operator of iterator. for (iter = commandMap.begin(); iter != commandMap.end(); ++iter) { if(commandMap.empty()) { - // intermediate solution. + // intermediate solution! break; } if ((iter->second.uptimeOfStart + (timeoutSeconds * 1000)) < uptime) { - sif::info << "test" << std::endl; verificationReporter.sendFailureReport( TC_VERIFY::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl, From 02f778ea1d4bbe07df38a7e58ca50ebf6ea81232 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 19 Sep 2020 17:14:09 +0200 Subject: [PATCH 088/192] new error code added --- datapoollocal/LocalDataPoolManager.cpp | 7 ++++--- datapoollocal/LocalDataPoolManager.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/datapoollocal/LocalDataPoolManager.cpp b/datapoollocal/LocalDataPoolManager.cpp index 20d6451d..635fafce 100644 --- a/datapoollocal/LocalDataPoolManager.cpp +++ b/datapoollocal/LocalDataPoolManager.cpp @@ -163,11 +163,12 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage( &newCollIntvl); if(command == HousekeepingMessage:: MODIFY_DIAGNOSTICS_REPORT_COLLECTION_INTERVAL) { - return changeCollectionInterval(sid, newCollIntvl, true); + result = changeCollectionInterval(sid, newCollIntvl, true); } else { - return changeCollectionInterval(sid, newCollIntvl, false); + result = changeCollectionInterval(sid, newCollIntvl, false); } + break; } case(HousekeepingMessage::GENERATE_ONE_PARAMETER_REPORT): @@ -343,7 +344,7 @@ ReturnValue_t LocalDataPoolManager::changeCollectionInterval(sid_t sid, if(dataSet->periodicHelper == nullptr) { // config error - return HasReturnvaluesIF::RETURN_FAILED; + return PERIODIC_HELPER_INVALID; } dataSet->periodicHelper->changeCollectionInterval(newCollectionInterval); diff --git a/datapoollocal/LocalDataPoolManager.h b/datapoollocal/LocalDataPoolManager.h index 505b9b1a..44b15f59 100644 --- a/datapoollocal/LocalDataPoolManager.h +++ b/datapoollocal/LocalDataPoolManager.h @@ -57,6 +57,7 @@ public: static constexpr ReturnValue_t WRONG_HK_PACKET_TYPE = MAKE_RETURN_CODE(0x03); static constexpr ReturnValue_t REPORTING_STATUS_UNCHANGED = MAKE_RETURN_CODE(0x04); + static constexpr ReturnValue_t PERIODIC_HELPER_INVALID = MAKE_RETURN_CODE(0x05); /** * This constructor is used by a class which wants to implement * a personal local data pool. The queueToUse can be supplied if it From 718502c04b35f2677c39d68da4c00f5052e01d33 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 19 Sep 2020 17:15:33 +0200 Subject: [PATCH 089/192] added additional flag which casn be used to disable periodic handling --- datapoollocal/LocalPoolDataSetBase.cpp | 6 ++++-- datapoollocal/LocalPoolDataSetBase.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/datapoollocal/LocalPoolDataSetBase.cpp b/datapoollocal/LocalPoolDataSetBase.cpp index 6832005b..c280e7c7 100644 --- a/datapoollocal/LocalPoolDataSetBase.cpp +++ b/datapoollocal/LocalPoolDataSetBase.cpp @@ -8,7 +8,7 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner, uint32_t setId, PoolVariableIF** registeredVariablesArray, - const size_t maxNumberOfVariables): + const size_t maxNumberOfVariables, bool noPeriodicHandling): PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) { if(hkOwner == nullptr) { // Configuration error. @@ -21,7 +21,9 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner, this->sid.ownerSetId = setId; // Data creators get a periodic helper for periodic HK data generation. - periodicHelper = new PeriodicHousekeepingHelper(this); + if(not noPeriodicHandling) { + periodicHelper = new PeriodicHousekeepingHelper(this); + } } LocalPoolDataSetBase::LocalPoolDataSetBase(sid_t sid, diff --git a/datapoollocal/LocalPoolDataSetBase.h b/datapoollocal/LocalPoolDataSetBase.h index 1b58a211..83e0425c 100644 --- a/datapoollocal/LocalPoolDataSetBase.h +++ b/datapoollocal/LocalPoolDataSetBase.h @@ -45,7 +45,7 @@ public: */ LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner, uint32_t setId, PoolVariableIF** registeredVariablesArray, - const size_t maxNumberOfVariables); + const size_t maxNumberOfVariables, bool noPeriodicHandling = false); /** * @brief Constructor for users of local pool data. From 44989ada64c2fa5919e2ae6245d964eed009976f Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 19 Sep 2020 19:41:41 +0200 Subject: [PATCH 090/192] file system message taken over --- memory/FileSystemMessage.cpp | 54 ++++++++++++++++++++++++++++++------ memory/FileSystemMessage.h | 26 +++++++++++------ 2 files changed, 63 insertions(+), 17 deletions(-) diff --git a/memory/FileSystemMessage.cpp b/memory/FileSystemMessage.cpp index 30437a62..fe1ff2b8 100644 --- a/memory/FileSystemMessage.cpp +++ b/memory/FileSystemMessage.cpp @@ -5,24 +5,60 @@ * Author: Jakob Meier */ -#include "FileSystemMessage.h" -#include "../objectmanager/ObjectManagerIF.h" +#include +#include -ReturnValue_t FileSystemMessage::setWriteToFileCommand(CommandMessage* message, - MessageQueueId_t replyQueueId, store_address_t storageID) { - message->setCommand(WRITE_TO_FILE); - message->setParameter(replyQueueId); + +ReturnValue_t FileSystemMessage::setDeleteFileCommand( + CommandMessage* message, store_address_t storageID) { + message->setCommand(DELETE_FILE); message->setParameter2(storageID.raw); return HasReturnvaluesIF::RETURN_OK; } -store_address_t FileSystemMessage::getStoreID(const CommandMessage* message) { +ReturnValue_t FileSystemMessage::setCreateDirectoryCommand( + CommandMessage* message, store_address_t storageID) { + message->setCommand(CREATE_DIRECTORY); + message->setParameter2(storageID.raw); + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t FileSystemMessage::setDeleteDirectoryCommand( + CommandMessage* message, store_address_t storageID) { + message->setCommand(DELETE_DIRECTORY); + message->setParameter2(storageID.raw); + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t FileSystemMessage::setWriteCommand(CommandMessage* message, + store_address_t storageID) { + message->setCommand(WRITE); + message->setParameter2(storageID.raw); + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t FileSystemMessage::setReadCommand(CommandMessage* message, + store_address_t storageID) { + message->setCommand(READ); + message->setParameter2(storageID.raw); + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t FileSystemMessage::setReadReply(CommandMessage* message, + store_address_t storageID) { + message->setCommand(READ_REPLY); + message->setParameter2(storageID.raw); + return HasReturnvaluesIF::RETURN_OK; +} + +store_address_t FileSystemMessage::getStoreId(const CommandMessage* message) { store_address_t temp; temp.raw = message->getParameter2(); return temp; } -MessageQueueId_t FileSystemMessage::getReplyQueueId(const CommandMessage* message){ - return message->getParameter(); +void FileSystemMessage::setCompletionReply(CommandMessage* message, + Command_t completionStatus) { + message->setCommand(completionStatus); } diff --git a/memory/FileSystemMessage.h b/memory/FileSystemMessage.h index da5b3181..cbc4f8bf 100644 --- a/memory/FileSystemMessage.h +++ b/memory/FileSystemMessage.h @@ -8,9 +8,9 @@ #ifndef FRAMEWORK_MEMORY_FILESYSTEMMESSAGE_H_ #define FRAMEWORK_MEMORY_FILESYSTEMMESSAGE_H_ -#include "../ipc/CommandMessage.h" -#include "../storagemanager/StorageManagerIF.h" -#include "../objectmanager/SystemObject.h" +#include +#include +#include class FileSystemMessage { private: @@ -19,12 +19,22 @@ public: static const uint8_t MESSAGE_ID = messagetypes::FILE_SYSTEM_MESSAGE; static const Command_t CREATE_FILE = MAKE_COMMAND_ID( 0x01 ); static const Command_t DELETE_FILE = MAKE_COMMAND_ID( 0x02 ); - static const Command_t WRITE_TO_FILE = MAKE_COMMAND_ID( 0x80 ); - - static ReturnValue_t setWriteToFileCommand(CommandMessage* message, MessageQueueId_t replyToQueue, store_address_t storageID ); - static store_address_t getStoreID( const CommandMessage* message ); - static MessageQueueId_t getReplyQueueId(const CommandMessage* message); + static const Command_t CREATE_DIRECTORY = MAKE_COMMAND_ID( 0x09 ); + static const Command_t DELETE_DIRECTORY = MAKE_COMMAND_ID( 0x0A ); + static const Command_t WRITE = MAKE_COMMAND_ID( 0x80 ); + static const Command_t READ = MAKE_COMMAND_ID( 0x81 ); + static const Command_t READ_REPLY = MAKE_COMMAND_ID( 0x82 ); + static const Command_t COMPLETION_SUCCESS = MAKE_COMMAND_ID(5); + static const Command_t COMPLETION_FAILED = MAKE_COMMAND_ID(6); + static ReturnValue_t setDeleteFileCommand(CommandMessage* message, store_address_t storageID); + static ReturnValue_t setCreateDirectoryCommand(CommandMessage* message, store_address_t storageID); + static ReturnValue_t setDeleteDirectoryCommand(CommandMessage* message, store_address_t storageID); + static ReturnValue_t setWriteCommand(CommandMessage* message, store_address_t storageID); + static ReturnValue_t setReadCommand(CommandMessage* message, store_address_t storageID); + static ReturnValue_t setReadReply(CommandMessage* message, store_address_t storageID); + static store_address_t getStoreId( const CommandMessage* message ); + static void setCompletionReply(CommandMessage* message, Command_t completionStatus); }; #endif /* FRAMEWORK_MEMORY_FILESYSTEMMESSAGE_H_ */ From 9e9bde03951b143fec0e16078bcb0a02f0cd442e Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 19 Sep 2020 19:50:02 +0200 Subject: [PATCH 091/192] srv23 taken over --- memory/FileSystemMessage.cpp | 11 ++--------- memory/FileSystemMessage.h | 24 ++++++++++-------------- pus/Service2DeviceAccess.cpp | 3 +-- 3 files changed, 13 insertions(+), 25 deletions(-) diff --git a/memory/FileSystemMessage.cpp b/memory/FileSystemMessage.cpp index fe1ff2b8..0d1421fa 100644 --- a/memory/FileSystemMessage.cpp +++ b/memory/FileSystemMessage.cpp @@ -1,12 +1,5 @@ -/* - * FileSystemMessage.cpp - * - * Created on: 19.01.2020 - * Author: Jakob Meier - */ - -#include -#include +#include "FileSystemMessage.h" +#include "../objectmanager/ObjectManagerIF.h" ReturnValue_t FileSystemMessage::setDeleteFileCommand( diff --git a/memory/FileSystemMessage.h b/memory/FileSystemMessage.h index cbc4f8bf..348c9409 100644 --- a/memory/FileSystemMessage.h +++ b/memory/FileSystemMessage.h @@ -1,17 +1,13 @@ -/* - * FileSystemMessage.h - * - * Created on: 19.01.2020 - * Author: Jakob Meier +#ifndef FSFW_MEMORY_FILESYSTEMMESSAGE_H_ +#define FSFW_MEMORY_FILESYSTEMMESSAGE_H_ + +#include "../ipc/CommandMessage.h" +#include "../storagemanager/StorageManagerIF.h" +#include "../objectmanager/SystemObject.h" + +/** + * @author Jakob Meier */ - -#ifndef FRAMEWORK_MEMORY_FILESYSTEMMESSAGE_H_ -#define FRAMEWORK_MEMORY_FILESYSTEMMESSAGE_H_ - -#include -#include -#include - class FileSystemMessage { private: FileSystemMessage(); //A private ctor inhibits instantiation @@ -37,4 +33,4 @@ public: static void setCompletionReply(CommandMessage* message, Command_t completionStatus); }; -#endif /* FRAMEWORK_MEMORY_FILESYSTEMMESSAGE_H_ */ +#endif /* FSFW_MEMORY_FILESYSTEMMESSAGE_H_ */ diff --git a/pus/Service2DeviceAccess.cpp b/pus/Service2DeviceAccess.cpp index 9529c675..8780b22c 100644 --- a/pus/Service2DeviceAccess.cpp +++ b/pus/Service2DeviceAccess.cpp @@ -39,8 +39,7 @@ ReturnValue_t Service2DeviceAccess::getMessageQueueAndObject( SerializeAdapter::deSerialize(objectId, &tcData, &tcDataLen, SerializeIF::Endianness::BIG); - ReturnValue_t result = checkInterfaceAndAcquireMessageQueue(id,objectId); - return result; + return checkInterfaceAndAcquireMessageQueue(id,objectId); } ReturnValue_t Service2DeviceAccess::checkInterfaceAndAcquireMessageQueue( From e140d39944ba02407aa281cc6397bc75e69017ad Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 19 Sep 2020 20:08:25 +0200 Subject: [PATCH 092/192] some fixes for sd card handler --- memory/HasFileSystemIF.h | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/memory/HasFileSystemIF.h b/memory/HasFileSystemIF.h index b6d43981..6065ebfd 100644 --- a/memory/HasFileSystemIF.h +++ b/memory/HasFileSystemIF.h @@ -1,15 +1,11 @@ -/* - * HasFileSystemIF.h - * - * Created on: 19.01.2020 - * Author: Jakob Meier - */ - -#ifndef FRAMEWORK_MEMORY_HASFILESYSTEMIF_H_ -#define FRAMEWORK_MEMORY_HASFILESYSTEMIF_H_ +#ifndef FSFW_MEMORY_HASFILESYSTEMIF_H_ +#define FSFW_MEMORY_HASFILESYSTEMIF_H_ #include "../returnvalues/HasReturnvaluesIF.h" +/** + * @author Jakob Meier + */ class HasFileSystemIF { public: @@ -19,18 +15,24 @@ public: * @return MessageQueueId_t of the object */ virtual MessageQueueId_t getCommandQueue() const = 0; + /** * Function to write to a file * @param dirname Directory of the file * @param filename The filename of the file * @param data The data to write to the file * @param size The size of the data to write - * @param packetNumber Counts the number of packets. For large files the write procedure must be split in multiple calls to writeToFile + * @param packetNumber Counts the number of packets. + * For large files the write procedure must be split in multiple calls + * to writeToFile */ - virtual ReturnValue_t writeToFile(const char* dirname, char* filename, const uint8_t* data, uint32_t size, uint16_t packetNumber) = 0; - virtual ReturnValue_t createFile(const char* dirname, const char* filename, const uint8_t* data, uint32_t size) = 0; - virtual ReturnValue_t deleteFile(const char* dirname, const char* filename) = 0; + virtual ReturnValue_t writeToFile(const char* dirname, const char* filename, + const uint8_t* data, size_t size, uint16_t packetNumber) = 0; + virtual ReturnValue_t createFile(const char* dirname, const char* filename, + const uint8_t* data, size_t size) = 0; + virtual ReturnValue_t deleteFile(const char* dirname, + const char* filename) = 0; }; -#endif /* FRAMEWORK_MEMORY_HASFILESYSTEMIF_H_ */ +#endif /* FSFW_MEMORY_HASFILESYSTEMIF_H_ */ From cad08e1ea9d722801b1e6675b88a8513bdc6078a Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 19 Sep 2020 20:54:27 +0200 Subject: [PATCH 093/192] error output for failed deletion --- storagemanager/ConstStorageAccessor.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/storagemanager/ConstStorageAccessor.cpp b/storagemanager/ConstStorageAccessor.cpp index 6235ac40..5c143adb 100644 --- a/storagemanager/ConstStorageAccessor.cpp +++ b/storagemanager/ConstStorageAccessor.cpp @@ -14,7 +14,12 @@ ConstStorageAccessor::ConstStorageAccessor(store_address_t storeId, ConstStorageAccessor::~ConstStorageAccessor() { if(deleteData and store != nullptr) { - store->deleteData(storeId); + ReturnValue_t result = store->deleteData(storeId); + if(result != HasReturnvaluesIF::RETURN_OK) { + // Configuration error. + sif::error << "ConstStorageAccessor::~ConstStorageAccessor: " + << "Could not delete entry!" << std::endl; + } } } From 40db85e73f54d77cd813afe7f57667ca7e3f56cc Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 19 Sep 2020 21:36:12 +0200 Subject: [PATCH 094/192] separate messages for success/failure --- memory/FileSystemMessage.cpp | 10 +++++++--- memory/FileSystemMessage.h | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/memory/FileSystemMessage.cpp b/memory/FileSystemMessage.cpp index 0d1421fa..951836e9 100644 --- a/memory/FileSystemMessage.cpp +++ b/memory/FileSystemMessage.cpp @@ -50,8 +50,12 @@ store_address_t FileSystemMessage::getStoreId(const CommandMessage* message) { return temp; } -void FileSystemMessage::setCompletionReply(CommandMessage* message, - Command_t completionStatus) { - message->setCommand(completionStatus); +void FileSystemMessage::setSuccessReply(CommandMessage *message) { + message->setCommand(COMPLETION_SUCCESS); } +void FileSystemMessage::setFailureReply(CommandMessage *message, + ReturnValue_t errorCode) { + message->setCommand(COMPLETION_SUCCESS); + message->setParameter(errorCode); +} diff --git a/memory/FileSystemMessage.h b/memory/FileSystemMessage.h index 348c9409..6508f6be 100644 --- a/memory/FileSystemMessage.h +++ b/memory/FileSystemMessage.h @@ -30,7 +30,8 @@ public: static ReturnValue_t setReadCommand(CommandMessage* message, store_address_t storageID); static ReturnValue_t setReadReply(CommandMessage* message, store_address_t storageID); static store_address_t getStoreId( const CommandMessage* message ); - static void setCompletionReply(CommandMessage* message, Command_t completionStatus); + static void setSuccessReply(CommandMessage* message); + static void setFailureReply(CommandMessage* message, ReturnValue_t errorCode); }; #endif /* FSFW_MEMORY_FILESYSTEMMESSAGE_H_ */ From 763c52cfca0c173cf54924cb736ebb4262171489 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 19 Sep 2020 21:57:23 +0200 Subject: [PATCH 095/192] CSB FIFO first steps to make configurable --- tmtcservices/CommandingServiceBase.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tmtcservices/CommandingServiceBase.h b/tmtcservices/CommandingServiceBase.h index 23b08acf..8237415a 100644 --- a/tmtcservices/CommandingServiceBase.h +++ b/tmtcservices/CommandingServiceBase.h @@ -39,7 +39,11 @@ class CommandingServiceBase: public SystemObject, public HasReturnvaluesIF { friend void (Factory::setStaticFrameworkObjectIds)(); public: + // We could make this configurable via preprocessor and the FSFWConfig file. + static constexpr uint8_t COMMAND_INFO_FIFO_DEPTH = 3; + static const uint8_t INTERFACE_ID = CLASS_ID::COMMAND_SERVICE_BASE; + static const ReturnValue_t EXECUTION_COMPLETE = MAKE_RETURN_CODE(1); static const ReturnValue_t NO_STEP_MESSAGE = MAKE_RETURN_CODE(2); static const ReturnValue_t OBJECT_BUSY = MAKE_RETURN_CODE(3); @@ -223,7 +227,7 @@ protected: uint32_t state; Command_t command; object_id_t objectId; - FIFO fifo; + FIFO fifo; virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, Endianness streamEndianness) const override{ @@ -235,7 +239,7 @@ protected: }; virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, - Endianness streamEndianness) override{ + Endianness streamEndianness) override { return HasReturnvaluesIF::RETURN_FAILED; }; }; From f5d793a1cf63b9ebe87bef2e0d49e55947c11cf1 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sun, 20 Sep 2020 13:38:53 +0200 Subject: [PATCH 096/192] file system message getter func --- memory/FileSystemMessage.cpp | 5 +++++ memory/FileSystemMessage.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/memory/FileSystemMessage.cpp b/memory/FileSystemMessage.cpp index 951836e9..416f646c 100644 --- a/memory/FileSystemMessage.cpp +++ b/memory/FileSystemMessage.cpp @@ -59,3 +59,8 @@ void FileSystemMessage::setFailureReply(CommandMessage *message, message->setCommand(COMPLETION_SUCCESS); message->setParameter(errorCode); } + +ReturnValue_t FileSystemMessage::getFailureReply( + const CommandMessage *message) { + return message->getParameter(); +} diff --git a/memory/FileSystemMessage.h b/memory/FileSystemMessage.h index 6508f6be..d3dbd83c 100644 --- a/memory/FileSystemMessage.h +++ b/memory/FileSystemMessage.h @@ -32,6 +32,8 @@ public: static store_address_t getStoreId( const CommandMessage* message ); static void setSuccessReply(CommandMessage* message); static void setFailureReply(CommandMessage* message, ReturnValue_t errorCode); + + static ReturnValue_t getFailureReply(const CommandMessage* message); }; #endif /* FSFW_MEMORY_FILESYSTEMMESSAGE_H_ */ From e3cbc4dfd5a854204130df4e0dd3434438b8d795 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 22 Sep 2020 02:12:02 +0200 Subject: [PATCH 097/192] shared ring buffer extended --- container/SharedRingBuffer.cpp | 25 +++++++++++++++++++++++++ container/SharedRingBuffer.h | 16 ++++++++++++++++ timemanager/Countdown.cpp | 13 +++---------- timemanager/Countdown.h | 26 +++++++++++++------------- 4 files changed, 57 insertions(+), 23 deletions(-) diff --git a/container/SharedRingBuffer.cpp b/container/SharedRingBuffer.cpp index 800e75d3..48bdb9df 100644 --- a/container/SharedRingBuffer.cpp +++ b/container/SharedRingBuffer.cpp @@ -9,6 +9,7 @@ SharedRingBuffer::SharedRingBuffer(object_id_t objectId, const size_t size, mutex = MutexFactory::instance()->createMutex(); } + SharedRingBuffer::SharedRingBuffer(object_id_t objectId, uint8_t *buffer, const size_t size, bool overwriteOld, size_t maxExcessBytes): SystemObject(objectId), SimpleRingBuffer(buffer, size, overwriteOld, @@ -16,6 +17,11 @@ SharedRingBuffer::SharedRingBuffer(object_id_t objectId, uint8_t *buffer, mutex = MutexFactory::instance()->createMutex(); } + +void SharedRingBuffer::setToUseReceiveSizeFIFO(uint32_t fifoDepth) { + this->fifoDepth = fifoDepth; +} + ReturnValue_t SharedRingBuffer::lockRingBufferMutex( MutexIF::TimeoutType timeoutType, dur_millis_t timeout) { return mutex->lockMutex(timeoutType, timeout); @@ -25,6 +31,25 @@ ReturnValue_t SharedRingBuffer::unlockRingBufferMutex() { return mutex->unlockMutex(); } + + MutexIF* SharedRingBuffer::getMutexHandle() const { return mutex; } + +ReturnValue_t SharedRingBuffer::initialize() { + if(fifoDepth > 0) { + receiveSizesFIFO = new DynamicFIFO(fifoDepth); + } + return SystemObject::initialize(); +} + +DynamicFIFO* SharedRingBuffer::getReceiveSizesFIFO() { + if(receiveSizesFIFO == nullptr) { + // Configuration error. + sif::warning << "SharedRingBuffer::getReceiveSizesFIFO: Ring buffer" + << " was not configured to have sizes FIFO, returning nullptr!" + << std::endl; + } + return receiveSizesFIFO; +} diff --git a/container/SharedRingBuffer.h b/container/SharedRingBuffer.h index 80c068b3..c9e0ae3f 100644 --- a/container/SharedRingBuffer.h +++ b/container/SharedRingBuffer.h @@ -1,6 +1,7 @@ #ifndef FSFW_CONTAINER_SHAREDRINGBUFFER_H_ #define FSFW_CONTAINER_SHAREDRINGBUFFER_H_ +#include #include "SimpleRingBuffer.h" #include "../ipc/MutexIF.h" #include "../objectmanager/SystemObject.h" @@ -26,6 +27,8 @@ public: SharedRingBuffer(object_id_t objectId, const size_t size, bool overwriteOld, size_t maxExcessBytes); + void setToUseReceiveSizeFIFO(uint32_t fifoDepth); + /** * This constructor takes an external buffer with the specified size. * @param buffer @@ -59,8 +62,21 @@ public: * @return */ MutexIF* getMutexHandle() const; + + ReturnValue_t initialize() override; + + /** + * If the shared ring buffer was configured to have a sizes FIFO, a handle + * to that FIFO can be retrieved with this function. + * Do not forget to protect access with a lock if required! + * @return + */ + DynamicFIFO* getReceiveSizesFIFO(); private: MutexIF* mutex = nullptr; + + size_t fifoDepth = 0; + DynamicFIFO* receiveSizesFIFO = nullptr; }; diff --git a/timemanager/Countdown.cpp b/timemanager/Countdown.cpp index 95cce029..dfe0e1ec 100644 --- a/timemanager/Countdown.cpp +++ b/timemanager/Countdown.cpp @@ -1,14 +1,7 @@ -/** - * @file Countdown.cpp - * @brief This file defines the Countdown class. - * @date 21.03.2013 - * @author baetz - */ +#include "Countdown.h" - -#include "../timemanager/Countdown.h" - -Countdown::Countdown(uint32_t initialTimeout) : startTime(0), timeout(initialTimeout) { +Countdown::Countdown(uint32_t initialTimeout): startTime(0), + timeout(initialTimeout) { } Countdown::~Countdown() { diff --git a/timemanager/Countdown.h b/timemanager/Countdown.h index 20380e71..f6a41e73 100644 --- a/timemanager/Countdown.h +++ b/timemanager/Countdown.h @@ -1,18 +1,13 @@ +#ifndef FSFW_TIMEMANAGER_COUNTDOWN_H_ +#define FSFW_TIMEMANAGER_COUNTDOWN_H_ + +#include "Clock.h" + /** - * @file Countdown.h * @brief This file defines the Countdown class. - * @date 21.03.2013 * @author baetz */ - -#ifndef COUNTDOWN_H_ -#define COUNTDOWN_H_ - -#include "../timemanager/Clock.h" - class Countdown { -private: - uint32_t startTime; public: uint32_t timeout; Countdown(uint32_t initialTimeout = 0); @@ -23,9 +18,14 @@ public: bool isBusy() const; - ReturnValue_t resetTimer(); //!< Use last set timeout value and restart timer. + //!< Use last set timeout value and restart timer. + ReturnValue_t resetTimer(); - void timeOut(); //!< Make hasTimedOut() return true + //!< Make hasTimedOut() return true + void timeOut(); + +private: + uint32_t startTime = 0; }; -#endif /* COUNTDOWN_H_ */ +#endif /* FSFW_TIMEMANAGER_COUNTDOWN_H_ */ From 5072c09bc030e381df054b5b28ff979804030cff Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 22 Sep 2020 13:59:25 +0200 Subject: [PATCH 098/192] csb hotfix --- tmtcservices/CommandingServiceBase.cpp | 9 ++------- tmtcservices/CommandingServiceBase.h | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/tmtcservices/CommandingServiceBase.cpp b/tmtcservices/CommandingServiceBase.cpp index 3a124f5d..0ebc3944 100644 --- a/tmtcservices/CommandingServiceBase.cpp +++ b/tmtcservices/CommandingServiceBase.cpp @@ -384,10 +384,10 @@ void CommandingServiceBase::acceptPacket(uint8_t reportId, } -void CommandingServiceBase::checkAndExecuteFifo(CommandMapIter iter) { +void CommandingServiceBase::checkAndExecuteFifo(CommandMapIter& iter) { store_address_t address; if (iter->second.fifo.retrieve(&address) != RETURN_OK) { - commandMap.erase(iter->first); + commandMap.erase(&iter); } else { TcPacketStored newPacket(address); startExecution(&newPacket, iter); @@ -411,12 +411,7 @@ void CommandingServiceBase::checkTimeout() { uint32_t uptime; Clock::getUptime(&uptime); CommandMapIter iter; - // TODO: BUG HERE! Problems with comparison operator of iterator. for (iter = commandMap.begin(); iter != commandMap.end(); ++iter) { - if(commandMap.empty()) { - // intermediate solution! - break; - } if ((iter->second.uptimeOfStart + (timeoutSeconds * 1000)) < uptime) { verificationReporter.sendFailureReport( TC_VERIFY::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags, diff --git a/tmtcservices/CommandingServiceBase.h b/tmtcservices/CommandingServiceBase.h index 8237415a..252b6943 100644 --- a/tmtcservices/CommandingServiceBase.h +++ b/tmtcservices/CommandingServiceBase.h @@ -316,7 +316,7 @@ protected: ReturnValue_t sendTmPacket(uint8_t subservice, SerializeIF* content, SerializeIF* header = nullptr); - void checkAndExecuteFifo(CommandMapIter iter); + void checkAndExecuteFifo(CommandMapIter& iter); private: /** From 4074ca1b8970e3c3c115f77df15dc87e60f64f59 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 22 Sep 2020 14:22:14 +0200 Subject: [PATCH 099/192] error code improved --- tmtcservices/TmTcBridge.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tmtcservices/TmTcBridge.cpp b/tmtcservices/TmTcBridge.cpp index 8c2f15e5..8abe37a2 100644 --- a/tmtcservices/TmTcBridge.cpp +++ b/tmtcservices/TmTcBridge.cpp @@ -95,8 +95,9 @@ ReturnValue_t TmTcBridge::handleTm() { ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; ReturnValue_t result = handleTmQueue(); if(result != RETURN_OK) { - sif::error << "TmTcBridge::handleTm: Error handling TM queue!" - << std::endl; + sif::error << "TmTcBridge::handleTm: Error handling TM queue with " + << "error code 0x" << std::hex << result << std::dec + << "!" << std::endl; status = result; } From c7a6711eecddf89a5bad9ab193f166dfd8e93452 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 22 Sep 2020 16:25:10 +0200 Subject: [PATCH 100/192] include fix --- container/SharedRingBuffer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/container/SharedRingBuffer.h b/container/SharedRingBuffer.h index c9e0ae3f..fdc9d626 100644 --- a/container/SharedRingBuffer.h +++ b/container/SharedRingBuffer.h @@ -1,8 +1,8 @@ #ifndef FSFW_CONTAINER_SHAREDRINGBUFFER_H_ #define FSFW_CONTAINER_SHAREDRINGBUFFER_H_ -#include #include "SimpleRingBuffer.h" +#include "DynamicFIFO.h" #include "../ipc/MutexIF.h" #include "../objectmanager/SystemObject.h" #include "../timemanager/Clock.h" From 320a5ac355728fd8b357d8bb3e0bca889e2e280e Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Wed, 23 Sep 2020 17:44:22 +0200 Subject: [PATCH 101/192] has health IF improvements --- health/HasHealthIF.h | 16 +++++++---- health/HealthHelper.h | 3 +- health/HealthMessage.cpp | 2 +- health/HealthMessage.h | 17 +++++++----- health/HealthTable.cpp | 59 ++++++++++++++++------------------------ health/HealthTable.h | 32 +++++++++++++--------- health/HealthTableIF.h | 20 ++++++-------- health/ManagesHealthIF.h | 9 +++--- 8 files changed, 79 insertions(+), 79 deletions(-) diff --git a/health/HasHealthIF.h b/health/HasHealthIF.h index ac404300..d5321a6d 100644 --- a/health/HasHealthIF.h +++ b/health/HasHealthIF.h @@ -1,5 +1,5 @@ -#ifndef HASHEALTHIF_H_ -#define HASHEALTHIF_H_ +#ifndef FSFW_HEALTH_HASHEALTHIF_H_ +#define FSFW_HEALTH_HASHEALTHIF_H_ #include "../events/Event.h" #include "../returnvalues/HasReturnvaluesIF.h" @@ -8,9 +8,13 @@ class HasHealthIF { public: - typedef enum { - HEALTHY = 1, FAULTY = 0, EXTERNAL_CONTROL = 2, NEEDS_RECOVERY = 3, PERMANENT_FAULTY = 4 - } HealthState; + enum HealthState: uint8_t { + HEALTHY = 1, + FAULTY = 0, + EXTERNAL_CONTROL = 2, + NEEDS_RECOVERY = 3, + PERMANENT_FAULTY = 4 + }; static const uint8_t INTERFACE_ID = CLASS_ID::HAS_HEALTH_IF; static const ReturnValue_t OBJECT_NOT_HEALTHY = MAKE_RETURN_CODE(1); @@ -47,4 +51,4 @@ public: virtual HasHealthIF::HealthState getHealth() = 0; }; -#endif /* HASHEALTHIF_H_ */ +#endif /* FSFW_HEALTH_HASHEALTHIF_H_ */ diff --git a/health/HealthHelper.h b/health/HealthHelper.h index d1f1945c..813123b2 100644 --- a/health/HealthHelper.h +++ b/health/HealthHelper.h @@ -114,7 +114,8 @@ private: * @param health the health is passed as parameter so that the number of calls to the health table can be minimized * @param oldHealth information of the previous health state. */ - void informParent(HasHealthIF::HealthState health, HasHealthIF::HealthState oldHealth); + void informParent(HasHealthIF::HealthState health, + HasHealthIF::HealthState oldHealth); void handleSetHealthCommand(CommandMessage *message); }; diff --git a/health/HealthMessage.cpp b/health/HealthMessage.cpp index 39c53fb1..1bb29526 100644 --- a/health/HealthMessage.cpp +++ b/health/HealthMessage.cpp @@ -1,4 +1,4 @@ -#include "../health/HealthMessage.h" +#include "HealthMessage.h" void HealthMessage::setHealthMessage(CommandMessage* message, Command_t command, HasHealthIF::HealthState health, HasHealthIF::HealthState oldHealth) { diff --git a/health/HealthMessage.h b/health/HealthMessage.h index fa773d42..de4923ab 100644 --- a/health/HealthMessage.h +++ b/health/HealthMessage.h @@ -1,19 +1,22 @@ -#ifndef HEALTHMESSAGE_H_ -#define HEALTHMESSAGE_H_ +#ifndef FSFW_HEALTH_HEALTHMESSAGE_H_ +#define FSFW_HEALTH_HEALTHMESSAGE_H_ -#include "../health/HasHealthIF.h" +#include "HasHealthIF.h" #include "../ipc/CommandMessage.h" class HealthMessage { public: static const uint8_t MESSAGE_ID = messagetypes::HEALTH_COMMAND; - static const Command_t HEALTH_SET = MAKE_COMMAND_ID(1);//REPLY_COMMAND_OK/REPLY_REJECTED - static const Command_t HEALTH_ANNOUNCE = MAKE_COMMAND_ID(3); //NO REPLY! + // REPLY_COMMAND_OK/REPLY_REJECTED + static const Command_t HEALTH_SET = MAKE_COMMAND_ID(1); + // NO REPLY! + static const Command_t HEALTH_ANNOUNCE = MAKE_COMMAND_ID(3); static const Command_t HEALTH_INFO = MAKE_COMMAND_ID(5); static const Command_t REPLY_HEALTH_SET = MAKE_COMMAND_ID(6); static void setHealthMessage(CommandMessage *message, Command_t command, - HasHealthIF::HealthState health, HasHealthIF::HealthState oldHealth = HasHealthIF::FAULTY); + HasHealthIF::HealthState health, + HasHealthIF::HealthState oldHealth = HasHealthIF::FAULTY); static void setHealthMessage(CommandMessage *message, Command_t command); @@ -27,4 +30,4 @@ private: HealthMessage(); }; -#endif /* HEALTHMESSAGE_H_ */ +#endif /* FSFW_HEALTH_HEALTHMESSAGE_H_ */ diff --git a/health/HealthTable.cpp b/health/HealthTable.cpp index 1aa5a3ae..6d6fe017 100644 --- a/health/HealthTable.cpp +++ b/health/HealthTable.cpp @@ -1,6 +1,7 @@ -#include "../health/HealthTable.h" -#include "../serialize/SerializeAdapter.h" +#include "HealthTable.h" +#include "../ipc/MutexHelper.h" #include "../ipc/MutexFactory.h" +#include "../serialize/SerializeAdapter.h" HealthTable::HealthTable(object_id_t objectid) : SystemObject(objectid) { @@ -18,74 +19,64 @@ ReturnValue_t HealthTable::registerObject(object_id_t object, if (healthMap.count(object) != 0) { return HasReturnvaluesIF::RETURN_FAILED; } - healthMap.insert( - std::pair(object, - initilialState)); + healthMap.emplace(object, initilialState); return HasReturnvaluesIF::RETURN_OK; } void HealthTable::setHealth(object_id_t object, HasHealthIF::HealthState newState) { - mutex->lockMutex(MutexIF::BLOCKING); + MutexHelper(mutex, MutexIF::TimeoutType::WAITING, 20); HealthMap::iterator iter = healthMap.find(object); if (iter != healthMap.end()) { iter->second = newState; } - mutex->unlockMutex(); } HasHealthIF::HealthState HealthTable::getHealth(object_id_t object) { HasHealthIF::HealthState state = HasHealthIF::HEALTHY; - mutex->lockMutex(MutexIF::BLOCKING); + MutexHelper(mutex, MutexIF::TimeoutType::WAITING, 20); HealthMap::iterator iter = healthMap.find(object); if (iter != healthMap.end()) { state = iter->second; } - mutex->unlockMutex(); return state; } -uint32_t HealthTable::getPrintSize() { - mutex->lockMutex(MutexIF::BLOCKING); - uint32_t size = healthMap.size() * 5 + 2; - mutex->unlockMutex(); - return size; -} bool HealthTable::hasHealth(object_id_t object) { - bool exits = false; - mutex->lockMutex(MutexIF::BLOCKING); + MutexHelper(mutex, MutexIF::TimeoutType::WAITING, 20); HealthMap::iterator iter = healthMap.find(object); if (iter != healthMap.end()) { - exits = true; + return true; } - mutex->unlockMutex(); - return exits; + return false; +} + +size_t HealthTable::getPrintSize() { + MutexHelper(mutex, MutexIF::TimeoutType::WAITING, 20); + uint32_t size = healthMap.size() * sizeof(object_id_t) + + sizeof(HasHealthIF::HealthState) + sizeof(uint16_t); + return size; } void HealthTable::printAll(uint8_t* pointer, size_t maxSize) { - mutex->lockMutex(MutexIF::BLOCKING); + MutexHelper(mutex, MutexIF::TimeoutType::WAITING, 20); size_t size = 0; uint16_t count = healthMap.size(); - ReturnValue_t result = SerializeAdapter::serialize(&count, + SerializeAdapter::serialize(&count, &pointer, &size, maxSize, SerializeIF::Endianness::BIG); - HealthMap::iterator iter; - for (iter = healthMap.begin(); - iter != healthMap.end() && result == HasReturnvaluesIF::RETURN_OK; - ++iter) { - result = SerializeAdapter::serialize(&iter->first, + for (const auto& health: healthMap) { + SerializeAdapter::serialize(&health.first, &pointer, &size, maxSize, SerializeIF::Endianness::BIG); - uint8_t health = iter->second; - result = SerializeAdapter::serialize(&health, &pointer, &size, + uint8_t healthValue = health.second; + SerializeAdapter::serialize(&healthValue, &pointer, &size, maxSize, SerializeIF::Endianness::BIG); } - mutex->unlockMutex(); } -ReturnValue_t HealthTable::iterate( - std::pair *value, bool reset) { +ReturnValue_t HealthTable::iterate(HealthEntry *value, bool reset) { ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - mutex->lockMutex(MutexIF::BLOCKING); + MutexHelper(mutex, MutexIF::TimeoutType::WAITING, 20); if (reset) { mapIterator = healthMap.begin(); } @@ -94,7 +85,5 @@ ReturnValue_t HealthTable::iterate( } *value = *mapIterator; mapIterator++; - mutex->unlockMutex(); - return result; } diff --git a/health/HealthTable.h b/health/HealthTable.h index 0f54a264..c5ebb5d4 100644 --- a/health/HealthTable.h +++ b/health/HealthTable.h @@ -1,27 +1,31 @@ -#ifndef FRAMEWORK_HEALTH_HEALTHTABLE_H_ -#define FRAMEWORK_HEALTH_HEALTHTABLE_H_ +#ifndef FSFW_HEALTH_HEALTHTABLE_H_ +#define FSFW_HEALTH_HEALTHTABLE_H_ -#include "../health/HealthTableIF.h" +#include "HealthTableIF.h" #include "../objectmanager/SystemObject.h" #include "../ipc/MutexIF.h" #include typedef std::map HealthMap; +using HealthEntry = std::pair; class HealthTable: public HealthTableIF, public SystemObject { public: HealthTable(object_id_t objectid); virtual ~HealthTable(); - virtual ReturnValue_t registerObject(object_id_t object, - HasHealthIF::HealthState initilialState = HasHealthIF::HEALTHY); + /** HealthTableIF overrides */ + virtual ReturnValue_t registerObject(object_id_t object, + HasHealthIF::HealthState initilialState = + HasHealthIF::HEALTHY) override; + virtual size_t getPrintSize() override; + virtual void printAll(uint8_t *pointer, size_t maxSize) override; - virtual bool hasHealth(object_id_t object); - virtual void setHealth(object_id_t object, HasHealthIF::HealthState newState); - virtual HasHealthIF::HealthState getHealth(object_id_t); - - virtual uint32_t getPrintSize(); - virtual void printAll(uint8_t *pointer, size_t maxSize); + /** ManagesHealthIF overrides */ + virtual bool hasHealth(object_id_t object) override; + virtual void setHealth(object_id_t object, + HasHealthIF::HealthState newState) override; + virtual HasHealthIF::HealthState getHealth(object_id_t) override; protected: MutexIF* mutex; @@ -29,7 +33,9 @@ protected: HealthMap::iterator mapIterator; - virtual ReturnValue_t iterate(std::pair *value, bool reset = false); + virtual ReturnValue_t iterate( + HealthEntry* value, + bool reset = false) override; }; -#endif /* HEALTHTABLE_H_ */ +#endif /* FSFW_HEALTH_HEALTHTABLE_H_ */ diff --git a/health/HealthTableIF.h b/health/HealthTableIF.h index f18f0315..d61e6761 100644 --- a/health/HealthTableIF.h +++ b/health/HealthTableIF.h @@ -1,28 +1,24 @@ -#ifndef FRAMEWORK_HEALTH_HEALTHTABLEIF_H_ -#define FRAMEWORK_HEALTH_HEALTHTABLEIF_H_ +#ifndef FSFW_HEALTH_HEALTHTABLEIF_H_ +#define FSFW_HEALTH_HEALTHTABLEIF_H_ -#include "../health/ManagesHealthIF.h" +#include "ManagesHealthIF.h" #include "../objectmanager/ObjectManagerIF.h" #include "../returnvalues/HasReturnvaluesIF.h" -#include - class HealthTableIF: public ManagesHealthIF { - // TODO: This is in the mission folder and not in the framework folder. - // delete it? - friend class HealthCommandingService; public: - virtual ~HealthTableIF() { - } + virtual ~HealthTableIF() {} virtual ReturnValue_t registerObject(object_id_t object, HasHealthIF::HealthState initilialState = HasHealthIF::HEALTHY) = 0; - virtual uint32_t getPrintSize() = 0; + virtual size_t getPrintSize() = 0; virtual void printAll(uint8_t *pointer, size_t maxSize) = 0; protected: - virtual ReturnValue_t iterate(std::pair *value, bool reset = false) = 0; + virtual ReturnValue_t iterate( + std::pair *value, + bool reset = false) = 0; }; #endif /* FRAMEWORK_HEALTH_HEALTHTABLEIF_H_ */ diff --git a/health/ManagesHealthIF.h b/health/ManagesHealthIF.h index 8ca17012..2edfceca 100644 --- a/health/ManagesHealthIF.h +++ b/health/ManagesHealthIF.h @@ -1,8 +1,9 @@ -#ifndef FRAMEWORK_HEALTH_MANAGESHEALTHIF_H_ -#define FRAMEWORK_HEALTH_MANAGESHEALTHIF_H_ +#ifndef FSFW_HEALTH_MANAGESHEALTHIF_H_ +#define FSFW_HEALTH_MANAGESHEALTHIF_H_ -#include "../health/HasHealthIF.h" +#include "HasHealthIF.h" #include "../objectmanager/ObjectManagerIF.h" + class ManagesHealthIF { public: virtual ~ManagesHealthIF() { @@ -49,4 +50,4 @@ public: } }; -#endif /* FRAMEWORK_HEALTH_MANAGESHEALTHIF_H_ */ +#endif /* FSFW_HEALTH_MANAGESHEALTHIF_H_ */ From 2f0b36de46938bf6dd58539f75f91f183e567d25 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Wed, 23 Sep 2020 19:54:22 +0200 Subject: [PATCH 102/192] updated framework object list --- objectmanager/frameworkObjects.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/objectmanager/frameworkObjects.h b/objectmanager/frameworkObjects.h index 4a30e70a..87439c88 100644 --- a/objectmanager/frameworkObjects.h +++ b/objectmanager/frameworkObjects.h @@ -8,6 +8,8 @@ enum framework_objects { PUS_SERVICE_2 = 0x53000002, PUS_SERVICE_5 = 0x53000005, PUS_SERVICE_8 = 0x53000008, + PUS_SERVICE_9 = 0x53000009, + PUS_SERVICE_17 = 0x53000017, PUS_SERVICE_200 = 0x53000200, //Generic IDs for IPC, modes, health, events From 43ab0ba2702f482f1f5e7d39493a90e66bb91336 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Wed, 23 Sep 2020 19:55:48 +0200 Subject: [PATCH 103/192] updated subsystemId ranged --- events/fwSubsystemIdRanges.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/events/fwSubsystemIdRanges.h b/events/fwSubsystemIdRanges.h index 3c57c160..8dc4def7 100644 --- a/events/fwSubsystemIdRanges.h +++ b/events/fwSubsystemIdRanges.h @@ -19,7 +19,8 @@ enum { SYSTEM_MANAGER_1 = 75, SYSTEM_1 = 79, PUS_SERVICE_1 = 80, - PUS_SERVICE_17 = 83, + PUS_SERVICE_9 = 89, + PUS_SERVICE_17 = 97, FW_SUBSYSTEM_ID_RANGE }; } From 5ca1c7bca2d7a5c431488afde034dbe6625807cb Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Wed, 23 Sep 2020 19:58:51 +0200 Subject: [PATCH 104/192] coutndown update --- timemanager/Countdown.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/timemanager/Countdown.cpp b/timemanager/Countdown.cpp index dfe0e1ec..20b56189 100644 --- a/timemanager/Countdown.cpp +++ b/timemanager/Countdown.cpp @@ -1,7 +1,6 @@ #include "Countdown.h" -Countdown::Countdown(uint32_t initialTimeout): startTime(0), - timeout(initialTimeout) { +Countdown::Countdown(uint32_t initialTimeout): timeout(initialTimeout) { } Countdown::~Countdown() { From a65745d037a2ef26e51302d5c585620681a0f56a Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Fri, 25 Sep 2020 18:40:04 +0200 Subject: [PATCH 105/192] added explicit function to refresh task handle --- osal/FreeRTOS/BinSemaphUsingTask.cpp | 8 ++++++-- osal/FreeRTOS/BinSemaphUsingTask.h | 28 +++++++++++++++++++++------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/osal/FreeRTOS/BinSemaphUsingTask.cpp b/osal/FreeRTOS/BinSemaphUsingTask.cpp index dd1e48ca..9c29948e 100644 --- a/osal/FreeRTOS/BinSemaphUsingTask.cpp +++ b/osal/FreeRTOS/BinSemaphUsingTask.cpp @@ -1,5 +1,5 @@ -#include "../../osal/FreeRTOS/BinSemaphUsingTask.h" -#include "../../osal/FreeRTOS/TaskManagement.h" +#include "BinSemaphUsingTask.h" +#include "TaskManagement.h" #include "../../serviceinterface/ServiceInterfaceStream.h" BinarySemaphoreUsingTask::BinarySemaphoreUsingTask() { @@ -16,6 +16,10 @@ BinarySemaphoreUsingTask::~BinarySemaphoreUsingTask() { xTaskNotifyAndQuery(handle, 0, eSetValueWithOverwrite, nullptr); } +void BinarySemaphoreUsingTask::refreshTaskHandle() { + handle = TaskManagement::getCurrentTaskHandle(); +} + ReturnValue_t BinarySemaphoreUsingTask::acquire(TimeoutType timeoutType, uint32_t timeoutMs) { TickType_t timeout = 0; diff --git a/osal/FreeRTOS/BinSemaphUsingTask.h b/osal/FreeRTOS/BinSemaphUsingTask.h index 4317e0b2..65a091a3 100644 --- a/osal/FreeRTOS/BinSemaphUsingTask.h +++ b/osal/FreeRTOS/BinSemaphUsingTask.h @@ -1,5 +1,5 @@ -#ifndef FRAMEWORK_OSAL_FREERTOS_BINSEMAPHUSINGTASK_H_ -#define FRAMEWORK_OSAL_FREERTOS_BINSEMAPHUSINGTASK_H_ +#ifndef FSFW_OSAL_FREERTOS_BINSEMAPHUSINGTASK_H_ +#define FSFW_OSAL_FREERTOS_BINSEMAPHUSINGTASK_H_ #include "../../returnvalues/HasReturnvaluesIF.h" #include "../../tasks/SemaphoreIF.h" @@ -7,16 +7,20 @@ #include #include +// todo: does not work for older FreeRTOS version, so we should +// actually check whether tskKERNEL_VERSION_MAJOR is larger than.. 7 or 8 ? + /** * @brief Binary Semaphore implementation using the task notification value. * The notification value should therefore not be used - * for other purposes. + * for other purposes! * @details * Additional information: https://www.freertos.org/RTOS-task-notifications.html * and general semaphore documentation. * This semaphore is bound to the task it is created in! - * Take care of calling this function with the correct executing task, - * (for example in the initializeAfterTaskCreation() function). + * Take care of building this class with the correct executing task, + * (for example in the initializeAfterTaskCreation() function) or + * by calling refreshTaskHandle() with the correct executing task. */ class BinarySemaphoreUsingTask: public SemaphoreIF, public HasReturnvaluesIF { @@ -28,6 +32,16 @@ public: //! @brief Default dtor virtual~ BinarySemaphoreUsingTask(); + /** + * This function can be used to get the correct task handle from the + * currently executing task. + * + * This is required because the task notification value will be used + * as a binary semaphore, and the semaphore might be created by another + * task. + */ + void refreshTaskHandle(); + ReturnValue_t acquire(TimeoutType timeoutType = TimeoutType::BLOCKING, uint32_t timeoutMs = portMAX_DELAY) override; ReturnValue_t release() override; @@ -70,10 +84,10 @@ public: * - @c RETURN_FAILED on failure */ static ReturnValue_t releaseFromISR(TaskHandle_t taskToNotify, - BaseType_t * higherPriorityTaskWoken); + BaseType_t* higherPriorityTaskWoken); protected: TaskHandle_t handle; }; -#endif /* FRAMEWORK_OSAL_FREERTOS_BINSEMAPHUSINGTASK_H_ */ +#endif /* FSFW_OSAL_FREERTOS_BINSEMAPHUSINGTASK_H_ */ From cf28c9ff9d861b7ecd30a45b172635ed1766b882 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Fri, 25 Sep 2020 19:01:59 +0200 Subject: [PATCH 106/192] make event func changed --- events/Event.cpp | 6 ++++-- events/Event.h | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/events/Event.cpp b/events/Event.cpp index ea3d46fe..0f76b438 100644 --- a/events/Event.cpp +++ b/events/Event.cpp @@ -1,4 +1,5 @@ #include "Event.h" + namespace EVENT { EventId_t getEventId(Event event) { return (event & 0xFFFF); @@ -8,7 +9,8 @@ EventSeverity_t getSeverity(Event event) { return ((event >> 16) & 0xFF); } -Event makeEvent(EventId_t eventId, EventSeverity_t eventSeverity) { - return (eventSeverity << 16) + (eventId & 0xFFFF); +Event makeEvent(uint8_t subsystemId, uint8_t uniqueEventId, + EventSeverity_t eventSeverity) { + return (eventSeverity << 16) + (subsystemId * 100) + uniqueEventId; } } diff --git a/events/Event.h b/events/Event.h index f8410f32..f5434826 100644 --- a/events/Event.h +++ b/events/Event.h @@ -18,9 +18,10 @@ EventId_t getEventId(Event event); EventSeverity_t getSeverity(Event event); -Event makeEvent(EventId_t eventId, EventSeverity_t eventSeverity); - +Event makeEvent(uint8_t subsystemId, uint8_t uniqueEventId, + EventSeverity_t eventSeverity); } + namespace SEVERITY { static const EventSeverity_t INFO = 1; static const EventSeverity_t LOW = 2; From 9aca5cb6f246d3db825bb447fa18d28468a59ec4 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 26 Sep 2020 14:59:40 +0200 Subject: [PATCH 107/192] taken over convergence changes --- memory/AcceptsMemoryMessagesIF.h | 17 ++++--------- memory/MemoryHelper.cpp | 15 +++++------ memory/MemoryHelper.h | 36 +++++++++++++++++--------- memory/MemoryMessage.cpp | 27 ++++++++------------ memory/MemoryMessage.h | 43 +++++++++++++++++++------------- modes/HasModesIF.h | 24 +++++++----------- modes/ModeHelper.cpp | 7 +++--- modes/ModeHelper.h | 14 +++++------ modes/ModeMessage.cpp | 10 ++++---- modes/ModeMessage.h | 20 ++++++--------- 10 files changed, 106 insertions(+), 107 deletions(-) diff --git a/memory/AcceptsMemoryMessagesIF.h b/memory/AcceptsMemoryMessagesIF.h index 4c222dec..cf8aa5ec 100644 --- a/memory/AcceptsMemoryMessagesIF.h +++ b/memory/AcceptsMemoryMessagesIF.h @@ -1,15 +1,8 @@ -/** - * @file AcceptsMemoryMessagesIF.h - * @brief This file defines the AcceptsMemoryMessagesIF class. - * @date 11.07.2013 - * @author baetz - */ +#ifndef FSFW_MEMORY_ACCEPTSMEMORYMESSAGESIF_H_ +#define FSFW_MEMORY_ACCEPTSMEMORYMESSAGESIF_H_ -#ifndef ACCEPTSMEMORYMESSAGESIF_H_ -#define ACCEPTSMEMORYMESSAGESIF_H_ - -#include "../memory/HasMemoryIF.h" -#include "../memory/MemoryMessage.h" +#include "HasMemoryIF.h" +#include "MemoryMessage.h" #include "../ipc/MessageQueueSenderIF.h" class AcceptsMemoryMessagesIF : public HasMemoryIF { @@ -18,4 +11,4 @@ public: }; -#endif /* ACCEPTSMEMORYMESSAGESIF_H_ */ +#endif /* AFSFW_MEMORY_ACCEPTSMEMORYMESSAGESIF_H_ */ diff --git a/memory/MemoryHelper.cpp b/memory/MemoryHelper.cpp index 2daddf63..6b11882f 100644 --- a/memory/MemoryHelper.cpp +++ b/memory/MemoryHelper.cpp @@ -1,14 +1,15 @@ +#include "MemoryHelper.h" +#include "MemoryMessage.h" + #include "../globalfunctions/CRC.h" -#include "../memory/MemoryHelper.h" -#include "../memory/MemoryMessage.h" #include "../objectmanager/ObjectManagerIF.h" #include "../serialize/EndianConverter.h" #include "../serviceinterface/ServiceInterfaceStream.h" MemoryHelper::MemoryHelper(HasMemoryIF* workOnThis, MessageQueueIF* useThisQueue): - workOnThis(workOnThis), queueToUse(useThisQueue), ipcStore(nullptr), - ipcAddress(), lastCommand(CommandMessage::CMD_NONE), busy(false) { + workOnThis(workOnThis), queueToUse(useThisQueue), ipcAddress(), + lastCommand(CommandMessage::CMD_NONE), busy(false) { } ReturnValue_t MemoryHelper::handleMemoryCommand(CommandMessage* message) { @@ -34,7 +35,7 @@ ReturnValue_t MemoryHelper::handleMemoryCommand(CommandMessage* message) { } void MemoryHelper::completeLoad(ReturnValue_t errorCode, - const uint8_t* dataToCopy, const uint32_t size, uint8_t* copyHere) { + const uint8_t* dataToCopy, const size_t size, uint8_t* copyHere) { busy = false; switch (errorCode) { case HasMemoryIF::DO_IT_MYSELF: @@ -64,7 +65,7 @@ void MemoryHelper::completeLoad(ReturnValue_t errorCode, } void MemoryHelper::completeDump(ReturnValue_t errorCode, - const uint8_t* dataToCopy, const uint32_t size) { + const uint8_t* dataToCopy, const size_t size) { busy = false; CommandMessage reply; MemoryMessage::setMemoryReplyFailed(&reply, errorCode, lastCommand); @@ -121,7 +122,7 @@ void MemoryHelper::completeDump(ReturnValue_t errorCode, } void MemoryHelper::swapMatrixCopy(uint8_t* out, const uint8_t *in, - uint32_t totalSize, uint8_t datatypeSize) { + size_t totalSize, uint8_t datatypeSize) { if (totalSize % datatypeSize != 0){ return; } diff --git a/memory/MemoryHelper.h b/memory/MemoryHelper.h index 418cf50d..a651861c 100644 --- a/memory/MemoryHelper.h +++ b/memory/MemoryHelper.h @@ -1,11 +1,16 @@ -#ifndef FRAMEWORK_MEMORY_MEMORYHELPER_H_ -#define FRAMEWORK_MEMORY_MEMORYHELPER_H_ +#ifndef FSFW_MEMORY_MEMORYHELPER_H_ +#define FSFW_MEMORY_MEMORYHELPER_H_ + +#include "AcceptsMemoryMessagesIF.h" + #include "../ipc/CommandMessage.h" -#include "../memory/AcceptsMemoryMessagesIF.h" #include "../returnvalues/HasReturnvaluesIF.h" #include "../storagemanager/StorageManagerIF.h" #include "../ipc/MessageQueueIF.h" +/** + * @brief TODO: documentation. + */ class MemoryHelper : public HasReturnvaluesIF { public: static const uint8_t INTERFACE_ID = CLASS_ID::MEMORY_HELPER; @@ -13,6 +18,20 @@ public: static const ReturnValue_t INVALID_ADDRESS = MAKE_RETURN_CODE(0xE1); static const ReturnValue_t INVALID_SIZE = MAKE_RETURN_CODE(0xE2); static const ReturnValue_t STATE_MISMATCH = MAKE_RETURN_CODE(0xE3); + + MemoryHelper(HasMemoryIF* workOnThis, MessageQueueIF* useThisQueue); + ~MemoryHelper(); + + ReturnValue_t handleMemoryCommand(CommandMessage* message); + void completeLoad(ReturnValue_t errorCode, + const uint8_t* dataToCopy = nullptr, const size_t size = 0, + uint8_t* copyHere = nullptr); + void completeDump(ReturnValue_t errorCode, + const uint8_t* dataToCopy = nullptr, const size_t size = 0); + void swapMatrixCopy(uint8_t *out, const uint8_t *in, size_t totalSize, + uint8_t datatypeSize); + ReturnValue_t initialize(MessageQueueIF* queueToUse_); + private: HasMemoryIF* workOnThis; MessageQueueIF* queueToUse; @@ -25,13 +44,6 @@ private: void handleMemoryLoad(CommandMessage* message); void handleMemoryCheckOrDump(CommandMessage* message); ReturnValue_t initialize(); -public: - ReturnValue_t handleMemoryCommand(CommandMessage* message); - void completeLoad( ReturnValue_t errorCode, const uint8_t* dataToCopy = NULL, const uint32_t size = 0, uint8_t* copyHere = NULL ); - void completeDump( ReturnValue_t errorCode, const uint8_t* dataToCopy = NULL, const uint32_t size = 0); - void swapMatrixCopy( uint8_t *out, const uint8_t *in, uint32_t totalSize, uint8_t datatypeSize); - ReturnValue_t initialize(MessageQueueIF* queueToUse_); - MemoryHelper( HasMemoryIF* workOnThis, MessageQueueIF* useThisQueue ); - ~MemoryHelper(); + }; -#endif /* MEMORYHELPER_H_ */ +#endif /* FSFW_MEMORY_MEMORYHELPER_H_ */ diff --git a/memory/MemoryMessage.cpp b/memory/MemoryMessage.cpp index 4e077dee..94fa4691 100644 --- a/memory/MemoryMessage.cpp +++ b/memory/MemoryMessage.cpp @@ -1,7 +1,6 @@ -#include "../memory/MemoryMessage.h" +#include "MemoryMessage.h" + #include "../objectmanager/ObjectManagerIF.h" -MemoryMessage::MemoryMessage() { -} uint32_t MemoryMessage::getAddress(const CommandMessage* message) { return message->getParameter(); @@ -17,18 +16,17 @@ uint32_t MemoryMessage::getLength(const CommandMessage* message) { return message->getParameter2(); } -ReturnValue_t MemoryMessage::setMemoryDumpCommand(CommandMessage* message, +void MemoryMessage::setMemoryDumpCommand(CommandMessage* message, uint32_t address, uint32_t length) { message->setCommand(CMD_MEMORY_DUMP); message->setParameter( address ); message->setParameter2( length ); - return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t MemoryMessage::setMemoryDumpReply(CommandMessage* message, store_address_t storageID) { +void MemoryMessage::setMemoryDumpReply(CommandMessage* message, + store_address_t storageID) { message->setCommand(REPLY_MEMORY_DUMP); message->setParameter2( storageID.raw ); - return HasReturnvaluesIF::RETURN_OK; } void MemoryMessage::setMemoryLoadCommand(CommandMessage* message, @@ -64,22 +62,21 @@ void MemoryMessage::clear(CommandMessage* message) { } } -ReturnValue_t MemoryMessage::setMemoryCheckCommand(CommandMessage* message, +void MemoryMessage::setMemoryCheckCommand(CommandMessage* message, uint32_t address, uint32_t length) { message->setCommand(CMD_MEMORY_CHECK); message->setParameter( address ); message->setParameter2( length ); - return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t MemoryMessage::setMemoryCheckReply(CommandMessage* message, +void MemoryMessage::setMemoryCheckReply(CommandMessage* message, uint16_t crc) { message->setCommand(REPLY_MEMORY_CHECK); message->setParameter( crc ); - return HasReturnvaluesIF::RETURN_OK; } -void MemoryMessage::setCrcReturnValue(CommandMessage* message, ReturnValue_t returnValue){ +void MemoryMessage::setCrcReturnValue(CommandMessage* message, + ReturnValue_t returnValue){ message->setParameter(returnValue<<16); }; @@ -95,18 +92,16 @@ Command_t MemoryMessage::getInitialCommand(const CommandMessage* message) { return message->getParameter2(); } -ReturnValue_t MemoryMessage::setMemoryReplyFailed(CommandMessage* message, +void MemoryMessage::setMemoryReplyFailed(CommandMessage* message, ReturnValue_t errorCode, Command_t initialCommand) { message->setCommand(REPLY_MEMORY_FAILED); message->setParameter(errorCode); message->setParameter2(initialCommand); - return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t MemoryMessage::setMemoryCopyEnd(CommandMessage* message) { +void MemoryMessage::setMemoryCopyEnd(CommandMessage* message) { message->setCommand(END_OF_MEMORY_COPY); message->setParameter(0); message->setParameter2(0); - return HasReturnvaluesIF::RETURN_OK; } diff --git a/memory/MemoryMessage.h b/memory/MemoryMessage.h index a366eb9a..05b9926d 100644 --- a/memory/MemoryMessage.h +++ b/memory/MemoryMessage.h @@ -1,14 +1,15 @@ -#ifndef MEMORYMESSAGE_H_ -#define MEMORYMESSAGE_H_ +#ifndef FSFW_MEMORY_MEMORYMESSAGE_H_ +#define FSFW_MEMORY_MEMORYMESSAGE_H_ #include "../ipc/CommandMessage.h" #include "../storagemanager/StorageManagerIF.h" class MemoryMessage { -private: - MemoryMessage(); //A private ctor inhibits instantiation public: + // Instantiation forbidden. + MemoryMessage() = delete; + static const uint8_t MESSAGE_ID = messagetypes::MEMORY; static const Command_t CMD_MEMORY_LOAD = MAKE_COMMAND_ID( 0x01 ); static const Command_t CMD_MEMORY_DUMP = MAKE_COMMAND_ID( 0x02 ); @@ -19,21 +20,29 @@ public: static const Command_t END_OF_MEMORY_COPY = MAKE_COMMAND_ID(0xF0); static uint32_t getAddress( const CommandMessage* message ); - static store_address_t getStoreID( const CommandMessage* message ); + static store_address_t getStoreID(const CommandMessage* message); static uint32_t getLength( const CommandMessage* message ); - static ReturnValue_t getErrorCode( const CommandMessage* message ); - static ReturnValue_t setMemoryDumpCommand( CommandMessage* message, uint32_t address, uint32_t length ); - static ReturnValue_t setMemoryDumpReply( CommandMessage* message, store_address_t storageID ); - static void setMemoryLoadCommand( CommandMessage* message, uint32_t address, store_address_t storageID ); - static ReturnValue_t setMemoryCheckCommand( CommandMessage* message, uint32_t address, uint32_t length ); - static ReturnValue_t setMemoryCheckReply( CommandMessage* message, uint16_t crc ); - static ReturnValue_t setMemoryReplyFailed( CommandMessage* message, ReturnValue_t errorCode, Command_t initialCommand ); - static ReturnValue_t setMemoryCopyEnd( CommandMessage* message); + static ReturnValue_t getErrorCode(const CommandMessage* message); + static uint16_t getCrc(const CommandMessage* message ); + static ReturnValue_t getCrcReturnValue(const CommandMessage* message); + static Command_t getInitialCommand(const CommandMessage* message); + + static void setMemoryDumpCommand(CommandMessage* message, + uint32_t address, uint32_t length ); + static void setMemoryDumpReply(CommandMessage* message, + store_address_t storageID); + static void setMemoryLoadCommand(CommandMessage* message, + uint32_t address, store_address_t storageID ); + static void setMemoryCheckCommand(CommandMessage* message, + uint32_t address, uint32_t length); + static void setMemoryCheckReply(CommandMessage* message, + uint16_t crc); + static void setMemoryReplyFailed(CommandMessage* message, + ReturnValue_t errorCode, Command_t initialCommand); + static void setMemoryCopyEnd(CommandMessage* message); static void setCrcReturnValue(CommandMessage*, ReturnValue_t returnValue); - static uint16_t getCrc( const CommandMessage* message ); - static ReturnValue_t getCrcReturnValue(const CommandMessage* message); - static Command_t getInitialCommand( const CommandMessage* message ); + static void clear(CommandMessage* message); }; -#endif /* MEMORYMESSAGE_H_ */ +#endif /* FSFW_MEMORY_MEMORYMESSAGE_H_ */ diff --git a/modes/HasModesIF.h b/modes/HasModesIF.h index 39a50c2a..34a15937 100644 --- a/modes/HasModesIF.h +++ b/modes/HasModesIF.h @@ -1,18 +1,11 @@ -/** - * @file HasModesIF.h - * @brief This file defines the HasModesIF class. - * @date 20.06.2013 - * @author baetz - */ - -#ifndef HASMODESIF_H_ -#define HASMODESIF_H_ +#ifndef FSFW_MODES_HASMODESIF_H_ +#define FSFW_MODES_HASMODESIF_H_ +#include "ModeHelper.h" +#include "ModeMessage.h" #include "../events/Event.h" -#include "../modes/ModeHelper.h" -#include "../modes/ModeMessage.h" #include "../returnvalues/HasReturnvaluesIF.h" -#include +#include class HasModesIF { @@ -37,10 +30,11 @@ public: static const Mode_t MODE_ON = 1; //!< The device is powered and ready to perform operations. In this mode, no commands are sent by the device handler itself, but direct commands van be commanded and will be interpreted static const Mode_t MODE_OFF = 0; //!< The device is powered off. The only command accepted in this mode is a mode change to on. static const Submode_t SUBMODE_NONE = 0; //!< To avoid checks against magic number "0". - virtual ~HasModesIF() { - } + + virtual ~HasModesIF() {} virtual MessageQueueId_t getCommandQueue() const = 0; virtual void getMode(Mode_t *mode, Submode_t *submode) = 0; + protected: virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, uint32_t *msToReachTheMode) { @@ -54,4 +48,4 @@ protected: virtual void announceMode(bool recursive) {} }; -#endif /* HASMODESIF_H_ */ +#endif /*FSFW_MODES_HASMODESIF_H_ */ diff --git a/modes/ModeHelper.cpp b/modes/ModeHelper.cpp index 68f009e7..6be4f776 100644 --- a/modes/ModeHelper.cpp +++ b/modes/ModeHelper.cpp @@ -1,6 +1,7 @@ +#include "HasModesIF.h" +#include "ModeHelper.h" + #include "../ipc/MessageQueueSenderIF.h" -#include "../modes/HasModesIF.h" -#include "../modes/ModeHelper.h" #include "../serviceinterface/ServiceInterfaceStream.h" ModeHelper::ModeHelper(HasModesIF *owner) : @@ -26,7 +27,7 @@ ReturnValue_t ModeHelper::handleModeCommand(CommandMessage* command) { uint32_t timeout; ReturnValue_t result = owner->checkModeCommand(mode, submode, &timeout); if (result != HasReturnvaluesIF::RETURN_OK) { - ModeMessage::cantReachMode(&reply, result); + ModeMessage::setCantReachMode(&reply, result); MessageQueueSenderIF::sendMessage(command->getSender(), &reply, owner->getCommandQueue()); break; diff --git a/modes/ModeHelper.h b/modes/ModeHelper.h index 02cf5799..c2f089ec 100644 --- a/modes/ModeHelper.h +++ b/modes/ModeHelper.h @@ -1,8 +1,8 @@ -#ifndef MODEHELPER_H_ -#define MODEHELPER_H_ +#ifndef FSFW_MODES_MODEHELPER_H_ +#define FSFW_MODES_MODEHELPER_H_ +#include "ModeMessage.h" #include "../ipc/MessageQueueIF.h" -#include "../modes/ModeMessage.h" #include "../returnvalues/HasReturnvaluesIF.h" #include "../timemanager/Countdown.h" @@ -20,14 +20,14 @@ public: ReturnValue_t handleModeCommand(CommandMessage *message); /** - * - * @param parentQueue the Queue id of the parent object. Set to 0 if no parent present + * @param parentQueue the Queue id of the parent object. + * Set to 0 if no parent present */ void setParentQueue(MessageQueueId_t parentQueueId); ReturnValue_t initialize(MessageQueueId_t parentQueueId); - ReturnValue_t initialize(void); //void is there to stop eclipse CODAN from falsely reporting an error + ReturnValue_t initialize(void); void modeChanged(Mode_t mode, Submode_t submode); @@ -50,4 +50,4 @@ private: void sendModeInfoMessage(Mode_t ownerMode, Submode_t ownerSubmode); }; -#endif /* MODEHELPER_H_ */ +#endif /* FSFW_MODES_MODEHELPER_H_ */ diff --git a/modes/ModeMessage.cpp b/modes/ModeMessage.cpp index 7ad7d06f..b33bba60 100644 --- a/modes/ModeMessage.cpp +++ b/modes/ModeMessage.cpp @@ -1,4 +1,4 @@ -#include "../modes/ModeMessage.h" +#include "ModeMessage.h" Mode_t ModeMessage::getMode(const CommandMessage* message) { return message->getParameter(); @@ -8,12 +8,11 @@ Submode_t ModeMessage::getSubmode(const CommandMessage* message) { return message->getParameter2(); } -ReturnValue_t ModeMessage::setModeMessage(CommandMessage* message, Command_t command, - Mode_t mode, Submode_t submode) { +void ModeMessage::setModeMessage(CommandMessage* message, + Command_t command, Mode_t mode, Submode_t submode) { message->setCommand( command ); message->setParameter( mode ); message->setParameter2( submode ); - return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t ModeMessage::getCantReachModeReason(const CommandMessage* message) { @@ -24,7 +23,8 @@ void ModeMessage::clear(CommandMessage* message) { message->setCommand(CommandMessage::CMD_NONE); } -void ModeMessage::cantReachMode(CommandMessage* message, ReturnValue_t reason) { +void ModeMessage::setCantReachMode(CommandMessage* message, + ReturnValue_t reason) { message->setCommand(REPLY_CANT_REACH_MODE); message->setParameter(reason); message->setParameter2(0); diff --git a/modes/ModeMessage.h b/modes/ModeMessage.h index 925f3fc1..856996cf 100644 --- a/modes/ModeMessage.h +++ b/modes/ModeMessage.h @@ -1,12 +1,5 @@ -/** - * @file ModeMessage.h - * @brief This file defines the ModeMessage class. - * @date 17.07.2013 - * @author baetz - */ - -#ifndef MODEMESSAGE_H_ -#define MODEMESSAGE_H_ +#ifndef FSFW_MODES_MODEMESSAGE_H_ +#define FSFW_MODES_MODEMESSAGE_H_ #include "../ipc/CommandMessage.h" @@ -30,11 +23,12 @@ public: static Mode_t getMode(const CommandMessage* message); static Submode_t getSubmode(const CommandMessage* message); - static ReturnValue_t setModeMessage(CommandMessage* message, + static ReturnValue_t getCantReachModeReason(const CommandMessage* message); + + static void setModeMessage(CommandMessage* message, Command_t command, Mode_t mode, Submode_t submode); - static void cantReachMode(CommandMessage* message, ReturnValue_t reason); - static ReturnValue_t getCantReachModeReason(const CommandMessage* message); + static void setCantReachMode(CommandMessage* message, ReturnValue_t reason); static void clear(CommandMessage* message); }; -#endif /* MODEMESSAGE_H_ */ +#endif /* FSFW_MODES_MODEMESSAGE_H_ */ From fab7eb8a5d40386237ee243cc98af78e22f5fffe Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 26 Sep 2020 15:03:04 +0200 Subject: [PATCH 108/192] controller base update --- controller/ControllerBase.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/controller/ControllerBase.cpp b/controller/ControllerBase.cpp index da84ed27..4f50fe1f 100644 --- a/controller/ControllerBase.cpp +++ b/controller/ControllerBase.cpp @@ -1,5 +1,5 @@ -#include "../subsystem/SubsystemBase.h" -#include "../controller/ControllerBase.h" +#include "ControllerBase.h" + #include "../subsystem/SubsystemBase.h" #include "../ipc/QueueFactory.h" #include "../action/HasActionsIF.h" @@ -25,7 +25,7 @@ ReturnValue_t ControllerBase::initialize() { MessageQueueId_t parentQueue = 0; if (parentId != objects::NO_OBJECT) { SubsystemBase *parent = objectManager->get(parentId); - if (parent == NULL) { + if (parent == nullptr) { return RETURN_FAILED; } parentQueue = parent->getCommandQueue(); From 08d0e0949342c3620fb119c9d2e6dabde243e2aa Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 26 Sep 2020 15:16:13 +0200 Subject: [PATCH 109/192] power equalization --- power/Fuse.cpp | 20 ++++++++++++-------- power/Fuse.h | 13 +++++++------ power/PowerComponent.cpp | 24 +++++++++--------------- power/PowerComponent.h | 24 ++++++++++++++---------- power/PowerComponentIF.h | 14 +++++++------- power/PowerSensor.cpp | 14 ++++++++------ power/PowerSensor.h | 8 ++++---- power/PowerSwitchIF.h | 23 ++++++++--------------- power/PowerSwitcher.cpp | 25 ++++++++++++++++--------- power/PowerSwitcher.h | 19 ++++++++++++------- 10 files changed, 97 insertions(+), 87 deletions(-) diff --git a/power/Fuse.cpp b/power/Fuse.cpp index 3ea0b18c..ace625bf 100644 --- a/power/Fuse.cpp +++ b/power/Fuse.cpp @@ -1,7 +1,8 @@ +#include "Fuse.h" + #include "../monitoring/LimitViolationReporter.h" #include "../monitoring/MonitoringMessageContent.h" #include "../objectmanager/ObjectManagerIF.h" -#include "../power/Fuse.h" #include "../serialize/SerialFixedArrayListAdapter.h" #include "../ipc/QueueFactory.h" @@ -10,13 +11,16 @@ object_id_t Fuse::powerSwitchId = 0; Fuse::Fuse(object_id_t fuseObjectId, uint8_t fuseId, VariableIds ids, float maxCurrent, uint16_t confirmationCount) : SystemObject(fuseObjectId), oldFuseState(0), fuseId(fuseId), powerIF( - NULL), currentLimit(fuseObjectId, 1, ids.pidCurrent, confirmationCount, - maxCurrent, FUSE_CURRENT_HIGH), powerMonitor(fuseObjectId, 2, - GlobalDataPool::poolIdAndPositionToPid(ids.poolIdPower, 0), - confirmationCount), set(), voltage(ids.pidVoltage, &set), current( - ids.pidCurrent, &set), state(ids.pidState, &set), power( - ids.poolIdPower, &set, PoolVariableIF::VAR_READ_WRITE), commandQueue( - NULL), parameterHelper(this), healthHelper(this, fuseObjectId) { + NULL), + currentLimit(fuseObjectId, 1, ids.pidCurrent, confirmationCount, + maxCurrent, FUSE_CURRENT_HIGH), + powerMonitor(fuseObjectId, 2, + GlobalDataPool::poolIdAndPositionToPid(ids.poolIdPower, 0), + confirmationCount), + set(), voltage(ids.pidVoltage, &set), current(ids.pidCurrent, &set), + state(ids.pidState, &set), + power(ids.poolIdPower, &set, PoolVariableIF::VAR_READ_WRITE), + parameterHelper(this), healthHelper(this, fuseObjectId) { commandQueue = QueueFactory::instance()->createMessageQueue(); } diff --git a/power/Fuse.h b/power/Fuse.h index dd8759f4..13a0eb7c 100644 --- a/power/Fuse.h +++ b/power/Fuse.h @@ -1,13 +1,14 @@ -#ifndef FUSE_H_ -#define FUSE_H_ +#ifndef FSFW_POWER_FUSE_H_ +#define FSFW_POWER_FUSE_H_ + +#include "PowerComponentIF.h" +#include "PowerSwitchIF.h" #include "../datapoolglob/GlobalDataSet.h" #include "../datapoolglob/GlobalPoolVariable.h" #include "../datapoolglob/PIDReader.h" #include "../devicehandlers/HealthDevice.h" #include "../monitoring/AbsLimitMonitor.h" -#include "../power/PowerComponentIF.h" -#include "../power/PowerSwitchIF.h" #include "../returnvalues/HasReturnvaluesIF.h" #include "../parameters/ParameterHelper.h" #include @@ -90,7 +91,7 @@ private: PIDReader current; PIDReader state; gp_float_t power; - MessageQueueIF* commandQueue; + MessageQueueIF* commandQueue = nullptr; ParameterHelper parameterHelper; HealthHelper healthHelper; static object_id_t powerSwitchId; @@ -103,4 +104,4 @@ private: bool areSwitchesOfComponentOn(DeviceList::iterator iter); }; -#endif /* FUSE_H_ */ +#endif /* FSFW_POWER_FUSE_H_ */ diff --git a/power/PowerComponent.cpp b/power/PowerComponent.cpp index a3797055..4af7c96b 100644 --- a/power/PowerComponent.cpp +++ b/power/PowerComponent.cpp @@ -1,20 +1,14 @@ -/** - * @file PowerComponent.cpp - * @brief This file defines the PowerComponent class. - * @date 28.08.2014 - * @author baetz - */ +#include "PowerComponent.h" -#include "../power/PowerComponent.h" - -PowerComponent::PowerComponent() : - deviceObjectId(0), switchId1(0xFF), switchId2(0xFF), doIHaveTwoSwitches( - false), min(0.0), max(0.0), moduleId(0) { +PowerComponent::PowerComponent(): switchId1(0xFF), switchId2(0xFF), + doIHaveTwoSwitches(false) { } -PowerComponent::PowerComponent(object_id_t setId, uint8_t moduleId, float min, float max, - uint8_t switchId1, bool twoSwitches, uint8_t switchId2) : - deviceObjectId(setId), switchId1(switchId1), switchId2(switchId2), doIHaveTwoSwitches( - twoSwitches), min(min), max(max), moduleId(moduleId) { + +PowerComponent::PowerComponent(object_id_t setId, uint8_t moduleId, float min, + float max, uint8_t switchId1, bool twoSwitches, uint8_t switchId2) : + deviceObjectId(setId), switchId1(switchId1), switchId2(switchId2), + doIHaveTwoSwitches(twoSwitches), min(min), max(max), + moduleId(moduleId) { } ReturnValue_t PowerComponent::serialize(uint8_t** buffer, size_t* size, diff --git a/power/PowerComponent.h b/power/PowerComponent.h index dc5217be..c1add3b9 100644 --- a/power/PowerComponent.h +++ b/power/PowerComponent.h @@ -1,13 +1,17 @@ -#ifndef POWERCOMPONENT_H_ -#define POWERCOMPONENT_H_ +#ifndef FSFW_POWER_POWERCOMPONENT_H_ +#define FSFW_POWER_POWERCOMPONENT_H_ +#include "PowerComponentIF.h" + +#include "../objectmanager/frameworkObjects.h" #include "../objectmanager/SystemObjectIF.h" -#include "../power/PowerComponentIF.h" + class PowerComponent: public PowerComponentIF { public: - PowerComponent(object_id_t setId, uint8_t moduleId, float min, float max, uint8_t switchId1, - bool twoSwitches = false, uint8_t switchId2 = 0xFF); + PowerComponent(object_id_t setId, uint8_t moduleId, float min, float max, + uint8_t switchId1, bool twoSwitches = false, + uint8_t switchId2 = 0xFF); virtual object_id_t getDeviceObjectId(); @@ -31,18 +35,18 @@ public: ParameterWrapper *parameterWrapper, const ParameterWrapper *newValues, uint16_t startAtIndex); private: - const object_id_t deviceObjectId; + const object_id_t deviceObjectId = objects::NO_OBJECT; const uint8_t switchId1; const uint8_t switchId2; const bool doIHaveTwoSwitches; - float min; - float max; + float min = 0.0; + float max = 0.0; - uint8_t moduleId; + uint8_t moduleId = 0; PowerComponent(); }; -#endif /* POWERCOMPONENT_H_ */ +#endif /* FSFW_POWER_POWERCOMPONENT_H_ */ diff --git a/power/PowerComponentIF.h b/power/PowerComponentIF.h index c2e3a6a5..58f27b6c 100644 --- a/power/PowerComponentIF.h +++ b/power/PowerComponentIF.h @@ -1,5 +1,5 @@ -#ifndef POWERCOMPONENTIF_H_ -#define POWERCOMPONENTIF_H_ +#ifndef FSFW_POWER_POWERCOMPONENTIF_H_ +#define FSFW_POWER_POWERCOMPONENTIF_H_ #include "../serialize/SerializeIF.h" #include "../parameters/HasParametersIF.h" @@ -10,15 +10,15 @@ public: } - virtual object_id_t getDeviceObjectId()=0; + virtual object_id_t getDeviceObjectId() = 0; - virtual uint8_t getSwitchId1()=0; - virtual uint8_t getSwitchId2()=0; - virtual bool hasTwoSwitches()=0; + virtual uint8_t getSwitchId1() = 0; + virtual uint8_t getSwitchId2() = 0; + virtual bool hasTwoSwitches() = 0; virtual float getMin() = 0; virtual float getMax() = 0; }; -#endif /* POWERCOMPONENTIF_H_ */ +#endif /* FSFW_POWER_POWERCOMPONENTIF_H_ */ diff --git a/power/PowerSensor.cpp b/power/PowerSensor.cpp index df26fb8e..739d02f2 100644 --- a/power/PowerSensor.cpp +++ b/power/PowerSensor.cpp @@ -1,14 +1,16 @@ -#include "../power/PowerSensor.h" +#include "PowerSensor.h" + #include "../ipc/QueueFactory.h" PowerSensor::PowerSensor(object_id_t setId, VariableIds ids, DefaultLimits limits, SensorEvents events, uint16_t confirmationCount) : - SystemObject(setId), commandQueue(NULL), parameterHelper(this), healthHelper(this, setId), set(), current( - ids.pidCurrent, &set), voltage(ids.pidVoltage, &set), power( - ids.poolIdPower, &set, PoolVariableIF::VAR_WRITE), currentLimit( - setId, MODULE_ID_CURRENT, ids.pidCurrent, confirmationCount, + SystemObject(setId), parameterHelper(this), healthHelper(this, setId), + set(), current(ids.pidCurrent, &set), voltage(ids.pidVoltage, &set), + power(ids.poolIdPower, &set, PoolVariableIF::VAR_WRITE), + currentLimit(setId, MODULE_ID_CURRENT, ids.pidCurrent, confirmationCount, limits.currentMin, limits.currentMax, events.currentLow, - events.currentHigh), voltageLimit(setId, MODULE_ID_VOLTAGE, + events.currentHigh), + voltageLimit(setId, MODULE_ID_VOLTAGE, ids.pidVoltage, confirmationCount, limits.voltageMin, limits.voltageMax, events.voltageLow, events.voltageHigh) { commandQueue = QueueFactory::instance()->createMessageQueue(); diff --git a/power/PowerSensor.h b/power/PowerSensor.h index da0bd8c7..20ebff39 100644 --- a/power/PowerSensor.h +++ b/power/PowerSensor.h @@ -1,5 +1,5 @@ -#ifndef POWERSENSOR_H_ -#define POWERSENSOR_H_ +#ifndef FSFW_POWER_POWERSENSOR_H_ +#define FSFW_POWER_POWERSENSOR_H_ #include "../datapoolglob/GlobalDataSet.h" #include "../datapoolglob/GlobalPoolVariable.h" @@ -50,7 +50,7 @@ public: ParameterWrapper *parameterWrapper, const ParameterWrapper *newValues, uint16_t startAtIndex); private: - MessageQueueIF* commandQueue; + MessageQueueIF* commandQueue = nullptr; ParameterHelper parameterHelper; HealthHelper healthHelper; GlobDataSet set; @@ -68,4 +68,4 @@ protected: LimitMonitor voltageLimit; }; -#endif /* POWERSENSOR_H_ */ +#endif /* FSFW_POWER_POWERSENSOR_H_ */ diff --git a/power/PowerSwitchIF.h b/power/PowerSwitchIF.h index 876a82c5..1422baeb 100644 --- a/power/PowerSwitchIF.h +++ b/power/PowerSwitchIF.h @@ -1,22 +1,15 @@ -/** - * @file PowerSwitchIF.h - * @brief This file defines the PowerSwitchIF class. - * @date 20.03.2013 - * @author baetz - */ - -#ifndef POWERSWITCHIF_H_ -#define POWERSWITCHIF_H_ +#ifndef FSFW_POWER_POWERSWITCHIF_H_ +#define FSFW_POWER_POWERSWITCHIF_H_ #include "../events/Event.h" #include "../returnvalues/HasReturnvaluesIF.h" /** * - * @brief This interface defines a connection to a device that is capable of turning on and off - * switches of devices identified by a switch ID. - * @details The virtual functions of this interface do not allow to make any assignments - * because they can be called asynchronosuly (const ending). - * + * @brief This interface defines a connection to a device that is capable of + * turning on and off switches of devices identified by a switch ID. + * @details + * The virtual functions of this interface do not allow to make any assignments + * because they can be called asynchronosuly (const ending). * @ingroup interfaces */ class PowerSwitchIF : public HasReturnvaluesIF { @@ -77,4 +70,4 @@ public: }; -#endif /* POWERSWITCHIF_H_ */ +#endif /* FSFW_POWER_POWERSWITCHIF_H_ */ diff --git a/power/PowerSwitcher.cpp b/power/PowerSwitcher.cpp index 1844a11a..a9ada457 100644 --- a/power/PowerSwitcher.cpp +++ b/power/PowerSwitcher.cpp @@ -1,15 +1,17 @@ +#include "PowerSwitcher.h" + #include "../objectmanager/ObjectManagerIF.h" -#include "../power/PowerSwitcher.h" #include "../serviceinterface/ServiceInterfaceStream.h" PowerSwitcher::PowerSwitcher(uint8_t setSwitch1, uint8_t setSwitch2, - PowerSwitcher::State_t setStartState) : - state(setStartState), firstSwitch(setSwitch1), secondSwitch(setSwitch2), power(NULL) { + PowerSwitcher::State_t setStartState): + state(setStartState), firstSwitch(setSwitch1), + secondSwitch(setSwitch2) { } ReturnValue_t PowerSwitcher::initialize(object_id_t powerSwitchId) { power = objectManager->get(powerSwitchId); - if (power == NULL) { + if (power == nullptr) { return HasReturnvaluesIF::RETURN_FAILED; } return HasReturnvaluesIF::RETURN_OK; @@ -17,17 +19,22 @@ ReturnValue_t PowerSwitcher::initialize(object_id_t powerSwitchId) { ReturnValue_t PowerSwitcher::getStateOfSwitches() { SwitchReturn_t result = howManySwitches(); + switch (result) { case ONE_SWITCH: return power->getSwitchState(firstSwitch); case TWO_SWITCHES: - if ((power->getSwitchState(firstSwitch) == PowerSwitchIF::SWITCH_ON) - && (power->getSwitchState(secondSwitch) == PowerSwitchIF::SWITCH_ON)) { + ReturnValue_t firstSwitchState = power->getSwitchState(firstSwitch); + ReturnValue_t secondSwitchState = power->getSwitchState(firstSwitch); + if ((firstSwitchState == PowerSwitchIF::SWITCH_ON) + && (secondSwitchState == PowerSwitchIF::SWITCH_ON)) { return PowerSwitchIF::SWITCH_ON; - } else if ((power->getSwitchState(firstSwitch) == PowerSwitchIF::SWITCH_OFF) - && (power->getSwitchState(secondSwitch) == PowerSwitchIF::SWITCH_OFF)) { + } + else if ((firstSwitchState == PowerSwitchIF::SWITCH_OFF) + && (secondSwitchState == PowerSwitchIF::SWITCH_OFF)) { return PowerSwitchIF::SWITCH_OFF; - } else { + } + else { return HasReturnvaluesIF::RETURN_FAILED; } default: diff --git a/power/PowerSwitcher.h b/power/PowerSwitcher.h index 515ce042..f4e2138d 100644 --- a/power/PowerSwitcher.h +++ b/power/PowerSwitcher.h @@ -1,10 +1,13 @@ -#ifndef POWERSWITCHER_H_ -#define POWERSWITCHER_H_ -#include "../power/PowerSwitchIF.h" +#ifndef FSFW_POWER_POWERSWITCHER_H_ +#define FSFW_POWER_POWERSWITCHER_H_ + +#include "PowerSwitchIF.h" + +#include "../objectmanager/SystemObjectIF.h" #include "../returnvalues/HasReturnvaluesIF.h" #include "../timemanager/Countdown.h" -class PowerSwitcher : public HasReturnvaluesIF { +class PowerSwitcher: public HasReturnvaluesIF { public: enum State_t { WAIT_OFF, @@ -16,7 +19,8 @@ public: static const uint8_t INTERFACE_ID = CLASS_ID::POWER_SWITCHER; static const ReturnValue_t IN_POWER_TRANSITION = MAKE_RETURN_CODE(1); static const ReturnValue_t SWITCH_STATE_MISMATCH = MAKE_RETURN_CODE(2); - PowerSwitcher( uint8_t setSwitch1, uint8_t setSwitch2 = NO_SWITCH, State_t setStartState = SWITCH_IS_OFF ); + PowerSwitcher( uint8_t setSwitch1, uint8_t setSwitch2 = NO_SWITCH, + State_t setStartState = SWITCH_IS_OFF ); ReturnValue_t initialize(object_id_t powerSwitchId); void turnOn(); void turnOff(); @@ -29,7 +33,8 @@ public: private: uint8_t firstSwitch; uint8_t secondSwitch; - PowerSwitchIF* power; + PowerSwitchIF* power = nullptr; + static const uint8_t NO_SWITCH = 0xFF; enum SwitchReturn_t { ONE_SWITCH = 1, @@ -42,4 +47,4 @@ private: -#endif /* POWERSWITCHER_H_ */ +#endif /* FSFW_POWER_POWERSWITCHER_H_ */ From 6fd39dfac38da3c825f14b8171e05ef961dcb96c Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 26 Sep 2020 15:27:06 +0200 Subject: [PATCH 110/192] set struct reporting continued --- datapoollocal/LocalDataPoolManager.cpp | 12 ++++++++++++ housekeeping/HousekeepingMessage.cpp | 14 ++++++++++++++ housekeeping/HousekeepingMessage.h | 6 ++++++ power/PowerComponentIF.h | 5 ++--- power/PowerSwitcher.cpp | 3 ++- 5 files changed, 36 insertions(+), 4 deletions(-) diff --git a/datapoollocal/LocalDataPoolManager.cpp b/datapoollocal/LocalDataPoolManager.cpp index 635fafce..553d2ec1 100644 --- a/datapoollocal/LocalDataPoolManager.cpp +++ b/datapoollocal/LocalDataPoolManager.cpp @@ -392,5 +392,17 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid, sif::error << "HousekeepingManager::generateSetStructurePacket: " "Expected size is not equal to serialized size" << std::endl; } + + CommandMessage reply; + if(isDiagnostics) { + HousekeepingMessage::setDiagnosticsStuctureReportReply(&reply, + sid, storeId); + } + else { + HousekeepingMessage::setHkStuctureReportReply(&reply, + sid, storeId); + } + + hkQueue->reply(&reply); return result; } diff --git a/housekeeping/HousekeepingMessage.cpp b/housekeeping/HousekeepingMessage.cpp index 25475072..706bd273 100644 --- a/housekeeping/HousekeepingMessage.cpp +++ b/housekeeping/HousekeepingMessage.cpp @@ -126,3 +126,17 @@ sid_t HousekeepingMessage::getSid(const CommandMessage* message) { void HousekeepingMessage::setSid(CommandMessage *message, sid_t sid) { std::memcpy(message->getData(), &sid.raw, sizeof(sid.raw)); } + +void HousekeepingMessage::setHkStuctureReportReply(CommandMessage *reply, + sid_t sid, store_address_t storeId) { + reply->setCommand(HK_DEFINITIONS_REPORT); + setSid(reply, sid); + reply->setParameter3(storeId.raw); +} + +void HousekeepingMessage::setDiagnosticsStuctureReportReply( + CommandMessage *reply, sid_t sid, store_address_t storeId) { + reply->setCommand(DIAGNOSTICS_DEFINITION_REPORT); + setSid(reply, sid); + reply->setParameter3(storeId.raw); +} diff --git a/housekeeping/HousekeepingMessage.h b/housekeeping/HousekeepingMessage.h index 5c1b4e55..af89dade 100644 --- a/housekeeping/HousekeepingMessage.h +++ b/housekeeping/HousekeepingMessage.h @@ -121,6 +121,12 @@ public: static void setHkRequestSuccessReply(CommandMessage* reply, sid_t sid); static void setHkRequestFailureReply(CommandMessage* reply, sid_t sid, ReturnValue_t error); + + static void setHkStuctureReportReply(CommandMessage* reply, + sid_t sid, store_address_t storeId); + static void setDiagnosticsStuctureReportReply(CommandMessage* reply, + sid_t sid, store_address_t storeId); + static sid_t getHkRequestFailureReply(const CommandMessage* reply, ReturnValue_t* error); diff --git a/power/PowerComponentIF.h b/power/PowerComponentIF.h index 58f27b6c..f35b4d1d 100644 --- a/power/PowerComponentIF.h +++ b/power/PowerComponentIF.h @@ -3,12 +3,11 @@ #include "../serialize/SerializeIF.h" #include "../parameters/HasParametersIF.h" +#include "../objectmanager/SystemObjectIF.h" class PowerComponentIF : public SerializeIF, public HasParametersIF { public: - virtual ~PowerComponentIF() { - - } + virtual ~PowerComponentIF() {} virtual object_id_t getDeviceObjectId() = 0; diff --git a/power/PowerSwitcher.cpp b/power/PowerSwitcher.cpp index a9ada457..ed37998e 100644 --- a/power/PowerSwitcher.cpp +++ b/power/PowerSwitcher.cpp @@ -23,7 +23,7 @@ ReturnValue_t PowerSwitcher::getStateOfSwitches() { switch (result) { case ONE_SWITCH: return power->getSwitchState(firstSwitch); - case TWO_SWITCHES: + case TWO_SWITCHES: { ReturnValue_t firstSwitchState = power->getSwitchState(firstSwitch); ReturnValue_t secondSwitchState = power->getSwitchState(firstSwitch); if ((firstSwitchState == PowerSwitchIF::SWITCH_ON) @@ -37,6 +37,7 @@ ReturnValue_t PowerSwitcher::getStateOfSwitches() { else { return HasReturnvaluesIF::RETURN_FAILED; } + } default: return HasReturnvaluesIF::RETURN_FAILED; } From 55bdd2c2f5e8d656375912dc24a4d40515bca925 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 26 Sep 2020 15:28:28 +0200 Subject: [PATCH 111/192] include fix --- datapoollocal/LocalDataPoolManager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/datapoollocal/LocalDataPoolManager.cpp b/datapoollocal/LocalDataPoolManager.cpp index 553d2ec1..7986a3ed 100644 --- a/datapoollocal/LocalDataPoolManager.cpp +++ b/datapoollocal/LocalDataPoolManager.cpp @@ -1,6 +1,7 @@ -#include #include "LocalDataPoolManager.h" #include "LocalPoolDataSetBase.h" + +#include "../housekeeping/HousekeepingSetPacket.h" #include "../housekeeping/AcceptsHkPacketsIF.h" #include "../ipc/MutexFactory.h" #include "../ipc/MutexHelper.h" From 50621704073764a4673288442e54346af7bf4af2 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 26 Sep 2020 15:32:16 +0200 Subject: [PATCH 112/192] correct function used now --- datapoollocal/LocalDataPoolManager.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/datapoollocal/LocalDataPoolManager.cpp b/datapoollocal/LocalDataPoolManager.cpp index 7986a3ed..4299861e 100644 --- a/datapoollocal/LocalDataPoolManager.cpp +++ b/datapoollocal/LocalDataPoolManager.cpp @@ -154,9 +154,9 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage( } case(HousekeepingMessage::REPORT_DIAGNOSTICS_REPORT_STRUCTURES): + return generateSetStructurePacket(sid, true); case(HousekeepingMessage::REPORT_HK_REPORT_STRUCTURES): - //return generateSetStructurePacket(sid, ); - return HasReturnvaluesIF::RETURN_OK; + return generateSetStructurePacket(sid, false); case(HousekeepingMessage::MODIFY_DIAGNOSTICS_REPORT_COLLECTION_INTERVAL): case(HousekeepingMessage::MODIFY_PARAMETER_REPORT_COLLECTION_INTERVAL): { float newCollIntvl = 0; @@ -354,6 +354,7 @@ ReturnValue_t LocalDataPoolManager::changeCollectionInterval(sid_t sid, ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid, bool isDiagnostics) { + // Get and check dataset first. LocalPoolDataSetBase* dataSet = dynamic_cast( owner->getDataSetHandle(sid)); if(dataSet == nullptr) { @@ -373,6 +374,7 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid, float collectionInterval = dataSet->periodicHelper->getCollectionIntervalInSeconds(); + // Generate set packet which can be serialized. HousekeepingSetPacket setPacket = HousekeepingSetPacket(sid, reportingEnabled, valid, collectionInterval, dataSet); size_t expectedSize = setPacket.getSerializedSize(); @@ -386,6 +388,7 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid, return result; } + // Serialize set packet into store. size_t size = 0; result = setPacket.serialize(&storePtr, &size, expectedSize, SerializeIF::Endianness::BIG); @@ -394,6 +397,7 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid, "Expected size is not equal to serialized size" << std::endl; } + // Send structure reporting reply. CommandMessage reply; if(isDiagnostics) { HousekeepingMessage::setDiagnosticsStuctureReportReply(&reply, From de08bd6c8a9b8ec3f0627a028c319446d0a09bc7 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 26 Sep 2020 15:33:24 +0200 Subject: [PATCH 113/192] small include fix --- datapoollocal/LocalPoolVector.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datapoollocal/LocalPoolVector.h b/datapoollocal/LocalPoolVector.h index 69df192c..57c4b90b 100644 --- a/datapoollocal/LocalPoolVector.h +++ b/datapoollocal/LocalPoolVector.h @@ -194,7 +194,7 @@ private: }; -#include "../datapoollocal/LocalPoolVector.tpp" +#include "LocalPoolVector.tpp" template using lp_vec_t = LocalPoolVector; From 52d8c4f3a84c870e67f251be025ec27f657d2e17 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 26 Sep 2020 15:35:10 +0200 Subject: [PATCH 114/192] include guard fix --- datapoollocal/LocalDataPoolManager.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/datapoollocal/LocalDataPoolManager.h b/datapoollocal/LocalDataPoolManager.h index 44b15f59..55d971ce 100644 --- a/datapoollocal/LocalDataPoolManager.h +++ b/datapoollocal/LocalDataPoolManager.h @@ -1,5 +1,5 @@ -#ifndef FRAMEWORK_DATAPOOLLOCAL_LOCALDATAPOOLMANAGER_H_ -#define FRAMEWORK_DATAPOOLLOCAL_LOCALDATAPOOLMANAGER_H_ +#ifndef FSFW_DATAPOOLLOCAL_LOCALDATAPOOLMANAGER_H_ +#define FSFW_DATAPOOLLOCAL_LOCALDATAPOOLMANAGER_H_ #include "HasLocalDataPoolIF.h" @@ -276,4 +276,4 @@ ReturnValue_t LocalDataPoolManager::fetchPoolEntry(lp_id_t localPoolId, } -#endif /* FRAMEWORK_DATAPOOLLOCAL_LOCALDATAPOOLMANAGER_H_ */ +#endif /* FSFW_DATAPOOLLOCAL_LOCALDATAPOOLMANAGER_H_ */ From e67b1fce9a1f23d30a73d41142472adb7fb42b57 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 26 Sep 2020 16:38:07 +0200 Subject: [PATCH 115/192] added additional include --- controller/ControllerBase.h | 1 + datapoollocal/LocalDataPoolManager.h | 1 + 2 files changed, 2 insertions(+) diff --git a/controller/ControllerBase.h b/controller/ControllerBase.h index 400c3bb6..6c2ec1d6 100644 --- a/controller/ControllerBase.h +++ b/controller/ControllerBase.h @@ -7,6 +7,7 @@ #include "../modes/ModeHelper.h" #include "../objectmanager/SystemObject.h" #include "../tasks/ExecutableObjectIF.h" +#include "../tasks/PeriodicTaskIF.h" #include "../datapool/HkSwitchHelper.h" /** diff --git a/datapoollocal/LocalDataPoolManager.h b/datapoollocal/LocalDataPoolManager.h index 55d971ce..3b9b6cd9 100644 --- a/datapoollocal/LocalDataPoolManager.h +++ b/datapoollocal/LocalDataPoolManager.h @@ -173,6 +173,7 @@ private: //! Every housekeeping data manager has a mutex to protect access //! to it's data pool. MutexIF* mutex = nullptr; + /** The class which actually owns the manager (and its datapool). */ HasLocalDataPoolIF* owner = nullptr; From 4a97596030f2dbebcdebdd00c2c524e74df00d36 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 26 Sep 2020 17:21:32 +0200 Subject: [PATCH 116/192] internal error reporter uses new local datapool now --- internalError/InternalErrorDataset.h | 31 +++++++ internalError/InternalErrorReporter.cpp | 107 +++++++++++++++++------- internalError/InternalErrorReporter.h | 63 ++++++++++---- 3 files changed, 158 insertions(+), 43 deletions(-) create mode 100644 internalError/InternalErrorDataset.h diff --git a/internalError/InternalErrorDataset.h b/internalError/InternalErrorDataset.h new file mode 100644 index 00000000..c5dc3d73 --- /dev/null +++ b/internalError/InternalErrorDataset.h @@ -0,0 +1,31 @@ +#ifndef FSFW_INTERNALERROR_INTERNALERRORDATASET_H_ +#define FSFW_INTERNALERROR_INTERNALERRORDATASET_H_ + +#include +#include + +enum errorPoolIds { + TM_HITS, + QUEUE_HITS, + STORE_HITS +}; + + +class InternalErrorDataset: public StaticLocalDataSet<3 * sizeof(uint32_t)> { +public: + static constexpr uint8_t ERROR_SET_ID = 0; + + InternalErrorDataset(HasLocalDataPoolIF* owner): + StaticLocalDataSet(owner, ERROR_SET_ID) {} + + InternalErrorDataset(sid_t sid): + StaticLocalDataSet(sid) {} + + lp_var_t tmHits = lp_var_t(TM_HITS, sid.objectId, this); + lp_var_t queueHits = lp_var_t(QUEUE_HITS, sid.objectId, this); + lp_var_t storeHits = lp_var_t(STORE_HITS, sid.objectId, this); +}; + + + +#endif /* FSFW_INTERNALERROR_INTERNALERRORDATASET_H_ */ diff --git a/internalError/InternalErrorReporter.cpp b/internalError/InternalErrorReporter.cpp index 3424266b..f22fd03a 100644 --- a/internalError/InternalErrorReporter.cpp +++ b/internalError/InternalErrorReporter.cpp @@ -1,16 +1,18 @@ -#include "../datapoolglob/GlobalDataSet.h" #include "InternalErrorReporter.h" +#include "../ipc/QueueFactory.h" +#include "../datapoolglob/GlobalDataSet.h" #include "../datapoolglob/GlobalPoolVariable.h" #include "../ipc/MutexFactory.h" - #include "../serviceinterface/ServiceInterfaceStream.h" InternalErrorReporter::InternalErrorReporter(object_id_t setObjectId, - uint32_t queuePoolId, uint32_t tmPoolId, uint32_t storePoolId) : - SystemObject(setObjectId), mutex(NULL), queuePoolId(queuePoolId), - tmPoolId(tmPoolId),storePoolId(storePoolId), queueHits(0), tmHits(0), - storeHits(0) { + uint32_t messageQueueDepth) : + SystemObject(setObjectId), + commandQueue(QueueFactory::instance()-> + createMessageQueue(messageQueueDepth)), + poolManager(this, commandQueue), + internalErrorDataset(this) { mutex = MutexFactory::instance()->createMutex(); } @@ -18,28 +20,40 @@ InternalErrorReporter::~InternalErrorReporter() { MutexFactory::instance()->deleteMutex(mutex); } +void InternalErrorReporter::setDiagnosticPrintout(bool enable) { + this->diagnosticPrintout = enable; +} + ReturnValue_t InternalErrorReporter::performOperation(uint8_t opCode) { - - GlobDataSet mySet; - gp_uint32_t queueHitsInPool(queuePoolId, &mySet, - PoolVariableIF::VAR_READ_WRITE); - gp_uint32_t tmHitsInPool(tmPoolId, &mySet, - PoolVariableIF::VAR_READ_WRITE); - - gp_uint32_t storeHitsInPool(storePoolId, &mySet, - PoolVariableIF::VAR_READ_WRITE); - mySet.read(); + internalErrorDataset.read(INTERNAL_ERROR_MUTEX_TIMEOUT); uint32_t newQueueHits = getAndResetQueueHits(); uint32_t newTmHits = getAndResetTmHits(); uint32_t newStoreHits = getAndResetStoreHits(); - queueHitsInPool.value += newQueueHits; - tmHitsInPool.value += newTmHits; - storeHitsInPool.value += newStoreHits; +#ifdef DEBUG + if(diagnosticPrintout) { + if((newQueueHits > 0) or (newTmHits > 0) or (newStoreHits > 0)) { + sif::debug << "InternalErrorReporter::performOperation: Errors " + << "occured!" << std::endl; + sif::debug << "Queue errors: " << newQueueHits << std::endl; + sif::debug << "TM errors: " << newQueueHits << std::endl; + sif::debug << "Store errors: " << newQueueHits << std::endl; + } + } +#endif - mySet.commit(PoolVariableIF::VALID); + internalErrorDataset.queueHits.value += newQueueHits; + internalErrorDataset.storeHits.value += newTmHits; + internalErrorDataset.tmHits.value += newStoreHits; + internalErrorDataset.commit(INTERNAL_ERROR_MUTEX_TIMEOUT); + + CommandMessage message; + ReturnValue_t result = commandQueue->receiveMessage(&message); + if(result != MessageQueueIF::EMPTY) { + poolManager.handleHousekeepingMessage(&message); + } return HasReturnvaluesIF::RETURN_OK; } @@ -53,7 +67,7 @@ void InternalErrorReporter::lostTm() { uint32_t InternalErrorReporter::getAndResetQueueHits() { uint32_t value; - mutex->lockMutex(MutexIF::BLOCKING); + mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); value = queueHits; queueHits = 0; mutex->unlockMutex(); @@ -62,21 +76,21 @@ uint32_t InternalErrorReporter::getAndResetQueueHits() { uint32_t InternalErrorReporter::getQueueHits() { uint32_t value; - mutex->lockMutex(MutexIF::BLOCKING); + mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); value = queueHits; mutex->unlockMutex(); return value; } void InternalErrorReporter::incrementQueueHits() { - mutex->lockMutex(MutexIF::BLOCKING); + mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); queueHits++; mutex->unlockMutex(); } uint32_t InternalErrorReporter::getAndResetTmHits() { uint32_t value; - mutex->lockMutex(MutexIF::BLOCKING); + mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); value = tmHits; tmHits = 0; mutex->unlockMutex(); @@ -85,14 +99,14 @@ uint32_t InternalErrorReporter::getAndResetTmHits() { uint32_t InternalErrorReporter::getTmHits() { uint32_t value; - mutex->lockMutex(MutexIF::BLOCKING); + mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); value = tmHits; mutex->unlockMutex(); return value; } void InternalErrorReporter::incrementTmHits() { - mutex->lockMutex(MutexIF::BLOCKING); + mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); tmHits++; mutex->unlockMutex(); } @@ -103,7 +117,7 @@ void InternalErrorReporter::storeFull() { uint32_t InternalErrorReporter::getAndResetStoreHits() { uint32_t value; - mutex->lockMutex(MutexIF::BLOCKING); + mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); value = storeHits; storeHits = 0; mutex->unlockMutex(); @@ -112,14 +126,49 @@ uint32_t InternalErrorReporter::getAndResetStoreHits() { uint32_t InternalErrorReporter::getStoreHits() { uint32_t value; - mutex->lockMutex(MutexIF::BLOCKING); + mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); value = storeHits; mutex->unlockMutex(); return value; } void InternalErrorReporter::incrementStoreHits() { - mutex->lockMutex(MutexIF::BLOCKING); + mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); storeHits++; mutex->unlockMutex(); } + +object_id_t InternalErrorReporter::getObjectId() const { + return SystemObject::getObjectId(); +} + +MessageQueueId_t InternalErrorReporter::getCommandQueue() const { + return this->commandQueue->getId(); +} + +ReturnValue_t InternalErrorReporter::initializeLocalDataPool( + LocalDataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(errorPoolIds::TM_HITS, + new PoolEntry()); + localDataPoolMap.emplace(errorPoolIds::QUEUE_HITS, + new PoolEntry()); + localDataPoolMap.emplace(errorPoolIds::STORE_HITS, + new PoolEntry()); + return HasReturnvaluesIF::RETURN_OK; +} + +LocalDataPoolManager* InternalErrorReporter::getHkManagerHandle() { + return &poolManager; +} + +dur_millis_t InternalErrorReporter::getPeriodicOperationFrequency() const { + return this->executingTask->getPeriodMs(); +} + +LocalPoolDataSetBase* InternalErrorReporter::getDataSetHandle(sid_t sid) { + return &internalErrorDataset; +} + +void InternalErrorReporter::setTaskIF(PeriodicTaskIF *task) { + this->executingTask = task; +} diff --git a/internalError/InternalErrorReporter.h b/internalError/InternalErrorReporter.h index 9aa24a0f..1deb1422 100644 --- a/internalError/InternalErrorReporter.h +++ b/internalError/InternalErrorReporter.h @@ -1,37 +1,72 @@ -#ifndef INTERNALERRORREPORTER_H_ -#define INTERNALERRORREPORTER_H_ +#ifndef FSFW_INTERNALERROR_INTERNALERRORREPORTER_H_ +#define FSFW_INTERNALERROR_INTERNALERRORREPORTER_H_ #include "InternalErrorReporterIF.h" +#include "../tasks/PeriodicTaskIF.h" +#include "../internalError/InternalErrorDataset.h" +#include "../datapoollocal/LocalDataPoolManager.h" #include "../tasks/ExecutableObjectIF.h" #include "../objectmanager/SystemObject.h" #include "../ipc/MutexIF.h" +/** + * @brief This class is used to track internal errors like lost telemetry, + * failed message sending or a full store. + * @details + * All functions were kept virtual so this class can be extended easily + * to store custom internal errors (e.g. communication interface errors). + */ class InternalErrorReporter: public SystemObject, public ExecutableObjectIF, - public InternalErrorReporterIF { + public InternalErrorReporterIF, + public HasLocalDataPoolIF { public: - InternalErrorReporter(object_id_t setObjectId, uint32_t queuePoolId, - uint32_t tmPoolId, uint32_t storePoolId); + static constexpr uint8_t INTERNAL_ERROR_MUTEX_TIMEOUT = 20; + + InternalErrorReporter(object_id_t setObjectId, + uint32_t messageQueueDepth = 5); + + /** + * Enable diagnostic printout. Please note that this feature will + * only work if DEBUG has been supplied to the build defines. + * @param enable + */ + void setDiagnosticPrintout(bool enable); + virtual ~InternalErrorReporter(); - virtual ReturnValue_t performOperation(uint8_t opCode); + virtual object_id_t getObjectId() const override; + virtual MessageQueueId_t getCommandQueue() const override; + virtual ReturnValue_t initializeLocalDataPool( + LocalDataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; + virtual LocalDataPoolManager* getHkManagerHandle() override; + virtual dur_millis_t getPeriodicOperationFrequency() const override; + virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + + virtual ReturnValue_t performOperation(uint8_t opCode) override; virtual void queueMessageNotSent(); virtual void lostTm(); virtual void storeFull(); + + virtual void setTaskIF(PeriodicTaskIF* task) override; protected: - MutexIF* mutex; + MessageQueueIF* commandQueue; + LocalDataPoolManager poolManager; - uint32_t queuePoolId; - uint32_t tmPoolId; - uint32_t storePoolId; + PeriodicTaskIF* executingTask = nullptr; + MutexIF* mutex = nullptr; + InternalErrorDataset internalErrorDataset; - uint32_t queueHits; - uint32_t tmHits; - uint32_t storeHits; + bool diagnosticPrintout = true; + + uint32_t queueHits = 0; + uint32_t tmHits = 0; + uint32_t storeHits = 0; uint32_t getAndResetQueueHits(); uint32_t getQueueHits(); @@ -47,4 +82,4 @@ protected: }; -#endif /* INTERNALERRORREPORTER_H_ */ +#endif /* FSFW_INTERNALERROR_INTERNALERRORREPORTER_H_ */ From c3830da3d0a1f871bfca904b240f7cedfbb2a366 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 26 Sep 2020 17:24:06 +0200 Subject: [PATCH 117/192] bugfixes --- internalError/InternalErrorReporter.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internalError/InternalErrorReporter.cpp b/internalError/InternalErrorReporter.cpp index f22fd03a..3f7a0619 100644 --- a/internalError/InternalErrorReporter.cpp +++ b/internalError/InternalErrorReporter.cpp @@ -37,15 +37,15 @@ ReturnValue_t InternalErrorReporter::performOperation(uint8_t opCode) { sif::debug << "InternalErrorReporter::performOperation: Errors " << "occured!" << std::endl; sif::debug << "Queue errors: " << newQueueHits << std::endl; - sif::debug << "TM errors: " << newQueueHits << std::endl; - sif::debug << "Store errors: " << newQueueHits << std::endl; + sif::debug << "TM errors: " << newTmHits << std::endl; + sif::debug << "Store errors: " << newStoreHits << std::endl; } } #endif internalErrorDataset.queueHits.value += newQueueHits; - internalErrorDataset.storeHits.value += newTmHits; - internalErrorDataset.tmHits.value += newStoreHits; + internalErrorDataset.storeHits.value += newStoreHits; + internalErrorDataset.tmHits.value += newTmHits; internalErrorDataset.commit(INTERNAL_ERROR_MUTEX_TIMEOUT); From 6eaade239579ca814bb3aaded0f858b8f7bf47d7 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 26 Sep 2020 17:28:03 +0200 Subject: [PATCH 118/192] added new mode for local datapool manager --- datapoollocal/LocalDataPoolManager.h | 2 ++ internalError/InternalErrorReporter.cpp | 5 +++++ internalError/InternalErrorReporter.h | 1 + 3 files changed, 8 insertions(+) diff --git a/datapoollocal/LocalDataPoolManager.h b/datapoollocal/LocalDataPoolManager.h index 3b9b6cd9..6fb51b3e 100644 --- a/datapoollocal/LocalDataPoolManager.h +++ b/datapoollocal/LocalDataPoolManager.h @@ -146,6 +146,8 @@ public: enum class ReportingType: uint8_t { //! Periodic generation of HK packets. PERIODIC, + //! Housekeeping packet will be generated if values have changed. + UPDATE_HK, //! Update notification will be sent out as message. UPDATE_NOTIFICATION, //! Notification will be sent out as message and a snapshot of the diff --git a/internalError/InternalErrorReporter.cpp b/internalError/InternalErrorReporter.cpp index 3f7a0619..767ece51 100644 --- a/internalError/InternalErrorReporter.cpp +++ b/internalError/InternalErrorReporter.cpp @@ -12,6 +12,7 @@ InternalErrorReporter::InternalErrorReporter(object_id_t setObjectId, commandQueue(QueueFactory::instance()-> createMessageQueue(messageQueueDepth)), poolManager(this, commandQueue), + internalErrorSid(setObjectId, InternalErrorDataset::ERROR_SET_ID), internalErrorDataset(this) { mutex = MutexFactory::instance()->createMutex(); } @@ -154,6 +155,10 @@ ReturnValue_t InternalErrorReporter::initializeLocalDataPool( new PoolEntry()); localDataPoolMap.emplace(errorPoolIds::STORE_HITS, new PoolEntry()); + // todo: Only send HK if values have changed, will be supported by + // pool manager soon. + poolManager.subscribeForPeriodicPacket(internalErrorSid, false, + getPeriodicOperationFrequency(), false); return HasReturnvaluesIF::RETURN_OK; } diff --git a/internalError/InternalErrorReporter.h b/internalError/InternalErrorReporter.h index 1deb1422..85ac0836 100644 --- a/internalError/InternalErrorReporter.h +++ b/internalError/InternalErrorReporter.h @@ -60,6 +60,7 @@ protected: PeriodicTaskIF* executingTask = nullptr; MutexIF* mutex = nullptr; + sid_t internalErrorSid; InternalErrorDataset internalErrorDataset; bool diagnosticPrintout = true; From c12110cbf16c71394aa939e67629fc3c11370472 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 26 Sep 2020 22:23:17 +0200 Subject: [PATCH 119/192] has file system IF retvals --- memory/HasFileSystemIF.h | 15 ++++++++++++++- returnvalues/FwClassIds.h | 6 +++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/memory/HasFileSystemIF.h b/memory/HasFileSystemIF.h index 6065ebfd..916169ee 100644 --- a/memory/HasFileSystemIF.h +++ b/memory/HasFileSystemIF.h @@ -2,12 +2,24 @@ #define FSFW_MEMORY_HASFILESYSTEMIF_H_ #include "../returnvalues/HasReturnvaluesIF.h" +#include "../returnvalues/FwClassIds.h" +#include "../ipc/messageQueueDefinitions.h" + +#include /** * @author Jakob Meier */ class HasFileSystemIF { public: + static constexpr uint8_t INTERFACE_ID = CLASS_ID::FILE_SYSTEM; + + static constexpr ReturnValue_t FILE_DOES_NOT_EXIST = MAKE_RETURN_CODE(0x00); + static constexpr ReturnValue_t FILE_ALREADY_EXISTS = MAKE_RETURN_CODE(0x01); + + static constexpr ReturnValue_t DIRECTORY_DOES_NOT_EXIST = MAKE_RETURN_CODE(0x02); + static constexpr ReturnValue_t DIRECTORY_ALREADY_EXISTS = MAKE_RETURN_CODE(0x03); + static constexpr ReturnValue_t DIRECTORY_NOT_EMPTY = MAKE_RETURN_CODE(0x04); virtual ~HasFileSystemIF() {} /** @@ -29,7 +41,8 @@ public: virtual ReturnValue_t writeToFile(const char* dirname, const char* filename, const uint8_t* data, size_t size, uint16_t packetNumber) = 0; virtual ReturnValue_t createFile(const char* dirname, const char* filename, - const uint8_t* data, size_t size) = 0; + const uint8_t* data = nullptr, size_t size = 0, + size_t* bytesWritten = nullptr) = 0; virtual ReturnValue_t deleteFile(const char* dirname, const char* filename) = 0; }; diff --git a/returnvalues/FwClassIds.h b/returnvalues/FwClassIds.h index 781320e3..c8c0a3ad 100644 --- a/returnvalues/FwClassIds.h +++ b/returnvalues/FwClassIds.h @@ -65,9 +65,9 @@ enum { POOL_VARIABLE_IF, //PVA 59 HOUSEKEEPING_MANAGER, //HKM 60 DLE_ENCODER, //DLEE 61 - PUS_PARSER, //PUSP 62 - SERIAL_ANALYZER, //SERA 63 - PUS_SERVICE_9, // PUS9 64 + SERIAL_ANALYZER, //SERA 62 + PUS_SERVICE_9, // PUS9 63 + FILE_SYSTEM, // FLSY 64 FW_CLASS_ID_COUNT //is actually count + 1 ! }; From 88c4b2a5390a927d1eda33e9ac410ddc757cfc45 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 28 Sep 2020 16:56:42 +0200 Subject: [PATCH 120/192] bugfixes for srv3 --- datapoollocal/LocalDataPoolManager.cpp | 63 +++++++++++++++---------- housekeeping/HousekeepingSetPacket.h | 1 + internalError/InternalErrorReporter.cpp | 8 ++++ internalError/InternalErrorReporter.h | 1 + pus/Service3Housekeeping.cpp | 21 +++++++-- pus/Service3Housekeeping.h | 2 +- 6 files changed, 64 insertions(+), 32 deletions(-) diff --git a/datapoollocal/LocalDataPoolManager.cpp b/datapoollocal/LocalDataPoolManager.cpp index 4299861e..f07f458e 100644 --- a/datapoollocal/LocalDataPoolManager.cpp +++ b/datapoollocal/LocalDataPoolManager.cpp @@ -15,42 +15,53 @@ object_id_t LocalDataPoolManager::defaultHkDestination = objects::NO_OBJECT; LocalDataPoolManager::LocalDataPoolManager(HasLocalDataPoolIF* owner, MessageQueueIF* queueToUse, bool appendValidityBuffer): appendValidityBuffer(appendValidityBuffer) { - if(owner == nullptr) { - sif::error << "HkManager: Invalid supplied owner!" << std::endl; - return; - } - this->owner = owner; - mutex = MutexFactory::instance()->createMutex(); - if(mutex == nullptr) { - sif::error << "LocalDataPoolManager::LocalDataPoolManager: " - "Could not create mutex." << std::endl; - } - ipcStore = objectManager->get(objects::IPC_STORE); - if(ipcStore == nullptr) { - sif::error << "LocalDataPoolManager::LocalDataPoolManager: " - "Could not set IPC store." << std::endl; - } + if(owner == nullptr) { + sif::error << "LocalDataPoolManager::LocalDataPoolManager: " + << "Invalid supplied owner!" << std::endl; + return; + } + this->owner = owner; + mutex = MutexFactory::instance()->createMutex(); + if(mutex == nullptr) { + sif::error << "LocalDataPoolManager::LocalDataPoolManager: " + << "Could not create mutex." << std::endl; + } - hkQueue = queueToUse; - - if(defaultHkDestination != objects::NO_OBJECT) { - AcceptsHkPacketsIF* hkPacketReceiver = - objectManager->get(defaultHkDestination); - if(hkPacketReceiver != nullptr) { - hkDestinationId = hkPacketReceiver->getHkQueue(); - } - } + hkQueue = queueToUse; } LocalDataPoolManager::~LocalDataPoolManager() {} ReturnValue_t LocalDataPoolManager::initialize(MessageQueueIF* queueToUse) { if(queueToUse == nullptr) { - sif::error << "LocalDataPoolManager::initialize: Supplied queue " - "invalid!" << std::endl; + sif::error << "LocalDataPoolManager::initialize: " + << std::hex << "0x" << owner->getObjectId() << ". Supplied " + << "queue invalid!" << std::dec << std::endl; } hkQueue = queueToUse; + ipcStore = objectManager->get(objects::IPC_STORE); + if(ipcStore == nullptr) { + sif::error << "LocalDataPoolManager::initialize: " + << std::hex << "0x" << owner->getObjectId() << ": Could not " + << "set IPC store." <get(defaultHkDestination); + if(hkPacketReceiver != nullptr) { + hkDestinationId = hkPacketReceiver->getHkQueue(); + } + else { + sif::error << "LocalDataPoolManager::LocalDataPoolManager: " + << "Default HK destination object is invalid!" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + } + return HasReturnvaluesIF::RETURN_OK; } diff --git a/housekeeping/HousekeepingSetPacket.h b/housekeeping/HousekeepingSetPacket.h index 007b95be..051e4c61 100644 --- a/housekeeping/HousekeepingSetPacket.h +++ b/housekeeping/HousekeepingSetPacket.h @@ -12,6 +12,7 @@ public: objectId(sid.objectId), setId(sid.ownerSetId), reportingEnabled(reportingEnabled), valid(valid), collectionIntervalSeconds(collectionInterval), dataSet(dataSetPtr) { + setLinks(); } ReturnValue_t serialize(uint8_t** buffer, size_t* size, diff --git a/internalError/InternalErrorReporter.cpp b/internalError/InternalErrorReporter.cpp index 767ece51..4cdab9e7 100644 --- a/internalError/InternalErrorReporter.cpp +++ b/internalError/InternalErrorReporter.cpp @@ -177,3 +177,11 @@ LocalPoolDataSetBase* InternalErrorReporter::getDataSetHandle(sid_t sid) { void InternalErrorReporter::setTaskIF(PeriodicTaskIF *task) { this->executingTask = task; } + +ReturnValue_t InternalErrorReporter::initialize() { + ReturnValue_t result = poolManager.initialize(commandQueue); + if(result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + return SystemObject::initialize(); +} diff --git a/internalError/InternalErrorReporter.h b/internalError/InternalErrorReporter.h index 85ac0836..c715f7a0 100644 --- a/internalError/InternalErrorReporter.h +++ b/internalError/InternalErrorReporter.h @@ -45,6 +45,7 @@ public: virtual dur_millis_t getPeriodicOperationFrequency() const override; virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + virtual ReturnValue_t initialize() override; virtual ReturnValue_t performOperation(uint8_t opCode) override; virtual void queueMessageNotSent(); diff --git a/pus/Service3Housekeeping.cpp b/pus/Service3Housekeeping.cpp index ad08c328..c668ec8e 100644 --- a/pus/Service3Housekeeping.cpp +++ b/pus/Service3Housekeeping.cpp @@ -181,7 +181,7 @@ ReturnValue_t Service3Housekeeping::handleReply(const CommandMessage* reply, switch(command) { case(HousekeepingMessage::HK_REPORT): { - ReturnValue_t result = generateHkReport(reply, + ReturnValue_t result = generateHkReply(reply, static_cast(Subservice::HK_REPORT)); if(result != HasReturnvaluesIF::RETURN_OK) { return result; @@ -190,7 +190,7 @@ ReturnValue_t Service3Housekeeping::handleReply(const CommandMessage* reply, } case(HousekeepingMessage::DIAGNOSTICS_REPORT): { - ReturnValue_t result = generateHkReport(reply, + ReturnValue_t result = generateHkReply(reply, static_cast(Subservice::DIAGNOSTICS_REPORT)); if(result != HasReturnvaluesIF::RETURN_OK) { return result; @@ -198,6 +198,17 @@ ReturnValue_t Service3Housekeeping::handleReply(const CommandMessage* reply, return CommandingServiceBase::EXECUTION_COMPLETE; } + case(HousekeepingMessage::HK_DEFINITIONS_REPORT): { + return generateHkReply(reply, static_cast( + Subservice::HK_DEFINITIONS_REPORT)); + break; + } + case(HousekeepingMessage::DIAGNOSTICS_DEFINITION_REPORT): { + return generateHkReply(reply, static_cast( + Subservice::DIAGNOSTICS_REPORT)); + break; + } + case(HousekeepingMessage::HK_REQUEST_SUCCESS): { return CommandingServiceBase::EXECUTION_COMPLETE; } @@ -226,13 +237,13 @@ void Service3Housekeeping::handleUnrequestedReply( switch(command) { case(HousekeepingMessage::DIAGNOSTICS_REPORT): { - result = generateHkReport(reply, + result = generateHkReply(reply, static_cast(Subservice::DIAGNOSTICS_REPORT)); break; } case(HousekeepingMessage::HK_REPORT): { - result = generateHkReport(reply, + result = generateHkReply(reply, static_cast(Subservice::HK_REPORT)); break; } @@ -254,7 +265,7 @@ MessageQueueId_t Service3Housekeeping::getHkQueue() const { return commandQueue->getId(); } -ReturnValue_t Service3Housekeeping::generateHkReport( +ReturnValue_t Service3Housekeeping::generateHkReply( const CommandMessage* hkMessage, uint8_t subserviceId) { store_address_t storeId; diff --git a/pus/Service3Housekeeping.h b/pus/Service3Housekeeping.h index 01964bab..269710ef 100644 --- a/pus/Service3Housekeeping.h +++ b/pus/Service3Housekeeping.h @@ -82,7 +82,7 @@ private: ReturnValue_t checkInterfaceAndAcquireMessageQueue( MessageQueueId_t* messageQueueToSet, object_id_t* objectId); - ReturnValue_t generateHkReport(const CommandMessage* hkMessage, + ReturnValue_t generateHkReply(const CommandMessage* hkMessage, uint8_t subserviceId); ReturnValue_t prepareReportingTogglingCommand(CommandMessage* command, object_id_t objectId, bool enableReporting, bool isDiagnostics, From bf574c12e4ea8397062d17a3e047e7de7d223437 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 28 Sep 2020 21:09:56 +0200 Subject: [PATCH 121/192] bugfixes, owner ptr not const anymore --- datapoollocal/LocalDataPoolManager.cpp | 3 ++- datapoollocal/LocalDataPoolManager.h | 2 +- datapoollocal/LocalPoolDataSetBase.cpp | 20 ++++++++++++-- datapoollocal/LocalPoolDataSetBase.h | 4 ++- datapoollocal/LocalPoolVariable.tpp | 37 +++++++++++++------------- housekeeping/HousekeepingSetPacket.h | 2 +- 6 files changed, 44 insertions(+), 24 deletions(-) diff --git a/datapoollocal/LocalDataPoolManager.cpp b/datapoollocal/LocalDataPoolManager.cpp index f07f458e..1a8239ae 100644 --- a/datapoollocal/LocalDataPoolManager.cpp +++ b/datapoollocal/LocalDataPoolManager.cpp @@ -229,7 +229,7 @@ MutexIF* LocalDataPoolManager::getMutexHandle() { return mutex; } -const HasLocalDataPoolIF* LocalDataPoolManager::getOwner() const { +HasLocalDataPoolIF* LocalDataPoolManager::getOwner() { return owner; } @@ -374,6 +374,7 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid, return HasReturnvaluesIF::RETURN_FAILED; } + bool targetIsDiagnostics = dataSet->isDiagnostics(); if((targetIsDiagnostics and not isDiagnostics) or (not targetIsDiagnostics and isDiagnostics)) { diff --git a/datapoollocal/LocalDataPoolManager.h b/datapoollocal/LocalDataPoolManager.h index 6fb51b3e..e55efa9c 100644 --- a/datapoollocal/LocalDataPoolManager.h +++ b/datapoollocal/LocalDataPoolManager.h @@ -127,7 +127,7 @@ public: */ ReturnValue_t initializeHousekeepingPoolEntriesOnce(); - const HasLocalDataPoolIF* getOwner() const; + HasLocalDataPoolIF* getOwner(); ReturnValue_t printPoolEntry(lp_id_t localPoolId); diff --git a/datapoollocal/LocalPoolDataSetBase.cpp b/datapoollocal/LocalPoolDataSetBase.cpp index c280e7c7..da0a86b2 100644 --- a/datapoollocal/LocalPoolDataSetBase.cpp +++ b/datapoollocal/LocalPoolDataSetBase.cpp @@ -119,8 +119,14 @@ ReturnValue_t LocalPoolDataSetBase::unlockDataPool() { } ReturnValue_t LocalPoolDataSetBase::serializeLocalPoolIds(uint8_t** buffer, - size_t* size, size_t maxSize, - SerializeIF::Endianness streamEndianness) const { + size_t* size, size_t maxSize,SerializeIF::Endianness streamEndianness, + bool serializeFillCount) const { + // Serialize as uint8_t + uint8_t fillCount = this->fillCount; + if(serializeFillCount) { + SerializeAdapter::serialize(&fillCount, buffer, size, maxSize, + streamEndianness); + } for (uint16_t count = 0; count < fillCount; count++) { lp_id_t currentPoolId = registeredVariables[count]->getDataPoolId(); auto result = SerializeAdapter::serialize(¤tPoolId, buffer, @@ -135,6 +141,16 @@ ReturnValue_t LocalPoolDataSetBase::serializeLocalPoolIds(uint8_t** buffer, } +uint8_t LocalPoolDataSetBase::getLocalPoolIdsSerializedSize( + bool serializeFillCount) const { + if(serializeFillCount) { + return fillCount * sizeof(lp_id_t) + sizeof(uint8_t); + } + else { + return fillCount * sizeof(lp_id_t); + } +} + size_t LocalPoolDataSetBase::getSerializedSize() const { if(withValidityBuffer) { uint8_t validityMaskSize = std::ceil(static_cast(fillCount)/8.0); diff --git a/datapoollocal/LocalPoolDataSetBase.h b/datapoollocal/LocalPoolDataSetBase.h index 83e0425c..4f277123 100644 --- a/datapoollocal/LocalPoolDataSetBase.h +++ b/datapoollocal/LocalPoolDataSetBase.h @@ -97,7 +97,9 @@ public: size_t *size, SerializeIF::Endianness streamEndianness); ReturnValue_t serializeLocalPoolIds(uint8_t** buffer, size_t* size, size_t maxSize, - SerializeIF::Endianness streamEndianness) const; + SerializeIF::Endianness streamEndianness, + bool serializeFillCount = true) const; + uint8_t getLocalPoolIdsSerializedSize(bool serializeFillCount = true) const; /** * Set the dataset valid or invalid diff --git a/datapoollocal/LocalPoolVariable.tpp b/datapoollocal/LocalPoolVariable.tpp index 09d10acc..b47e602c 100644 --- a/datapoollocal/LocalPoolVariable.tpp +++ b/datapoollocal/LocalPoolVariable.tpp @@ -9,36 +9,37 @@ template inline LocalPoolVar::LocalPoolVar(lp_id_t poolId, HasLocalDataPoolIF* hkOwner, DataSetIF* dataSet, pool_rwm_t setReadWriteMode): - localPoolId(poolId),readWriteMode(setReadWriteMode) { + localPoolId(poolId), readWriteMode(setReadWriteMode) { if(poolId == PoolVariableIF::NO_PARAMETER) { - sif::warning << "LocalPoolVector: 0 passed as pool ID, which is the " - "NO_PARAMETER value!" << std::endl; + sif::warning << "LocalPoolVar::LocalPoolVar: 0 passed as pool ID, " + << "which is the NO_PARAMETER value!" << std::endl; } if(hkOwner == nullptr) { - sif::error << "LocalPoolVariable: The supplied pool owner is a nullptr!" - << std::endl; + sif::error << "LocalPoolVar::LocalPoolVar: The supplied pool " + << "owner is a invalid!" << std::endl; return; } hkManager = hkOwner->getHkManagerHandle(); if(dataSet != nullptr) { - dataSet->registerVariable(this); + dataSet->registerVariable(this); } } template inline LocalPoolVar::LocalPoolVar(lp_id_t poolId, object_id_t poolOwner, - DataSetIF *dataSet, pool_rwm_t setReadWriteMode): - readWriteMode(setReadWriteMode) { - if(poolId == PoolVariableIF::NO_PARAMETER) { - sif::warning << "LocalPoolVector: 0 passed as pool ID, which is the " - "NO_PARAMETER value!" << std::endl; - } - HasLocalDataPoolIF* hkOwner = - objectManager->get(poolOwner); - if(hkOwner == nullptr) { - sif::error << "LocalPoolVariable: The supplied pool owner did not implement" - "the correct interface HasHkPoolParametersIF!" << std::endl; - return; + DataSetIF *dataSet, pool_rwm_t setReadWriteMode): + localPoolId(poolId), readWriteMode(setReadWriteMode) { + if(poolId == PoolVariableIF::NO_PARAMETER) { + sif::warning << "LocalPoolVar::LocalPoolVar: 0 passed as pool ID, " + << "which is the NO_PARAMETER value!" << std::endl; + } + HasLocalDataPoolIF* hkOwner = + objectManager->get(poolOwner); + if(hkOwner == nullptr) { + sif::error << "LocalPoolVariable: The supplied pool owner did not " + << "implement the correct interface " + << "HasLocalDataPoolIF!" << std::endl; + return; } hkManager = hkOwner->getHkManagerHandle(); if(dataSet != nullptr) { diff --git a/housekeeping/HousekeepingSetPacket.h b/housekeeping/HousekeepingSetPacket.h index 051e4c61..f94720d4 100644 --- a/housekeeping/HousekeepingSetPacket.h +++ b/housekeeping/HousekeepingSetPacket.h @@ -28,7 +28,7 @@ public: size_t getSerializedSize() const override { size_t linkedSize = SerialLinkedListAdapter::getSerializedSize(); - linkedSize += dataSet->getFillCount() * sizeof(lp_id_t); + linkedSize += dataSet->getLocalPoolIdsSerializedSize(); return linkedSize; } From ad2ca814b2e100c7da2b3371244f28c70baa1e32 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 28 Sep 2020 21:28:03 +0200 Subject: [PATCH 122/192] improved doc --- datapoollocal/LocalPoolDataSetBase.h | 24 +++++++++++++++++++----- datapoollocal/LocalPoolVariable.h | 13 ++++++------- datapoollocal/LocalPoolVariable.tpp | 6 +++--- datapoollocal/StaticLocalDataSet.h | 13 ++++++++----- 4 files changed, 36 insertions(+), 20 deletions(-) diff --git a/datapoollocal/LocalPoolDataSetBase.h b/datapoollocal/LocalPoolDataSetBase.h index 4f277123..d00af992 100644 --- a/datapoollocal/LocalPoolDataSetBase.h +++ b/datapoollocal/LocalPoolDataSetBase.h @@ -1,7 +1,6 @@ #ifndef FSFW_DATAPOOLLOCAL_LOCALPOOLDATASETBASE_H_ #define FSFW_DATAPOOLLOCAL_LOCALPOOLDATASETBASE_H_ - #include "HasLocalDataPoolIF.h" #include "../datapool/DataSetIF.h" #include "../datapool/PoolDataSetBase.h" @@ -16,15 +15,22 @@ class PeriodicHousekeepingHelper; * @brief The LocalDataSet class manages a set of locally checked out * variables for local data pools * @details + * Extends the PoolDataSetBase class for local data pools by introducing + * a validity state, a flag to mark the set as changed, and various other + * functions to make it usable by the LocalDataPoolManager class. + * * This class manages a list, where a set of local variables (or pool variables) * are registered. They are checked-out (i.e. their values are looked * up and copied) with the read call. After the user finishes working with the * pool variables, he can write back all variable values to the pool with - * the commit call. The data set manages locking and freeing the local data pools, - * to ensure thread-safety. + * the commit call. The data set manages locking and freeing the local data + * pools, to ensure thread-safety. + * + * Pool variables can be added to the dataset by using the constructor + * argument of the pool variable or using the #registerVariable member function. * * An internal state manages usage of this class. Variables may only be - * registered before the read call is made, and the commit call only + * registered before any read call is made, and the commit call can only happen * after the read call. * * If pool variables are writable and not committed until destruction @@ -72,6 +78,7 @@ public: sid_t getSid() const; + /** SerializeIF overrides */ ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, SerializeIF::Endianness streamEndianness) const override; ReturnValue_t deSerialize(const uint8_t** buffer, size_t *size, @@ -82,7 +89,7 @@ public: * Special version of the serilization function which appends a * validity buffer at the end. Each bit of this validity buffer * denotes whether the container data set entries are valid from left - * to right, MSB first. + * to right, MSB first. (length = ceil(N/8), N = number of pool variables) * @param buffer * @param size * @param maxSize @@ -142,6 +149,13 @@ protected: */ bool changed = false; + /** + * Specify whether the validity buffer is serialized too when serializing + * or deserializing the packet. Each bit of the validity buffer will + * contain the validity state of the pool variables from left to right. + * The size of validity buffer thus will be ceil(N / 8) with N = number of + * pool variables. + */ bool withValidityBuffer = true; /** diff --git a/datapoollocal/LocalPoolVariable.h b/datapoollocal/LocalPoolVariable.h index 6047342e..ec5c8cd1 100644 --- a/datapoollocal/LocalPoolVariable.h +++ b/datapoollocal/LocalPoolVariable.h @@ -1,12 +1,12 @@ -#ifndef FRAMEWORK_DATAPOOLLOCAL_LOCALPOOLVARIABLE_H_ -#define FRAMEWORK_DATAPOOLLOCAL_LOCALPOOLVARIABLE_H_ +#ifndef FSFW_DATAPOOLLOCAL_LOCALPOOLVARIABLE_H_ +#define FSFW_DATAPOOLLOCAL_LOCALPOOLVARIABLE_H_ + +#include "HasLocalDataPoolIF.h" +#include "LocalDataPoolManager.h" #include "../datapool/PoolVariableIF.h" #include "../datapool/DataSetIF.h" -#include "../datapoollocal/HasLocalDataPoolIF.h" -#include "../datapoollocal/LocalDataPoolManager.h" #include "../objectmanager/ObjectManagerIF.h" - #include "../serialize/SerializeAdapter.h" /** @@ -41,7 +41,6 @@ public: * @param dataSet The data set in which the variable shall register itself. * If nullptr, the variable is not registered. * @param setReadWriteMode Specify the read-write mode of the pool variable. - */ LocalPoolVar(lp_id_t poolId, HasLocalDataPoolIF* hkOwner, DataSetIF* dataSet = nullptr, @@ -175,4 +174,4 @@ using lp_float_t = LocalPoolVar; using lp_double_t = LocalPoolVar; -#endif +#endif /* FSFW_DATAPOOLLOCAL_LOCALPOOLVARIABLE_H_ */ diff --git a/datapoollocal/LocalPoolVariable.tpp b/datapoollocal/LocalPoolVariable.tpp index b47e602c..b0bdd7b9 100644 --- a/datapoollocal/LocalPoolVariable.tpp +++ b/datapoollocal/LocalPoolVariable.tpp @@ -1,7 +1,7 @@ -#ifndef FRAMEWORK_DATAPOOLLOCAL_LOCALPOOLVARIABLE_TPP_ -#define FRAMEWORK_DATAPOOLLOCAL_LOCALPOOLVARIABLE_TPP_ +#ifndef FSFW_DATAPOOLLOCAL_LOCALPOOLVARIABLE_TPP_ +#define FSFW_DATAPOOLLOCAL_LOCALPOOLVARIABLE_TPP_ -#ifndef FRAMEWORK_DATAPOOLLOCAL_LOCALPOOLVARIABLE_H_ +#ifndef FSFW_DATAPOOLLOCAL_LOCALPOOLVARIABLE_H_ #error Include LocalPoolVariable.h before LocalPoolVariable.tpp! #endif diff --git a/datapoollocal/StaticLocalDataSet.h b/datapoollocal/StaticLocalDataSet.h index 2f306898..a637e360 100644 --- a/datapoollocal/StaticLocalDataSet.h +++ b/datapoollocal/StaticLocalDataSet.h @@ -8,11 +8,14 @@ /** * @brief This local dataset type is created on the stack. * @details - * Size of data set specified as a constructor argument. It is recommended - * to use the default LocalDataSet of the dataset is constructed on the heap - * and the SharedLocalDataSet if it created on the heap and used by multiple - * other software objects. - * @tparam capacity + * This will is the primary data structure to organize pool variables into + * sets which can be accessed via the housekeeping service interface or + * which can be sent to other software objects. + * + * It is recommended to read the documentation of the LocalPoolDataSetBase + * class for more information on how this class works and how to use it. + * @tparam capacity Capacity of the static dataset, which is usually known + * beforehand. */ template class StaticLocalDataSet: public LocalPoolDataSetBase { From 786dcdf88d915c701a0266768b06e6158cdd59e9 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 28 Sep 2020 22:13:17 +0200 Subject: [PATCH 123/192] removed clock include --- datapoollocal/HasLocalDataPoolIF.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/datapoollocal/HasLocalDataPoolIF.h b/datapoollocal/HasLocalDataPoolIF.h index e078f01e..f8f4ef4c 100644 --- a/datapoollocal/HasLocalDataPoolIF.h +++ b/datapoollocal/HasLocalDataPoolIF.h @@ -4,7 +4,6 @@ #include "../datapool/PoolEntryIF.h" #include "../ipc/MessageQueueSenderIF.h" #include "../housekeeping/HousekeepingMessage.h" -#include "../timemanager/Clock.h" #include @@ -65,11 +64,11 @@ public: virtual LocalDataPoolManager* getHkManagerHandle() = 0; /** - * Returns the minimum sampling frequency, which will usually be the - * period the pool owner performs its periodic operation- + * Returns the minimum sampling frequency in milliseconds, which will + * usually be the period the pool owner performs its periodic operation. * @return */ - virtual dur_millis_t getPeriodicOperationFrequency() const = 0; + virtual uint32_t getPeriodicOperationFrequency() const = 0; /** * This function is used by the pool manager to get a valid dataset From e48dbb87973ccbce0fb5679b7bd0ad726c34161b Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 28 Sep 2020 22:17:18 +0200 Subject: [PATCH 124/192] small improvements --- datapoollocal/LocalDataPoolManager.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/datapoollocal/LocalDataPoolManager.cpp b/datapoollocal/LocalDataPoolManager.cpp index 1a8239ae..d8b57377 100644 --- a/datapoollocal/LocalDataPoolManager.cpp +++ b/datapoollocal/LocalDataPoolManager.cpp @@ -81,7 +81,7 @@ ReturnValue_t LocalDataPoolManager::initializeHousekeepingPoolEntriesOnce() { return result; } sif::warning << "HousekeepingManager: The map should only be initialized " - "once!" << std::endl; + << "once!" << std::endl; return HasReturnvaluesIF::RETURN_OK; } @@ -117,7 +117,7 @@ ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(sid_t sid, objectManager->get(packetDestination); if(hkReceiverObject == nullptr) { sif::error << "LocalDataPoolManager::subscribeForPeriodicPacket:" - " Invalid receiver!"<< std::endl; + << " Invalid receiver!"<< std::endl; return HasReturnvaluesIF::RETURN_OK; } @@ -218,7 +218,7 @@ ReturnValue_t LocalDataPoolManager::printPoolEntry( auto poolIter = localPoolMap.find(localPoolId); if (poolIter == localPoolMap.end()) { sif::debug << "HousekeepingManager::fechPoolEntry:" - " Pool entry not found." << std::endl; + << " Pool entry not found." << std::endl; return POOL_ENTRY_NOT_FOUND; } poolIter->second->print(); @@ -239,7 +239,7 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid, if(dataSet == nullptr) { // Configuration error. sif::warning << "HousekeepingManager::generateHousekeepingPacket:" - " Set ID not found or dataset not assigned!" << std::endl; + << " Set ID not found or dataset not assigned!" << std::endl; return HasReturnvaluesIF::RETURN_FAILED; } @@ -321,9 +321,9 @@ void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver& receiver) { if(result != HasReturnvaluesIF::RETURN_OK) { // configuration error sif::debug << "LocalDataPoolManager::performHkOperation:" - << "0x" << std::setfill('0') << std::setw(8) - << owner->getObjectId() << " Error generating " - << "HK packet" << std::setfill(' ') << std::endl; + << "0x" << std::hex << std::setfill('0') << std::setw(8) + << owner->getObjectId() << " Error generating " + << "HK packet" << std::setfill(' ') << std::dec << std::endl; } } @@ -370,7 +370,7 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid, owner->getDataSetHandle(sid)); if(dataSet == nullptr) { sif::warning << "HousekeepingManager::generateHousekeepingPacket:" - " Set ID not found" << std::endl; + << " Set ID not found" << std::endl; return HasReturnvaluesIF::RETURN_FAILED; } @@ -396,7 +396,7 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid, expectedSize,&storePtr); if(result != HasReturnvaluesIF::RETURN_OK) { sif::error << "HousekeepingManager::generateHousekeepingPacket: " - "Could not get free element from IPC store." << std::endl; + << "Could not get free element from IPC store." << std::endl; return result; } @@ -406,7 +406,7 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid, SerializeIF::Endianness::BIG); if(expectedSize != size) { sif::error << "HousekeepingManager::generateSetStructurePacket: " - "Expected size is not equal to serialized size" << std::endl; + << "Expected size is not equal to serialized size" << std::endl; } // Send structure reporting reply. From 7e9d095ed16264786480e648465efa7d44abe8d8 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 28 Sep 2020 22:38:36 +0200 Subject: [PATCH 125/192] important bugfixes --- datapool/PoolDataSetBase.cpp | 5 +++++ datapoollocal/LocalDataPoolManager.h | 11 +++++++++-- internalError/InternalErrorReporter.cpp | 7 ++++++- internalError/InternalErrorReporter.h | 1 + 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/datapool/PoolDataSetBase.cpp b/datapool/PoolDataSetBase.cpp index 1acd3fd3..cb2348f7 100644 --- a/datapool/PoolDataSetBase.cpp +++ b/datapool/PoolDataSetBase.cpp @@ -59,6 +59,11 @@ uint16_t PoolDataSetBase::getFillCount() const { ReturnValue_t PoolDataSetBase::readVariable(uint16_t count) { ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + if(registeredVariables[count] == nullptr) { + // configuration error. + return HasReturnvaluesIF::RETURN_FAILED; + } + // These checks are often performed by the respective // variable implementation too, but I guess a double check does not hurt. if (registeredVariables[count]->getReadWriteMode() != diff --git a/datapoollocal/LocalDataPoolManager.h b/datapoollocal/LocalDataPoolManager.h index e55efa9c..c3b385e8 100644 --- a/datapoollocal/LocalDataPoolManager.h +++ b/datapoollocal/LocalDataPoolManager.h @@ -58,6 +58,7 @@ public: static constexpr ReturnValue_t WRONG_HK_PACKET_TYPE = MAKE_RETURN_CODE(0x03); static constexpr ReturnValue_t REPORTING_STATUS_UNCHANGED = MAKE_RETURN_CODE(0x04); static constexpr ReturnValue_t PERIODIC_HELPER_INVALID = MAKE_RETURN_CODE(0x05); + /** * This constructor is used by a class which wants to implement * a personal local data pool. The queueToUse can be supplied if it @@ -73,14 +74,20 @@ public: virtual~ LocalDataPoolManager(); /** - * Initializes the map by calling the map initialization function of the - * owner and assigns the queue to use. + * Assigns the queue to use. * @param queueToUse * @param nonDiagInvlFactor See #setNonDiagnosticIntervalFactor doc * @return */ ReturnValue_t initialize(MessageQueueIF* queueToUse); + /** + * Initializes the map by calling the map initialization function and + * setting the periodic factor for non-diagnostic packets. + * Don't forget to call this, otherwise the map will be invalid! + * @param nonDiagInvlFactor + * @return + */ ReturnValue_t initializeAfterTaskCreation(uint8_t nonDiagInvlFactor = 5); /** diff --git a/internalError/InternalErrorReporter.cpp b/internalError/InternalErrorReporter.cpp index 4cdab9e7..943ae8b3 100644 --- a/internalError/InternalErrorReporter.cpp +++ b/internalError/InternalErrorReporter.cpp @@ -158,7 +158,7 @@ ReturnValue_t InternalErrorReporter::initializeLocalDataPool( // todo: Only send HK if values have changed, will be supported by // pool manager soon. poolManager.subscribeForPeriodicPacket(internalErrorSid, false, - getPeriodicOperationFrequency(), false); + getPeriodicOperationFrequency(), true); return HasReturnvaluesIF::RETURN_OK; } @@ -185,3 +185,8 @@ ReturnValue_t InternalErrorReporter::initialize() { } return SystemObject::initialize(); } + +ReturnValue_t InternalErrorReporter::initializeAfterTaskCreation() { + return poolManager.initializeAfterTaskCreation(); +} + diff --git a/internalError/InternalErrorReporter.h b/internalError/InternalErrorReporter.h index c715f7a0..8d33c06e 100644 --- a/internalError/InternalErrorReporter.h +++ b/internalError/InternalErrorReporter.h @@ -46,6 +46,7 @@ public: virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; virtual ReturnValue_t initialize() override; + virtual ReturnValue_t initializeAfterTaskCreation() override; virtual ReturnValue_t performOperation(uint8_t opCode) override; virtual void queueMessageNotSent(); From 1d972fcbef9e935121ad5a168ec1f5f6f2c8619d Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 28 Sep 2020 22:46:18 +0200 Subject: [PATCH 126/192] hk messages are cleared properly now --- housekeeping/HousekeepingMessage.cpp | 19 +++++++++++++++++++ housekeeping/HousekeepingMessage.h | 1 + ipc/CommandMessageCleaner.cpp | 6 +++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/housekeeping/HousekeepingMessage.cpp b/housekeeping/HousekeepingMessage.cpp index 706bd273..7c3e04f7 100644 --- a/housekeeping/HousekeepingMessage.cpp +++ b/housekeeping/HousekeepingMessage.cpp @@ -1,3 +1,4 @@ +#include #include "HousekeepingMessage.h" #include @@ -140,3 +141,21 @@ void HousekeepingMessage::setDiagnosticsStuctureReportReply( setSid(reply, sid); reply->setParameter3(storeId.raw); } + +void HousekeepingMessage::clear(CommandMessage* message) { + switch(message->getCommand()) { + case(HK_REPORT): + case(DIAGNOSTICS_REPORT): + case(HK_DEFINITIONS_REPORT): + case(DIAGNOSTICS_DEFINITION_REPORT): { + store_address_t storeId; + getHkDataReply(message, &storeId); + StorageManagerIF *ipcStore = objectManager->get( + objects::IPC_STORE); + if (ipcStore != nullptr) { + ipcStore->deleteData(storeId); + } + } + } + message->setCommand(CommandMessage::CMD_NONE); +} diff --git a/housekeeping/HousekeepingMessage.h b/housekeeping/HousekeepingMessage.h index af89dade..f276e263 100644 --- a/housekeeping/HousekeepingMessage.h +++ b/housekeeping/HousekeepingMessage.h @@ -142,6 +142,7 @@ public: static sid_t getCollectionIntervalModificationCommand( const CommandMessage* command, float* newCollectionInterval); + static void clear(CommandMessage* message); private: static void setSid(CommandMessage* message, sid_t sid); }; diff --git a/ipc/CommandMessageCleaner.cpp b/ipc/CommandMessageCleaner.cpp index 6a99b4d2..fa03a9a3 100644 --- a/ipc/CommandMessageCleaner.cpp +++ b/ipc/CommandMessageCleaner.cpp @@ -1,4 +1,4 @@ -#include "../ipc/CommandMessageCleaner.h" +#include "CommandMessageCleaner.h" #include "../devicehandlers/DeviceHandlerMessage.h" #include "../health/HealthMessage.h" @@ -7,6 +7,7 @@ #include "../monitoring/MonitoringMessage.h" #include "../subsystem/modes/ModeSequenceMessage.h" #include "../tmstorage/TmStoreMessage.h" +#include "../housekeeping/HousekeepingMessage.h" #include "../parameters/ParameterMessage.h" void CommandMessageCleaner::clearCommandMessage(CommandMessage* message) { @@ -38,6 +39,9 @@ void CommandMessageCleaner::clearCommandMessage(CommandMessage* message) { case messagetypes::PARAMETER: ParameterMessage::clear(message); break; + case messagetypes::HOUSEKEEPING: + HousekeepingMessage::clear(message); + break; default: messagetypes::clearMissionMessage(message); break; From 62ee1391bf195337af99bddb151cd65fcc95504e Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 28 Sep 2020 22:48:10 +0200 Subject: [PATCH 127/192] added two new commands --- housekeeping/HousekeepingMessage.cpp | 3 ++- housekeeping/HousekeepingMessage.h | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/housekeeping/HousekeepingMessage.cpp b/housekeeping/HousekeepingMessage.cpp index 7c3e04f7..b07368e6 100644 --- a/housekeeping/HousekeepingMessage.cpp +++ b/housekeeping/HousekeepingMessage.cpp @@ -147,7 +147,8 @@ void HousekeepingMessage::clear(CommandMessage* message) { case(HK_REPORT): case(DIAGNOSTICS_REPORT): case(HK_DEFINITIONS_REPORT): - case(DIAGNOSTICS_DEFINITION_REPORT): { + case(DIAGNOSTICS_DEFINITION_REPORT): + case(UPDATE_SNAPSHOT):{ store_address_t storeId; getHkDataReply(message, &storeId); StorageManagerIF *ipcStore = objectManager->get( diff --git a/housekeeping/HousekeepingMessage.h b/housekeeping/HousekeepingMessage.h index f276e263..041a5eaa 100644 --- a/housekeeping/HousekeepingMessage.h +++ b/housekeeping/HousekeepingMessage.h @@ -101,6 +101,9 @@ public: static constexpr Command_t HK_REQUEST_FAILURE = MAKE_COMMAND_ID(129); + static constexpr Command_t UPDATE_NOTIFICATION = MAKE_COMMAND_ID(130); + static constexpr Command_t UPDATE_SNAPSHOT = MAKE_COMMAND_ID(131); + static sid_t getSid(const CommandMessage* message); static void setToggleReportingCommand(CommandMessage* command, sid_t sid, From 7ff9c29b62cbd3738377bcb6883ac42362db4731 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 28 Sep 2020 22:51:02 +0200 Subject: [PATCH 128/192] added another command --- housekeeping/HousekeepingMessage.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/housekeeping/HousekeepingMessage.h b/housekeeping/HousekeepingMessage.h index 041a5eaa..6dc95f54 100644 --- a/housekeeping/HousekeepingMessage.h +++ b/housekeeping/HousekeepingMessage.h @@ -104,8 +104,11 @@ public: static constexpr Command_t UPDATE_NOTIFICATION = MAKE_COMMAND_ID(130); static constexpr Command_t UPDATE_SNAPSHOT = MAKE_COMMAND_ID(131); + static constexpr Command_t UPDATE_HK_REPORT = MAKE_COMMAND_ID(132); + static sid_t getSid(const CommandMessage* message); + /** Setter functions */ static void setToggleReportingCommand(CommandMessage* command, sid_t sid, bool enableReporting, bool isDiagnostics); static void setStructureReportingCommand(CommandMessage* command, sid_t sid, From 1f70b1159d39527d58cbcd2a0e85ca46c2d66695 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 28 Sep 2020 23:21:21 +0200 Subject: [PATCH 129/192] another small bugfix --- datapoollocal/LocalDataPoolManager.h | 14 ++++++++------ housekeeping/HousekeepingMessage.cpp | 2 +- housekeeping/PeriodicHousekeepingHelper.cpp | 2 +- internalError/InternalErrorDataset.h | 9 ++++++--- internalError/InternalErrorReporter.cpp | 4 ++-- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/datapoollocal/LocalDataPoolManager.h b/datapoollocal/LocalDataPoolManager.h index c3b385e8..779e3050 100644 --- a/datapoollocal/LocalDataPoolManager.h +++ b/datapoollocal/LocalDataPoolManager.h @@ -90,6 +90,14 @@ public: */ ReturnValue_t initializeAfterTaskCreation(uint8_t nonDiagInvlFactor = 5); + /** + * This should be called in the periodic handler of the owner. + * It performs all the periodic functionalities of the data pool manager, + * for example generating periodic HK packets. + * @return + */ + ReturnValue_t performHkOperation(); + /** * @return */ @@ -108,12 +116,6 @@ public: */ void setNonDiagnosticIntervalFactor(uint8_t nonDiagInvlFactor); - /** - * This should be called in the periodic handler of the owner. - * It performs all the periodic functionalities of the data pool manager. - * @return - */ - ReturnValue_t performHkOperation(); /** * Generate a housekeeping packet with a given SID. diff --git a/housekeeping/HousekeepingMessage.cpp b/housekeeping/HousekeepingMessage.cpp index b07368e6..d2ab546b 100644 --- a/housekeeping/HousekeepingMessage.cpp +++ b/housekeeping/HousekeepingMessage.cpp @@ -148,7 +148,7 @@ void HousekeepingMessage::clear(CommandMessage* message) { case(DIAGNOSTICS_REPORT): case(HK_DEFINITIONS_REPORT): case(DIAGNOSTICS_DEFINITION_REPORT): - case(UPDATE_SNAPSHOT):{ + case(UPDATE_SNAPSHOT): { store_address_t storeId; getHkDataReply(message, &storeId); StorageManagerIF *ipcStore = objectManager->get( diff --git a/housekeeping/PeriodicHousekeepingHelper.cpp b/housekeeping/PeriodicHousekeepingHelper.cpp index d184489b..37349f81 100644 --- a/housekeeping/PeriodicHousekeepingHelper.cpp +++ b/housekeeping/PeriodicHousekeepingHelper.cpp @@ -10,7 +10,7 @@ void PeriodicHousekeepingHelper::initialize(float collectionInterval, dur_millis_t minimumPeriodicInterval, bool isDiagnostics, uint8_t nonDiagIntervalFactor) { this->minimumPeriodicInterval = minimumPeriodicInterval; - if(isDiagnostics) { + if(not isDiagnostics) { this->minimumPeriodicInterval = this->minimumPeriodicInterval * nonDiagIntervalFactor; } diff --git a/internalError/InternalErrorDataset.h b/internalError/InternalErrorDataset.h index c5dc3d73..6bba1171 100644 --- a/internalError/InternalErrorDataset.h +++ b/internalError/InternalErrorDataset.h @@ -21,9 +21,12 @@ public: InternalErrorDataset(sid_t sid): StaticLocalDataSet(sid) {} - lp_var_t tmHits = lp_var_t(TM_HITS, sid.objectId, this); - lp_var_t queueHits = lp_var_t(QUEUE_HITS, sid.objectId, this); - lp_var_t storeHits = lp_var_t(STORE_HITS, sid.objectId, this); + lp_var_t tmHits = lp_var_t(TM_HITS, + hkManager->getOwner(), this); + lp_var_t queueHits = lp_var_t(QUEUE_HITS, + hkManager->getOwner(), this); + lp_var_t storeHits = lp_var_t(STORE_HITS, + hkManager->getOwner(), this); }; diff --git a/internalError/InternalErrorReporter.cpp b/internalError/InternalErrorReporter.cpp index 943ae8b3..a41d4568 100644 --- a/internalError/InternalErrorReporter.cpp +++ b/internalError/InternalErrorReporter.cpp @@ -50,6 +50,8 @@ ReturnValue_t InternalErrorReporter::performOperation(uint8_t opCode) { internalErrorDataset.commit(INTERNAL_ERROR_MUTEX_TIMEOUT); + poolManager.performHkOperation(); + CommandMessage message; ReturnValue_t result = commandQueue->receiveMessage(&message); if(result != MessageQueueIF::EMPTY) { @@ -155,8 +157,6 @@ ReturnValue_t InternalErrorReporter::initializeLocalDataPool( new PoolEntry()); localDataPoolMap.emplace(errorPoolIds::STORE_HITS, new PoolEntry()); - // todo: Only send HK if values have changed, will be supported by - // pool manager soon. poolManager.subscribeForPeriodicPacket(internalErrorSid, false, getPeriodicOperationFrequency(), true); return HasReturnvaluesIF::RETURN_OK; From 260fac43f73d638823c4dd1d887e2e8409c9a480 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 28 Sep 2020 23:38:37 +0200 Subject: [PATCH 130/192] bugfix --- internalError/InternalErrorReporter.cpp | 1 + pus/Service3Housekeeping.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/internalError/InternalErrorReporter.cpp b/internalError/InternalErrorReporter.cpp index a41d4568..22e2c38c 100644 --- a/internalError/InternalErrorReporter.cpp +++ b/internalError/InternalErrorReporter.cpp @@ -159,6 +159,7 @@ ReturnValue_t InternalErrorReporter::initializeLocalDataPool( new PoolEntry()); poolManager.subscribeForPeriodicPacket(internalErrorSid, false, getPeriodicOperationFrequency(), true); + internalErrorDataset.setValidity(true, true); return HasReturnvaluesIF::RETURN_OK; } diff --git a/pus/Service3Housekeeping.cpp b/pus/Service3Housekeeping.cpp index c668ec8e..3f41f541 100644 --- a/pus/Service3Housekeeping.cpp +++ b/pus/Service3Housekeeping.cpp @@ -205,7 +205,7 @@ ReturnValue_t Service3Housekeeping::handleReply(const CommandMessage* reply, } case(HousekeepingMessage::DIAGNOSTICS_DEFINITION_REPORT): { return generateHkReply(reply, static_cast( - Subservice::DIAGNOSTICS_REPORT)); + Subservice::DIAGNOSTICS_DEFINITION_REPORT)); break; } From 53a62257906df8ca44d3a447dd4434e3d7b889ea Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 29 Sep 2020 12:50:36 +0200 Subject: [PATCH 131/192] doc & tweaks --- devicehandlers/DeviceHandlerBase.h | 6 ++++-- internalError/InternalErrorDataset.h | 4 ++-- osal/FreeRTOS/PeriodicTask.cpp | 8 ++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/devicehandlers/DeviceHandlerBase.h b/devicehandlers/DeviceHandlerBase.h index 8f1b135b..eda318cb 100644 --- a/devicehandlers/DeviceHandlerBase.h +++ b/devicehandlers/DeviceHandlerBase.h @@ -106,13 +106,15 @@ public: void setThermalStateRequestPoolIds(uint32_t thermalStatePoolId, uint32_t thermalRequestPoolId); /** - * @brief Helper function to easy device handler development. + * @brief Helper function to ease device handler development. * This will instruct the transition to MODE_ON immediately * (leading to doStartUp() being called for the transition to the ON mode), * so external mode commanding is not necessary anymore. * * This has to be called before the task is started! - * (e.g. in the task factory) + * (e.g. in the task factory). This is only a helper function for + * development. Regular mode commanding should be performed by commanding + * the AssemblyBase or Subsystem objects resposible for the device handler. */ void setStartUpImmediately(); diff --git a/internalError/InternalErrorDataset.h b/internalError/InternalErrorDataset.h index 6bba1171..52a4b632 100644 --- a/internalError/InternalErrorDataset.h +++ b/internalError/InternalErrorDataset.h @@ -18,8 +18,8 @@ public: InternalErrorDataset(HasLocalDataPoolIF* owner): StaticLocalDataSet(owner, ERROR_SET_ID) {} - InternalErrorDataset(sid_t sid): - StaticLocalDataSet(sid) {} + InternalErrorDataset(object_id_t objectId): + StaticLocalDataSet(sid_t(objectId , ERROR_SET_ID)) {} lp_var_t tmHits = lp_var_t(TM_HITS, hkManager->getOwner(), this); diff --git a/osal/FreeRTOS/PeriodicTask.cpp b/osal/FreeRTOS/PeriodicTask.cpp index 990d38d6..c90587bd 100644 --- a/osal/FreeRTOS/PeriodicTask.cpp +++ b/osal/FreeRTOS/PeriodicTask.cpp @@ -133,11 +133,11 @@ TaskHandle_t PeriodicTask::getTaskHandle() { } void PeriodicTask::handleMissedDeadline() { -#ifdef DEBUG - sif::warning << "PeriodicTask: " << pcTaskGetName(NULL) << - " missed deadline!\n" << std::flush; -#endif if(deadlineMissedFunc != nullptr) { this->deadlineMissedFunc(); } +#ifdef DEBUG + sif::warning << "PeriodicTask::handleMissedDeadline " << pcTaskGetName(NULL) + << " missed deadline!\n" << std::flush; +#endif } From 7b1f72254f866666d251f097b6587fc1c92f67e2 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 29 Sep 2020 13:30:30 +0200 Subject: [PATCH 132/192] object id names improved --- objectmanager/frameworkObjects.h | 14 +++++++------- tmtcservices/VerificationReporter.cpp | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/objectmanager/frameworkObjects.h b/objectmanager/frameworkObjects.h index 87439c88..4d08f084 100644 --- a/objectmanager/frameworkObjects.h +++ b/objectmanager/frameworkObjects.h @@ -4,13 +4,13 @@ namespace objects { enum framework_objects { // Default verification reporter. - PUS_SERVICE_1 = 0x53000001, - PUS_SERVICE_2 = 0x53000002, - PUS_SERVICE_5 = 0x53000005, - PUS_SERVICE_8 = 0x53000008, - PUS_SERVICE_9 = 0x53000009, - PUS_SERVICE_17 = 0x53000017, - PUS_SERVICE_200 = 0x53000200, + PUS_SERVICE_1_VERIFICATION = 0x53000001, + PUS_SERVICE_2_DEVICE_ACCESS = 0x53000002, + PUS_SERVICE_5_EVENT_REPORTING = 0x53000005, + PUS_SERVICE_8_FUNCTION_MGMT = 0x53000008, + PUS_SERVICE_9_TIME_MGMT = 0x53000009, + PUS_SERVICE_17_TEST = 0x53000017, + PUS_SERVICE_200_MODE_MGMT = 0x53000200, //Generic IDs for IPC, modes, health, events HEALTH_TABLE = 0x53010000, diff --git a/tmtcservices/VerificationReporter.cpp b/tmtcservices/VerificationReporter.cpp index 0c53e1a4..4255c5ae 100644 --- a/tmtcservices/VerificationReporter.cpp +++ b/tmtcservices/VerificationReporter.cpp @@ -6,7 +6,7 @@ #include "../serviceinterface/ServiceInterfaceStream.h" #include "../objectmanager/frameworkObjects.h" -object_id_t VerificationReporter::messageReceiver = objects::PUS_SERVICE_1; +object_id_t VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; VerificationReporter::VerificationReporter() : acknowledgeQueue(MessageQueueIF::NO_QUEUE) { From 3663d7269ca37b8ac2a5af62e1f86557d9766462 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 29 Sep 2020 13:37:21 +0200 Subject: [PATCH 133/192] changes taken over --- tmtcservices/VerificationReporter.cpp | 13 +++++++------ tmtcservices/VerificationReporter.h | 8 ++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/tmtcservices/VerificationReporter.cpp b/tmtcservices/VerificationReporter.cpp index 4255c5ae..7e40bd27 100644 --- a/tmtcservices/VerificationReporter.cpp +++ b/tmtcservices/VerificationReporter.cpp @@ -1,12 +1,13 @@ -#include "../tmtcservices/VerificationReporter.h" +#include "VerificationReporter.h" +#include "AcceptsVerifyMessageIF.h" +#include "PusVerificationReport.h" #include "../ipc/MessageQueueIF.h" -#include "../tmtcservices/AcceptsVerifyMessageIF.h" -#include "../tmtcservices/PusVerificationReport.h" #include "../serviceinterface/ServiceInterfaceStream.h" #include "../objectmanager/frameworkObjects.h" -object_id_t VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; +object_id_t VerificationReporter::messageReceiver = + objects::PUS_SERVICE_1_VERIFICATION; VerificationReporter::VerificationReporter() : acknowledgeQueue(MessageQueueIF::NO_QUEUE) { @@ -98,8 +99,8 @@ void VerificationReporter::initialize() { if (temp == nullptr) { sif::error << "VerificationReporter::initialize: Message " << "receiver invalid. Make sure it is set up properly and " - <<"implementsAcceptsVerifyMessageIF" << std::endl; - + << "implementsAcceptsVerifyMessageIF" << std::endl; + return; } this->acknowledgeQueue = temp->getVerificationQueue(); } diff --git a/tmtcservices/VerificationReporter.h b/tmtcservices/VerificationReporter.h index 4d92f6b3..f26fa54f 100644 --- a/tmtcservices/VerificationReporter.h +++ b/tmtcservices/VerificationReporter.h @@ -1,8 +1,8 @@ -#ifndef FRAMEWORK_TMTCSERVICES_VERIFICATIONREPORTER_H_ -#define FRAMEWORK_TMTCSERVICES_VERIFICATIONREPORTER_H_ +#ifndef FSFW_TMTCSERVICES_VERIFICATIONREPORTER_H_ +#define FSFW_TMTCSERVICES_VERIFICATIONREPORTER_H_ +#include "PusVerificationReport.h" #include "../objectmanager/ObjectManagerIF.h" -#include "../tmtcservices/PusVerificationReport.h" namespace Factory{ void setStaticFrameworkObjectIds(); @@ -47,4 +47,4 @@ private: MessageQueueId_t acknowledgeQueue; }; -#endif /* FRAMEWORK_TMTCSERVICES_VERIFICATIONREPORTER_H_ */ +#endif /* FSFW_TMTCSERVICES_VERIFICATIONREPORTER_H_ */ From 1691d63169c7bec77954873c476f1fa530f981ec Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 29 Sep 2020 13:54:08 +0200 Subject: [PATCH 134/192] include fix --- datapoollocal/LocalDataPoolManager.cpp | 4 +++- objectmanager/frameworkObjects.h | 1 + tmtcservices/PusVerificationReport.h | 12 +++++++----- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/datapoollocal/LocalDataPoolManager.cpp b/datapoollocal/LocalDataPoolManager.cpp index d8b57377..c23f183b 100644 --- a/datapoollocal/LocalDataPoolManager.cpp +++ b/datapoollocal/LocalDataPoolManager.cpp @@ -6,11 +6,13 @@ #include "../ipc/MutexFactory.h" #include "../ipc/MutexHelper.h" #include "../ipc/QueueFactory.h" +#include "../objectmanager/frameworkObjects.h" #include #include -object_id_t LocalDataPoolManager::defaultHkDestination = objects::NO_OBJECT; +object_id_t LocalDataPoolManager::defaultHkDestination = + objects::PUS_SERVICE_3_HOUSEKEEPING; LocalDataPoolManager::LocalDataPoolManager(HasLocalDataPoolIF* owner, MessageQueueIF* queueToUse, bool appendValidityBuffer): diff --git a/objectmanager/frameworkObjects.h b/objectmanager/frameworkObjects.h index 4d08f084..57783286 100644 --- a/objectmanager/frameworkObjects.h +++ b/objectmanager/frameworkObjects.h @@ -6,6 +6,7 @@ enum framework_objects { // Default verification reporter. PUS_SERVICE_1_VERIFICATION = 0x53000001, PUS_SERVICE_2_DEVICE_ACCESS = 0x53000002, + PUS_SERVICE_3_HOUSEKEEPING = 0x53000003, PUS_SERVICE_5_EVENT_REPORTING = 0x53000005, PUS_SERVICE_8_FUNCTION_MGMT = 0x53000008, PUS_SERVICE_9_TIME_MGMT = 0x53000009, diff --git a/tmtcservices/PusVerificationReport.h b/tmtcservices/PusVerificationReport.h index c0a46758..9dce95ac 100644 --- a/tmtcservices/PusVerificationReport.h +++ b/tmtcservices/PusVerificationReport.h @@ -1,9 +1,11 @@ -#ifndef PUSVERIFICATIONREPORT_H_ -#define PUSVERIFICATIONREPORT_H_ +#ifndef FSFW_TMTCSERVICES_PUSVERIFICATIONREPORT_H_ +#define FSFW_TMTCSERVICES_PUSVERIFICATIONREPORT_H_ + +#include "VerificationCodes.h" #include "../ipc/MessageQueueMessage.h" #include "../tmtcpacket/pus/TcPacketBase.h" -#include "../tmtcservices/VerificationCodes.h" +#include "../returnvalues/HasReturnvaluesIF.h" class PusVerificationMessage: public MessageQueueMessage { private: @@ -30,7 +32,7 @@ private: public: static const uint8_t VERIFICATION_MIN_SIZE = 6; PusVerificationMessage(); -// PusVerificationMessage( uint8_t set_report_id, TcPacketBase* current_packet, ReturnValue_t set_error_code = 0, uint8_t set_step = 0, uint32_t parameter1 = 0, uint32_t parameter2 = 0 ); + PusVerificationMessage(uint8_t set_report_id, uint8_t ackFlags, uint16_t tcPacketId, uint16_t tcSequenceControl, ReturnValue_t set_error_code = 0, uint8_t set_step = 0, @@ -74,4 +76,4 @@ public: uint8_t* getReport(); }; -#endif /* PUSVERIFICATIONREPORT_H_ */ +#endif /* FSFW_TMTCSERVICES_PUSVERIFICATIONREPORT_H_ */ From 224248dfa1e3ca25eaa4cd94910b8e1293679406 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 29 Sep 2020 14:27:31 +0200 Subject: [PATCH 135/192] removed debug outpuzt for missed deadline --- osal/FreeRTOS/FixedTimeslotTask.cpp | 9 --------- osal/FreeRTOS/PeriodicTask.cpp | 4 ---- 2 files changed, 13 deletions(-) diff --git a/osal/FreeRTOS/FixedTimeslotTask.cpp b/osal/FreeRTOS/FixedTimeslotTask.cpp index 309574eb..062686e2 100644 --- a/osal/FreeRTOS/FixedTimeslotTask.cpp +++ b/osal/FreeRTOS/FixedTimeslotTask.cpp @@ -150,15 +150,6 @@ void FixedTimeslotTask::handleMissedDeadline() { if(deadlineMissedFunc != nullptr) { this->deadlineMissedFunc(); } - -#ifdef DEBUG - object_id_t handlerId = pst.current->handlerId; - sif::warning << "FixedTimeslotTask: " << pcTaskGetName(NULL) << " with" - << " object ID 0x" << std::setfill('0') << std::setw(8) << std::hex - << handlerId << " missed deadline!" << std::setfill(' ') - << std::dec << std::endl; -#endif - } ReturnValue_t FixedTimeslotTask::sleepFor(uint32_t ms) { diff --git a/osal/FreeRTOS/PeriodicTask.cpp b/osal/FreeRTOS/PeriodicTask.cpp index c90587bd..5c0a840d 100644 --- a/osal/FreeRTOS/PeriodicTask.cpp +++ b/osal/FreeRTOS/PeriodicTask.cpp @@ -136,8 +136,4 @@ void PeriodicTask::handleMissedDeadline() { if(deadlineMissedFunc != nullptr) { this->deadlineMissedFunc(); } -#ifdef DEBUG - sif::warning << "PeriodicTask::handleMissedDeadline " << pcTaskGetName(NULL) - << " missed deadline!\n" << std::flush; -#endif } From 485e96f12f74dc6dd891aed548b8915872dd540c Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 29 Sep 2020 14:49:57 +0200 Subject: [PATCH 136/192] merged changes --- storagemanager/ConstStorageAccessor.cpp | 15 ++++++--------- storagemanager/ConstStorageAccessor.h | 8 ++++---- storagemanager/LocalPool.h | 13 +++++++------ storagemanager/LocalPool.tpp | 17 +++++++++-------- storagemanager/PoolManager.h | 25 ++++++++++++++++--------- storagemanager/PoolManager.tpp | 19 +++++++++++-------- storagemanager/StorageAccessor.cpp | 4 ++-- storagemanager/StorageAccessor.h | 8 ++++---- storagemanager/StorageManagerIF.h | 12 +++++++----- 9 files changed, 66 insertions(+), 55 deletions(-) diff --git a/storagemanager/ConstStorageAccessor.cpp b/storagemanager/ConstStorageAccessor.cpp index 5c143adb..842f1ce8 100644 --- a/storagemanager/ConstStorageAccessor.cpp +++ b/storagemanager/ConstStorageAccessor.cpp @@ -1,6 +1,7 @@ +#include "ConstStorageAccessor.h" +#include "StorageManagerIF.h" + #include "../serviceinterface/ServiceInterfaceStream.h" -#include "../storagemanager/ConstStorageAccessor.h" -#include "../storagemanager/StorageManagerIF.h" #include "../globalfunctions/arrayprinter.h" ConstStorageAccessor::ConstStorageAccessor(store_address_t storeId): @@ -14,12 +15,7 @@ ConstStorageAccessor::ConstStorageAccessor(store_address_t storeId, ConstStorageAccessor::~ConstStorageAccessor() { if(deleteData and store != nullptr) { - ReturnValue_t result = store->deleteData(storeId); - if(result != HasReturnvaluesIF::RETURN_OK) { - // Configuration error. - sif::error << "ConstStorageAccessor::~ConstStorageAccessor: " - << "Could not delete entry!" << std::endl; - } + store->deleteData(storeId); } } @@ -62,7 +58,8 @@ ReturnValue_t ConstStorageAccessor::getDataCopy(uint8_t *pointer, return HasReturnvaluesIF::RETURN_FAILED; } if(size_ > maxSize) { - sif::error << "StorageAccessor: Supplied buffer not large enough" << std::endl; + sif::error << "StorageAccessor: Supplied buffer not large enough" + << std::endl; return HasReturnvaluesIF::RETURN_FAILED; } std::copy(constDataPointer, constDataPointer + size_, pointer); diff --git a/storagemanager/ConstStorageAccessor.h b/storagemanager/ConstStorageAccessor.h index 573892da..96d2dca2 100644 --- a/storagemanager/ConstStorageAccessor.h +++ b/storagemanager/ConstStorageAccessor.h @@ -1,7 +1,7 @@ -#ifndef FRAMEWORK_STORAGEMANAGER_CONSTSTORAGEACCESSOR_H_ -#define FRAMEWORK_STORAGEMANAGER_CONSTSTORAGEACCESSOR_H_ +#ifndef FSFW_STORAGEMANAGER_CONSTSTORAGEACCESSOR_H_ +#define FSFW_STORAGEMANAGER_CONSTSTORAGEACCESSOR_H_ -#include "../storagemanager/storeAddress.h" +#include "storeAddress.h" #include "../returnvalues/HasReturnvaluesIF.h" #include @@ -113,4 +113,4 @@ protected: }; -#endif /* FRAMEWORK_STORAGEMANAGER_CONSTSTORAGEACCESSOR_H_ */ +#endif /* FSFW_STORAGEMANAGER_CONSTSTORAGEACCESSOR_H_ */ diff --git a/storagemanager/LocalPool.h b/storagemanager/LocalPool.h index 2a526b6a..3a94c03d 100644 --- a/storagemanager/LocalPool.h +++ b/storagemanager/LocalPool.h @@ -1,14 +1,15 @@ -#ifndef FRAMEWORK_STORAGEMANAGER_LOCALPOOL_H_ -#define FRAMEWORK_STORAGEMANAGER_LOCALPOOL_H_ +#ifndef FSFW_STORAGEMANAGER_LOCALPOOL_H_ +#define FSFW_STORAGEMANAGER_LOCALPOOL_H_ +#include "StorageManagerIF.h" #include "../objectmanager/SystemObject.h" -#include "../serviceinterface/ServiceInterfaceStream.h" -#include "../storagemanager/StorageManagerIF.h" #include "../objectmanager/ObjectManagerIF.h" +#include "../serviceinterface/ServiceInterfaceStream.h" #include "../internalError/InternalErrorReporterIF.h" #include "../storagemanager/StorageAccessor.h" #include + /** * @brief The LocalPool class provides an intermediate data storage with * a fixed pool size policy. @@ -184,6 +185,6 @@ private: ReturnValue_t findEmpty(uint16_t pool_index, uint16_t* element); }; -#include "../storagemanager/LocalPool.tpp" +#include "LocalPool.tpp" -#endif /* FRAMEWORK_STORAGEMANAGER_LOCALPOOL_H_ */ +#endif /* FSFW_STORAGEMANAGER_LOCALPOOL_H_ */ diff --git a/storagemanager/LocalPool.tpp b/storagemanager/LocalPool.tpp index 764bd7be..5e61efe4 100644 --- a/storagemanager/LocalPool.tpp +++ b/storagemanager/LocalPool.tpp @@ -1,7 +1,7 @@ -#ifndef FRAMEWORK_STORAGEMANAGER_LOCALPOOL_TPP_ -#define FRAMEWORK_STORAGEMANAGER_LOCALPOOL_TPP_ +#ifndef FSFW_STORAGEMANAGER_LOCALPOOL_TPP_ +#define FSFW_STORAGEMANAGER_LOCALPOOL_TPP_ -#ifndef FRAMEWORK_STORAGEMANAGER_LOCALPOOL_H_ +#ifndef FSFW_STORAGEMANAGER_LOCALPOOL_H_ #error Include LocalPool.h before LocalPool.tpp! #endif @@ -125,9 +125,10 @@ inline LocalPool::~LocalPool(void) { } } -template inline -ReturnValue_t LocalPool::addData(store_address_t* storageId, - const uint8_t* data, size_t size, bool ignoreFault) { +template +inline ReturnValue_t LocalPool::addData( + store_address_t* storageId, const uint8_t* data, size_t size, + bool ignoreFault) { ReturnValue_t status = reserveSpace(size, storageId, ignoreFault); if (status == RETURN_OK) { write(*storageId, data, size); @@ -171,7 +172,7 @@ inline ReturnValue_t LocalPool::getData(store_address_t storeId template inline ReturnValue_t LocalPool::getData( store_address_t packet_id, const uint8_t** packet_ptr, size_t* size) { - uint8_t* tempData = NULL; + uint8_t* tempData = nullptr; ReturnValue_t status = modifyData(packet_id, &tempData, size); *packet_ptr = tempData; return status; @@ -301,4 +302,4 @@ inline ReturnValue_t LocalPool::initialize() { return RETURN_OK; } -#endif +#endif /* FSFW_STORAGEMANAGER_LOCALPOOL_TPP_ */ diff --git a/storagemanager/PoolManager.h b/storagemanager/PoolManager.h index 76bddb8f..8cc6c065 100644 --- a/storagemanager/PoolManager.h +++ b/storagemanager/PoolManager.h @@ -1,9 +1,10 @@ -#ifndef FRAMEWORK_STORAGEMANAGER_POOLMANAGER_H_ -#define FRAMEWORK_STORAGEMANAGER_POOLMANAGER_H_ +#ifndef FSFW_STORAGEMANAGER_POOLMANAGER_H_ +#define FSFW_STORAGEMANAGER_POOLMANAGER_H_ -#include "../storagemanager/LocalPool.h" +#include "LocalPool.h" +#include "StorageAccessor.h" #include "../ipc/MutexHelper.h" -#include "../storagemanager/StorageAccessor.h" + /** * @brief The PoolManager class provides an intermediate data storage with @@ -19,18 +20,24 @@ public: const uint16_t element_sizes[NUMBER_OF_POOLS], const uint16_t n_elements[NUMBER_OF_POOLS]); - //! @brief In the PoolManager's destructor all allocated memory is freed. + /** + * @brief In the PoolManager's destructor all allocated memory + * is freed. + */ virtual ~PoolManager(); - //! @brief LocalPool overrides for thread-safety. Decorator function which - //! wraps LocalPool calls with a mutex protection. + /** + * @brief LocalPool overrides for thread-safety. Decorator function + * which wraps LocalPool calls with a mutex protection. + */ ReturnValue_t deleteData(store_address_t) override; ReturnValue_t deleteData(uint8_t* buffer, size_t size, store_address_t* storeId = nullptr) override; + void setMutexTimeout(uint32_t mutexTimeoutMs); protected: //! Default mutex timeout value to prevent permanent blocking. - static constexpr uint32_t mutexTimeout = 50; + uint32_t mutexTimeoutMs = 20; ReturnValue_t reserveSpace(const uint32_t size, store_address_t* address, bool ignoreFault) override; @@ -46,4 +53,4 @@ protected: #include "PoolManager.tpp" -#endif /* POOLMANAGER_H_ */ +#endif /* FSFW_STORAGEMANAGER_POOLMANAGER_H_ */ diff --git a/storagemanager/PoolManager.tpp b/storagemanager/PoolManager.tpp index 0656e967..2be44ece 100644 --- a/storagemanager/PoolManager.tpp +++ b/storagemanager/PoolManager.tpp @@ -1,7 +1,7 @@ #ifndef FRAMEWORK_STORAGEMANAGER_POOLMANAGER_TPP_ #define FRAMEWORK_STORAGEMANAGER_POOLMANAGER_TPP_ -#ifndef FRAMEWORK_STORAGEMANAGER_POOLMANAGER_H_ +#ifndef FSFW_STORAGEMANAGER_POOLMANAGER_H_ #error Include PoolManager.h before PoolManager.tpp! #endif @@ -21,8 +21,7 @@ inline PoolManager::~PoolManager(void) { template inline ReturnValue_t PoolManager::reserveSpace( const uint32_t size, store_address_t* address, bool ignoreFault) { - MutexHelper mutexHelper(mutex, MutexIF::TimeoutType::WAITING, - mutexTimeout); + MutexHelper mutexHelper(mutex,MutexIF::WAITING, mutexTimeoutMs); ReturnValue_t status = LocalPool::reserveSpace(size, address,ignoreFault); return status; @@ -34,8 +33,7 @@ inline ReturnValue_t PoolManager::deleteData( // debug << "PoolManager( " << translateObject(getObjectId()) << // " )::deleteData from store " << packet_id.pool_index << // ". id is "<< packet_id.packet_index << std::endl; - MutexHelper mutexHelper(mutex, MutexIF::TimeoutType::WAITING, - mutexTimeout); + MutexHelper mutexHelper(mutex,MutexIF::WAITING, mutexTimeoutMs); ReturnValue_t status = LocalPool::deleteData(packet_id); return status; } @@ -43,11 +41,16 @@ inline ReturnValue_t PoolManager::deleteData( template inline ReturnValue_t PoolManager::deleteData(uint8_t* buffer, size_t size, store_address_t* storeId) { - MutexHelper mutexHelper(mutex, MutexIF::TimeoutType::WAITING, - mutexTimeout); + MutexHelper mutexHelper(mutex,MutexIF::WAITING, mutexTimeoutMs); ReturnValue_t status = LocalPool::deleteData(buffer, size, storeId); return status; } -#endif +template +inline void PoolManager::setMutexTimeout( + uint32_t mutexTimeoutMs) { + this->mutexTimeout = mutexTimeoutMs; +} + +#endif /* FRAMEWORK_STORAGEMANAGER_POOLMANAGER_TPP_ */ diff --git a/storagemanager/StorageAccessor.cpp b/storagemanager/StorageAccessor.cpp index 60bd4130..9c2f936a 100644 --- a/storagemanager/StorageAccessor.cpp +++ b/storagemanager/StorageAccessor.cpp @@ -1,5 +1,5 @@ -#include "../storagemanager/StorageAccessor.h" -#include "../storagemanager/StorageManagerIF.h" +#include "StorageAccessor.h" +#include "StorageManagerIF.h" #include "../serviceinterface/ServiceInterfaceStream.h" StorageAccessor::StorageAccessor(store_address_t storeId): diff --git a/storagemanager/StorageAccessor.h b/storagemanager/StorageAccessor.h index a65427b8..5cf15d50 100644 --- a/storagemanager/StorageAccessor.h +++ b/storagemanager/StorageAccessor.h @@ -1,7 +1,7 @@ -#ifndef FRAMEWORK_STORAGEMANAGER_STORAGEACCESSOR_H_ -#define FRAMEWORK_STORAGEMANAGER_STORAGEACCESSOR_H_ +#ifndef FSFW_STORAGEMANAGER_STORAGEACCESSOR_H_ +#define FSFW_STORAGEMANAGER_STORAGEACCESSOR_H_ -#include "../storagemanager/ConstStorageAccessor.h" +#include "ConstStorageAccessor.h" class StorageManagerIF; @@ -42,4 +42,4 @@ private: void assignConstPointer(); }; -#endif /* TEST_PROTOTYPES_STORAGEACCESSOR_H_ */ +#endif /* FSFW_STORAGEMANAGER_STORAGEACCESSOR_H_ */ diff --git a/storagemanager/StorageManagerIF.h b/storagemanager/StorageManagerIF.h index 2229cdf8..834e7563 100644 --- a/storagemanager/StorageManagerIF.h +++ b/storagemanager/StorageManagerIF.h @@ -1,10 +1,12 @@ -#ifndef STORAGEMANAGERIF_H_H -#define STORAGEMANAGERIF_H_H +#ifndef FSFW_STORAGEMANAGER_STORAGEMANAGERIF_H_ +#define FSFW_STORAGEMANAGER_STORAGEMANAGERIF_H_ + +#include "StorageAccessor.h" +#include "storeAddress.h" #include "../events/Event.h" #include "../returnvalues/HasReturnvaluesIF.h" -#include "../storagemanager/StorageAccessor.h" -#include "../storagemanager/storeAddress.h" + #include #include @@ -164,4 +166,4 @@ public: virtual void clearStore() = 0; }; -#endif /* STORAGEMANAGERIF_H_ */ +#endif /* FSFW_STORAGEMANAGER_STORAGEMANAGERIF_H_ */ From fd87a16661290a771e18287bd88ef9df42d60cb2 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 29 Sep 2020 14:51:25 +0200 Subject: [PATCH 137/192] changes taken over --- storagemanager/storeAddress.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/storagemanager/storeAddress.h b/storagemanager/storeAddress.h index 5dd785a3..044c0790 100644 --- a/storagemanager/storeAddress.h +++ b/storagemanager/storeAddress.h @@ -1,5 +1,6 @@ -#ifndef FRAMEWORK_STORAGEMANAGER_STOREADDRESS_H_ -#define FRAMEWORK_STORAGEMANAGER_STOREADDRESS_H_ +#ifndef FSFW_STORAGEMANAGER_STOREADDRESS_H_ +#define FSFW_STORAGEMANAGER_STOREADDRESS_H_ + #include /** @@ -51,4 +52,4 @@ union store_address_t { } }; -#endif /* FRAMEWORK_STORAGEMANAGER_STOREADDRESS_H_ */ +#endif /* FSFW_STORAGEMANAGER_STOREADDRESS_H_ */ From bc23fd65a678fef98a3a7e701d6e40fdac8cf387 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 29 Sep 2020 15:13:51 +0200 Subject: [PATCH 138/192] master taken over --- pus/Service8FunctionManagement.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pus/Service8FunctionManagement.cpp b/pus/Service8FunctionManagement.cpp index 3c94071d..2c2e590b 100644 --- a/pus/Service8FunctionManagement.cpp +++ b/pus/Service8FunctionManagement.cpp @@ -1,5 +1,5 @@ -#include "../pus/Service8FunctionManagement.h" -#include "../pus/servicepackets/Service8Packets.h" +#include "Service8FunctionManagement.h" +#include "servicepackets/Service8Packets.h" #include "../objectmanager/SystemObjectIF.h" #include "../action/HasActionsIF.h" From 207d2cab9c6345c02b93f754344e0e34fc446a5f Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 29 Sep 2020 15:15:29 +0200 Subject: [PATCH 139/192] service 1 changes taken over --- pus/servicepackets/Service1Packets.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pus/servicepackets/Service1Packets.h b/pus/servicepackets/Service1Packets.h index 8c5cb005..dbd31028 100644 --- a/pus/servicepackets/Service1Packets.h +++ b/pus/servicepackets/Service1Packets.h @@ -1,9 +1,3 @@ -#ifndef MISSION_PUS_SERVICEPACKETS_SERVICE1PACKETS_H_ -#define MISSION_PUS_SERVICEPACKETS_SERVICE1PACKETS_H_ - -#include "../../serialize/SerializeAdapter.h" -#include "../../tmtcservices/VerificationCodes.h" - /** * @defgroup spacepackets PUS Packet Definitions * This group contains all implemented TM or TM packages that are sent to @@ -11,12 +5,18 @@ * packet structures in Mission Information Base (MIB). */ +#ifndef MISSION_PUS_SERVICEPACKETS_SERVICE1PACKETS_H_ +#define MISSION_PUS_SERVICEPACKETS_SERVICE1PACKETS_H_ + +#include "../../serialize/SerializeAdapter.h" +#include "../../tmtcservices/VerificationCodes.h" + /** * @brief FailureReport class to serialize a failure report * @brief Subservice 1, 3, 5, 7 * @ingroup spacepackets */ -class FailureReport: public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 2, 4, 6, 8 +class FailureReport: public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 1, 3, 5, 7 public: FailureReport(uint8_t failureSubtype_, uint16_t packetId_, uint16_t packetSequenceControl_, uint8_t stepNumber_, @@ -111,7 +111,7 @@ private: * @brief Subservices 2, 4, 6, 8 * @ingroup spacepackets */ -class SuccessReport: public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 1, 3, 5, 7 +class SuccessReport: public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 2, 4, 6, 8 public: SuccessReport(uint8_t subtype_, uint16_t packetId_, uint16_t packetSequenceControl_,uint8_t stepNumber_) : From 1ea1c8c02fca9cc46536831280e3160b0c73b3f5 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 29 Sep 2020 15:16:20 +0200 Subject: [PATCH 140/192] srv9 fix --- pus/Service9TimeManagement.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pus/Service9TimeManagement.h b/pus/Service9TimeManagement.h index 4ad6be6e..4802cdec 100644 --- a/pus/Service9TimeManagement.h +++ b/pus/Service9TimeManagement.h @@ -1,7 +1,7 @@ #ifndef FSFW_PUS_SERVICE9TIMEMANAGEMENT_H_ #define FSFW_PUS_SERVICE9TIMEMANAGEMENT_H_ -#include +#include "../tmtcservices/PusServiceBase.h" class Service9TimeManagement: public PusServiceBase { public: @@ -34,7 +34,6 @@ private: SET_TIME = 128 //!< [EXPORT] : [COMMAND] Time command in ASCII, CUC or CDS format }; - void setIsisClock(Clock::TimeOfDay_t& timeOfDay); }; From e1eb1a3be17fa8b417859ff5d3231dc32cf1535f Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 29 Sep 2020 15:48:42 +0200 Subject: [PATCH 141/192] small tweaks --- pus/CService201HealthCommanding.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pus/CService201HealthCommanding.cpp b/pus/CService201HealthCommanding.cpp index cc5dd640..7e68533d 100644 --- a/pus/CService201HealthCommanding.cpp +++ b/pus/CService201HealthCommanding.cpp @@ -7,8 +7,8 @@ CService201HealthCommanding::CService201HealthCommanding(object_id_t objectId, uint16_t apid, uint8_t serviceId): - CommandingServiceBase(objectId, apid, serviceId, - NUMBER_OF_PARALLEL_COMMANDS,COMMAND_TIMEOUT_SECONDS) { + CommandingServiceBase(objectId, apid, serviceId, + NUMBER_OF_PARALLEL_COMMANDS,COMMAND_TIMEOUT_SECONDS) { } CService201HealthCommanding::~CService201HealthCommanding() { @@ -56,8 +56,8 @@ ReturnValue_t CService201HealthCommanding::prepareCommand if (result != RETURN_OK) { return result; } else { - HealthMessage::setHealthMessage(dynamic_cast(message), - HealthMessage::HEALTH_SET, healthCommand.getHealth()); + HealthMessage::setHealthMessage(message, HealthMessage::HEALTH_SET, + healthCommand.getHealth()); return result; } } @@ -79,6 +79,6 @@ void CService201HealthCommanding::prepareHealthSetReply( uint8_t health = static_cast(HealthMessage::getHealth(reply)); uint8_t oldHealth = static_cast(HealthMessage::getOldHealth(reply)); HealthSetReply healthSetReply(health, oldHealth); - sendTmPacket(Subservice::REPLY_HEALTH_SET,&healthSetReply); + sendTmPacket(Subservice::REPLY_HEALTH_SET, &healthSetReply); } From d85096d98b951890bf93d373c4a928bea822676f Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 29 Sep 2020 16:03:01 +0200 Subject: [PATCH 142/192] service 200 take over --- pus/CService200ModeCommanding.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/pus/CService200ModeCommanding.cpp b/pus/CService200ModeCommanding.cpp index dda58e03..c63b47a6 100644 --- a/pus/CService200ModeCommanding.cpp +++ b/pus/CService200ModeCommanding.cpp @@ -1,5 +1,5 @@ -#include "../pus/CService200ModeCommanding.h" -#include "../pus/servicepackets/Service200Packets.h" +#include "CService200ModeCommanding.h" +#include "servicepackets/Service200Packets.h" #include "../modes/HasModesIF.h" #include "../serviceinterface/ServiceInterfaceStream.h" @@ -107,13 +107,23 @@ ReturnValue_t CService200ModeCommanding::prepareWrongModeReply( const CommandMessage *reply, object_id_t objectId) { ModePacket wrongModeReply(objectId, ModeMessage::getMode(reply), ModeMessage::getSubmode(reply)); - return sendTmPacket(Subservice::REPLY_WRONG_MODE_REPLY, &wrongModeReply); + ReturnValue_t result = sendTmPacket(Subservice::REPLY_WRONG_MODE_REPLY, &wrongModeReply); + if(result == RETURN_OK){ + // We want to produce an error here in any case because the mode was not correct + return RETURN_FAILED; + } + return result; } ReturnValue_t CService200ModeCommanding::prepareCantReachModeReply( const CommandMessage *reply, object_id_t objectId) { CantReachModePacket cantReachModePacket(objectId, ModeMessage::getCantReachModeReason(reply)); - return sendTmPacket(Subservice::REPLY_CANT_REACH_MODE, + ReturnValue_t result = sendTmPacket(Subservice::REPLY_CANT_REACH_MODE, &cantReachModePacket); + if(result == RETURN_OK){ + // We want to produce an error here in any case because the mode was not reached + return RETURN_FAILED; + } + return result; } From 9013ac240ff9a9ef2f488c1e6bee22ec314b6a37 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 29 Sep 2020 16:12:01 +0200 Subject: [PATCH 143/192] array list taken over --- container/ArrayList.h | 200 +++++++++++++++++++++--------------------- 1 file changed, 99 insertions(+), 101 deletions(-) diff --git a/container/ArrayList.h b/container/ArrayList.h index ae983171..426e02b3 100644 --- a/container/ArrayList.h +++ b/container/ArrayList.h @@ -1,5 +1,5 @@ -#ifndef FRAMEWORK_CONTAINER_ARRAYLIST_H_ -#define FRAMEWORK_CONTAINER_ARRAYLIST_H_ +#ifndef FSFW_CONTAINER_ARRAYLIST_H_ +#define FSFW_CONTAINER_ARRAYLIST_H_ #include "../returnvalues/HasReturnvaluesIF.h" #include "../serialize/SerializeAdapter.h" @@ -20,11 +20,35 @@ public: static const uint8_t INTERFACE_ID = CLASS_ID::ARRAY_LIST; static const ReturnValue_t FULL = MAKE_RETURN_CODE(0x01); - /** - * Copying is forbiden by declaring copy ctor and copy assignment deleted - * It is too ambigous in this case. - * (Allocate a new backend? Use the same? What to do in an modifying call?) - */ + /** + * This is the allocating constructor. + * It allocates an array of the specified size. + * @param maxSize + */ + ArrayList(count_t maxSize) : + size(0), maxSize_(maxSize), allocated(true) { + entries = new T[maxSize]; + } + + /** + * This is the non-allocating constructor + * + * It expects a pointer to an array of a certain size and initializes + * itself to it. + * + * @param storage the array to use as backend + * @param maxSize size of storage + * @param size size of data already present in storage + */ + ArrayList(T *storage, count_t maxSize, count_t size = 0) : + size(size), entries(storage), maxSize_(maxSize), allocated(false) { + } + + /** + * Copying is forbiden by declaring copy ctor and copy assignment deleted + * It is too ambigous in this case. + * (Allocate a new backend? Use the same? What to do in an modifying call?) + */ ArrayList(const ArrayList& other) = delete; const ArrayList& operator=(const ArrayList& other) = delete; @@ -33,30 +57,6 @@ public: */ count_t size; - /** - * This is the allocating constructor; - * - * It allocates an array of the specified size. - * - * @param maxSize - */ - ArrayList(count_t maxSize) : - size(0), maxSize_(maxSize), allocated(true) { - entries = new T[maxSize]; - } - - /** - * This is the non-allocating constructor - * - * It expects a pointer to an array of a certain size and initializes itself to it. - * - * @param storage the array to use as backend - * @param maxSize size of storage - * @param size size of data already present in storage - */ - ArrayList(T *storage, count_t maxSize, count_t size = 0) : - size(size), entries(storage), maxSize_(maxSize), allocated(false) { - } /** * Destructor, if the allocating constructor was used, it deletes the array. @@ -67,86 +67,84 @@ public: } } - /** - * An Iterator to go trough an ArrayList - * - * It stores a pointer to an element and increments the - * pointer when incremented itself. - */ - class Iterator { - public: - /** - * Empty ctor, points to NULL - */ - Iterator(): value(0) {} + /** + * An Iterator to go trough an ArrayList + * + * It stores a pointer to an element and increments the + * pointer when incremented itself. + */ + class Iterator { + public: + /** + * Empty ctor, points to NULL + */ + Iterator(): value(0) {} - /** - * Initializes the Iterator to point to an element - * - * @param initialize - */ - Iterator(T *initialize) { - value = initialize; - } + /** + * Initializes the Iterator to point to an element + * + * @param initialize + */ + Iterator(T *initialize) { + value = initialize; + } - /** - * The current element the iterator points to - */ - T *value; + /** + * The current element the iterator points to + */ + T *value; - Iterator& operator++() { - value++; - return *this; - } + Iterator& operator++() { + value++; + return *this; + } - Iterator operator++(int) { - Iterator tmp(*this); - operator++(); - return tmp; - } + Iterator operator++(int) { + Iterator tmp(*this); + operator++(); + return tmp; + } - Iterator& operator--() { - value--; - return *this; - } + Iterator& operator--() { + value--; + return *this; + } - Iterator operator--(int) { - Iterator tmp(*this); - operator--(); - return tmp; - } + Iterator operator--(int) { + Iterator tmp(*this); + operator--(); + return tmp; + } - T& operator*() { - return *value; - } + T& operator*() { + return *value; + } - const T& operator*() const { - return *value; - } + const T& operator*() const { + return *value; + } - T *operator->() { - return value; - } + T *operator->() { + return value; + } - const T *operator->() const { - return value; - } + const T *operator->() const { + return value; + } - //SHOULDDO this should be implemented as non-member - bool operator==(const typename ArrayList::Iterator& other) const { - return (value == other.value); - } + //SHOULDDO this should be implemented as non-member + bool operator==(const typename + ArrayList::Iterator& other) const { + return (value == other.value); + } - //SHOULDDO this should be implemented as non-member - bool operator!=(const typename ArrayList::Iterator& other) const { - // POSSIBLY BUGGY ! Also this is really confusing. Why does - // the operator above use the value while this one - // dereferences itself? - //return not (value == other.value); - return !(*this == other); - } - }; + //SHOULDDO this should be implemented as non-member + bool operator!=(const typename + ArrayList::Iterator& other) const { + return !(*this == other); + } + }; /** * Iterator pointing to the first stored elmement @@ -201,7 +199,7 @@ public: * * @return maximum number of elements */ - uint32_t maxSize() const { + size_t maxSize() const { return this->maxSize_; } @@ -245,7 +243,7 @@ protected: /** * remembering the maximum size */ - uint32_t maxSize_; + size_t maxSize_; /** * true if the array was allocated and needs to be deleted in the destructor. @@ -253,4 +251,4 @@ protected: bool allocated; }; -#endif /* ARRAYLIST_H_ */ +#endif /* FSFW_CONTAINER_ARRAYLIST_H_ */ From 4f3cfdcaaf57a790ae7b8cf874c76252f20ceb6d Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 29 Sep 2020 16:41:14 +0200 Subject: [PATCH 144/192] fixed map and array list implemented as non - members --- container/ArrayList.h | 34 +++++++++++++++++++++++----------- container/FixedMap.h | 10 ++++++++++ 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/container/ArrayList.h b/container/ArrayList.h index 426e02b3..16318569 100644 --- a/container/ArrayList.h +++ b/container/ArrayList.h @@ -133,19 +133,29 @@ public: } - //SHOULDDO this should be implemented as non-member - bool operator==(const typename - ArrayList::Iterator& other) const { - return (value == other.value); - } - - //SHOULDDO this should be implemented as non-member - bool operator!=(const typename - ArrayList::Iterator& other) const { - return !(*this == other); - } +// //SHOULDDO this should be implemented as non-member +// bool operator==(const typename +// ArrayList::Iterator& other) const { +// return (value == other.value); +// } +// +// //SHOULDDO this should be implemented as non-member +// bool operator!=(const typename +// ArrayList::Iterator& other) const { +// return !(*this == other); +// } }; + friend bool operator==(const ArrayList::Iterator& lhs, + const ArrayList::Iterator& rhs) { + return (lhs.value == rhs.value); + } + + friend bool operator!=(const ArrayList::Iterator& lhs, + const ArrayList::Iterator& rhs) { + return not (lhs.value == rhs.value); + } + /** * Iterator pointing to the first stored elmement * @@ -251,4 +261,6 @@ protected: bool allocated; }; + + #endif /* FSFW_CONTAINER_ARRAYLIST_H_ */ diff --git a/container/FixedMap.h b/container/FixedMap.h index e5fbb3be..1e36b1bc 100644 --- a/container/FixedMap.h +++ b/container/FixedMap.h @@ -61,6 +61,16 @@ public: } }; + friend bool operator==(const typename FixedMap::Iterator& lhs, + const typename FixedMap::Iterator& rhs) { + return (lhs.value == rhs.value); + } + + friend bool operator!=(const typename FixedMap::Iterator& lhs, + const typename FixedMap::Iterator& rhs) { + return not (lhs.value == rhs.value); + } + Iterator begin() const { return Iterator(&theMap[0]); } From 3c814a5e6105390bbbee8ae7df825af45fa53df1 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 29 Sep 2020 18:01:55 +0200 Subject: [PATCH 145/192] include fixes --- monitoring/AbsLimitMonitor.h | 2 +- monitoring/LimitMonitor.h | 13 ++++++------- monitoring/LimitViolationReporter.cpp | 6 +++--- monitoring/MonitorBase.h | 12 ++++++------ monitoring/MonitorReporter.h | 6 +++--- monitoring/MonitoringIF.h | 2 +- monitoring/MonitoringMessage.cpp | 2 +- monitoring/MonitoringMessageContent.h | 4 ++-- monitoring/TwoValueLimitMonitor.h | 2 +- 9 files changed, 24 insertions(+), 25 deletions(-) diff --git a/monitoring/AbsLimitMonitor.h b/monitoring/AbsLimitMonitor.h index c32c63ef..2e60f6f8 100644 --- a/monitoring/AbsLimitMonitor.h +++ b/monitoring/AbsLimitMonitor.h @@ -1,7 +1,7 @@ #ifndef FRAMEWORK_MONITORING_ABSLIMITMONITOR_H_ #define FRAMEWORK_MONITORING_ABSLIMITMONITOR_H_ -#include "../monitoring/MonitorBase.h" +#include "MonitorBase.h" #include template diff --git a/monitoring/LimitMonitor.h b/monitoring/LimitMonitor.h index 4aec8669..66e6725e 100644 --- a/monitoring/LimitMonitor.h +++ b/monitoring/LimitMonitor.h @@ -1,7 +1,7 @@ #ifndef FRAMEWORK_MONITORING_LIMITMONITOR_H_ #define FRAMEWORK_MONITORING_LIMITMONITOR_H_ -#include "../monitoring/MonitorBase.h" +#include "MonitorBase.h" /** * Variant of a limit checking class. @@ -16,13 +16,12 @@ public: uint16_t confirmationLimit, T lowerLimit, T upperLimit, Event belowLowEvent = MonitoringIF::VALUE_BELOW_LOW_LIMIT, Event aboveHighEvent = MonitoringIF::VALUE_ABOVE_HIGH_LIMIT) : - MonitorBase(reporterId, monitorId, parameterId, confirmationLimit), - lowerLimit(lowerLimit), upperLimit(upperLimit), belowLowEvent(belowLowEvent), - aboveHighEvent(aboveHighEvent) { + MonitorBase(reporterId, monitorId, parameterId, confirmationLimit), lowerLimit( + lowerLimit), upperLimit(upperLimit), belowLowEvent( + belowLowEvent), aboveHighEvent(aboveHighEvent) { + } + virtual ~LimitMonitor() { } - - virtual ~LimitMonitor() {} - virtual ReturnValue_t checkSample(T sample, T* crossedLimit) { *crossedLimit = 0.0; if (sample > upperLimit) { diff --git a/monitoring/LimitViolationReporter.cpp b/monitoring/LimitViolationReporter.cpp index 87278f4e..c531a6e6 100644 --- a/monitoring/LimitViolationReporter.cpp +++ b/monitoring/LimitViolationReporter.cpp @@ -4,9 +4,9 @@ * @date 17.07.2014 * @author baetz */ -#include "../monitoring/LimitViolationReporter.h" -#include "../monitoring/MonitoringIF.h" -#include "../monitoring/ReceivesMonitoringReportsIF.h" +#include "LimitViolationReporter.h" +#include "MonitoringIF.h" +#include "ReceivesMonitoringReportsIF.h" #include "../objectmanager/ObjectManagerIF.h" #include "../serialize/SerializeAdapter.h" diff --git a/monitoring/MonitorBase.h b/monitoring/MonitorBase.h index 5173c479..51677fc1 100644 --- a/monitoring/MonitorBase.h +++ b/monitoring/MonitorBase.h @@ -1,12 +1,12 @@ #ifndef MONITORBASE_H_ #define MONITORBASE_H_ -#include "../datapoolglob/GlobalDataSet.h" -#include "../datapoolglob/PIDReader.h" -#include "../monitoring/LimitViolationReporter.h" -#include "../monitoring/MonitoringIF.h" -#include "../monitoring/MonitoringMessageContent.h" -#include "../monitoring/MonitorReporter.h" +#include "../datapool/DataSet.h" +#include "../datapool/PIDReader.h" +#include "LimitViolationReporter.h" +#include "MonitoringIF.h" +#include "MonitoringMessageContent.h" +#include "MonitorReporter.h" /** * Base class for monitoring of parameters. diff --git a/monitoring/MonitorReporter.h b/monitoring/MonitorReporter.h index 9823cde0..ca2b534b 100644 --- a/monitoring/MonitorReporter.h +++ b/monitoring/MonitorReporter.h @@ -2,9 +2,9 @@ #define FRAMEWORK_MONITORING_MONITORREPORTER_H_ #include "../events/EventManagerIF.h" -#include "../monitoring/LimitViolationReporter.h" -#include "../monitoring/MonitoringIF.h" -#include "../monitoring/MonitoringMessageContent.h" +#include "LimitViolationReporter.h" +#include "MonitoringIF.h" +#include "MonitoringMessageContent.h" #include "../parameters/HasParametersIF.h" template diff --git a/monitoring/MonitoringIF.h b/monitoring/MonitoringIF.h index d9ea339f..44218c36 100644 --- a/monitoring/MonitoringIF.h +++ b/monitoring/MonitoringIF.h @@ -2,7 +2,7 @@ #define MONITORINGIF_H_ #include "../memory/HasMemoryIF.h" -#include "../monitoring/MonitoringMessage.h" +#include "MonitoringMessage.h" #include "../serialize/SerializeIF.h" class MonitoringIF : public SerializeIF { diff --git a/monitoring/MonitoringMessage.cpp b/monitoring/MonitoringMessage.cpp index 2cfe1ece..8caa27ae 100644 --- a/monitoring/MonitoringMessage.cpp +++ b/monitoring/MonitoringMessage.cpp @@ -1,4 +1,4 @@ -#include "../monitoring/MonitoringMessage.h" +#include "MonitoringMessage.h" #include "../objectmanager/ObjectManagerIF.h" MonitoringMessage::~MonitoringMessage() { diff --git a/monitoring/MonitoringMessageContent.h b/monitoring/MonitoringMessageContent.h index ea52962b..c82506f3 100644 --- a/monitoring/MonitoringMessageContent.h +++ b/monitoring/MonitoringMessageContent.h @@ -1,8 +1,8 @@ #ifndef MONITORINGMESSAGECONTENT_H_ #define MONITORINGMESSAGECONTENT_H_ -#include "../monitoring/HasMonitorsIF.h" -#include "../monitoring/MonitoringIF.h" +#include "HasMonitorsIF.h" +#include "MonitoringIF.h" #include "../objectmanager/ObjectManagerIF.h" #include "../serialize/SerialBufferAdapter.h" #include "../serialize/SerialFixedArrayListAdapter.h" diff --git a/monitoring/TwoValueLimitMonitor.h b/monitoring/TwoValueLimitMonitor.h index 74934828..e690cdae 100644 --- a/monitoring/TwoValueLimitMonitor.h +++ b/monitoring/TwoValueLimitMonitor.h @@ -1,7 +1,7 @@ #ifndef FRAMEWORK_MONITORING_TWOVALUELIMITMONITOR_H_ #define FRAMEWORK_MONITORING_TWOVALUELIMITMONITOR_H_ -#include "../monitoring/LimitMonitor.h" +#include "LimitMonitor.h" template class TwoValueLimitMonitor: public LimitMonitor { From b59a4c5de62863afd9fa3a45912a4f4e7f862b4b Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 29 Sep 2020 18:02:41 +0200 Subject: [PATCH 146/192] equalization complete --- monitoring/MonitorBase.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/monitoring/MonitorBase.h b/monitoring/MonitorBase.h index 51677fc1..964fd55e 100644 --- a/monitoring/MonitorBase.h +++ b/monitoring/MonitorBase.h @@ -1,8 +1,8 @@ #ifndef MONITORBASE_H_ #define MONITORBASE_H_ -#include "../datapool/DataSet.h" -#include "../datapool/PIDReader.h" +#include "../datapoolglob/GlobalDataSet.h" +#include "../datapoolglob/PIDReader.h" #include "LimitViolationReporter.h" #include "MonitoringIF.h" #include "MonitoringMessageContent.h" From d8392de058b1ecde643dabb5903f3534b68acefb Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Wed, 30 Sep 2020 20:28:33 +0200 Subject: [PATCH 147/192] made define more generic --- timemanager/CCSDSTime.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/timemanager/CCSDSTime.cpp b/timemanager/CCSDSTime.cpp index 80a4e27c..8878a38a 100644 --- a/timemanager/CCSDSTime.cpp +++ b/timemanager/CCSDSTime.cpp @@ -159,7 +159,7 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t* } // Newlib nano can't parse uint8, see SCNu8 documentation and https://sourceware.org/newlib/README // Suggestion: use uint16 all the time. This should work on all systems. -#if FSFW_NEWLIB_NANO_NO_C99_IO == 1 +#if FSFW_NO_C99_IO == 1 uint16_t year; uint16_t month; uint16_t day; From d44428f49c8d99de93632b20307d9ddbe4b77584 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Wed, 30 Sep 2020 23:38:54 +0200 Subject: [PATCH 148/192] DH IF and DH message improved --- devicehandlers/DeviceHandlerIF.h | 14 +++-- devicehandlers/DeviceHandlerMessage.h | 75 ++++++++++----------------- 2 files changed, 37 insertions(+), 52 deletions(-) diff --git a/devicehandlers/DeviceHandlerIF.h b/devicehandlers/DeviceHandlerIF.h index e3fa3b88..b4cf736d 100644 --- a/devicehandlers/DeviceHandlerIF.h +++ b/devicehandlers/DeviceHandlerIF.h @@ -1,8 +1,9 @@ -#ifndef DEVICEHANDLERIF_H_ -#define DEVICEHANDLERIF_H_ +#ifndef FSFW_DEVICEHANDLERS_DEVICEHANDLERIF_H_ +#define FSFW_DEVICEHANDLERS_DEVICEHANDLERIF_H_ + +#include "DeviceHandlerMessage.h" #include "../action/HasActionsIF.h" -#include "../devicehandlers/DeviceHandlerMessage.h" #include "../events/Event.h" #include "../modes/HasModesIF.h" #include "../ipc/MessageQueueSenderIF.h" @@ -14,6 +15,11 @@ */ class DeviceHandlerIF { public: + /** + * This is used to uniquely identify commands that are sent to a device + * The values are defined in the device-specific implementations + */ + typedef uint32_t DeviceCommandId_t; static const uint8_t TRANSITION_MODE_CHILD_ACTION_MASK = 0x20; static const uint8_t TRANSITION_MODE_BASE_ACTION_MASK = 0x10; @@ -152,4 +158,4 @@ public: }; -#endif /* DEVICEHANDLERIF_H_ */ +#endif /* FSFW_DEVICEHANDLERS_DEVICEHANDLERIF_H_ */ diff --git a/devicehandlers/DeviceHandlerMessage.h b/devicehandlers/DeviceHandlerMessage.h index 5f4583d2..842dfee8 100644 --- a/devicehandlers/DeviceHandlerMessage.h +++ b/devicehandlers/DeviceHandlerMessage.h @@ -1,69 +1,53 @@ -#ifndef DEVICEHANDLERMESSAGE_H_ -#define DEVICEHANDLERMESSAGE_H_ +#ifndef FSFW_DEVICEHANDLERS_DEVICEHANDLERMESSAGE_H_ +#define FSFW_DEVICEHANDLERS_DEVICEHANDLERMESSAGE_H_ #include "../action/ActionMessage.h" #include "../ipc/CommandMessage.h" #include "../objectmanager/SystemObjectIF.h" #include "../storagemanager/StorageManagerIF.h" -//SHOULDDO: rework the static constructors to name the type of command they are building, maybe even hide setting the commandID. +// SHOULDDO: rework the static constructors to name the type of command +// they are building, maybe even hide setting the commandID. + /** - * This is used to uniquely identify commands that are sent to a device - * - * The values are defined in the device-specific implementations - */ -typedef uint32_t DeviceCommandId_t; - -/** - * The DeviceHandlerMessage is used to send Commands to a DeviceHandlerIF + * @brief The DeviceHandlerMessage is used to send commands to classes + * implementing DeviceHandlerIF */ class DeviceHandlerMessage { -private: - DeviceHandlerMessage(); public: + // Instantiation forbidden. + DeviceHandlerMessage() = delete; + virtual ~DeviceHandlerMessage() {} /** * These are the commands that can be sent to a DeviceHandlerBase */ static const uint8_t MESSAGE_ID = messagetypes::DEVICE_HANDLER_COMMAND; - static const Command_t CMD_RAW = MAKE_COMMAND_ID( 1 ); //!< Sends a raw command, setParameter is a ::store_id_t containing the raw packet to send -// static const Command_t CMD_DIRECT = MAKE_COMMAND_ID( 2 ); //!< Sends a direct command, setParameter is a ::DeviceCommandId_t, setParameter2 is a ::store_id_t containing the data needed for the command - static const Command_t CMD_SWITCH_ADDRESS = MAKE_COMMAND_ID( 3 ); //!< Requests a IO-Board switch, setParameter() is the IO-Board identifier - static const Command_t CMD_WIRETAPPING = MAKE_COMMAND_ID( 4 ); //!< (De)Activates the monitoring of all raw traffic in DeviceHandlers, setParameter is 0 to deactivate, 1 to activate + //! Sends a raw command, setParameter is a storeId containing the + //! raw packet to send + static const Command_t CMD_RAW = MAKE_COMMAND_ID( 1 ); + //! Requests a IO-Board switch, setParameter() is the IO-Board identifier + static const Command_t CMD_SWITCH_ADDRESS = MAKE_COMMAND_ID( 3 ); + //! (De)Activates the monitoring of all raw traffic in DeviceHandlers, + //! setParameter is 0 to deactivate, 1 to activate + static const Command_t CMD_WIRETAPPING = MAKE_COMMAND_ID( 4 ); - /*static const Command_t REPLY_SWITCHED_IOBOARD = MAKE_COMMAND_ID(1 );//!< Reply to a @c CMD_SWITCH_IOBOARD, indicates switch was successful, getParameter() contains the board switched to (0: nominal, 1: redundant) - static const Command_t REPLY_CANT_SWITCH_IOBOARD = MAKE_COMMAND_ID( 2); //!< Reply to a @c CMD_SWITCH_IOBOARD, indicating the switch could not be performed, getParameter() contains the error message - static const Command_t REPLY_WIRETAPPING = MAKE_COMMAND_ID( 3); //!< Reply to a @c CMD_WIRETAPPING, getParameter() is the current state, 1 enabled, 0 disabled - - static const Command_t REPLY_COMMAND_WAS_SENT = MAKE_COMMAND_ID(4 );//!< Reply to a @c CMD_RAW or @c CMD_DIRECT, indicates the command was successfully sent to the device, getParameter() contains the ::DeviceCommandId_t - static const Command_t REPLY_COMMAND_NOT_SUPPORTED = MAKE_COMMAND_ID(5 );//!< Reply to a @c CMD_DIRECT, the requested ::DeviceCommand_t is not supported, getParameter() contains the requested ::DeviceCommand_t, getParameter2() contains the ::DeviceCommandId_t - static const Command_t REPLY_COMMAND_WAS_NOT_SENT = MAKE_COMMAND_ID(6 );//!< Reply to a @c CMD_RAW or @c CMD_DIRECT, indicates the command was not sent, getParameter contains the RMAP Return code (@see rmap.h), getParameter2() contains the ::DeviceCommandId_t - - static const Command_t REPLY_COMMAND_ALREADY_SENT = MAKE_COMMAND_ID(7 );//!< Reply to a @c CMD_DIRECT, the requested ::DeviceCommand_t has already been sent to the device and not ye been answered - static const Command_t REPLY_WRONG_MODE_FOR_CMD = MAKE_COMMAND_ID(8 );//!< Reply to a @c CMD_RAW or @c CMD_DIRECT, indicates that the requested command can not be sent in the curent mode, getParameter() contains the DeviceHandlerCommand_t - static const Command_t REPLY_NO_DATA = MAKE_COMMAND_ID(9 ); //!< Reply to a CMD_RAW or @c CMD_DIRECT, indicates that the ::store_id_t was invalid, getParameter() contains the ::DeviceCommandId_t, getPrameter2() contains the error code - */ - static const Command_t REPLY_DIRECT_COMMAND_SENT = ActionMessage::STEP_SUCCESS; //!< Signals that a direct command was sent - static const Command_t REPLY_RAW_COMMAND = MAKE_COMMAND_ID(0x11 ); //!< Contains a raw command sent to the Device - static const Command_t REPLY_RAW_REPLY = MAKE_COMMAND_ID( 0x12); //!< Contains a raw reply from the Device, getParameter() is the ObjcetId of the sender, getParameter2() is a ::store_id_t containing the raw packet received + //! Signals that a direct command was sent + static const Command_t REPLY_DIRECT_COMMAND_SENT = ActionMessage::STEP_SUCCESS; + //! Contains a raw command sent to the Device + static const Command_t REPLY_RAW_COMMAND = MAKE_COMMAND_ID(0x11 ); + //! Contains a raw reply from the Device, getParameter() is the ObjcetId + //! of the sender, getParameter2() is a ::store_id_t containing the + //! raw packet received + static const Command_t REPLY_RAW_REPLY = MAKE_COMMAND_ID( 0x12); static const Command_t REPLY_DIRECT_COMMAND_DATA = ActionMessage::DATA_REPLY; - /** - * Default Destructor - */ - virtual ~DeviceHandlerMessage() { - } - static store_address_t getStoreAddress(const CommandMessage* message); static uint32_t getDeviceCommandId(const CommandMessage* message); static object_id_t getDeviceObjectId(const CommandMessage *message); static object_id_t getIoBoardObjectId(const CommandMessage* message); static uint8_t getWiretappingMode(const CommandMessage* message); -// static void setDeviceHandlerDirectCommandMessage(CommandMessage* message, -// DeviceCommandId_t deviceCommand, -// store_address_t commandParametersStoreId); - static void setDeviceHandlerDirectCommandReply(CommandMessage* message, object_id_t deviceObjectid, store_address_t commandParametersStoreId); @@ -75,11 +59,6 @@ public: object_id_t deviceObjectid, store_address_t rawPacketStoreId, bool isCommand); -// static void setDeviceHandlerMessage(CommandMessage* message, -// Command_t command, DeviceCommandId_t deviceCommand, -// store_address_t commandParametersStoreId); -// static void setDeviceHandlerMessage(CommandMessage* message, -// Command_t command, store_address_t rawPacketStoreId); static void setDeviceHandlerWiretappingMessage(CommandMessage* message, uint8_t wiretappingMode); static void setDeviceHandlerSwitchIoBoardMessage(CommandMessage* message, @@ -88,4 +67,4 @@ public: static void clear(CommandMessage* message); }; -#endif /* DEVICEHANDLERMESSAGE_H_ */ +#endif /* FSFW_DEVICEHANDLERS_DEVICEHANDLERMESSAGE_H_ */ From aed2d7fc9369e006cc7aa672a1cfeb7fb46e9f25 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Wed, 30 Sep 2020 23:42:18 +0200 Subject: [PATCH 149/192] slight formatting --- devicehandlers/DeviceHandlerIF.h | 12 +++++++----- devicehandlers/DeviceHandlerMessage.cpp | 17 ++--------------- devicehandlers/DeviceHandlerMessage.h | 15 +++++++++------ 3 files changed, 18 insertions(+), 26 deletions(-) diff --git a/devicehandlers/DeviceHandlerIF.h b/devicehandlers/DeviceHandlerIF.h index b4cf736d..9c8eb098 100644 --- a/devicehandlers/DeviceHandlerIF.h +++ b/devicehandlers/DeviceHandlerIF.h @@ -8,6 +8,12 @@ #include "../modes/HasModesIF.h" #include "../ipc/MessageQueueSenderIF.h" +/** + * This is used to uniquely identify commands that are sent to a device + * The values are defined in the device-specific implementations + */ +using DeviceCommandId_t = uint32_t; + /** * @brief This is the Interface used to communicate with a device handler. * @details Includes all expected return values, events and modes. @@ -15,11 +21,7 @@ */ class DeviceHandlerIF { public: - /** - * This is used to uniquely identify commands that are sent to a device - * The values are defined in the device-specific implementations - */ - typedef uint32_t DeviceCommandId_t; + static const uint8_t TRANSITION_MODE_CHILD_ACTION_MASK = 0x20; static const uint8_t TRANSITION_MODE_BASE_ACTION_MASK = 0x10; diff --git a/devicehandlers/DeviceHandlerMessage.cpp b/devicehandlers/DeviceHandlerMessage.cpp index b4963dbf..cb9043db 100644 --- a/devicehandlers/DeviceHandlerMessage.cpp +++ b/devicehandlers/DeviceHandlerMessage.cpp @@ -1,9 +1,5 @@ +#include "DeviceHandlerMessage.h" #include "../objectmanager/ObjectManagerIF.h" -#include "../devicehandlers/DeviceHandlerMessage.h" -#include "../objectmanager/ObjectManagerIF.h" - -DeviceHandlerMessage::DeviceHandlerMessage() { -} store_address_t DeviceHandlerMessage::getStoreAddress( const CommandMessage* message) { @@ -25,14 +21,6 @@ uint8_t DeviceHandlerMessage::getWiretappingMode( return message->getParameter(); } -//void DeviceHandlerMessage::setDeviceHandlerDirectCommandMessage( -// CommandMessage* message, DeviceCommandId_t deviceCommand, -// store_address_t commandParametersStoreId) { -// message->setCommand(CMD_DIRECT); -// message->setParameter(deviceCommand); -// message->setParameter2(commandParametersStoreId.raw); -//} - void DeviceHandlerMessage::setDeviceHandlerRawCommandMessage( CommandMessage* message, store_address_t rawPacketStoreId) { message->setCommand(CMD_RAW); @@ -79,13 +67,12 @@ void DeviceHandlerMessage::setDeviceHandlerDirectCommandReply( void DeviceHandlerMessage::clear(CommandMessage* message) { switch (message->getCommand()) { case CMD_RAW: -// case CMD_DIRECT: case REPLY_RAW_COMMAND: case REPLY_RAW_REPLY: case REPLY_DIRECT_COMMAND_DATA: { StorageManagerIF *ipcStore = objectManager->get( objects::IPC_STORE); - if (ipcStore != NULL) { + if (ipcStore != nullptr) { ipcStore->deleteData(getStoreAddress(message)); } } diff --git a/devicehandlers/DeviceHandlerMessage.h b/devicehandlers/DeviceHandlerMessage.h index 842dfee8..e5da01c8 100644 --- a/devicehandlers/DeviceHandlerMessage.h +++ b/devicehandlers/DeviceHandlerMessage.h @@ -15,7 +15,10 @@ */ class DeviceHandlerMessage { public: - // Instantiation forbidden. + /** + * Instantiation forbidden. Instead, use static functions to operate + * on messages. + */ DeviceHandlerMessage() = delete; virtual ~DeviceHandlerMessage() {} @@ -25,21 +28,21 @@ public: static const uint8_t MESSAGE_ID = messagetypes::DEVICE_HANDLER_COMMAND; //! Sends a raw command, setParameter is a storeId containing the //! raw packet to send - static const Command_t CMD_RAW = MAKE_COMMAND_ID( 1 ); + static const Command_t CMD_RAW = MAKE_COMMAND_ID(1); //! Requests a IO-Board switch, setParameter() is the IO-Board identifier - static const Command_t CMD_SWITCH_ADDRESS = MAKE_COMMAND_ID( 3 ); + static const Command_t CMD_SWITCH_ADDRESS = MAKE_COMMAND_ID(3); //! (De)Activates the monitoring of all raw traffic in DeviceHandlers, //! setParameter is 0 to deactivate, 1 to activate - static const Command_t CMD_WIRETAPPING = MAKE_COMMAND_ID( 4 ); + static const Command_t CMD_WIRETAPPING = MAKE_COMMAND_ID(4); //! Signals that a direct command was sent static const Command_t REPLY_DIRECT_COMMAND_SENT = ActionMessage::STEP_SUCCESS; //! Contains a raw command sent to the Device - static const Command_t REPLY_RAW_COMMAND = MAKE_COMMAND_ID(0x11 ); + static const Command_t REPLY_RAW_COMMAND = MAKE_COMMAND_ID(0x11); //! Contains a raw reply from the Device, getParameter() is the ObjcetId //! of the sender, getParameter2() is a ::store_id_t containing the //! raw packet received - static const Command_t REPLY_RAW_REPLY = MAKE_COMMAND_ID( 0x12); + static const Command_t REPLY_RAW_REPLY = MAKE_COMMAND_ID(0x12); static const Command_t REPLY_DIRECT_COMMAND_DATA = ActionMessage::DATA_REPLY; static store_address_t getStoreAddress(const CommandMessage* message); From 43b44c57b6754c82e3813444568b8fc275469f92 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 1 Oct 2020 11:07:20 +0200 Subject: [PATCH 150/192] placement fact update --- container/PlacementFactory.h | 42 +++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/container/PlacementFactory.h b/container/PlacementFactory.h index 05538478..a0aebb7d 100644 --- a/container/PlacementFactory.h +++ b/container/PlacementFactory.h @@ -3,26 +3,62 @@ #include "../storagemanager/StorageManagerIF.h" #include - +/** + * The Placement Factory is used to create objects at runtime in a specific pool. + * In general, this should be avoided and it should only be used if you know what you are doing. + * You are not allowed to use this container with a type that allocates memory internally like ArrayList. + * + * Also, you have to check the returned pointer in generate against nullptr! + * + * A backend of Type StorageManagerIF must be given as a place to store the new objects. + * Therefore ThreadSafety is only provided by your StorageManager Implementation. + * + * Objects must be destroyed by the user with "destroy"! Otherwise the pool will not be cleared. + * + * The concept is based on the placement new operator. + * + * @warning Do not use with any Type that allocates memory internally! + * @ingroup container + */ class PlacementFactory { public: PlacementFactory(StorageManagerIF* backend) : dataBackend(backend) { } + + /*** + * Generates an object of type T in the backend storage. + * + * @warning Do not use with any Type that allocates memory internally! + * + * @tparam T Type of Object + * @param args Constructor Arguments to be passed + * @return A pointer to the new object or a nullptr in case of failure + */ template T* generate(Args&&... args) { store_address_t tempId; - uint8_t* pData = NULL; + uint8_t* pData = nullptr; ReturnValue_t result = dataBackend->getFreeElement(&tempId, sizeof(T), &pData); if (result != HasReturnvaluesIF::RETURN_OK) { - return NULL; + return nullptr; } T* temp = new (pData) T(std::forward(args)...); return temp; } + /*** + * Function to destroy the object allocated with generate and free space in backend. + * This must be called by the user. + * + * @param thisElement Element to be destroyed + * @return RETURN_OK if the element was destroyed, different errors on failure + */ template ReturnValue_t destroy(T* thisElement) { + if (thisElement == nullptr){ + return HasReturnvaluesIF::RETURN_FAILED; + } //Need to call destructor first, in case something was allocated by the object (shouldn't do that, however). thisElement->~T(); uint8_t* pointer = (uint8_t*) (thisElement); From 32ebca48b864039cd5ee334b6f69ff6010d1d700 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 1 Oct 2020 11:07:46 +0200 Subject: [PATCH 151/192] FIFO updates --- container/FIFOBase.h | 30 ++++++++++++++++++++++-------- container/FIFOBase.tpp | 6 ++++++ 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/container/FIFOBase.h b/container/FIFOBase.h index b744706d..edd66d37 100644 --- a/container/FIFOBase.h +++ b/container/FIFOBase.h @@ -19,32 +19,46 @@ public: /** * Insert value into FIFO * @param value - * @return + * @return RETURN_OK on success, FULL if full */ ReturnValue_t insert(T value); /** * Retrieve item from FIFO. This removes the item from the FIFO. - * @param value - * @return + * @param value Must point to a valid T + * @return RETURN_OK on success, EMPTY if empty and FAILED if nullptr check failed */ ReturnValue_t retrieve(T *value); /** * Retrieve item from FIFO without removing it from FIFO. - * @param value - * @return + * @param value Must point to a valid T + * @return RETURN_OK on success, EMPTY if empty and FAILED if nullptr check failed */ ReturnValue_t peek(T * value); /** * Remove item from FIFO. - * @return + * @return RETURN_OK on success, EMPTY if empty */ ReturnValue_t pop(); + /*** + * Check if FIFO is empty + * @return True if empty, False if not + */ bool empty(); + /*** + * Check if FIFO is Full + * @return True if full, False if not + */ bool full(); + /*** + * Current used size (elements) used + * @return size_t in elements + */ size_t size(); - - + /*** + * Get maximal capacity of fifo + * @return size_t with max capacity of this fifo + */ size_t getMaxCapacity() const; protected: diff --git a/container/FIFOBase.tpp b/container/FIFOBase.tpp index d54b3f8f..763004b6 100644 --- a/container/FIFOBase.tpp +++ b/container/FIFOBase.tpp @@ -26,6 +26,9 @@ inline ReturnValue_t FIFOBase::retrieve(T* value) { if (empty()) { return EMPTY; } else { + if (value == nullptr){ + return HasReturnvaluesIF::RETURN_FAILED; + } *value = values[readIndex]; readIndex = next(readIndex); --currentSize; @@ -38,6 +41,9 @@ inline ReturnValue_t FIFOBase::peek(T* value) { if(empty()) { return EMPTY; } else { + if (value == nullptr){ + return HasReturnvaluesIF::RETURN_FAILED; + } *value = values[readIndex]; return HasReturnvaluesIF::RETURN_OK; } From 315777d265a57b50aff944bc795a15a24e64ac72 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 1 Oct 2020 13:21:23 +0200 Subject: [PATCH 152/192] tc distribution equalization --- tcdistribution/CCSDSDistributor.cpp | 22 ++++--- tcdistribution/CCSDSDistributor.h | 14 +++-- tcdistribution/CCSDSDistributorIF.h | 36 ++++++----- tcdistribution/PUSDistributor.cpp | 94 +++++++++++++++++------------ tcdistribution/PUSDistributor.h | 18 +++--- tcdistribution/PUSDistributorIF.h | 13 ++-- tcdistribution/TcDistributor.cpp | 25 ++++---- tcdistribution/TcDistributor.h | 34 ++++++----- tcdistribution/TcPacketCheck.cpp | 24 ++++---- tcdistribution/TcPacketCheck.h | 25 ++++---- 10 files changed, 170 insertions(+), 135 deletions(-) diff --git a/tcdistribution/CCSDSDistributor.cpp b/tcdistribution/CCSDSDistributor.cpp index dda26d7f..ddd63308 100644 --- a/tcdistribution/CCSDSDistributor.cpp +++ b/tcdistribution/CCSDSDistributor.cpp @@ -1,5 +1,6 @@ +#include "CCSDSDistributor.h" + #include "../serviceinterface/ServiceInterfaceStream.h" -#include "../tcdistribution/CCSDSDistributor.h" #include "../tmtcpacket/SpacePacketBase.h" CCSDSDistributor::CCSDSDistributor(uint16_t setDefaultApid, @@ -19,7 +20,7 @@ TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() { &packet, &size ); if(result != HasReturnvaluesIF::RETURN_OK) { sif::error << "CCSDSDistributor::selectDestination: Getting data from" - "store failed!" << std::endl; + " store failed!" << std::endl; } SpacePacketBase currentPacket(packet); @@ -42,9 +43,9 @@ MessageQueueId_t CCSDSDistributor::getRequestQueue() { ReturnValue_t CCSDSDistributor::registerApplication( AcceptsTelecommandsIF* application) { ReturnValue_t returnValue = RETURN_OK; - bool errorCode = true; - errorCode = this->queueMap.insert( std::pair( application->getIdentifier(), application->getRequestQueue() ) ).second; - if( errorCode == false ) { + auto insertPair = this->queueMap.emplace(application->getIdentifier(), + application->getRequestQueue()); + if(not insertPair.second) { returnValue = RETURN_FAILED; } return returnValue; @@ -53,9 +54,8 @@ ReturnValue_t CCSDSDistributor::registerApplication( ReturnValue_t CCSDSDistributor::registerApplication(uint16_t apid, MessageQueueId_t id) { ReturnValue_t returnValue = RETURN_OK; - bool errorCode = true; - errorCode = this->queueMap.insert( std::pair( apid, id ) ).second; - if( errorCode == false ) { + auto insertPair = this->queueMap.emplace(apid, id); + if(not insertPair.second) { returnValue = RETURN_FAILED; } return returnValue; @@ -69,7 +69,11 @@ uint16_t CCSDSDistributor::getIdentifier() { ReturnValue_t CCSDSDistributor::initialize() { ReturnValue_t status = this->TcDistributor::initialize(); this->tcStore = objectManager->get( objects::TC_STORE ); - if (this->tcStore == NULL) status = RETURN_FAILED; + if (this->tcStore == nullptr) { + sif::error << "CCSDSDistributor::initialize: Could not initialize" + " TC store!" << std::endl; + status = RETURN_FAILED; + } return status; } diff --git a/tcdistribution/CCSDSDistributor.h b/tcdistribution/CCSDSDistributor.h index 6abd952b..e8d54c9c 100644 --- a/tcdistribution/CCSDSDistributor.h +++ b/tcdistribution/CCSDSDistributor.h @@ -38,7 +38,7 @@ public: MessageQueueId_t id) override; ReturnValue_t registerApplication( AcceptsTelecommandsIF* application) override; - uint16_t getIdentifier(); + uint16_t getIdentifier() override; ReturnValue_t initialize() override; protected: @@ -50,6 +50,12 @@ protected: * @return Iterator to map entry of found APID or iterator to default APID. */ TcMqMapIter selectDestination() override; + /** + * The callback here handles the generation of acceptance + * success/failure messages. + */ + ReturnValue_t callbackAfterSending( ReturnValue_t queueStatus ) override; + /** * The default APID, where packets with unknown APID are sent to. */ @@ -59,11 +65,7 @@ protected: * pure Space Packets and there exists no SpacePacketStored class. */ StorageManagerIF* tcStore = nullptr; - /** - * The callback here handles the generation of acceptance - * success/failure messages. - */ - ReturnValue_t callbackAfterSending( ReturnValue_t queueStatus ); + }; #endif /* FRAMEWORK_TCDISTRIBUTION_CCSDSDISTRIBUTOR_H_ */ diff --git a/tcdistribution/CCSDSDistributorIF.h b/tcdistribution/CCSDSDistributorIF.h index be3c2811..6334a35a 100644 --- a/tcdistribution/CCSDSDistributorIF.h +++ b/tcdistribution/CCSDSDistributorIF.h @@ -1,34 +1,38 @@ -#ifndef CCSDSDISTRIBUTORIF_H_ -#define CCSDSDISTRIBUTORIF_H_ +#ifndef FSFW_TCDISTRIBUTION_CCSDSDISTRIBUTORIF_H_ +#define FSFW_TCDISTRIBUTION_CCSDSDISTRIBUTORIF_H_ #include "../tmtcservices/AcceptsTelecommandsIF.h" #include "../ipc/MessageQueueSenderIF.h" /** * This is the Interface to a CCSDS Distributor. - * On a CCSDS Distributor, Applications (in terms of CCSDS) may register themselves, - * either by passing a pointer to themselves (and implementing the CCSDSApplicationIF, - * or by explicitly passing an APID and a MessageQueueId to route the TC's to. - * \ingroup tc_distribution + * On a CCSDS Distributor, Applications (in terms of CCSDS) may register + * themselves, either by passing a pointer to themselves (and implementing the + * CCSDSApplicationIF), or by explicitly passing an APID and a MessageQueueId + * to route the TC's to. + * @ingroup tc_distribution */ class CCSDSDistributorIF { public: /** - * With this call, a class implementing the CCSDSApplicationIF can register at the - * distributor. + * With this call, a class implementing the CCSDSApplicationIF can register + * at the distributor. * @param application A pointer to the Application to register. - * @return - \c RETURN_OK on success, - * - \c RETURN_FAILED on failure. + * @return - @c RETURN_OK on success, + * - @c RETURN_FAILED on failure. */ - virtual ReturnValue_t registerApplication( AcceptsTelecommandsIF* application ) = 0; + virtual ReturnValue_t registerApplication( + AcceptsTelecommandsIF* application) = 0; /** * With this call, other Applications can register to the CCSDS distributor. * This is done by passing an APID and a MessageQueueId to the method. * @param apid The APID to register. - * @param id The MessageQueueId of the message queue to send the TC Packets to. - * @return - \c RETURN_OK on success, - * - \c RETURN_FAILED on failure. + * @param id The MessageQueueId of the message queue to send the + * TC Packets to. + * @return - @c RETURN_OK on success, + * - @c RETURN_FAILED on failure. */ - virtual ReturnValue_t registerApplication( uint16_t apid, MessageQueueId_t id ) = 0; + virtual ReturnValue_t registerApplication( uint16_t apid, + MessageQueueId_t id) = 0; /** * The empty virtual destructor. */ @@ -37,4 +41,4 @@ public: }; -#endif /* CCSDSDISTRIBUTORIF_H_ */ +#endif /* FSFW_TCDISTRIBUTION_CCSDSDISTRIBUTORIF_H_ */ diff --git a/tcdistribution/PUSDistributor.cpp b/tcdistribution/PUSDistributor.cpp index 0c710ef2..3baef7d1 100644 --- a/tcdistribution/PUSDistributor.cpp +++ b/tcdistribution/PUSDistributor.cpp @@ -1,57 +1,66 @@ +#include "CCSDSDistributorIF.h" +#include "PUSDistributor.h" + #include "../serviceinterface/ServiceInterfaceStream.h" -#include "../tcdistribution/CCSDSDistributorIF.h" -#include "../tcdistribution/PUSDistributor.h" #include "../tmtcpacket/pus/TcPacketStored.h" #include "../tmtcservices/PusVerificationReport.h" PUSDistributor::PUSDistributor(uint16_t setApid, object_id_t setObjectId, object_id_t setPacketSource) : TcDistributor(setObjectId), checker(setApid), verifyChannel(), - currentPacket(), tcStatus(RETURN_FAILED), - packetSource(setPacketSource) {} + tcStatus(RETURN_FAILED), packetSource(setPacketSource) {} PUSDistributor::~PUSDistributor() {} -TcDistributor::TcMqMapIter PUSDistributor::selectDestination() { - TcMqMapIter queueMapIt = this->queueMap.end(); - this->currentPacket.setStoreAddress(this->currentMessage.getStorageId()); - if (currentPacket.getWholeData() != NULL) { - tcStatus = checker.checkPacket(¤tPacket); -// sif::debug << "PUSDistributor::handlePacket: packetCheck returned with " -// << (int)tcStatus << std::endl; - uint32_t queue_id = currentPacket.getService(); - queueMapIt = this->queueMap.find(queue_id); - } else { - tcStatus = PACKET_LOST; - } - if (queueMapIt == this->queueMap.end()) { - tcStatus = DESTINATION_NOT_FOUND; - } +PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() { + // sif:: debug << "PUSDistributor::handlePacket received: " + // << this->current_packet_id.store_index << ", " + // << this->current_packet_id.packet_index << std::endl; + TcMqMapIter queueMapIt = this->queueMap.end(); + this->currentPacket->setStoreAddress(this->currentMessage.getStorageId()); + if (currentPacket->getWholeData() != NULL) { + tcStatus = checker.checkPacket(currentPacket); +#ifdef DEBUG + if(tcStatus != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "PUSDistributor::handlePacket: Packet format " + << "invalid, code "<< static_cast(tcStatus) + << std::endl; + } +#endif + uint32_t queue_id = currentPacket->getService(); + queueMapIt = this->queueMap.find(queue_id); + } + else { + tcStatus = PACKET_LOST; + } - if (tcStatus != RETURN_OK) { - sif::debug << "PUSDistributor::handlePacket: Error with " << tcStatus - << ", 0x"<< std::hex << tcStatus << std::dec << std::endl; - return this->queueMap.end(); - } else { - return queueMapIt; - } + if (queueMapIt == this->queueMap.end()) { + tcStatus = DESTINATION_NOT_FOUND; +#ifdef DEBUG + sif::debug << "PUSDistributor::handlePacket: Destination not found, " + << "code "<< static_cast(tcStatus) << std::endl; +#endif + } + + if (tcStatus != RETURN_OK) { + return this->queueMap.end(); + } + else { + return queueMapIt; + } } -//uint16_t PUSDistributor::createDestination( uint8_t service_id, uint8_t subservice_id ) { -// return ( service_id << 8 ) + subservice_id; -//} ReturnValue_t PUSDistributor::registerService(AcceptsTelecommandsIF* service) { uint16_t serviceId = service->getIdentifier(); - //info << "Service ID: " << (int)serviceId << std::endl; + // sif::info << "Service ID: " << (int)serviceId << std::endl; MessageQueueId_t queue = service->getRequestQueue(); auto returnPair = queueMap.emplace(serviceId, queue); if (not returnPair.second) { - //TODO Return Code sif::error << "PUSDistributor::registerService: Service ID already" " exists in map." << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; + return SERVICE_ID_ALREADY_EXISTS; } return HasReturnvaluesIF::RETURN_OK; } @@ -66,13 +75,14 @@ ReturnValue_t PUSDistributor::callbackAfterSending(ReturnValue_t queueStatus) { } if (tcStatus != RETURN_OK) { this->verifyChannel.sendFailureReport(TC_VERIFY::ACCEPTANCE_FAILURE, - ¤tPacket, tcStatus); - //A failed packet is deleted immediately after reporting, otherwise it will block memory. - currentPacket.deletePacket(); + currentPacket, tcStatus); + // A failed packet is deleted immediately after reporting, + // otherwise it will block memory. + currentPacket->deletePacket(); return RETURN_FAILED; } else { this->verifyChannel.sendSuccessReport(TC_VERIFY::ACCEPTANCE_SUCCESS, - ¤tPacket); + currentPacket); return RETURN_OK; } } @@ -84,9 +94,15 @@ uint16_t PUSDistributor::getIdentifier() { ReturnValue_t PUSDistributor::initialize() { CCSDSDistributorIF* ccsdsDistributor = objectManager->get(packetSource); - if (ccsdsDistributor == NULL) { - return RETURN_FAILED; - } else { + if (ccsdsDistributor == nullptr) { + sif::error << "PUSDistributor::initialize: Packet source invalid." + << " Make sure it exists and implements CCSDSDistributorIF!" + << std::endl; + return RETURN_FAILED; + } + else { return ccsdsDistributor->registerApplication(this); } + + currentPacket = new TcPacketStored(); } diff --git a/tcdistribution/PUSDistributor.h b/tcdistribution/PUSDistributor.h index b8cff1f4..be3804ef 100644 --- a/tcdistribution/PUSDistributor.h +++ b/tcdistribution/PUSDistributor.h @@ -1,10 +1,11 @@ -#ifndef FRAMEWORK_TCDISTRIBUTION_PUSDISTRIBUTOR_H_ -#define FRAMEWORK_TCDISTRIBUTION_PUSDISTRIBUTOR_H_ +#ifndef FSFW_TCDISTRIBUTION_PUSDISTRIBUTOR_H_ +#define FSFW_TCDISTRIBUTION_PUSDISTRIBUTOR_H_ + +#include "PUSDistributorIF.h" +#include "TcDistributor.h" +#include "TcPacketCheck.h" #include "../returnvalues/HasReturnvaluesIF.h" -#include "../tcdistribution/PUSDistributorIF.h" -#include "../tcdistribution/TcDistributor.h" -#include "../tcdistribution/TcPacketCheck.h" #include "../tmtcservices/AcceptsTelecommandsIF.h" #include "../tmtcservices/VerificationReporter.h" @@ -50,7 +51,7 @@ protected: /** * The currently handled packet is stored here. */ - TcPacketStored currentPacket; + TcPacketStored* currentPacket = nullptr; /** * With this variable, the current check status is stored to generate * acceptance messages later. @@ -58,6 +59,7 @@ protected: ReturnValue_t tcStatus; const object_id_t packetSource; + /** * This method reads the packet service, checks if such a service is * registered and forwards the packet to the destination. @@ -71,7 +73,7 @@ protected: * The callback here handles the generation of acceptance * success/failure messages. */ - ReturnValue_t callbackAfterSending(ReturnValue_t queueStatus); + ReturnValue_t callbackAfterSending(ReturnValue_t queueStatus) override; }; -#endif /* FRAMEWORK_TCDISTRIBUTION_PUSDISTRIBUTOR_H_ */ +#endif /* FSFW_TCDISTRIBUTION_PUSDISTRIBUTOR_H_ */ diff --git a/tcdistribution/PUSDistributorIF.h b/tcdistribution/PUSDistributorIF.h index 5e27b35c..0125c08f 100644 --- a/tcdistribution/PUSDistributorIF.h +++ b/tcdistribution/PUSDistributorIF.h @@ -1,11 +1,12 @@ -#ifndef PUSDISTRIBUTORIF_H_ -#define PUSDISTRIBUTORIF_H_ +#ifndef FSFW_TCDISTRIBUTION_PUSDISTRIBUTORIF_H_ +#define FSFW_TCDISTRIBUTION_PUSDISTRIBUTORIF_H_ #include "../tmtcservices/AcceptsTelecommandsIF.h" #include "../ipc/MessageQueueSenderIF.h" + /** * This interface allows PUS Services to register themselves at a PUS Distributor. - * \ingroup tc_distribution + * @ingroup tc_distribution */ class PUSDistributorIF { public: @@ -17,10 +18,10 @@ public: /** * With this method, Services can register themselves at the PUS Distributor. * @param service A pointer to the registering Service. - * @return - \c RETURN_OK on success, - * - \c RETURN_FAILED on failure. + * @return - @c RETURN_OK on success, + * - @c RETURN_FAILED on failure. */ virtual ReturnValue_t registerService( AcceptsTelecommandsIF* service ) = 0; }; -#endif /* PUSDISTRIBUTORIF_H_ */ +#endif /* FSFW_TCDISTRIBUTION_PUSDISTRIBUTORIF_H_ */ diff --git a/tcdistribution/TcDistributor.cpp b/tcdistribution/TcDistributor.cpp index b0354558..06e1817f 100644 --- a/tcdistribution/TcDistributor.cpp +++ b/tcdistribution/TcDistributor.cpp @@ -1,12 +1,13 @@ +#include "TcDistributor.h" + #include "../serviceinterface/ServiceInterfaceStream.h" -#include "../serviceinterface/ServiceInterfaceStream.h" -#include "../tcdistribution/TcDistributor.h" #include "../tmtcservices/TmTcMessage.h" #include "../ipc/QueueFactory.h" -TcDistributor::TcDistributor(object_id_t set_object_id) : - SystemObject(set_object_id), tcQueue(NULL) { - tcQueue = QueueFactory::instance()->createMessageQueue(DISTRIBUTER_MAX_PACKETS); +TcDistributor::TcDistributor(object_id_t objectId) : + SystemObject(objectId) { + tcQueue = QueueFactory::instance()-> + createMessageQueue(DISTRIBUTER_MAX_PACKETS); } TcDistributor::~TcDistributor() { @@ -38,14 +39,14 @@ ReturnValue_t TcDistributor::handlePacket() { } void TcDistributor::print() { - sif::debug << "Distributor content is: " << std::endl << "ID\t| message queue id" - << std::endl; - for (TcMqMapIter it = this->queueMap.begin(); it != this->queueMap.end(); - it++) { - sif::debug << it->first << "\t| 0x" << std::hex << it->second << std::dec - << std::endl; + sif::debug << "Distributor content is: " << std::endl + << "ID\t| Message Queue ID" << std::endl; + sif::debug << std::setfill('0') << std::setw(8) << std::hex; + for (const auto& queueMapIter: queueMap) { + sif::debug << queueMapIter.first << "\t| 0x" << queueMapIter.second + << std::endl; } - sif::debug << std::dec; + sif::debug << std::setfill(' ') << std::dec; } diff --git a/tcdistribution/TcDistributor.h b/tcdistribution/TcDistributor.h index 95b7d25b..5d0ca45d 100644 --- a/tcdistribution/TcDistributor.h +++ b/tcdistribution/TcDistributor.h @@ -1,5 +1,5 @@ -#ifndef FRAMEWORK_TMTCSERVICES_TCDISTRIBUTOR_H_ -#define FRAMEWORK_TMTCSERVICES_TCDISTRIBUTOR_H_ +#ifndef FSFW_TMTCSERVICES_TCDISTRIBUTOR_H_ +#define FSFW_TMTCSERVICES_TCDISTRIBUTOR_H_ #include "../objectmanager/ObjectManagerIF.h" #include "../objectmanager/SystemObject.h" @@ -34,9 +34,10 @@ public: using TcMessageQueueMap = std::map; using TcMqMapIter = std::map::iterator; - static const uint8_t INTERFACE_ID = CLASS_ID::PACKET_DISTRIBUTION; - static const ReturnValue_t PACKET_LOST = MAKE_RETURN_CODE( 1 ); - static const ReturnValue_t DESTINATION_NOT_FOUND = MAKE_RETURN_CODE( 2 ); + static constexpr uint8_t INTERFACE_ID = CLASS_ID::PACKET_DISTRIBUTION; + static constexpr ReturnValue_t PACKET_LOST = MAKE_RETURN_CODE( 1 ); + static constexpr ReturnValue_t DESTINATION_NOT_FOUND = MAKE_RETURN_CODE( 2 ); + static constexpr ReturnValue_t SERVICE_ID_ALREADY_EXISTS = MAKE_RETURN_CODE(3); /** * Within the default constructor, the SystemObject id is set and the * message queue is initialized. @@ -44,7 +45,7 @@ public: * @param set_object_id This id is assigned to the distributor * implementation. */ - TcDistributor( object_id_t set_object_id ); + TcDistributor(object_id_t objectId); /** * The destructor is empty, the message queues are not in the vicinity of * this class. @@ -69,7 +70,7 @@ protected: * This is the receiving queue for incoming Telecommands. * The child classes must make its queue id public. */ - MessageQueueIF* tcQueue; + MessageQueueIF* tcQueue = nullptr; /** * The last received incoming packet information is stored in this * member. @@ -94,18 +95,19 @@ protected: /** * The handlePacket method calls the child class's selectDestination method * and forwards the packet to its destination, if found. - * @return The message queue return value or \c RETURN_FAILED, in case no + * @return The message queue return value or @c RETURN_FAILED, in case no * destination was found. */ ReturnValue_t handlePacket(); /** - * This method gives the child class a chance to perform some kind of operation - * after the parent tried to forward the message. + * This method gives the child class a chance to perform some kind of + * operation after the parent tried to forward the message. * A typically application would be sending success/failure messages. - * The default implementation just returns \c RETURN_OK. - * @param queueStatus The status of the message queue after an attempt to send the TC. - * @return - \c RETURN_OK on success - * - \c RETURN_FAILED on failure + * The default implementation just returns @c RETURN_OK. + * @param queueStatus The status of the message queue after an attempt + * to send the TC. + * @return - @c RETURN_OK on success + * - @c RETURN_FAILED on failure */ virtual ReturnValue_t callbackAfterSending( ReturnValue_t queueStatus ); @@ -113,8 +115,8 @@ private: /** * This constant sets the maximum number of packets distributed per call. */ - static const uint8_t DISTRIBUTER_MAX_PACKETS = 128; + static constexpr uint8_t DISTRIBUTER_MAX_PACKETS = 128; }; -#endif /* TCDISTRIBUTOR_H_ */ +#endif /* FSFW_TMTCSERVICES_TCDISTRIBUTOR_H_ */ diff --git a/tcdistribution/TcPacketCheck.cpp b/tcdistribution/TcPacketCheck.cpp index 4701ce23..38ed04aa 100644 --- a/tcdistribution/TcPacketCheck.cpp +++ b/tcdistribution/TcPacketCheck.cpp @@ -1,31 +1,33 @@ +#include "TcPacketCheck.h" + #include "../globalfunctions/CRC.h" #include "../serviceinterface/ServiceInterfaceStream.h" #include "../storagemanager/StorageManagerIF.h" -#include "../tcdistribution/TcPacketCheck.h" #include "../tmtcservices/VerificationCodes.h" -TcPacketCheck::TcPacketCheck( uint16_t set_apid ) : apid(set_apid) { +TcPacketCheck::TcPacketCheck( uint16_t setApid ) : apid(setApid) { } -ReturnValue_t TcPacketCheck::checkPacket( TcPacketStored* current_packet ) { - uint16_t calculated_crc = CRC::crc16ccitt( current_packet->getWholeData(), current_packet->getFullSize() ); +ReturnValue_t TcPacketCheck::checkPacket( TcPacketStored* currentPacket ) { + uint16_t calculated_crc = CRC::crc16ccitt( currentPacket->getWholeData(), + currentPacket->getFullSize() ); if ( calculated_crc != 0 ) { return INCORRECT_CHECKSUM; } - bool condition = !(current_packet->hasSecondaryHeader()) || - current_packet->getPacketVersionNumber() != CCSDS_VERSION_NUMBER || - !(current_packet->isTelecommand()); + bool condition = (not currentPacket->hasSecondaryHeader()) or + (currentPacket->getPacketVersionNumber() != CCSDS_VERSION_NUMBER) or + (not currentPacket->isTelecommand()); if ( condition ) { return INCORRECT_PRIMARY_HEADER; } - if ( current_packet->getAPID() != this->apid ) + if ( currentPacket->getAPID() != this->apid ) return ILLEGAL_APID; - if ( !current_packet->isSizeCorrect() ) { + if ( not currentPacket->isSizeCorrect() ) { return INCOMPLETE_PACKET; } - condition = (current_packet->getSecondaryHeaderFlag() != CCSDS_SECONDARY_HEADER_FLAG) || - (current_packet->getPusVersionNumber() != PUS_VERSION_NUMBER); + condition = (currentPacket->getSecondaryHeaderFlag() != CCSDS_SECONDARY_HEADER_FLAG) || + (currentPacket->getPusVersionNumber() != PUS_VERSION_NUMBER); if ( condition ) { return INCORRECT_SECONDARY_HEADER; } diff --git a/tcdistribution/TcPacketCheck.h b/tcdistribution/TcPacketCheck.h index 4ba269f5..703bb1bb 100644 --- a/tcdistribution/TcPacketCheck.h +++ b/tcdistribution/TcPacketCheck.h @@ -1,28 +1,29 @@ -#ifndef TCPACKETCHECK_H_ -#define TCPACKETCHECK_H_ +#ifndef FSFW_TCDISTRIBUTION_TCPACKETCHECK_H_ +#define FSFW_TCDISTRIBUTION_TCPACKETCHECK_H_ #include "../returnvalues/HasReturnvaluesIF.h" #include "../tmtcpacket/pus/TcPacketStored.h" #include "../tmtcservices/PusVerificationReport.h" + /** * This class performs a formal packet check for incoming PUS Telecommand Packets. * Currently, it only checks if the APID and CRC are correct. - * \ingroup tc_distribution + * @ingroup tc_distribution */ class TcPacketCheck : public HasReturnvaluesIF { protected: /** * Describes the version number a packet must have to pass. */ - static const uint8_t CCSDS_VERSION_NUMBER = 0; + static constexpr uint8_t CCSDS_VERSION_NUMBER = 0; /** * Describes the secondary header a packet must have to pass. */ - static const uint8_t CCSDS_SECONDARY_HEADER_FLAG = 0; + static constexpr uint8_t CCSDS_SECONDARY_HEADER_FLAG = 0; /** * Describes the TC Packet PUS Version Number a packet must have to pass. */ - static const uint8_t PUS_VERSION_NUMBER = 1; + static constexpr uint8_t PUS_VERSION_NUMBER = 1; /** * The packet id each correct packet should have. * It is composed of the APID and some static fields. @@ -41,19 +42,19 @@ public: * The constructor only sets the APID attribute. * @param set_apid The APID to set. */ - TcPacketCheck( uint16_t set_apid ); + TcPacketCheck( uint16_t setApid ); /** * This is the actual method to formally check a certain Telecommand Packet. * The packet's Application Data can not be checked here. * @param current_packet The packt to check - * @return - \c RETURN_OK on success. - * - \c INCORRECT_CHECKSUM if checksum is invalid. - * - \c ILLEGAL_APID if APID does not match. + * @return - @c RETURN_OK on success. + * - @c INCORRECT_CHECKSUM if checksum is invalid. + * - @c ILLEGAL_APID if APID does not match. */ - ReturnValue_t checkPacket( TcPacketStored* current_packet ); + ReturnValue_t checkPacket( TcPacketStored* currentPacket ); uint16_t getApid() const; }; -#endif /* TCPACKETCHECK_H_ */ +#endif /* FSFW_TCDISTRIBUTION_TCPACKETCHECK_H_ */ From 26454356f8958bf077e8756471869dc0bb8e0af8 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 1 Oct 2020 13:57:34 +0200 Subject: [PATCH 153/192] tpp extraction --- container/FixedOrderedMultimap.h | 56 +++--------------------- container/FixedOrderedMultimap.tpp | 69 ++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 49 deletions(-) diff --git a/container/FixedOrderedMultimap.h b/container/FixedOrderedMultimap.h index 99825dc4..cb8ab10f 100644 --- a/container/FixedOrderedMultimap.h +++ b/container/FixedOrderedMultimap.h @@ -1,9 +1,8 @@ #ifndef FSFW_CONTAINER_FIXEDORDEREDMULTIMAP_H_ #define FSFW_CONTAINER_FIXEDORDEREDMULTIMAP_H_ -#include "../container/ArrayList.h" +#include "ArrayList.h" #include -#include /** * @brief Map implementation which allows entries with identical keys @@ -72,56 +71,15 @@ public: */ ReturnValue_t exists(key_t key) const; - ReturnValue_t erase(Iterator *iter) { - uint32_t i; - if ((i = findFirstIndex((*iter).value->first)) >= _size) { - return KEY_DOES_NOT_EXIST; - } - removeFromPosition(i); - if (*iter != begin()) { - (*iter)--; - } else { - *iter = begin(); - } - return HasReturnvaluesIF::RETURN_OK; - } + ReturnValue_t erase(Iterator *iter); + ReturnValue_t erase(key_t key); - ReturnValue_t erase(key_t key) { - uint32_t i; - if ((i = findFirstIndex(key)) >= _size) { - return KEY_DOES_NOT_EXIST; - } - do { - removeFromPosition(i); - i = findFirstIndex(key, i); - } while (i < _size); - return HasReturnvaluesIF::RETURN_OK; - } + Iterator find(key_t key) const; + ReturnValue_t find(key_t key, T **value) const; - Iterator find(key_t key) const { - ReturnValue_t result = exists(key); - if (result != HasReturnvaluesIF::RETURN_OK) { - return end(); - } - return Iterator(&theMap[findFirstIndex(key)]); - } + void clear(); - ReturnValue_t find(key_t key, T **value) const { - ReturnValue_t result = exists(key); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - *value = &theMap[findFirstIndex(key)].second; - return HasReturnvaluesIF::RETURN_OK; - } - - void clear() { - _size = 0; - } - - size_t maxSize() const { - return theMap.maxSize(); - } + size_t maxSize() const; private: typedef KEY_COMPARE compare; diff --git a/container/FixedOrderedMultimap.tpp b/container/FixedOrderedMultimap.tpp index 5b7b9ead..bc76c594 100644 --- a/container/FixedOrderedMultimap.tpp +++ b/container/FixedOrderedMultimap.tpp @@ -71,4 +71,73 @@ inline ReturnValue_t FixedOrderedMultimap::exists( return result; } +template +inline ReturnValue_t FixedOrderedMultimap::erase( + Iterator *iter) +{ + uint32_t i; + if ((i = findFirstIndex((*iter).value->first)) >= _size) { + return KEY_DOES_NOT_EXIST; + } + removeFromPosition(i); + if (*iter != begin()) { + (*iter)--; + } else { + *iter = begin(); + } + return HasReturnvaluesIF::RETURN_OK; +} + +template +inline ReturnValue_t FixedOrderedMultimap::erase( + key_t key) +{ + uint32_t i; + if ((i = findFirstIndex(key)) >= _size) { + return KEY_DOES_NOT_EXIST; + } + do { + removeFromPosition(i); + i = findFirstIndex(key, i); + } while (i < _size); + return HasReturnvaluesIF::RETURN_OK; +} + +template +inline ReturnValue_t FixedOrderedMultimap::find( + key_t key, T **value) const +{ + ReturnValue_t result = exists(key); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + *value = &theMap[findFirstIndex(key)].second; + return HasReturnvaluesIF::RETURN_OK; +} + +template +inline typename FixedOrderedMultimap::Iterator +FixedOrderedMultimap::find( + key_t key) const +{ + ReturnValue_t result = exists(key); + if (result != HasReturnvaluesIF::RETURN_OK) { + return end(); + } + return Iterator(&theMap[findFirstIndex(key)]); +} + +template +inline void FixedOrderedMultimap::clear() +{ + _size = 0; +} + +template +inline size_t FixedOrderedMultimap::maxSize() const +{ + return theMap.maxSize(); +} + + #endif /* FRAMEWORK_CONTAINER_FIXEDORDEREDMULTIMAP_TPP_ */ From 0714dc6e06d7bbd30b12775d1f7f39bac189b216 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 1 Oct 2020 20:31:30 +0200 Subject: [PATCH 154/192] taken over container --- container/FixedOrderedMultimap.h | 250 +++++++++++++++++++---------- container/FixedOrderedMultimap.tpp | 190 +++++++++------------- 2 files changed, 243 insertions(+), 197 deletions(-) diff --git a/container/FixedOrderedMultimap.h b/container/FixedOrderedMultimap.h index cb8ab10f..96bc0073 100644 --- a/container/FixedOrderedMultimap.h +++ b/container/FixedOrderedMultimap.h @@ -5,120 +5,200 @@ #include /** - * @brief Map implementation which allows entries with identical keys + * @brief An associative container which allows multiple entries of the same key. * @details - * Performs no dynamic memory allocation except on initialization. - * Uses an ArrayList as the underlying container and thus has a linear + * Same keys are ordered by KEY_COMPARE function which is std::less > by default. + * + * It uses the ArrayList, so technically this is not a real map, it is an array of pairs + * of type key_t, T. It is ordered by key_t as FixedMap but allows same keys. Thus it has a linear * complexity O(n). As long as the number of entries remains low, this * should not be an issue. * The number of insertion and deletion operation should be minimized - * as those incur exensive memory move operations (the underlying container + * as those incur extensive memory move operations (the underlying container * is not node based). - * @ingroup container + * + * Its of fixed size so no allocations are performed after the construction. + * + * The maximum size is given as first parameter of the constructor. + * + * It provides an iterator to do list iterations. + * + * The type T must have a copy constructor if it is not trivial copy-able. + * + * @warning Iterators return a non-const key_t in the pair. + * @warning A User is not allowed to change the key, otherwise the map is corrupted. + * + * \ingroup container */ template> class FixedOrderedMultimap { public: static const uint8_t INTERFACE_ID = CLASS_ID::FIXED_MULTIMAP; - static const ReturnValue_t KEY_ALREADY_EXISTS = MAKE_RETURN_CODE(0x01); - static const ReturnValue_t MAP_FULL = MAKE_RETURN_CODE(0x02); - static const ReturnValue_t KEY_DOES_NOT_EXIST = MAKE_RETURN_CODE(0x03); + static const ReturnValue_t MAP_FULL = MAKE_RETURN_CODE(0x01); + static const ReturnValue_t KEY_DOES_NOT_EXIST = MAKE_RETURN_CODE(0x02); + + /*** + * Constructor which needs a size_t for the maximum allowed size + * + * Can not be resized during runtime + * + * Allocates memory at construction + * @param maxSize size_t of Maximum allowed size + */ + FixedOrderedMultimap(size_t maxSize):theMap(maxSize), _size(0){ + } + + /*** + * Virtual destructor frees Memory by deleting its member + */ + virtual ~FixedOrderedMultimap() { + } + + /*** + * Special iterator for FixedOrderedMultimap + */ + class Iterator: public ArrayList, size_t>::Iterator { + public: + Iterator() : + ArrayList, size_t>::Iterator() { + } + + Iterator(std::pair *pair) : + ArrayList, size_t>::Iterator(pair) { + } + }; + + /*** + * Returns an iterator pointing to the first element + * @return Iterator pointing to first element + */ + Iterator begin() const { + return Iterator(&theMap[0]); + } /** - * Initializes the ordered multimap with a fixed maximum size. - * @param maxSize + * Returns an iterator pointing to one element past the end + * @return Iterator pointing to one element past the end */ - FixedOrderedMultimap(size_t maxSize); + Iterator end() const { + return Iterator(&theMap[_size]); + } - virtual ~FixedOrderedMultimap() {} + /*** + * Returns the current size of the map (not maximum size!) + * @return Current size + */ + size_t size() const{ + return _size; + } - class Iterator: public ArrayList, uint32_t>::Iterator { - public: - /** Returns an iterator to nullptr */ - Iterator(); - /** Initializes iterator to given entry */ - Iterator(std::pair *pair); - }; + /** + * Clears the map, does not deallocate any memory + */ + void clear(){ + _size = 0; + } - /** Iterator to start of map */ - Iterator begin() const; - /** Iterator to end of map */ - Iterator end() const; - /** Current (variable) size of the map */ - size_t size() const; + /** + * Returns the maximum size of the map + * @return Maximum size of the map + */ + size_t maxSize() const{ + return theMap.maxSize(); + } - /** - * Insert a key/value pair inside the map. An iterator to the stored - * value might be returned optionally. - * @param key - * @param value - * @param storedValue - * @return - */ - ReturnValue_t insert(key_t key, T value, Iterator *storedValue = nullptr); - /** - * Insert a given std::pair - * @param pair - * @return - */ - ReturnValue_t insert(std::pair pair); - /** - * Checks existence of key in map. - * @param key - * @return - * - @c KEY_DOES_NOT_EXIST if key does not exists. - * - @c RETURN_OK otherwise. - */ - ReturnValue_t exists(key_t key) const; + /*** + * Used to insert a key and value separately. + * + * @param[in] key Key of the new element + * @param[in] value Value of the new element + * @param[in/out] (optional) storedValue On success this points to the new value, otherwise a nullptr + * @return RETURN_OK if insert was successful, MAP_FULL if no space is available + */ + ReturnValue_t insert(key_t key, T value, Iterator *storedValue = nullptr); - ReturnValue_t erase(Iterator *iter); - ReturnValue_t erase(key_t key); + /*** + * Used to insert new pair instead of single values + * + * @param pair Pair to be inserted + * @return RETURN_OK if insert was successful, MAP_FULL if no space is available + */ + ReturnValue_t insert(std::pair pair); - Iterator find(key_t key) const; - ReturnValue_t find(key_t key, T **value) const; + /*** + * Can be used to check if a certain key is in the map + * @param key Key to be checked + * @return RETURN_OK if the key exists KEY_DOES_NOT_EXIST otherwise + */ + ReturnValue_t exists(key_t key) const; - void clear(); + /*** + * Used to delete the element in the iterator + * + * The iterator will point to the element before or begin(), + * but never to one element in front of the map. + * + * @warning The iterator needs to be valid and dereferenceable + * @param[in/out] iter Pointer to iterator to the element that needs to be ereased + * @return RETURN_OK if erased, KEY_DOES_NOT_EXIST if the there is no element like this + */ + ReturnValue_t erase(Iterator *iter); - size_t maxSize() const; + /*** + * Used to erase by key + * @param key Key to be erased + * @return RETURN_OK if erased, KEY_DOES_NOT_EXIST if the there is no element like this + */ + ReturnValue_t erase(key_t key); + + /*** + * Find returns the first appearance of the key + * + * If the key does not exist, it points to end() + * + * @param key Key to search for + * @return Iterator pointing to the first entry of key + */ + Iterator find(key_t key) const{ + ReturnValue_t result = exists(key); + if (result != HasReturnvaluesIF::RETURN_OK) { + return end(); + } + return Iterator(&theMap[findFirstIndex(key)]); + }; + + /*** + * Finds first entry of the given key and returns a + * pointer to the value + * + * @param key Key to search for + * @param value Found value + * @return RETURN_OK if it points to the value, + * KEY_DOES_NOT_EXIST if the key is not in the map + */ + ReturnValue_t find(key_t key, T **value) const; + + friend bool operator==(const typename FixedOrderedMultimap::Iterator& lhs, + const typename FixedOrderedMultimap::Iterator& rhs) { + return (lhs.value == rhs.value); + } + + friend bool operator!=(const typename FixedOrderedMultimap::Iterator& lhs, + const typename FixedOrderedMultimap::Iterator& rhs) { + return not (lhs.value == rhs.value); + } private: typedef KEY_COMPARE compare; compare myComp; - ArrayList, uint32_t> theMap; + ArrayList, size_t> theMap; size_t _size; - uint32_t findFirstIndex(key_t key, uint32_t startAt = 0) const { - if (startAt >= _size) { - return startAt + 1; - } - uint32_t i = startAt; - for (i = startAt; i < _size; ++i) { - if (theMap[i].first == key) { - return i; - } - } - return i; - } + size_t findFirstIndex(key_t key, size_t startAt = 0) const; - uint32_t findNicePlace(key_t key) const { - uint32_t i = 0; - for (i = 0; i < _size; ++i) { - if (myComp(key, theMap[i].first)) { - return i; - } - } - return i; - } + size_t findNicePlace(key_t key) const; - void removeFromPosition(uint32_t position) { - if (_size <= position) { - return; - } - std::memmove(static_cast(&theMap[position]), - static_cast(&theMap[position + 1]), - (_size - position - 1) * sizeof(std::pair)); - --_size; - } + void removeFromPosition(size_t position); }; #include "FixedOrderedMultimap.tpp" diff --git a/container/FixedOrderedMultimap.tpp b/container/FixedOrderedMultimap.tpp index bc76c594..4aa85e97 100644 --- a/container/FixedOrderedMultimap.tpp +++ b/container/FixedOrderedMultimap.tpp @@ -1,142 +1,108 @@ #ifndef FRAMEWORK_CONTAINER_FIXEDORDEREDMULTIMAP_TPP_ #define FRAMEWORK_CONTAINER_FIXEDORDEREDMULTIMAP_TPP_ -template -inline FixedOrderedMultimap::Iterator::Iterator(): - ArrayList, uint32_t>::Iterator(){} template -inline FixedOrderedMultimap::Iterator::Iterator( - std::pair *pair): - ArrayList, uint32_t>::Iterator(pair){} - +inline ReturnValue_t FixedOrderedMultimap::insert(key_t key, T value, Iterator *storedValue) { + if (_size == theMap.maxSize()) { + return MAP_FULL; + } + size_t position = findNicePlace(key); + memmove(static_cast(&theMap[position + 1]),static_cast(&theMap[position]), + (_size - position) * sizeof(std::pair)); + theMap[position].first = key; + theMap[position].second = value; + ++_size; + if (storedValue != nullptr) { + *storedValue = Iterator(&theMap[position]); + } + return HasReturnvaluesIF::RETURN_OK; +} template -inline typename FixedOrderedMultimap::Iterator -FixedOrderedMultimap::begin() const { - return Iterator(&theMap[0]); +inline ReturnValue_t FixedOrderedMultimap::insert(std::pair pair) { + return insert(pair.first, pair.second); } template -inline typename FixedOrderedMultimap::Iterator -FixedOrderedMultimap::end() const { - return Iterator(&theMap[_size]); -} - - -template -inline size_t FixedOrderedMultimap::size() const { - return _size; +inline ReturnValue_t FixedOrderedMultimap::exists(key_t key) const { + ReturnValue_t result = KEY_DOES_NOT_EXIST; + if (findFirstIndex(key) < _size) { + result = HasReturnvaluesIF::RETURN_OK; + } + return result; } template -inline FixedOrderedMultimap::FixedOrderedMultimap( - size_t maxSize): theMap(maxSize), _size(0) {} - - -template -inline ReturnValue_t FixedOrderedMultimap::insert( - key_t key, T value, Iterator *storedValue) { - if (_size == theMap.maxSize()) { - return MAP_FULL; - } - uint32_t position = findNicePlace(key); - // Compiler might emitt warning because std::pair is not a POD type (yet..) - // See: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2342.htm#std::pair-example - // Circumvent warning by casting to void* - std::memmove(static_cast(&theMap[position + 1]), - static_cast(&theMap[position]), - (_size - position) * sizeof(std::pair)); - theMap[position].first = key; - theMap[position].second = value; - ++_size; - if (storedValue != nullptr) { - *storedValue = Iterator(&theMap[position]); - } - return HasReturnvaluesIF::RETURN_OK; +inline ReturnValue_t FixedOrderedMultimap::erase(Iterator *iter) { + size_t i; + if ((i = findFirstIndex((*iter).value->first)) >= _size) { + return KEY_DOES_NOT_EXIST; + } + removeFromPosition(i); + if (*iter != begin()) { + (*iter)--; + } else { + *iter = begin(); + } + return HasReturnvaluesIF::RETURN_OK; } template -inline ReturnValue_t FixedOrderedMultimap::insert( - std::pair pair) { - return insert(pair.fist, pair.second); +inline ReturnValue_t FixedOrderedMultimap::erase(key_t key) { + size_t i; + if ((i = findFirstIndex(key)) >= _size) { + return KEY_DOES_NOT_EXIST; + } + do { + removeFromPosition(i); + i = findFirstIndex(key, i); + } while (i < _size); + return HasReturnvaluesIF::RETURN_OK; } template -inline ReturnValue_t FixedOrderedMultimap::exists( - key_t key) const { - ReturnValue_t result = KEY_DOES_NOT_EXIST; - if (findFirstIndex(key) < _size) { - result = HasReturnvaluesIF::RETURN_OK; - } - return result; +inline ReturnValue_t FixedOrderedMultimap::find(key_t key, T **value) const { + ReturnValue_t result = exists(key); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + *value = &theMap[findFirstIndex(key)].second; + return HasReturnvaluesIF::RETURN_OK; } template -inline ReturnValue_t FixedOrderedMultimap::erase( - Iterator *iter) -{ - uint32_t i; - if ((i = findFirstIndex((*iter).value->first)) >= _size) { - return KEY_DOES_NOT_EXIST; - } - removeFromPosition(i); - if (*iter != begin()) { - (*iter)--; - } else { - *iter = begin(); - } - return HasReturnvaluesIF::RETURN_OK; +inline size_t FixedOrderedMultimap::findFirstIndex(key_t key, size_t startAt) const { + if (startAt >= _size) { + return startAt + 1; + } + size_t i = startAt; + for (i = startAt; i < _size; ++i) { + if (theMap[i].first == key) { + return i; + } + } + return i; } template -inline ReturnValue_t FixedOrderedMultimap::erase( - key_t key) -{ - uint32_t i; - if ((i = findFirstIndex(key)) >= _size) { - return KEY_DOES_NOT_EXIST; - } - do { - removeFromPosition(i); - i = findFirstIndex(key, i); - } while (i < _size); - return HasReturnvaluesIF::RETURN_OK; +inline size_t FixedOrderedMultimap::findNicePlace(key_t key) const { + size_t i = 0; + for (i = 0; i < _size; ++i) { + if (myComp(key, theMap[i].first)) { + return i; + } + } + return i; } template -inline ReturnValue_t FixedOrderedMultimap::find( - key_t key, T **value) const -{ - ReturnValue_t result = exists(key); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - *value = &theMap[findFirstIndex(key)].second; - return HasReturnvaluesIF::RETURN_OK; -} - -template -inline typename FixedOrderedMultimap::Iterator -FixedOrderedMultimap::find( - key_t key) const -{ - ReturnValue_t result = exists(key); - if (result != HasReturnvaluesIF::RETURN_OK) { - return end(); - } - return Iterator(&theMap[findFirstIndex(key)]); -} - -template -inline void FixedOrderedMultimap::clear() -{ - _size = 0; -} - -template -inline size_t FixedOrderedMultimap::maxSize() const -{ - return theMap.maxSize(); +inline void FixedOrderedMultimap::removeFromPosition(size_t position) { + if (_size <= position) { + return; + } + memmove(static_cast(&theMap[position]), static_cast(&theMap[position + 1]), + (_size - position - 1) * sizeof(std::pair)); + --_size; } From 1ecca4b3d882fcbc704f21a0ed9f32c0e2d2524e Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 1 Oct 2020 20:33:50 +0200 Subject: [PATCH 155/192] taken over array list --- container/ArrayList.h | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/container/ArrayList.h b/container/ArrayList.h index 16318569..6bd5c1d5 100644 --- a/container/ArrayList.h +++ b/container/ArrayList.h @@ -131,19 +131,6 @@ public: const T *operator->() const { return value; } - - -// //SHOULDDO this should be implemented as non-member -// bool operator==(const typename -// ArrayList::Iterator& other) const { -// return (value == other.value); -// } -// -// //SHOULDDO this should be implemented as non-member -// bool operator!=(const typename -// ArrayList::Iterator& other) const { -// return !(*this == other); -// } }; friend bool operator==(const ArrayList::Iterator& lhs, From 5fbb8f8ef02747e8c95c74f4301b369982a7b2f7 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 1 Oct 2020 20:35:13 +0200 Subject: [PATCH 156/192] taken over fixed array list from master --- container/FixedArrayList.h | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/container/FixedArrayList.h b/container/FixedArrayList.h index da85c623..e9e127cf 100644 --- a/container/FixedArrayList.h +++ b/container/FixedArrayList.h @@ -1,51 +1,32 @@ #ifndef FIXEDARRAYLIST_H_ #define FIXEDARRAYLIST_H_ -#include "../container/ArrayList.h" - +#include "ArrayList.h" +#include /** - * @brief Array List with a fixed maximum size - * @ingroup container + * \ingroup container */ -template +template class FixedArrayList: public ArrayList { + static_assert(MAX_SIZE <= (pow(2,sizeof(count_t)*8)-1), "count_t is not large enough to hold MAX_SIZE"); private: T data[MAX_SIZE]; public: - /** - * (Robin) Maybe we should also implement move assignment and move ctor. - * Or at least delete them. - */ FixedArrayList() : ArrayList(data, MAX_SIZE) { } - // (Robin): We could create a constructor to initialize the fixed array list - // with data and the known size field - // so it can be used for serialization too (with SerialFixedArrrayListAdapter) - // is this feasible? - /** - * Initialize a fixed array list with data and number of data fields. - * Endianness of entries can be swapped optionally. - * @param data_ - * @param count - * @param swapArrayListEndianess - */ - FixedArrayList(T * data_, count_t count): - ArrayList(data, MAX_SIZE) { - memcpy(this->data, data_, count * sizeof(T)); - this->size = count; - } - FixedArrayList(const FixedArrayList& other) : ArrayList(data, MAX_SIZE) { memcpy(this->data, other.data, sizeof(this->data)); this->entries = data; + this->size = other.size; } FixedArrayList& operator=(FixedArrayList other) { memcpy(this->data, other.data, sizeof(this->data)); this->entries = data; + this->size = other.size; return *this; } From f2c07ee9c6268f255eca9f8cbb374f393cf1ef72 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 1 Oct 2020 20:35:56 +0200 Subject: [PATCH 157/192] removed tests --- container/RingBufferTest.cpp.ignore | 79 ------ container/listTest.cpp.ignore | 365 ---------------------------- 2 files changed, 444 deletions(-) delete mode 100644 container/RingBufferTest.cpp.ignore delete mode 100644 container/listTest.cpp.ignore diff --git a/container/RingBufferTest.cpp.ignore b/container/RingBufferTest.cpp.ignore deleted file mode 100644 index d660e29c..00000000 --- a/container/RingBufferTest.cpp.ignore +++ /dev/null @@ -1,79 +0,0 @@ - -#include -#include "SimpleRingBuffer.h" - - -int main() { - using namespace std; - SimpleRingBuffer buffer(64, false); - uint8_t data[8] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'}; - ReturnValue_t result = buffer.writeData(data, 8); - if (result != HasReturnvaluesIF::RETURN_OK) { - cout << "writeData failed." << endl; - } - result = buffer.writeData(data, 8); - if (result != HasReturnvaluesIF::RETURN_OK) { - cout << "writeData failed." << endl; - } - uint8_t buffer2[47] = {0}; - for (uint8_t count = 0; count - -/* - -class Packet: public SinglyLinkedList { -public: - SinglyLinkedList::Element element1; - SinglyLinkedList::Element element2; - - Packet() { - this->start = &element1; - element1.next = &element2; - } -}; - -class Packet2: public SinglyLinkedList { -public: - SinglyLinkedList::Element element1; - SinglyLinkedList::Element, 2>> element2; - SinglyLinkedList::Element element3; - - Packet2() { - this->start = &element1; - element1.next = &element2; - element2.next = &element3; - } -}; - -class Packet3: public SinglyLinkedList { -public: - SinglyLinkedList::TypedElement element1; - SinglyLinkedList::TypedElement element2; - - Packet3() { - this->start = &element1; - element1.next = &element2; - } -}; - -void arrayList() { - puts("** Array List **"); - FixedArrayList list; - FixedArrayList list2; - - list.size = 2; - - list[0] = 0xcafecafe; - - list[1] = 0x12345678; - - uint8_t buffer[100]; - uint8_t *pointer = buffer; - uint32_t size = 0; - uint32_t maxSize = 100; - uint32_t i; - int32_t size2; - - printf("printsize: %i\n", list.getPrintSize()); - - list.print(&pointer, &size, 100, true); - - printf("buffer(%i):", size); - for (i = 0; i < size; ++i) { - printf("%02x", buffer[i]); - } - printf("\n"); - - pointer = buffer; - - size2 = size; - - printf("list2 read: %x\n", list2.read(&pointer, &size2, true)); - - printf("list2(%i):", list2.size); - for (ArrayList::Iterator iter = list2.begin(); - iter != list2.end(); iter++) { - printf("0x%04x ", *iter); - } - printf("\n"); - - HybridIterator hiter(list.begin(),list.end()); - - printf("hybrid1: 0x%04x\n", *(hiter++)); - printf("hybrid2: 0x%04x\n", *hiter); - -} - -void allocatingList() { - puts("** Allocating List **"); - ArrayList myList(3), myList2(2); - myList[0] = 0xab; - myList[1] = 0xcd; - myList.size = 2; - - uint8_t buffer[100]; - uint8_t *pointer = buffer; - uint32_t size = 0; - uint32_t maxSize = 100; - uint32_t i; - int32_t size2; - - myList.print(&pointer, &size, 100, true); - - pointer = buffer; - size2 = size; - - printf("Read %x\n", myList2.read(&pointer, &size2, true)); - - printf("%x,%x\n", myList2[0], myList2[1]); - -} - -void linkedList() { - puts("** Linked List **"); - uint8_t buffer[100]; - uint8_t *pointer = buffer; - uint32_t size = 0; - uint32_t maxSize = 100; - uint32_t i; - int32_t size2; - - Packet myPacket; - myPacket.element1.entry = 0x12345678; - myPacket.element2.entry = 0x9abcdef0; - - pointer = buffer; - size = 0; - ReturnValue_t result = myPacket.print(&pointer, &size, 100, true); - - printf("result %02x\n", result); - - printf("printsize: %i\n", myPacket.getPrintSize()); - - printf("buffer(%i):", size); - for (i = 0; i < size; ++i) { - printf("%02x", buffer[i]); - } - printf("\n"); - - Packet3 myPacket3; - - myPacket3.element1.entry = 0x12345678; - myPacket3.element2.entry = 0xabcdeff; - - SinglyLinkedList::TypedIterator titer(&myPacket3.element1); - - printf("0x%04x\n", *titer); - - HybridIterator hiter(&myPacket3.element1); - - printf("hybrid1: 0x%04x\n", *hiter); - hiter++; - printf("hybrid2: 0x%04x\n", *hiter); -} - -void complex() { - puts("** complex **"); - uint8_t buffer[100]; - uint8_t *pointer = buffer; - uint32_t size = 0; - uint32_t maxSize = 100; - uint32_t i; - int32_t size2 = size; - - Packet myPacket2; - - size2 = size; - pointer = buffer; - - myPacket2.read(&pointer, &size2, true); - - printf("packet: 0x%04x, 0x%04x\n", myPacket2.element1.entry, - myPacket2.element2.entry); - - buffer[0] = 0x12; - buffer[1] = 0x34; - buffer[2] = 0x56; - buffer[3] = 0x78; - buffer[4] = 0x2; - buffer[5] = 0x3; - buffer[6] = 0xab; - buffer[7] = 0xcd; - buffer[8] = 0xef; - buffer[9] = 0x2; - buffer[10] = 0x11; - buffer[11] = 0x22; - buffer[12] = 0xca; - buffer[13] = 0xfe; - buffer[14] = 0x5a; - buffer[15] = 0xfe; - - pointer = buffer; - size2 = 23; - - Packet2 p2; - - ReturnValue_t result = p2.read(&pointer, &size2, true); - printf("result is %02x\n", result); - - printf("%04x; %i: %i: %x %x %x; %i: %x %x;; %04x\n", p2.element1.entry, - p2.element2.entry.size, p2.element2.entry[0].size, - p2.element2.entry[0][0], p2.element2.entry[0][1], - p2.element2.entry[0][2], p2.element2.entry[1].size, - p2.element2.entry[1][0], p2.element2.entry[1][1], - p2.element3.entry); - -} -*/ -struct Test { - uint32_t a; - uint32_t b; -}; - -template -void printMap(FixedMap *map) { - typename FixedMap::Iterator iter; - printf("Map (%i): ", map->getSize()); - for (iter = map->begin(); iter != map->end(); ++iter) { - printf("%x:%08x,%08x ", iter.value->first, (*iter).a, (*iter).b); - } - printf("\n"); -} - -template -void map() { - puts("** Map **"); - typename FixedMap::Iterator iter; - ReturnValue_t result; - FixedMap myMap(5); - - printMap(&myMap); - - Test a; - a.a = 0x01234567; - a.b = 0xabcdef89; - - myMap.insert(1, a); - printMap(&myMap); - - a.a = 0; - - myMap.insert(2, a); - printMap(&myMap); - - printf("2 exists: %x\n", myMap.exists(0x02)); - - printf("ff exists: %x\n", myMap.exists(0xff)); - - a.a = 1; - printf("insert 0x2: %x\n", myMap.insert(2, a)); - - result = myMap.insert(0xff, a); - a.a = 0x44; - result = myMap.insert(0xab, a); - result = myMap.insert(0xa, a); - - printMap(&myMap); - - printf("insert 0x5: %x\n", myMap.insert(5, a)); - - printf("erase 0xfe: %x\n", myMap.erase(0xfe)); - - printf("erase 0x2: %x\n", myMap.erase(0x2)); - - printMap(&myMap); - - printf("erase 0xab: %x\n", myMap.erase(0xab)); - printMap(&myMap); - - printf("insert 0x5: %x\n", myMap.insert(5, a)); - printMap(&myMap); - - iter = myMap.begin(); - ++iter; - ++iter; - ++iter; - - printf("iter: %i: %x,%x\n",iter.value->first, iter->a, iter->b); - - myMap.erase(&iter); - - printf("iter: %i: %x,%x\n",iter.value->first, iter->a, iter->b); - printMap(&myMap); - -} - -/* -void mapPrint() { - puts("** Map Print **"); - FixedMap myMap(5); - Packet2 myPacket; - myPacket.element1.entry = 0x12345678; - - myPacket.element2.entry[0][0] = 0xab; - myPacket.element2.entry[0][1] = 0xcd; - myPacket.element2.entry[0].size = 2; - myPacket.element2.entry.size = 1; - - myPacket.element3.entry = 0xabcdef90; - - myMap.insert(0x1234, myPacket); - - uint8_t buffer[100]; - uint32_t size = 0, i; - uint8_t *pointer = buffer; - - printf("printsize: %i\n", myMap.getPrintSize()); - - SerializeAdapter>::print(&myMap, &pointer, - &size, 100, false); - - printf("buffer(%i):", size); - for (i = 0; i < size; ++i) { - printf("%02x", buffer[i]); - } - printf("\n"); - - int32_t size2 = size; - pointer = buffer; - - FixedMap myMap2(5); - - ReturnValue_t result = SerializeAdapter>::read( - &myMap2, &pointer, &size2, false); - - Packet2 *myPacket2 = myMap2.find(0x1234); - - printf("Map (%i): Packet2: %x, Array (%i): Array (%i): %x, %x; %x\n", - myMap2.getSize(), myPacket2->element1.entry, - myPacket2->element2.entry.size, myPacket2->element2.entry[0].size, - myPacket2->element2.entry[0][0], myPacket2->element2.entry[0][1], - myPacket2->element3.entry); - -} - -void empty() { - puts("** Empty **"); - ArrayList list(0); - printf("%p %p\n", list.front(), list.back()); -} -*/ - -int main(void) { - -// arrayList(); -// linkedList(); -// allocatingList(); -// complex(); - - map(); -// -// mapPrint(); - -// empty(); - - - - return 0; -} From 148bbb4be4ef309ac023631782064140fa8d5966 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 1 Oct 2020 20:36:43 +0200 Subject: [PATCH 158/192] master taken over --- container/FixedMap.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/container/FixedMap.h b/container/FixedMap.h index 1e36b1bc..7a5220fa 100644 --- a/container/FixedMap.h +++ b/container/FixedMap.h @@ -154,22 +154,22 @@ public: } bool empty() { - if(_size == 0) { - return true; - } - else { - return false; - } + if(_size == 0) { + return true; + } + else { + return false; + } } - bool full() { - if(_size >= theMap.maxSize()) { - return true; - } - else { - return false; - } - } + bool full() { + if(_size >= theMap.maxSize()) { + return true; + } + else { + return false; + } + } void clear() { _size = 0; From bf3276cbb2545c1773b1478569703dda9bb402d1 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 1 Oct 2020 20:40:02 +0200 Subject: [PATCH 159/192] taken over master --- container/RingBufferBase.h | 8 ++++---- container/SimpleRingBuffer.cpp | 6 +----- container/SimpleRingBuffer.h | 9 +++++---- container/SinglyLinkedList.h | 2 +- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/container/RingBufferBase.h b/container/RingBufferBase.h index 243a2915..886b9fab 100644 --- a/container/RingBufferBase.h +++ b/container/RingBufferBase.h @@ -1,5 +1,5 @@ -#ifndef FRAMEWORK_CONTAINER_RINGBUFFERBASE_H_ -#define FRAMEWORK_CONTAINER_RINGBUFFERBASE_H_ +#ifndef FSFW_CONTAINER_RINGBUFFERBASE_H_ +#define FSFW_CONTAINER_RINGBUFFERBASE_H_ #include "../returnvalues/HasReturnvaluesIF.h" #include @@ -65,6 +65,7 @@ protected: size_t read[N_READ_PTRS]; const size_t size; const bool overwriteOld; + void incrementWrite(uint32_t amount) { write = ((write + amount - start) % size) + start; } @@ -90,7 +91,6 @@ protected: } } - size_t getRead(uint8_t n = 0) const { return read[n]; } @@ -110,4 +110,4 @@ protected: } }; -#endif /* FRAMEWORK_CONTAINER_RINGBUFFERBASE_H_ */ +#endif /* FSFW_CONTAINER_RINGBUFFERBASE_H_ */ diff --git a/container/SimpleRingBuffer.cpp b/container/SimpleRingBuffer.cpp index d6b6f5af..88c9290e 100644 --- a/container/SimpleRingBuffer.cpp +++ b/container/SimpleRingBuffer.cpp @@ -1,4 +1,4 @@ -#include "../container/SimpleRingBuffer.h" +#include "SimpleRingBuffer.h" #include SimpleRingBuffer::SimpleRingBuffer(const size_t size, bool overwriteOld, @@ -25,12 +25,10 @@ SimpleRingBuffer::SimpleRingBuffer(uint8_t *buffer, const size_t size, } } - SimpleRingBuffer::~SimpleRingBuffer() { delete[] buffer; } - ReturnValue_t SimpleRingBuffer::getFreeElement(uint8_t **writePointer, size_t amount) { if (availableWriteSpace() >= amount or overwriteOld) { @@ -131,5 +129,3 @@ ReturnValue_t SimpleRingBuffer::deleteData(size_t amount, incrementRead(amount, READ_PTR); return HasReturnvaluesIF::RETURN_OK; } - - diff --git a/container/SimpleRingBuffer.h b/container/SimpleRingBuffer.h index dcf2684b..37ad5679 100644 --- a/container/SimpleRingBuffer.h +++ b/container/SimpleRingBuffer.h @@ -1,7 +1,7 @@ -#ifndef FRAMEWORK_CONTAINER_SIMPLERINGBUFFER_H_ -#define FRAMEWORK_CONTAINER_SIMPLERINGBUFFER_H_ +#ifndef FSFW_CONTAINER_SIMPLERINGBUFFER_H_ +#define FSFW_CONTAINER_SIMPLERINGBUFFER_H_ -#include "../container/RingBufferBase.h" +#include "RingBufferBase.h" #include /** @@ -117,6 +117,7 @@ public: */ ReturnValue_t deleteData(size_t amount, bool deleteRemaining = false, size_t* trueAmount = nullptr); + private: static const uint8_t READ_PTR = 0; uint8_t* buffer = nullptr; @@ -124,5 +125,5 @@ private: size_t excessBytes = 0; }; -#endif /* FRAMEWORK_CONTAINER_SIMPLERINGBUFFER_H_ */ +#endif /* FSFW_CONTAINER_SIMPLERINGBUFFER_H_ */ diff --git a/container/SinglyLinkedList.h b/container/SinglyLinkedList.h index 7d5fc4a9..eb6ae276 100644 --- a/container/SinglyLinkedList.h +++ b/container/SinglyLinkedList.h @@ -100,7 +100,7 @@ public: */ ElementIterator back() const { LinkedElement *element = start; - while (element != nullptr) { + while (element->getNext() != nullptr) { element = element->getNext(); } return ElementIterator::Iterator(element); From 0b1b159582b7b3234fdb926f4a1cb4fb875ad69d Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 1 Oct 2020 20:40:45 +0200 Subject: [PATCH 160/192] taken over master --- action/ActionHelper.cpp | 2 +- action/SimpleActionHelper.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/action/ActionHelper.cpp b/action/ActionHelper.cpp index 70c3f0fc..361f7dc3 100644 --- a/action/ActionHelper.cpp +++ b/action/ActionHelper.cpp @@ -1,6 +1,6 @@ -#include #include "ActionHelper.h" #include "HasActionsIF.h" +#include "../ipc/MessageQueueSenderIF.h" #include "../objectmanager/ObjectManagerIF.h" ActionHelper::ActionHelper(HasActionsIF* setOwner, MessageQueueIF* useThisQueue) : diff --git a/action/SimpleActionHelper.cpp b/action/SimpleActionHelper.cpp index 51e3fa1c..d79a3c97 100644 --- a/action/SimpleActionHelper.cpp +++ b/action/SimpleActionHelper.cpp @@ -1,6 +1,5 @@ #include "HasActionsIF.h" #include "SimpleActionHelper.h" - SimpleActionHelper::SimpleActionHelper(HasActionsIF* setOwner, MessageQueueIF* useThisQueue) : ActionHelper(setOwner, useThisQueue), isExecuting(false), lastCommander( From f9e6b9facac4e9f8c4c7a261f4bccf04337c1f07 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 1 Oct 2020 20:42:28 +0200 Subject: [PATCH 161/192] taken over master --- fdir/ConfirmsFailuresIF.h | 1 - fdir/EventCorrelation.cpp | 2 +- fdir/FailureIsolationBase.cpp | 2 +- fdir/FailureIsolationBase.h | 4 ++-- fdir/FaultCounter.cpp | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/fdir/ConfirmsFailuresIF.h b/fdir/ConfirmsFailuresIF.h index 6cb2c47d..14411461 100644 --- a/fdir/ConfirmsFailuresIF.h +++ b/fdir/ConfirmsFailuresIF.h @@ -4,7 +4,6 @@ #include "../returnvalues/HasReturnvaluesIF.h" #include "../ipc/MessageQueueSenderIF.h" -// TODO: Documentation. class ConfirmsFailuresIF { public: static const uint8_t INTERFACE_ID = CLASS_ID::HANDLES_FAILURES_IF; diff --git a/fdir/EventCorrelation.cpp b/fdir/EventCorrelation.cpp index f98d2223..d60fc6ca 100644 --- a/fdir/EventCorrelation.cpp +++ b/fdir/EventCorrelation.cpp @@ -1,4 +1,4 @@ -#include "../fdir/EventCorrelation.h" +#include "EventCorrelation.h" EventCorrelation::EventCorrelation(uint32_t timeout) : eventPending(false) { diff --git a/fdir/FailureIsolationBase.cpp b/fdir/FailureIsolationBase.cpp index ab462a97..f3b34f0f 100644 --- a/fdir/FailureIsolationBase.cpp +++ b/fdir/FailureIsolationBase.cpp @@ -1,5 +1,5 @@ #include "../events/EventManagerIF.h" -#include "../fdir/FailureIsolationBase.h" +#include "FailureIsolationBase.h" #include "../health/HasHealthIF.h" #include "../health/HealthMessage.h" #include "../ipc/QueueFactory.h" diff --git a/fdir/FailureIsolationBase.h b/fdir/FailureIsolationBase.h index f8a307b3..5b2c099a 100644 --- a/fdir/FailureIsolationBase.h +++ b/fdir/FailureIsolationBase.h @@ -2,8 +2,8 @@ #define FRAMEWORK_FDIR_FAILUREISOLATIONBASE_H_ #include "../events/EventMessage.h" -#include "../fdir/ConfirmsFailuresIF.h" -#include "../fdir/FaultCounter.h" +#include "ConfirmsFailuresIF.h" +#include "FaultCounter.h" #include "../health/HealthMessage.h" #include "../parameters/HasParametersIF.h" #include "../returnvalues/HasReturnvaluesIF.h" diff --git a/fdir/FaultCounter.cpp b/fdir/FaultCounter.cpp index b75bd48f..443adb52 100644 --- a/fdir/FaultCounter.cpp +++ b/fdir/FaultCounter.cpp @@ -1,4 +1,4 @@ -#include "../fdir/FaultCounter.h" +#include "FaultCounter.h" FaultCounter::FaultCounter(uint32_t failureThreshold, uint32_t decrementAfterMs, uint8_t setParameterDomain) : From af038d0a2f04c30cd4bfbe6ff3811afdc2740ddc Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 1 Oct 2020 20:44:27 +0200 Subject: [PATCH 162/192] master taken over --- globalfunctions/AsciiConverter.cpp | 2 +- globalfunctions/CRC.cpp | 2 +- globalfunctions/DleEncoder.cpp | 2 +- globalfunctions/DleEncoder.h | 8 ++++---- globalfunctions/arrayprinter.cpp | 4 ++-- globalfunctions/matching/BinaryMatcher.h | 2 +- globalfunctions/matching/DecimalMatcher.h | 2 +- globalfunctions/matching/MatchTree.h | 2 +- globalfunctions/matching/RangeMatcher.h | 2 +- globalfunctions/matching/SerializeableMatcherIF.h | 2 +- globalfunctions/math/QuaternionOperations.cpp | 2 +- 11 files changed, 15 insertions(+), 15 deletions(-) diff --git a/globalfunctions/AsciiConverter.cpp b/globalfunctions/AsciiConverter.cpp index c57125e2..9eb3698f 100644 --- a/globalfunctions/AsciiConverter.cpp +++ b/globalfunctions/AsciiConverter.cpp @@ -1,4 +1,4 @@ -#include "../globalfunctions/AsciiConverter.h" +#include "AsciiConverter.h" #include #include diff --git a/globalfunctions/CRC.cpp b/globalfunctions/CRC.cpp index 1258b698..7bb56806 100644 --- a/globalfunctions/CRC.cpp +++ b/globalfunctions/CRC.cpp @@ -1,4 +1,4 @@ -#include "../globalfunctions/CRC.h" +#include "CRC.h" #include const uint16_t CRC::crc16ccitt_table[256] = { diff --git a/globalfunctions/DleEncoder.cpp b/globalfunctions/DleEncoder.cpp index 6bd402d7..8520389d 100644 --- a/globalfunctions/DleEncoder.cpp +++ b/globalfunctions/DleEncoder.cpp @@ -92,7 +92,7 @@ ReturnValue_t DleEncoder::decode(const uint8_t *sourceStream, else { /* The next byte is a STX, DTX or 0x0D character which * was escaped by a DLE character. The actual byte was - * also encoded by adding + 0x40 to preven having control chars, + * also encoded by adding + 0x40 to prevent having control chars, * in the stream at all, so we convert it back. */ if (nextByte == 0x42 or nextByte == 0x43 or nextByte == 0x4D) { destStream[decodedIndex] = nextByte - 0x40; diff --git a/globalfunctions/DleEncoder.h b/globalfunctions/DleEncoder.h index 3c535d1f..6d073f9a 100644 --- a/globalfunctions/DleEncoder.h +++ b/globalfunctions/DleEncoder.h @@ -15,12 +15,12 @@ * char based transmission systems. * The passed source strean is converted into a encoded stream by adding * a STX marker at the start of the stream and an ETX marker at the end of - * the stream. Any STX, ETX, DLE and CR occurences in the source stream are + * the stream. Any STX, ETX, DLE and CR occurrences in the source stream are * escaped by a DLE character. The encoder also replaces escaped control chars * by another char, so STX, ETX and CR should not appear anywhere in the actual * encoded data stream. * - * When using a strictly char based reception of packets enoded with DLE, + * When using a strictly char based reception of packets encoded with DLE, * STX can be used to notify a reader that actual data will start to arrive * while ETX can be used to notify the reader that the data has ended. */ @@ -38,7 +38,7 @@ public: static constexpr uint8_t STX_CHAR = 0x02; //! End Of Text character. Last character in encoded stream static constexpr uint8_t ETX_CHAR = 0x03; - //! Data Link Escape character. Used to escape STX, ETX and DLE occurences + //! Data Link Escape character. Used to escape STX, ETX and DLE occurrences //! in the source stream. static constexpr uint8_t DLE_CHAR = 0x10; static constexpr uint8_t CARRIAGE_RETURN = 0x0D; @@ -47,7 +47,7 @@ public: * Encodes the give data stream by preceding it with the STX marker * and ending it with an ETX marker. STX, ETX and DLE characters inside * the stream are escaped by DLE characters and also replaced by adding - * 0x40 (which is reverted in the decoing process). + * 0x40 (which is reverted in the decoding process). * @param sourceStream * @param sourceLen * @param destStream diff --git a/globalfunctions/arrayprinter.cpp b/globalfunctions/arrayprinter.cpp index fa89c0dc..b1e888c5 100644 --- a/globalfunctions/arrayprinter.cpp +++ b/globalfunctions/arrayprinter.cpp @@ -1,4 +1,4 @@ -#include "../globalfunctions/arrayprinter.h" +#include "arrayprinter.h" #include "../serviceinterface/ServiceInterfaceStream.h" #include @@ -27,7 +27,7 @@ void arrayprinter::printHex(const uint8_t *data, size_t size, if(i < size - 1){ sif::info << " , "; if(i > 0 and i % maxCharPerLine == 0) { - sif::info << "\r\n" << std::flush; + sif::info << std::endl; } } diff --git a/globalfunctions/matching/BinaryMatcher.h b/globalfunctions/matching/BinaryMatcher.h index 550439ab..4f6db85d 100644 --- a/globalfunctions/matching/BinaryMatcher.h +++ b/globalfunctions/matching/BinaryMatcher.h @@ -1,7 +1,7 @@ #ifndef BINARYMATCHER_H_ #define BINARYMATCHER_H_ -#include "../../globalfunctions/matching/MatcherIF.h" +#include "MatcherIF.h" template class BinaryMatcher: public MatcherIF { diff --git a/globalfunctions/matching/DecimalMatcher.h b/globalfunctions/matching/DecimalMatcher.h index 3c765cd7..53505020 100644 --- a/globalfunctions/matching/DecimalMatcher.h +++ b/globalfunctions/matching/DecimalMatcher.h @@ -1,7 +1,7 @@ #ifndef DECIMALMATCHER_H_ #define DECIMALMATCHER_H_ -#include "../../globalfunctions/matching/MatcherIF.h" +#include "MatcherIF.h" template class DecimalMatcher: public MatcherIF { diff --git a/globalfunctions/matching/MatchTree.h b/globalfunctions/matching/MatchTree.h index 46245c25..755687b2 100644 --- a/globalfunctions/matching/MatchTree.h +++ b/globalfunctions/matching/MatchTree.h @@ -2,7 +2,7 @@ #define FRAMEWORK_GLOBALFUNCTIONS_MATCHING_MATCHTREE_H_ #include "../../container/BinaryTree.h" -#include "../../globalfunctions/matching/SerializeableMatcherIF.h" +#include "SerializeableMatcherIF.h" #include "../../serialize/SerializeAdapter.h" template diff --git a/globalfunctions/matching/RangeMatcher.h b/globalfunctions/matching/RangeMatcher.h index 04c9c3fa..b64b9e30 100644 --- a/globalfunctions/matching/RangeMatcher.h +++ b/globalfunctions/matching/RangeMatcher.h @@ -1,7 +1,7 @@ #ifndef RANGEMATCHER_H_ #define RANGEMATCHER_H_ -#include "../../globalfunctions/matching/SerializeableMatcherIF.h" +#include "SerializeableMatcherIF.h" #include "../../serialize/SerializeAdapter.h" template diff --git a/globalfunctions/matching/SerializeableMatcherIF.h b/globalfunctions/matching/SerializeableMatcherIF.h index f99c6964..067b0251 100644 --- a/globalfunctions/matching/SerializeableMatcherIF.h +++ b/globalfunctions/matching/SerializeableMatcherIF.h @@ -1,7 +1,7 @@ #ifndef FRAMEWORK_GLOBALFUNCTIONS_MATCHING_SERIALIZEABLEMATCHERIF_H_ #define FRAMEWORK_GLOBALFUNCTIONS_MATCHING_SERIALIZEABLEMATCHERIF_H_ -#include "../../globalfunctions/matching/MatcherIF.h" +#include "MatcherIF.h" #include "../../serialize/SerializeIF.h" template diff --git a/globalfunctions/math/QuaternionOperations.cpp b/globalfunctions/math/QuaternionOperations.cpp index c6778de4..c09426da 100644 --- a/globalfunctions/math/QuaternionOperations.cpp +++ b/globalfunctions/math/QuaternionOperations.cpp @@ -1,5 +1,5 @@ #include "QuaternionOperations.h" -#include "../../globalfunctions/math/VectorOperations.h" +#include "VectorOperations.h" #include #include From 55a4c0423db264b8a1d16bd7bc8abb527d9a9597 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 1 Oct 2020 20:45:28 +0200 Subject: [PATCH 163/192] typo --- memory/AcceptsMemoryMessagesIF.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/memory/AcceptsMemoryMessagesIF.h b/memory/AcceptsMemoryMessagesIF.h index cf8aa5ec..7491f47d 100644 --- a/memory/AcceptsMemoryMessagesIF.h +++ b/memory/AcceptsMemoryMessagesIF.h @@ -11,4 +11,4 @@ public: }; -#endif /* AFSFW_MEMORY_ACCEPTSMEMORYMESSAGESIF_H_ */ +#endif /* FSFW_MEMORY_ACCEPTSMEMORYMESSAGESIF_H_ */ From 0c1c61558ba2d2c831260d4a6be51cc9b90a1ee4 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 3 Oct 2020 03:45:29 +0200 Subject: [PATCH 164/192] very important bugfix --- tcdistribution/PUSDistributor.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tcdistribution/PUSDistributor.cpp b/tcdistribution/PUSDistributor.cpp index 3baef7d1..63d1dcde 100644 --- a/tcdistribution/PUSDistributor.cpp +++ b/tcdistribution/PUSDistributor.cpp @@ -17,8 +17,11 @@ PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() { // << this->current_packet_id.store_index << ", " // << this->current_packet_id.packet_index << std::endl; TcMqMapIter queueMapIt = this->queueMap.end(); + if(this->currentPacket == nullptr) { + return queueMapIt; + } this->currentPacket->setStoreAddress(this->currentMessage.getStorageId()); - if (currentPacket->getWholeData() != NULL) { + if (currentPacket->getWholeData() != nullptr) { tcStatus = checker.checkPacket(currentPacket); #ifdef DEBUG if(tcStatus != HasReturnvaluesIF::RETURN_OK) { @@ -94,6 +97,7 @@ uint16_t PUSDistributor::getIdentifier() { ReturnValue_t PUSDistributor::initialize() { CCSDSDistributorIF* ccsdsDistributor = objectManager->get(packetSource); + currentPacket = new TcPacketStored(); if (ccsdsDistributor == nullptr) { sif::error << "PUSDistributor::initialize: Packet source invalid." << " Make sure it exists and implements CCSDSDistributorIF!" @@ -103,6 +107,4 @@ ReturnValue_t PUSDistributor::initialize() { else { return ccsdsDistributor->registerApplication(this); } - - currentPacket = new TcPacketStored(); } From 20c261514b672d3919c036c85702d71fe107723e Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sun, 4 Oct 2020 14:31:06 +0200 Subject: [PATCH 165/192] made message interface more readable (dec instead hex) --- memory/FileSystemMessage.cpp | 18 ++++++----------- memory/FileSystemMessage.h | 38 +++++++++++++++++++++--------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/memory/FileSystemMessage.cpp b/memory/FileSystemMessage.cpp index 416f646c..b01e1fc6 100644 --- a/memory/FileSystemMessage.cpp +++ b/memory/FileSystemMessage.cpp @@ -2,46 +2,40 @@ #include "../objectmanager/ObjectManagerIF.h" -ReturnValue_t FileSystemMessage::setDeleteFileCommand( +void FileSystemMessage::setDeleteFileCommand( CommandMessage* message, store_address_t storageID) { message->setCommand(DELETE_FILE); message->setParameter2(storageID.raw); - return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t FileSystemMessage::setCreateDirectoryCommand( +void FileSystemMessage::setCreateDirectoryCommand( CommandMessage* message, store_address_t storageID) { message->setCommand(CREATE_DIRECTORY); message->setParameter2(storageID.raw); - return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t FileSystemMessage::setDeleteDirectoryCommand( +void FileSystemMessage::setDeleteDirectoryCommand( CommandMessage* message, store_address_t storageID) { message->setCommand(DELETE_DIRECTORY); message->setParameter2(storageID.raw); - return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t FileSystemMessage::setWriteCommand(CommandMessage* message, +void FileSystemMessage::setWriteCommand(CommandMessage* message, store_address_t storageID) { message->setCommand(WRITE); message->setParameter2(storageID.raw); - return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t FileSystemMessage::setReadCommand(CommandMessage* message, +void FileSystemMessage::setReadCommand(CommandMessage* message, store_address_t storageID) { message->setCommand(READ); message->setParameter2(storageID.raw); - return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t FileSystemMessage::setReadReply(CommandMessage* message, +void FileSystemMessage::setReadReply(CommandMessage* message, store_address_t storageID) { message->setCommand(READ_REPLY); message->setParameter2(storageID.raw); - return HasReturnvaluesIF::RETURN_OK; } store_address_t FileSystemMessage::getStoreId(const CommandMessage* message) { diff --git a/memory/FileSystemMessage.h b/memory/FileSystemMessage.h index d3dbd83c..a56abb9c 100644 --- a/memory/FileSystemMessage.h +++ b/memory/FileSystemMessage.h @@ -13,26 +13,32 @@ private: FileSystemMessage(); //A private ctor inhibits instantiation public: static const uint8_t MESSAGE_ID = messagetypes::FILE_SYSTEM_MESSAGE; - static const Command_t CREATE_FILE = MAKE_COMMAND_ID( 0x01 ); - static const Command_t DELETE_FILE = MAKE_COMMAND_ID( 0x02 ); - static const Command_t CREATE_DIRECTORY = MAKE_COMMAND_ID( 0x09 ); - static const Command_t DELETE_DIRECTORY = MAKE_COMMAND_ID( 0x0A ); - static const Command_t WRITE = MAKE_COMMAND_ID( 0x80 ); - static const Command_t READ = MAKE_COMMAND_ID( 0x81 ); - static const Command_t READ_REPLY = MAKE_COMMAND_ID( 0x82 ); + static const Command_t CREATE_FILE = MAKE_COMMAND_ID(1); + static const Command_t DELETE_FILE = MAKE_COMMAND_ID(2); + static const Command_t CREATE_DIRECTORY = MAKE_COMMAND_ID(9); + static const Command_t DELETE_DIRECTORY = MAKE_COMMAND_ID(10); + static const Command_t WRITE = MAKE_COMMAND_ID(128); + static const Command_t READ = MAKE_COMMAND_ID(129); + static const Command_t READ_REPLY = MAKE_COMMAND_ID(130); static const Command_t COMPLETION_SUCCESS = MAKE_COMMAND_ID(5); static const Command_t COMPLETION_FAILED = MAKE_COMMAND_ID(6); - static ReturnValue_t setDeleteFileCommand(CommandMessage* message, store_address_t storageID); - static ReturnValue_t setCreateDirectoryCommand(CommandMessage* message, store_address_t storageID); - static ReturnValue_t setDeleteDirectoryCommand(CommandMessage* message, store_address_t storageID); - static ReturnValue_t setWriteCommand(CommandMessage* message, store_address_t storageID); - static ReturnValue_t setReadCommand(CommandMessage* message, store_address_t storageID); - static ReturnValue_t setReadReply(CommandMessage* message, store_address_t storageID); - static store_address_t getStoreId( const CommandMessage* message ); - static void setSuccessReply(CommandMessage* message); - static void setFailureReply(CommandMessage* message, ReturnValue_t errorCode); + static void setDeleteFileCommand(CommandMessage* message, + store_address_t storeId); + static void setCreateDirectoryCommand(CommandMessage* message, + store_address_t storeId); + static void setDeleteDirectoryCommand(CommandMessage* message, + store_address_t storeId); + static void setWriteCommand(CommandMessage* message, + store_address_t storeId); + static void setReadCommand(CommandMessage* message, + store_address_t storeId); + static void setReadReply(CommandMessage* message, store_address_t storeId); + static void setSuccessReply(CommandMessage* message); + static void setFailureReply(CommandMessage* message, + ReturnValue_t errorCode); + static store_address_t getStoreId(const CommandMessage* message); static ReturnValue_t getFailureReply(const CommandMessage* message); }; From 2b1029916bab936cd7553d8c93f5300abeefe495 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sun, 4 Oct 2020 15:55:39 +0200 Subject: [PATCH 166/192] using deletei nstead --- memory/FileSystemMessage.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/memory/FileSystemMessage.h b/memory/FileSystemMessage.h index a56abb9c..c098d407 100644 --- a/memory/FileSystemMessage.h +++ b/memory/FileSystemMessage.h @@ -9,9 +9,10 @@ * @author Jakob Meier */ class FileSystemMessage { -private: - FileSystemMessage(); //A private ctor inhibits instantiation public: + // Instantiation forbidden + FileSystemMessage() = delete; + static const uint8_t MESSAGE_ID = messagetypes::FILE_SYSTEM_MESSAGE; static const Command_t CREATE_FILE = MAKE_COMMAND_ID(1); static const Command_t DELETE_FILE = MAKE_COMMAND_ID(2); From a8a6d448ecc601fc74cefbc7b80736985b8ca06b Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sun, 4 Oct 2020 23:24:36 +0200 Subject: [PATCH 167/192] added subservices --- memory/FileSystemMessage.cpp | 11 ++++++++-- memory/FileSystemMessage.h | 41 ++++++++++++++++++++++++++++++------ 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/memory/FileSystemMessage.cpp b/memory/FileSystemMessage.cpp index b01e1fc6..b9c426a8 100644 --- a/memory/FileSystemMessage.cpp +++ b/memory/FileSystemMessage.cpp @@ -22,13 +22,13 @@ void FileSystemMessage::setDeleteDirectoryCommand( void FileSystemMessage::setWriteCommand(CommandMessage* message, store_address_t storageID) { - message->setCommand(WRITE); + message->setCommand(APPEND_TO_FILE); message->setParameter2(storageID.raw); } void FileSystemMessage::setReadCommand(CommandMessage* message, store_address_t storageID) { - message->setCommand(READ); + message->setCommand(READ_FROM_FILE); message->setParameter2(storageID.raw); } @@ -38,6 +38,12 @@ void FileSystemMessage::setReadReply(CommandMessage* message, message->setParameter2(storageID.raw); } +void FileSystemMessage::setCreateFileCommand(CommandMessage *message, + store_address_t storeId) { + message->setCommand(CREATE_FILE); + message->setParameter2(storeId.raw); +} + store_address_t FileSystemMessage::getStoreId(const CommandMessage* message) { store_address_t temp; temp.raw = message->getParameter2(); @@ -58,3 +64,4 @@ ReturnValue_t FileSystemMessage::getFailureReply( const CommandMessage *message) { return message->getParameter(); } + diff --git a/memory/FileSystemMessage.h b/memory/FileSystemMessage.h index c098d407..4d77fd16 100644 --- a/memory/FileSystemMessage.h +++ b/memory/FileSystemMessage.h @@ -14,16 +14,45 @@ public: FileSystemMessage() = delete; static const uint8_t MESSAGE_ID = messagetypes::FILE_SYSTEM_MESSAGE; + /* PUS standard (ECSS-E-ST-70-41C15 2016 p.654) */ static const Command_t CREATE_FILE = MAKE_COMMAND_ID(1); static const Command_t DELETE_FILE = MAKE_COMMAND_ID(2); + /** Report file attributes */ + static const Command_t REPORT_FILE_ATTRIBUTES = MAKE_COMMAND_ID(3); + static const Command_t FILE_ATTRIBUTES_REPLY = MAKE_COMMAND_ID(4); + /** Command to lock a file, setting it read-only */ + static const Command_t LOCK_FILE = MAKE_COMMAND_ID(5); + /** Command to unlock a file, enabling further operations on it */ + static const Command_t UNLOCK_FILE = MAKE_COMMAND_ID(6); + /** + * Find file in repository, using a search pattern. + * Please note that * is the wildcard character. + * For example, when looking for all files which start with have the + * structure tm.bin, tm*.bin can be used. + */ + static const Command_t FIND_FILE = MAKE_COMMAND_ID(7); static const Command_t CREATE_DIRECTORY = MAKE_COMMAND_ID(9); - static const Command_t DELETE_DIRECTORY = MAKE_COMMAND_ID(10); - static const Command_t WRITE = MAKE_COMMAND_ID(128); - static const Command_t READ = MAKE_COMMAND_ID(129); - static const Command_t READ_REPLY = MAKE_COMMAND_ID(130); - static const Command_t COMPLETION_SUCCESS = MAKE_COMMAND_ID(5); - static const Command_t COMPLETION_FAILED = MAKE_COMMAND_ID(6); + static const Command_t DELETE_DIRECTORY = MAKE_COMMAND_ID(10); + static const Command_t RENAME_DIRECTORY = MAKE_COMMAND_ID(11); + /** Dump contents of a repository */ + static const Command_t DUMP_REPOSITORY = MAKE_COMMAND_ID(12); + /** Repository dump reply */ + static const Command_t DUMY_REPOSITORY_REPLY = MAKE_COMMAND_ID(13); + + static const Command_t APPEND_TO_FILE = MAKE_COMMAND_ID(128); + static const Command_t READ_FROM_FILE = MAKE_COMMAND_ID(129); + static const Command_t READ_REPLY = MAKE_COMMAND_ID(130); + + /** Dump the structure of the whole SD card as an ASCII file */ + static const Command_t DUMP_FILE_STRUCTURE = MAKE_COMMAND_ID(131); + + + static const Command_t COMPLETION_SUCCESS = MAKE_COMMAND_ID(150); + static const Command_t COMPLETION_FAILED = MAKE_COMMAND_ID(151); + + static void setCreateFileCommand(CommandMessage* message, + store_address_t storeId); static void setDeleteFileCommand(CommandMessage* message, store_address_t storeId); static void setCreateDirectoryCommand(CommandMessage* message, From f955cd9eee41ad52eb854f8fb8cca4b040dba181 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sun, 4 Oct 2020 23:37:22 +0200 Subject: [PATCH 168/192] made interface more generic --- memory/HasFileSystemIF.h | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/memory/HasFileSystemIF.h b/memory/HasFileSystemIF.h index 916169ee..e270f256 100644 --- a/memory/HasFileSystemIF.h +++ b/memory/HasFileSystemIF.h @@ -29,22 +29,44 @@ public: virtual MessageQueueId_t getCommandQueue() const = 0; /** - * Function to write to a file + * Generic function to append to file. * @param dirname Directory of the file * @param filename The filename of the file * @param data The data to write to the file * @param size The size of the data to write - * @param packetNumber Counts the number of packets. + * @param packetNumber Current packet number. Can be used to verify that + * there are no missing packets. + * @param args Any other arguments which an implementation might require. + * @param bytesWritten Actual bytes written to file * For large files the write procedure must be split in multiple calls * to writeToFile */ - virtual ReturnValue_t writeToFile(const char* dirname, const char* filename, - const uint8_t* data, size_t size, uint16_t packetNumber) = 0; - virtual ReturnValue_t createFile(const char* dirname, const char* filename, - const uint8_t* data = nullptr, size_t size = 0, - size_t* bytesWritten = nullptr) = 0; - virtual ReturnValue_t deleteFile(const char* dirname, - const char* filename) = 0; + virtual ReturnValue_t appendToFile(const char* repositoryPath, + const char* filename, const uint8_t* data, size_t size, + uint16_t packetNumber, void* args = nullptr) = 0; + + /** + * Generic function to create a new file. + * @param repositoryPath + * @param filename + * @param data + * @param size + * @param args Any other arguments which an implementation might require. + * @return + */ + virtual ReturnValue_t createFile(const char* repositoryPath, + const char* filename, const uint8_t* data = nullptr, + size_t size = 0, void* args = nullptr) = 0; + + /** + * Generic function to delete a file. + * @param repositoryPath + * @param filename + * @param args + * @return + */ + virtual ReturnValue_t deleteFile(const char* repositoryPath, + const char* filename, void* args = nullptr) = 0; }; From a7fe23c3004d8c933b36d3c5a23f0b8322eaa022 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 5 Oct 2020 00:12:52 +0200 Subject: [PATCH 169/192] small stuff --- memory/FileSystemMessage.cpp | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/memory/FileSystemMessage.cpp b/memory/FileSystemMessage.cpp index b9c426a8..839268a0 100644 --- a/memory/FileSystemMessage.cpp +++ b/memory/FileSystemMessage.cpp @@ -1,35 +1,40 @@ #include "FileSystemMessage.h" #include "../objectmanager/ObjectManagerIF.h" +void FileSystemMessage::setCreateFileCommand(CommandMessage* message, + store_address_t storeId) { + message->setCommand(CREATE_FILE); + message->setParameter2(storeId.raw); +} void FileSystemMessage::setDeleteFileCommand( - CommandMessage* message, store_address_t storageID) { - message->setCommand(DELETE_FILE); - message->setParameter2(storageID.raw); + CommandMessage* message, store_address_t storeId) { + message->setCommand(DELETE_FILE); + message->setParameter2(storeId.raw); } void FileSystemMessage::setCreateDirectoryCommand( - CommandMessage* message, store_address_t storageID) { + CommandMessage* message, store_address_t storeId) { message->setCommand(CREATE_DIRECTORY); - message->setParameter2(storageID.raw); + message->setParameter2(storeId.raw); } void FileSystemMessage::setDeleteDirectoryCommand( - CommandMessage* message, store_address_t storageID) { + CommandMessage* message, store_address_t storeId) { message->setCommand(DELETE_DIRECTORY); - message->setParameter2(storageID.raw); + message->setParameter2(storeId.raw); } void FileSystemMessage::setWriteCommand(CommandMessage* message, - store_address_t storageID) { + store_address_t storeId) { message->setCommand(APPEND_TO_FILE); - message->setParameter2(storageID.raw); + message->setParameter2(storeId.raw); } void FileSystemMessage::setReadCommand(CommandMessage* message, - store_address_t storageID) { + store_address_t storeId) { message->setCommand(READ_FROM_FILE); - message->setParameter2(storageID.raw); + message->setParameter2(storeId.raw); } void FileSystemMessage::setReadReply(CommandMessage* message, @@ -38,12 +43,6 @@ void FileSystemMessage::setReadReply(CommandMessage* message, message->setParameter2(storageID.raw); } -void FileSystemMessage::setCreateFileCommand(CommandMessage *message, - store_address_t storeId) { - message->setCommand(CREATE_FILE); - message->setParameter2(storeId.raw); -} - store_address_t FileSystemMessage::getStoreId(const CommandMessage* message) { store_address_t temp; temp.raw = message->getParameter2(); From 1431116417672389bfef1ea1a77bf832cbbe309e Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 5 Oct 2020 12:11:11 +0200 Subject: [PATCH 170/192] NULL exception somewhere --- memory/FileSystemMessage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/memory/FileSystemMessage.cpp b/memory/FileSystemMessage.cpp index 839268a0..21f22f5d 100644 --- a/memory/FileSystemMessage.cpp +++ b/memory/FileSystemMessage.cpp @@ -55,7 +55,7 @@ void FileSystemMessage::setSuccessReply(CommandMessage *message) { void FileSystemMessage::setFailureReply(CommandMessage *message, ReturnValue_t errorCode) { - message->setCommand(COMPLETION_SUCCESS); + message->setCommand(COMPLETION_FAILED); message->setParameter(errorCode); } From c17d50bd1e16031be3861723d68b9269c4623cbf Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 5 Oct 2020 19:46:25 +0200 Subject: [PATCH 171/192] file syste mmessage moved to mission code for now --- memory/FileSystemMessage.cpp | 66 ------------------------------- memory/FileSystemMessage.h | 75 ------------------------------------ 2 files changed, 141 deletions(-) delete mode 100644 memory/FileSystemMessage.cpp delete mode 100644 memory/FileSystemMessage.h diff --git a/memory/FileSystemMessage.cpp b/memory/FileSystemMessage.cpp deleted file mode 100644 index 21f22f5d..00000000 --- a/memory/FileSystemMessage.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include "FileSystemMessage.h" -#include "../objectmanager/ObjectManagerIF.h" - -void FileSystemMessage::setCreateFileCommand(CommandMessage* message, - store_address_t storeId) { - message->setCommand(CREATE_FILE); - message->setParameter2(storeId.raw); -} - -void FileSystemMessage::setDeleteFileCommand( - CommandMessage* message, store_address_t storeId) { - message->setCommand(DELETE_FILE); - message->setParameter2(storeId.raw); -} - -void FileSystemMessage::setCreateDirectoryCommand( - CommandMessage* message, store_address_t storeId) { - message->setCommand(CREATE_DIRECTORY); - message->setParameter2(storeId.raw); -} - -void FileSystemMessage::setDeleteDirectoryCommand( - CommandMessage* message, store_address_t storeId) { - message->setCommand(DELETE_DIRECTORY); - message->setParameter2(storeId.raw); -} - -void FileSystemMessage::setWriteCommand(CommandMessage* message, - store_address_t storeId) { - message->setCommand(APPEND_TO_FILE); - message->setParameter2(storeId.raw); -} - -void FileSystemMessage::setReadCommand(CommandMessage* message, - store_address_t storeId) { - message->setCommand(READ_FROM_FILE); - message->setParameter2(storeId.raw); -} - -void FileSystemMessage::setReadReply(CommandMessage* message, - store_address_t storageID) { - message->setCommand(READ_REPLY); - message->setParameter2(storageID.raw); -} - -store_address_t FileSystemMessage::getStoreId(const CommandMessage* message) { - store_address_t temp; - temp.raw = message->getParameter2(); - return temp; -} - -void FileSystemMessage::setSuccessReply(CommandMessage *message) { - message->setCommand(COMPLETION_SUCCESS); -} - -void FileSystemMessage::setFailureReply(CommandMessage *message, - ReturnValue_t errorCode) { - message->setCommand(COMPLETION_FAILED); - message->setParameter(errorCode); -} - -ReturnValue_t FileSystemMessage::getFailureReply( - const CommandMessage *message) { - return message->getParameter(); -} - diff --git a/memory/FileSystemMessage.h b/memory/FileSystemMessage.h deleted file mode 100644 index 4d77fd16..00000000 --- a/memory/FileSystemMessage.h +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef FSFW_MEMORY_FILESYSTEMMESSAGE_H_ -#define FSFW_MEMORY_FILESYSTEMMESSAGE_H_ - -#include "../ipc/CommandMessage.h" -#include "../storagemanager/StorageManagerIF.h" -#include "../objectmanager/SystemObject.h" - -/** - * @author Jakob Meier - */ -class FileSystemMessage { -public: - // Instantiation forbidden - FileSystemMessage() = delete; - - static const uint8_t MESSAGE_ID = messagetypes::FILE_SYSTEM_MESSAGE; - /* PUS standard (ECSS-E-ST-70-41C15 2016 p.654) */ - static const Command_t CREATE_FILE = MAKE_COMMAND_ID(1); - static const Command_t DELETE_FILE = MAKE_COMMAND_ID(2); - /** Report file attributes */ - static const Command_t REPORT_FILE_ATTRIBUTES = MAKE_COMMAND_ID(3); - static const Command_t FILE_ATTRIBUTES_REPLY = MAKE_COMMAND_ID(4); - /** Command to lock a file, setting it read-only */ - static const Command_t LOCK_FILE = MAKE_COMMAND_ID(5); - /** Command to unlock a file, enabling further operations on it */ - static const Command_t UNLOCK_FILE = MAKE_COMMAND_ID(6); - /** - * Find file in repository, using a search pattern. - * Please note that * is the wildcard character. - * For example, when looking for all files which start with have the - * structure tm.bin, tm*.bin can be used. - */ - static const Command_t FIND_FILE = MAKE_COMMAND_ID(7); - static const Command_t CREATE_DIRECTORY = MAKE_COMMAND_ID(9); - static const Command_t DELETE_DIRECTORY = MAKE_COMMAND_ID(10); - static const Command_t RENAME_DIRECTORY = MAKE_COMMAND_ID(11); - - /** Dump contents of a repository */ - static const Command_t DUMP_REPOSITORY = MAKE_COMMAND_ID(12); - /** Repository dump reply */ - static const Command_t DUMY_REPOSITORY_REPLY = MAKE_COMMAND_ID(13); - - static const Command_t APPEND_TO_FILE = MAKE_COMMAND_ID(128); - static const Command_t READ_FROM_FILE = MAKE_COMMAND_ID(129); - static const Command_t READ_REPLY = MAKE_COMMAND_ID(130); - - /** Dump the structure of the whole SD card as an ASCII file */ - static const Command_t DUMP_FILE_STRUCTURE = MAKE_COMMAND_ID(131); - - - static const Command_t COMPLETION_SUCCESS = MAKE_COMMAND_ID(150); - static const Command_t COMPLETION_FAILED = MAKE_COMMAND_ID(151); - - static void setCreateFileCommand(CommandMessage* message, - store_address_t storeId); - static void setDeleteFileCommand(CommandMessage* message, - store_address_t storeId); - static void setCreateDirectoryCommand(CommandMessage* message, - store_address_t storeId); - static void setDeleteDirectoryCommand(CommandMessage* message, - store_address_t storeId); - static void setWriteCommand(CommandMessage* message, - store_address_t storeId); - static void setReadCommand(CommandMessage* message, - store_address_t storeId); - static void setReadReply(CommandMessage* message, store_address_t storeId); - static void setSuccessReply(CommandMessage* message); - static void setFailureReply(CommandMessage* message, - ReturnValue_t errorCode); - - static store_address_t getStoreId(const CommandMessage* message); - static ReturnValue_t getFailureReply(const CommandMessage* message); -}; - -#endif /* FSFW_MEMORY_FILESYSTEMMESSAGE_H_ */ From 8c43c6993eca053fdf8dc633ea049ceed6564a43 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 5 Oct 2020 22:47:32 +0200 Subject: [PATCH 172/192] CSB fifo depth configurable --- pus/Service1TelecommandVerification.cpp | 5 ++--- pus/Service1TelecommandVerification.h | 3 ++- returnvalues/FwClassIds.h | 4 ++-- tmtcservices/CommandingServiceBase.h | 4 +++- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pus/Service1TelecommandVerification.cpp b/pus/Service1TelecommandVerification.cpp index 9b17eba5..6d081fe2 100644 --- a/pus/Service1TelecommandVerification.cpp +++ b/pus/Service1TelecommandVerification.cpp @@ -8,13 +8,12 @@ #include "../tmtcservices/AcceptsTelemetryIF.h" #include "../serviceinterface/ServiceInterfaceStream.h" - Service1TelecommandVerification::Service1TelecommandVerification( object_id_t objectId, uint16_t apid, uint8_t serviceId, - object_id_t targetDestination): + object_id_t targetDestination, uint16_t messageQueueDepth): SystemObject(objectId), apid(apid), serviceId(serviceId), targetDestination(targetDestination) { - tmQueue = QueueFactory::instance()->createMessageQueue(); + tmQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth); } Service1TelecommandVerification::~Service1TelecommandVerification() {} diff --git a/pus/Service1TelecommandVerification.h b/pus/Service1TelecommandVerification.h index 37562d1c..6fff0332 100644 --- a/pus/Service1TelecommandVerification.h +++ b/pus/Service1TelecommandVerification.h @@ -44,7 +44,8 @@ public: static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PUS_SERVICE_1; Service1TelecommandVerification(object_id_t objectId, - uint16_t apid, uint8_t serviceId, object_id_t targetDestination); + uint16_t apid, uint8_t serviceId, object_id_t targetDestination, + uint16_t messageQueueDepth); virtual ~Service1TelecommandVerification(); /** diff --git a/returnvalues/FwClassIds.h b/returnvalues/FwClassIds.h index c8c0a3ad..120d1e2e 100644 --- a/returnvalues/FwClassIds.h +++ b/returnvalues/FwClassIds.h @@ -66,8 +66,8 @@ enum { HOUSEKEEPING_MANAGER, //HKM 60 DLE_ENCODER, //DLEE 61 SERIAL_ANALYZER, //SERA 62 - PUS_SERVICE_9, // PUS9 63 - FILE_SYSTEM, // FLSY 64 + PUS_SERVICE_9, //PUS9 63 + FILE_SYSTEM, //FLSY 64 FW_CLASS_ID_COUNT //is actually count + 1 ! }; diff --git a/tmtcservices/CommandingServiceBase.h b/tmtcservices/CommandingServiceBase.h index 252b6943..9f1d4c4f 100644 --- a/tmtcservices/CommandingServiceBase.h +++ b/tmtcservices/CommandingServiceBase.h @@ -13,6 +13,8 @@ #include "../container/FIFO.h" #include "../serialize/SerializeIF.h" +#include + class TcPacketStored; namespace Factory{ @@ -40,7 +42,7 @@ class CommandingServiceBase: public SystemObject, friend void (Factory::setStaticFrameworkObjectIds)(); public: // We could make this configurable via preprocessor and the FSFWConfig file. - static constexpr uint8_t COMMAND_INFO_FIFO_DEPTH = 3; + static constexpr uint8_t COMMAND_INFO_FIFO_DEPTH = FSFW_CSB_FIFO_DEPTH; static const uint8_t INTERFACE_ID = CLASS_ID::COMMAND_SERVICE_BASE; From 6a077c583dd2063ad9b71d9298967c78e59d967b Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 6 Oct 2020 14:00:18 +0200 Subject: [PATCH 173/192] action helper some formatting stuff --- action/ActionHelper.h | 74 +++++++++++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 27 deletions(-) diff --git a/action/ActionHelper.h b/action/ActionHelper.h index bbc6d114..0334543c 100644 --- a/action/ActionHelper.h +++ b/action/ActionHelper.h @@ -1,15 +1,18 @@ -#ifndef ACTIONHELPER_H_ -#define ACTIONHELPER_H_ +#ifndef FSFW_ACTION_ACTIONHELPER_H_ +#define FSFW_ACTION_ACTIONHELPER_H_ #include "ActionMessage.h" #include "../serialize/SerializeIF.h" #include "../ipc/MessageQueueIF.h" /** - * \brief Action Helper is a helper class which handles action messages + * @brief Action Helper is a helper class which handles action messages * - * Components which use the HasActionIF this helper can be used to handle the action messages. - * It does handle step messages as well as other answers to action calls. It uses the executeAction function - * of its owner as callback. The call of the initialize function is mandatory and it needs a valid messageQueueIF pointer! + * Components which use the HasActionIF this helper can be used to handle + * the action messages. + * It does handle step messages as well as other answers to action calls. + * It uses the executeAction function of its owner as callback. + * The call of the initialize function is mandatory and needs a + * valid MessageQueueIF pointer! */ class HasActionsIF; @@ -18,7 +21,8 @@ public: /** * Constructor of the action helper * @param setOwner Pointer to the owner of the interface - * @param useThisQueue messageQueue to be used, can be set during initialize function as well. + * @param useThisQueue messageQueue to be used, can be set during + * initialize function as well. */ ActionHelper(HasActionsIF* setOwner, MessageQueueIF* useThisQueue); @@ -26,28 +30,35 @@ public: /** * Function to be called from the owner with a new command message * - * If the message is a valid action message the helper will use the executeAction function from HasActionsIF. - * If the message is invalid or the callback fails a message reply will be send to the sender of the message automatically. + * If the message is a valid action message the helper will use the + * executeAction function from HasActionsIF. + * If the message is invalid or the callback fails a message reply will be + * send to the sender of the message automatically. * * @param command Pointer to a command message received by the owner - * @return HasReturnvaluesIF::RETURN_OK if the message is a action message, CommandMessage::UNKNOW_COMMAND if this message ID is unkown + * @return HasReturnvaluesIF::RETURN_OK if the message is a action message, + * CommandMessage::UNKNOW_COMMAND if this message ID is unkown */ ReturnValue_t handleActionMessage(CommandMessage* command); /** - * Helper initialize function. Must be called before use of any other helper function - * @param queueToUse_ Pointer to the messageQueue to be used, optional if queue was set in constructor + * Helper initialize function. Must be called before use of any other + * helper function + * @param queueToUse_ Pointer to the messageQueue to be used, optional + * if queue was set in constructor * @return Returns RETURN_OK if successful */ ReturnValue_t initialize(MessageQueueIF* queueToUse_ = nullptr); /** - * Function to be called from the owner to send a step message. Success or failure will be determined by the result value. + * Function to be called from the owner to send a step message. + * Success or failure will be determined by the result value. * * @param step Number of steps already done * @param reportTo The messageQueueId to report the step message to * @param commandId ID of the executed command * @param result Result of the execution */ - void step(uint8_t step, MessageQueueId_t reportTo, ActionId_t commandId, ReturnValue_t result = HasReturnvaluesIF::RETURN_OK); + void step(uint8_t step, MessageQueueId_t reportTo, ActionId_t commandId, + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK); /** * Function to be called by the owner to send a action completion message * @@ -55,39 +66,48 @@ public: * @param commandId ID of the executed command * @param result Result of the execution */ - void finish(MessageQueueId_t reportTo, ActionId_t commandId, ReturnValue_t result = HasReturnvaluesIF::RETURN_OK); + void finish(MessageQueueId_t reportTo, ActionId_t commandId, + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK); /** * Function to be called by the owner if an action does report data * - * @param reportTo MessageQueueId_t to report the action completion message to + * @param reportTo MessageQueueId_t to report the action completion + * message to * @param replyId ID of the executed command * @param data Pointer to the data * @return Returns RETURN_OK if successful, otherwise failure code */ - ReturnValue_t reportData(MessageQueueId_t reportTo, ActionId_t replyId, SerializeIF* data, bool hideSender = false); + ReturnValue_t reportData(MessageQueueId_t reportTo, ActionId_t replyId, + SerializeIF* data, bool hideSender = false); /** - * Function to setup the MessageQueueIF* of the helper. Can be used to set the messageQueueIF* if - * message queue is unavailable at construction and initialize but must be setup before first call of other functions. + * Function to setup the MessageQueueIF* of the helper. Can be used to + * set the MessageQueueIF* if message queue is unavailable at construction + * and initialize but must be setup before first call of other functions. * @param queue Queue to be used by the helper */ void setQueueToUse(MessageQueueIF *queue); protected: - static const uint8_t STEP_OFFSET = 1;//!< Increase of value of this per step + //!< Increase of value of this per step + static const uint8_t STEP_OFFSET = 1; HasActionsIF* owner;//!< Pointer to the owner - MessageQueueIF* queueToUse;//!< Queue to be used as response sender, has to be set with - StorageManagerIF* ipcStore;//!< Pointer to an IPC Store, initialized during construction or initialize(MessageQueueIF* queueToUse_) or with setQueueToUse(MessageQueueIF *queue) + //! Queue to be used as response sender, has to be set in ctor or with + //! setQueueToUse + MessageQueueIF* queueToUse; + //! Pointer to an IPC Store, initialized during construction or + StorageManagerIF* ipcStore; + /** - *Internal function called by handleActionMessage(CommandMessage* command) - * + * Internal function called by handleActionMessage * @param commandedBy MessageQueueID of Commander * @param actionId ID of action to be done * @param dataAddress Address of additional data in IPC Store */ - virtual void prepareExecution(MessageQueueId_t commandedBy, ActionId_t actionId, store_address_t dataAddress); + virtual void prepareExecution(MessageQueueId_t commandedBy, + ActionId_t actionId, store_address_t dataAddress); /** - * + * @brief Default implementation is empty. */ virtual void resetHelper(); }; -#endif /* ACTIONHELPER_H_ */ +#endif /* FSFW_ACTION_ACTIONHELPER_H_ */ From df1a730cdff36835424057e64f89f3817fda24bb Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 6 Oct 2020 16:01:35 +0200 Subject: [PATCH 174/192] some form stuff --- action/ActionHelper.cpp | 15 +++++++++------ action/ActionHelper.h | 2 +- pus/Service8FunctionManagement.cpp | 4 ++-- tmtcservices/TmTcMessage.cpp | 8 ++++---- tmtcservices/TmTcMessage.h | 16 ++++++++-------- 5 files changed, 24 insertions(+), 21 deletions(-) diff --git a/action/ActionHelper.cpp b/action/ActionHelper.cpp index 361f7dc3..ab986c6c 100644 --- a/action/ActionHelper.cpp +++ b/action/ActionHelper.cpp @@ -3,8 +3,9 @@ #include "../ipc/MessageQueueSenderIF.h" #include "../objectmanager/ObjectManagerIF.h" -ActionHelper::ActionHelper(HasActionsIF* setOwner, MessageQueueIF* useThisQueue) : - owner(setOwner), queueToUse(useThisQueue), ipcStore(nullptr) { +ActionHelper::ActionHelper(HasActionsIF* setOwner, + MessageQueueIF* useThisQueue) : + owner(setOwner), queueToUse(useThisQueue) { } ActionHelper::~ActionHelper() { @@ -33,13 +34,15 @@ ReturnValue_t ActionHelper::initialize(MessageQueueIF* queueToUse_) { return HasReturnvaluesIF::RETURN_OK; } -void ActionHelper::step(uint8_t step, MessageQueueId_t reportTo, ActionId_t commandId, ReturnValue_t result) { +void ActionHelper::step(uint8_t step, MessageQueueId_t reportTo, + ActionId_t commandId, ReturnValue_t result) { CommandMessage reply; ActionMessage::setStepReply(&reply, commandId, step + STEP_OFFSET, result); queueToUse->sendMessage(reportTo, &reply); } -void ActionHelper::finish(MessageQueueId_t reportTo, ActionId_t commandId, ReturnValue_t result) { +void ActionHelper::finish(MessageQueueId_t reportTo, ActionId_t commandId, + ReturnValue_t result) { CommandMessage reply; ActionMessage::setCompletionReply(&reply, commandId, result); queueToUse->sendMessage(reportTo, &reply); @@ -49,8 +52,8 @@ void ActionHelper::setQueueToUse(MessageQueueIF* queue) { queueToUse = queue; } -void ActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId_t actionId, - store_address_t dataAddress) { +void ActionHelper::prepareExecution(MessageQueueId_t commandedBy, + ActionId_t actionId, store_address_t dataAddress) { const uint8_t* dataPtr = NULL; size_t size = 0; ReturnValue_t result = ipcStore->getData(dataAddress, &dataPtr, &size); diff --git a/action/ActionHelper.h b/action/ActionHelper.h index 0334543c..a20f286a 100644 --- a/action/ActionHelper.h +++ b/action/ActionHelper.h @@ -94,7 +94,7 @@ protected: //! setQueueToUse MessageQueueIF* queueToUse; //! Pointer to an IPC Store, initialized during construction or - StorageManagerIF* ipcStore; + StorageManagerIF* ipcStore = nullptr; /** * Internal function called by handleActionMessage diff --git a/pus/Service8FunctionManagement.cpp b/pus/Service8FunctionManagement.cpp index 2c2e590b..c1c88a50 100644 --- a/pus/Service8FunctionManagement.cpp +++ b/pus/Service8FunctionManagement.cpp @@ -7,10 +7,10 @@ #include "../serialize/SerializeAdapter.h" #include "../serviceinterface/ServiceInterfaceStream.h" -Service8FunctionManagement::Service8FunctionManagement(object_id_t object_id, +Service8FunctionManagement::Service8FunctionManagement(object_id_t objectId, uint16_t apid, uint8_t serviceId, uint8_t numParallelCommands, uint16_t commandTimeoutSeconds): - CommandingServiceBase(object_id, apid, serviceId, numParallelCommands, + CommandingServiceBase(objectId, apid, serviceId, numParallelCommands, commandTimeoutSeconds) {} Service8FunctionManagement::~Service8FunctionManagement() {} diff --git a/tmtcservices/TmTcMessage.cpp b/tmtcservices/TmTcMessage.cpp index a715225b..f81eba62 100644 --- a/tmtcservices/TmTcMessage.cpp +++ b/tmtcservices/TmTcMessage.cpp @@ -15,15 +15,15 @@ store_address_t TmTcMessage::getStorageId() { return temp_id; } -TmTcMessage::TmTcMessage(store_address_t store_id) { +TmTcMessage::TmTcMessage(store_address_t storeId) { this->messageSize += sizeof(store_address_t); - this->setStorageId(store_id); + this->setStorageId(storeId); } size_t TmTcMessage::getMinimumMessageSize() { return this->HEADER_SIZE + sizeof(store_address_t); } -void TmTcMessage::setStorageId(store_address_t store_id) { - memcpy(this->getData(), &store_id, sizeof(store_address_t) ); +void TmTcMessage::setStorageId(store_address_t storeId) { + memcpy(this->getData(), &storeId, sizeof(store_address_t) ); } diff --git a/tmtcservices/TmTcMessage.h b/tmtcservices/TmTcMessage.h index b5e1ff8d..41fe198a 100644 --- a/tmtcservices/TmTcMessage.h +++ b/tmtcservices/TmTcMessage.h @@ -1,5 +1,5 @@ -#ifndef TMTCMESSAGE_H_ -#define TMTCMESSAGE_H_ +#ifndef FSFW_TMTCSERVICES_TMTCMESSAGE_H_ +#define FSFW_TMTCSERVICES_TMTCMESSAGE_H_ #include "../ipc/MessageQueueMessage.h" #include "../storagemanager/StorageManagerIF.h" @@ -10,13 +10,13 @@ * a packet stored in one of the IPC stores (typically a special TM and * a special TC store). This makes passing commands very simple and * efficient. - * \ingroup message_queue + * @ingroup message_queue */ class TmTcMessage : public MessageQueueMessage { protected: /** * @brief This call always returns the same fixed size of the message. - * @return Returns HEADER_SIZE + \c sizeof(store_address_t). + * @return Returns HEADER_SIZE + @c sizeof(store_address_t). */ size_t getMinimumMessageSize(); public: @@ -29,7 +29,7 @@ public: * into the message. * @param packet_id The packet id to put into the message. */ - TmTcMessage( store_address_t packet_id ); + TmTcMessage( store_address_t packetId ); /** * @brief The class's destructor is empty. */ @@ -42,9 +42,9 @@ public: /** * @brief In some cases it might be useful to have a setter for packet id * as well. - * @param packet_id The packet id to put into the message. + * @param packetId The packet id to put into the message. */ - void setStorageId( store_address_t packet_id ); + void setStorageId( store_address_t packetId ); }; -#endif /* TMTCMESSAGE_H_ */ +#endif /* FSFW_TMTCSERVICES_TMTCMESSAGE_H_ */ From 9fb38e9b7c168e514706b3b757e70b2d1b163c3f Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 6 Oct 2020 19:58:29 +0200 Subject: [PATCH 175/192] better error output --- osal/FreeRTOS/MessageQueue.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/osal/FreeRTOS/MessageQueue.cpp b/osal/FreeRTOS/MessageQueue.cpp index 2dfe5ab6..fdadf8b7 100644 --- a/osal/FreeRTOS/MessageQueue.cpp +++ b/osal/FreeRTOS/MessageQueue.cpp @@ -11,7 +11,12 @@ MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize): maxMessageSize(maxMessageSize) { handle = xQueueCreate(messageDepth, maxMessageSize); if (handle == nullptr) { - sif::error << "MessageQueue::MessageQueue Creation failed" << std::endl; + sif::error << "MessageQueue::MessageQueue:" + << " Creation failed." << std::endl; + sif::error << "Specified Message Depth: " << messageDepth + << std::endl; + sif::error << "Specified Maximum Message Size: " + << maxMessageSize << std::endl; } } From 6e9db0d67533b8b3fa25def2b185691749c2b6f6 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Wed, 7 Oct 2020 18:43:56 +0200 Subject: [PATCH 176/192] retval added --- memory/HasFileSystemIF.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/memory/HasFileSystemIF.h b/memory/HasFileSystemIF.h index e270f256..7ab4cc4e 100644 --- a/memory/HasFileSystemIF.h +++ b/memory/HasFileSystemIF.h @@ -21,6 +21,8 @@ public: static constexpr ReturnValue_t DIRECTORY_ALREADY_EXISTS = MAKE_RETURN_CODE(0x03); static constexpr ReturnValue_t DIRECTORY_NOT_EMPTY = MAKE_RETURN_CODE(0x04); + static constexpr ReturnValue_t SEQUENCE_PACKET_MISSING = MAKE_RETURN_CODE(0x05); + virtual ~HasFileSystemIF() {} /** * Function to get the MessageQueueId_t of the implementing object From 2364c4f9a4d1aa551557e0d2a4b616652da8d2db Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Wed, 7 Oct 2020 20:47:46 +0200 Subject: [PATCH 177/192] form improvements --- tmtcpacket/pus/TmPacketStored.cpp | 7 +++-- tmtcpacket/pus/TmPacketStored.h | 47 +++++++++++++++++++------------ 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/tmtcpacket/pus/TmPacketStored.cpp b/tmtcpacket/pus/TmPacketStored.cpp index 17b49f43..4cf76589 100644 --- a/tmtcpacket/pus/TmPacketStored.cpp +++ b/tmtcpacket/pus/TmPacketStored.cpp @@ -1,8 +1,9 @@ +#include "TmPacketStored.h" + #include "../../objectmanager/ObjectManagerIF.h" #include "../../serviceinterface/ServiceInterfaceStream.h" -#include "../../tmtcpacket/pus/TmPacketStored.h" #include "../../tmtcservices/TmTcMessage.h" -#include +#include TmPacketStored::TmPacketStored(store_address_t setAddress) : TmPacketBase(NULL), storeAddress(setAddress) { @@ -11,7 +12,7 @@ TmPacketStored::TmPacketStored(store_address_t setAddress) : TmPacketStored::TmPacketStored(uint16_t apid, uint8_t service, uint8_t subservice, uint8_t packetSubcounter, const uint8_t *data, - uint32_t size, const uint8_t *headerData, uint32_t headerSize) : + size_t size, const uint8_t *headerData, size_t headerSize) : TmPacketBase(NULL) { storeAddress.raw = StorageManagerIF::INVALID_ADDRESS; if (!checkAndSetStore()) { diff --git a/tmtcpacket/pus/TmPacketStored.h b/tmtcpacket/pus/TmPacketStored.h index 98e37ed5..81a6f6e5 100644 --- a/tmtcpacket/pus/TmPacketStored.h +++ b/tmtcpacket/pus/TmPacketStored.h @@ -1,9 +1,9 @@ -#ifndef TMPACKETSTORED_H_ -#define TMPACKETSTORED_H_ +#ifndef FSFW_TMTCPACKET_TMPACKETSTORED_H_ +#define FSFW_TMTCPACKET_TMPACKETSTORED_H_ +#include "TmPacketBase.h" #include "../../serialize/SerializeIF.h" #include "../../storagemanager/StorageManagerIF.h" -#include "../../tmtcpacket/pus/TmPacketBase.h" #include "../../internalError/InternalErrorReporterIF.h" #include "../../ipc/MessageQueueSenderIF.h" @@ -21,7 +21,7 @@ class TmPacketStored : public TmPacketBase { private: /** * This is a pointer to the store all instances of the class use. - * If the store is not yet set (i.e. \c store is NULL), every constructor + * If the store is not yet set (i.e. @c store is NULL), every constructor * call tries to set it and throws an error message in case of failures. * The default store is objects::TM_STORE. */ @@ -37,8 +37,8 @@ private: * A helper method to check if a store is assigned to the class. * If not, the method tries to retrieve the store from the global * ObjectManager. - * @return @li \c true if the store is linked or could be created. - * @li \c false otherwise. + * @return @li @c true if the store is linked or could be created. + * @li @c false otherwise. */ bool checkAndSetStore(); @@ -52,8 +52,9 @@ public: /** * With this constructor, new space is allocated in the packet store and * a new PUS Telemetry Packet is created there. - * Packet Application Data passed in data is copied into the packet. The Application data is - * passed in two parts, first a header, then a data field. This allows building a Telemetry + * Packet Application Data passed in data is copied into the packet. + * The Application data is passed in two parts, first a header, then a + * data field. This allows building a Telemetry * Packet from two separate data sources. * @param apid Sets the packet's APID field. * @param service Sets the packet's Service ID field. @@ -61,20 +62,29 @@ public: * @param subservice Sets the packet's Service Subtype field. * This specifies the source sub-service. * @param packet_counter Sets the Packet counter field of this packet - * @param data The payload data to be copied to the Application Data Field + * @param data The payload data to be copied to the Application + * Data Field * @param size The amount of data to be copied. - * @param headerData The header Data of the Application field; will be copied in front of data + * @param headerData The header Data of the Application field; will be + * copied in front of data * @param headerSize The size of the headerDataF */ - TmPacketStored( uint16_t apid, uint8_t service, uint8_t subservice, uint8_t packet_counter = 0, const uint8_t* data = NULL, uint32_t size = 0, const uint8_t* headerData = NULL, uint32_t headerSize = 0); + TmPacketStored(uint16_t apid, uint8_t service, uint8_t subservice, + uint8_t packet_counter = 0, const uint8_t* data = nullptr, + size_t size = 0, const uint8_t* headerData = nullptr, + size_t headerSize = 0); /** - * Another ctor to directly pass structured content and header data to the packet to avoid additional buffers. + * Another ctor to directly pass structured content and header data to the + * packet to avoid additional buffers. */ - TmPacketStored( uint16_t apid, uint8_t service, uint8_t subservice, uint8_t packet_counter, SerializeIF* content, SerializeIF* header = NULL); + TmPacketStored(uint16_t apid, uint8_t service, uint8_t subservice, + uint8_t packet_counter, SerializeIF* content, + SerializeIF* header = nullptr); /** * This is a getter for the current store address of the packet. - * @return The current store address. The (raw) value is \c StorageManagerIF::INVALID_ADDRESS if - * the packet is not linked. + * @return + * The current store address. The (raw) value is + * @c StorageManagerIF::INVALID_ADDRESS if the packet is not linked. */ store_address_t getStoreAddress(); /** @@ -87,10 +97,11 @@ public: * if the packet is a class member and used for more than one packet. * @param setAddress The new packet id to link to. */ - void setStoreAddress( store_address_t setAddress ); + void setStoreAddress(store_address_t setAddress); - ReturnValue_t sendPacket( MessageQueueId_t destination, MessageQueueId_t sentFrom, bool doErrorReporting = true ); + ReturnValue_t sendPacket(MessageQueueId_t destination, + MessageQueueId_t sentFrom, bool doErrorReporting = true); }; -#endif /* TMPACKETSTORED_H_ */ +#endif /* FSFW_TMTCPACKET_TMPACKETSTORED_H_ */ From e338b4662d8682f391cdf950ed4a47e80eaf37da Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Fri, 9 Oct 2020 02:49:18 +0200 Subject: [PATCH 178/192] fix for c++11 comformity --- datapoollocal/LocalDataPoolManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datapoollocal/LocalDataPoolManager.cpp b/datapoollocal/LocalDataPoolManager.cpp index c23f183b..4f124e7f 100644 --- a/datapoollocal/LocalDataPoolManager.cpp +++ b/datapoollocal/LocalDataPoolManager.cpp @@ -389,7 +389,7 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid, dataSet->periodicHelper->getCollectionIntervalInSeconds(); // Generate set packet which can be serialized. - HousekeepingSetPacket setPacket = HousekeepingSetPacket(sid, + HousekeepingSetPacket setPacket(sid, reportingEnabled, valid, collectionInterval, dataSet); size_t expectedSize = setPacket.getSerializedSize(); uint8_t* storePtr = nullptr; From 94884c2402e3c5077bfe5b88c3255cd554a4ad5b Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 10 Oct 2020 17:11:11 +0200 Subject: [PATCH 179/192] service 1 small improvements --- pus/Service1TelecommandVerification.cpp | 5 ++--- pus/Service1TelecommandVerification.h | 8 ++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/pus/Service1TelecommandVerification.cpp b/pus/Service1TelecommandVerification.cpp index 6d081fe2..86b0dcde 100644 --- a/pus/Service1TelecommandVerification.cpp +++ b/pus/Service1TelecommandVerification.cpp @@ -1,12 +1,11 @@ -#include "../pus/Service1TelecommandVerification.h" -#include "../pus/servicepackets/Service1Packets.h" +#include "Service1TelecommandVerification.h" +#include "servicepackets/Service1Packets.h" #include "../ipc/QueueFactory.h" #include "../tmtcservices/PusVerificationReport.h" #include "../tmtcpacket/pus/TmPacketStored.h" #include "../serviceinterface/ServiceInterfaceStream.h" #include "../tmtcservices/AcceptsTelemetryIF.h" -#include "../serviceinterface/ServiceInterfaceStream.h" Service1TelecommandVerification::Service1TelecommandVerification( object_id_t objectId, uint16_t apid, uint8_t serviceId, diff --git a/pus/Service1TelecommandVerification.h b/pus/Service1TelecommandVerification.h index 6fff0332..3d68a4e0 100644 --- a/pus/Service1TelecommandVerification.h +++ b/pus/Service1TelecommandVerification.h @@ -1,5 +1,5 @@ -#ifndef MISSION_PUS_SERVICE1TELECOMMANDVERIFICATION_H_ -#define MISSION_PUS_SERVICE1TELECOMMANDVERIFICATION_H_ +#ifndef FSFW_PUS_SERVICE1TELECOMMANDVERIFICATION_H_ +#define FSFW_PUS_SERVICE1TELECOMMANDVERIFICATION_H_ #include "../objectmanager/SystemObject.h" #include "../returnvalues/HasReturnvaluesIF.h" @@ -52,7 +52,7 @@ public: * * @return ID of Verification Queue */ - virtual MessageQueueId_t getVerificationQueue(); + virtual MessageQueueId_t getVerificationQueue() override; /** * Performs the service periodically as specified in init_mission(). @@ -92,4 +92,4 @@ private: }; }; -#endif /* MISSION_PUS_SERVICE1TELECOMMANDVERIFICATION_H_ */ +#endif /* FSFW_PUS_SERVICE1TELECOMMANDVERIFICATION_H_ */ From 3aa666633e4d561847e2cf12972c2fb916d41ee8 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 10 Oct 2020 17:14:52 +0200 Subject: [PATCH 180/192] include guard replacements --- pus/CService200ModeCommanding.h | 6 +++--- pus/Service2DeviceAccess.cpp | 4 ++-- pus/Service2DeviceAccess.h | 6 +++--- pus/Service5EventReporting.cpp | 4 ++-- pus/Service5EventReporting.h | 6 +++--- pus/Service8FunctionManagement.h | 6 +++--- pus/servicepackets/Service1Packets.h | 6 +++--- pus/servicepackets/Service200Packets.h | 6 +++--- pus/servicepackets/Service2Packets.h | 6 +++--- pus/servicepackets/Service5Packets.h | 6 +++--- pus/servicepackets/Service8Packets.h | 6 +++--- 11 files changed, 31 insertions(+), 31 deletions(-) diff --git a/pus/CService200ModeCommanding.h b/pus/CService200ModeCommanding.h index 89347dbd..c86d7b84 100644 --- a/pus/CService200ModeCommanding.h +++ b/pus/CService200ModeCommanding.h @@ -1,5 +1,5 @@ -#ifndef FRAMEWORK_PUS_CSERVICE200MODECOMMANDING_H_ -#define FRAMEWORK_PUS_CSERVICE200MODECOMMANDING_H_ +#ifndef FSFW_PUS_CSERVICE200MODECOMMANDING_H_ +#define FSFW_PUS_CSERVICE200MODECOMMANDING_H_ #include "../tmtcservices/CommandingServiceBase.h" @@ -82,4 +82,4 @@ private: }; }; -#endif /* FRAMEWORK_PUS_CSERVICE200MODECOMMANDING_H_ */ +#endif /* FSFW_PUS_CSERVICE200MODECOMMANDING_H_ */ diff --git a/pus/Service2DeviceAccess.cpp b/pus/Service2DeviceAccess.cpp index 8780b22c..878a13b0 100644 --- a/pus/Service2DeviceAccess.cpp +++ b/pus/Service2DeviceAccess.cpp @@ -1,5 +1,5 @@ -#include "../pus/Service2DeviceAccess.h" -#include "../pus/servicepackets/Service2Packets.h" +#include "Service2DeviceAccess.h" +#include "servicepackets/Service2Packets.h" #include "../devicehandlers/DeviceHandlerIF.h" #include "../storagemanager/StorageManagerIF.h" diff --git a/pus/Service2DeviceAccess.h b/pus/Service2DeviceAccess.h index f6aa8b52..fa2ea75c 100644 --- a/pus/Service2DeviceAccess.h +++ b/pus/Service2DeviceAccess.h @@ -1,5 +1,5 @@ -#ifndef FRAMEWORK_PUS_SERVICE2DEVICEACCESS_H_ -#define FRAMEWORK_PUS_SERVICE2DEVICEACCESS_H_ +#ifndef FSFW_PUS_SERVICE2DEVICEACCESS_H_ +#define FSFW_PUS_SERVICE2DEVICEACCESS_H_ #include "../objectmanager/SystemObjectIF.h" #include "../devicehandlers/AcceptsDeviceResponsesIF.h" @@ -89,4 +89,4 @@ private: }; -#endif /* MISSION_PUS_DEVICE2DEVICECOMMANDING_H_ */ +#endif /* FSFW_PUS_DEVICE2DEVICECOMMANDING_H_ */ diff --git a/pus/Service5EventReporting.cpp b/pus/Service5EventReporting.cpp index 02031df4..829d04bd 100644 --- a/pus/Service5EventReporting.cpp +++ b/pus/Service5EventReporting.cpp @@ -1,5 +1,5 @@ -#include "../pus/Service5EventReporting.h" -#include "../pus/servicepackets/Service5Packets.h" +#include "Service5EventReporting.h" +#include "servicepackets/Service5Packets.h" #include "../serviceinterface/ServiceInterfaceStream.h" #include "../events/EventManagerIF.h" diff --git a/pus/Service5EventReporting.h b/pus/Service5EventReporting.h index 0b6ee9a8..78c18bf3 100644 --- a/pus/Service5EventReporting.h +++ b/pus/Service5EventReporting.h @@ -1,5 +1,5 @@ -#ifndef FRAMEWORK_PUS_SERVICE5EVENTREPORTING_H_ -#define FRAMEWORK_PUS_SERVICE5EVENTREPORTING_H_ +#ifndef FSFW_PUS_SERVICE5EVENTREPORTING_H_ +#define FSFW_PUS_SERVICE5EVENTREPORTING_H_ #include "../tmtcservices/PusServiceBase.h" #include "../events/EventMessage.h" @@ -83,4 +83,4 @@ private: ReturnValue_t generateEventReport(EventMessage message); }; -#endif /* MISSION_PUS_SERVICE5EVENTREPORTING_H_ */ +#endif /* FSFW_PUS_SERVICE5EVENTREPORTING_H_ */ diff --git a/pus/Service8FunctionManagement.h b/pus/Service8FunctionManagement.h index b5ebcda8..292a5e36 100644 --- a/pus/Service8FunctionManagement.h +++ b/pus/Service8FunctionManagement.h @@ -1,5 +1,5 @@ -#ifndef FRAMEWORK_PUS_SERVICE8FUNCTIONMANAGEMENT_H_ -#define FRAMEWORK_PUS_SERVICE8FUNCTIONMANAGEMENT_H_ +#ifndef FSFW_PUS_SERVICE8FUNCTIONMANAGEMENT_H_ +#define FSFW_PUS_SERVICE8FUNCTIONMANAGEMENT_H_ #include "../action/ActionMessage.h" #include "../tmtcservices/CommandingServiceBase.h" @@ -64,4 +64,4 @@ private: object_id_t objectId, ActionId_t actionId); }; -#endif /* FRAMEWORK_PUS_SERVICE8FUNCTIONMANAGEMENT_H_ */ +#endif /* FSFW_PUS_SERVICE8FUNCTIONMANAGEMENT_H_ */ diff --git a/pus/servicepackets/Service1Packets.h b/pus/servicepackets/Service1Packets.h index dbd31028..ecb62693 100644 --- a/pus/servicepackets/Service1Packets.h +++ b/pus/servicepackets/Service1Packets.h @@ -1,3 +1,6 @@ +#ifndef FSFW_PUS_SERVICEPACKETS_SERVICE1PACKETS_H_ +#define FSFW_PUS_SERVICEPACKETS_SERVICE1PACKETS_H_ + /** * @defgroup spacepackets PUS Packet Definitions * This group contains all implemented TM or TM packages that are sent to @@ -5,9 +8,6 @@ * packet structures in Mission Information Base (MIB). */ -#ifndef MISSION_PUS_SERVICEPACKETS_SERVICE1PACKETS_H_ -#define MISSION_PUS_SERVICEPACKETS_SERVICE1PACKETS_H_ - #include "../../serialize/SerializeAdapter.h" #include "../../tmtcservices/VerificationCodes.h" diff --git a/pus/servicepackets/Service200Packets.h b/pus/servicepackets/Service200Packets.h index efcf65fc..cb9ad4a7 100644 --- a/pus/servicepackets/Service200Packets.h +++ b/pus/servicepackets/Service200Packets.h @@ -1,5 +1,5 @@ -#ifndef FRAMEWORK_PUS_SERVICEPACKETS_SERVICE200PACKETS_H_ -#define FRAMEWORK_PUS_SERVICEPACKETS_SERVICE200PACKETS_H_ +#ifndef FSFW_PUS_SERVICEPACKETS_SERVICE200PACKETS_H_ +#define FSFW_PUS_SERVICEPACKETS_SERVICE200PACKETS_H_ #include "../../serialize/SerialLinkedListAdapter.h" #include "../../modes/ModeMessage.h" @@ -60,4 +60,4 @@ public: SerializeElement reason; //!< [EXPORT] : [COMMENT] Reason the mode could not be reached }; -#endif /* FRAMEWORK_PUS_SERVICEPACKETS_SERVICE200PACKETS_H_ */ +#endif /* FSFW_PUS_SERVICEPACKETS_SERVICE200PACKETS_H_ */ diff --git a/pus/servicepackets/Service2Packets.h b/pus/servicepackets/Service2Packets.h index d4f3fb17..285a8f9f 100644 --- a/pus/servicepackets/Service2Packets.h +++ b/pus/servicepackets/Service2Packets.h @@ -1,5 +1,5 @@ -#ifndef FRAMEWORK_PUS_SERVICEPACKETS_SERVICE2PACKETS_H_ -#define FRAMEWORK_PUS_SERVICEPACKETS_SERVICE2PACKETS_H_ +#ifndef FSFW_PUS_SERVICEPACKETS_SERVICE2PACKETS_H_ +#define FSFW_PUS_SERVICEPACKETS_SERVICE2PACKETS_H_ #include "../../action/ActionMessage.h" #include "../../objectmanager/SystemObjectIF.h" @@ -73,4 +73,4 @@ public: } }; -#endif /* FRAMEWORK_PUS_SERVICEPACKETS_SERVICE2PACKETS_H_ */ +#endif /* FSFW_PUS_SERVICEPACKETS_SERVICE2PACKETS_H_ */ diff --git a/pus/servicepackets/Service5Packets.h b/pus/servicepackets/Service5Packets.h index 9655608a..f903d6a2 100644 --- a/pus/servicepackets/Service5Packets.h +++ b/pus/servicepackets/Service5Packets.h @@ -1,5 +1,5 @@ -#ifndef MISSION_PUS_SERVICEPACKETS_SERVICE5PACKETS_H_ -#define MISSION_PUS_SERVICEPACKETS_SERVICE5PACKETS_H_ +#ifndef FSFW_PUS_SERVICEPACKETS_SERVICE5PACKETS_H_ +#define FSFW_PUS_SERVICEPACKETS_SERVICE5PACKETS_H_ #include "../../serialize/SerializeAdapter.h" #include "../../tmtcservices/VerificationCodes.h" @@ -73,4 +73,4 @@ private: }; -#endif /* MISSION_PUS_SERVICEPACKETS_SERVICE5PACKETS_H_ */ +#endif /* FSFW_PUS_SERVICEPACKETS_SERVICE5PACKETS_H_ */ diff --git a/pus/servicepackets/Service8Packets.h b/pus/servicepackets/Service8Packets.h index 14f8b6e6..b026edf5 100644 --- a/pus/servicepackets/Service8Packets.h +++ b/pus/servicepackets/Service8Packets.h @@ -1,5 +1,5 @@ -#ifndef FRAMEWORK_PUS_SERVICEPACKETS_SERVICE8PACKETS_H_ -#define FRAMEWORK_PUS_SERVICEPACKETS_SERVICE8PACKETS_H_ +#ifndef FSFW_PUS_SERVICEPACKETS_SERVICE8PACKETS_H_ +#define FSFW_PUS_SERVICEPACKETS_SERVICE8PACKETS_H_ #include "../../action/ActionMessage.h" #include "../../objectmanager/SystemObjectIF.h" @@ -118,4 +118,4 @@ private: }; -#endif /* FRAMEWORK_PUS_SERVICEPACKETS_SERVICE8PACKETS_H_ */ +#endif /* FSFW_PUS_SERVICEPACKETS_SERVICE8PACKETS_H_ */ From 837a18135e2d643f52213ff1c1995af3d1cd9f2d Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 10 Oct 2020 17:41:51 +0200 Subject: [PATCH 181/192] subsystem folder update --- subsystem/Subsystem.cpp | 28 +++++++++++++------------ subsystem/Subsystem.h | 24 +++++++++++---------- subsystem/SubsystemBase.cpp | 18 +++++++--------- subsystem/SubsystemBase.h | 23 ++++++++++---------- subsystem/modes/HasModeSequenceIF.h | 6 +++--- subsystem/modes/ModeDefinitions.h | 21 ++++++++----------- subsystem/modes/ModeSequenceMessage.cpp | 25 ++++++---------------- subsystem/modes/ModeSequenceMessage.h | 9 ++++---- subsystem/modes/ModeStore.cpp | 2 ++ 9 files changed, 73 insertions(+), 83 deletions(-) diff --git a/subsystem/Subsystem.cpp b/subsystem/Subsystem.cpp index ba1f463c..9712d7d4 100644 --- a/subsystem/Subsystem.cpp +++ b/subsystem/Subsystem.cpp @@ -12,13 +12,10 @@ Subsystem::Subsystem(object_id_t setObjectId, object_id_t parent, uint32_t maxNumberOfSequences, uint32_t maxNumberOfTables) : SubsystemBase(setObjectId, parent, 0), isInTransition(false), childrenChangedHealth(false), currentTargetTable(), - targetMode(0), targetSubmode(SUBMODE_NONE), initialMode(0), - currentSequenceIterator(), modeTables(maxNumberOfTables), - modeSequences(maxNumberOfSequences) {} + targetSubmode(SUBMODE_NONE), currentSequenceIterator(), + modeTables(maxNumberOfTables), modeSequences(maxNumberOfSequences) {} -Subsystem::~Subsystem() { - //Auto-generated destructor stub -} +Subsystem::~Subsystem() {} ReturnValue_t Subsystem::checkSequence(HybridIterator iter, Mode_t fallbackSequence) { @@ -344,7 +341,8 @@ ReturnValue_t Subsystem::addSequence(ArrayList *sequence, ReturnValue_t result; - //Before initialize() is called, tables must not be checked as the children are not added yet. + //Before initialize() is called, tables must not be checked as the + //children are not added yet. //Sequences added before are checked by initialize() if (!preInit) { result = checkSequence( @@ -390,8 +388,8 @@ ReturnValue_t Subsystem::addTable(ArrayList *table, Mode_t id, ReturnValue_t result; - //Before initialize() is called, tables must not be checked as the children are not added yet. - //Tables added before are checked by initialize() + //Before initialize() is called, tables must not be checked as the children + //are not added yet. Tables added before are checked by initialize() if (!preInit) { result = checkTable( HybridIterator(table->front(), table->back())); @@ -582,12 +580,14 @@ void Subsystem::transitionFailed(ReturnValue_t failureCode, triggerEvent(MODE_TRANSITION_FAILED, failureCode, parameter); if (mode == targetMode) { //already tried going back to the current mode - //go into fallback mode, also set current mode to fallback mode, so we come here at the next fail + //go into fallback mode, also set current mode to fallback mode, + //so we come here at the next fail modeHelper.setForced(true); ReturnValue_t result; if ((result = checkSequence(getFallbackSequence(mode))) != RETURN_OK) { triggerEvent(FALLBACK_FAILED, result, getFallbackSequence(mode)); - isInTransition = false; //keep still and allow arbitrary mode commands to recover + //keep still and allow arbitrary mode commands to recover + isInTransition = false; return; } mode = getFallbackSequence(mode); @@ -651,8 +651,10 @@ void Subsystem::cantKeepMode() { modeHelper.setForced(true); - //already set the mode, so that we do not try to go back in our old mode when the transition fails + //already set the mode, so that we do not try to go back in our old mode + //when the transition fails mode = getFallbackSequence(mode); - //SHOULDDO: We should store submodes for fallback sequence as well, otherwise we should get rid of submodes completely. + //SHOULDDO: We should store submodes for fallback sequence as well, + //otherwise we should get rid of submodes completely. startTransition(mode, SUBMODE_NONE); } diff --git a/subsystem/Subsystem.h b/subsystem/Subsystem.h index 2b501574..9a3fcdfe 100644 --- a/subsystem/Subsystem.h +++ b/subsystem/Subsystem.h @@ -1,13 +1,14 @@ -#ifndef SUBSYSTEM_H_ -#define SUBSYSTEM_H_ +#ifndef FSFW_SUBSYSTEM_SUBSYSTEM_H_ +#define FSFW_SUBSYSTEM_SUBSYSTEM_H_ + +#include "SubsystemBase.h" +#include "modes/ModeDefinitions.h" #include "../container/FixedArrayList.h" #include "../container/FixedMap.h" #include "../container/HybridIterator.h" #include "../container/SinglyLinkedList.h" #include "../serialize/SerialArrayListAdapter.h" -#include "../subsystem/modes/ModeDefinitions.h" -#include "../subsystem/SubsystemBase.h" class Subsystem: public SubsystemBase, public HasModeSequenceIF { public: @@ -44,11 +45,11 @@ public: void setInitialMode(Mode_t mode); - virtual ReturnValue_t initialize(); + virtual ReturnValue_t initialize() override; - virtual ReturnValue_t checkObjectConnections(); + virtual ReturnValue_t checkObjectConnections() override; - virtual MessageQueueId_t getSequenceCommandQueue() const; + virtual MessageQueueId_t getSequenceCommandQueue() const override; /** * @@ -96,11 +97,11 @@ protected: HybridIterator currentTargetTable; - Mode_t targetMode; + Mode_t targetMode = 0; Submode_t targetSubmode; - Mode_t initialMode; + Mode_t initialMode = 0; HybridIterator currentSequenceIterator; @@ -153,7 +154,8 @@ protected: virtual void startTransition(Mode_t mode, Submode_t submode); - void sendSerializablesAsCommandMessage(Command_t command, SerializeIF **elements, uint8_t count); + void sendSerializablesAsCommandMessage(Command_t command, + SerializeIF **elements, uint8_t count); void transitionFailed(ReturnValue_t failureCode, uint32_t parameter); @@ -161,4 +163,4 @@ protected: }; -#endif /* SUBSYSTEM_H_ */ +#endif /* FSFW_SUBSYSTEM_SUBSYSTEM_H_ */ diff --git a/subsystem/SubsystemBase.cpp b/subsystem/SubsystemBase.cpp index 17599808..f60c8847 100644 --- a/subsystem/SubsystemBase.cpp +++ b/subsystem/SubsystemBase.cpp @@ -6,10 +6,10 @@ SubsystemBase::SubsystemBase(object_id_t setObjectId, object_id_t parent, Mode_t initialMode, uint16_t commandQueueDepth) : SystemObject(setObjectId), mode(initialMode), submode(SUBMODE_NONE), - childrenChangedMode(false), commandsOutstanding(0), commandQueue(NULL), + childrenChangedMode(false), + commandQueue(QueueFactory::instance()->createMessageQueue( + commandQueueDepth, CommandMessage::MAX_MESSAGE_SIZE)), healthHelper(this, setObjectId), modeHelper(this), parentId(parent) { - commandQueue = QueueFactory::instance()->createMessageQueue(commandQueueDepth, - MessageQueueMessage::MAX_MESSAGE_SIZE); } SubsystemBase::~SubsystemBase() { @@ -21,7 +21,8 @@ ReturnValue_t SubsystemBase::registerChild(object_id_t objectId) { ChildInfo info; HasModesIF *child = objectManager->get(objectId); - //This is a rather ugly hack to have the changedHealth info for all children available. (needed for FOGs). + // This is a rather ugly hack to have the changedHealth info for all + // children available. HasHealthIF* healthChild = objectManager->get(objectId); if (child == nullptr) { if (healthChild == nullptr) { @@ -38,14 +39,11 @@ ReturnValue_t SubsystemBase::registerChild(object_id_t objectId) { info.submode = SUBMODE_NONE; info.healthChanged = false; - std::pair::iterator, bool> returnValue = - childrenMap.insert( - std::pair(objectId, info)); - if (!(returnValue.second)) { + auto resultPair = childrenMap.emplace(objectId, info); + if (not resultPair.second) { return COULD_NOT_INSERT_CHILD; - } else { - return RETURN_OK; } + return RETURN_OK; } ReturnValue_t SubsystemBase::checkStateAgainstTable( diff --git a/subsystem/SubsystemBase.h b/subsystem/SubsystemBase.h index 2d949b56..b8e4f902 100644 --- a/subsystem/SubsystemBase.h +++ b/subsystem/SubsystemBase.h @@ -1,5 +1,7 @@ -#ifndef SUBSYSTEMBASE_H_ -#define SUBSYSTEMBASE_H_ +#ifndef FSFW_SUBSYSTEM_SUBSYSTEMBASE_H_ +#define FSFW_SUBSYSTEM_SUBSYSTEMBASE_H_ + +#include "modes/HasModeSequenceIF.h" #include "../container/HybridIterator.h" #include "../health/HasHealthIF.h" @@ -7,7 +9,6 @@ #include "../modes/HasModesIF.h" #include "../objectmanager/SystemObject.h" #include "../returnvalues/HasReturnvaluesIF.h" -#include "../subsystem/modes/HasModeSequenceIF.h" #include "../tasks/ExecutableObjectIF.h" #include "../ipc/MessageQueueIF.h" #include @@ -34,17 +35,17 @@ public: Mode_t initialMode = 0, uint16_t commandQueueDepth = 8); virtual ~SubsystemBase(); - virtual MessageQueueId_t getCommandQueue() const; + virtual MessageQueueId_t getCommandQueue() const override; ReturnValue_t registerChild(object_id_t objectId); - virtual ReturnValue_t initialize(); + virtual ReturnValue_t initialize() override; - virtual ReturnValue_t performOperation(uint8_t opCode); + virtual ReturnValue_t performOperation(uint8_t opCode) override; - virtual ReturnValue_t setHealth(HealthState health); + virtual ReturnValue_t setHealth(HealthState health) override; - virtual HasHealthIF::HealthState getHealth(); + virtual HasHealthIF::HealthState getHealth() override; protected: struct ChildInfo { @@ -62,9 +63,9 @@ protected: /** * Always check this against <=0, so you are robust against too many replies */ - int32_t commandsOutstanding; + int32_t commandsOutstanding = 0; - MessageQueueIF* commandQueue; + MessageQueueIF* commandQueue = nullptr; HealthHelper healthHelper; @@ -126,4 +127,4 @@ protected: virtual void modeChanged(); }; -#endif /* SUBSYSTEMBASE_H_ */ +#endif /* FSFW_SUBSYSTEM_SUBSYSTEMBASE_H_ */ diff --git a/subsystem/modes/HasModeSequenceIF.h b/subsystem/modes/HasModeSequenceIF.h index 06bde2aa..70b1667e 100644 --- a/subsystem/modes/HasModeSequenceIF.h +++ b/subsystem/modes/HasModeSequenceIF.h @@ -1,9 +1,9 @@ #ifndef HASMODESEQUENCEIF_H_ #define HASMODESEQUENCEIF_H_ -#include "../../subsystem/modes/ModeDefinitions.h" -#include "../../subsystem/modes/ModeSequenceMessage.h" -#include "../../subsystem/modes/ModeStoreIF.h" +#include "ModeDefinitions.h" +#include "ModeSequenceMessage.h" +#include "ModeStoreIF.h" class HasModeSequenceIF { diff --git a/subsystem/modes/ModeDefinitions.h b/subsystem/modes/ModeDefinitions.h index a865ab0c..13a780ee 100644 --- a/subsystem/modes/ModeDefinitions.h +++ b/subsystem/modes/ModeDefinitions.h @@ -1,22 +1,19 @@ -#ifndef MODEDEFINITIONS_H_ -#define MODEDEFINITIONS_H_ +#ifndef FSFW_SUBSYSTEM_MODES_MODEDEFINITIONS_H_ +#define FSFW_SUBSYSTEM_MODES_MODEDEFINITIONS_H_ #include "../../modes/HasModesIF.h" #include "../../objectmanager/SystemObjectIF.h" #include "../../serialize/SerializeIF.h" #include "../../serialize/SerialLinkedListAdapter.h" + class ModeListEntry: public SerializeIF, public LinkedElement { public: - ModeListEntry() : - LinkedElement(this), value1(0), value2(0), value3(0), value4( - 0) { + ModeListEntry(): LinkedElement(this) {} - } - - uint32_t value1; - uint32_t value2; - uint8_t value3; - uint8_t value4; + uint32_t value1 = 0; + uint32_t value2 = 0; + uint8_t value3 = 0; + uint8_t value4 = 0; virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, Endianness streamEndianness) const { @@ -149,4 +146,4 @@ public: } }; -#endif //MODEDEFINITIONS_H_ +#endif /* FSFW_SUBSYSTEM_MODES_MODEDEFINITIONS_H_ */ diff --git a/subsystem/modes/ModeSequenceMessage.cpp b/subsystem/modes/ModeSequenceMessage.cpp index e092380e..7733098e 100644 --- a/subsystem/modes/ModeSequenceMessage.cpp +++ b/subsystem/modes/ModeSequenceMessage.cpp @@ -1,8 +1,7 @@ -#include "../../objectmanager/ObjectManagerIF.h" -#include "../../objectmanager/ObjectManagerIF.h" +#include "ModeSequenceMessage.h" + #include "../../objectmanager/ObjectManagerIF.h" #include "../../storagemanager/StorageManagerIF.h" -#include "../../subsystem/modes/ModeSequenceMessage.h" void ModeSequenceMessage::setModeSequenceMessage(CommandMessage* message, Command_t command, Mode_t sequence, store_address_t storeAddress) { @@ -11,25 +10,12 @@ void ModeSequenceMessage::setModeSequenceMessage(CommandMessage* message, message->setParameter2(sequence); } -//void ModeSequenceMessage::setModeSequenceMessage(CommandMessage* message, -// Command_t command, ModeTableId_t table, store_address_t storeAddress) { -// message->setCommand(command); -// message->setParameter(storeAddress.raw); -// message->setParameter2(table); -//} - void ModeSequenceMessage::setModeSequenceMessage(CommandMessage* message, Command_t command, Mode_t sequence) { message->setCommand(command); message->setParameter2(sequence); } -//void ModeSequenceMessage::setModeSequenceMessage(CommandMessage* message, -// Command_t command, ModeTableId_t table) { -// message->setCommand(command); -// message->setParameter2(table); -//} - void ModeSequenceMessage::setModeSequenceMessage(CommandMessage* message, Command_t command, store_address_t storeAddress) { message->setCommand(command); @@ -63,9 +49,10 @@ void ModeSequenceMessage::clear(CommandMessage *message) { case SEQUENCE_LIST: case TABLE_LIST: case TABLE: - case SEQUENCE:{ - StorageManagerIF *ipcStore = objectManager->get(objects::IPC_STORE); - if (ipcStore != NULL){ + case SEQUENCE: { + StorageManagerIF *ipcStore = objectManager->get( + objects::IPC_STORE); + if (ipcStore != nullptr){ ipcStore->deleteData(ModeSequenceMessage::getStoreAddress(message)); } } diff --git a/subsystem/modes/ModeSequenceMessage.h b/subsystem/modes/ModeSequenceMessage.h index 61ba30f3..9be4586e 100644 --- a/subsystem/modes/ModeSequenceMessage.h +++ b/subsystem/modes/ModeSequenceMessage.h @@ -1,9 +1,10 @@ -#ifndef MODESEQUENCEMESSAGE_H_ -#define MODESEQUENCEMESSAGE_H_ +#ifndef FSFW_SUBSYSTEM_MODES_MODESEQUENCEMESSAGE_H_ +#define FSFW_SUBSYSTEM_MODES_MODESEQUENCEMESSAGE_H_ +#include "ModeDefinitions.h" #include "../../ipc/CommandMessage.h" #include "../../storagemanager/StorageManagerIF.h" -#include "../../subsystem/modes/ModeDefinitions.h" + class ModeSequenceMessage { public: @@ -45,4 +46,4 @@ private: ModeSequenceMessage(); }; -#endif /* MODESEQUENCEMESSAGE_H_ */ +#endif /* FSFW_SUBSYSTEM_MODES_MODESEQUENCEMESSAGE_H_ */ diff --git a/subsystem/modes/ModeStore.cpp b/subsystem/modes/ModeStore.cpp index dce2931c..260e5ab2 100644 --- a/subsystem/modes/ModeStore.cpp +++ b/subsystem/modes/ModeStore.cpp @@ -1,5 +1,7 @@ #include "../../subsystem/modes/ModeStore.h" +// todo: I think some parts are deprecated. If this is used, the define +// USE_MODESTORE could be part of the new FSFWConfig.h file. #ifdef USE_MODESTORE ModeStore::ModeStore(object_id_t objectId, uint32_t slots) : From bc0402faf7c819d5b63630bc209444b3c2df89bb Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 10 Oct 2020 17:49:50 +0200 Subject: [PATCH 182/192] health update --- health/HasHealthIF.h | 9 +++------ health/HealthHelper.h | 42 +++++++++++++++++++++++++----------------- health/HealthTable.h | 5 +++-- 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/health/HasHealthIF.h b/health/HasHealthIF.h index d5321a6d..86863ea8 100644 --- a/health/HasHealthIF.h +++ b/health/HasHealthIF.h @@ -35,18 +35,15 @@ public: virtual MessageQueueId_t getCommandQueue() const = 0; /** - * set the Health State - * + * @brief Set the Health State * The parent will be informed, if the Health changes - * * @param health */ virtual ReturnValue_t setHealth(HealthState health) = 0; /** - * get Health State - * - * @return Health State of the object + * @brief Get Health State + * @return Health State of the object */ virtual HasHealthIF::HealthState getHealth() = 0; }; diff --git a/health/HealthHelper.h b/health/HealthHelper.h index 813123b2..08889fba 100644 --- a/health/HealthHelper.h +++ b/health/HealthHelper.h @@ -12,13 +12,15 @@ #include "../returnvalues/HasReturnvaluesIF.h" /** - * Helper class for Objects that implement HasHealthIF + * @brief Helper class for Objects that implement HasHealthIF + * @details + * It takes care of registering with the Health Table as well as handling + * health commands (including replying to the sender) and updating + * the Health Table. * - * It takes care of registering with the Health Table as well as handling health commands - * (including replying to the sender) and updating the Health Table. - * - * If a parent is set in the ctor, the parent will be informed with a @c HEALTH_INFO message - * about changes in the health state. Note that a @c HEALTH_INFO is only generated if the Health + * If a parent is set in the ctor, the parent will be informed with a + * @c HEALTH_INFO message about changes in the health state. + * Note that a @c HEALTH_INFO is only generated if the Health * changes, not for all @c HEALTH_SET commands received. * * It does NOT handle @c HEALTH_INFO messages @@ -27,10 +29,9 @@ class HealthHelper { public: /** - * ctor - * * @param owner - * @param objectId the object Id to use when communication with the HealthTable + * @param objectId The object Id to use when communication with + * the HealthTable */ HealthHelper(HasHealthIF* owner, object_id_t objectId); @@ -56,8 +57,9 @@ public: * * @param message * @return - * -@c RETURN_OK if the message was handled - * -@c RETURN_FAILED if the message could not be handled (ie it was not a @c HEALTH_SET or @c HEALTH_READ message) + * -@c RETURN_OK if the message was handled + * -@c RETURN_FAILED if the message could not be handled + * (ie it was not a @c HEALTH_SET or @c HEALTH_READ message) */ ReturnValue_t handleHealthCommand(CommandMessage *message); @@ -78,16 +80,19 @@ public: HasHealthIF::HealthState getHealth(); /** - * @param parentQueue the Queue id of the parent object. Set to 0 if no parent present + * @param parentQueue The queue ID of the parent object. + * Set to 0 if no parent present */ void setParentQueue(MessageQueueId_t parentQueue); /** * - * @param parentQueue the Queue id of the parent object. Set to 0 if no parent present + * @param parentQueue The queue ID of the parent object. + * Set to 0 if no parent present * @return - * -@c RETURN_OK if the Health Table was found and the object could be registered - * -@c RETURN_FAILED else + * -@c RETURN_OK if the Health Table was found and the object + * could be registered + * -@c RETURN_FAILED else */ ReturnValue_t initialize(MessageQueueId_t parentQueue ); @@ -110,8 +115,11 @@ private: HasHealthIF* owner; /** - * if the #parentQueue is not NULL, a @c HEALTH_INFO message will be sent to this queue - * @param health the health is passed as parameter so that the number of calls to the health table can be minimized + * if the #parentQueue is not NULL, a @c HEALTH_INFO message + * will be sent to this queue + * @param health + * The health is passed as parameter so that the number of + * calls to the health table can be minimized * @param oldHealth information of the previous health state. */ void informParent(HasHealthIF::HealthState health, diff --git a/health/HealthTable.h b/health/HealthTable.h index c5ebb5d4..945fb2e6 100644 --- a/health/HealthTable.h +++ b/health/HealthTable.h @@ -6,8 +6,6 @@ #include "../ipc/MutexIF.h" #include -typedef std::map HealthMap; -using HealthEntry = std::pair; class HealthTable: public HealthTableIF, public SystemObject { public: @@ -28,6 +26,9 @@ public: virtual HasHealthIF::HealthState getHealth(object_id_t) override; protected: + using HealthMap = std::map; + using HealthEntry = std::pair; + MutexIF* mutex; HealthMap healthMap; From 01e7a98425f8fd09b08d8f0e8edbbe9bed695de6 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 10 Oct 2020 17:55:38 +0200 Subject: [PATCH 183/192] added announce all subservice --- health/HealthMessage.cpp | 6 ++++-- health/HealthMessage.h | 11 +++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/health/HealthMessage.cpp b/health/HealthMessage.cpp index 1bb29526..52479c26 100644 --- a/health/HealthMessage.cpp +++ b/health/HealthMessage.cpp @@ -7,11 +7,13 @@ void HealthMessage::setHealthMessage(CommandMessage* message, Command_t command, message->setParameter2(oldHealth); } -void HealthMessage::setHealthMessage(CommandMessage* message, Command_t command) { +void HealthMessage::setHealthMessage(CommandMessage* message, + Command_t command) { message->setCommand(command); } -HasHealthIF::HealthState HealthMessage::getHealth(const CommandMessage* message) { +HasHealthIF::HealthState HealthMessage::getHealth( + const CommandMessage* message) { return (HasHealthIF::HealthState) message->getParameter(); } diff --git a/health/HealthMessage.h b/health/HealthMessage.h index de4923ab..fb979c66 100644 --- a/health/HealthMessage.h +++ b/health/HealthMessage.h @@ -7,17 +7,20 @@ class HealthMessage { public: static const uint8_t MESSAGE_ID = messagetypes::HEALTH_COMMAND; - // REPLY_COMMAND_OK/REPLY_REJECTED + static const Command_t HEALTH_SET = MAKE_COMMAND_ID(1); - // NO REPLY! - static const Command_t HEALTH_ANNOUNCE = MAKE_COMMAND_ID(3); + // No reply expected, health will be announced as event! + static const Command_t HEALTH_ANNOUNCE = MAKE_COMMAND_ID(2); + // Same as before, but all objects in health table will + // announce their health as events. + static const Command_t HEALTH_ANNOUNCE_ALL = MAKE_COMMAND_ID(3); + static const Command_t HEALTH_INFO = MAKE_COMMAND_ID(5); static const Command_t REPLY_HEALTH_SET = MAKE_COMMAND_ID(6); static void setHealthMessage(CommandMessage *message, Command_t command, HasHealthIF::HealthState health, HasHealthIF::HealthState oldHealth = HasHealthIF::FAULTY); - static void setHealthMessage(CommandMessage *message, Command_t command); static HasHealthIF::HealthState getHealth(const CommandMessage *message); From b9c7d1bd3f77f8d2da1e7376ef55df99ea26ec92 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 10 Oct 2020 18:09:04 +0200 Subject: [PATCH 184/192] added health subservices --- pus/CService200ModeCommanding.cpp | 5 ++- pus/CService200ModeCommanding.h | 5 +-- pus/CService201HealthCommanding.cpp | 54 +++++++++++++++++--------- pus/CService201HealthCommanding.h | 17 +++++--- pus/servicepackets/Service201Packets.h | 4 +- 5 files changed, 54 insertions(+), 31 deletions(-) diff --git a/pus/CService200ModeCommanding.cpp b/pus/CService200ModeCommanding.cpp index c63b47a6..c4e99359 100644 --- a/pus/CService200ModeCommanding.cpp +++ b/pus/CService200ModeCommanding.cpp @@ -7,9 +7,10 @@ #include "../modes/ModeMessage.h" CService200ModeCommanding::CService200ModeCommanding(object_id_t objectId, - uint16_t apid, uint8_t serviceId): + uint16_t apid, uint8_t serviceId, uint8_t numParallelCommands, + uint16_t commandTimeoutSeconds): CommandingServiceBase(objectId, apid, serviceId, - NUMBER_OF_PARALLEL_COMMANDS,COMMAND_TIMEOUT_SECONDS) {} + numParallelCommands, commandTimeoutSeconds) {} CService200ModeCommanding::~CService200ModeCommanding() {} diff --git a/pus/CService200ModeCommanding.h b/pus/CService200ModeCommanding.h index c86d7b84..84040212 100644 --- a/pus/CService200ModeCommanding.h +++ b/pus/CService200ModeCommanding.h @@ -15,11 +15,10 @@ */ class CService200ModeCommanding: public CommandingServiceBase { public: - static constexpr uint8_t NUMBER_OF_PARALLEL_COMMANDS = 4; - static constexpr uint16_t COMMAND_TIMEOUT_SECONDS = 60; CService200ModeCommanding(object_id_t objectId, - uint16_t apid, uint8_t serviceId); + uint16_t apid, uint8_t serviceId, uint8_t numParallelCommands = 4, + uint16_t commandTimeoutSeconds = 60); virtual~ CService200ModeCommanding(); protected: diff --git a/pus/CService201HealthCommanding.cpp b/pus/CService201HealthCommanding.cpp index 7e68533d..db43db89 100644 --- a/pus/CService201HealthCommanding.cpp +++ b/pus/CService201HealthCommanding.cpp @@ -6,9 +6,10 @@ #include "servicepackets/Service201Packets.h" CService201HealthCommanding::CService201HealthCommanding(object_id_t objectId, - uint16_t apid, uint8_t serviceId): + uint16_t apid, uint8_t serviceId, uint8_t numParallelCommands, + uint16_t commandTimeoutSeconds): CommandingServiceBase(objectId, apid, serviceId, - NUMBER_OF_PARALLEL_COMMANDS,COMMAND_TIMEOUT_SECONDS) { + numParallelCommands, commandTimeoutSeconds) { } CService201HealthCommanding::~CService201HealthCommanding() { @@ -17,6 +18,8 @@ CService201HealthCommanding::~CService201HealthCommanding() { ReturnValue_t CService201HealthCommanding::isValidSubservice(uint8_t subservice) { switch(subservice) { case(Subservice::COMMAND_SET_HEALTH): + case(Subservice::COMMAND_ANNOUNCE_HEALTH): + case(Subservice::COMMAND_ANNOUNCE_HEALTH_ALL): return RETURN_OK; default: sif::error << "Invalid Subservice" << std::endl; @@ -47,19 +50,34 @@ ReturnValue_t CService201HealthCommanding::checkInterfaceAndAcquireMessageQueue( return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t CService201HealthCommanding::prepareCommand - (CommandMessage* message, uint8_t subservice, const uint8_t *tcData, +ReturnValue_t CService201HealthCommanding::prepareCommand( + CommandMessage* message, uint8_t subservice, const uint8_t *tcData, size_t tcDataLen, uint32_t *state, object_id_t objectId) { - HealthCommand healthCommand; - ReturnValue_t result = healthCommand.deSerialize(&tcData, &tcDataLen, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - return result; - } else { - HealthMessage::setHealthMessage(message, HealthMessage::HEALTH_SET, - healthCommand.getHealth()); - return result; - } + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + switch(subservice) { + case(Subservice::COMMAND_SET_HEALTH): { + HealthSetCommand healthCommand; + result = healthCommand.deSerialize(&tcData, &tcDataLen, + SerializeIF::Endianness::BIG); + if (result != RETURN_OK) { + break; + } + HealthMessage::setHealthMessage(message, HealthMessage::HEALTH_SET, + healthCommand.getHealth()); + break; + } + case(Subservice::COMMAND_ANNOUNCE_HEALTH): { + HealthMessage::setHealthMessage(message, + HealthMessage::HEALTH_ANNOUNCE); + break; + } + case(Subservice::COMMAND_ANNOUNCE_HEALTH_ALL): { + HealthMessage::setHealthMessage(message, + HealthMessage::HEALTH_ANNOUNCE_ALL); + break; + } + } + return result; } ReturnValue_t CService201HealthCommanding::handleReply @@ -68,17 +86,17 @@ ReturnValue_t CService201HealthCommanding::handleReply object_id_t objectId, bool *isStep) { Command_t replyId = reply->getCommand(); if (replyId == HealthMessage::REPLY_HEALTH_SET) { - prepareHealthSetReply(reply); + return prepareHealthSetReply(reply); } - return RETURN_OK; + return CommandingServiceBase::INVALID_REPLY; } -void CService201HealthCommanding::prepareHealthSetReply( +ReturnValue_t CService201HealthCommanding::prepareHealthSetReply( const CommandMessage* reply) { prepareHealthSetReply(reply); uint8_t health = static_cast(HealthMessage::getHealth(reply)); uint8_t oldHealth = static_cast(HealthMessage::getOldHealth(reply)); HealthSetReply healthSetReply(health, oldHealth); - sendTmPacket(Subservice::REPLY_HEALTH_SET, &healthSetReply); + return sendTmPacket(Subservice::REPLY_HEALTH_SET, &healthSetReply); } diff --git a/pus/CService201HealthCommanding.h b/pus/CService201HealthCommanding.h index 100f675e..124e2ac7 100644 --- a/pus/CService201HealthCommanding.h +++ b/pus/CService201HealthCommanding.h @@ -19,11 +19,10 @@ */ class CService201HealthCommanding: public CommandingServiceBase { public: - static const uint8_t NUMBER_OF_PARALLEL_COMMANDS = 4; - static const uint16_t COMMAND_TIMEOUT_SECONDS = 60; CService201HealthCommanding(object_id_t objectId, uint16_t apid, - uint8_t serviceId); + uint8_t serviceId, uint8_t numParallelCommands = 4, + uint16_t commandTimeoutSeconds = 60); virtual~ CService201HealthCommanding(); protected: /* CSB abstract function implementations */ @@ -47,11 +46,17 @@ private: ReturnValue_t checkInterfaceAndAcquireMessageQueue( MessageQueueId_t* MessageQueueToSet, object_id_t* objectId); - void prepareHealthSetReply(const CommandMessage *reply); + ReturnValue_t prepareHealthSetReply(const CommandMessage *reply); enum Subservice { - COMMAND_SET_HEALTH = 1, //!< [EXPORT] : [TC] Set health of target object - REPLY_HEALTH_SET = 2 //!< [EXPORT] : [TM] Reply to health set command which also provides old health + //! [EXPORT] : [TC] Set health of target object + COMMAND_SET_HEALTH = 1, + //! [EXPORT] : [TM] Reply to health set command which also provides old health + REPLY_HEALTH_SET = 2, + //! [EXPORT] : [TC] Commands object to announce their health as an event + COMMAND_ANNOUNCE_HEALTH = 3, + //! [EXPORT] : [TC] Commands all objects in the health map to announce their health + COMMAND_ANNOUNCE_HEALTH_ALL = 4 }; }; diff --git a/pus/servicepackets/Service201Packets.h b/pus/servicepackets/Service201Packets.h index 8dce88e5..aed821f9 100644 --- a/pus/servicepackets/Service201Packets.h +++ b/pus/servicepackets/Service201Packets.h @@ -5,10 +5,10 @@ #include "../../serialize/SerializeIF.h" #include "../../health/HasHealthIF.h" -class HealthCommand: public SerialLinkedListAdapter { //!< [EXPORT] : [SUBSERVICE] 1 +class HealthSetCommand: public SerialLinkedListAdapter { //!< [EXPORT] : [SUBSERVICE] 1 public: - HealthCommand() { + HealthSetCommand() { setLinks(); } From 670e9bfa0f4fa55fddfd3cbcd7669987e65aa3f5 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 10 Oct 2020 18:12:22 +0200 Subject: [PATCH 185/192] CMD/REPLY prefixes added --- pus/Service2DeviceAccess.cpp | 12 ++++++------ pus/Service2DeviceAccess.h | 12 ++++++++---- pus/Service8FunctionManagement.cpp | 4 ++-- pus/Service8FunctionManagement.h | 6 ++++-- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/pus/Service2DeviceAccess.cpp b/pus/Service2DeviceAccess.cpp index 878a13b0..3648b7eb 100644 --- a/pus/Service2DeviceAccess.cpp +++ b/pus/Service2DeviceAccess.cpp @@ -21,8 +21,8 @@ Service2DeviceAccess::~Service2DeviceAccess() {} ReturnValue_t Service2DeviceAccess::isValidSubservice(uint8_t subservice) { switch(static_cast(subservice)){ - case Subservice::RAW_COMMANDING: - case Subservice::TOGGLE_WIRETAPPING: + case Subservice::COMMAND_RAW_COMMANDING: + case Subservice::COMMAND_TOGGLE_WIRETAPPING: return HasReturnvaluesIF::RETURN_OK; default: sif::error << "Invalid Subservice" << std::endl; @@ -58,11 +58,11 @@ ReturnValue_t Service2DeviceAccess::prepareCommand(CommandMessage* message, uint8_t subservice, const uint8_t* tcData, size_t tcDataLen, uint32_t* state, object_id_t objectId) { switch(static_cast(subservice)){ - case Subservice::RAW_COMMANDING: { + case Subservice::COMMAND_RAW_COMMANDING: { return prepareRawCommand(message, tcData, tcDataLen); } break; - case Subservice::TOGGLE_WIRETAPPING: { + case Subservice::COMMAND_TOGGLE_WIRETAPPING: { return prepareWiretappingCommand(message, tcData, tcDataLen); } break; @@ -118,11 +118,11 @@ void Service2DeviceAccess::handleUnrequestedReply(CommandMessage* reply) { switch(reply->getCommand()) { case DeviceHandlerMessage::REPLY_RAW_COMMAND: sendWiretappingTm(reply, - static_cast(Subservice::WIRETAPPING_RAW_TC)); + static_cast(Subservice::REPLY_WIRETAPPING_RAW_TC)); break; case DeviceHandlerMessage::REPLY_RAW_REPLY: sendWiretappingTm(reply, - static_cast(Subservice::RAW_REPLY)); + static_cast(Subservice::REPLY_RAW)); break; default: sif::error << "Unknown message in Service2DeviceAccess::" diff --git a/pus/Service2DeviceAccess.h b/pus/Service2DeviceAccess.h index fa2ea75c..b62e6854 100644 --- a/pus/Service2DeviceAccess.h +++ b/pus/Service2DeviceAccess.h @@ -81,10 +81,14 @@ private: const uint8_t* tcData, size_t tcDataLen); enum class Subservice { - RAW_COMMANDING = 128, //!< [EXPORT] : [COMMAND] Command in device native protocol - TOGGLE_WIRETAPPING = 129, //!< [EXPORT] : [COMMAND] Toggle wiretapping of raw communication - RAW_REPLY = 130, //!< [EXPORT] : [REPLY] Includes wiretapping TM and normal TM raw replies from device - WIRETAPPING_RAW_TC = 131 //!< [EXPORT] : [REPLY] Wiretapping packets of commands built by device handler + //!< [EXPORT] : [COMMAND] Command in device native protocol + COMMAND_RAW_COMMANDING = 128, + //!< [EXPORT] : [COMMAND] Toggle wiretapping of raw communication + COMMAND_TOGGLE_WIRETAPPING = 129, + //!< [EXPORT] : [REPLY] Includes wiretapping TM and normal TM raw replies from device + REPLY_RAW = 130, + //!< [EXPORT] : [REPLY] Wiretapping packets of commands built by device handler + REPLY_WIRETAPPING_RAW_TC = 131 }; }; diff --git a/pus/Service8FunctionManagement.cpp b/pus/Service8FunctionManagement.cpp index c1c88a50..d710c56e 100644 --- a/pus/Service8FunctionManagement.cpp +++ b/pus/Service8FunctionManagement.cpp @@ -19,7 +19,7 @@ Service8FunctionManagement::~Service8FunctionManagement() {} ReturnValue_t Service8FunctionManagement::isValidSubservice( uint8_t subservice) { switch(static_cast(subservice)) { - case Subservice::DIRECT_COMMANDING: + case Subservice::COMMAND_DIRECT_COMMANDING: return HasReturnvaluesIF::RETURN_OK; default: return AcceptsTelecommandsIF::INVALID_SUBSERVICE; @@ -131,7 +131,7 @@ ReturnValue_t Service8FunctionManagement::handleDataReply( } DataReply dataReply(objectId, actionId, buffer, size); result = sendTmPacket(static_cast( - Subservice::DIRECT_COMMANDING_DATA_REPLY), &dataReply); + Subservice::REPLY_DIRECT_COMMANDING_DATA), &dataReply); auto deletionResult = IPCStore->deleteData(storeId); if(deletionResult != HasReturnvaluesIF::RETURN_OK) { diff --git a/pus/Service8FunctionManagement.h b/pus/Service8FunctionManagement.h index 292a5e36..00153cfb 100644 --- a/pus/Service8FunctionManagement.h +++ b/pus/Service8FunctionManagement.h @@ -52,8 +52,10 @@ protected: private: enum class Subservice { - DIRECT_COMMANDING = 128, //!< [EXPORT] : [COMMAND] Functional commanding - DIRECT_COMMANDING_DATA_REPLY = 130, //!< [EXPORT] : [REPLY] Data reply + //!< [EXPORT] : [COMMAND] Functional commanding + COMMAND_DIRECT_COMMANDING = 128, + //!< [EXPORT] : [REPLY] Data reply + REPLY_DIRECT_COMMANDING_DATA = 130, }; ReturnValue_t checkInterfaceAndAcquireMessageQueue( From 3e79d2e73ad239b5f1c4838178f35348ac5ca6b8 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 10 Oct 2020 20:04:01 +0200 Subject: [PATCH 186/192] added extended controller base --- controller/ControllerBase.cpp | 8 +- controller/ControllerBase.h | 30 +++---- controller/ExtendedControllerBase.cpp | 110 ++++++++++++++++++++++++++ controller/ExtendedControllerBase.h | 70 ++++++++++++++++ 4 files changed, 201 insertions(+), 17 deletions(-) create mode 100644 controller/ExtendedControllerBase.cpp create mode 100644 controller/ExtendedControllerBase.h diff --git a/controller/ControllerBase.cpp b/controller/ControllerBase.cpp index 4f50fe1f..45e678eb 100644 --- a/controller/ControllerBase.cpp +++ b/controller/ControllerBase.cpp @@ -9,7 +9,8 @@ ControllerBase::ControllerBase(object_id_t setObjectId, object_id_t parentId, SystemObject(setObjectId), parentId(parentId), mode(MODE_OFF), submode(SUBMODE_NONE), modeHelper(this), healthHelper(this, setObjectId), hkSwitcher(this) { - commandQueue = QueueFactory::instance()->createMessageQueue(commandQueueDepth); + commandQueue = QueueFactory::instance()->createMessageQueue( + commandQueueDepth); } ControllerBase::~ControllerBase() { @@ -56,8 +57,9 @@ MessageQueueId_t ControllerBase::getCommandQueue() const { void ControllerBase::handleQueue() { CommandMessage command; - ReturnValue_t result; - for (result = commandQueue->receiveMessage(&command); result == RETURN_OK; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + for (result = commandQueue->receiveMessage(&command); + result == RETURN_OK; result = commandQueue->receiveMessage(&command)) { result = modeHelper.handleModeCommand(&command); diff --git a/controller/ControllerBase.h b/controller/ControllerBase.h index 6c2ec1d6..25d3ab1f 100644 --- a/controller/ControllerBase.h +++ b/controller/ControllerBase.h @@ -11,9 +11,10 @@ #include "../datapool/HkSwitchHelper.h" /** - * @brief Generic base class for controller classes + * @brief Generic base class for controller classes * @details - * Implements common interfaces for controllers. + * Implements common interfaces for controllers, which generally have + * a mode and a health state. This avoids boilerplate code. */ class ControllerBase: public HasModesIF, public HasHealthIF, @@ -27,24 +28,18 @@ public: size_t commandQueueDepth = 3); virtual ~ControllerBase(); + /** SystemObject override */ virtual ReturnValue_t initialize() override; virtual MessageQueueId_t getCommandQueue() const override; - virtual ReturnValue_t performOperation(uint8_t opCode) override; - + /** HasHealthIF overrides */ virtual ReturnValue_t setHealth(HealthState health) override; - virtual HasHealthIF::HealthState getHealth() override; - /** - * Implementation of ExecutableObjectIF function - * - * Used to setup the reference of the task, that executes this component - * @param task_ Pointer to the taskIF of this task - */ - virtual void setTaskIF(PeriodicTaskIF* task_) override; - + /** ExecutableObjectIF overrides */ + virtual ReturnValue_t performOperation(uint8_t opCode) override; + virtual void setTaskIF(PeriodicTaskIF* task) override; virtual ReturnValue_t initializeAfterTaskCreation() override; protected: @@ -57,6 +52,9 @@ protected: */ virtual ReturnValue_t handleCommandMessage(CommandMessage *message) = 0; + /** + * Periodic helper, implemented by child class. + */ virtual void performControlOperation() = 0; virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, @@ -74,6 +72,7 @@ protected: HealthHelper healthHelper; + // Is this still needed? HkSwitchHelper hkSwitcher; /** @@ -82,13 +81,16 @@ protected: */ PeriodicTaskIF* executingTask = nullptr; - void handleQueue(); + /** Handle mode and health messages */ + virtual void handleQueue(); + /** Mode helpers */ virtual void modeChanged(Mode_t mode, Submode_t submode); virtual void startTransition(Mode_t mode, Submode_t submode); virtual void getMode(Mode_t *mode, Submode_t *submode); virtual void setToExternalControl(); virtual void announceMode(bool recursive); + /** HK helpers */ virtual void changeHK(Mode_t mode, Submode_t submode, bool enable); }; diff --git a/controller/ExtendedControllerBase.cpp b/controller/ExtendedControllerBase.cpp new file mode 100644 index 00000000..f3336e43 --- /dev/null +++ b/controller/ExtendedControllerBase.cpp @@ -0,0 +1,110 @@ +#include "ExtendedControllerBase.h" + + +ExtendedControllerBase::ExtendedControllerBase(object_id_t objectId, + object_id_t parentId, size_t commandQueueDepth): + ControllerBase(objectId, parentId, commandQueueDepth), + localPoolManager(this, commandQueue), + actionHelper(this, commandQueue) { +} + +ReturnValue_t ExtendedControllerBase::executeAction(ActionId_t actionId, + MessageQueueId_t commandedBy, const uint8_t *data, size_t size) { + // needs to be overriden and implemented by child class. + return HasReturnvaluesIF::RETURN_OK; +} + + + +ReturnValue_t ExtendedControllerBase::initializeLocalDataPool( + LocalDataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { + // needs to be overriden and implemented by child class. + return HasReturnvaluesIF::RETURN_OK; +} + +object_id_t ExtendedControllerBase::getObjectId() const { + return SystemObject::getObjectId(); +} + +LocalDataPoolManager* ExtendedControllerBase::getHkManagerHandle() { + return &localPoolManager; +} + +uint32_t ExtendedControllerBase::getPeriodicOperationFrequency() const { + return this->executingTask->getPeriodMs(); +} + +ReturnValue_t ExtendedControllerBase::handleCommandMessage( + CommandMessage *message) { + ReturnValue_t result = actionHelper.handleActionMessage(message); + if(result == HasReturnvaluesIF::RETURN_OK) { + return result; + } + return localPoolManager.handleHousekeepingMessage(message); +} + +void ExtendedControllerBase::handleQueue() { + CommandMessage command; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + for (result = commandQueue->receiveMessage(&command); + result == RETURN_OK; + result = commandQueue->receiveMessage(&command)) { + result = actionHelper.handleActionMessage(&command); + if (result == RETURN_OK) { + continue; + } + + result = modeHelper.handleModeCommand(&command); + if (result == RETURN_OK) { + continue; + } + + result = healthHelper.handleHealthCommand(&command); + if (result == RETURN_OK) { + continue; + } + + result = localPoolManager.handleHousekeepingMessage(&command); + if (result == RETURN_OK) { + continue; + } + + result = handleCommandMessage(&command); + if (result == RETURN_OK) { + continue; + } + command.setToUnknownCommand(); + commandQueue->reply(&command); + } +} + +ReturnValue_t ExtendedControllerBase::initialize() { + ReturnValue_t result = ControllerBase::initialize(); + if(result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = actionHelper.initialize(commandQueue); + if(result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + + return localPoolManager.initialize(commandQueue); +} + +ReturnValue_t ExtendedControllerBase::initializeAfterTaskCreation() { + return localPoolManager.initializeAfterTaskCreation(); +} + +ReturnValue_t ExtendedControllerBase::performOperation(uint8_t opCode) { + handleQueue(); + hkSwitcher.performOperation(); + localPoolManager.performHkOperation(); + performControlOperation(); + return RETURN_OK; +} + +LocalPoolDataSetBase* ExtendedControllerBase::getDataSetHandle(sid_t sid) { + sif::warning << "ExtendedControllerBase::getDataSetHandle: No child " + << " implementation provided, returning nullptr!" << std::endl; + return nullptr; +} diff --git a/controller/ExtendedControllerBase.h b/controller/ExtendedControllerBase.h new file mode 100644 index 00000000..fa47950a --- /dev/null +++ b/controller/ExtendedControllerBase.h @@ -0,0 +1,70 @@ +#ifndef FSFW_CONTROLLER_EXTENDEDCONTROLLERBASE_H_ +#define FSFW_CONTROLLER_EXTENDEDCONTROLLERBASE_H_ + +#include "ControllerBase.h" + +#include "../action/HasActionsIF.h" +#include "../datapoollocal/HasLocalDataPoolIF.h" +#include "../action/ActionHelper.h" +#include "../datapoollocal/LocalDataPoolManager.h" + +/** + * @brief Extendes the basic ControllerBase with the common components + * HasActionsIF for commandability and HasLocalDataPoolIF to keep + * a pool of local data pool variables. + * @details + * Default implementations required for the interfaces will be empty and have + * to be implemented by child class. + */ +class ExtendedControllerBase: public ControllerBase, + public HasActionsIF, + public HasLocalDataPoolIF { +public: + ExtendedControllerBase(object_id_t objectId, object_id_t parentId, + size_t commandQueueDepth = 3); + + /** SystemObjectIF overrides */ + virtual ReturnValue_t initialize() override; + + /** ExecutableObjectIF overrides */ + virtual ReturnValue_t performOperation(uint8_t opCode) override; + virtual ReturnValue_t initializeAfterTaskCreation() override; + +protected: + LocalDataPoolManager localPoolManager; + ActionHelper actionHelper; + + /** + * Implemented by child class. Handle all command messages which are + * not health, mode, action or housekeeping messages. + * @param message + * @return + */ + virtual ReturnValue_t handleCommandMessage(CommandMessage *message) = 0; + + /** + * Periodic helper from ControllerBase, implemented by child class. + */ + virtual void performControlOperation() = 0; + + /** Handle the four messages mentioned above */ + void handleQueue() override; + + /** HasActionsIF overrides */ + virtual ReturnValue_t executeAction(ActionId_t actionId, + MessageQueueId_t commandedBy, const uint8_t* data, + size_t size) override; + + /** HasLocalDatapoolIF overrides */ + virtual object_id_t getObjectId() const override; + virtual ReturnValue_t initializeLocalDataPool( + LocalDataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; + virtual LocalDataPoolManager* getHkManagerHandle() override; + virtual uint32_t getPeriodicOperationFrequency() const override; + virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; +}; + + + +#endif /* FSFW_CONTROLLER_EXTENDEDCONTROLLERBASE_H_ */ From ed71a3700435aa8532abd2764ddfa9d5be882235 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sat, 10 Oct 2020 20:11:20 +0200 Subject: [PATCH 187/192] get command queue override --- controller/ExtendedControllerBase.cpp | 4 ++++ controller/ExtendedControllerBase.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/controller/ExtendedControllerBase.cpp b/controller/ExtendedControllerBase.cpp index f3336e43..f69d2ea1 100644 --- a/controller/ExtendedControllerBase.cpp +++ b/controller/ExtendedControllerBase.cpp @@ -103,6 +103,10 @@ ReturnValue_t ExtendedControllerBase::performOperation(uint8_t opCode) { return RETURN_OK; } +MessageQueueId_t ExtendedControllerBase::getCommandQueue() const { + return commandQueue->getId(); +} + LocalPoolDataSetBase* ExtendedControllerBase::getDataSetHandle(sid_t sid) { sif::warning << "ExtendedControllerBase::getDataSetHandle: No child " << " implementation provided, returning nullptr!" << std::endl; diff --git a/controller/ExtendedControllerBase.h b/controller/ExtendedControllerBase.h index fa47950a..02c5728e 100644 --- a/controller/ExtendedControllerBase.h +++ b/controller/ExtendedControllerBase.h @@ -26,6 +26,8 @@ public: /** SystemObjectIF overrides */ virtual ReturnValue_t initialize() override; + virtual MessageQueueId_t getCommandQueue() const override; + /** ExecutableObjectIF overrides */ virtual ReturnValue_t performOperation(uint8_t opCode) override; virtual ReturnValue_t initializeAfterTaskCreation() override; From 18671a0db7357a0e209cc547d64271f84f8893af Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 12 Oct 2020 13:40:24 +0200 Subject: [PATCH 188/192] doc wrong --- action/HasActionsIF.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/action/HasActionsIF.h b/action/HasActionsIF.h index 886d0837..a26ed588 100644 --- a/action/HasActionsIF.h +++ b/action/HasActionsIF.h @@ -47,10 +47,9 @@ public: virtual MessageQueueId_t getCommandQueue() const = 0; /** * Execute or initialize the execution of a certain function. - * Returning #EXECUTION_FINISHED or a failure code, nothing else needs to - * be done. When needing more steps, return RETURN_OK and issue steps and - * completion manually. - * One "step failed" or completion report must be issued! + * When used in conjunction with the ActionHelper class, returning + * a return code which is not equal to RETURN_OK will trigger a step reply + * with step 0. */ virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, const uint8_t* data, size_t size) = 0; From b9ebd153a2d6e897b76c41d09f2f2f8d40c1d517 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 12 Oct 2020 16:55:40 +0200 Subject: [PATCH 189/192] added action helper function --- action/ActionHelper.cpp | 56 ++++++++++++++++++++++++++++++++++++----- action/ActionHelper.h | 15 +++++++++-- 2 files changed, 63 insertions(+), 8 deletions(-) diff --git a/action/ActionHelper.cpp b/action/ActionHelper.cpp index ab986c6c..9fd117f3 100644 --- a/action/ActionHelper.cpp +++ b/action/ActionHelper.cpp @@ -89,22 +89,28 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - result = data->serialize(&dataPtr, &size, maxSize, SerializeIF::Endianness::BIG); + result = data->serialize(&dataPtr, &size, maxSize, + SerializeIF::Endianness::BIG); if (result != HasReturnvaluesIF::RETURN_OK) { ipcStore->deleteData(storeAddress); return result; } - //We don't need to report the objectId, as we receive REQUESTED data before the completion success message. - //True aperiodic replies need to be reported with another dedicated message. + // We don't need to report the objectId, as we receive REQUESTED data + // before the completion success message. + // True aperiodic replies need to be reported with + // another dedicated message. ActionMessage::setDataReply(&reply, replyId, storeAddress); //TODO Service Implementation sucks at the moment - if (hideSender){ + // why does it suck and why would someone need to hide the sender? + if (hideSender) { result = MessageQueueSenderIF::sendMessage(reportTo, &reply); - } else { + } + else { result = queueToUse->sendMessage(reportTo, &reply); } - if ( result != HasReturnvaluesIF::RETURN_OK){ + + if (result != HasReturnvaluesIF::RETURN_OK){ ipcStore->deleteData(storeAddress); } return result; @@ -112,3 +118,41 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, void ActionHelper::resetHelper() { } + +ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, + ActionId_t replyId, const uint8_t *data, size_t dataSize, + bool hideSender) { + CommandMessage reply; + store_address_t storeAddress; + uint8_t *dataPtr = nullptr; + size_t size = 0; + ReturnValue_t result = ipcStore->addData(&storeAddress, data, dataSize); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + + if (result != HasReturnvaluesIF::RETURN_OK) { + ipcStore->deleteData(storeAddress); + return result; + } + + // We don't need to report the objectId, as we receive REQUESTED data + // before the completion success message. + // True aperiodic replies need to be reported with + // another dedicated message. + ActionMessage::setDataReply(&reply, replyId, storeAddress); + + //TODO Service Implementation sucks at the moment + // why does it suck and why would someone need to hide the sender? + if (hideSender) { + result = MessageQueueSenderIF::sendMessage(reportTo, &reply); + } + else { + result = queueToUse->sendMessage(reportTo, &reply); + } + + if (result != HasReturnvaluesIF::RETURN_OK){ + ipcStore->deleteData(storeAddress); + } + return result; +} diff --git a/action/ActionHelper.h b/action/ActionHelper.h index a20f286a..17ca3ebd 100644 --- a/action/ActionHelper.h +++ b/action/ActionHelper.h @@ -69,8 +69,8 @@ public: void finish(MessageQueueId_t reportTo, ActionId_t commandId, ReturnValue_t result = HasReturnvaluesIF::RETURN_OK); /** - * Function to be called by the owner if an action does report data - * + * Function to be called by the owner if an action does report data. + * Takes a SerializeIF* pointer and serializes it into the IPC store. * @param reportTo MessageQueueId_t to report the action completion * message to * @param replyId ID of the executed command @@ -79,6 +79,17 @@ public: */ ReturnValue_t reportData(MessageQueueId_t reportTo, ActionId_t replyId, SerializeIF* data, bool hideSender = false); + /** + * Function to be called by the owner if an action does report data. + * Takes the raw data and writes it into the IPC store. + * @param reportTo MessageQueueId_t to report the action completion + * message to + * @param replyId ID of the executed command + * @param data Pointer to the data + * @return Returns RETURN_OK if successful, otherwise failure code + */ + ReturnValue_t reportData(MessageQueueId_t reportTo, ActionId_t replyId, + const uint8_t* data, size_t dataSize, bool hideSender = false); /** * Function to setup the MessageQueueIF* of the helper. Can be used to * set the MessageQueueIF* if message queue is unavailable at construction From e4c74ec060df2beb86eb34f1b2a9a8b1193adbd8 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 12 Oct 2020 16:57:37 +0200 Subject: [PATCH 190/192] added todos --- action/ActionHelper.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/action/ActionHelper.cpp b/action/ActionHelper.cpp index 9fd117f3..8122885b 100644 --- a/action/ActionHelper.cpp +++ b/action/ActionHelper.cpp @@ -101,8 +101,8 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, // another dedicated message. ActionMessage::setDataReply(&reply, replyId, storeAddress); - //TODO Service Implementation sucks at the moment - // why does it suck and why would someone need to hide the sender? + // TODO: Service Implementation sucks at the moment + // TODO: why does it suck and why would someone need to hide the sender? if (hideSender) { result = MessageQueueSenderIF::sendMessage(reportTo, &reply); } @@ -124,8 +124,6 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, bool hideSender) { CommandMessage reply; store_address_t storeAddress; - uint8_t *dataPtr = nullptr; - size_t size = 0; ReturnValue_t result = ipcStore->addData(&storeAddress, data, dataSize); if (result != HasReturnvaluesIF::RETURN_OK) { return result; @@ -142,8 +140,8 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, // another dedicated message. ActionMessage::setDataReply(&reply, replyId, storeAddress); - //TODO Service Implementation sucks at the moment - // why does it suck and why would someone need to hide the sender? + // TODO: Service Implementation sucks at the moment + // TODO: why does it suck and why would someone need to hide the sender? if (hideSender) { result = MessageQueueSenderIF::sendMessage(reportTo, &reply); } From 06c7919daa1f30e93452d2fe284d7ff0ccae4a41 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 12 Oct 2020 17:39:13 +0200 Subject: [PATCH 191/192] monitoring form improvements --- monitoring/AbsLimitMonitor.h | 23 +++++++++++++++-------- monitoring/HasMonitorsIF.h | 12 +++--------- monitoring/MonitoringIF.h | 8 ++++---- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/monitoring/AbsLimitMonitor.h b/monitoring/AbsLimitMonitor.h index 2e60f6f8..c9c33c74 100644 --- a/monitoring/AbsLimitMonitor.h +++ b/monitoring/AbsLimitMonitor.h @@ -1,5 +1,5 @@ -#ifndef FRAMEWORK_MONITORING_ABSLIMITMONITOR_H_ -#define FRAMEWORK_MONITORING_ABSLIMITMONITOR_H_ +#ifndef FSFW_MONITORING_ABSLIMITMONITOR_H_ +#define FSFW_MONITORING_ABSLIMITMONITOR_H_ #include "MonitorBase.h" #include @@ -7,9 +7,14 @@ template class AbsLimitMonitor: public MonitorBase { public: - AbsLimitMonitor(object_id_t reporterId, uint8_t monitorId, uint32_t parameterId, - uint16_t confirmationLimit, T limit, Event violationEvent = MonitoringIF::VALUE_OUT_OF_RANGE, bool aboveIsViolation = true) : - MonitorBase(reporterId, monitorId, parameterId, confirmationLimit), limit(limit), violationEvent(violationEvent), aboveIsViolation(aboveIsViolation) { + AbsLimitMonitor(object_id_t reporterId, uint8_t monitorId, + uint32_t parameterId, uint16_t confirmationLimit, T limit, + Event violationEvent = MonitoringIF::VALUE_OUT_OF_RANGE, + bool aboveIsViolation = true) : + MonitorBase(reporterId, monitorId, parameterId, + confirmationLimit), + limit(limit), violationEvent(violationEvent), + aboveIsViolation(aboveIsViolation) { } virtual ~AbsLimitMonitor() { } @@ -32,7 +37,8 @@ public: const ParameterWrapper *newValues, uint16_t startAtIndex) { ReturnValue_t result = this->MonitorBase::getParameter(domainId, parameterId, parameterWrapper, newValues, startAtIndex); - //We'll reuse the DOMAIN_ID of MonitorReporter, as we know the parameterIds used there. + // We'll reuse the DOMAIN_ID of MonitorReporter, + // as we know the parameterIds used there. if (result != this->INVALID_MATRIX_ID) { return result; } @@ -59,7 +65,8 @@ protected: void sendTransitionEvent(T currentValue, ReturnValue_t state) { switch (state) { case MonitoringIF::OUT_OF_RANGE: - EventManagerIF::triggerEvent(this->reportingId, violationEvent, this->parameterId); + EventManagerIF::triggerEvent(this->reportingId, + violationEvent, this->parameterId); break; default: break; @@ -70,4 +77,4 @@ protected: const bool aboveIsViolation; }; -#endif /* FRAMEWORK_MONITORING_ABSLIMITMONITOR_H_ */ +#endif /* FSFW_MONITORING_ABSLIMITMONITOR_H_ */ diff --git a/monitoring/HasMonitorsIF.h b/monitoring/HasMonitorsIF.h index 85d92b6b..04f63437 100644 --- a/monitoring/HasMonitorsIF.h +++ b/monitoring/HasMonitorsIF.h @@ -1,11 +1,5 @@ -/** - * @file HasMonitorsIF.h - * @brief This file defines the HasMonitorsIF class. - * @date 28.07.2014 - * @author baetz - */ -#ifndef HASMONITORSIF_H_ -#define HASMONITORSIF_H_ +#ifndef FSFW_MONITORING_HASMONITORSIF_H_ +#define FSFW_MONITORING_HASMONITORSIF_H_ #include "../events/EventReportingProxyIF.h" #include "../objectmanager/ObjectManagerIF.h" @@ -27,4 +21,4 @@ public: } }; -#endif /* HASMONITORSIF_H_ */ +#endif /* FSFW_MONITORING_HASMONITORSIF_H_ */ diff --git a/monitoring/MonitoringIF.h b/monitoring/MonitoringIF.h index 44218c36..aa266f33 100644 --- a/monitoring/MonitoringIF.h +++ b/monitoring/MonitoringIF.h @@ -1,8 +1,8 @@ -#ifndef MONITORINGIF_H_ -#define MONITORINGIF_H_ +#ifndef FSFW_MONITORING_MONITORINGIF_H_ +#define FSFW_MONITORING_MONITORINGIF_H_ -#include "../memory/HasMemoryIF.h" #include "MonitoringMessage.h" +#include "../memory/HasMemoryIF.h" #include "../serialize/SerializeIF.h" class MonitoringIF : public SerializeIF { @@ -64,4 +64,4 @@ public: -#endif /* MONITORINGIF_H_ */ +#endif /* FSFW_MONITORING_MONITORINGIF_H_ */ From 736ce2d5fd199ed5c18eb2d59718ce4faa3b5cff Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 12 Oct 2020 17:42:30 +0200 Subject: [PATCH 192/192] some more form improvements --- monitoring/MonitorBase.h | 36 ++++++++++++++++++++++-------------- monitoring/MonitorReporter.h | 26 +++++++++++++++----------- 2 files changed, 37 insertions(+), 25 deletions(-) diff --git a/monitoring/MonitorBase.h b/monitoring/MonitorBase.h index 964fd55e..5f9a2caf 100644 --- a/monitoring/MonitorBase.h +++ b/monitoring/MonitorBase.h @@ -1,35 +1,42 @@ -#ifndef MONITORBASE_H_ -#define MONITORBASE_H_ +#ifndef FSFW_MONITORING_MONITORBASE_H_ +#define FSFW_MONITORING_MONITORBASE_H_ -#include "../datapoolglob/GlobalDataSet.h" -#include "../datapoolglob/PIDReader.h" #include "LimitViolationReporter.h" #include "MonitoringIF.h" #include "MonitoringMessageContent.h" #include "MonitorReporter.h" +#include "../datapoolglob/GlobalDataSet.h" +#include "../datapoolglob/PIDReader.h" + /** - * Base class for monitoring of parameters. - * Can be used anywhere, specializations need to implement checkSample and should override sendTransitionEvent. - * Manages state handling, enabling and disabling of events/reports and forwarding of transition - * reports via MonitorReporter. In addition, it provides default implementations for fetching the parameter sample from - * the data pool and a simple confirmation counter. + * @brief Base class for monitoring of parameters. + * @details + * Can be used anywhere, specializations need to implement checkSample and + * should override sendTransitionEvent. + * Manages state handling, enabling and disabling of events/reports and + * forwarding of transition reports via MonitorReporter. + * + * In addition, it provides default implementations for fetching the + * parameter sample from the data pool and a simple confirmation counter. */ template class MonitorBase: public MonitorReporter { public: MonitorBase(object_id_t reporterId, uint8_t monitorId, uint32_t parameterId, uint16_t confirmationLimit) : - MonitorReporter(reporterId, monitorId, parameterId, confirmationLimit) { + MonitorReporter(reporterId, monitorId, parameterId, + confirmationLimit) { } virtual ~MonitorBase() { } virtual ReturnValue_t check() { - //1. Fetch sample of type T, return validity. + // 1. Fetch sample of type T, return validity. T sample = 0; ReturnValue_t validity = fetchSample(&sample); - //2. If returning from fetch != OK, parameter is invalid. Report (if oldState is != invalidity). + // 2. If returning from fetch != OK, parameter is invalid. + // Report (if oldState is != invalidity). if (validity != HasReturnvaluesIF::RETURN_OK) { this->monitorStateIs(validity, sample, 0); //3. Otherwise, check sample. @@ -43,7 +50,8 @@ public: ReturnValue_t currentState = checkSample(sample, &crossedLimit); return this->monitorStateIs(currentState,sample, crossedLimit); } - //Abstract or default. + + // Abstract or default. virtual ReturnValue_t checkSample(T sample, T* crossedLimit) = 0; protected: @@ -59,4 +67,4 @@ protected: } }; -#endif /* MONITORBASE_H_ */ +#endif /* FSFW_MONITORING_MONITORBASE_H_ */ diff --git a/monitoring/MonitorReporter.h b/monitoring/MonitorReporter.h index ca2b534b..88fa6ede 100644 --- a/monitoring/MonitorReporter.h +++ b/monitoring/MonitorReporter.h @@ -1,10 +1,11 @@ -#ifndef FRAMEWORK_MONITORING_MONITORREPORTER_H_ -#define FRAMEWORK_MONITORING_MONITORREPORTER_H_ +#ifndef FSFW_MONITORING_MONITORREPORTER_H_ +#define FSFW_MONITORING_MONITORREPORTER_H_ -#include "../events/EventManagerIF.h" #include "LimitViolationReporter.h" #include "MonitoringIF.h" #include "MonitoringMessageContent.h" + +#include "../events/EventManagerIF.h" #include "../parameters/HasParametersIF.h" template @@ -14,11 +15,12 @@ public: static const uint8_t ENABLED = 1; static const uint8_t DISABLED = 0; - MonitorReporter(object_id_t reportingId, uint8_t monitorId, uint32_t parameterId, uint16_t confirmationLimit) : - monitorId(monitorId), parameterId(parameterId), reportingId( - reportingId), oldState(MonitoringIF::UNCHECKED), reportingEnabled( - ENABLED), eventEnabled(ENABLED), currentCounter(0), confirmationLimit( - confirmationLimit) { + MonitorReporter(object_id_t reportingId, uint8_t monitorId, + uint32_t parameterId, uint16_t confirmationLimit) : + monitorId(monitorId), parameterId(parameterId), + reportingId(reportingId), oldState(MonitoringIF::UNCHECKED), + reportingEnabled(ENABLED), eventEnabled(ENABLED), currentCounter(0), + confirmationLimit(confirmationLimit) { } virtual ~MonitorReporter() { @@ -148,7 +150,8 @@ protected: case HasReturnvaluesIF::RETURN_OK: break; default: - EventManagerIF::triggerEvent(reportingId, MonitoringIF::MONITOR_CHANGED_STATE, state); + EventManagerIF::triggerEvent(reportingId, + MonitoringIF::MONITOR_CHANGED_STATE, state); break; } } @@ -159,7 +162,8 @@ protected: * @param crossedLimit The limit crossed (if applicable). * @param state Current state the monitor is in. */ - virtual void sendTransitionReport(T parameterValue, T crossedLimit, ReturnValue_t state) { + virtual void sendTransitionReport(T parameterValue, T crossedLimit, + ReturnValue_t state) { MonitoringReportContent report(parameterId, parameterValue, crossedLimit, oldState, state); LimitViolationReporter::sendLimitViolationReport(&report); @@ -175,4 +179,4 @@ protected: } }; -#endif /* FRAMEWORK_MONITORING_MONITORREPORTER_H_ */ +#endif /* FSFW_MONITORING_MONITORREPORTER_H_ */