From 098741ffe6375a75c6248ec0c9c5f32100158c4d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 24 Oct 2022 10:14:58 +0200 Subject: [PATCH 001/373] start adding basic pus 15 components --- mission/tmtc/CMakeLists.txt | 3 ++- mission/tmtc/Service15TmStorage.cpp | 13 +++++++++++++ mission/tmtc/Service15TmStorage.h | 16 ++++++++++++++++ mission/tmtc/TmStoreBackend.cpp | 9 +++++++++ mission/tmtc/TmStoreBackend.h | 16 ++++++++++++++++ 5 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 mission/tmtc/Service15TmStorage.cpp create mode 100644 mission/tmtc/Service15TmStorage.h create mode 100644 mission/tmtc/TmStoreBackend.cpp create mode 100644 mission/tmtc/TmStoreBackend.h diff --git a/mission/tmtc/CMakeLists.txt b/mission/tmtc/CMakeLists.txt index f34f9ccc..2fdccc81 100644 --- a/mission/tmtc/CMakeLists.txt +++ b/mission/tmtc/CMakeLists.txt @@ -1,3 +1,4 @@ target_sources( ${LIB_EIVE_MISSION} PRIVATE CCSDSHandler.cpp VirtualChannel.cpp TmFunnel.cpp - CfdpTmFunnel.cpp PusTmFunnel.cpp) + CfdpTmFunnel.cpp PusTmFunnel.cpp Service15TmStorage.cpp + TmStoreBackend.cpp) diff --git a/mission/tmtc/Service15TmStorage.cpp b/mission/tmtc/Service15TmStorage.cpp new file mode 100644 index 00000000..1a441247 --- /dev/null +++ b/mission/tmtc/Service15TmStorage.cpp @@ -0,0 +1,13 @@ +#include "Service15TmStorage.h" + + +Service15TmStorage::Service15TmStorage(PsbParams params): PusServiceBase(params) { +} + +ReturnValue_t Service15TmStorage::handleRequest(uint8_t subservice) { + return returnvalue::OK; +} + +ReturnValue_t Service15TmStorage::performService() { + return returnvalue::OK; +} diff --git a/mission/tmtc/Service15TmStorage.h b/mission/tmtc/Service15TmStorage.h new file mode 100644 index 00000000..82856bec --- /dev/null +++ b/mission/tmtc/Service15TmStorage.h @@ -0,0 +1,16 @@ +#ifndef MISSION_TMTC_SERVICE15TMSTORAGE_H_ +#define MISSION_TMTC_SERVICE15TMSTORAGE_H_ + +#include "fsfw/tmtcservices/PusServiceBase.h" + +class Service15TmStorage: public PusServiceBase { +public: + explicit Service15TmStorage(PsbParams params); +private: + ReturnValue_t handleRequest(uint8_t subservice) override; + ReturnValue_t performService() override; +}; + + + +#endif /* MISSION_TMTC_SERVICE15TMSTORAGE_H_ */ diff --git a/mission/tmtc/TmStoreBackend.cpp b/mission/tmtc/TmStoreBackend.cpp new file mode 100644 index 00000000..4ffaa98b --- /dev/null +++ b/mission/tmtc/TmStoreBackend.cpp @@ -0,0 +1,9 @@ +#include "TmStoreBackend.h" + +const char* TmStoreBackend::getName() const { + return "TM Store Backend"; +} + +MessageQueueId_t TmStoreBackend::getReportReceptionQueue(uint8_t virtualChannel) const { + return MessageQueueIF::NO_QUEUE; +} diff --git a/mission/tmtc/TmStoreBackend.h b/mission/tmtc/TmStoreBackend.h new file mode 100644 index 00000000..d845d758 --- /dev/null +++ b/mission/tmtc/TmStoreBackend.h @@ -0,0 +1,16 @@ +#ifndef MISSION_TMTC_TMSTOREBACKEND_H_ +#define MISSION_TMTC_TMSTOREBACKEND_H_ + +#include + +class TmStoreBackend: public AcceptsTelemetryIF { +public: + + [[nodiscard]] const char* getName() const override; + [[nodiscard]] MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) const override; +private: +}; + + + +#endif /* MISSION_TMTC_TMSTOREBACKEND_H_ */ From e897fb63d805a0f5859b46faeaf800fcb4c977b5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 24 Oct 2022 10:26:00 +0200 Subject: [PATCH 002/373] use CSB backend instead --- mission/tmtc/CMakeLists.txt | 11 ++++++++--- mission/tmtc/Service15TmStorage.cpp | 28 +++++++++++++++++++++++----- mission/tmtc/Service15TmStorage.h | 25 ++++++++++++++++--------- mission/tmtc/TmStoreBackend.cpp | 4 +--- mission/tmtc/TmStoreBackend.h | 10 ++++------ 5 files changed, 52 insertions(+), 26 deletions(-) diff --git a/mission/tmtc/CMakeLists.txt b/mission/tmtc/CMakeLists.txt index 2fdccc81..d8dd4e1c 100644 --- a/mission/tmtc/CMakeLists.txt +++ b/mission/tmtc/CMakeLists.txt @@ -1,4 +1,9 @@ target_sources( - ${LIB_EIVE_MISSION} PRIVATE CCSDSHandler.cpp VirtualChannel.cpp TmFunnel.cpp - CfdpTmFunnel.cpp PusTmFunnel.cpp Service15TmStorage.cpp - TmStoreBackend.cpp) + ${LIB_EIVE_MISSION} + PRIVATE CCSDSHandler.cpp + VirtualChannel.cpp + TmFunnel.cpp + CfdpTmFunnel.cpp + PusTmFunnel.cpp + Service15TmStorage.cpp + TmStoreBackend.cpp) diff --git a/mission/tmtc/Service15TmStorage.cpp b/mission/tmtc/Service15TmStorage.cpp index 1a441247..590b6c8e 100644 --- a/mission/tmtc/Service15TmStorage.cpp +++ b/mission/tmtc/Service15TmStorage.cpp @@ -1,13 +1,31 @@ #include "Service15TmStorage.h" +using namespace returnvalue; -Service15TmStorage::Service15TmStorage(PsbParams params): PusServiceBase(params) { +Service15TmStorage::Service15TmStorage(object_id_t objectId, uint16_t apid, + uint8_t numParallelCommands, uint16_t commandTimeoutSecs, + size_t queueDepth) + : CommandingServiceBase(objectId, apid, "PUS Service 15", 15, numParallelCommands, + commandTimeoutSecs, queueDepth) {} + +ReturnValue_t Service15TmStorage::isValidSubservice(uint8_t subservice) { return OK; } + +ReturnValue_t Service15TmStorage::getMessageQueueAndObject(uint8_t subservice, + const uint8_t *tcData, size_t tcDataLen, + MessageQueueId_t *id, + object_id_t *objectId) { + return OK; } -ReturnValue_t Service15TmStorage::handleRequest(uint8_t subservice) { - return returnvalue::OK; +ReturnValue_t Service15TmStorage::prepareCommand(CommandMessage *message, uint8_t subservice, + const uint8_t *tcData, size_t tcDataLen, + uint32_t *state, object_id_t objectId) { + return OK; } -ReturnValue_t Service15TmStorage::performService() { - return returnvalue::OK; +ReturnValue_t Service15TmStorage::handleReply(const CommandMessage *reply, + Command_t previousCommand, uint32_t *state, + CommandMessage *optionalNextCommand, + object_id_t objectId, bool *isStep) { + return OK; } diff --git a/mission/tmtc/Service15TmStorage.h b/mission/tmtc/Service15TmStorage.h index 82856bec..0243fdb3 100644 --- a/mission/tmtc/Service15TmStorage.h +++ b/mission/tmtc/Service15TmStorage.h @@ -1,16 +1,23 @@ #ifndef MISSION_TMTC_SERVICE15TMSTORAGE_H_ #define MISSION_TMTC_SERVICE15TMSTORAGE_H_ -#include "fsfw/tmtcservices/PusServiceBase.h" +#include -class Service15TmStorage: public PusServiceBase { -public: - explicit Service15TmStorage(PsbParams params); -private: - ReturnValue_t handleRequest(uint8_t subservice) override; - ReturnValue_t performService() override; +class Service15TmStorage : public CommandingServiceBase { + public: + explicit Service15TmStorage(object_id_t objectId, uint16_t apid, uint8_t numParallelCommands, + uint16_t commandTimeoutSecs, size_t queueDepth); + + private: + 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; }; - - #endif /* MISSION_TMTC_SERVICE15TMSTORAGE_H_ */ diff --git a/mission/tmtc/TmStoreBackend.cpp b/mission/tmtc/TmStoreBackend.cpp index 4ffaa98b..4362609d 100644 --- a/mission/tmtc/TmStoreBackend.cpp +++ b/mission/tmtc/TmStoreBackend.cpp @@ -1,8 +1,6 @@ #include "TmStoreBackend.h" -const char* TmStoreBackend::getName() const { - return "TM Store Backend"; -} +const char* TmStoreBackend::getName() const { return "TM Store Backend"; } MessageQueueId_t TmStoreBackend::getReportReceptionQueue(uint8_t virtualChannel) const { return MessageQueueIF::NO_QUEUE; diff --git a/mission/tmtc/TmStoreBackend.h b/mission/tmtc/TmStoreBackend.h index d845d758..f53b5227 100644 --- a/mission/tmtc/TmStoreBackend.h +++ b/mission/tmtc/TmStoreBackend.h @@ -3,14 +3,12 @@ #include -class TmStoreBackend: public AcceptsTelemetryIF { -public: - +class TmStoreBackend : public AcceptsTelemetryIF { + public: [[nodiscard]] const char* getName() const override; [[nodiscard]] MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) const override; -private: + + private: }; - - #endif /* MISSION_TMTC_TMSTOREBACKEND_H_ */ From ed7606290456ee2bbaa1ce760cf34cbac63f3669 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 24 Oct 2022 10:40:01 +0200 Subject: [PATCH 003/373] bump fsfw --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 754b71a3..56e8e5a8 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 754b71a35fc27208d7c679ea58783cacda973996 +Subproject commit 56e8e5a8b34dee6fcf240111618109e53b77841f From 46a756b1ee4322ef219376ad85f9561eaf48f66f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 24 Oct 2022 10:57:30 +0200 Subject: [PATCH 004/373] some updates --- CMakeLists.txt | 1 + fsfw | 2 +- mission/tmtc/CMakeLists.txt | 2 +- mission/tmtc/TmStore.cpp | 32 ++++++++++++++++++++++++ mission/tmtc/TmStore.h | 44 +++++++++++++++++++++++++++++++++ mission/tmtc/TmStoreBackend.cpp | 7 ------ mission/tmtc/TmStoreBackend.h | 14 ----------- 7 files changed, 79 insertions(+), 23 deletions(-) create mode 100644 mission/tmtc/TmStore.cpp create mode 100644 mission/tmtc/TmStore.h delete mode 100644 mission/tmtc/TmStoreBackend.cpp delete mode 100644 mission/tmtc/TmStoreBackend.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 43336bdd..831a7064 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -210,6 +210,7 @@ set(LIB_JSON_PATH ${THIRD_PARTY_FOLDER}/json) set(FSFW_WARNING_SHADOW_LOCAL_GCC OFF) set(EIVE_ADD_LINUX_FILES False) +set(FSFW_ADD_TMSTORAGE ON) # Analyse different OS and architecture/target options, determine BSP_PATH, # display information about compiler etc. diff --git a/fsfw b/fsfw index 56e8e5a8..096af44e 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 56e8e5a8b34dee6fcf240111618109e53b77841f +Subproject commit 096af44e39c4a94b17ee051fbdf907ddb3026a00 diff --git a/mission/tmtc/CMakeLists.txt b/mission/tmtc/CMakeLists.txt index d8dd4e1c..0f77efcd 100644 --- a/mission/tmtc/CMakeLists.txt +++ b/mission/tmtc/CMakeLists.txt @@ -6,4 +6,4 @@ target_sources( CfdpTmFunnel.cpp PusTmFunnel.cpp Service15TmStorage.cpp - TmStoreBackend.cpp) + TmStore.cpp) diff --git a/mission/tmtc/TmStore.cpp b/mission/tmtc/TmStore.cpp new file mode 100644 index 00000000..f0940ef0 --- /dev/null +++ b/mission/tmtc/TmStore.cpp @@ -0,0 +1,32 @@ +#include "TmStore.h" + +using namespace returnvalue; + +const char* TmStore::getName() const { return "TM Store Backend"; } + +MessageQueueId_t TmStore::getReportReceptionQueue(uint8_t virtualChannel) const { + return MessageQueueIF::NO_QUEUE; +} + +MessageQueueId_t TmStore::getCommandQueue() const { return MessageQueueIF::NO_QUEUE; } + +TmStoreBackendIF* TmStore::getBackend() const { return nullptr; } + +ReturnValue_t TmStore::packetRetrieved(PusTmReader* packet, uint32_t address) { return OK; } + +void TmStore::noMorePacketsInStore() {} + +void TmStore::handleRetrievalFailed(ReturnValue_t errorCode, uint32_t parameter1, + uint32_t parameter2) {} + +ReturnValue_t TmStore::fetchPackets(ApidSsc start, ApidSsc end) { return OK; } + +ReturnValue_t TmStore::deletePackets(ApidSsc upTo) { return OK; } + +ReturnValue_t TmStore::checkPacket(SpacePacketReader* tmPacket) { return OK; } + +void TmStore::setEnabled(bool enabled) {} + +void TmStore::resetDownlinkedPacketCount() {} + +ReturnValue_t TmStore::setDumpTarget(object_id_t dumpTarget) { return OK; } diff --git a/mission/tmtc/TmStore.h b/mission/tmtc/TmStore.h new file mode 100644 index 00000000..870072d1 --- /dev/null +++ b/mission/tmtc/TmStore.h @@ -0,0 +1,44 @@ +#ifndef MISSION_TMTC_TMSTOREBACKEND_H_ +#define MISSION_TMTC_TMSTOREBACKEND_H_ + +#include +#include + +class TmStore : public TmStoreFrontendIF, public AcceptsTelemetryIF { + public: + [[nodiscard]] const char* getName() const override; + [[nodiscard]] MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) const override; + + private: + /** + * To get the queue where commands shall be sent. + * @return Id of command queue. + */ + MessageQueueId_t getCommandQueue() const override; + + TmStoreBackendIF* getBackend() const override; + + /** + * Callback from the back-end to indicate a certain packet was received. + * front-end takes care of discarding/downloading the packet. + * @param packet Pointer to the newly received Space Packet. + * @param address Start address of the packet found + * @param isLastPacket Indicates if no more packets can be fetched. + * @return If more packets shall be fetched, returnvalue::OK must be returned. + * Any other code stops fetching packets. + */ + ReturnValue_t packetRetrieved(PusTmReader* packet, uint32_t address) override; + void noMorePacketsInStore() override; + void handleRetrievalFailed(ReturnValue_t errorCode, uint32_t parameter1 = 0, + uint32_t parameter2 = 0) override; + + ReturnValue_t fetchPackets(ApidSsc start, ApidSsc end) override; + ReturnValue_t deletePackets(ApidSsc upTo) override; + ReturnValue_t checkPacket(SpacePacketReader* tmPacket) override; + bool isEnabled() const = 0; + void setEnabled(bool enabled) override; + void resetDownlinkedPacketCount() override; + ReturnValue_t setDumpTarget(object_id_t dumpTarget) override; +}; + +#endif /* MISSION_TMTC_TMSTOREBACKEND_H_ */ diff --git a/mission/tmtc/TmStoreBackend.cpp b/mission/tmtc/TmStoreBackend.cpp deleted file mode 100644 index 4362609d..00000000 --- a/mission/tmtc/TmStoreBackend.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "TmStoreBackend.h" - -const char* TmStoreBackend::getName() const { return "TM Store Backend"; } - -MessageQueueId_t TmStoreBackend::getReportReceptionQueue(uint8_t virtualChannel) const { - return MessageQueueIF::NO_QUEUE; -} diff --git a/mission/tmtc/TmStoreBackend.h b/mission/tmtc/TmStoreBackend.h deleted file mode 100644 index f53b5227..00000000 --- a/mission/tmtc/TmStoreBackend.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef MISSION_TMTC_TMSTOREBACKEND_H_ -#define MISSION_TMTC_TMSTOREBACKEND_H_ - -#include - -class TmStoreBackend : public AcceptsTelemetryIF { - public: - [[nodiscard]] const char* getName() const override; - [[nodiscard]] MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) const override; - - private: -}; - -#endif /* MISSION_TMTC_TMSTOREBACKEND_H_ */ From d5867f104f6b503423987eb74f463eb77fe6751b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 25 Oct 2022 18:20:21 +0200 Subject: [PATCH 005/373] continue tm store --- linux/fsfwconfig/FSFWConfig.h.in | 2 +- mission/tmtc/TmStore.cpp | 32 +++++------------------ mission/tmtc/TmStore.h | 44 ++++++++++++++------------------ 3 files changed, 27 insertions(+), 51 deletions(-) diff --git a/linux/fsfwconfig/FSFWConfig.h.in b/linux/fsfwconfig/FSFWConfig.h.in index 25772ce7..f3d3f0f4 100644 --- a/linux/fsfwconfig/FSFWConfig.h.in +++ b/linux/fsfwconfig/FSFWConfig.h.in @@ -42,7 +42,7 @@ //! When using the newlib nano library, C99 support for stdio facilities //! will not be provided. This define should be set to 1 if this is the case. -#define FSFW_NO_C99_IO 1 +#define FSFW_NO_C99_IO 0 //! Specify whether a special mode store is used for Subsystem components. #define FSFW_USE_MODESTORE 0 diff --git a/mission/tmtc/TmStore.cpp b/mission/tmtc/TmStore.cpp index f0940ef0..12e1f4d3 100644 --- a/mission/tmtc/TmStore.cpp +++ b/mission/tmtc/TmStore.cpp @@ -1,32 +1,14 @@ #include "TmStore.h" +#include + using namespace returnvalue; -const char* TmStore::getName() const { return "TM Store Backend"; } +TmStore::TmStore(object_id_t objectId, SdCardMountedIF& sdcMan) + : SystemObject(objectId), sdcMan(sdcMan) {} -MessageQueueId_t TmStore::getReportReceptionQueue(uint8_t virtualChannel) const { - return MessageQueueIF::NO_QUEUE; +ReturnValue_t TmStore::passPacket(PusTmReader& reader) { + return returnvalue::OK; } -MessageQueueId_t TmStore::getCommandQueue() const { return MessageQueueIF::NO_QUEUE; } - -TmStoreBackendIF* TmStore::getBackend() const { return nullptr; } - -ReturnValue_t TmStore::packetRetrieved(PusTmReader* packet, uint32_t address) { return OK; } - -void TmStore::noMorePacketsInStore() {} - -void TmStore::handleRetrievalFailed(ReturnValue_t errorCode, uint32_t parameter1, - uint32_t parameter2) {} - -ReturnValue_t TmStore::fetchPackets(ApidSsc start, ApidSsc end) { return OK; } - -ReturnValue_t TmStore::deletePackets(ApidSsc upTo) { return OK; } - -ReturnValue_t TmStore::checkPacket(SpacePacketReader* tmPacket) { return OK; } - -void TmStore::setEnabled(bool enabled) {} - -void TmStore::resetDownlinkedPacketCount() {} - -ReturnValue_t TmStore::setDumpTarget(object_id_t dumpTarget) { return OK; } +MessageQueueId_t TmStore::getCommandQueue() { return MessageQueueIF::NO_QUEUE; } diff --git a/mission/tmtc/TmStore.h b/mission/tmtc/TmStore.h index 870072d1..015feef6 100644 --- a/mission/tmtc/TmStore.h +++ b/mission/tmtc/TmStore.h @@ -1,44 +1,38 @@ #ifndef MISSION_TMTC_TMSTOREBACKEND_H_ #define MISSION_TMTC_TMSTOREBACKEND_H_ +#include + +#include #include +#include #include -class TmStore : public TmStoreFrontendIF, public AcceptsTelemetryIF { +struct PacketFilter { + std::optional apid; + std::optional service; + std::optional> serviceSubservice; +}; + +class TmStore : public SystemObject { public: - [[nodiscard]] const char* getName() const override; - [[nodiscard]] MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) const override; + TmStore(object_id_t objectId, SdCardMountedIF& sdcMan); + + ReturnValue_t passPacket(PusTmReader& reader); private: /** * To get the queue where commands shall be sent. * @return Id of command queue. */ - MessageQueueId_t getCommandQueue() const override; + MessageQueueId_t getCommandQueue(); - TmStoreBackendIF* getBackend() const override; + SdCardMountedIF& sdcMan; - /** - * Callback from the back-end to indicate a certain packet was received. - * front-end takes care of discarding/downloading the packet. - * @param packet Pointer to the newly received Space Packet. - * @param address Start address of the packet found - * @param isLastPacket Indicates if no more packets can be fetched. - * @return If more packets shall be fetched, returnvalue::OK must be returned. - * Any other code stops fetching packets. - */ - ReturnValue_t packetRetrieved(PusTmReader* packet, uint32_t address) override; - void noMorePacketsInStore() override; - void handleRetrievalFailed(ReturnValue_t errorCode, uint32_t parameter1 = 0, - uint32_t parameter2 = 0) override; - ReturnValue_t fetchPackets(ApidSsc start, ApidSsc end) override; - ReturnValue_t deletePackets(ApidSsc upTo) override; - ReturnValue_t checkPacket(SpacePacketReader* tmPacket) override; - bool isEnabled() const = 0; - void setEnabled(bool enabled) override; - void resetDownlinkedPacketCount() override; - ReturnValue_t setDumpTarget(object_id_t dumpTarget) override; + std::vector apidToStore; + std::vector servicesToStore; + std::vector> serviceSubserviceCombinationToStore; }; #endif /* MISSION_TMTC_TMSTOREBACKEND_H_ */ From 31093c0d1314ee282188f850e3627203b18168f6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 25 Oct 2022 18:21:08 +0200 Subject: [PATCH 006/373] bump fsfw --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 096af44e..819a2bfa 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 096af44e39c4a94b17ee051fbdf907ddb3026a00 +Subproject commit 819a2bfac49babfc6a78452bb83cd581bf902bc8 From 4ca892e9f3dd2c6f21442826b6b35857da565cf8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 11 Nov 2022 11:29:41 +0100 Subject: [PATCH 007/373] bump fsfw --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 39946bff..4d2802a4 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 39946bff58db7c5ac9016ca3156abb059560d9cb +Subproject commit 4d2802a470e5386e2bc7765c7409a99835d0c046 From 608632fde343ee3f0a2d2e900e10054077b5352b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 11 Nov 2022 11:38:37 +0100 Subject: [PATCH 008/373] bump fsfw --- bsp_q7s/core/ObjectFactory.cpp | 12 ++++++------ fsfw | 2 +- linux/ObjectFactory.cpp | 2 +- linux/boardtest/UartTestClass.cpp | 2 +- linux/boardtest/UartTestClass.h | 2 +- linux/devices/ScexUartReader.cpp | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index f5397e04..52e39cdd 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -572,8 +572,8 @@ void ObjectFactory::createSolarArrayDeploymentComponents(PowerSwitchIF& pwrSwitc } void ObjectFactory::createSyrlinksComponents(PowerSwitchIF* pwrSwitcher) { - UartCookie* syrlinksUartCookie = - new UartCookie(objects::SYRLINKS_HK_HANDLER, q7s::UART_SYRLINKS_DEV, uart::SYRLINKS_BAUD, + SerialCookie* syrlinksUartCookie = + new SerialCookie(objects::SYRLINKS_HK_HANDLER, q7s::UART_SYRLINKS_DEV, uart::SYRLINKS_BAUD, syrlinks::MAX_REPLY_SIZE, UartModes::NON_CANONICAL); syrlinksUartCookie->setParityEven(); @@ -602,7 +602,7 @@ void ObjectFactory::createPayloadComponents(LinuxLibgpioIF* gpioComIF, PowerSwit mpsocGpioCookie->addGpio(gpioIds::ENABLE_MPSOC_UART, gpioConfigMPSoC); gpioChecker(gpioComIF->addGpios(mpsocGpioCookie), "PLOC MPSoC"); auto mpsocCookie = - new UartCookie(objects::PLOC_MPSOC_HANDLER, q7s::UART_PLOC_MPSOC_DEV, uart::PLOC_MPSOC_BAUD, + new SerialCookie(objects::PLOC_MPSOC_HANDLER, q7s::UART_PLOC_MPSOC_DEV, uart::PLOC_MPSOC_BAUD, mpsoc::MAX_REPLY_SIZE, UartModes::NON_CANONICAL); mpsocCookie->setNoFixedSizeReply(); auto plocMpsocHelper = new PlocMPSoCHelper(objects::PLOC_MPSOC_HELPER); @@ -619,7 +619,7 @@ void ObjectFactory::createPayloadComponents(LinuxLibgpioIF* gpioComIF, PowerSwit supvGpioCookie->addGpio(gpioIds::ENABLE_SUPV_UART, gpioConfigSupv); gpioComIF->addGpios(supvGpioCookie); auto supervisorCookie = - new UartCookie(objects::PLOC_SUPERVISOR_HANDLER, q7s::UART_PLOC_SUPERVSIOR_DEV, + new SerialCookie(objects::PLOC_SUPERVISOR_HANDLER, q7s::UART_PLOC_SUPERVSIOR_DEV, uart::PLOC_SUPV_BAUD, supv::MAX_PACKET_SIZE * 20, UartModes::NON_CANONICAL); supervisorCookie->setNoFixedSizeReply(); auto supvHelper = new PlocSupvHelper(objects::PLOC_SUPERVISOR_HELPER); @@ -905,8 +905,8 @@ void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) { } void ObjectFactory::createStrComponents(PowerSwitchIF* pwrSwitcher) { - UartCookie* starTrackerCookie = - new UartCookie(objects::STAR_TRACKER, q7s::UART_STAR_TRACKER_DEV, uart::STAR_TRACKER_BAUD, + SerialCookie* starTrackerCookie = + new SerialCookie(objects::STAR_TRACKER, q7s::UART_STAR_TRACKER_DEV, uart::STAR_TRACKER_BAUD, startracker::MAX_FRAME_SIZE * 2 + 2, UartModes::NON_CANONICAL); starTrackerCookie->setNoFixedSizeReply(); StrHelper* strHelper = new StrHelper(objects::STR_HELPER); diff --git a/fsfw b/fsfw index 4d2802a4..046dbe1d 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 4d2802a470e5386e2bc7765c7409a99835d0c046 +Subproject commit 046dbe1deb8053f64d7ef85992dec22aea9a3a10 diff --git a/linux/ObjectFactory.cpp b/linux/ObjectFactory.cpp index 21f884f9..e35d7e96 100644 --- a/linux/ObjectFactory.cpp +++ b/linux/ObjectFactory.cpp @@ -326,7 +326,7 @@ void ObjectFactory::createRtdComponents(std::string spiDev, GpioIF* gpioComIF, void ObjectFactory::createScexComponents(std::string uartDev, PowerSwitchIF* pwrSwitcher, SdCardMountedIF& mountedIF, bool onImmediately, std::optional switchId) { - auto* cookie = new UartCookie(objects::SCEX, uartDev, uart::SCEX_BAUD, 4096); + auto* cookie = new SerialCookie(objects::SCEX, uartDev, uart::SCEX_BAUD, 4096); cookie->setTwoStopBits(); // cookie->setParityEven(); auto scexUartReader = new ScexUartReader(objects::SCEX_UART_READER); diff --git a/linux/boardtest/UartTestClass.cpp b/linux/boardtest/UartTestClass.cpp index 2c914d74..51ea237f 100644 --- a/linux/boardtest/UartTestClass.cpp +++ b/linux/boardtest/UartTestClass.cpp @@ -164,7 +164,7 @@ void UartTestClass::scexInit() { #else std::string devname = "/dev/ul-scex"; #endif - uartCookie = new UartCookie(this->getObjectId(), devname, UartBaudRate::RATE_57600, 4096); + uartCookie = new SerialCookie(this->getObjectId(), devname, UartBaudRate::RATE_57600, 4096); reader->setDebugMode(false); ReturnValue_t result = reader->initializeInterface(uartCookie); if (result != OK) { diff --git a/linux/boardtest/UartTestClass.h b/linux/boardtest/UartTestClass.h index 6304724b..05776bc0 100644 --- a/linux/boardtest/UartTestClass.h +++ b/linux/boardtest/UartTestClass.h @@ -57,7 +57,7 @@ class UartTestClass : public TestTask { scex::Cmds currCmd = scex::Cmds::PING; TestModes mode = TestModes::GPS; DleEncoder dleEncoder = DleEncoder(); - UartCookie* uartCookie = nullptr; + SerialCookie* uartCookie = nullptr; size_t encodedLen = 0; lwgps_t gpsData = {}; struct termios tty = {}; diff --git a/linux/devices/ScexUartReader.cpp b/linux/devices/ScexUartReader.cpp index ce59472d..6f615014 100644 --- a/linux/devices/ScexUartReader.cpp +++ b/linux/devices/ScexUartReader.cpp @@ -84,7 +84,7 @@ ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) { } ReturnValue_t ScexUartReader::initializeInterface(CookieIF *cookie) { - UartCookie *uartCookie = dynamic_cast(cookie); + SerialCookie *uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { return FAILED; } From f60a80f308b9ef6159bf1d698c65314d5d25da12 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 11 Nov 2022 11:43:42 +0100 Subject: [PATCH 009/373] fix merge conflict --- bsp_q7s/core/ObjectFactory.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 85c0fd9f..6dc08ca1 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -905,11 +905,7 @@ void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) { } void ObjectFactory::createStrComponents(PowerSwitchIF* pwrSwitcher) { -<<<<<<< HEAD - SerialCookie* starTrackerCookie = -======= auto* starTrackerCookie = ->>>>>>> origin/develop new SerialCookie(objects::STAR_TRACKER, q7s::UART_STAR_TRACKER_DEV, uart::STAR_TRACKER_BAUD, startracker::MAX_FRAME_SIZE * 2 + 2, UartModes::NON_CANONICAL); starTrackerCookie->setNoFixedSizeReply(); From c599714aea0834a98482e898389b313c4441916c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 11 Nov 2022 15:39:27 +0100 Subject: [PATCH 010/373] some sort of filter handling --- bsp_q7s/core/ObjectFactory.cpp | 8 +++---- fsfw | 2 +- mission/tmtc/CMakeLists.txt | 10 +++++++-- mission/tmtc/TmStore.cpp | 39 ++++++++++++++++++++++++++++++++-- mission/tmtc/TmStore.h | 19 ++++++----------- 5 files changed, 57 insertions(+), 21 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 6dc08ca1..b110e82a 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -574,7 +574,7 @@ void ObjectFactory::createSolarArrayDeploymentComponents(PowerSwitchIF& pwrSwitc void ObjectFactory::createSyrlinksComponents(PowerSwitchIF* pwrSwitcher) { auto* syrlinksUartCookie = new SerialCookie(objects::SYRLINKS_HK_HANDLER, q7s::UART_SYRLINKS_DEV, uart::SYRLINKS_BAUD, - syrlinks::MAX_REPLY_SIZE, UartModes::NON_CANONICAL); + syrlinks::MAX_REPLY_SIZE, UartModes::NON_CANONICAL); syrlinksUartCookie->setParityEven(); auto syrlinksFdir = new SyrlinksFdir(objects::SYRLINKS_HK_HANDLER); @@ -603,7 +603,7 @@ void ObjectFactory::createPayloadComponents(LinuxLibgpioIF* gpioComIF, PowerSwit gpioChecker(gpioComIF->addGpios(mpsocGpioCookie), "PLOC MPSoC"); auto mpsocCookie = new SerialCookie(objects::PLOC_MPSOC_HANDLER, q7s::UART_PLOC_MPSOC_DEV, uart::PLOC_MPSOC_BAUD, - mpsoc::MAX_REPLY_SIZE, UartModes::NON_CANONICAL); + mpsoc::MAX_REPLY_SIZE, UartModes::NON_CANONICAL); mpsocCookie->setNoFixedSizeReply(); auto plocMpsocHelper = new PlocMPSoCHelper(objects::PLOC_MPSOC_HELPER); auto* mpsocHandler = new PlocMPSoCHandler( @@ -620,7 +620,7 @@ void ObjectFactory::createPayloadComponents(LinuxLibgpioIF* gpioComIF, PowerSwit gpioComIF->addGpios(supvGpioCookie); auto supervisorCookie = new SerialCookie(objects::PLOC_SUPERVISOR_HANDLER, q7s::UART_PLOC_SUPERVSIOR_DEV, - uart::PLOC_SUPV_BAUD, supv::MAX_PACKET_SIZE * 20, UartModes::NON_CANONICAL); + uart::PLOC_SUPV_BAUD, supv::MAX_PACKET_SIZE * 20, UartModes::NON_CANONICAL); supervisorCookie->setNoFixedSizeReply(); auto supvHelper = new PlocSupvHelper(objects::PLOC_SUPERVISOR_HELPER); auto* supvHandler = new PlocSupervisorHandler( @@ -907,7 +907,7 @@ void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) { void ObjectFactory::createStrComponents(PowerSwitchIF* pwrSwitcher) { auto* starTrackerCookie = new SerialCookie(objects::STAR_TRACKER, q7s::UART_STAR_TRACKER_DEV, uart::STAR_TRACKER_BAUD, - startracker::MAX_FRAME_SIZE * 2 + 2, UartModes::NON_CANONICAL); + startracker::MAX_FRAME_SIZE * 2 + 2, UartModes::NON_CANONICAL); starTrackerCookie->setNoFixedSizeReply(); StrHelper* strHelper = new StrHelper(objects::STR_HELPER); auto starTracker = diff --git a/fsfw b/fsfw index 046dbe1d..2b6a33e7 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 046dbe1deb8053f64d7ef85992dec22aea9a3a10 +Subproject commit 2b6a33e718f896300ca08345a9211c2ae974d014 diff --git a/mission/tmtc/CMakeLists.txt b/mission/tmtc/CMakeLists.txt index 3c631be7..cc84aabb 100644 --- a/mission/tmtc/CMakeLists.txt +++ b/mission/tmtc/CMakeLists.txt @@ -1,4 +1,10 @@ target_sources( ${LIB_EIVE_MISSION} - PRIVATE CcsdsIpCoreHandler.cpp VirtualChannel.cpp TmFunnelHandler.cpp - TmFunnelBase.cpp CfdpTmFunnel.cpp Service15TmStorage.cpp TmStore.cpp PusTmFunnel.cpp) + PRIVATE CcsdsIpCoreHandler.cpp + VirtualChannel.cpp + TmFunnelHandler.cpp + TmFunnelBase.cpp + CfdpTmFunnel.cpp + Service15TmStorage.cpp + TmStore.cpp + PusTmFunnel.cpp) diff --git a/mission/tmtc/TmStore.cpp b/mission/tmtc/TmStore.cpp index 12e1f4d3..3033b001 100644 --- a/mission/tmtc/TmStore.cpp +++ b/mission/tmtc/TmStore.cpp @@ -1,14 +1,49 @@ #include "TmStore.h" + #include +#include using namespace returnvalue; -TmStore::TmStore(object_id_t objectId, SdCardMountedIF& sdcMan) - : SystemObject(objectId), sdcMan(sdcMan) {} +TmStore::TmStore(object_id_t objectId, std::string baseName, PacketFilter filter, SdCardMountedIF& sdcMan) + : SystemObject(objectId), filter(filter), sdcMan(sdcMan) {} ReturnValue_t TmStore::passPacket(PusTmReader& reader) { + bool inApidList = false; + if (filter.apid) { + auto& apidFilter = filter.apid.value(); + if (std::find(apidFilter.begin(), apidFilter.end(), reader.getApid()) != apidFilter.end()) { + if (not filter.serviceSubservices and not filter.services) { + return storePacket(reader); + } + inApidList = true; + } + } + std::pair serviceSubservice; + serviceSubservice.first = reader.getService(); + serviceSubservice.second = reader.getSubService(); + if (filter.services) { + auto& serviceFilter = filter.services.value(); + if (std::find(serviceFilter.begin(), serviceFilter.end(), serviceSubservice.first) != + serviceFilter.end()) { + if (filter.apid and inApidList) { + return storePacket(reader); + } + } + } + if (filter.serviceSubservices) { + auto& serviceSubserviceFilter = filter.serviceSubservices.value(); + if (std::find(serviceSubserviceFilter.begin(), serviceSubserviceFilter.end(), + serviceSubservice) != serviceSubserviceFilter.end()) { + if (filter.apid and inApidList) { + return storePacket(reader); + } + } + } return returnvalue::OK; } +ReturnValue_t TmStore::storePacket(PusTmReader& reader) { return returnvalue::OK; } + MessageQueueId_t TmStore::getCommandQueue() { return MessageQueueIF::NO_QUEUE; } diff --git a/mission/tmtc/TmStore.h b/mission/tmtc/TmStore.h index 015feef6..7d8cb144 100644 --- a/mission/tmtc/TmStore.h +++ b/mission/tmtc/TmStore.h @@ -1,24 +1,24 @@ #ifndef MISSION_TMTC_TMSTOREBACKEND_H_ #define MISSION_TMTC_TMSTOREBACKEND_H_ -#include - #include #include #include #include +#include struct PacketFilter { - std::optional apid; - std::optional service; - std::optional> serviceSubservice; + std::optional> apid; + std::optional> services; + std::optional>> serviceSubservices; }; class TmStore : public SystemObject { public: - TmStore(object_id_t objectId, SdCardMountedIF& sdcMan); + TmStore(object_id_t objectId, std::string baseName, PacketFilter filter, SdCardMountedIF& sdcMan); ReturnValue_t passPacket(PusTmReader& reader); + ReturnValue_t storePacket(PusTmReader& reader); private: /** @@ -26,13 +26,8 @@ class TmStore : public SystemObject { * @return Id of command queue. */ MessageQueueId_t getCommandQueue(); - + PacketFilter filter; SdCardMountedIF& sdcMan; - - - std::vector apidToStore; - std::vector servicesToStore; - std::vector> serviceSubserviceCombinationToStore; }; #endif /* MISSION_TMTC_TMSTOREBACKEND_H_ */ From da98cd77e89f0fc7f4f63dc703dc66cb6863fbff Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 24 Nov 2022 15:16:42 +0100 Subject: [PATCH 011/373] bump fsfw --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 160ff799..296bc56e 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 160ff799ace61e24708dcf1fdeaf5fafdf23a4ca +Subproject commit 296bc56e2a1acb0e4d84efd5189845192ddc1de2 From fba820a1c0db8e22125c75e432fed8e2258d762d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 12 Dec 2022 10:06:30 +0100 Subject: [PATCH 012/373] start storage algorithms --- bsp_hosted/scheduling.cpp | 2 +- .../devicedefinitions/GPSDefinitions.h | 2 +- mission/tmtc/TmStore.cpp | 37 +++++++++++++++++-- mission/tmtc/TmStore.h | 13 ++++++- unittest/controller/testThermalController.cpp | 2 +- 5 files changed, 49 insertions(+), 7 deletions(-) diff --git a/bsp_hosted/scheduling.cpp b/bsp_hosted/scheduling.cpp index 19df002f..2e73bbf5 100644 --- a/bsp_hosted/scheduling.cpp +++ b/bsp_hosted/scheduling.cpp @@ -185,7 +185,7 @@ void scheduling::initTasks() { #endif /* OBSW_ADD_TEST_CODE == 1 */ PeriodicTaskIF* dummyTask = factory->createPeriodicTask( - "DUMMY_TASK", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, missedDeadlineFunc); + "DUMMY_TASK", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, missedDeadlineFunc); dummyTask->addComponent(objects::SUS_0_N_LOC_XFYFZM_PT_XF); dummyTask->addComponent(objects::SUS_1_N_LOC_XBYFZM_PT_XB); dummyTask->addComponent(objects::SUS_2_N_LOC_XFYBZB_PT_YB); diff --git a/mission/devices/devicedefinitions/GPSDefinitions.h b/mission/devices/devicedefinitions/GPSDefinitions.h index 7653745f..387d08be 100644 --- a/mission/devices/devicedefinitions/GPSDefinitions.h +++ b/mission/devices/devicedefinitions/GPSDefinitions.h @@ -1,9 +1,9 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_GPSDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_GPSDEFINITIONS_H_ +#include "eive/eventSubsystemIds.h" #include "fsfw/datapoollocal/StaticLocalDataSet.h" #include "fsfw/devicehandlers/DeviceHandlerIF.h" -#include "eive/eventSubsystemIds.h" namespace GpsHyperion { diff --git a/mission/tmtc/TmStore.cpp b/mission/tmtc/TmStore.cpp index 3033b001..8429491c 100644 --- a/mission/tmtc/TmStore.cpp +++ b/mission/tmtc/TmStore.cpp @@ -3,11 +3,18 @@ #include #include +#include using namespace returnvalue; -TmStore::TmStore(object_id_t objectId, std::string baseName, PacketFilter filter, SdCardMountedIF& sdcMan) - : SystemObject(objectId), filter(filter), sdcMan(sdcMan) {} +TmStore::TmStore(object_id_t objectId, std::string baseName, RolloverInterval interval, + uint8_t intervalFactor, PacketFilter filter, SdCardMountedIF& sdcMan) + : SystemObject(objectId), + filter(filter), + baseName(std::move(baseName)), + interval(interval), + intervalFactor(intervalFactor), + sdcMan(sdcMan) {} ReturnValue_t TmStore::passPacket(PusTmReader& reader) { bool inApidList = false; @@ -44,6 +51,30 @@ ReturnValue_t TmStore::passPacket(PusTmReader& reader) { return returnvalue::OK; } -ReturnValue_t TmStore::storePacket(PusTmReader& reader) { return returnvalue::OK; } +ReturnValue_t TmStore::storePacket(PusTmReader& reader) { + using namespace std::filesystem; + std::string currentPrefix = sdcMan.getCurrentMountPrefix(); + path baseDir = currentPrefix / baseName; + // It is assumed here that the filesystem is usable. + if (not exists(baseDir)) { + create_directory(baseDir); + } + if (not mostRecentFile) { + // TODO: Find most recent file by iterating through all files and remembering the file + // with the most recent timestamp. + for (auto const& file : directory_iterator(baseDir)) { + if (file.is_directory()) { + continue; + } + auto path = file.path(); + // TODO: Scan file timestamp from name somehow. Maybe use scanf or similar? + } + } + // TODO: Need to find the file of the most recent file. + // TODO: If file exists: Determine whether file rolls over: Maximum file size reached? Interval + // since last timestamp exceeds rollover interval? + // TODO: If file does not exist or rollover criteria met: Create new file with current timestamp. + return returnvalue::OK; +} MessageQueueId_t TmStore::getCommandQueue() { return MessageQueueIF::NO_QUEUE; } diff --git a/mission/tmtc/TmStore.h b/mission/tmtc/TmStore.h index 7d8cb144..7402921e 100644 --- a/mission/tmtc/TmStore.h +++ b/mission/tmtc/TmStore.h @@ -13,20 +13,31 @@ struct PacketFilter { std::optional>> serviceSubservices; }; +enum class RolloverInterval { HOURLY, DAILY }; + class TmStore : public SystemObject { public: - TmStore(object_id_t objectId, std::string baseName, PacketFilter filter, SdCardMountedIF& sdcMan); + TmStore(object_id_t objectId, std::string baseName, RolloverInterval interval, + uint8_t intervalFactor, PacketFilter filter, SdCardMountedIF& sdcMan); ReturnValue_t passPacket(PusTmReader& reader); ReturnValue_t storePacket(PusTmReader& reader); private: + static constexpr size_t MAX_FILESIZE = 8192; + /** * To get the queue where commands shall be sent. * @return Id of command queue. */ MessageQueueId_t getCommandQueue(); PacketFilter filter; + std::string baseName; + RolloverInterval interval; + uint8_t intervalFactor; + char NAME_BUF[524] = {}; + std::array fileBuf{}; + std::optional mostRecentFile; SdCardMountedIF& sdcMan; }; diff --git a/unittest/controller/testThermalController.cpp b/unittest/controller/testThermalController.cpp index 1c5f63fe..44fba918 100644 --- a/unittest/controller/testThermalController.cpp +++ b/unittest/controller/testThermalController.cpp @@ -13,7 +13,7 @@ TEST_CASE("Thermal Controller", "[ThermalController]") { const object_id_t THERMAL_CONTROLLER_ID = 0x123; new TemperatureSensorsDummy(); - //new SusDummy(); + // new SusDummy(); // testEnvironment::initialize(); From c493273a21196c45385c663e779a4c7da9178e14 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 12 Dec 2022 14:58:56 +0100 Subject: [PATCH 013/373] oh god sscanf --- mission/tmtc/TmStore.cpp | 12 +++++++++++- tmtc | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/mission/tmtc/TmStore.cpp b/mission/tmtc/TmStore.cpp index 8429491c..331348ab 100644 --- a/mission/tmtc/TmStore.cpp +++ b/mission/tmtc/TmStore.cpp @@ -4,6 +4,7 @@ #include #include +#include using namespace returnvalue; @@ -66,8 +67,17 @@ ReturnValue_t TmStore::storePacket(PusTmReader& reader) { if (file.is_directory()) { continue; } - auto path = file.path(); + auto pathStr = file.path().string(); + Clock::TimeOfDay_t tod; + if(pathStr.find(baseName) == std::string::npos) { + continue; + } + float seconds = 0.0; + char* prefix = nullptr; // TODO: Scan file timestamp from name somehow. Maybe use scanf or similar? + int count = sscanf(pathStr.c_str(), "%s%4" SCNu32 "-%2" SCNu32 "-%2" + SCNu32 "T%2" SCNu32 ":%2" SCNu32 ":%fZ", prefix, &tod.year, &tod.month, &tod.day, + &tod.hour, &tod.minute, &seconds); } } // TODO: Need to find the file of the most recent file. diff --git a/tmtc b/tmtc index 96e27e71..a55572db 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 96e27e716349bf01cac11c7e7b0b497a36149e87 +Subproject commit a55572db2890ef9e8276c95ba8ebfb2d74a88f7c From 6f1f92c9d13e7ab958f7249c91c341aaa6356bba Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 12 Dec 2022 16:04:38 +0100 Subject: [PATCH 014/373] i wonder if this even works --- mission/tmtc/TmStore.cpp | 5 +++-- tmtc | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mission/tmtc/TmStore.cpp b/mission/tmtc/TmStore.cpp index 331348ab..960a2054 100644 --- a/mission/tmtc/TmStore.cpp +++ b/mission/tmtc/TmStore.cpp @@ -74,10 +74,11 @@ ReturnValue_t TmStore::storePacket(PusTmReader& reader) { } float seconds = 0.0; char* prefix = nullptr; - // TODO: Scan file timestamp from name somehow. Maybe use scanf or similar? - int count = sscanf(pathStr.c_str(), "%s%4" SCNu32 "-%2" SCNu32 "-%2" + int count = sscanf(pathStr.c_str(), "%s_%4" SCNu32 "-%2" SCNu32 "-%2" SCNu32 "T%2" SCNu32 ":%2" SCNu32 ":%fZ", prefix, &tod.year, &tod.month, &tod.day, &tod.hour, &tod.minute, &seconds); + tod.second = std::floor(seconds); + static_cast(count); } } // TODO: Need to find the file of the most recent file. diff --git a/tmtc b/tmtc index a55572db..30cf4736 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit a55572db2890ef9e8276c95ba8ebfb2d74a88f7c +Subproject commit 30cf47365fec68a4b78395de03ecb2ae95af4e7e From 279697b326eaaa9ec9805b322609fad0b2e636c9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 12 Dec 2022 16:18:00 +0100 Subject: [PATCH 015/373] test stamp in filename --- mission/tmtc/TmStore.cpp | 14 +++++++------- unittest/CMakeLists.txt | 1 + unittest/testStampInFilename.cpp | 18 ++++++++++++++++++ 3 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 unittest/testStampInFilename.cpp diff --git a/mission/tmtc/TmStore.cpp b/mission/tmtc/TmStore.cpp index 960a2054..a2aec09c 100644 --- a/mission/tmtc/TmStore.cpp +++ b/mission/tmtc/TmStore.cpp @@ -3,8 +3,8 @@ #include #include -#include #include +#include using namespace returnvalue; @@ -55,7 +55,7 @@ ReturnValue_t TmStore::passPacket(PusTmReader& reader) { ReturnValue_t TmStore::storePacket(PusTmReader& reader) { using namespace std::filesystem; std::string currentPrefix = sdcMan.getCurrentMountPrefix(); - path baseDir = currentPrefix / baseName; + path baseDir = path(currentPrefix) / baseName; // It is assumed here that the filesystem is usable. if (not exists(baseDir)) { create_directory(baseDir); @@ -69,14 +69,14 @@ ReturnValue_t TmStore::storePacket(PusTmReader& reader) { } auto pathStr = file.path().string(); Clock::TimeOfDay_t tod; - if(pathStr.find(baseName) == std::string::npos) { - continue; + if (pathStr.find(baseName) == std::string::npos) { + continue; } float seconds = 0.0; char* prefix = nullptr; - int count = sscanf(pathStr.c_str(), "%s_%4" SCNu32 "-%2" SCNu32 "-%2" - SCNu32 "T%2" SCNu32 ":%2" SCNu32 ":%fZ", prefix, &tod.year, &tod.month, &tod.day, - &tod.hour, &tod.minute, &seconds); + int count = sscanf(pathStr.c_str(), + "%s_%4" SCNu32 "-%2" SCNu32 "-%2" SCNu32 "T%2" SCNu32 ":%2" SCNu32 ":%fZ", + prefix, &tod.year, &tod.month, &tod.day, &tod.hour, &tod.minute, &seconds); tod.second = std::floor(seconds); static_cast(count); } diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt index 1786b71e..977b794f 100644 --- a/unittest/CMakeLists.txt +++ b/unittest/CMakeLists.txt @@ -4,5 +4,6 @@ add_subdirectory(mocks) target_sources(${UNITTEST_NAME} PRIVATE main.cpp testEnvironment.cpp + testStampInFilename.cpp printChar.cpp ) \ No newline at end of file diff --git a/unittest/testStampInFilename.cpp b/unittest/testStampInFilename.cpp new file mode 100644 index 00000000..33a0f5a6 --- /dev/null +++ b/unittest/testStampInFilename.cpp @@ -0,0 +1,18 @@ + +#include +#include + +#include "fsfw/timemanager/Clock.h" + +TEST_CASE("Stamp in Filename", "[Stamp In Filename]") { + Clock::TimeOfDay_t tod; + std::string baseName = "verif"; + std::string pathStr = "verif_2022-05-25T16:55:23Z.bin"; + float seconds = 0.0; + char* prefix = nullptr; + int count = + sscanf(pathStr.c_str(), + "%s_%4" SCNu32 "-%2" SCNu32 "-%2" SCNu32 "T%2" SCNu32 ":%2" SCNu32 ":%2" SCNu32 "Z", + prefix, &tod.year, &tod.month, &tod.day, &tod.hour, &tod.minute, &tod.second); + static_cast(count); +} From a9699ad96910bc6ccb3fb95b0f5ce8e27e1ac20b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 12 Dec 2022 16:30:16 +0100 Subject: [PATCH 016/373] this should work --- unittest/testStampInFilename.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/unittest/testStampInFilename.cpp b/unittest/testStampInFilename.cpp index 33a0f5a6..c66bdce6 100644 --- a/unittest/testStampInFilename.cpp +++ b/unittest/testStampInFilename.cpp @@ -8,11 +8,14 @@ TEST_CASE("Stamp in Filename", "[Stamp In Filename]") { Clock::TimeOfDay_t tod; std::string baseName = "verif"; std::string pathStr = "verif_2022-05-25T16:55:23Z.bin"; + unsigned int underscorePos = pathStr.find_last_of('_'); + std::string stampStr = pathStr.substr(underscorePos + 1); float seconds = 0.0; char* prefix = nullptr; int count = - sscanf(pathStr.c_str(), - "%s_%4" SCNu32 "-%2" SCNu32 "-%2" SCNu32 "T%2" SCNu32 ":%2" SCNu32 ":%2" SCNu32 "Z", - prefix, &tod.year, &tod.month, &tod.day, &tod.hour, &tod.minute, &tod.second); + sscanf(stampStr.c_str(), + "%4" SCNu32 "-%2" SCNu32 "-%2" SCNu32 "T%2" SCNu32 ":%2" SCNu32 ":%2" SCNu32 "Z", + &tod.year, &tod.month, &tod.day, &tod.hour, &tod.minute, &tod.second); static_cast(count); + CHECK(count == 6); } From 293082a7e8684f05dda81e29a51a235c8ab26cf2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 12 Dec 2022 18:17:59 +0100 Subject: [PATCH 017/373] this logic should work --- mission/tmtc/TmStore.cpp | 24 +++++++++++++++--------- mission/tmtc/TmStore.h | 5 ++++- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/mission/tmtc/TmStore.cpp b/mission/tmtc/TmStore.cpp index a2aec09c..55a47347 100644 --- a/mission/tmtc/TmStore.cpp +++ b/mission/tmtc/TmStore.cpp @@ -61,8 +61,6 @@ ReturnValue_t TmStore::storePacket(PusTmReader& reader) { create_directory(baseDir); } if (not mostRecentFile) { - // TODO: Find most recent file by iterating through all files and remembering the file - // with the most recent timestamp. for (auto const& file : directory_iterator(baseDir)) { if (file.is_directory()) { continue; @@ -72,13 +70,21 @@ ReturnValue_t TmStore::storePacket(PusTmReader& reader) { if (pathStr.find(baseName) == std::string::npos) { continue; } - float seconds = 0.0; - char* prefix = nullptr; - int count = sscanf(pathStr.c_str(), - "%s_%4" SCNu32 "-%2" SCNu32 "-%2" SCNu32 "T%2" SCNu32 ":%2" SCNu32 ":%fZ", - prefix, &tod.year, &tod.month, &tod.day, &tod.hour, &tod.minute, &seconds); - tod.second = std::floor(seconds); - static_cast(count); + unsigned int underscorePos = pathStr.find_last_of('_'); + std::string stampStr = pathStr.substr(underscorePos + 1); + int count = + sscanf(stampStr.c_str(), + "%4" SCNu32 "-%2" SCNu32 "-%2" SCNu32 "T%2" SCNu32 ":%2" SCNu32 ":%2" SCNu32 "Z", + &tod.year, &tod.month, &tod.day, &tod.hour, &tod.minute, &tod.second); + if (count != 6) { + continue; + } + timeval tv{}; + Clock::convertTimeOfDayToTimeval(&tod, &tv); + if (not mostRecentTv || tv > mostRecentTv.value()) { + mostRecentTv = tv; + mostRecentFile = file.path(); + } } } // TODO: Need to find the file of the most recent file. diff --git a/mission/tmtc/TmStore.h b/mission/tmtc/TmStore.h index 7402921e..a2638d2b 100644 --- a/mission/tmtc/TmStore.h +++ b/mission/tmtc/TmStore.h @@ -7,6 +7,8 @@ #include #include +#include + struct PacketFilter { std::optional> apid; std::optional> services; @@ -37,7 +39,8 @@ class TmStore : public SystemObject { uint8_t intervalFactor; char NAME_BUF[524] = {}; std::array fileBuf{}; - std::optional mostRecentFile; + std::optional mostRecentTv; + std::optional mostRecentFile; SdCardMountedIF& sdcMan; }; From ed603f4e48914e7b7133340b266bfdb1c7df4e5d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 12 Dec 2022 18:27:01 +0100 Subject: [PATCH 018/373] continued TM store impl --- mission/tmtc/TmStore.cpp | 94 ++++++++++++++++++++++++---------------- mission/tmtc/TmStore.h | 13 ++++-- 2 files changed, 65 insertions(+), 42 deletions(-) diff --git a/mission/tmtc/TmStore.cpp b/mission/tmtc/TmStore.cpp index 55a47347..5c3f00c8 100644 --- a/mission/tmtc/TmStore.cpp +++ b/mission/tmtc/TmStore.cpp @@ -8,14 +8,11 @@ using namespace returnvalue; -TmStore::TmStore(object_id_t objectId, std::string baseName, RolloverInterval interval, - uint8_t intervalFactor, PacketFilter filter, SdCardMountedIF& sdcMan) - : SystemObject(objectId), - filter(filter), - baseName(std::move(baseName)), - interval(interval), - intervalFactor(intervalFactor), - sdcMan(sdcMan) {} +TmStore::TmStore(object_id_t objectId, std::string baseName, RolloverInterval intervalUnit, + uint32_t intervalCount, PacketFilter filter, SdCardMountedIF& sdcMan) + : SystemObject(objectId), filter(filter), baseName(std::move(baseName)), sdcMan(sdcMan) { + calcDiffSeconds(intervalUnit, intervalCount); +} ReturnValue_t TmStore::passPacket(PusTmReader& reader) { bool inApidList = false; @@ -54,38 +51,12 @@ ReturnValue_t TmStore::passPacket(PusTmReader& reader) { ReturnValue_t TmStore::storePacket(PusTmReader& reader) { using namespace std::filesystem; - std::string currentPrefix = sdcMan.getCurrentMountPrefix(); - path baseDir = path(currentPrefix) / baseName; - // It is assumed here that the filesystem is usable. - if (not exists(baseDir)) { - create_directory(baseDir); + if (baseDirUninitialized) { + updateBaseDir(); } + // It is assumed here that the filesystem is usable. if (not mostRecentFile) { - for (auto const& file : directory_iterator(baseDir)) { - if (file.is_directory()) { - continue; - } - auto pathStr = file.path().string(); - Clock::TimeOfDay_t tod; - if (pathStr.find(baseName) == std::string::npos) { - continue; - } - unsigned int underscorePos = pathStr.find_last_of('_'); - std::string stampStr = pathStr.substr(underscorePos + 1); - int count = - sscanf(stampStr.c_str(), - "%4" SCNu32 "-%2" SCNu32 "-%2" SCNu32 "T%2" SCNu32 ":%2" SCNu32 ":%2" SCNu32 "Z", - &tod.year, &tod.month, &tod.day, &tod.hour, &tod.minute, &tod.second); - if (count != 6) { - continue; - } - timeval tv{}; - Clock::convertTimeOfDayToTimeval(&tod, &tv); - if (not mostRecentTv || tv > mostRecentTv.value()) { - mostRecentTv = tv; - mostRecentFile = file.path(); - } - } + assignMostRecentFile(); } // TODO: Need to find the file of the most recent file. // TODO: If file exists: Determine whether file rolls over: Maximum file size reached? Interval @@ -95,3 +66,50 @@ ReturnValue_t TmStore::storePacket(PusTmReader& reader) { } MessageQueueId_t TmStore::getCommandQueue() { return MessageQueueIF::NO_QUEUE; } + +void TmStore::calcDiffSeconds(RolloverInterval intervalUnit, uint32_t intervalCount) { + if (intervalUnit == RolloverInterval::HOURLY) { + rolloverDiffSeconds = 60 * intervalCount; + } else if (intervalUnit == RolloverInterval::DAILY) { + rolloverDiffSeconds = 60 * 24 * intervalCount; + } +} + +void TmStore::updateBaseDir() { + using namespace std::filesystem; + std::string currentPrefix = sdcMan.getCurrentMountPrefix(); + baseDir = path(currentPrefix) / baseName; + if (not exists(baseDir)) { + create_directory(baseDir); + } + baseDirUninitialized = false; +} + +void TmStore::assignMostRecentFile() { + using namespace std::filesystem; + for (auto const& file : directory_iterator(baseDir)) { + if (file.is_directory()) { + continue; + } + auto pathStr = file.path().string(); + Clock::TimeOfDay_t tod; + if (pathStr.find(baseName) == std::string::npos) { + continue; + } + unsigned int underscorePos = pathStr.find_last_of('_'); + std::string stampStr = pathStr.substr(underscorePos + 1); + int count = + sscanf(stampStr.c_str(), + "%4" SCNu32 "-%2" SCNu32 "-%2" SCNu32 "T%2" SCNu32 ":%2" SCNu32 ":%2" SCNu32 "Z", + &tod.year, &tod.month, &tod.day, &tod.hour, &tod.minute, &tod.second); + if (count != 6) { + continue; + } + timeval tv{}; + Clock::convertTimeOfDayToTimeval(&tod, &tv); + if (not mostRecentTv || tv > mostRecentTv.value()) { + mostRecentTv = tv; + mostRecentFile = file.path(); + } + } +} diff --git a/mission/tmtc/TmStore.h b/mission/tmtc/TmStore.h index a2638d2b..f26461e7 100644 --- a/mission/tmtc/TmStore.h +++ b/mission/tmtc/TmStore.h @@ -19,8 +19,8 @@ enum class RolloverInterval { HOURLY, DAILY }; class TmStore : public SystemObject { public: - TmStore(object_id_t objectId, std::string baseName, RolloverInterval interval, - uint8_t intervalFactor, PacketFilter filter, SdCardMountedIF& sdcMan); + TmStore(object_id_t objectId, std::string baseName, RolloverInterval intervalUnit, + uint32_t intervalCount, PacketFilter filter, SdCardMountedIF& sdcMan); ReturnValue_t passPacket(PusTmReader& reader); ReturnValue_t storePacket(PusTmReader& reader); @@ -34,14 +34,19 @@ class TmStore : public SystemObject { */ MessageQueueId_t getCommandQueue(); PacketFilter filter; + bool baseDirUninitialized = true; std::string baseName; - RolloverInterval interval; - uint8_t intervalFactor; + std::filesystem::path baseDir; + uint32_t rolloverDiffSeconds = 0; char NAME_BUF[524] = {}; std::array fileBuf{}; std::optional mostRecentTv; std::optional mostRecentFile; SdCardMountedIF& sdcMan; + + void calcDiffSeconds(RolloverInterval intervalUnit, uint32_t intervalCount); + void updateBaseDir(); + void assignMostRecentFile(); }; #endif /* MISSION_TMTC_TMSTOREBACKEND_H_ */ From 1f381d9477291371108db02db2125684dfeeb7ab Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 12 Dec 2022 18:42:51 +0100 Subject: [PATCH 019/373] implemented core write --- mission/tmtc/TmStore.cpp | 21 +++++++++++++++++---- mission/tmtc/TmStore.h | 6 ++++-- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/mission/tmtc/TmStore.cpp b/mission/tmtc/TmStore.cpp index 5c3f00c8..d29538ed 100644 --- a/mission/tmtc/TmStore.cpp +++ b/mission/tmtc/TmStore.cpp @@ -5,6 +5,7 @@ #include #include #include +#include using namespace returnvalue; @@ -58,10 +59,18 @@ ReturnValue_t TmStore::storePacket(PusTmReader& reader) { if (not mostRecentFile) { assignMostRecentFile(); } - // TODO: Need to find the file of the most recent file. - // TODO: If file exists: Determine whether file rolls over: Maximum file size reached? Interval - // since last timestamp exceeds rollover interval? - // TODO: If file does not exist or rollover criteria met: Create new file with current timestamp. + + if (currentTv.tv_sec < mostRecentTv.value().tv_sec or + currentTv.tv_sec - mostRecentTv.value().tv_sec > static_cast(rolloverDiffSeconds)) { + if (file_size(mostRecentFile.value()) + reader.getFullPacketLen() > fileBuf.size()) { + // TODO: Rename old file to XYZ.1..z , create new file with the same name as old one, + // update most recent file with that name + } + } + + // Rollover conditions were handled, write to file now + std::ofstream of(mostRecentFile.value(), std::ios::app | std::ios::binary); + of.write(reinterpret_cast(reader.getFullData()), reader.getFullPacketLen()); return returnvalue::OK; } @@ -85,6 +94,8 @@ void TmStore::updateBaseDir() { baseDirUninitialized = false; } +ReturnValue_t TmStore::updateCurrentTimestamp() { return Clock::getClock_timeval(¤tTv); } + void TmStore::assignMostRecentFile() { using namespace std::filesystem; for (auto const& file : directory_iterator(baseDir)) { @@ -113,3 +124,5 @@ void TmStore::assignMostRecentFile() { } } } + +ReturnValue_t TmStore::storePacketInternal(PusTmReader& reader) { return returnvalue::OK; } diff --git a/mission/tmtc/TmStore.h b/mission/tmtc/TmStore.h index f26461e7..3151a818 100644 --- a/mission/tmtc/TmStore.h +++ b/mission/tmtc/TmStore.h @@ -22,6 +22,8 @@ class TmStore : public SystemObject { TmStore(object_id_t objectId, std::string baseName, RolloverInterval intervalUnit, uint32_t intervalCount, PacketFilter filter, SdCardMountedIF& sdcMan); + void updateBaseDir(); + ReturnValue_t updateCurrentTimestamp(); ReturnValue_t passPacket(PusTmReader& reader); ReturnValue_t storePacket(PusTmReader& reader); @@ -38,15 +40,15 @@ class TmStore : public SystemObject { std::string baseName; std::filesystem::path baseDir; uint32_t rolloverDiffSeconds = 0; - char NAME_BUF[524] = {}; std::array fileBuf{}; + timeval currentTv{}; std::optional mostRecentTv; std::optional mostRecentFile; SdCardMountedIF& sdcMan; void calcDiffSeconds(RolloverInterval intervalUnit, uint32_t intervalCount); - void updateBaseDir(); void assignMostRecentFile(); + ReturnValue_t storePacketInternal(PusTmReader& reader); }; #endif /* MISSION_TMTC_TMSTOREBACKEND_H_ */ From e62c527d05b095b1a7006a452792d365f0b71608 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 13 Dec 2022 10:07:36 +0100 Subject: [PATCH 020/373] create files as well --- mission/tmtc/TmStore.cpp | 31 +++++++++++++++++++++++++++---- mission/tmtc/TmStore.h | 2 +- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/mission/tmtc/TmStore.cpp b/mission/tmtc/TmStore.cpp index d29538ed..18a32cb7 100644 --- a/mission/tmtc/TmStore.cpp +++ b/mission/tmtc/TmStore.cpp @@ -57,14 +57,23 @@ ReturnValue_t TmStore::storePacket(PusTmReader& reader) { } // It is assumed here that the filesystem is usable. if (not mostRecentFile) { - assignMostRecentFile(); + assignAndOrCreateMostRecentFile(); } if (currentTv.tv_sec < mostRecentTv.value().tv_sec or currentTv.tv_sec - mostRecentTv.value().tv_sec > static_cast(rolloverDiffSeconds)) { if (file_size(mostRecentFile.value()) + reader.getFullPacketLen() > fileBuf.size()) { - // TODO: Rename old file to XYZ.1..z , create new file with the same name as old one, - // update most recent file with that name + uint8_t appendedCounter = 1; + path rolloverName; + while (true) { + rolloverName = path(mostRecentFile.value().string() + std::to_string(appendedCounter)); + if (not exists(rolloverName)) { + break; + } + appendedCounter++; + } + rename(mostRecentFile.value(), rolloverName); + std::ofstream of(mostRecentFile.value(), std::ios::binary); } } @@ -96,7 +105,7 @@ void TmStore::updateBaseDir() { ReturnValue_t TmStore::updateCurrentTimestamp() { return Clock::getClock_timeval(¤tTv); } -void TmStore::assignMostRecentFile() { +void TmStore::assignAndOrCreateMostRecentFile() { using namespace std::filesystem; for (auto const& file : directory_iterator(baseDir)) { if (file.is_directory()) { @@ -123,6 +132,20 @@ void TmStore::assignMostRecentFile() { mostRecentFile = file.path(); } } + if (not mostRecentFile) { + updateCurrentTimestamp(); + unsigned currentIdx = 0; + memcpy(fileBuf.data() + currentIdx, baseName.data(), baseName.size()); + currentIdx += baseName.size(); + Clock::TimeOfDay_t tod; + Clock::convertTimevalToTimeOfDay(¤tTv, &tod); + currentIdx += sprintf(reinterpret_cast(fileBuf.data() + currentIdx), + "%4" SCNu32 "-%2" SCNu32 "-%2" SCNu32 "T%2" SCNu32 ":%2" SCNu32 + ":%2" SCNu32 "Z.bin", + tod.year, tod.month, tod.day, tod.hour, tod.minute, tod.second); + path newPath(std::string(reinterpret_cast(fileBuf.data()), currentIdx)); + std::ofstream of(newPath, std::ios::binary); + } } ReturnValue_t TmStore::storePacketInternal(PusTmReader& reader) { return returnvalue::OK; } diff --git a/mission/tmtc/TmStore.h b/mission/tmtc/TmStore.h index 3151a818..98e7bc62 100644 --- a/mission/tmtc/TmStore.h +++ b/mission/tmtc/TmStore.h @@ -47,7 +47,7 @@ class TmStore : public SystemObject { SdCardMountedIF& sdcMan; void calcDiffSeconds(RolloverInterval intervalUnit, uint32_t intervalCount); - void assignMostRecentFile(); + void assignAndOrCreateMostRecentFile(); ReturnValue_t storePacketInternal(PusTmReader& reader); }; From 04b04ed8595fda148b692a9d661325777501e158 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 13 Dec 2022 10:08:31 +0100 Subject: [PATCH 021/373] update state as well --- mission/tmtc/TmStore.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mission/tmtc/TmStore.cpp b/mission/tmtc/TmStore.cpp index 18a32cb7..e5adc4a8 100644 --- a/mission/tmtc/TmStore.cpp +++ b/mission/tmtc/TmStore.cpp @@ -145,6 +145,8 @@ void TmStore::assignAndOrCreateMostRecentFile() { tod.year, tod.month, tod.day, tod.hour, tod.minute, tod.second); path newPath(std::string(reinterpret_cast(fileBuf.data()), currentIdx)); std::ofstream of(newPath, std::ios::binary); + mostRecentFile = newPath; + mostRecentTv = currentTv; } } From eddc620307622c3adddf9b24e03210d2cfeef36a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 13 Dec 2022 13:46:49 +0100 Subject: [PATCH 022/373] interval calculation bugfix --- mission/tmtc/TmStore.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mission/tmtc/TmStore.cpp b/mission/tmtc/TmStore.cpp index e5adc4a8..8863dfe6 100644 --- a/mission/tmtc/TmStore.cpp +++ b/mission/tmtc/TmStore.cpp @@ -87,9 +87,9 @@ MessageQueueId_t TmStore::getCommandQueue() { return MessageQueueIF::NO_QUEUE; } void TmStore::calcDiffSeconds(RolloverInterval intervalUnit, uint32_t intervalCount) { if (intervalUnit == RolloverInterval::HOURLY) { - rolloverDiffSeconds = 60 * intervalCount; + rolloverDiffSeconds = 60 * 60 * intervalCount; } else if (intervalUnit == RolloverInterval::DAILY) { - rolloverDiffSeconds = 60 * 24 * intervalCount; + rolloverDiffSeconds = 60 * 60 * 24 * intervalCount; } } From 3965c08bfb7afb2bacd37a5082d368c5ad5d2421 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 13 Dec 2022 14:19:43 +0100 Subject: [PATCH 023/373] add misc store --- bsp_q7s/fmObjectFactory.cpp | 3 ++- common/config/eive/objects.h | 1 + mission/core/GenericFactory.cpp | 4 ++-- mission/core/GenericFactory.h | 4 +++- mission/tmtc/PusTmFunnel.cpp | 7 +++++-- mission/tmtc/PusTmFunnel.h | 4 +++- mission/tmtc/TmStore.cpp | 19 ++++++++++++++++--- mission/tmtc/TmStore.h | 6 ++++-- 8 files changed, 36 insertions(+), 12 deletions(-) diff --git a/bsp_q7s/fmObjectFactory.cpp b/bsp_q7s/fmObjectFactory.cpp index c56dcf8d..e14dcbe6 100644 --- a/bsp_q7s/fmObjectFactory.cpp +++ b/bsp_q7s/fmObjectFactory.cpp @@ -18,7 +18,8 @@ void ObjectFactory::produce(void* args) { HealthTableIF* healthTable = nullptr; PusTmFunnel* pusFunnel = nullptr; CfdpTmFunnel* cfdpFunnel = nullptr; - ObjectFactory::produceGenericObjects(&healthTable, &pusFunnel, &cfdpFunnel); + ObjectFactory::produceGenericObjects(&healthTable, &pusFunnel, &cfdpFunnel, + *SdCardManager::instance()); LinuxLibgpioIF* gpioComIF = nullptr; SerialComIF* uartComIF = nullptr; diff --git a/common/config/eive/objects.h b/common/config/eive/objects.h index 9fb4aeff..0c592913 100644 --- a/common/config/eive/objects.h +++ b/common/config/eive/objects.h @@ -146,6 +146,7 @@ enum commonObjects : uint32_t { CFDP_TM_FUNNEL = 0x73000102, CFDP_HANDLER = 0x73000205, CFDP_DISTRIBUTOR = 0x73000206, + MISC_STORE = 0x73020001, }; } diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index cca48baf..c0e1eb43 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -68,7 +68,7 @@ EiveFaultHandler EIVE_FAULT_HANDLER; } // namespace cfdp void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFunnel** pusFunnel, - CfdpTmFunnel** cfdpFunnel) { + CfdpTmFunnel** cfdpFunnel, SdCardMountedIF& sdcMan) { // Framework objects new EventManager(objects::EVENT_MANAGER); auto healthTable = new HealthTable(objects::HEALTH_TABLE); @@ -122,7 +122,7 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFun new PusDistributor(config::EIVE_PUS_APID, objects::PUS_PACKET_DISTRIBUTOR, ccsdsDistrib); *cfdpFunnel = new CfdpTmFunnel(objects::CFDP_TM_FUNNEL, config::EIVE_CFDP_APID, *tmStore, 50); - *pusFunnel = new PusTmFunnel(objects::PUS_TM_FUNNEL, *timeStamper, *tmStore, 80); + *pusFunnel = new PusTmFunnel(objects::PUS_TM_FUNNEL, *timeStamper, *tmStore, sdcMan, 80); #if OBSW_ADD_TCPIP_SERVERS == 1 #if OBSW_ADD_TMTC_UDP_SERVER == 1 (*cfdpFunnel)->addDestination(*udpBridge, 0); diff --git a/mission/core/GenericFactory.h b/mission/core/GenericFactory.h index 2e2b0748..050a316d 100644 --- a/mission/core/GenericFactory.h +++ b/mission/core/GenericFactory.h @@ -1,6 +1,8 @@ #ifndef MISSION_CORE_GENERICFACTORY_H_ #define MISSION_CORE_GENERICFACTORY_H_ +#include + class HealthTableIF; class PusTmFunnel; class CfdpTmFunnel; @@ -8,7 +10,7 @@ class CfdpTmFunnel; namespace ObjectFactory { void produceGenericObjects(HealthTableIF** healthTable, PusTmFunnel** pusFunnel, - CfdpTmFunnel** cfdpFunnel); + CfdpTmFunnel** cfdpFunnel, SdCardMountedIF& sdcMan); } diff --git a/mission/tmtc/PusTmFunnel.cpp b/mission/tmtc/PusTmFunnel.cpp index 5d6bbb4d..4a3b6588 100644 --- a/mission/tmtc/PusTmFunnel.cpp +++ b/mission/tmtc/PusTmFunnel.cpp @@ -1,12 +1,15 @@ #include "PusTmFunnel.h" +#include "eive/objects.h" #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager.h" #include "fsfw/tmtcpacket/pus/tm/PusTmZcWriter.h" PusTmFunnel::PusTmFunnel(object_id_t objectId, TimeReaderIF &timeReader, StorageManagerIF &tmStore, - uint32_t messageDepth) - : TmFunnelBase(objectId, tmStore, messageDepth), timeReader(timeReader) {} + SdCardMountedIF &sdcMan, uint32_t messageDepth) + : TmFunnelBase(objectId, tmStore, messageDepth), + timeReader(timeReader), + miscStore(objects::MISC_STORE, "misc", RolloverInterval::HOURLY, 8, sdcMan) {} PusTmFunnel::~PusTmFunnel() = default; diff --git a/mission/tmtc/PusTmFunnel.h b/mission/tmtc/PusTmFunnel.h index ca9a6016..96a9d33d 100644 --- a/mission/tmtc/PusTmFunnel.h +++ b/mission/tmtc/PusTmFunnel.h @@ -10,6 +10,7 @@ #include +#include "TmStore.h" #include "fsfw/timemanager/TimeReaderIF.h" /** @@ -26,7 +27,7 @@ class PusTmFunnel : public TmFunnelBase { public: explicit PusTmFunnel(object_id_t objectId, TimeReaderIF &timeReader, StorageManagerIF &tmStore, - uint32_t messageDepth = 10); + SdCardMountedIF &sdcMan, uint32_t messageDepth = 10); [[nodiscard]] const char *getName() const override; ~PusTmFunnel() override; @@ -35,6 +36,7 @@ class PusTmFunnel : public TmFunnelBase { private: uint16_t sourceSequenceCount = 0; TimeReaderIF &timeReader; + TmStore miscStore; ReturnValue_t handlePacket(TmTcMessage &message); }; diff --git a/mission/tmtc/TmStore.cpp b/mission/tmtc/TmStore.cpp index 8863dfe6..40dbf726 100644 --- a/mission/tmtc/TmStore.cpp +++ b/mission/tmtc/TmStore.cpp @@ -10,8 +10,8 @@ using namespace returnvalue; TmStore::TmStore(object_id_t objectId, std::string baseName, RolloverInterval intervalUnit, - uint32_t intervalCount, PacketFilter filter, SdCardMountedIF& sdcMan) - : SystemObject(objectId), filter(filter), baseName(std::move(baseName)), sdcMan(sdcMan) { + uint32_t intervalCount, SdCardMountedIF& sdcMan) + : SystemObject(objectId), baseName(std::move(baseName)), sdcMan(sdcMan) { calcDiffSeconds(intervalUnit, intervalCount); } @@ -150,4 +150,17 @@ void TmStore::assignAndOrCreateMostRecentFile() { } } -ReturnValue_t TmStore::storePacketInternal(PusTmReader& reader) { return returnvalue::OK; } +void TmStore::addApid(uint16_t apid) { + if (not filter.apid) { + filter.apid = std::vector(apid); + return; + } + filter.apid.value().push_back(apid); +} + +void TmStore::addService(uint8_t service) { + if (not filter.services) { + filter.services = std::vector(service); + } + filter.services.value().push_back(service); +} diff --git a/mission/tmtc/TmStore.h b/mission/tmtc/TmStore.h index 98e7bc62..4a873750 100644 --- a/mission/tmtc/TmStore.h +++ b/mission/tmtc/TmStore.h @@ -20,7 +20,10 @@ enum class RolloverInterval { HOURLY, DAILY }; class TmStore : public SystemObject { public: TmStore(object_id_t objectId, std::string baseName, RolloverInterval intervalUnit, - uint32_t intervalCount, PacketFilter filter, SdCardMountedIF& sdcMan); + uint32_t intervalCount, SdCardMountedIF& sdcMan); + + void addApid(uint16_t apid); + void addService(uint8_t service); void updateBaseDir(); ReturnValue_t updateCurrentTimestamp(); @@ -48,7 +51,6 @@ class TmStore : public SystemObject { void calcDiffSeconds(RolloverInterval intervalUnit, uint32_t intervalCount); void assignAndOrCreateMostRecentFile(); - ReturnValue_t storePacketInternal(PusTmReader& reader); }; #endif /* MISSION_TMTC_TMSTOREBACKEND_H_ */ From 828d791da5fece7118e1eb29e443331efc3abc48 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 13 Dec 2022 14:26:20 +0100 Subject: [PATCH 024/373] add misc store --- mission/tmtc/PusTmFunnel.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mission/tmtc/PusTmFunnel.cpp b/mission/tmtc/PusTmFunnel.cpp index 4a3b6588..1eb59ba4 100644 --- a/mission/tmtc/PusTmFunnel.cpp +++ b/mission/tmtc/PusTmFunnel.cpp @@ -1,5 +1,6 @@ #include "PusTmFunnel.h" +#include "eive/definitions.h" #include "eive/objects.h" #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager.h" @@ -9,7 +10,10 @@ PusTmFunnel::PusTmFunnel(object_id_t objectId, TimeReaderIF &timeReader, Storage SdCardMountedIF &sdcMan, uint32_t messageDepth) : TmFunnelBase(objectId, tmStore, messageDepth), timeReader(timeReader), - miscStore(objects::MISC_STORE, "misc", RolloverInterval::HOURLY, 8, sdcMan) {} + miscStore(objects::MISC_STORE, "misc", RolloverInterval::HOURLY, 8, sdcMan) { + miscStore.addApid(config::EIVE_PUS_APID); + miscStore.addService(17); +} PusTmFunnel::~PusTmFunnel() = default; From fcc9858b66be492c1ffc854553917426c9e2fa72 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 13 Dec 2022 14:30:16 +0100 Subject: [PATCH 025/373] use new packet store --- mission/tmtc/PusTmFunnel.cpp | 12 ++++++++++-- mission/tmtc/PusTmFunnel.h | 1 + mission/tmtc/TmStore.h | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/mission/tmtc/PusTmFunnel.cpp b/mission/tmtc/PusTmFunnel.cpp index 1eb59ba4..f34ffb2b 100644 --- a/mission/tmtc/PusTmFunnel.cpp +++ b/mission/tmtc/PusTmFunnel.cpp @@ -11,8 +11,8 @@ PusTmFunnel::PusTmFunnel(object_id_t objectId, TimeReaderIF &timeReader, Storage : TmFunnelBase(objectId, tmStore, messageDepth), timeReader(timeReader), miscStore(objects::MISC_STORE, "misc", RolloverInterval::HOURLY, 8, sdcMan) { - miscStore.addApid(config::EIVE_PUS_APID); - miscStore.addService(17); + miscStore.addApid(config::EIVE_PUS_APID); + miscStore.addService(17); } PusTmFunnel::~PusTmFunnel() = default; @@ -55,6 +55,8 @@ ReturnValue_t PusTmFunnel::handlePacket(TmTcMessage &message) { sourceSequenceCount = sourceSequenceCount % ccsds::LIMIT_SEQUENCE_COUNT; packet.updateErrorControl(); + miscStore.passPacket(packet); + for (unsigned int idx = 0; idx < destinations.size(); idx++) { const auto &destVcidPair = destinations[idx]; if (destinations.size() > 1) { @@ -87,3 +89,9 @@ ReturnValue_t PusTmFunnel::handlePacket(TmTcMessage &message) { } const char *PusTmFunnel::getName() const { return "PUS TM Funnel"; } + +ReturnValue_t PusTmFunnel::initialize() { + miscStore.updateBaseDir(); + miscStore.updateCurrentTimestamp(); + return returnvalue::OK; +} diff --git a/mission/tmtc/PusTmFunnel.h b/mission/tmtc/PusTmFunnel.h index 96a9d33d..f4285375 100644 --- a/mission/tmtc/PusTmFunnel.h +++ b/mission/tmtc/PusTmFunnel.h @@ -39,6 +39,7 @@ class PusTmFunnel : public TmFunnelBase { TmStore miscStore; ReturnValue_t handlePacket(TmTcMessage &message); + ReturnValue_t initialize() override; }; #endif // FSFW_EXAMPLE_COMMON_PUSTMFUNNEL_H diff --git a/mission/tmtc/TmStore.h b/mission/tmtc/TmStore.h index 4a873750..954c3944 100644 --- a/mission/tmtc/TmStore.h +++ b/mission/tmtc/TmStore.h @@ -28,7 +28,6 @@ class TmStore : public SystemObject { void updateBaseDir(); ReturnValue_t updateCurrentTimestamp(); ReturnValue_t passPacket(PusTmReader& reader); - ReturnValue_t storePacket(PusTmReader& reader); private: static constexpr size_t MAX_FILESIZE = 8192; @@ -51,6 +50,7 @@ class TmStore : public SystemObject { void calcDiffSeconds(RolloverInterval intervalUnit, uint32_t intervalCount); void assignAndOrCreateMostRecentFile(); + ReturnValue_t storePacket(PusTmReader& reader); }; #endif /* MISSION_TMTC_TMSTOREBACKEND_H_ */ From 33ac72de835f2a7aa51f7d9352189a01744a40b5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 13 Dec 2022 14:33:16 +0100 Subject: [PATCH 026/373] check whether SD card is usable --- mission/tmtc/PusTmFunnel.cpp | 7 +++++-- mission/tmtc/PusTmFunnel.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/mission/tmtc/PusTmFunnel.cpp b/mission/tmtc/PusTmFunnel.cpp index f34ffb2b..f506bbd6 100644 --- a/mission/tmtc/PusTmFunnel.cpp +++ b/mission/tmtc/PusTmFunnel.cpp @@ -10,7 +10,8 @@ PusTmFunnel::PusTmFunnel(object_id_t objectId, TimeReaderIF &timeReader, Storage SdCardMountedIF &sdcMan, uint32_t messageDepth) : TmFunnelBase(objectId, tmStore, messageDepth), timeReader(timeReader), - miscStore(objects::MISC_STORE, "misc", RolloverInterval::HOURLY, 8, sdcMan) { + miscStore(objects::MISC_STORE, "misc", RolloverInterval::HOURLY, 8, sdcMan), + sdcMan(sdcMan) { miscStore.addApid(config::EIVE_PUS_APID); miscStore.addService(17); } @@ -55,7 +56,9 @@ ReturnValue_t PusTmFunnel::handlePacket(TmTcMessage &message) { sourceSequenceCount = sourceSequenceCount % ccsds::LIMIT_SEQUENCE_COUNT; packet.updateErrorControl(); - miscStore.passPacket(packet); + if(sdcMan.isSdCardUsable(std::nullopt)) { + miscStore.passPacket(packet); + } for (unsigned int idx = 0; idx < destinations.size(); idx++) { const auto &destVcidPair = destinations[idx]; diff --git a/mission/tmtc/PusTmFunnel.h b/mission/tmtc/PusTmFunnel.h index f4285375..82d6a0cb 100644 --- a/mission/tmtc/PusTmFunnel.h +++ b/mission/tmtc/PusTmFunnel.h @@ -37,6 +37,7 @@ class PusTmFunnel : public TmFunnelBase { uint16_t sourceSequenceCount = 0; TimeReaderIF &timeReader; TmStore miscStore; + SdCardMountedIF& sdcMan; ReturnValue_t handlePacket(TmTcMessage &message); ReturnValue_t initialize() override; From 130a3ce727d4fb9fe13aac23fc84a1594e8c0730 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 13 Dec 2022 14:38:30 +0100 Subject: [PATCH 027/373] initialize stores as well --- mission/tmtc/PusTmFunnel.cpp | 18 +++++++++++++----- mission/tmtc/PusTmFunnel.h | 3 ++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/mission/tmtc/PusTmFunnel.cpp b/mission/tmtc/PusTmFunnel.cpp index f506bbd6..920cb494 100644 --- a/mission/tmtc/PusTmFunnel.cpp +++ b/mission/tmtc/PusTmFunnel.cpp @@ -11,7 +11,7 @@ PusTmFunnel::PusTmFunnel(object_id_t objectId, TimeReaderIF &timeReader, Storage : TmFunnelBase(objectId, tmStore, messageDepth), timeReader(timeReader), miscStore(objects::MISC_STORE, "misc", RolloverInterval::HOURLY, 8, sdcMan), - sdcMan(sdcMan) { + sdcMan(sdcMan) { miscStore.addApid(config::EIVE_PUS_APID); miscStore.addService(17); } @@ -56,8 +56,13 @@ ReturnValue_t PusTmFunnel::handlePacket(TmTcMessage &message) { sourceSequenceCount = sourceSequenceCount % ccsds::LIMIT_SEQUENCE_COUNT; packet.updateErrorControl(); - if(sdcMan.isSdCardUsable(std::nullopt)) { - miscStore.passPacket(packet); + if (sdcMan.isSdCardUsable(std::nullopt)) { + if (not storesInitialized) { + miscStore.updateBaseDir(); + miscStore.updateCurrentTimestamp(); + storesInitialized = true; + } + miscStore.passPacket(packet); } for (unsigned int idx = 0; idx < destinations.size(); idx++) { @@ -94,7 +99,10 @@ ReturnValue_t PusTmFunnel::handlePacket(TmTcMessage &message) { const char *PusTmFunnel::getName() const { return "PUS TM Funnel"; } ReturnValue_t PusTmFunnel::initialize() { - miscStore.updateBaseDir(); - miscStore.updateCurrentTimestamp(); + if (not storesInitialized and sdcMan.isSdCardUsable(std::nullopt)) { + miscStore.updateBaseDir(); + miscStore.updateCurrentTimestamp(); + storesInitialized = true; + } return returnvalue::OK; } diff --git a/mission/tmtc/PusTmFunnel.h b/mission/tmtc/PusTmFunnel.h index 82d6a0cb..57045d91 100644 --- a/mission/tmtc/PusTmFunnel.h +++ b/mission/tmtc/PusTmFunnel.h @@ -36,8 +36,9 @@ class PusTmFunnel : public TmFunnelBase { private: uint16_t sourceSequenceCount = 0; TimeReaderIF &timeReader; + bool storesInitialized = false; TmStore miscStore; - SdCardMountedIF& sdcMan; + SdCardMountedIF &sdcMan; ReturnValue_t handlePacket(TmTcMessage &message); ReturnValue_t initialize() override; From 8c10cbe37b1a53147c50b6ab89cbf480e5fd8d8d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 13 Dec 2022 15:24:51 +0100 Subject: [PATCH 028/373] the stores only keep references to the current time --- common/config/eive/objects.h | 1 + mission/tmtc/PusTmFunnel.cpp | 11 ++++++++--- mission/tmtc/PusTmFunnel.h | 2 ++ mission/tmtc/TmStore.cpp | 7 ++----- mission/tmtc/TmStore.h | 5 ++--- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/common/config/eive/objects.h b/common/config/eive/objects.h index 0c592913..83b103ce 100644 --- a/common/config/eive/objects.h +++ b/common/config/eive/objects.h @@ -147,6 +147,7 @@ enum commonObjects : uint32_t { CFDP_HANDLER = 0x73000205, CFDP_DISTRIBUTOR = 0x73000206, MISC_STORE = 0x73020001, + EVENT_STORE = 0x73020002, }; } diff --git a/mission/tmtc/PusTmFunnel.cpp b/mission/tmtc/PusTmFunnel.cpp index 920cb494..d7453f12 100644 --- a/mission/tmtc/PusTmFunnel.cpp +++ b/mission/tmtc/PusTmFunnel.cpp @@ -10,10 +10,14 @@ PusTmFunnel::PusTmFunnel(object_id_t objectId, TimeReaderIF &timeReader, Storage SdCardMountedIF &sdcMan, uint32_t messageDepth) : TmFunnelBase(objectId, tmStore, messageDepth), timeReader(timeReader), - miscStore(objects::MISC_STORE, "misc", RolloverInterval::HOURLY, 8, sdcMan), + miscStore(objects::MISC_STORE, "misc", RolloverInterval::HOURLY, 8, currentTv, sdcMan), + eventStore(objects::EVENT_STORE, "event", RolloverInterval::HOURLY, 1, currentTv, sdcMan), sdcMan(sdcMan) { + Clock::getClock_timeval(¤tTv); miscStore.addApid(config::EIVE_PUS_APID); miscStore.addService(17); + eventStore.addApid(config::EIVE_PUS_APID); + eventStore.addService(5); } PusTmFunnel::~PusTmFunnel() = default; @@ -59,10 +63,11 @@ ReturnValue_t PusTmFunnel::handlePacket(TmTcMessage &message) { if (sdcMan.isSdCardUsable(std::nullopt)) { if (not storesInitialized) { miscStore.updateBaseDir(); - miscStore.updateCurrentTimestamp(); + eventStore.updateBaseDir(); storesInitialized = true; } miscStore.passPacket(packet); + eventStore.passPacket(packet); } for (unsigned int idx = 0; idx < destinations.size(); idx++) { @@ -101,7 +106,7 @@ const char *PusTmFunnel::getName() const { return "PUS TM Funnel"; } ReturnValue_t PusTmFunnel::initialize() { if (not storesInitialized and sdcMan.isSdCardUsable(std::nullopt)) { miscStore.updateBaseDir(); - miscStore.updateCurrentTimestamp(); + eventStore.updateBaseDir(); storesInitialized = true; } return returnvalue::OK; diff --git a/mission/tmtc/PusTmFunnel.h b/mission/tmtc/PusTmFunnel.h index 57045d91..3e3c8545 100644 --- a/mission/tmtc/PusTmFunnel.h +++ b/mission/tmtc/PusTmFunnel.h @@ -37,7 +37,9 @@ class PusTmFunnel : public TmFunnelBase { uint16_t sourceSequenceCount = 0; TimeReaderIF &timeReader; bool storesInitialized = false; + timeval currentTv; TmStore miscStore; + TmStore eventStore; SdCardMountedIF &sdcMan; ReturnValue_t handlePacket(TmTcMessage &message); diff --git a/mission/tmtc/TmStore.cpp b/mission/tmtc/TmStore.cpp index 40dbf726..5ae6dcc7 100644 --- a/mission/tmtc/TmStore.cpp +++ b/mission/tmtc/TmStore.cpp @@ -10,8 +10,8 @@ using namespace returnvalue; TmStore::TmStore(object_id_t objectId, std::string baseName, RolloverInterval intervalUnit, - uint32_t intervalCount, SdCardMountedIF& sdcMan) - : SystemObject(objectId), baseName(std::move(baseName)), sdcMan(sdcMan) { + uint32_t intervalCount, timeval& currentTv, SdCardMountedIF& sdcMan) + : SystemObject(objectId), baseName(std::move(baseName)), currentTv(currentTv), sdcMan(sdcMan) { calcDiffSeconds(intervalUnit, intervalCount); } @@ -103,8 +103,6 @@ void TmStore::updateBaseDir() { baseDirUninitialized = false; } -ReturnValue_t TmStore::updateCurrentTimestamp() { return Clock::getClock_timeval(¤tTv); } - void TmStore::assignAndOrCreateMostRecentFile() { using namespace std::filesystem; for (auto const& file : directory_iterator(baseDir)) { @@ -133,7 +131,6 @@ void TmStore::assignAndOrCreateMostRecentFile() { } } if (not mostRecentFile) { - updateCurrentTimestamp(); unsigned currentIdx = 0; memcpy(fileBuf.data() + currentIdx, baseName.data(), baseName.size()); currentIdx += baseName.size(); diff --git a/mission/tmtc/TmStore.h b/mission/tmtc/TmStore.h index 954c3944..9d20bbe4 100644 --- a/mission/tmtc/TmStore.h +++ b/mission/tmtc/TmStore.h @@ -20,13 +20,12 @@ enum class RolloverInterval { HOURLY, DAILY }; class TmStore : public SystemObject { public: TmStore(object_id_t objectId, std::string baseName, RolloverInterval intervalUnit, - uint32_t intervalCount, SdCardMountedIF& sdcMan); + uint32_t intervalCount, timeval& currentTv, SdCardMountedIF& sdcMan); void addApid(uint16_t apid); void addService(uint8_t service); void updateBaseDir(); - ReturnValue_t updateCurrentTimestamp(); ReturnValue_t passPacket(PusTmReader& reader); private: @@ -43,7 +42,7 @@ class TmStore : public SystemObject { std::filesystem::path baseDir; uint32_t rolloverDiffSeconds = 0; std::array fileBuf{}; - timeval currentTv{}; + timeval& currentTv; std::optional mostRecentTv; std::optional mostRecentFile; SdCardMountedIF& sdcMan; From 283b897ae703b0d627ce06e54cb5200d57892776 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 13 Dec 2022 15:34:13 +0100 Subject: [PATCH 029/373] allow minutely rollover as well --- mission/tmtc/TmStore.cpp | 4 +++- mission/tmtc/TmStore.h | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/mission/tmtc/TmStore.cpp b/mission/tmtc/TmStore.cpp index 5ae6dcc7..6ec49da8 100644 --- a/mission/tmtc/TmStore.cpp +++ b/mission/tmtc/TmStore.cpp @@ -86,7 +86,9 @@ ReturnValue_t TmStore::storePacket(PusTmReader& reader) { MessageQueueId_t TmStore::getCommandQueue() { return MessageQueueIF::NO_QUEUE; } void TmStore::calcDiffSeconds(RolloverInterval intervalUnit, uint32_t intervalCount) { - if (intervalUnit == RolloverInterval::HOURLY) { + if (intervalUnit == RolloverInterval::MINUTELY) { + rolloverDiffSeconds = 60 * intervalCount; + } else if (intervalUnit == RolloverInterval::HOURLY) { rolloverDiffSeconds = 60 * 60 * intervalCount; } else if (intervalUnit == RolloverInterval::DAILY) { rolloverDiffSeconds = 60 * 60 * 24 * intervalCount; diff --git a/mission/tmtc/TmStore.h b/mission/tmtc/TmStore.h index 9d20bbe4..193a1db5 100644 --- a/mission/tmtc/TmStore.h +++ b/mission/tmtc/TmStore.h @@ -15,7 +15,7 @@ struct PacketFilter { std::optional>> serviceSubservices; }; -enum class RolloverInterval { HOURLY, DAILY }; +enum class RolloverInterval { MINUTELY, HOURLY, DAILY }; class TmStore : public SystemObject { public: @@ -41,7 +41,7 @@ class TmStore : public SystemObject { std::string baseName; std::filesystem::path baseDir; uint32_t rolloverDiffSeconds = 0; - std::array fileBuf{}; + std::array fileBuf{}; timeval& currentTv; std::optional mostRecentTv; std::optional mostRecentFile; From 8858084f6ef32948cfab2c226d95cde58712a89b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 13 Dec 2022 15:35:39 +0100 Subject: [PATCH 030/373] introduce new second interval --- mission/tmtc/PusTmFunnel.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mission/tmtc/PusTmFunnel.h b/mission/tmtc/PusTmFunnel.h index 3e3c8545..683fcbd2 100644 --- a/mission/tmtc/PusTmFunnel.h +++ b/mission/tmtc/PusTmFunnel.h @@ -34,6 +34,9 @@ class PusTmFunnel : public TmFunnelBase { ReturnValue_t performOperation(uint8_t operationCode); private: + // Update TV stamp every 5 minutes + static constexpr dur_millis_t TV_UPDATE_INTERVAL_SECS = 60 * 5; + uint16_t sourceSequenceCount = 0; TimeReaderIF &timeReader; bool storesInitialized = false; From 3e17de0127cdfb54110eb4686af0e239caf70b04 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 13 Dec 2022 15:43:41 +0100 Subject: [PATCH 031/373] update clock every 5 minutes --- mission/tmtc/PusTmFunnel.cpp | 9 +++++++++ mission/tmtc/PusTmFunnel.h | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/mission/tmtc/PusTmFunnel.cpp b/mission/tmtc/PusTmFunnel.cpp index d7453f12..832656e7 100644 --- a/mission/tmtc/PusTmFunnel.cpp +++ b/mission/tmtc/PusTmFunnel.cpp @@ -14,6 +14,7 @@ PusTmFunnel::PusTmFunnel(object_id_t objectId, TimeReaderIF &timeReader, Storage eventStore(objects::EVENT_STORE, "event", RolloverInterval::HOURLY, 1, currentTv, sdcMan), sdcMan(sdcMan) { Clock::getClock_timeval(¤tTv); + Clock::getUptime(&lastTvUpdate); miscStore.addApid(config::EIVE_PUS_APID); miscStore.addService(17); eventStore.addApid(config::EIVE_PUS_APID); @@ -60,6 +61,14 @@ ReturnValue_t PusTmFunnel::handlePacket(TmTcMessage &message) { sourceSequenceCount = sourceSequenceCount % ccsds::LIMIT_SEQUENCE_COUNT; packet.updateErrorControl(); + timeval currentUptime; + Clock::getUptime(¤tUptime); + if (currentUptime.tv_sec - lastTvUpdate.tv_sec > + static_cast(TV_UPDATE_INTERVAL_SECS)) { + Clock::getClock_timeval(¤tTv); + lastTvUpdate = currentUptime; + } + if (sdcMan.isSdCardUsable(std::nullopt)) { if (not storesInitialized) { miscStore.updateBaseDir(); diff --git a/mission/tmtc/PusTmFunnel.h b/mission/tmtc/PusTmFunnel.h index 683fcbd2..c4132379 100644 --- a/mission/tmtc/PusTmFunnel.h +++ b/mission/tmtc/PusTmFunnel.h @@ -40,7 +40,8 @@ class PusTmFunnel : public TmFunnelBase { uint16_t sourceSequenceCount = 0; TimeReaderIF &timeReader; bool storesInitialized = false; - timeval currentTv; + timeval currentTv{}; + timeval lastTvUpdate{}; TmStore miscStore; TmStore eventStore; SdCardMountedIF &sdcMan; From d37f48336b922293575791da238b0a4f2f8f4c6d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 13 Dec 2022 15:56:40 +0100 Subject: [PATCH 032/373] ok im done --- common/config/eive/objects.h | 3 ++- mission/tmtc/PusTmFunnel.cpp | 13 +++++++------ mission/tmtc/PusTmFunnel.h | 3 ++- mission/tmtc/TmStore.cpp | 13 +++++++++++-- mission/tmtc/TmStore.h | 1 + 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/common/config/eive/objects.h b/common/config/eive/objects.h index 83b103ce..ede974fb 100644 --- a/common/config/eive/objects.h +++ b/common/config/eive/objects.h @@ -147,7 +147,8 @@ enum commonObjects : uint32_t { CFDP_HANDLER = 0x73000205, CFDP_DISTRIBUTOR = 0x73000206, MISC_STORE = 0x73020001, - EVENT_STORE = 0x73020002, + OK_STORE = 0x73020002, + NOT_OK_STORE = 0x73020003, }; } diff --git a/mission/tmtc/PusTmFunnel.cpp b/mission/tmtc/PusTmFunnel.cpp index 832656e7..c5c0b4eb 100644 --- a/mission/tmtc/PusTmFunnel.cpp +++ b/mission/tmtc/PusTmFunnel.cpp @@ -11,14 +11,15 @@ PusTmFunnel::PusTmFunnel(object_id_t objectId, TimeReaderIF &timeReader, Storage : TmFunnelBase(objectId, tmStore, messageDepth), timeReader(timeReader), miscStore(objects::MISC_STORE, "misc", RolloverInterval::HOURLY, 8, currentTv, sdcMan), - eventStore(objects::EVENT_STORE, "event", RolloverInterval::HOURLY, 1, currentTv, sdcMan), + okStore(objects::OK_STORE, "event", RolloverInterval::MINUTELY, 30, currentTv, sdcMan), + notOkStore(objects::NOT_OK_STORE, "event", RolloverInterval::MINUTELY, 30, currentTv, sdcMan), sdcMan(sdcMan) { Clock::getClock_timeval(¤tTv); Clock::getUptime(&lastTvUpdate); miscStore.addApid(config::EIVE_PUS_APID); miscStore.addService(17); - eventStore.addApid(config::EIVE_PUS_APID); - eventStore.addService(5); + okStore.addApid(config::EIVE_PUS_APID); + okStore.addServiceSubservice(5, 1); } PusTmFunnel::~PusTmFunnel() = default; @@ -72,11 +73,11 @@ ReturnValue_t PusTmFunnel::handlePacket(TmTcMessage &message) { if (sdcMan.isSdCardUsable(std::nullopt)) { if (not storesInitialized) { miscStore.updateBaseDir(); - eventStore.updateBaseDir(); + okStore.updateBaseDir(); storesInitialized = true; } miscStore.passPacket(packet); - eventStore.passPacket(packet); + okStore.passPacket(packet); } for (unsigned int idx = 0; idx < destinations.size(); idx++) { @@ -115,7 +116,7 @@ const char *PusTmFunnel::getName() const { return "PUS TM Funnel"; } ReturnValue_t PusTmFunnel::initialize() { if (not storesInitialized and sdcMan.isSdCardUsable(std::nullopt)) { miscStore.updateBaseDir(); - eventStore.updateBaseDir(); + okStore.updateBaseDir(); storesInitialized = true; } return returnvalue::OK; diff --git a/mission/tmtc/PusTmFunnel.h b/mission/tmtc/PusTmFunnel.h index c4132379..26bbfec2 100644 --- a/mission/tmtc/PusTmFunnel.h +++ b/mission/tmtc/PusTmFunnel.h @@ -43,7 +43,8 @@ class PusTmFunnel : public TmFunnelBase { timeval currentTv{}; timeval lastTvUpdate{}; TmStore miscStore; - TmStore eventStore; + TmStore okStore; + TmStore notOkStore; SdCardMountedIF &sdcMan; ReturnValue_t handlePacket(TmTcMessage &message); diff --git a/mission/tmtc/TmStore.cpp b/mission/tmtc/TmStore.cpp index 6ec49da8..82ccafe9 100644 --- a/mission/tmtc/TmStore.cpp +++ b/mission/tmtc/TmStore.cpp @@ -6,6 +6,7 @@ #include #include #include +#include using namespace returnvalue; @@ -151,7 +152,7 @@ void TmStore::assignAndOrCreateMostRecentFile() { void TmStore::addApid(uint16_t apid) { if (not filter.apid) { - filter.apid = std::vector(apid); + filter.apid = std::vector({apid}); return; } filter.apid.value().push_back(apid); @@ -159,7 +160,15 @@ void TmStore::addApid(uint16_t apid) { void TmStore::addService(uint8_t service) { if (not filter.services) { - filter.services = std::vector(service); + filter.services = std::vector({service}); } filter.services.value().push_back(service); } + +void TmStore::addServiceSubservice(uint8_t service, uint8_t subservice) { + if (not filter.serviceSubservices) { + filter.serviceSubservices = + std::vector>({std::pair(service, subservice)}); + } + filter.serviceSubservices.value().push_back({service, subservice}); +} diff --git a/mission/tmtc/TmStore.h b/mission/tmtc/TmStore.h index 193a1db5..ff141dd1 100644 --- a/mission/tmtc/TmStore.h +++ b/mission/tmtc/TmStore.h @@ -24,6 +24,7 @@ class TmStore : public SystemObject { void addApid(uint16_t apid); void addService(uint8_t service); + void addServiceSubservice(uint8_t service, uint8_t subservice); void updateBaseDir(); ReturnValue_t passPacket(PusTmReader& reader); From 9c217ad91e3f28d786b911e9d4edd94ff65c1c58 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 14 Dec 2022 09:53:38 +0100 Subject: [PATCH 033/373] now hosted should compile again --- bsp_hosted/ObjectFactory.cpp | 4 +++- bsp_linux_board/CMakeLists.txt | 2 +- bsp_linux_board/ObjectFactory.cpp | 2 +- bsp_linux_board/RPiSdCardManager.cpp | 13 ------------- mission/utility/CMakeLists.txt | 2 +- mission/utility/DummySdCardManager.cpp | 13 +++++++++++++ .../utility/DummySdCardManager.h | 6 +++--- 7 files changed, 22 insertions(+), 20 deletions(-) delete mode 100644 bsp_linux_board/RPiSdCardManager.cpp create mode 100644 mission/utility/DummySdCardManager.cpp rename bsp_linux_board/RPiSdCardManager.h => mission/utility/DummySdCardManager.h (74%) diff --git a/bsp_hosted/ObjectFactory.cpp b/bsp_hosted/ObjectFactory.cpp index 779bb006..ae768a7c 100644 --- a/bsp_hosted/ObjectFactory.cpp +++ b/bsp_hosted/ObjectFactory.cpp @@ -8,6 +8,7 @@ #include #include +#include "../mission/utility/DummySdCardManager.h" #include "OBSWConfig.h" #include "devConf.h" #include "eive/definitions.h" @@ -78,7 +79,8 @@ void ObjectFactory::produce(void* args) { Factory::setStaticFrameworkObjectIds(); PusTmFunnel* pusFunnel; CfdpTmFunnel* cfdpFunnel; - ObjectFactory::produceGenericObjects(nullptr, &pusFunnel, &cfdpFunnel); + auto sdcMan = new DummySdCardManager("/tmp"); + ObjectFactory::produceGenericObjects(nullptr, &pusFunnel, &cfdpFunnel, *sdcMan); DummyGpioIF* dummyGpioIF = new DummyGpioIF(); auto* dummySwitcher = new DummyPowerSwitcher(objects::PCDU_HANDLER, 18, 0); diff --git a/bsp_linux_board/CMakeLists.txt b/bsp_linux_board/CMakeLists.txt index 39f06401..9e3ec023 100644 --- a/bsp_linux_board/CMakeLists.txt +++ b/bsp_linux_board/CMakeLists.txt @@ -1,5 +1,5 @@ target_sources(${OBSW_NAME} PUBLIC InitMission.cpp main.cpp gpioInit.cpp - ObjectFactory.cpp RPiSdCardManager.cpp) + ObjectFactory.cpp) add_subdirectory(boardconfig) add_subdirectory(boardtest) diff --git a/bsp_linux_board/ObjectFactory.cpp b/bsp_linux_board/ObjectFactory.cpp index 53db052c..95ea87bb 100644 --- a/bsp_linux_board/ObjectFactory.cpp +++ b/bsp_linux_board/ObjectFactory.cpp @@ -82,7 +82,7 @@ void ObjectFactory::produce(void* args) { #endif #if OBSW_ADD_SCEX_DEVICE == 1 - auto* sdcMan = new RPiSdCardManager("/tmp"); + auto* sdcMan = new DummySdCardManager("/tmp"); createScexComponents(uart::DEV, pwrSwitcher, *sdcMan, true, std::nullopt); #endif diff --git a/bsp_linux_board/RPiSdCardManager.cpp b/bsp_linux_board/RPiSdCardManager.cpp deleted file mode 100644 index dfcae8da..00000000 --- a/bsp_linux_board/RPiSdCardManager.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "RPiSdCardManager.h" - -RPiSdCardManager::RPiSdCardManager(std::string prefix) : prefix(std::move(prefix)) {} - -const std::string& RPiSdCardManager::getCurrentMountPrefix() const { return prefix; } - -bool RPiSdCardManager::isSdCardUsable(sd::SdCard sdCard) { return true; } - -std::optional RPiSdCardManager::getPreferredSdCard() const { return std::nullopt; } - -void RPiSdCardManager::setActiveSdCard(sd::SdCard sdCard) {} - -std::optional RPiSdCardManager::getActiveSdCard() const { return std::nullopt; } diff --git a/mission/utility/CMakeLists.txt b/mission/utility/CMakeLists.txt index e2459ed1..dadce33f 100644 --- a/mission/utility/CMakeLists.txt +++ b/mission/utility/CMakeLists.txt @@ -1,3 +1,3 @@ target_sources( ${LIB_EIVE_MISSION} PRIVATE Timestamp.cpp ProgressPrinter.cpp Filenaming.cpp - GlobalConfigHandler.cpp) + GlobalConfigHandler.cpp DummySdCardManager.cpp) diff --git a/mission/utility/DummySdCardManager.cpp b/mission/utility/DummySdCardManager.cpp new file mode 100644 index 00000000..1b2a45e1 --- /dev/null +++ b/mission/utility/DummySdCardManager.cpp @@ -0,0 +1,13 @@ +#include "DummySdCardManager.h" + +DummySdCardManager::DummySdCardManager(std::string prefix) : prefix(std::move(prefix)) {} + +const std::string& DummySdCardManager::getCurrentMountPrefix() const { return prefix; } + +bool DummySdCardManager::isSdCardUsable(std::optional sdCard) { return true; } + +std::optional DummySdCardManager::getPreferredSdCard() const { return std::nullopt; } + +void DummySdCardManager::setActiveSdCard(sd::SdCard sdCard) {} + +std::optional DummySdCardManager::getActiveSdCard() const { return std::nullopt; } diff --git a/bsp_linux_board/RPiSdCardManager.h b/mission/utility/DummySdCardManager.h similarity index 74% rename from bsp_linux_board/RPiSdCardManager.h rename to mission/utility/DummySdCardManager.h index 068471c1..1a74dc10 100644 --- a/bsp_linux_board/RPiSdCardManager.h +++ b/mission/utility/DummySdCardManager.h @@ -2,11 +2,11 @@ #define BSP_LINUX_BOARD_RPISDCARDMANAGER_H_ #include -class RPiSdCardManager : public SdCardMountedIF { +class DummySdCardManager : public SdCardMountedIF { public: - RPiSdCardManager(std::string prefix); + DummySdCardManager(std::string prefix); const std::string& getCurrentMountPrefix() const override; - bool isSdCardUsable(sd::SdCard sdCard) override; + bool isSdCardUsable(std::optional sdCard) override; std::optional getPreferredSdCard() const override; void setActiveSdCard(sd::SdCard sdCard) override; std::optional getActiveSdCard() const override; From 2d72942d471e3d39829fbabe73c559be303cf0fd Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 14 Dec 2022 10:14:53 +0100 Subject: [PATCH 034/373] important bugfix --- mission/tmtc/TmStore.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mission/tmtc/TmStore.cpp b/mission/tmtc/TmStore.cpp index 82ccafe9..8ba37693 100644 --- a/mission/tmtc/TmStore.cpp +++ b/mission/tmtc/TmStore.cpp @@ -161,6 +161,7 @@ void TmStore::addApid(uint16_t apid) { void TmStore::addService(uint8_t service) { if (not filter.services) { filter.services = std::vector({service}); + return; } filter.services.value().push_back(service); } @@ -169,6 +170,7 @@ void TmStore::addServiceSubservice(uint8_t service, uint8_t subservice) { if (not filter.serviceSubservices) { filter.serviceSubservices = std::vector>({std::pair(service, subservice)}); + return; } filter.serviceSubservices.value().push_back({service, subservice}); } From 8ee6a23229b2097a241ccfcdae656fc6ddd58df3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 14 Dec 2022 10:34:23 +0100 Subject: [PATCH 035/373] more fixes and improvements --- mission/tmtc/PusTmFunnel.cpp | 11 ++++++++--- mission/tmtc/TmStore.cpp | 21 +++++++++++---------- mission/tmtc/TmStore.h | 5 +++-- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/mission/tmtc/PusTmFunnel.cpp b/mission/tmtc/PusTmFunnel.cpp index c5c0b4eb..236e68fa 100644 --- a/mission/tmtc/PusTmFunnel.cpp +++ b/mission/tmtc/PusTmFunnel.cpp @@ -10,9 +10,9 @@ PusTmFunnel::PusTmFunnel(object_id_t objectId, TimeReaderIF &timeReader, Storage SdCardMountedIF &sdcMan, uint32_t messageDepth) : TmFunnelBase(objectId, tmStore, messageDepth), timeReader(timeReader), - miscStore(objects::MISC_STORE, "misc", RolloverInterval::HOURLY, 8, currentTv, sdcMan), - okStore(objects::OK_STORE, "event", RolloverInterval::MINUTELY, 30, currentTv, sdcMan), - notOkStore(objects::NOT_OK_STORE, "event", RolloverInterval::MINUTELY, 30, currentTv, sdcMan), + miscStore(objects::MISC_STORE, "tm", "misc", RolloverInterval::HOURLY, 8, currentTv, sdcMan), + okStore(objects::OK_STORE, "tm", "ok", RolloverInterval::MINUTELY, 30, currentTv, sdcMan), + notOkStore(objects::NOT_OK_STORE,"tm", "nok", RolloverInterval::MINUTELY, 30, currentTv, sdcMan), sdcMan(sdcMan) { Clock::getClock_timeval(¤tTv); Clock::getUptime(&lastTvUpdate); @@ -20,6 +20,11 @@ PusTmFunnel::PusTmFunnel(object_id_t objectId, TimeReaderIF &timeReader, Storage miscStore.addService(17); okStore.addApid(config::EIVE_PUS_APID); okStore.addServiceSubservice(5, 1); + okStore.addApid(config::EIVE_PUS_APID); + okStore.addServiceSubservice(1, 1); + okStore.addServiceSubservice(1, 3); + okStore.addServiceSubservice(1, 5); + okStore.addServiceSubservice(1, 7); } PusTmFunnel::~PusTmFunnel() = default; diff --git a/mission/tmtc/TmStore.cpp b/mission/tmtc/TmStore.cpp index 8ba37693..16ae51a9 100644 --- a/mission/tmtc/TmStore.cpp +++ b/mission/tmtc/TmStore.cpp @@ -10,9 +10,9 @@ using namespace returnvalue; -TmStore::TmStore(object_id_t objectId, std::string baseName, RolloverInterval intervalUnit, - uint32_t intervalCount, timeval& currentTv, SdCardMountedIF& sdcMan) - : SystemObject(objectId), baseName(std::move(baseName)), currentTv(currentTv), sdcMan(sdcMan) { +TmStore::TmStore(object_id_t objectId, std::string baseDir, std::string baseName, + RolloverInterval intervalUnit, uint32_t intervalCount, timeval& currentTv, SdCardMountedIF& sdcMan) + : SystemObject(objectId), baseDir(std::move(baseDir)), baseName(std::move(baseName)), currentTv(currentTv), sdcMan(sdcMan) { calcDiffSeconds(intervalUnit, intervalCount); } @@ -99,16 +99,16 @@ void TmStore::calcDiffSeconds(RolloverInterval intervalUnit, uint32_t intervalCo void TmStore::updateBaseDir() { using namespace std::filesystem; std::string currentPrefix = sdcMan.getCurrentMountPrefix(); - baseDir = path(currentPrefix) / baseName; - if (not exists(baseDir)) { - create_directory(baseDir); + basePath = path(currentPrefix) / baseDir / baseName; + if (not exists(basePath)) { + create_directories(basePath); } baseDirUninitialized = false; } void TmStore::assignAndOrCreateMostRecentFile() { using namespace std::filesystem; - for (auto const& file : directory_iterator(baseDir)) { + for (auto const& file : directory_iterator(basePath)) { if (file.is_directory()) { continue; } @@ -135,13 +135,14 @@ void TmStore::assignAndOrCreateMostRecentFile() { } if (not mostRecentFile) { unsigned currentIdx = 0; - memcpy(fileBuf.data() + currentIdx, baseName.data(), baseName.size()); + path pathStart = basePath / baseName; + memcpy(fileBuf.data() + currentIdx, pathStart.c_str(), pathStart.string().length()); currentIdx += baseName.size(); Clock::TimeOfDay_t tod; Clock::convertTimevalToTimeOfDay(¤tTv, &tod); currentIdx += sprintf(reinterpret_cast(fileBuf.data() + currentIdx), - "%4" SCNu32 "-%2" SCNu32 "-%2" SCNu32 "T%2" SCNu32 ":%2" SCNu32 - ":%2" SCNu32 "Z.bin", + "_%4" PRIu32 "-%2" PRIu32 "-%2" PRIu32 "T%2" PRIu32 ":%2" PRIu32 + ":%2" PRIu32 "Z.bin", tod.year, tod.month, tod.day, tod.hour, tod.minute, tod.second); path newPath(std::string(reinterpret_cast(fileBuf.data()), currentIdx)); std::ofstream of(newPath, std::ios::binary); diff --git a/mission/tmtc/TmStore.h b/mission/tmtc/TmStore.h index ff141dd1..9fdaf462 100644 --- a/mission/tmtc/TmStore.h +++ b/mission/tmtc/TmStore.h @@ -19,7 +19,7 @@ enum class RolloverInterval { MINUTELY, HOURLY, DAILY }; class TmStore : public SystemObject { public: - TmStore(object_id_t objectId, std::string baseName, RolloverInterval intervalUnit, + TmStore(object_id_t objectId, std::string baseDir, std::string baseName, RolloverInterval intervalUnit, uint32_t intervalCount, timeval& currentTv, SdCardMountedIF& sdcMan); void addApid(uint16_t apid); @@ -39,8 +39,9 @@ class TmStore : public SystemObject { MessageQueueId_t getCommandQueue(); PacketFilter filter; bool baseDirUninitialized = true; + std::string baseDir; std::string baseName; - std::filesystem::path baseDir; + std::filesystem::path basePath; uint32_t rolloverDiffSeconds = 0; std::array fileBuf{}; timeval& currentTv; From 9cea0c50c343114a586ea8a80c81a741bfad1d0f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 14 Dec 2022 10:35:30 +0100 Subject: [PATCH 036/373] using const char* instead --- mission/tmtc/TmStore.cpp | 2 +- mission/tmtc/TmStore.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mission/tmtc/TmStore.cpp b/mission/tmtc/TmStore.cpp index 16ae51a9..d7f77a04 100644 --- a/mission/tmtc/TmStore.cpp +++ b/mission/tmtc/TmStore.cpp @@ -10,7 +10,7 @@ using namespace returnvalue; -TmStore::TmStore(object_id_t objectId, std::string baseDir, std::string baseName, +TmStore::TmStore(object_id_t objectId, const char* baseDir, std::string baseName, RolloverInterval intervalUnit, uint32_t intervalCount, timeval& currentTv, SdCardMountedIF& sdcMan) : SystemObject(objectId), baseDir(std::move(baseDir)), baseName(std::move(baseName)), currentTv(currentTv), sdcMan(sdcMan) { calcDiffSeconds(intervalUnit, intervalCount); diff --git a/mission/tmtc/TmStore.h b/mission/tmtc/TmStore.h index 9fdaf462..c048b385 100644 --- a/mission/tmtc/TmStore.h +++ b/mission/tmtc/TmStore.h @@ -19,7 +19,7 @@ enum class RolloverInterval { MINUTELY, HOURLY, DAILY }; class TmStore : public SystemObject { public: - TmStore(object_id_t objectId, std::string baseDir, std::string baseName, RolloverInterval intervalUnit, + TmStore(object_id_t objectId, const char* baseDir, std::string baseName, RolloverInterval intervalUnit, uint32_t intervalCount, timeval& currentTv, SdCardMountedIF& sdcMan); void addApid(uint16_t apid); @@ -39,7 +39,7 @@ class TmStore : public SystemObject { MessageQueueId_t getCommandQueue(); PacketFilter filter; bool baseDirUninitialized = true; - std::string baseDir; + const char* baseDir; std::string baseName; std::filesystem::path basePath; uint32_t rolloverDiffSeconds = 0; From 58d6b59b7cfab99d0cb6a979e08e2c326db16618 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 14 Dec 2022 10:42:16 +0100 Subject: [PATCH 037/373] it seems to work now --- mission/tmtc/PusTmFunnel.cpp | 3 ++- mission/tmtc/TmStore.cpp | 23 ++++++++++++++--------- mission/tmtc/TmStore.h | 5 +++-- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/mission/tmtc/PusTmFunnel.cpp b/mission/tmtc/PusTmFunnel.cpp index 236e68fa..39ef4bc5 100644 --- a/mission/tmtc/PusTmFunnel.cpp +++ b/mission/tmtc/PusTmFunnel.cpp @@ -12,7 +12,8 @@ PusTmFunnel::PusTmFunnel(object_id_t objectId, TimeReaderIF &timeReader, Storage timeReader(timeReader), miscStore(objects::MISC_STORE, "tm", "misc", RolloverInterval::HOURLY, 8, currentTv, sdcMan), okStore(objects::OK_STORE, "tm", "ok", RolloverInterval::MINUTELY, 30, currentTv, sdcMan), - notOkStore(objects::NOT_OK_STORE,"tm", "nok", RolloverInterval::MINUTELY, 30, currentTv, sdcMan), + notOkStore(objects::NOT_OK_STORE, "tm", "nok", RolloverInterval::MINUTELY, 30, currentTv, + sdcMan), sdcMan(sdcMan) { Clock::getClock_timeval(¤tTv); Clock::getUptime(&lastTvUpdate); diff --git a/mission/tmtc/TmStore.cpp b/mission/tmtc/TmStore.cpp index d7f77a04..4a0813b0 100644 --- a/mission/tmtc/TmStore.cpp +++ b/mission/tmtc/TmStore.cpp @@ -11,8 +11,13 @@ using namespace returnvalue; TmStore::TmStore(object_id_t objectId, const char* baseDir, std::string baseName, - RolloverInterval intervalUnit, uint32_t intervalCount, timeval& currentTv, SdCardMountedIF& sdcMan) - : SystemObject(objectId), baseDir(std::move(baseDir)), baseName(std::move(baseName)), currentTv(currentTv), sdcMan(sdcMan) { + RolloverInterval intervalUnit, uint32_t intervalCount, timeval& currentTv, + SdCardMountedIF& sdcMan) + : SystemObject(objectId), + baseDir(std::move(baseDir)), + baseName(std::move(baseName)), + currentTv(currentTv), + sdcMan(sdcMan) { calcDiffSeconds(intervalUnit, intervalCount); } @@ -119,10 +124,10 @@ void TmStore::assignAndOrCreateMostRecentFile() { } unsigned int underscorePos = pathStr.find_last_of('_'); std::string stampStr = pathStr.substr(underscorePos + 1); - int count = - sscanf(stampStr.c_str(), - "%4" SCNu32 "-%2" SCNu32 "-%2" SCNu32 "T%2" SCNu32 ":%2" SCNu32 ":%2" SCNu32 "Z", - &tod.year, &tod.month, &tod.day, &tod.hour, &tod.minute, &tod.second); + int count = sscanf(stampStr.c_str(), + "%04" SCNu32 "-%02" SCNu32 "-%02" SCNu32 "T%02" SCNu32 "-%02" SCNu32 + "-%02" SCNu32 "Z", + &tod.year, &tod.month, &tod.day, &tod.hour, &tod.minute, &tod.second); if (count != 6) { continue; } @@ -137,12 +142,12 @@ void TmStore::assignAndOrCreateMostRecentFile() { unsigned currentIdx = 0; path pathStart = basePath / baseName; memcpy(fileBuf.data() + currentIdx, pathStart.c_str(), pathStart.string().length()); - currentIdx += baseName.size(); + currentIdx += pathStart.string().length(); Clock::TimeOfDay_t tod; Clock::convertTimevalToTimeOfDay(¤tTv, &tod); currentIdx += sprintf(reinterpret_cast(fileBuf.data() + currentIdx), - "_%4" PRIu32 "-%2" PRIu32 "-%2" PRIu32 "T%2" PRIu32 ":%2" PRIu32 - ":%2" PRIu32 "Z.bin", + "_%04" PRIu32 "-%02" PRIu32 "-%02" PRIu32 "T%02" PRIu32 "-%02" PRIu32 + "-%02" PRIu32 "Z.bin", tod.year, tod.month, tod.day, tod.hour, tod.minute, tod.second); path newPath(std::string(reinterpret_cast(fileBuf.data()), currentIdx)); std::ofstream of(newPath, std::ios::binary); diff --git a/mission/tmtc/TmStore.h b/mission/tmtc/TmStore.h index c048b385..5c2f10b6 100644 --- a/mission/tmtc/TmStore.h +++ b/mission/tmtc/TmStore.h @@ -19,8 +19,9 @@ enum class RolloverInterval { MINUTELY, HOURLY, DAILY }; class TmStore : public SystemObject { public: - TmStore(object_id_t objectId, const char* baseDir, std::string baseName, RolloverInterval intervalUnit, - uint32_t intervalCount, timeval& currentTv, SdCardMountedIF& sdcMan); + TmStore(object_id_t objectId, const char* baseDir, std::string baseName, + RolloverInterval intervalUnit, uint32_t intervalCount, timeval& currentTv, + SdCardMountedIF& sdcMan); void addApid(uint16_t apid); void addService(uint8_t service); From ff9bcd6b1447a57a30b72437e53db50275b4423a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 14 Dec 2022 10:54:18 +0100 Subject: [PATCH 038/373] added remaining missing stores --- common/config/eive/objects.h | 7 ++++--- mission/tmtc/PusTmFunnel.cpp | 18 +++++++++++++++--- mission/tmtc/PusTmFunnel.h | 7 ++----- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/common/config/eive/objects.h b/common/config/eive/objects.h index ede974fb..fa5ebecc 100644 --- a/common/config/eive/objects.h +++ b/common/config/eive/objects.h @@ -146,9 +146,10 @@ enum commonObjects : uint32_t { CFDP_TM_FUNNEL = 0x73000102, CFDP_HANDLER = 0x73000205, CFDP_DISTRIBUTOR = 0x73000206, - MISC_STORE = 0x73020001, - OK_STORE = 0x73020002, - NOT_OK_STORE = 0x73020003, + MISC_TM_STORE = 0x73020001, + OK_TM_STORE = 0x73020002, + NOT_OK_TM_STORE = 0x73020003, + HK_TM_STORE = 0x73020004 }; } diff --git a/mission/tmtc/PusTmFunnel.cpp b/mission/tmtc/PusTmFunnel.cpp index 39ef4bc5..c0aabf89 100644 --- a/mission/tmtc/PusTmFunnel.cpp +++ b/mission/tmtc/PusTmFunnel.cpp @@ -10,22 +10,34 @@ PusTmFunnel::PusTmFunnel(object_id_t objectId, TimeReaderIF &timeReader, Storage SdCardMountedIF &sdcMan, uint32_t messageDepth) : TmFunnelBase(objectId, tmStore, messageDepth), timeReader(timeReader), - miscStore(objects::MISC_STORE, "tm", "misc", RolloverInterval::HOURLY, 8, currentTv, sdcMan), - okStore(objects::OK_STORE, "tm", "ok", RolloverInterval::MINUTELY, 30, currentTv, sdcMan), - notOkStore(objects::NOT_OK_STORE, "tm", "nok", RolloverInterval::MINUTELY, 30, currentTv, + miscStore(objects::MISC_TM_STORE, "tm", "misc", RolloverInterval::HOURLY, 2, currentTv, + sdcMan), + okStore(objects::OK_TM_STORE, "tm", "ok", RolloverInterval::MINUTELY, 30, currentTv, sdcMan), + notOkStore(objects::NOT_OK_TM_STORE, "tm", "nok", RolloverInterval::MINUTELY, 30, currentTv, sdcMan), + hkStore(objects::HK_TM_STORE, "tm", "hk", RolloverInterval::MINUTELY, 15, currentTv, sdcMan), sdcMan(sdcMan) { Clock::getClock_timeval(¤tTv); Clock::getUptime(&lastTvUpdate); miscStore.addApid(config::EIVE_PUS_APID); miscStore.addService(17); + miscStore.addService(200); okStore.addApid(config::EIVE_PUS_APID); okStore.addServiceSubservice(5, 1); okStore.addApid(config::EIVE_PUS_APID); + okStore.addService(8); okStore.addServiceSubservice(1, 1); okStore.addServiceSubservice(1, 3); okStore.addServiceSubservice(1, 5); okStore.addServiceSubservice(1, 7); + notOkStore.addApid(config::EIVE_PUS_APID); + notOkStore.addServiceSubservice(5, 2); + notOkStore.addServiceSubservice(5, 3); + notOkStore.addServiceSubservice(5, 4); + notOkStore.addServiceSubservice(1, 2); + notOkStore.addServiceSubservice(1, 4); + notOkStore.addServiceSubservice(1, 6); + notOkStore.addServiceSubservice(1, 8); } PusTmFunnel::~PusTmFunnel() = default; diff --git a/mission/tmtc/PusTmFunnel.h b/mission/tmtc/PusTmFunnel.h index 26bbfec2..d447e88b 100644 --- a/mission/tmtc/PusTmFunnel.h +++ b/mission/tmtc/PusTmFunnel.h @@ -16,11 +16,7 @@ /** * @brief TM Recipient. * @details - * TODO: Add support for TM storage by using the (or a) LIVE flag provided by the CCSDS or Syrlinks - * handler. If we are in LIVE TM mode, forward TM to downlink destination directly. Otherwise, - * forward to TM storage backend which stores TMs into files. - * Main telemetry receiver. All generated telemetry is funneled into - * this object. + * Main telemetry receiver. All generated telemetry is funneled into this object. * @ingroup utility * @author J. Meier, R. Mueller */ @@ -45,6 +41,7 @@ class PusTmFunnel : public TmFunnelBase { TmStore miscStore; TmStore okStore; TmStore notOkStore; + TmStore hkStore; SdCardMountedIF &sdcMan; ReturnValue_t handlePacket(TmTcMessage &message); From 5d67b896aaf232535096b5640e4e2948ab1cf285 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 14 Dec 2022 11:00:07 +0100 Subject: [PATCH 039/373] improve store init handling, add remaining stores --- mission/tmtc/PusTmFunnel.cpp | 21 +++++++++++++-------- mission/tmtc/PusTmFunnel.h | 1 + 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/mission/tmtc/PusTmFunnel.cpp b/mission/tmtc/PusTmFunnel.cpp index c0aabf89..5c4c8ead 100644 --- a/mission/tmtc/PusTmFunnel.cpp +++ b/mission/tmtc/PusTmFunnel.cpp @@ -19,6 +19,8 @@ PusTmFunnel::PusTmFunnel(object_id_t objectId, TimeReaderIF &timeReader, Storage sdcMan(sdcMan) { Clock::getClock_timeval(¤tTv); Clock::getUptime(&lastTvUpdate); + hkStore.addApid(config::EIVE_PUS_APID); + hkStore.addService(3); miscStore.addApid(config::EIVE_PUS_APID); miscStore.addService(17); miscStore.addService(200); @@ -88,12 +90,9 @@ ReturnValue_t PusTmFunnel::handlePacket(TmTcMessage &message) { lastTvUpdate = currentUptime; } - if (sdcMan.isSdCardUsable(std::nullopt)) { - if (not storesInitialized) { - miscStore.updateBaseDir(); - okStore.updateBaseDir(); - storesInitialized = true; - } + bool sdcUsable = sdcMan.isSdCardUsable(std::nullopt); + initStoresIfPossible(sdcUsable); + if (sdcUsable) { miscStore.passPacket(packet); okStore.passPacket(packet); } @@ -131,11 +130,17 @@ ReturnValue_t PusTmFunnel::handlePacket(TmTcMessage &message) { const char *PusTmFunnel::getName() const { return "PUS TM Funnel"; } -ReturnValue_t PusTmFunnel::initialize() { - if (not storesInitialized and sdcMan.isSdCardUsable(std::nullopt)) { +void PusTmFunnel::initStoresIfPossible(bool sdCardUsable) { + if (not storesInitialized and sdCardUsable) { miscStore.updateBaseDir(); okStore.updateBaseDir(); + hkStore.updateBaseDir(); + notOkStore.updateBaseDir(); storesInitialized = true; } +} + +ReturnValue_t PusTmFunnel::initialize() { + initStoresIfPossible(sdcMan.isSdCardUsable(std::nullopt)); return returnvalue::OK; } diff --git a/mission/tmtc/PusTmFunnel.h b/mission/tmtc/PusTmFunnel.h index d447e88b..b380ec79 100644 --- a/mission/tmtc/PusTmFunnel.h +++ b/mission/tmtc/PusTmFunnel.h @@ -45,6 +45,7 @@ class PusTmFunnel : public TmFunnelBase { SdCardMountedIF &sdcMan; ReturnValue_t handlePacket(TmTcMessage &message); + void initStoresIfPossible(bool sdCardUsable); ReturnValue_t initialize() override; }; From ec02332615bf0f823203996420410d997a781727 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 14 Dec 2022 11:29:32 +0100 Subject: [PATCH 040/373] start implementing the PUS Service --- mission/tmtc/Service15TmStorage.cpp | 12 +++++++++++- mission/tmtc/Service15TmStorage.h | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/mission/tmtc/Service15TmStorage.cpp b/mission/tmtc/Service15TmStorage.cpp index 590b6c8e..ae2400b5 100644 --- a/mission/tmtc/Service15TmStorage.cpp +++ b/mission/tmtc/Service15TmStorage.cpp @@ -8,7 +8,17 @@ Service15TmStorage::Service15TmStorage(object_id_t objectId, uint16_t apid, : CommandingServiceBase(objectId, apid, "PUS Service 15", 15, numParallelCommands, commandTimeoutSecs, queueDepth) {} -ReturnValue_t Service15TmStorage::isValidSubservice(uint8_t subservice) { return OK; } +ReturnValue_t Service15TmStorage::isValidSubservice(uint8_t subservice) { + switch (subservice) { + case(Subservices::START_BY_TIME_RANGE_RETRIEVAL): { + return OK; + } + case(Subservices::DELETE_UP_TO): { + return OK; + } + } + return FAILED; +} ReturnValue_t Service15TmStorage::getMessageQueueAndObject(uint8_t subservice, const uint8_t *tcData, size_t tcDataLen, diff --git a/mission/tmtc/Service15TmStorage.h b/mission/tmtc/Service15TmStorage.h index 0243fdb3..92cab52a 100644 --- a/mission/tmtc/Service15TmStorage.h +++ b/mission/tmtc/Service15TmStorage.h @@ -5,6 +5,10 @@ class Service15TmStorage : public CommandingServiceBase { public: + enum Subservices: uint8_t { + START_BY_TIME_RANGE_RETRIEVAL = 9, + DELETE_UP_TO = 11 + }; explicit Service15TmStorage(object_id_t objectId, uint16_t apid, uint8_t numParallelCommands, uint16_t commandTimeoutSecs, size_t queueDepth); From 4d473315feecfb45c0dc9af18990e4962518d99d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 14 Dec 2022 13:19:14 +0100 Subject: [PATCH 041/373] allow sending TC requests to funnels --- mission/core/GenericFactory.cpp | 4 ++-- mission/tmtc/CfdpTmFunnel.cpp | 4 ++-- mission/tmtc/CfdpTmFunnel.h | 2 +- mission/tmtc/PusTmFunnel.cpp | 4 ++-- mission/tmtc/PusTmFunnel.h | 2 +- mission/tmtc/Service15TmStorage.cpp | 12 ++++++------ mission/tmtc/Service15TmStorage.h | 5 +---- mission/tmtc/TmFunnelBase.cpp | 6 +++++- mission/tmtc/TmFunnelBase.h | 11 +++++++++-- 9 files changed, 29 insertions(+), 21 deletions(-) diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index c0e1eb43..0e58e1ec 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -121,8 +121,8 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFun new CcsdsDistributor(config::EIVE_PUS_APID, objects::CCSDS_PACKET_DISTRIBUTOR); new PusDistributor(config::EIVE_PUS_APID, objects::PUS_PACKET_DISTRIBUTOR, ccsdsDistrib); - *cfdpFunnel = new CfdpTmFunnel(objects::CFDP_TM_FUNNEL, config::EIVE_CFDP_APID, *tmStore, 50); - *pusFunnel = new PusTmFunnel(objects::PUS_TM_FUNNEL, *timeStamper, *tmStore, sdcMan, 80); + *cfdpFunnel = new CfdpTmFunnel(objects::CFDP_TM_FUNNEL, config::EIVE_CFDP_APID, *tmStore, 50, 15); + *pusFunnel = new PusTmFunnel(objects::PUS_TM_FUNNEL, *timeStamper, *tmStore, sdcMan, 80, 15); #if OBSW_ADD_TCPIP_SERVERS == 1 #if OBSW_ADD_TMTC_UDP_SERVER == 1 (*cfdpFunnel)->addDestination(*udpBridge, 0); diff --git a/mission/tmtc/CfdpTmFunnel.cpp b/mission/tmtc/CfdpTmFunnel.cpp index aff7c95d..e5080b71 100644 --- a/mission/tmtc/CfdpTmFunnel.cpp +++ b/mission/tmtc/CfdpTmFunnel.cpp @@ -5,8 +5,8 @@ #include "fsfw/tmtcservices/TmTcMessage.h" CfdpTmFunnel::CfdpTmFunnel(object_id_t objectId, uint16_t cfdpInCcsdsApid, - StorageManagerIF& tmStore, uint32_t messageDepth) - : TmFunnelBase(objectId, tmStore, messageDepth), cfdpInCcsdsApid(cfdpInCcsdsApid) {} + StorageManagerIF& tmStore, uint32_t tmMsgDepth, uint32_t tcMsgDepth) + : TmFunnelBase(objectId, tmStore, tmMsgDepth, tcMsgDepth), cfdpInCcsdsApid(cfdpInCcsdsApid) {} const char* CfdpTmFunnel::getName() const { return "CFDP TM Funnel"; } diff --git a/mission/tmtc/CfdpTmFunnel.h b/mission/tmtc/CfdpTmFunnel.h index e294956a..32d16975 100644 --- a/mission/tmtc/CfdpTmFunnel.h +++ b/mission/tmtc/CfdpTmFunnel.h @@ -13,7 +13,7 @@ class CfdpTmFunnel : public TmFunnelBase { public: CfdpTmFunnel(object_id_t objectId, uint16_t cfdpInCcsdsApid, StorageManagerIF& tmStore, - uint32_t messageDepth); + uint32_t tmMsgDepth, uint32_t tcMsgDepth); [[nodiscard]] const char* getName() const override; ReturnValue_t performOperation(uint8_t opCode); ReturnValue_t initialize() override; diff --git a/mission/tmtc/PusTmFunnel.cpp b/mission/tmtc/PusTmFunnel.cpp index 5c4c8ead..ff66f3c9 100644 --- a/mission/tmtc/PusTmFunnel.cpp +++ b/mission/tmtc/PusTmFunnel.cpp @@ -7,8 +7,8 @@ #include "fsfw/tmtcpacket/pus/tm/PusTmZcWriter.h" PusTmFunnel::PusTmFunnel(object_id_t objectId, TimeReaderIF &timeReader, StorageManagerIF &tmStore, - SdCardMountedIF &sdcMan, uint32_t messageDepth) - : TmFunnelBase(objectId, tmStore, messageDepth), + SdCardMountedIF &sdcMan, uint32_t tmMsgDepth, uint32_t tcMsgDepth) + : TmFunnelBase(objectId, tmStore, tmMsgDepth, tcMsgDepth), timeReader(timeReader), miscStore(objects::MISC_TM_STORE, "tm", "misc", RolloverInterval::HOURLY, 2, currentTv, sdcMan), diff --git a/mission/tmtc/PusTmFunnel.h b/mission/tmtc/PusTmFunnel.h index b380ec79..a54093c2 100644 --- a/mission/tmtc/PusTmFunnel.h +++ b/mission/tmtc/PusTmFunnel.h @@ -23,7 +23,7 @@ class PusTmFunnel : public TmFunnelBase { public: explicit PusTmFunnel(object_id_t objectId, TimeReaderIF &timeReader, StorageManagerIF &tmStore, - SdCardMountedIF &sdcMan, uint32_t messageDepth = 10); + SdCardMountedIF &sdcMan, uint32_t tmMsgDepth, uint32_t tcMsgDepth); [[nodiscard]] const char *getName() const override; ~PusTmFunnel() override; diff --git a/mission/tmtc/Service15TmStorage.cpp b/mission/tmtc/Service15TmStorage.cpp index ae2400b5..5bdec8e1 100644 --- a/mission/tmtc/Service15TmStorage.cpp +++ b/mission/tmtc/Service15TmStorage.cpp @@ -10,12 +10,12 @@ Service15TmStorage::Service15TmStorage(object_id_t objectId, uint16_t apid, ReturnValue_t Service15TmStorage::isValidSubservice(uint8_t subservice) { switch (subservice) { - case(Subservices::START_BY_TIME_RANGE_RETRIEVAL): { - return OK; - } - case(Subservices::DELETE_UP_TO): { - return OK; - } + case (Subservices::START_BY_TIME_RANGE_RETRIEVAL): { + return OK; + } + case (Subservices::DELETE_UP_TO): { + return OK; + } } return FAILED; } diff --git a/mission/tmtc/Service15TmStorage.h b/mission/tmtc/Service15TmStorage.h index 92cab52a..2074754a 100644 --- a/mission/tmtc/Service15TmStorage.h +++ b/mission/tmtc/Service15TmStorage.h @@ -5,10 +5,7 @@ class Service15TmStorage : public CommandingServiceBase { public: - enum Subservices: uint8_t { - START_BY_TIME_RANGE_RETRIEVAL = 9, - DELETE_UP_TO = 11 - }; + enum Subservices : uint8_t { START_BY_TIME_RANGE_RETRIEVAL = 9, DELETE_UP_TO = 11 }; explicit Service15TmStorage(object_id_t objectId, uint16_t apid, uint8_t numParallelCommands, uint16_t commandTimeoutSecs, size_t queueDepth); diff --git a/mission/tmtc/TmFunnelBase.cpp b/mission/tmtc/TmFunnelBase.cpp index fa0062e6..156e4664 100644 --- a/mission/tmtc/TmFunnelBase.cpp +++ b/mission/tmtc/TmFunnelBase.cpp @@ -2,11 +2,15 @@ #include "fsfw/ipc/QueueFactory.h" -TmFunnelBase::TmFunnelBase(object_id_t objectId, StorageManagerIF &tmStore, uint32_t tmMsgDepth) +TmFunnelBase::TmFunnelBase(object_id_t objectId, StorageManagerIF &tmStore, uint32_t tmMsgDepth, + uint32_t tcMsgDepth) : SystemObject(objectId), tmStore(tmStore) { tmQueue = QueueFactory::instance()->createMessageQueue(tmMsgDepth); + tcQueue = QueueFactory::instance()->createMessageQueue(tcMsgDepth); } +MessageQueueId_t TmFunnelBase::getCommandQueue() const { return tcQueue->getId(); } + TmFunnelBase::~TmFunnelBase() { QueueFactory::instance()->deleteMessageQueue(tmQueue); } MessageQueueId_t TmFunnelBase::getReportReceptionQueue(uint8_t virtualChannel) const { diff --git a/mission/tmtc/TmFunnelBase.h b/mission/tmtc/TmFunnelBase.h index c630fefd..271c17c0 100644 --- a/mission/tmtc/TmFunnelBase.h +++ b/mission/tmtc/TmFunnelBase.h @@ -3,14 +3,20 @@ #include #include +#include #include #include -class TmFunnelBase : public AcceptsTelemetryIF, public SystemObject { +class TmFunnelBase : public TmStoreFrontendSimpleIF, + public AcceptsTelemetryIF, + public SystemObject { public: - TmFunnelBase(object_id_t objectId, StorageManagerIF& tmStore, uint32_t tmMsgDepth); + TmFunnelBase(object_id_t objectId, StorageManagerIF& tmStore, uint32_t tmMsgDepth, + uint32_t tcMsgDepth); void addDestination(const AcceptsTelemetryIF& downlinkDestination, uint8_t vcid = 0); + + [[nodiscard]] MessageQueueId_t getCommandQueue() const override; [[nodiscard]] MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) const override; virtual ~TmFunnelBase(); @@ -18,6 +24,7 @@ class TmFunnelBase : public AcceptsTelemetryIF, public SystemObject { protected: StorageManagerIF& tmStore; std::vector> destinations; + MessageQueueIF* tcQueue = nullptr; MessageQueueIF* tmQueue = nullptr; }; From 5431dfc9bdea0ecc342edc5123bab7062f7f4626 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 14 Dec 2022 13:51:24 +0100 Subject: [PATCH 042/373] basic packet routing --- common/config/eive/objects.h | 3 ++- fsfw | 2 +- mission/tmtc/Service15TmStorage.cpp | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/common/config/eive/objects.h b/common/config/eive/objects.h index fa5ebecc..6c2d87a1 100644 --- a/common/config/eive/objects.h +++ b/common/config/eive/objects.h @@ -149,7 +149,8 @@ enum commonObjects : uint32_t { MISC_TM_STORE = 0x73020001, OK_TM_STORE = 0x73020002, NOT_OK_TM_STORE = 0x73020003, - HK_TM_STORE = 0x73020004 + HK_TM_STORE = 0x73020004, + CFDP_TM_STORE = 0x73030000 }; } diff --git a/fsfw b/fsfw index 75fc7a05..2aa4af69 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 75fc7a056db2a4aee8c20c225fd3c2b79fce8ce3 +Subproject commit 2aa4af69742d932f09ec2a1d3d29b648295035d1 diff --git a/mission/tmtc/Service15TmStorage.cpp b/mission/tmtc/Service15TmStorage.cpp index 5bdec8e1..c4c9bc43 100644 --- a/mission/tmtc/Service15TmStorage.cpp +++ b/mission/tmtc/Service15TmStorage.cpp @@ -1,5 +1,10 @@ #include "Service15TmStorage.h" +#include +#include + +#include "eive/objects.h" + using namespace returnvalue; Service15TmStorage::Service15TmStorage(object_id_t objectId, uint16_t apid, @@ -24,6 +29,19 @@ ReturnValue_t Service15TmStorage::getMessageQueueAndObject(uint8_t subservice, const uint8_t *tcData, size_t tcDataLen, MessageQueueId_t *id, object_id_t *objectId) { + object_id_t targetObjectId; + SerializeAdapter::deSerialize(&targetObjectId, &tcData, &tcDataLen, + SerializeIF::Endianness::NETWORK); + if (targetObjectId == objects::CFDP_TM_STORE) { + *objectId = objects::CFDP_TM_FUNNEL; + } else { + *objectId = objects::PUS_TM_FUNNEL; + } + auto *frontendIF = ObjectManager::instance()->get(*objectId); + if (frontendIF == nullptr) { + return FAILED; + } + *id = frontendIF->getCommandQueue(); return OK; } From 62b3e16ac4ec45081ed1e2c92bd6d3ade829b3eb Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 14 Dec 2022 15:09:57 +0100 Subject: [PATCH 043/373] add service 2 --- mission/tmtc/PusTmFunnel.cpp | 1 + mission/tmtc/Service15TmStorage.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/mission/tmtc/PusTmFunnel.cpp b/mission/tmtc/PusTmFunnel.cpp index ff66f3c9..923150b3 100644 --- a/mission/tmtc/PusTmFunnel.cpp +++ b/mission/tmtc/PusTmFunnel.cpp @@ -23,6 +23,7 @@ PusTmFunnel::PusTmFunnel(object_id_t objectId, TimeReaderIF &timeReader, Storage hkStore.addService(3); miscStore.addApid(config::EIVE_PUS_APID); miscStore.addService(17); + miscStore.addService(2); miscStore.addService(200); okStore.addApid(config::EIVE_PUS_APID); okStore.addServiceSubservice(5, 1); diff --git a/mission/tmtc/Service15TmStorage.cpp b/mission/tmtc/Service15TmStorage.cpp index c4c9bc43..c44f226c 100644 --- a/mission/tmtc/Service15TmStorage.cpp +++ b/mission/tmtc/Service15TmStorage.cpp @@ -48,6 +48,7 @@ ReturnValue_t Service15TmStorage::getMessageQueueAndObject(uint8_t subservice, ReturnValue_t Service15TmStorage::prepareCommand(CommandMessage *message, uint8_t subservice, const uint8_t *tcData, size_t tcDataLen, uint32_t *state, object_id_t objectId) { + return OK; } From b6522c9fb352f4c90abedbc49b2f9e234387a5d8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 14 Dec 2022 15:41:20 +0100 Subject: [PATCH 044/373] that should do the job --- mission/tmtc/Service15TmStorage.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/mission/tmtc/Service15TmStorage.cpp b/mission/tmtc/Service15TmStorage.cpp index c44f226c..d752bf00 100644 --- a/mission/tmtc/Service15TmStorage.cpp +++ b/mission/tmtc/Service15TmStorage.cpp @@ -4,6 +4,7 @@ #include #include "eive/objects.h" +#include "fsfw/tmstorage/TmStoreMessage.h" using namespace returnvalue; @@ -48,7 +49,29 @@ ReturnValue_t Service15TmStorage::getMessageQueueAndObject(uint8_t subservice, ReturnValue_t Service15TmStorage::prepareCommand(CommandMessage *message, uint8_t subservice, const uint8_t *tcData, size_t tcDataLen, uint32_t *state, object_id_t objectId) { - + if (subservice == Subservices::START_BY_TIME_RANGE_RETRIEVAL) { + if (tcDataLen != 12) { + return INVALID_TC; + } + store_address_t storeId; + ReturnValue_t result = ipcStore->addData(&storeId, tcData, tcDataLen); + if (result != OK) { + return result; + } + // Store timestamps + TmStoreMessage::setDownlinkContentTimeMessage(message, storeId); + } else if (subservice == Subservices::DELETE_UP_TO) { + if (tcDataLen != 8) { + return INVALID_TC; + } + store_address_t storeId; + ReturnValue_t result = ipcStore->addData(&storeId, tcData, tcDataLen); + if (result != OK) { + return result; + } + // Store timestamps + TmStoreMessage::setDeleteContentTimeMessage(message, storeId); + } return OK; } From bbf0def3ff9c7b07d6030a6db5cbeb937a075ce2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 16 Dec 2022 13:26:20 +0100 Subject: [PATCH 045/373] add missing dot --- mission/tmtc/TmStore.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mission/tmtc/TmStore.cpp b/mission/tmtc/TmStore.cpp index 4a0813b0..07fddcf0 100644 --- a/mission/tmtc/TmStore.cpp +++ b/mission/tmtc/TmStore.cpp @@ -72,7 +72,8 @@ ReturnValue_t TmStore::storePacket(PusTmReader& reader) { uint8_t appendedCounter = 1; path rolloverName; while (true) { - rolloverName = path(mostRecentFile.value().string() + std::to_string(appendedCounter)); + rolloverName = + path(mostRecentFile.value().string() + "." + std::to_string(appendedCounter)); if (not exists(rolloverName)) { break; } From 74f116f2fa15a84e7fc12e66adb487349aa3c571 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 19 Dec 2022 13:25:45 +0100 Subject: [PATCH 046/373] that should be the basic interface --- mission/tmtc/PusTmFunnel.cpp | 31 ++++++++++++++++++++++++++----- mission/tmtc/TmStore.cpp | 6 ++++++ mission/tmtc/TmStore.h | 5 +++++ tmtc | 2 +- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/mission/tmtc/PusTmFunnel.cpp b/mission/tmtc/PusTmFunnel.cpp index 923150b3..a3e6f144 100644 --- a/mission/tmtc/PusTmFunnel.cpp +++ b/mission/tmtc/PusTmFunnel.cpp @@ -2,8 +2,10 @@ #include "eive/definitions.h" #include "eive/objects.h" +#include "fsfw/ipc/CommandMessage.h" #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager.h" +#include "fsfw/tmstorage/TmStoreMessage.h" #include "fsfw/tmtcpacket/pus/tm/PusTmZcWriter.h" PusTmFunnel::PusTmFunnel(object_id_t objectId, TimeReaderIF &timeReader, StorageManagerIF &tmStore, @@ -46,8 +48,31 @@ PusTmFunnel::PusTmFunnel(object_id_t objectId, TimeReaderIF &timeReader, Storage PusTmFunnel::~PusTmFunnel() = default; ReturnValue_t PusTmFunnel::performOperation(uint8_t) { + CommandMessage cmdMessage; + ReturnValue_t status = tcQueue->receiveMessage(&cmdMessage); + while (status == returnvalue::OK) { + if (cmdMessage.getCommand() == messagetypes::TM_STORE) { + object_id_t objectId = TmStoreMessage::getObjectId(&cmdMessage); + switch (objectId) { + case (objects::HK_TM_STORE): { + break; + } + case (objects::OK_TM_STORE): { + break; + } + case (objects::NOT_OK_TM_STORE): { + break; + } + case (objects::MISC_TM_STORE): { + break; + } + default: { + } + } + } + } TmTcMessage currentMessage; - ReturnValue_t status = tmQueue->receiveMessage(¤tMessage); + status = tmQueue->receiveMessage(¤tMessage); while (status == returnvalue::OK) { status = handlePacket(currentMessage); if (status != returnvalue::OK) { @@ -56,10 +81,6 @@ ReturnValue_t PusTmFunnel::performOperation(uint8_t) { } status = tmQueue->receiveMessage(¤tMessage); } - - if (status == MessageQueueIF::EMPTY) { - return returnvalue::OK; - } return status; } diff --git a/mission/tmtc/TmStore.cpp b/mission/tmtc/TmStore.cpp index 07fddcf0..2de1e818 100644 --- a/mission/tmtc/TmStore.cpp +++ b/mission/tmtc/TmStore.cpp @@ -181,3 +181,9 @@ void TmStore::addServiceSubservice(uint8_t service, uint8_t subservice) { } filter.serviceSubservices.value().push_back({service, subservice}); } + +void TmStore::deleteUpTo(uint32_t unixSeconds) {} + +void TmStore::dumpFromUpTo(uint32_t fromUnixSeconds, uint32_t upToUnixSeconds, + std::vector>& destinations, + MessageQueueIF* tmQueue) {} diff --git a/mission/tmtc/TmStore.h b/mission/tmtc/TmStore.h index 5c2f10b6..72071e02 100644 --- a/mission/tmtc/TmStore.h +++ b/mission/tmtc/TmStore.h @@ -27,6 +27,11 @@ class TmStore : public SystemObject { void addService(uint8_t service); void addServiceSubservice(uint8_t service, uint8_t subservice); + void deleteUpTo(uint32_t unixSeconds); + void dumpFromUpTo(uint32_t fromUnixSeconds, uint32_t upToUnixSeconds, + std::vector>& destinations, + MessageQueueIF* tmQueue); + void updateBaseDir(); ReturnValue_t passPacket(PusTmReader& reader); diff --git a/tmtc b/tmtc index 30cf4736..383b3214 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 30cf47365fec68a4b78395de03ecb2ae95af4e7e +Subproject commit 383b32141c8c382b84c587d6814fe9252dde0b4a From c4c1f09f2e751ea3c93478536984509b23e700e7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 19 Dec 2022 13:57:05 +0100 Subject: [PATCH 047/373] continue request handling --- mission/core/GenericFactory.cpp | 9 ++++++--- mission/tmtc/CfdpTmFunnel.cpp | 6 ++++-- mission/tmtc/CfdpTmFunnel.h | 2 +- mission/tmtc/PusTmFunnel.cpp | 26 +++++++++++++++++++++++--- mission/tmtc/PusTmFunnel.h | 3 ++- mission/tmtc/TmFunnelBase.cpp | 4 ++-- mission/tmtc/TmFunnelBase.h | 3 ++- 7 files changed, 40 insertions(+), 13 deletions(-) diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index 0e58e1ec..ddd29bb9 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -80,6 +80,7 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFun auto* timeStamper = new CdsShortTimeStamper(objects::TIME_STAMPER); StorageManagerIF* tcStore; StorageManagerIF* tmStore; + StorageManagerIF* ipcStore; { PoolManager::LocalPoolConfig poolCfg = {{250, 16}, {250, 32}, {250, 64}, {150, 128}, {120, 1024}, {120, 2048}}; @@ -95,7 +96,7 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFun { PoolManager::LocalPoolConfig poolCfg = {{300, 16}, {200, 32}, {150, 64}, {150, 128}, {100, 256}, {50, 512}, {50, 1024}, {10, 2048}}; - new PoolManager(objects::IPC_STORE, poolCfg); + ipcStore = new PoolManager(objects::IPC_STORE, poolCfg); } #if OBSW_ADD_TCPIP_SERVERS == 1 @@ -121,8 +122,10 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFun new CcsdsDistributor(config::EIVE_PUS_APID, objects::CCSDS_PACKET_DISTRIBUTOR); new PusDistributor(config::EIVE_PUS_APID, objects::PUS_PACKET_DISTRIBUTOR, ccsdsDistrib); - *cfdpFunnel = new CfdpTmFunnel(objects::CFDP_TM_FUNNEL, config::EIVE_CFDP_APID, *tmStore, 50, 15); - *pusFunnel = new PusTmFunnel(objects::PUS_TM_FUNNEL, *timeStamper, *tmStore, sdcMan, 80, 15); + *cfdpFunnel = new CfdpTmFunnel(objects::CFDP_TM_FUNNEL, config::EIVE_CFDP_APID, *tmStore, 50, 15, + *ipcStore); + *pusFunnel = + new PusTmFunnel(objects::PUS_TM_FUNNEL, *timeStamper, *tmStore, sdcMan, 80, 15, *ipcStore); #if OBSW_ADD_TCPIP_SERVERS == 1 #if OBSW_ADD_TMTC_UDP_SERVER == 1 (*cfdpFunnel)->addDestination(*udpBridge, 0); diff --git a/mission/tmtc/CfdpTmFunnel.cpp b/mission/tmtc/CfdpTmFunnel.cpp index e5080b71..f2d31a92 100644 --- a/mission/tmtc/CfdpTmFunnel.cpp +++ b/mission/tmtc/CfdpTmFunnel.cpp @@ -5,8 +5,10 @@ #include "fsfw/tmtcservices/TmTcMessage.h" CfdpTmFunnel::CfdpTmFunnel(object_id_t objectId, uint16_t cfdpInCcsdsApid, - StorageManagerIF& tmStore, uint32_t tmMsgDepth, uint32_t tcMsgDepth) - : TmFunnelBase(objectId, tmStore, tmMsgDepth, tcMsgDepth), cfdpInCcsdsApid(cfdpInCcsdsApid) {} + StorageManagerIF& tmStore, uint32_t tmMsgDepth, uint32_t tcMsgDepth, + StorageManagerIF& ipcStore) + : TmFunnelBase(objectId, tmStore, tmMsgDepth, tcMsgDepth, ipcStore), + cfdpInCcsdsApid(cfdpInCcsdsApid) {} const char* CfdpTmFunnel::getName() const { return "CFDP TM Funnel"; } diff --git a/mission/tmtc/CfdpTmFunnel.h b/mission/tmtc/CfdpTmFunnel.h index 32d16975..55917727 100644 --- a/mission/tmtc/CfdpTmFunnel.h +++ b/mission/tmtc/CfdpTmFunnel.h @@ -13,7 +13,7 @@ class CfdpTmFunnel : public TmFunnelBase { public: CfdpTmFunnel(object_id_t objectId, uint16_t cfdpInCcsdsApid, StorageManagerIF& tmStore, - uint32_t tmMsgDepth, uint32_t tcMsgDepth); + uint32_t tmMsgDepth, uint32_t tcMsgDepth, StorageManagerIF& ipcStore); [[nodiscard]] const char* getName() const override; ReturnValue_t performOperation(uint8_t opCode); ReturnValue_t initialize() override; diff --git a/mission/tmtc/PusTmFunnel.cpp b/mission/tmtc/PusTmFunnel.cpp index a3e6f144..ff662afd 100644 --- a/mission/tmtc/PusTmFunnel.cpp +++ b/mission/tmtc/PusTmFunnel.cpp @@ -9,8 +9,9 @@ #include "fsfw/tmtcpacket/pus/tm/PusTmZcWriter.h" PusTmFunnel::PusTmFunnel(object_id_t objectId, TimeReaderIF &timeReader, StorageManagerIF &tmStore, - SdCardMountedIF &sdcMan, uint32_t tmMsgDepth, uint32_t tcMsgDepth) - : TmFunnelBase(objectId, tmStore, tmMsgDepth, tcMsgDepth), + SdCardMountedIF &sdcMan, uint32_t tmMsgDepth, uint32_t tcMsgDepth, + StorageManagerIF &ipcStore) + : TmFunnelBase(objectId, tmStore, tmMsgDepth, tcMsgDepth, ipcStore), timeReader(timeReader), miscStore(objects::MISC_TM_STORE, "tm", "misc", RolloverInterval::HOURLY, 2, currentTv, sdcMan), @@ -51,24 +52,43 @@ ReturnValue_t PusTmFunnel::performOperation(uint8_t) { CommandMessage cmdMessage; ReturnValue_t status = tcQueue->receiveMessage(&cmdMessage); while (status == returnvalue::OK) { - if (cmdMessage.getCommand() == messagetypes::TM_STORE) { + if (cmdMessage.getMessageType() == messagetypes::TM_STORE) { + Command_t cmd = cmdMessage.getCommand(); object_id_t objectId = TmStoreMessage::getObjectId(&cmdMessage); + TmStore *tmStore = nullptr; switch (objectId) { case (objects::HK_TM_STORE): { + tmStore = &hkStore; break; } case (objects::OK_TM_STORE): { + tmStore = &okStore; break; } case (objects::NOT_OK_TM_STORE): { + tmStore = ¬OkStore; break; } case (objects::MISC_TM_STORE): { + tmStore = &miscStore; break; } default: { } } + if (tmStore == nullptr) { + continue; + } + if (cmd == TmStoreMessage::DELETE_STORE_CONTENT_TIME) { + store_address_t storeId = TmStoreMessage::getStoreId(&cmdMessage); + auto accessor = ipcStore.getData(storeId); + uint32_t deleteUpToUnixSeconds = 0; + size_t size = accessor.second.size(); + SerializeAdapter::deSerialize(&deleteUpToUnixSeconds, accessor.second.data(), &size, + SerializeIF::Endianness::NETWORK); + tmStore->deleteUpTo(deleteUpToUnixSeconds); + } else if (cmd == TmStoreMessage::DOWNLINK_STORE_CONTENT_TIME) { + } } } TmTcMessage currentMessage; diff --git a/mission/tmtc/PusTmFunnel.h b/mission/tmtc/PusTmFunnel.h index a54093c2..464db37c 100644 --- a/mission/tmtc/PusTmFunnel.h +++ b/mission/tmtc/PusTmFunnel.h @@ -23,7 +23,8 @@ class PusTmFunnel : public TmFunnelBase { public: explicit PusTmFunnel(object_id_t objectId, TimeReaderIF &timeReader, StorageManagerIF &tmStore, - SdCardMountedIF &sdcMan, uint32_t tmMsgDepth, uint32_t tcMsgDepth); + SdCardMountedIF &sdcMan, uint32_t tmMsgDepth, uint32_t tcMsgDepth, + StorageManagerIF &ipcStore); [[nodiscard]] const char *getName() const override; ~PusTmFunnel() override; diff --git a/mission/tmtc/TmFunnelBase.cpp b/mission/tmtc/TmFunnelBase.cpp index 156e4664..b4bf6c62 100644 --- a/mission/tmtc/TmFunnelBase.cpp +++ b/mission/tmtc/TmFunnelBase.cpp @@ -3,8 +3,8 @@ #include "fsfw/ipc/QueueFactory.h" TmFunnelBase::TmFunnelBase(object_id_t objectId, StorageManagerIF &tmStore, uint32_t tmMsgDepth, - uint32_t tcMsgDepth) - : SystemObject(objectId), tmStore(tmStore) { + uint32_t tcMsgDepth, StorageManagerIF &ipcStore) + : SystemObject(objectId), tmStore(tmStore), ipcStore(ipcStore) { tmQueue = QueueFactory::instance()->createMessageQueue(tmMsgDepth); tcQueue = QueueFactory::instance()->createMessageQueue(tcMsgDepth); } diff --git a/mission/tmtc/TmFunnelBase.h b/mission/tmtc/TmFunnelBase.h index 271c17c0..12453cc2 100644 --- a/mission/tmtc/TmFunnelBase.h +++ b/mission/tmtc/TmFunnelBase.h @@ -13,7 +13,7 @@ class TmFunnelBase : public TmStoreFrontendSimpleIF, public SystemObject { public: TmFunnelBase(object_id_t objectId, StorageManagerIF& tmStore, uint32_t tmMsgDepth, - uint32_t tcMsgDepth); + uint32_t tcMsgDepth, StorageManagerIF& ipcStore); void addDestination(const AcceptsTelemetryIF& downlinkDestination, uint8_t vcid = 0); [[nodiscard]] MessageQueueId_t getCommandQueue() const override; @@ -23,6 +23,7 @@ class TmFunnelBase : public TmStoreFrontendSimpleIF, protected: StorageManagerIF& tmStore; + StorageManagerIF& ipcStore; std::vector> destinations; MessageQueueIF* tcQueue = nullptr; MessageQueueIF* tmQueue = nullptr; From b9753dc5ba84dc097bac492bb13bb974dc27d854 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 19 Dec 2022 14:01:15 +0100 Subject: [PATCH 048/373] added dump command forwarding --- mission/tmtc/PusTmFunnel.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mission/tmtc/PusTmFunnel.cpp b/mission/tmtc/PusTmFunnel.cpp index ff662afd..18706397 100644 --- a/mission/tmtc/PusTmFunnel.cpp +++ b/mission/tmtc/PusTmFunnel.cpp @@ -88,6 +88,17 @@ ReturnValue_t PusTmFunnel::performOperation(uint8_t) { SerializeIF::Endianness::NETWORK); tmStore->deleteUpTo(deleteUpToUnixSeconds); } else if (cmd == TmStoreMessage::DOWNLINK_STORE_CONTENT_TIME) { + store_address_t storeId = TmStoreMessage::getStoreId(&cmdMessage); + auto accessor = ipcStore.getData(storeId); + uint32_t dumpFromUnixSeconds; + uint32_t dumpUntilUnixSeconds; + size_t size = accessor.second.size(); + SerializeAdapter::deSerialize(&dumpFromUnixSeconds, accessor.second.data(), &size, + SerializeIF::Endianness::NETWORK); + SerializeAdapter::deSerialize(&dumpUntilUnixSeconds, accessor.second.data(), &size, + SerializeIF::Endianness::NETWORK); + // TODO: TM store missing, and maybe there is a better way to do this? + tmStore->dumpFromUpTo(dumpFromUnixSeconds, dumpUntilUnixSeconds, destinations, tmQueue); } } } From d9453c3b83f0129478d6f1afebfb098930f44d9a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 19 Dec 2022 14:40:27 +0100 Subject: [PATCH 049/373] absolutely magnificent --- mission/tmtc/PusTmFunnel.cpp | 33 ++----------------------------- mission/tmtc/TmFunnelBase.cpp | 37 +++++++++++++++++++++++++++++++++++ mission/tmtc/TmFunnelBase.h | 3 +++ mission/tmtc/TmStore.cpp | 9 +++++++-- mission/tmtc/TmStore.h | 6 +++--- 5 files changed, 52 insertions(+), 36 deletions(-) diff --git a/mission/tmtc/PusTmFunnel.cpp b/mission/tmtc/PusTmFunnel.cpp index 18706397..f79ac9b2 100644 --- a/mission/tmtc/PusTmFunnel.cpp +++ b/mission/tmtc/PusTmFunnel.cpp @@ -98,7 +98,7 @@ ReturnValue_t PusTmFunnel::performOperation(uint8_t) { SerializeAdapter::deSerialize(&dumpUntilUnixSeconds, accessor.second.data(), &size, SerializeIF::Endianness::NETWORK); // TODO: TM store missing, and maybe there is a better way to do this? - tmStore->dumpFromUpTo(dumpFromUnixSeconds, dumpUntilUnixSeconds, destinations, tmQueue); + tmStore->dumpFromUpTo(dumpFromUnixSeconds, dumpUntilUnixSeconds, *this); } } } @@ -149,36 +149,7 @@ ReturnValue_t PusTmFunnel::handlePacket(TmTcMessage &message) { miscStore.passPacket(packet); okStore.passPacket(packet); } - - for (unsigned int idx = 0; idx < destinations.size(); idx++) { - const auto &destVcidPair = destinations[idx]; - if (destinations.size() > 1) { - if (idx < destinations.size() - 1) { - // Create copy of data to ensure each TM recipient has its own copy. That way, we don't need - // to bother with send order and where the data is deleted. - store_address_t storeId; - result = tmStore.addData(&storeId, packetData, size); - if (result == returnvalue::OK) { - message.setStorageId(storeId); - } else { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "PusTmFunnel::handlePacket: Store too full to create data copy" - << std::endl; -#endif - } - } else { - message.setStorageId(origStoreId); - } - } - result = tmQueue->sendMessage(destVcidPair.first, &message); - if (result != returnvalue::OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "PusTmFunnel::handlePacket: Error sending TM to downlink handler" << std::endl; -#endif - tmStore.deleteData(message.getStorageId()); - } - } - return result; + return sendPacketToDestinations(origStoreId, message, packetData, size); } const char *PusTmFunnel::getName() const { return "PUS TM Funnel"; } diff --git a/mission/tmtc/TmFunnelBase.cpp b/mission/tmtc/TmFunnelBase.cpp index b4bf6c62..0f600efe 100644 --- a/mission/tmtc/TmFunnelBase.cpp +++ b/mission/tmtc/TmFunnelBase.cpp @@ -1,5 +1,7 @@ #include "TmFunnelBase.h" +#include + #include "fsfw/ipc/QueueFactory.h" TmFunnelBase::TmFunnelBase(object_id_t objectId, StorageManagerIF &tmStore, uint32_t tmMsgDepth, @@ -21,3 +23,38 @@ void TmFunnelBase::addDestination(const AcceptsTelemetryIF &downlinkDestination, auto queueId = downlinkDestination.getReportReceptionQueue(vcid); destinations.emplace_back(queueId, vcid); } + +ReturnValue_t TmFunnelBase::sendPacketToDestinations(store_address_t origStoreId, + TmTcMessage &message, + const uint8_t *packetData, size_t size) { + ReturnValue_t result; + for (unsigned int idx = 0; idx < destinations.size(); idx++) { + const auto &destVcidPair = destinations[idx]; + if (destinations.size() > 1) { + if (idx < destinations.size() - 1) { + // Create copy of data to ensure each TM recipient has its own copy. That way, we don't need + // to bother with send order and where the data is deleted. + store_address_t storeId; + result = tmStore.addData(&storeId, packetData, size); + if (result == returnvalue::OK) { + message.setStorageId(storeId); + } else { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::error << "PusTmFunnel::handlePacket: Store too full to create data copy" + << std::endl; +#endif + } + } else { + message.setStorageId(origStoreId); + } + } + result = tmQueue->sendMessage(destVcidPair.first, &message); + if (result != returnvalue::OK) { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::error << "PusTmFunnel::handlePacket: Error sending TM to downlink handler" << std::endl; +#endif + tmStore.deleteData(message.getStorageId()); + } + } + return result; +} diff --git a/mission/tmtc/TmFunnelBase.h b/mission/tmtc/TmFunnelBase.h index 12453cc2..bfff3440 100644 --- a/mission/tmtc/TmFunnelBase.h +++ b/mission/tmtc/TmFunnelBase.h @@ -5,6 +5,7 @@ #include #include #include +#include #include @@ -15,6 +16,8 @@ class TmFunnelBase : public TmStoreFrontendSimpleIF, TmFunnelBase(object_id_t objectId, StorageManagerIF& tmStore, uint32_t tmMsgDepth, uint32_t tcMsgDepth, StorageManagerIF& ipcStore); void addDestination(const AcceptsTelemetryIF& downlinkDestination, uint8_t vcid = 0); + ReturnValue_t sendPacketToDestinations(store_address_t origStoreId, TmTcMessage& message, + const uint8_t* packetData, size_t size); [[nodiscard]] MessageQueueId_t getCommandQueue() const override; [[nodiscard]] MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) const override; diff --git a/mission/tmtc/TmStore.cpp b/mission/tmtc/TmStore.cpp index 2de1e818..a18f16d1 100644 --- a/mission/tmtc/TmStore.cpp +++ b/mission/tmtc/TmStore.cpp @@ -185,5 +185,10 @@ void TmStore::addServiceSubservice(uint8_t service, uint8_t subservice) { void TmStore::deleteUpTo(uint32_t unixSeconds) {} void TmStore::dumpFromUpTo(uint32_t fromUnixSeconds, uint32_t upToUnixSeconds, - std::vector>& destinations, - MessageQueueIF* tmQueue) {} + TmFunnelBase& funnel) { + store_address_t storeId; + TmTcMessage message; + const uint8_t* packetData = nullptr; + size_t size = 0; + funnel.sendPacketToDestinations(storeId, message, packetData, size); +} diff --git a/mission/tmtc/TmStore.h b/mission/tmtc/TmStore.h index 72071e02..0654052d 100644 --- a/mission/tmtc/TmStore.h +++ b/mission/tmtc/TmStore.h @@ -9,6 +9,8 @@ #include +#include "TmFunnelBase.h" + struct PacketFilter { std::optional> apid; std::optional> services; @@ -28,9 +30,7 @@ class TmStore : public SystemObject { void addServiceSubservice(uint8_t service, uint8_t subservice); void deleteUpTo(uint32_t unixSeconds); - void dumpFromUpTo(uint32_t fromUnixSeconds, uint32_t upToUnixSeconds, - std::vector>& destinations, - MessageQueueIF* tmQueue); + void dumpFromUpTo(uint32_t fromUnixSeconds, uint32_t upToUnixSeconds, TmFunnelBase& tmFunnel); void updateBaseDir(); ReturnValue_t passPacket(PusTmReader& reader); From 29fd2653f15a4a0ee59b9df2753ccdac27ce3569 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 19 Dec 2022 15:23:42 +0100 Subject: [PATCH 050/373] added TODO with steps --- mission/tmtc/TmStore.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mission/tmtc/TmStore.cpp b/mission/tmtc/TmStore.cpp index a18f16d1..26b3b0a8 100644 --- a/mission/tmtc/TmStore.cpp +++ b/mission/tmtc/TmStore.cpp @@ -182,10 +182,17 @@ void TmStore::addServiceSubservice(uint8_t service, uint8_t subservice) { filter.serviceSubservices.value().push_back({service, subservice}); } -void TmStore::deleteUpTo(uint32_t unixSeconds) {} +void TmStore::deleteUpTo(uint32_t unixSeconds) { + +} void TmStore::dumpFromUpTo(uint32_t fromUnixSeconds, uint32_t upToUnixSeconds, TmFunnelBase& funnel) { + // TODO: + // 1. Find all files within the specified range + // 2. For each file, dump content into buffer, parse out space packets, + // 3. Store each packet into the TM store and send the message to all + // destinations store_address_t storeId; TmTcMessage message; const uint8_t* packetData = nullptr; From d14d7ae66d704eb849a6f55cc860e2fdb0e43ba9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 11 Jan 2023 09:18:07 +0100 Subject: [PATCH 051/373] bump submodules --- fsfw | 2 +- tmtc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fsfw b/fsfw index 2aa4af69..041d1b87 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 2aa4af69742d932f09ec2a1d3d29b648295035d1 +Subproject commit 041d1b8795af8f57738171ad84a1c323b9d0c8d5 diff --git a/tmtc b/tmtc index 383b3214..b032defa 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 383b32141c8c382b84c587d6814fe9252dde0b4a +Subproject commit b032defa7c6450cbbf21ffe8cfc50f6d5d5bc614 From a0ad48d169bf54966c4f3908e4e0ea08d888d36c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 24 Jan 2023 15:24:39 +0100 Subject: [PATCH 052/373] start adding heater info set --- mission/controller/ThermalController.cpp | 1 + mission/controller/ThermalController.h | 1 + .../ThermalControllerDefinitions.h | 25 +++++++++++++++---- tmtc | 2 +- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index f0356f66..6f7b7193 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -19,6 +19,7 @@ ThermalController::ThermalController(object_id_t objectId) sensorTemperatures(this), susTemperatures(this), deviceTemperatures(this), + heaterInfo(this), max31865Set0(objects::RTD_0_IC3_PLOC_HEATSPREADER, EiveMax31855::RtdCommands::EXCHANGE_SET_ID), max31865Set1(objects::RTD_1_IC4_PLOC_MISSIONBOARD, diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 5f4569c3..1783e932 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -37,6 +37,7 @@ class ThermalController : public ExtendedControllerBase { thermalControllerDefinitions::SensorTemperatures sensorTemperatures; thermalControllerDefinitions::SusTemperatures susTemperatures; thermalControllerDefinitions::DeviceTemperatures deviceTemperatures; + thermalControllerDefinitions::HeaterInfo heaterInfo; // Temperature Sensors MAX31865::Max31865Set max31865Set0; diff --git a/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h b/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h index 9f800bec..89a1d10e 100644 --- a/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h +++ b/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h @@ -3,14 +3,16 @@ #include #include +#include "devices/heaterSwitcherList.h" namespace thermalControllerDefinitions { enum SetIds : uint32_t { - SENSOR_TEMPERATURES, - DEVICE_TEMPERATURES, - SUS_TEMPERATURES, - COMPONENT_TEMPERATURES + SENSOR_TEMPERATURES = 0, + DEVICE_TEMPERATURES = 1, + SUS_TEMPERATURES = 2, + COMPONENT_TEMPERATURES = 3, + HEATER_SET = 4, }; enum PoolIds : lp_id_t { @@ -75,7 +77,10 @@ enum PoolIds : lp_id_t { TEMP_GYRO_3_SIDE_B, TEMP_MGM_0_SIDE_A, TEMP_MGM_2_SIDE_B, - TEMP_ADC_PAYLOAD_PCDU + TEMP_ADC_PAYLOAD_PCDU, + + HEATER_SWITCH_LIST, + HEATER_CURRENT }; static const uint8_t ENTRIES_SENSOR_TEMPERATURE_SET = 25; @@ -201,6 +206,16 @@ class SusTemperatures : public StaticLocalDataSet { lp_var_t(sid.objectId, PoolIds::SUS_11_R_LOC_XBYMZB_PT_ZB, this); }; +class HeaterInfo: public StaticLocalDataSet<12> { +public: + HeaterInfo(HasLocalDataPoolIF* owner): StaticLocalDataSet(owner, HEATER_SET) {} + HeaterInfo(object_id_t objectId): StaticLocalDataSet(sid_t(objectId, HEATER_SET)) {} + + lp_vec_t heaterSwitchState = + lp_vec_t(sid.objectId, PoolIds::HEATER_SWITCH_LIST, this); + lp_var_t heaterCurrent = lp_var_t(sid.objectId, PoolIds::HEATER_CURRENT, this); +}; + } // namespace thermalControllerDefinitions #endif /* MISSION_CONTROLLER_CONTROLLERDEFINITIONS_THERMALCONTROLLERDEFINITIONS_H_ */ diff --git a/tmtc b/tmtc index 49f27c99..5998aa12 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 49f27c9923cfa13a3bafce46c37dd2631550f4af +Subproject commit 5998aa12a4750584eb474b5d936fa461e9725154 From 485ee2f8e0e32f987c98650c8afa808cc4ff94c7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 24 Jan 2023 15:35:56 +0100 Subject: [PATCH 053/373] base line heater info set --- mission/controller/ThermalController.cpp | 4 ++++ mission/controller/ThermalController.h | 12 +++++++----- .../ThermalControllerDefinitions.h | 12 +++++++----- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 6f7b7193..35391599 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -205,6 +205,8 @@ ReturnValue_t ThermalController::initializeLocalDataPool(localpool::DataPool& lo new PoolEntry({0.0})); localDataPoolMap.emplace(thermalControllerDefinitions::TEMP_ADC_PAYLOAD_PCDU, new PoolEntry({0.0})); + localDataPoolMap.emplace(thermalControllerDefinitions::HEATER_SWITCH_LIST, &heaterSwitchStates); + localDataPoolMap.emplace(thermalControllerDefinitions::HEATER_CURRENT, &heaterCurrent); poolManager.subscribeForRegularPeriodicPacket( subdp::RegularHkPeriodicParams(sensorTemperatures.getSid(), false, 10.0)); @@ -212,6 +214,8 @@ ReturnValue_t ThermalController::initializeLocalDataPool(localpool::DataPool& lo subdp::RegularHkPeriodicParams(susTemperatures.getSid(), false, 10.0)); poolManager.subscribeForRegularPeriodicPacket( subdp::RegularHkPeriodicParams(deviceTemperatures.getSid(), false, 10.0)); + poolManager.subscribeForDiagPeriodicPacket( + subdp::DiagnosticsHkPeriodicParams(heaterInfo.getSid(), false, 10.0)); return returnvalue::OK; } diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 1783e932..df36defd 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -81,11 +81,13 @@ class ThermalController : public ExtendedControllerBase { // Initial delay to make sure all pool variables have been initialized their owners Countdown initialCountdown = Countdown(DELAY); - PoolEntry tmp1075Tcs0 = PoolEntry(10.0); - PoolEntry tmp1075Tcs1 = PoolEntry(10.0); - PoolEntry tmp1075PlPcdu0 = PoolEntry(10.0); - PoolEntry tmp1075PlPcdu1 = PoolEntry(10.0); - PoolEntry tmp1075IfBrd = PoolEntry(10.0); + PoolEntry tmp1075Tcs0 = PoolEntry({10.0}); + PoolEntry tmp1075Tcs1 = PoolEntry({10.0}); + PoolEntry tmp1075PlPcdu0 = PoolEntry({10.0}); + PoolEntry tmp1075PlPcdu1 = PoolEntry({10.0}); + PoolEntry tmp1075IfBrd = PoolEntry({10.0}); + PoolEntry heaterSwitchStates = PoolEntry(heater::NUMBER_OF_SWITCHES); + PoolEntry heaterCurrent = PoolEntry(); static constexpr dur_millis_t MUTEX_TIMEOUT = 50; void copySensors(); diff --git a/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h b/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h index 89a1d10e..3dbecb03 100644 --- a/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h +++ b/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h @@ -3,6 +3,7 @@ #include #include + #include "devices/heaterSwitcherList.h" namespace thermalControllerDefinitions { @@ -206,13 +207,14 @@ class SusTemperatures : public StaticLocalDataSet { lp_var_t(sid.objectId, PoolIds::SUS_11_R_LOC_XBYMZB_PT_ZB, this); }; -class HeaterInfo: public StaticLocalDataSet<12> { -public: - HeaterInfo(HasLocalDataPoolIF* owner): StaticLocalDataSet(owner, HEATER_SET) {} - HeaterInfo(object_id_t objectId): StaticLocalDataSet(sid_t(objectId, HEATER_SET)) {} +class HeaterInfo : public StaticLocalDataSet<12> { + public: + HeaterInfo(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HEATER_SET) {} + HeaterInfo(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, HEATER_SET)) {} lp_vec_t heaterSwitchState = - lp_vec_t(sid.objectId, PoolIds::HEATER_SWITCH_LIST, this); + lp_vec_t(sid.objectId, PoolIds::HEATER_SWITCH_LIST, + this); lp_var_t heaterCurrent = lp_var_t(sid.objectId, PoolIds::HEATER_CURRENT, this); }; From d0a7d2892e52fabd646eadda33299718913ff128 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 24 Jan 2023 15:46:20 +0100 Subject: [PATCH 054/373] added reading of current value --- mission/controller/ThermalController.cpp | 12 ++++++++++++ mission/controller/ThermalController.h | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 35391599..63bbf861 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -104,6 +104,18 @@ void ThermalController::performControlOperation() { copyDevices(); deviceTemperatures.commit(); } + + { + PoolReadGuard pg(&heaterInfo); + if (pg.getReadResult() == returnvalue::OK) { + { + PoolReadGuard pg(¤tVecPdu2); + if (pg.getReadResult() == returnvalue::OK) { + heaterInfo.heaterCurrent.value = currentVecPdu2.value[PDU2::Channels::TCS_HEATER_IN]; + } + } + } + } } ReturnValue_t ThermalController::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index df36defd..f661876d 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -8,6 +8,8 @@ #include #include +#include "mission/devices/devicedefinitions/GomspaceDefinitions.h" + class ThermalController : public ExtendedControllerBase { public: static const uint16_t INVALID_TEMPERATURE = 999; @@ -38,6 +40,8 @@ class ThermalController : public ExtendedControllerBase { thermalControllerDefinitions::SusTemperatures susTemperatures; thermalControllerDefinitions::DeviceTemperatures deviceTemperatures; thermalControllerDefinitions::HeaterInfo heaterInfo; + lp_vec_t currentVecPdu2 = + lp_vec_t(gp_id_t(objects::PDU2_HANDLER, PDU::pool::PDU_CURRENTS)); // Temperature Sensors MAX31865::Max31865Set max31865Set0; From 430e535fe9777aeba7cf06e9489adfa88ed93198 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 24 Jan 2023 15:48:06 +0100 Subject: [PATCH 055/373] update changelog --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7742cb5..f4380e82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,8 +10,16 @@ list yields a list of all related PRs for each release. # [unreleased] +## Changed + - Startracker temperature set and PCDU switcher set are diagnostic now +## Added + +- Added new heater info set for the TCS controller. This set contains the heater switch states + and the current draw. + PR: https://egit.irs.uni-stuttgart.de/eive/eive-obsw/pulls/351 + # [v1.20.0] 2023-01-24 ## Added From fc1dedeb7a453a9dc7883cd8ac29e277e7422c72 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 2 Feb 2023 15:33:04 +0100 Subject: [PATCH 056/373] moved transmitter timer and event handling of carrier and bitlock to ComSubsystem --- bsp_q7s/core/ObjectFactory.cpp | 9 +- mission/system/objects/ComSubsystem.cpp | 115 +++++++++++++++++++++++- mission/system/objects/ComSubsystem.h | 37 +++++++- mission/system/tree/comModeTree.cpp | 5 +- mission/system/tree/comModeTree.h | 5 ++ mission/tmtc/CcsdsIpCoreHandler.cpp | 105 +--------------------- mission/tmtc/CcsdsIpCoreHandler.h | 26 +----- 7 files changed, 163 insertions(+), 139 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 847cce5f..1fb9efed 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -783,15 +783,10 @@ ReturnValue_t ObjectFactory::createCcsdsComponents(LinuxLibgpioIF* gpioComIF, AxiPtmeConfig* axiPtmeConfig = new AxiPtmeConfig(objects::AXI_PTME_CONFIG, q7s::UIO_PTME, q7s::uiomapids::PTME_CONFIG); PtmeConfig* ptmeConfig = new PtmeConfig(objects::PTME_CONFIG, axiPtmeConfig); -#if OBSW_ENABLE_SYRLINKS_TRANSMIT_TIMEOUT == 1 - // Set to high value when not sending via syrlinks - static const uint32_t TRANSMITTER_TIMEOUT = 86400000; // 1 day -#else - static const uint32_t TRANSMITTER_TIMEOUT = 900000; // 15 minutes -#endif + *ipCoreHandler = new CcsdsIpCoreHandler( objects::CCSDS_HANDLER, objects::PTME, objects::CCSDS_PACKET_DISTRIBUTOR, ptmeConfig, - gpioComIF, gpioIds::RS485_EN_TX_CLOCK, gpioIds::RS485_EN_TX_DATA, TRANSMITTER_TIMEOUT); + gpioComIF, gpioIds::RS485_EN_TX_CLOCK, gpioIds::RS485_EN_TX_DATA); VirtualChannel* vc = nullptr; vc = new VirtualChannel(ccsds::VC0, config::VC0_QUEUE_SIZE, objects::CCSDS_HANDLER); (*ipCoreHandler)->addVirtualChannel(ccsds::VC0, vc); diff --git a/mission/system/objects/ComSubsystem.cpp b/mission/system/objects/ComSubsystem.cpp index 426e9c6c..5c98dfd8 100644 --- a/mission/system/objects/ComSubsystem.cpp +++ b/mission/system/objects/ComSubsystem.cpp @@ -1,13 +1,32 @@ +#include + #include "ComSubsystem.h" +#include #include +#include +#include +#include +#include -#include "mission/config/comCfg.h" +extern std::pair> COM_SEQUENCE_RX_ONLY; +extern std::pair> COM_SEQUENCE_RX_AND_TX_DEFAULT_RATE; +extern std::pair> COM_SEQUENCE_RX_AND_TX_LOW_RATE; +extern std::pair> COM_SEQUENCE_RX_AND_TX_HIGH_RATE; ComSubsystem::ComSubsystem(object_id_t setObjectId, uint32_t maxNumberOfSequences, - uint32_t maxNumberOfTables) + uint32_t maxNumberOfTables, uint32_t transmitterTimeout) : Subsystem(setObjectId, maxNumberOfSequences, maxNumberOfTables), paramHelper(this) { com::setCurrentDatarate(com::Datarate::LOW_RATE_MODULATION_BPSK); + auto mqArgs = MqArgs(setObjectId, static_cast(this)); + eventQueue = + QueueFactory::instance()->createMessageQueue(10, EventMessage::EVENT_MESSAGE_SIZE, &mqArgs); + transmitterCountdown.setTimeout(transmitterTimeout); +} + +void ComSubsystem::performChildOperation() { + readEventQueue(); + checkTransmitterCountdown(); } MessageQueueId_t ComSubsystem::getCommandQueue() const { return Subsystem::getCommandQueue(); } @@ -44,5 +63,97 @@ ReturnValue_t ComSubsystem::initialize() { if (result != returnvalue::OK) { return result; } + EventManagerIF* manager = ObjectManager::instance()->get(objects::EVENT_MANAGER); + if (manager == nullptr) { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::error << "ComSubsystem::initialize: Invalid event manager" << std::endl; +#endif + return ObjectManagerIF::CHILD_INIT_FAILED; + } + result = manager->registerListener(eventQueue->getId()); + if (result != returnvalue::OK) { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::warning << "ComSubsystem::initialize: Failed to register Com Subsystem as event " + "listener" << std::endl; +#endif + return ObjectManagerIF::CHILD_INIT_FAILED; + } + result = manager->subscribeToEventRange(eventQueue->getId(), + event::getEventId(PdecHandler::CARRIER_LOCK), + event::getEventId(PdecHandler::BIT_LOCK_PDEC)); + if (result != returnvalue::OK) { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::error << "ComSubsystem::initialize: Failed to subscribe to events from PDEC " + "handler" + << std::endl; +#endif + return result; + } return Subsystem::initialize(); } + +void ComSubsystem::startTransition(Mode_t mode, Submode_t submode) { + // Depending on the mode the transmitter timeout is enabled or + // disabled here + if (mode == COM_SEQUENCE_RX_ONLY.first) { + transmitterCountdown.timeOut(); + } else if ((mode == COM_SEQUENCE_RX_AND_TX_DEFAULT_RATE.first) || + (mode == COM_SEQUENCE_RX_AND_TX_LOW_RATE.first) || + (mode == COM_SEQUENCE_RX_AND_TX_HIGH_RATE.first)) { + transmitterCountdown.resetTimer(); + } + Subsystem::startTransition(mode, submode); +} + +void ComSubsystem::readEventQueue() { + EventMessage event; + for (ReturnValue_t result = eventQueue->receiveMessage(&event); result == returnvalue::OK; + result = eventQueue->receiveMessage(&event)) { + switch (event.getMessageId()) { + case EventMessage::EVENT_MESSAGE: + handleEventMessage(&event); + break; + default: + sif::debug << "CcsdsHandler::checkEvents: Did not subscribe to this event message" + << std::endl; + break; + } + } +} + +void ComSubsystem::handleEventMessage(EventMessage *eventMessage) { + Event event = eventMessage->getEvent(); + switch (event) { + case PdecHandler::BIT_LOCK_PDEC: { + handleBitLockEvent(); + break; + } + case PdecHandler::CARRIER_LOCK: { + handleCarrierLockEvent(); + break; + } + default: + sif::debug << "ComSubsystem::handleEvent: Did not subscribe to this event" << std::endl; + break; + } +} + +void ComSubsystem::handleBitLockEvent() { startRxAndTxDefaultSeq(); } + +void ComSubsystem::handleCarrierLockEvent() { + if (!enableTxWhenCarrierLock) { + return; + } + startRxAndTxDefaultSeq(); +} + +void ComSubsystem::startRxAndTxDefaultSeq() { + // Turns transmitter on + startTransition(COM_SEQUENCE_RX_AND_TX_DEFAULT_RATE.first, SUBMODE_NONE); +} + +void ComSubsystem::checkTransmitterCountdown() { + if (transmitterCountdown.hasTimedOut()) { + startTransition(COM_SEQUENCE_RX_ONLY.first, SUBMODE_NONE); + } +} diff --git a/mission/system/objects/ComSubsystem.h b/mission/system/objects/ComSubsystem.h index 74f0c30e..3f1ef5d2 100644 --- a/mission/system/objects/ComSubsystem.h +++ b/mission/system/objects/ComSubsystem.h @@ -4,26 +4,61 @@ #include #include #include +#include #include "mission/comDefs.h" class ComSubsystem : public Subsystem, public ReceivesParameterMessagesIF { public: - ComSubsystem(object_id_t setObjectId, uint32_t maxNumberOfSequences, uint32_t maxNumberOfTables); + /** + * @brief Constructor + * + * @param setObjectId + * @param maxNumberOfSequences + * @param maxNumberOfTables + * @param transmitterTimeout Maximum time the transmitter of the syrlinks + * will be enabled + */ + ComSubsystem(object_id_t setObjectId, uint32_t maxNumberOfSequences, uint32_t maxNumberOfTables, + uint32_t transmitterTimeout); virtual ~ComSubsystem() = default; MessageQueueId_t getCommandQueue() const override; ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueIdentifier, ParameterWrapper *parameterWrapper, const ParameterWrapper *newValues, uint16_t startAtIndex) override; + virtual void performChildOperation() override; private: ReturnValue_t handleCommandMessage(CommandMessage *message) override; ReturnValue_t initialize() override; + void startTransition(Mode_t mode, Submode_t submode) override; + + void readEventQueue(); + void handleEventMessage(EventMessage* eventMessage); + void handleBitLockEvent(); + void handleCarrierLockEvent(); + void checkTransmitterCountdown(); + /** + * @brief Enables transmitter in default (low) rate mode + */ + void startRxAndTxDefaultSeq(); + uint8_t datarateCfg = static_cast(com::Datarate::LOW_RATE_MODULATION_BPSK); ParameterHelper paramHelper; + + MessageQueueIF* eventQueue = nullptr; + + bool enableTxWhenCarrierLock = false; + + // Maximum time after which the transmitter will be turned of. This is a + // protection mechanism due prevent the syrlinks from overheating + uint32_t transmitterTimeout = 0; + + // Countdown will be started as soon as the transmitter was enabled + Countdown transmitterCountdown; }; #endif /* MISSION_SYSTEM_COMSUBSYSTEM_H_ */ diff --git a/mission/system/tree/comModeTree.cpp b/mission/system/tree/comModeTree.cpp index e08ba5ba..d0811dd7 100644 --- a/mission/system/tree/comModeTree.cpp +++ b/mission/system/tree/comModeTree.cpp @@ -1,6 +1,5 @@ #include "comModeTree.h" -#include #include #include #include @@ -11,7 +10,7 @@ const auto check = subsystem::checkInsert; -ComSubsystem satsystem::com::SUBSYSTEM = ComSubsystem(objects::COM_SUBSYSTEM, 12, 24); +ComSubsystem satsystem::com::SUBSYSTEM = ComSubsystem(objects::COM_SUBSYSTEM, 12, 24, TRANSMITTER_TIMEOUT); static const auto OFF = HasModesIF::MODE_OFF; static const auto ON = HasModesIF::MODE_ON; @@ -94,7 +93,7 @@ void buildRxOnlySequence(Subsystem& ss, ModeListEntry& eh) { // Build RX Only table. We could track the state of the CCSDS IP core handler // as well but I do not think this is necessary because enabling that should - // not intefere with the Syrlinks Handler. + // not interfere with the Syrlinks Handler. iht(objects::SYRLINKS_HANDLER, NML, ::com::Submode::RX_ONLY, COM_TABLE_RX_ONLY_TGT.second); check(ss.addTable(TableEntry(COM_TABLE_RX_ONLY_TGT.first, &COM_TABLE_RX_ONLY_TGT.second)), ctxc); diff --git a/mission/system/tree/comModeTree.h b/mission/system/tree/comModeTree.h index ccc7f15f..587cc8ed 100644 --- a/mission/system/tree/comModeTree.h +++ b/mission/system/tree/comModeTree.h @@ -2,12 +2,17 @@ #define MISSION_SYSTEM_TREE_COMMODETREE_H_ #include +#include namespace satsystem { namespace com { extern ComSubsystem SUBSYSTEM; +// The syrlinks must not transmitting longer then 15 minutes otherwise the +// transceiver might be damaged due to overheating +static const uint32_t TRANSMITTER_TIMEOUT = 900000; // 15 minutes + void init(); } // namespace com diff --git a/mission/tmtc/CcsdsIpCoreHandler.cpp b/mission/tmtc/CcsdsIpCoreHandler.cpp index 85d1143b..0b6a210d 100644 --- a/mission/tmtc/CcsdsIpCoreHandler.cpp +++ b/mission/tmtc/CcsdsIpCoreHandler.cpp @@ -1,12 +1,10 @@ #include "CcsdsIpCoreHandler.h" #include -#include #include #include #include "eive/definitions.h" -#include "fsfw/events/EventManagerIF.h" #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serialize/SerializeAdapter.h" @@ -16,8 +14,7 @@ CcsdsIpCoreHandler::CcsdsIpCoreHandler(object_id_t objectId, object_id_t ptmeId, object_id_t tcDestination, PtmeConfig* ptmeConfig, - GpioIF* gpioIF, gpioId_t enTxClock, gpioId_t enTxData, - uint32_t transmitterTimeout) + GpioIF* gpioIF, gpioId_t enTxClock, gpioId_t enTxData) : SystemObject(objectId), ptmeId(ptmeId), tcDestination(tcDestination), @@ -27,8 +24,7 @@ CcsdsIpCoreHandler::CcsdsIpCoreHandler(object_id_t objectId, object_id_t ptmeId, ptmeConfig(ptmeConfig), gpioIF(gpioIF), enTxClock(enTxClock), - enTxData(enTxData), - transmitterTimeout(transmitterTimeout) { + enTxData(enTxData) { commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); auto mqArgs = MqArgs(objectId, static_cast(this)); eventQueue = @@ -38,11 +34,9 @@ CcsdsIpCoreHandler::CcsdsIpCoreHandler(object_id_t objectId, object_id_t ptmeId, CcsdsIpCoreHandler::~CcsdsIpCoreHandler() {} ReturnValue_t CcsdsIpCoreHandler::performOperation(uint8_t operationCode) { - checkEvents(); readCommandQueue(); handleTelemetry(); handleTelecommands(); - checkTxTimer(); return returnvalue::OK; } @@ -98,34 +92,6 @@ ReturnValue_t CcsdsIpCoreHandler::initialize() { iter->second->setPtmeObject(ptme); } - EventManagerIF* manager = ObjectManager::instance()->get(objects::EVENT_MANAGER); - if (manager == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "CcsdsHandler::initialize: Invalid event manager" << std::endl; -#endif - return ObjectManagerIF::CHILD_INIT_FAILED; - } - result = manager->registerListener(eventQueue->getId()); - if (result != returnvalue::OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "CcsdsHandler::initialize: Failed to register CCSDS handler as event " - "listener" - << std::endl; -#endif - return ObjectManagerIF::CHILD_INIT_FAILED; - ; - } - result = manager->subscribeToEventRange(eventQueue->getId(), - event::getEventId(PdecHandler::CARRIER_LOCK), - event::getEventId(PdecHandler::BIT_LOCK_PDEC)); - if (result != returnvalue::OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "CcsdsHandler::initialize: Failed to subscribe to events from PDEC " - "handler" - << std::endl; -#endif - return result; - } result = ptmeConfig->initialize(); if (result != returnvalue::OK) { return ObjectManagerIF::CHILD_INIT_FAILED; @@ -135,9 +101,6 @@ ReturnValue_t CcsdsIpCoreHandler::initialize() { return ObjectManagerIF::CHILD_INIT_FAILED; } - transmitterCountdown.setTimeout(transmitterTimeout); - transmitterCountdown.timeOut(); - #if OBSW_SYRLINKS_SIMULATED == 1 // Update data on rising edge ptmeConfig->invertTxClock(false); @@ -286,54 +249,6 @@ ReturnValue_t CcsdsIpCoreHandler::executeAction(ActionId_t actionId, MessageQueu return EXECUTION_FINISHED; } -void CcsdsIpCoreHandler::checkEvents() { - EventMessage event; - for (ReturnValue_t result = eventQueue->receiveMessage(&event); result == returnvalue::OK; - result = eventQueue->receiveMessage(&event)) { - switch (event.getMessageId()) { - case EventMessage::EVENT_MESSAGE: - handleEvent(&event); - break; - default: - sif::debug << "CcsdsHandler::checkEvents: Did not subscribe to this event message" - << std::endl; - break; - } - } -} - -void CcsdsIpCoreHandler::handleEvent(EventMessage* eventMessage) { - Event event = eventMessage->getEvent(); - switch (event) { - case PdecHandler::BIT_LOCK_PDEC: { - handleBitLockEvent(); - break; - } - case PdecHandler::CARRIER_LOCK: { - handleCarrierLockEvent(); - break; - } - default: - sif::debug << "CcsdsHandler::handleEvent: Did not subscribe to this event" << std::endl; - break; - } -} - -void CcsdsIpCoreHandler::handleBitLockEvent() { - if (transmitterCountdown.isBusy()) { - // Transmitter already enabled - return; - } - enableTransmit(); -} - -void CcsdsIpCoreHandler::handleCarrierLockEvent() { - if (!enableTxWhenCarrierLock) { - return; - } - enableTransmit(); -} - void CcsdsIpCoreHandler::forwardLinkstate() { VirtualChannelMapIter iter; for (iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) { @@ -342,27 +257,12 @@ void CcsdsIpCoreHandler::forwardLinkstate() { } void CcsdsIpCoreHandler::enableTransmit() { - if (transmitterCountdown.isBusy()) { - // Transmitter already enabled - return; - } #ifndef TE0720_1CFA gpioIF->pullHigh(enTxClock); gpioIF->pullHigh(enTxData); #endif linkState = UP; forwardLinkstate(); - transmitterCountdown.resetTimer(); -} - -void CcsdsIpCoreHandler::checkTxTimer() { - if (linkState == DOWN) { - return; - } - if (transmitterCountdown.hasTimedOut()) { - disableTransmit(); - //TODO: set mode to off (move timer to subsystem) - } } void CcsdsIpCoreHandler::getMode(Mode_t* mode, Submode_t* submode) { @@ -431,7 +331,6 @@ void CcsdsIpCoreHandler::disableTransmit() { #endif linkState = DOWN; forwardLinkstate(); - transmitterCountdown.timeOut(); } const char* CcsdsIpCoreHandler::getName() const { return "CCSDS Handler"; } diff --git a/mission/tmtc/CcsdsIpCoreHandler.h b/mission/tmtc/CcsdsIpCoreHandler.h index 37212851..356c2f8d 100644 --- a/mission/tmtc/CcsdsIpCoreHandler.h +++ b/mission/tmtc/CcsdsIpCoreHandler.h @@ -59,8 +59,7 @@ class CcsdsIpCoreHandler : public SystemObject, * @param enTxData GPIO ID of RS485 tx data enable */ CcsdsIpCoreHandler(object_id_t objectId, object_id_t ptmeId, object_id_t tcDestination, - PtmeConfig* ptmeConfig, GpioIF* gpioIF, gpioId_t enTxClock, gpioId_t enTxData, - uint32_t transmitterTimeout = 900000); + PtmeConfig* ptmeConfig, GpioIF* gpioIF, gpioId_t enTxClock, gpioId_t enTxData); ~CcsdsIpCoreHandler(); @@ -154,29 +153,16 @@ class CcsdsIpCoreHandler : public SystemObject, PtmeConfig* ptmeConfig = nullptr; GpioIF* gpioIF = nullptr; + // GPIO to enable RS485 transceiver for TX clock gpioId_t enTxClock = gpio::NO_GPIO; + // GPIO to enable RS485 transceiver for TX data signal gpioId_t enTxData = gpio::NO_GPIO; - // Syrlinks must not be transmitting more than 15 minutes (according to datasheet) - // Value initialized by constructor argument - const uint32_t transmitterTimeout = 0; - - // Countdown to disable transmitter after 15 minutes - Countdown transmitterCountdown; - - // When true transmitting is started as soon as carrier lock has been detected - bool enableTxWhenCarrierLock = false; - bool linkState = DOWN; void readCommandQueue(void); void handleTelemetry(); void handleTelecommands(); - void checkEvents(); - void handleEvent(EventMessage* eventMessage); - - void handleBitLockEvent(); - void handleCarrierLockEvent(); /** * @brief Forward link state to virtual channels. @@ -188,12 +174,6 @@ class CcsdsIpCoreHandler : public SystemObject, */ void enableTransmit(); - /** - * @brief Checks Tx timer for timeout and disables RS485 tx clock and tx data in case - * timer has expired. - */ - void checkTxTimer(); - /** * @brief Disables the transmitter by pulling the enable tx clock and tx data pin of the * RS485 transceiver chips to high. From c0f936b757272356d9c375ce40dd2e48dbbea257 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 2 Feb 2023 16:00:53 +0100 Subject: [PATCH 057/373] add parameter command to change the transmitter timeout --- mission/comDefs.h | 2 +- mission/system/objects/ComSubsystem.cpp | 10 ++++++++++ mission/system/objects/ComSubsystem.h | 7 +++---- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/mission/comDefs.h b/mission/comDefs.h index 5538b166..8bb3f329 100644 --- a/mission/comDefs.h +++ b/mission/comDefs.h @@ -24,7 +24,7 @@ enum class CcsdsSubmode : uint8_t { DATARATE_HIGH = 2, DATARATE_DEFAULT = 3 }; -enum class ParameterId : uint8_t { DATARATE = 0 }; +enum class ParameterId : uint8_t { DATARATE = 0, TRANSMITTER_TIMEOUT = 1 }; } // namespace com diff --git a/mission/system/objects/ComSubsystem.cpp b/mission/system/objects/ComSubsystem.cpp index 5c98dfd8..dc58a7a5 100644 --- a/mission/system/objects/ComSubsystem.cpp +++ b/mission/system/objects/ComSubsystem.cpp @@ -47,6 +47,16 @@ ReturnValue_t ComSubsystem::getParameter(uint8_t domainId, uint8_t uniqueIdentif com::setCurrentDatarate(static_cast(newVal)); return returnvalue::OK; } + else if ((domainId == 0) and (uniqueIdentifier == static_cast(com::ParameterId::TRANSMITTER_TIMEOUT))) { + uint8_t newVal = 0; + ReturnValue_t result = newValues->getElement(&newVal); + if (result != returnvalue::OK) { + return result; + } + parameterWrapper->set(transmitterTimeout); + transmitterTimeout = newVal; + return returnvalue::OK; + } return returnvalue::OK; } diff --git a/mission/system/objects/ComSubsystem.h b/mission/system/objects/ComSubsystem.h index 3f1ef5d2..ac8cc60f 100644 --- a/mission/system/objects/ComSubsystem.h +++ b/mission/system/objects/ComSubsystem.h @@ -47,16 +47,15 @@ class ComSubsystem : public Subsystem, public ReceivesParameterMessagesIF { void startRxAndTxDefaultSeq(); uint8_t datarateCfg = static_cast(com::Datarate::LOW_RATE_MODULATION_BPSK); + // Maximum time after which the transmitter will be turned of. This is a + // protection mechanism due prevent the syrlinks from overheating + uint32_t transmitterTimeout = 0; ParameterHelper paramHelper; MessageQueueIF* eventQueue = nullptr; bool enableTxWhenCarrierLock = false; - // Maximum time after which the transmitter will be turned of. This is a - // protection mechanism due prevent the syrlinks from overheating - uint32_t transmitterTimeout = 0; - // Countdown will be started as soon as the transmitter was enabled Countdown transmitterCountdown; }; From 3a69bc705ae27976d412ba36213426827ed8a067 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 2 Feb 2023 16:02:09 +0100 Subject: [PATCH 058/373] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index c633893d..a3a3aaa8 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit c633893df43030bb26b8422604b569bf8419d454 +Subproject commit a3a3aaa8836b425c923eb97e49ed29b452377bf6 From 305f8aa5613070bbf1f8c02ba2c57d9749587bac Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Fri, 3 Feb 2023 10:07:53 +0100 Subject: [PATCH 059/373] update transmitter countdown when parameter command is received --- mission/system/objects/ComSubsystem.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/mission/system/objects/ComSubsystem.cpp b/mission/system/objects/ComSubsystem.cpp index dc58a7a5..bbe14af0 100644 --- a/mission/system/objects/ComSubsystem.cpp +++ b/mission/system/objects/ComSubsystem.cpp @@ -55,6 +55,7 @@ ReturnValue_t ComSubsystem::getParameter(uint8_t domainId, uint8_t uniqueIdentif } parameterWrapper->set(transmitterTimeout); transmitterTimeout = newVal; + transmitterCountdown.setTimeout(transmitterTimeout); return returnvalue::OK; } return returnvalue::OK; From 650bfd1ad30c161ffc529dc369bb47ccecd061e0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 7 Feb 2023 12:19:13 +0100 Subject: [PATCH 060/373] continued basic tm store impl --- common/config/eive/eventSubsystemIds.h | 1 + fsfw | 2 +- mission/tmtc/PusTmFunnel.cpp | 10 +-- mission/tmtc/TmStore.cpp | 94 +++++++++++++++++++++++--- mission/tmtc/TmStore.h | 15 +++- 5 files changed, 105 insertions(+), 17 deletions(-) diff --git a/common/config/eive/eventSubsystemIds.h b/common/config/eive/eventSubsystemIds.h index 40926b00..1af60bf8 100644 --- a/common/config/eive/eventSubsystemIds.h +++ b/common/config/eive/eventSubsystemIds.h @@ -36,6 +36,7 @@ enum : uint8_t { SCEX_HANDLER = 138, CONFIGHANDLER = 139, CORE = 140, + PERSISTENT_TM_STORE = 141, COMMON_SUBSYSTEM_ID_END }; diff --git a/fsfw b/fsfw index 6af5274b..2646707d 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 6af5274b688c2eb561a17d78e5417e6b843e4523 +Subproject commit 2646707d3fa1b568a6c99e8e0bd32585d729d162 diff --git a/mission/tmtc/PusTmFunnel.cpp b/mission/tmtc/PusTmFunnel.cpp index f79ac9b2..7da02bca 100644 --- a/mission/tmtc/PusTmFunnel.cpp +++ b/mission/tmtc/PusTmFunnel.cpp @@ -14,11 +14,13 @@ PusTmFunnel::PusTmFunnel(object_id_t objectId, TimeReaderIF &timeReader, Storage : TmFunnelBase(objectId, tmStore, tmMsgDepth, tcMsgDepth, ipcStore), timeReader(timeReader), miscStore(objects::MISC_TM_STORE, "tm", "misc", RolloverInterval::HOURLY, 2, currentTv, - sdcMan), - okStore(objects::OK_TM_STORE, "tm", "ok", RolloverInterval::MINUTELY, 30, currentTv, sdcMan), + tmStore, sdcMan), + okStore(objects::OK_TM_STORE, "tm", "ok", RolloverInterval::MINUTELY, 30, currentTv, tmStore, + sdcMan), notOkStore(objects::NOT_OK_TM_STORE, "tm", "nok", RolloverInterval::MINUTELY, 30, currentTv, - sdcMan), - hkStore(objects::HK_TM_STORE, "tm", "hk", RolloverInterval::MINUTELY, 15, currentTv, sdcMan), + tmStore, sdcMan), + hkStore(objects::HK_TM_STORE, "tm", "hk", RolloverInterval::MINUTELY, 15, currentTv, tmStore, + sdcMan), sdcMan(sdcMan) { Clock::getClock_timeval(¤tTv); Clock::getUptime(&lastTvUpdate); diff --git a/mission/tmtc/TmStore.cpp b/mission/tmtc/TmStore.cpp index c20df4f3..11fe0443 100644 --- a/mission/tmtc/TmStore.cpp +++ b/mission/tmtc/TmStore.cpp @@ -12,12 +12,13 @@ using namespace returnvalue; TmStore::TmStore(object_id_t objectId, const char* baseDir, std::string baseName, RolloverInterval intervalUnit, uint32_t intervalCount, timeval& currentTv, - SdCardMountedIF& sdcMan) + StorageManagerIF& tmStore, SdCardMountedIF& sdcMan) : SystemObject(objectId), baseDir(std::move(baseDir)), baseName(std::move(baseName)), currentTv(currentTv), - sdcMan(sdcMan) { + sdcMan(sdcMan), + tmStore(tmStore) { calcDiffSeconds(intervalUnit, intervalCount); } @@ -182,18 +183,89 @@ void TmStore::addServiceSubservice(uint8_t service, uint8_t subservice) { filter.serviceSubservices.value().push_back({service, subservice}); } -void TmStore::deleteUpTo(uint32_t unixSeconds) {} +void TmStore::deleteUpTo(uint32_t unixSeconds) { + using namespace std::filesystem; + for (auto const& file : directory_iterator(basePath)) { + if (file.is_directory() or + (mostRecentFile.has_value() and (mostRecentFile.value() == file.path()))) { + continue; + } + Clock::TimeOfDay_t tod; + pathToTod(file.path(), tod); + timeval time; + ReturnValue_t result = Clock::convertTimeOfDayToTimeval(&tod, &time); + if (result != returnvalue::OK) { + sif::error << "TOD to time conversion failed for file " << file << std::endl; + continue; + } + if (time.tv_sec + rolloverDiffSeconds < unixSeconds) { + std::filesystem::remove(file.path()); + } + } +} void TmStore::dumpFromUpTo(uint32_t fromUnixSeconds, uint32_t upToUnixSeconds, TmFunnelBase& funnel) { - // TODO: - // 1. Find all files within the specified range - // 2. For each file, dump content into buffer, parse out space packets, - // 3. Store each packet into the TM store and send the message to all - // destinations + using namespace std::filesystem; + for (auto const& file : directory_iterator(basePath)) { + if (file.is_directory() or + (mostRecentFile.has_value() and (mostRecentFile.value() == file.path()))) { + continue; + } + Clock::TimeOfDay_t tod; + pathToTod(file.path(), tod); + timeval time; + ReturnValue_t result = Clock::convertTimeOfDayToTimeval(&tod, &time); + if (result != returnvalue::OK) { + sif::error << "TOD to time conversion failed for file " << file << std::endl; + continue; + } + uint32_t timeUnsigned = static_cast(time.tv_sec); + if (timeUnsigned > fromUnixSeconds && timeUnsigned + rolloverDiffSeconds < upToUnixSeconds) { + fileToPackets(file, timeUnsigned, funnel); + } + } +} + +void TmStore::pathToTod(const std::filesystem::path& path, Clock::TimeOfDay_t& tod) { + auto pathStr = path.string(); + size_t splitChar = pathStr.find("_"); + auto timeOnlyStr = pathStr.substr(splitChar); + sscanf(timeOnlyStr.data(), + "%04" SCNu32 "-%02" SCNu32 "-%02" SCNu32 "T%02" SCNu32 "-%02" SCNu32 "-%02" SCNu32 "Z", + &tod.year, &tod.month, &tod.day, &tod.hour, &tod.minute, &tod.second); +} + +void TmStore::fileToPackets(const std::filesystem::path& path, uint32_t unixStamp, + TmFunnelBase& funnel) { store_address_t storeId; TmTcMessage message; - const uint8_t* packetData = nullptr; - size_t size = 0; - funnel.sendPacketToDestinations(storeId, message, packetData, size); + size_t size = std::filesystem::file_size(path); + if (size < 6) { + // Can't even read the CCSDS header + return; + } + std::ifstream ifile(path, std::ios::binary); + ifile.read(reinterpret_cast(fileBuf.data()), size); + size_t currentIdx = 0; + while (currentIdx < size) { + PusTmReader reader(&timeReader, fileBuf.data(), fileBuf.size()); + // CRC check to fully ensure this is a valid TM + ReturnValue_t result = reader.parseDataWithCrcCheck(); + if (result == returnvalue::OK) { + ReturnValue_t result = + tmStore.addData(&storeId, fileBuf.data() + currentIdx, reader.getFullPacketLen()); + if (result != returnvalue::OK) { + continue; + } + funnel.sendPacketToDestinations(storeId, message, fileBuf.data() + currentIdx, + reader.getFullPacketLen()); + currentIdx += reader.getFullPacketLen(); + } else { + sif::error << "Parsing of PUS TM failed with code " << result << std::endl; + triggerEvent(POSSIBLE_FILE_CORRUPTION, result, unixStamp); + // Stop for now, do not really know where to continue and we do not trust the file anymore. + break; + } + } } diff --git a/mission/tmtc/TmStore.h b/mission/tmtc/TmStore.h index 0654052d..91acb3a1 100644 --- a/mission/tmtc/TmStore.h +++ b/mission/tmtc/TmStore.h @@ -2,6 +2,7 @@ #define MISSION_TMTC_TMSTOREBACKEND_H_ #include +#include #include #include #include @@ -10,6 +11,7 @@ #include #include "TmFunnelBase.h" +#include "eive/eventSubsystemIds.h" struct PacketFilter { std::optional> apid; @@ -21,9 +23,16 @@ enum class RolloverInterval { MINUTELY, HOURLY, DAILY }; class TmStore : public SystemObject { public: + static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PERSISTENT_TM_STORE; + + //! [EXPORT] : [COMMENT] + //! P1: Result code of TM packet parser. + //! P2: Timestamp of possibly corrupt file as a unix timestamp. + static constexpr Event POSSIBLE_FILE_CORRUPTION = + event::makeEvent(SUBSYSTEM_ID, 0, severity::LOW); TmStore(object_id_t objectId, const char* baseDir, std::string baseName, RolloverInterval intervalUnit, uint32_t intervalCount, timeval& currentTv, - SdCardMountedIF& sdcMan); + StorageManagerIF& tmStore, SdCardMountedIF& sdcMan); void addApid(uint16_t apid); void addService(uint8_t service); @@ -44,6 +53,7 @@ class TmStore : public SystemObject { */ MessageQueueId_t getCommandQueue(); PacketFilter filter; + CdsShortTimeStamper timeReader; bool baseDirUninitialized = true; const char* baseDir; std::string baseName; @@ -54,9 +64,12 @@ class TmStore : public SystemObject { std::optional mostRecentTv; std::optional mostRecentFile; SdCardMountedIF& sdcMan; + StorageManagerIF& tmStore; void calcDiffSeconds(RolloverInterval intervalUnit, uint32_t intervalCount); void assignAndOrCreateMostRecentFile(); + void pathToTod(const std::filesystem::path& path, Clock::TimeOfDay_t& tod); + void fileToPackets(const std::filesystem::path& path, uint32_t unixStamp, TmFunnelBase& funnel); ReturnValue_t storePacket(PusTmReader& reader); }; From 94fee2d42941d9d0f548769d09e8da614adc3e3c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 7 Feb 2023 12:23:00 +0100 Subject: [PATCH 061/373] some more fixes and tweaks --- fsfw | 2 +- mission/tmtc/CMakeLists.txt | 2 +- mission/tmtc/{TmStore.cpp => PersistentTmStore.cpp} | 2 +- mission/tmtc/{TmStore.h => PersistentTmStore.h} | 0 mission/tmtc/PusTmFunnel.h | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) rename mission/tmtc/{TmStore.cpp => PersistentTmStore.cpp} (99%) rename mission/tmtc/{TmStore.h => PersistentTmStore.h} (100%) diff --git a/fsfw b/fsfw index 2646707d..a1567de9 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 2646707d3fa1b568a6c99e8e0bd32585d729d162 +Subproject commit a1567de9e8d84a044b4a33ccdaffd15f0f4f54f1 diff --git a/mission/tmtc/CMakeLists.txt b/mission/tmtc/CMakeLists.txt index cc84aabb..c4c93ab6 100644 --- a/mission/tmtc/CMakeLists.txt +++ b/mission/tmtc/CMakeLists.txt @@ -6,5 +6,5 @@ target_sources( TmFunnelBase.cpp CfdpTmFunnel.cpp Service15TmStorage.cpp - TmStore.cpp + PersistentTmStore.cpp PusTmFunnel.cpp) diff --git a/mission/tmtc/TmStore.cpp b/mission/tmtc/PersistentTmStore.cpp similarity index 99% rename from mission/tmtc/TmStore.cpp rename to mission/tmtc/PersistentTmStore.cpp index 11fe0443..d1bf054e 100644 --- a/mission/tmtc/TmStore.cpp +++ b/mission/tmtc/PersistentTmStore.cpp @@ -1,4 +1,4 @@ -#include "TmStore.h" +#include "PersistentTmStore.h" #include diff --git a/mission/tmtc/TmStore.h b/mission/tmtc/PersistentTmStore.h similarity index 100% rename from mission/tmtc/TmStore.h rename to mission/tmtc/PersistentTmStore.h diff --git a/mission/tmtc/PusTmFunnel.h b/mission/tmtc/PusTmFunnel.h index 464db37c..e47f5e96 100644 --- a/mission/tmtc/PusTmFunnel.h +++ b/mission/tmtc/PusTmFunnel.h @@ -10,7 +10,7 @@ #include -#include "TmStore.h" +#include "PersistentTmStore.h" #include "fsfw/timemanager/TimeReaderIF.h" /** From d82810d5e7aad212dd90181aa03782dd006d714d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 7 Feb 2023 15:22:01 +0100 Subject: [PATCH 062/373] add dumpFrom method --- mission/tmtc/PersistentTmStore.cpp | 12 ++++++++++-- mission/tmtc/PersistentTmStore.h | 1 + tmtc | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/mission/tmtc/PersistentTmStore.cpp b/mission/tmtc/PersistentTmStore.cpp index d1bf054e..8b0c4ee4 100644 --- a/mission/tmtc/PersistentTmStore.cpp +++ b/mission/tmtc/PersistentTmStore.cpp @@ -57,6 +57,10 @@ ReturnValue_t TmStore::passPacket(PusTmReader& reader) { return returnvalue::OK; } +void TmStore::dumpFrom(uint32_t fromUnixSeconds, TmFunnelBase &tmFunnel) { + return dumpFromUpTo(fromUnixSeconds, currentTv.tv_sec, tmFunnel); +} + ReturnValue_t TmStore::storePacket(PusTmReader& reader) { using namespace std::filesystem; if (baseDirUninitialized) { @@ -208,8 +212,12 @@ void TmStore::dumpFromUpTo(uint32_t fromUnixSeconds, uint32_t upToUnixSeconds, TmFunnelBase& funnel) { using namespace std::filesystem; for (auto const& file : directory_iterator(basePath)) { - if (file.is_directory() or - (mostRecentFile.has_value() and (mostRecentFile.value() == file.path()))) { + if (file.is_directory()) { + continue; + } + if (mostRecentFile.has_value() and mostRecentTv.has_value() and + (file.path() == mostRecentFile.value()) and + (upToUnixSeconds < static_cast(mostRecentTv.value().tv_sec))) { continue; } Clock::TimeOfDay_t tod; diff --git a/mission/tmtc/PersistentTmStore.h b/mission/tmtc/PersistentTmStore.h index 91acb3a1..8575f35f 100644 --- a/mission/tmtc/PersistentTmStore.h +++ b/mission/tmtc/PersistentTmStore.h @@ -39,6 +39,7 @@ class TmStore : public SystemObject { void addServiceSubservice(uint8_t service, uint8_t subservice); void deleteUpTo(uint32_t unixSeconds); + void dumpFrom(uint32_t fromUnixSeconds, TmFunnelBase& tmFunnel); void dumpFromUpTo(uint32_t fromUnixSeconds, uint32_t upToUnixSeconds, TmFunnelBase& tmFunnel); void updateBaseDir(); diff --git a/tmtc b/tmtc index d6445d38..2bd6caa3 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit d6445d38a8eb644a5e1bd27f0fc56d29e93c030d +Subproject commit 2bd6caa3c21255f2ab5a2773eb83d2fca78c2234 From 3159574cfabd616150b4e3070f2b50635edafae8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 8 Feb 2023 21:41:19 +0100 Subject: [PATCH 063/373] resolve more merge conflicts --- mission/controller/ThermalController.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index b84f07d6..c2fc8cde 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -110,7 +110,6 @@ void ThermalController::performControlOperation() { deviceTemperatures.commit(); } -<<<<<<< HEAD { PoolReadGuard pg(&heaterInfo); if (pg.getReadResult() == returnvalue::OK) { @@ -122,7 +121,7 @@ void ThermalController::performControlOperation() { } } } -======= + ctrlCameraBody(); ctrlAcsBoard(); ctrlMgt(); @@ -147,7 +146,6 @@ void ThermalController::performControlOperation() { ctrlTx(); ctrlMpa(); ctrlScexBoard(); ->>>>>>> origin/develop } ReturnValue_t ThermalController::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, From 5a5d00e4e50bf81bcb2932386850724bad31e966 Mon Sep 17 00:00:00 2001 From: meggert Date: Thu, 9 Feb 2023 17:11:23 +0100 Subject: [PATCH 064/373] dataPool for setting RW speeds --- mission/devices/RwHandler.cpp | 2 + mission/devices/RwHandler.h | 2 + .../devices/devicedefinitions/RwDefinitions.h | 54 +++++++++++++++---- 3 files changed, 47 insertions(+), 11 deletions(-) diff --git a/mission/devices/RwHandler.cpp b/mission/devices/RwHandler.cpp index 732bb9fe..d859f9d0 100644 --- a/mission/devices/RwHandler.cpp +++ b/mission/devices/RwHandler.cpp @@ -243,6 +243,8 @@ uint32_t RwHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { retur ReturnValue_t RwHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) { + localDataPoolMap.emplace(RwDefinitions::RW_SPEED, &rwSpeed); + localDataPoolMap.emplace(RwDefinitions::TEMPERATURE_C, new PoolEntry({0})); localDataPoolMap.emplace(RwDefinitions::CURR_SPEED, new PoolEntry({0})); diff --git a/mission/devices/RwHandler.h b/mission/devices/RwHandler.h index f9f66bd5..43deb579 100644 --- a/mission/devices/RwHandler.h +++ b/mission/devices/RwHandler.h @@ -96,6 +96,8 @@ class RwHandler : public DeviceHandlerBase { uint8_t commandBuffer[RwDefinitions::MAX_CMD_SIZE]; + PoolEntry rwSpeed = PoolEntry(0, false); + enum class InternalState { GET_RESET_STATUS, CLEAR_RESET_STATUS, READ_TEMPERATURE, GET_RW_SATUS }; InternalState internalState = InternalState::GET_RESET_STATUS; diff --git a/mission/devices/devicedefinitions/RwDefinitions.h b/mission/devices/devicedefinitions/RwDefinitions.h index 2923b41b..4016b23c 100644 --- a/mission/devices/devicedefinitions/RwDefinitions.h +++ b/mission/devices/devicedefinitions/RwDefinitions.h @@ -51,7 +51,9 @@ enum PoolIds : lp_id_t { SPI_BYTES_WRITTEN, SPI_BYTES_READ, SPI_REG_OVERRUN_ERRORS, - SPI_TOTAL_ERRORS + SPI_TOTAL_ERRORS, + + RW_SPEED, }; enum States : uint8_t { STATE_ERROR, IDLE, COASTING, RUNNING_SPEED_STABLE, RUNNING_SPEED_CHANGING }; @@ -75,10 +77,13 @@ static const DeviceCommandId_t SET_SPEED = 6; static const DeviceCommandId_t GET_TEMPERATURE = 8; static const DeviceCommandId_t GET_TM = 9; -static const uint32_t TEMPERATURE_SET_ID = GET_TEMPERATURE; -static const uint32_t STATUS_SET_ID = GET_RW_STATUS; -static const uint32_t LAST_RESET_ID = GET_LAST_RESET_STATUS; -static const uint32_t TM_SET_ID = GET_TM; +enum SetIds : uint32_t { + TEMPERATURE_SET_ID = GET_TEMPERATURE, + STATUS_SET_ID = GET_RW_STATUS, + LAST_RESET_ID = GET_LAST_RESET_STATUS, + TM_SET_ID = GET_TM, + RW_SPEED = 10, +}; static const size_t SIZE_GET_RESET_STATUS = 5; static const size_t SIZE_CLEAR_RESET_STATUS = 4; @@ -106,9 +111,11 @@ static const uint8_t TM_SET_ENTRIES = 24; */ class StatusSet : public StaticLocalDataSet { public: - StatusSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, STATUS_SET_ID) {} + StatusSet(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, RwDefinitions::SetIds::STATUS_SET_ID) {} - StatusSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, STATUS_SET_ID)) {} + StatusSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, RwDefinitions::SetIds::STATUS_SET_ID)) {} lp_var_t temperatureCelcius = lp_var_t(sid.objectId, PoolIds::TEMPERATURE_C, this); @@ -124,9 +131,11 @@ class StatusSet : public StaticLocalDataSet { */ class LastResetSatus : public StaticLocalDataSet { public: - LastResetSatus(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, LAST_RESET_ID) {} + LastResetSatus(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, RwDefinitions::SetIds::LAST_RESET_ID) {} - LastResetSatus(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, LAST_RESET_ID)) {} + LastResetSatus(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, RwDefinitions::SetIds::LAST_RESET_ID)) {} // If a reset occurs, the status code will be cached into this variable lp_var_t lastNonClearedResetStatus = @@ -143,9 +152,11 @@ class LastResetSatus : public StaticLocalDataSet { */ class TmDataset : public StaticLocalDataSet { public: - TmDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TM_SET_ID) {} + TmDataset(HasLocalDataPoolIF* owner) + : StaticLocalDataSet(owner, RwDefinitions::SetIds::TM_SET_ID) {} - TmDataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TM_SET_ID)) {} + TmDataset(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, RwDefinitions::SetIds::TM_SET_ID)) {} lp_var_t lastResetStatus = lp_var_t(sid.objectId, PoolIds::TM_LAST_RESET_STATUS, this); @@ -192,6 +203,27 @@ class TmDataset : public StaticLocalDataSet { lp_var_t(sid.objectId, PoolIds::SPI_TOTAL_ERRORS, this); }; +class RwSpeedActuationSet : StaticLocalDataSet<4> { + friend class ::RwHandler; + + public: + RwSpeedActuationSet(HasLocalDataPoolIF& owner) + : StaticLocalDataSet(&owner, RwDefinitions::SetIds::RW_SPEED) {} + RwSpeedActuationSet(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, RwDefinitions::SetIds::RW_SPEED)) {} + + void setRwSpeed(int32_t rwSpeed_) { + if (rwSpeed.value != rwSpeed_) { + } + rwSpeed = rwSpeed_; + } + + void getRwSpeed(int32_t& rwSpeed_) { rwSpeed_ = rwSpeed.value; } + + private: + lp_var_t rwSpeed = lp_var_t(sid.objectId, RW_SPEED, this); +}; + } // namespace RwDefinitions #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_RWDEFINITIONS_H_ */ From a3eaace4a55504e3a6dc13b933031e3e1b13963b Mon Sep 17 00:00:00 2001 From: meggert Date: Thu, 9 Feb 2023 17:31:26 +0100 Subject: [PATCH 065/373] added RwSpeedActuationSets to AcsController --- mission/controller/AcsController.cpp | 51 ++++++++++++++++++++++++++-- mission/controller/AcsController.h | 8 ++++- 2 files changed, 56 insertions(+), 3 deletions(-) diff --git a/mission/controller/AcsController.cpp b/mission/controller/AcsController.cpp index 1b4f54a9..bee21d71 100644 --- a/mission/controller/AcsController.cpp +++ b/mission/controller/AcsController.cpp @@ -189,8 +189,23 @@ void AcsController::performSafe() { // PoolReadGuard pg(&dipoleSet); // MutexGuard mg(torquer::lazyLock()); // torquer::NEW_ACTUATION_FLAG = true; - // dipoleSet.setDipoles(cmdDipolUnits[0], cmdDipolUnits[1], cmdDipolUnits[2], - // torqueDuration); + // dipoleSet.setDipoles(dipolCmdUnits[0], dipolCmdUnits[1], dipolCmdUnits[2], 0); + // } + // { + // PoolReadGuard pg(&rw1SpeedSet); + // rw1SpeedSet.setRwSpeed(0); + // } + // { + // PoolReadGuard pg(&rw2SpeedSet); + // rw2SpeedSet.setRwSpeed(0); + // } + // { + // PoolReadGuard pg(&rw3SpeedSet); + // rw3SpeedSet.setRwSpeed(0); + // } + // { + // PoolReadGuard pg(&rw4SpeedSet); + // rw4SpeedSet.setRwSpeed(0); // } } @@ -251,6 +266,22 @@ void AcsController::performDetumble() { // dipoleSet.setDipoles(cmdDipolUnitsInt[0], cmdDipolUnitsInt[1], cmdDipolUnitsInt[2], // torqueDuration); // } + // { + // PoolReadGuard pg(&rw1SpeedSet); + // rw1SpeedSet.setRwSpeed(0); + // } + // { + // PoolReadGuard pg(&rw2SpeedSet); + // rw2SpeedSet.setRwSpeed(0); + // } + // { + // PoolReadGuard pg(&rw3SpeedSet); + // rw3SpeedSet.setRwSpeed(0); + // } + // { + // PoolReadGuard pg(&rw4SpeedSet); + // rw4SpeedSet.setRwSpeed(0); + // } } void AcsController::performPointingCtrl() { @@ -431,6 +462,22 @@ void AcsController::performPointingCtrl() { // dipoleSet.setDipoles(cmdDipolUnitsInt[0], cmdDipolUnitsInt[1], cmdDipolUnitsInt[2], // torqueDuration); // } + // { + // PoolReadGuard pg(&rw1SpeedSet); + // rw1SpeedSet.setRwSpeed(cmdRwSpeedInt[0]); + // } + // { + // PoolReadGuard pg(&rw2SpeedSet); + // rw2SpeedSet.setRwSpeed(cmdRwSpeedInt[1]); + // } + // { + // PoolReadGuard pg(&rw3SpeedSet); + // rw3SpeedSet.setRwSpeed(cmdRwSpeedInt[2]); + // } + // { + // PoolReadGuard pg(&rw4SpeedSet); + // rw4SpeedSet.setRwSpeed(cmdRwSpeedInt[3]); + // } } ReturnValue_t AcsController::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, diff --git a/mission/controller/AcsController.h b/mission/controller/AcsController.h index 1e017099..d427bd5b 100644 --- a/mission/controller/AcsController.h +++ b/mission/controller/AcsController.h @@ -17,6 +17,7 @@ #include "eive/objects.h" #include "fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h" #include "fsfw_hal/devicehandlers/MgmRM3100Handler.h" +#include "mission/devices/devicedefinitions/RwDefinitions.h" #include "mission/devices/devicedefinitions/SusDefinitions.h" #include "mission/devices/devicedefinitions/imtqHandlerDefinitions.h" @@ -72,8 +73,13 @@ class AcsController : public ExtendedControllerBase, public ReceivesParameterMes /* ACS Sensor Values */ ACS::SensorValues sensorValues; - /* ACS Datasets */ + /* ACS Actuation Datasets */ IMTQ::DipoleActuationSet dipoleSet = IMTQ::DipoleActuationSet(objects::IMTQ_HANDLER); + RwDefinitions::RwSpeedActuationSet rw1SpeedSet = RwDefinitions::RwSpeedActuationSet(objects::RW1); + RwDefinitions::RwSpeedActuationSet rw2SpeedSet = RwDefinitions::RwSpeedActuationSet(objects::RW2); + RwDefinitions::RwSpeedActuationSet rw3SpeedSet = RwDefinitions::RwSpeedActuationSet(objects::RW3); + RwDefinitions::RwSpeedActuationSet rw4SpeedSet = RwDefinitions::RwSpeedActuationSet(objects::RW4); + /* ACS Datasets */ // MGMs acsctrl::MgmDataRaw mgmDataRaw; PoolEntry mgm0VecRaw = PoolEntry(3); From 51629da4a068e1aad1364692a339048e64accc49 Mon Sep 17 00:00:00 2001 From: meggert Date: Thu, 9 Feb 2023 17:55:20 +0100 Subject: [PATCH 066/373] naming fixes --- mission/devices/devicedefinitions/RwDefinitions.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mission/devices/devicedefinitions/RwDefinitions.h b/mission/devices/devicedefinitions/RwDefinitions.h index 4016b23c..a4e8e96d 100644 --- a/mission/devices/devicedefinitions/RwDefinitions.h +++ b/mission/devices/devicedefinitions/RwDefinitions.h @@ -82,7 +82,7 @@ enum SetIds : uint32_t { STATUS_SET_ID = GET_RW_STATUS, LAST_RESET_ID = GET_LAST_RESET_STATUS, TM_SET_ID = GET_TM, - RW_SPEED = 10, + SPEED_CMD_SET = 10, }; static const size_t SIZE_GET_RESET_STATUS = 5; @@ -204,13 +204,13 @@ class TmDataset : public StaticLocalDataSet { }; class RwSpeedActuationSet : StaticLocalDataSet<4> { - friend class ::RwHandler; + friend class RwHandler; public: RwSpeedActuationSet(HasLocalDataPoolIF& owner) - : StaticLocalDataSet(&owner, RwDefinitions::SetIds::RW_SPEED) {} + : StaticLocalDataSet(&owner, RwDefinitions::SetIds::SPEED_CMD_SET) {} RwSpeedActuationSet(object_id_t objectId) - : StaticLocalDataSet(sid_t(objectId, RwDefinitions::SetIds::RW_SPEED)) {} + : StaticLocalDataSet(sid_t(objectId, RwDefinitions::SetIds::SPEED_CMD_SET)) {} void setRwSpeed(int32_t rwSpeed_) { if (rwSpeed.value != rwSpeed_) { @@ -221,7 +221,8 @@ class RwSpeedActuationSet : StaticLocalDataSet<4> { void getRwSpeed(int32_t& rwSpeed_) { rwSpeed_ = rwSpeed.value; } private: - lp_var_t rwSpeed = lp_var_t(sid.objectId, RW_SPEED, this); + lp_var_t rwSpeed = + lp_var_t(sid.objectId, RwDefinitions::PoolIds::RW_SPEED, this); }; } // namespace RwDefinitions From 9dfd8491d26aee8b619818c3883da58e104afdb6 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 10 Feb 2023 10:25:13 +0100 Subject: [PATCH 067/373] added rampTime and torqueDuration to AcsParameters --- mission/controller/acs/AcsParameters.cpp | 5 +++++ mission/controller/acs/AcsParameters.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/mission/controller/acs/AcsParameters.cpp b/mission/controller/acs/AcsParameters.cpp index 13642fe9..30264963 100644 --- a/mission/controller/acs/AcsParameters.cpp +++ b/mission/controller/acs/AcsParameters.cpp @@ -278,6 +278,8 @@ ReturnValue_t AcsParameters::getParameter(uint8_t domainId, uint8_t parameterId, case 0x4: parameterWrapper->set(rwHandlingParameters.stictionTorque); break; + case 0x5: + parameterWrapper->set(rwHandlingParameters.rampTime); default: return INVALID_IDENTIFIER_ID; } @@ -584,6 +586,9 @@ ReturnValue_t AcsParameters::getParameter(uint8_t domainId, uint8_t parameterId, case 0x5: parameterWrapper->set(magnetorquesParameter.DipolMax); break; + case 0x6: + parameterWrapper->set(magnetorquesParameter.torqueDuration); + break; default: return INVALID_IDENTIFIER_ID; } diff --git a/mission/controller/acs/AcsParameters.h b/mission/controller/acs/AcsParameters.h index f1c0fb63..35e316f1 100644 --- a/mission/controller/acs/AcsParameters.h +++ b/mission/controller/acs/AcsParameters.h @@ -792,6 +792,8 @@ class AcsParameters : public HasParametersIF { double stictionSpeed = 100; // 80; // RPM double stictionReleaseSpeed = 120; // RPM double stictionTorque = 0.0006; + + uint16_t rampTime = 10; } rwHandlingParameters; struct RwMatrices { @@ -910,6 +912,7 @@ class AcsParameters : public HasParametersIF { double inverseAlignment[3][3] = {{0, -1, 0}, {0, 0, 1}, {-1, 0, 0}}; double DipolMax = 0.2; // [Am^2] + uint16_t torqueDuration = 300; // [ms] } magnetorquesParameter; struct DetumbleParameter { From 9041a3376c18cae282a1afcfbcd39c3ef3b09c47 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 10 Feb 2023 10:56:50 +0100 Subject: [PATCH 068/373] ActuatorCmd now output their solutions as integers as expected by the sensors --- mission/controller/acs/ActuatorCmd.cpp | 27 +++++++++++++++++--------- mission/controller/acs/ActuatorCmd.h | 6 +++--- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/mission/controller/acs/ActuatorCmd.cpp b/mission/controller/acs/ActuatorCmd.cpp index 4e0052e0..cbe24e5b 100644 --- a/mission/controller/acs/ActuatorCmd.cpp +++ b/mission/controller/acs/ActuatorCmd.cpp @@ -38,27 +38,32 @@ void ActuatorCmd::scalingTorqueRws(const double *rwTrq, double *rwTrqScaled) { } } -void ActuatorCmd::cmdSpeedToRws(const int32_t *speedRw0, const int32_t *speedRw1, - const int32_t *speedRw2, const int32_t *speedRw3, - const double *rwTorque, double *rwCmdSpeed) { +void ActuatorCmd::cmdSpeedToRws(const int32_t speedRw0, const int32_t speedRw1, + const int32_t speedRw2, const int32_t speedRw3, + const double *rwTorque, int32_t *rwCmdSpeed) { using namespace Math; // Calculating the commanded speed in RPM for every reaction wheel - double speedRws[4] = {(double)*speedRw0, (double)*speedRw1, (double)*speedRw2, (double)*speedRw3}; + int32_t speedRws[4] = {speedRw0, speedRw1, speedRw2, speedRw3}; double deltaSpeed[4] = {0, 0, 0, 0}; double commandTime = acsParameters.onBoardParams.sampleTime, inertiaWheel = acsParameters.rwHandlingParameters.inertiaWheel; double radToRpm = 60 / (2 * PI); // factor for conversion to RPM // W_RW = Torque_RW / I_RW * delta t [rad/s] double factor = commandTime / inertiaWheel * radToRpm; + int32_t deltaSpeedInt[4] = {0, 0, 0, 0}; VectorOperations::mulScalar(rwTorque, factor, deltaSpeed, 4); - VectorOperations::add(speedRws, deltaSpeed, rwCmdSpeed, 4); + for (int i = 0; i < 4; i++) { + deltaSpeedInt[i] = std::round(deltaSpeed[i]); + } + VectorOperations::add(speedRws, deltaSpeedInt, rwCmdSpeed, 4); } -void ActuatorCmd::cmdDipolMtq(const double *dipolMoment, double *dipolMomentActuator) { +void ActuatorCmd::cmdDipolMtq(const double *dipolMoment, int16_t *dipolMomentActuator) { // Convert to actuator frame + double dipolMomentActuatorDouble[3] = {0, 0, 0}; MatrixOperations::multiply(*acsParameters.magnetorquesParameter.inverseAlignment, - dipolMoment, dipolMomentActuator, 3, 3, 1); + dipolMoment, dipolMomentActuatorDouble, 3, 3, 1); // Scaling along largest element if dipol exceeds maximum double maxDipol = acsParameters.magnetorquesParameter.DipolMax; double maxValue = 0; @@ -69,8 +74,12 @@ void ActuatorCmd::cmdDipolMtq(const double *dipolMoment, double *dipolMomentActu } if (maxValue > maxDipol) { double scalingFactor = maxDipol / maxValue; - VectorOperations::mulScalar(dipolMomentActuator, scalingFactor, dipolMomentActuator, 3); + VectorOperations::mulScalar(dipolMomentActuatorDouble, scalingFactor, + dipolMomentActuatorDouble, 3); } // scale dipole from 1 Am^2 to 1e^-4 Am^2 - VectorOperations::mulScalar(dipolMomentActuator, 1e4, dipolMomentActuator, 3); + VectorOperations::mulScalar(dipolMomentActuatorDouble, 1e4, dipolMomentActuatorDouble, 3); + for (int i = 0; i < 3; i++) { + dipolMomentActuator[i] = std::round(dipolMomentActuatorDouble[i]); + } } diff --git a/mission/controller/acs/ActuatorCmd.h b/mission/controller/acs/ActuatorCmd.h index 04e2b61f..969bd782 100644 --- a/mission/controller/acs/ActuatorCmd.h +++ b/mission/controller/acs/ActuatorCmd.h @@ -28,8 +28,8 @@ class ActuatorCmd { * rwCmdSpeed output revolutions per minute for every * reaction wheel */ - void cmdSpeedToRws(const int32_t *speedRw0, const int32_t *speedRw1, const int32_t *speedRw2, - const int32_t *speedRw3, const double *rwTorque, double *rwCmdSpeed); + void cmdSpeedToRws(const int32_t speedRw0, const int32_t speedRw1, const int32_t speedRw2, + const int32_t speedRw3, const double *rwTorque, int32_t *rwCmdSpeed); /* * @brief: cmdDipolMtq() gives the commanded dipol moment for the magnetorques @@ -37,7 +37,7 @@ class ActuatorCmd { * @param: dipolMoment given dipol moment in spacecraft frame * dipolMomentActuator resulting dipol moment in actuator reference frame */ - void cmdDipolMtq(const double *dipolMoment, double *dipolMomentActuator); + void cmdDipolMtq(const double *dipolMoment, int16_t *dipolMomentActuator); protected: private: From c2079dcbbad994877c3dc3a638c25ea325699f0d Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 10 Feb 2023 11:26:46 +0100 Subject: [PATCH 069/373] added rampTime and made dataSet public --- .../devices/devicedefinitions/RwDefinitions.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/mission/devices/devicedefinitions/RwDefinitions.h b/mission/devices/devicedefinitions/RwDefinitions.h index a4e8e96d..b3cb0fe4 100644 --- a/mission/devices/devicedefinitions/RwDefinitions.h +++ b/mission/devices/devicedefinitions/RwDefinitions.h @@ -54,6 +54,7 @@ enum PoolIds : lp_id_t { SPI_TOTAL_ERRORS, RW_SPEED, + RAMP_TIME, }; enum States : uint8_t { STATE_ERROR, IDLE, COASTING, RUNNING_SPEED_STABLE, RUNNING_SPEED_CHANGING }; @@ -203,7 +204,7 @@ class TmDataset : public StaticLocalDataSet { lp_var_t(sid.objectId, PoolIds::SPI_TOTAL_ERRORS, this); }; -class RwSpeedActuationSet : StaticLocalDataSet<4> { +class RwSpeedActuationSet : public StaticLocalDataSet<2> { friend class RwHandler; public: @@ -212,17 +213,25 @@ class RwSpeedActuationSet : StaticLocalDataSet<4> { RwSpeedActuationSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, RwDefinitions::SetIds::SPEED_CMD_SET)) {} - void setRwSpeed(int32_t rwSpeed_) { + void setRwSpeed(int32_t rwSpeed_, uint16_t rampTime_) { if (rwSpeed.value != rwSpeed_) { + rwSpeed = rwSpeed_; + } + if (rampTime.value != rampTime_) { + rampTime = rampTime_; } - rwSpeed = rwSpeed_; } - void getRwSpeed(int32_t& rwSpeed_) { rwSpeed_ = rwSpeed.value; } + void getRwSpeed(int32_t& rwSpeed_, uint16_t& rampTime_) { + rwSpeed_ = rwSpeed.value; + rampTime_ = rampTime.value; + } private: lp_var_t rwSpeed = lp_var_t(sid.objectId, RwDefinitions::PoolIds::RW_SPEED, this); + lp_var_t rampTime = + lp_var_t(sid.objectId, RwDefinitions::PoolIds::RAMP_TIME, this); }; } // namespace RwDefinitions From 01d6060111ee96cedc8e40e3368aae3414a38562 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 10 Feb 2023 11:27:02 +0100 Subject: [PATCH 070/373] added ramp time --- mission/devices/RwHandler.cpp | 1 + mission/devices/RwHandler.h | 1 + 2 files changed, 2 insertions(+) diff --git a/mission/devices/RwHandler.cpp b/mission/devices/RwHandler.cpp index d859f9d0..e9383c4a 100644 --- a/mission/devices/RwHandler.cpp +++ b/mission/devices/RwHandler.cpp @@ -244,6 +244,7 @@ uint32_t RwHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { retur ReturnValue_t RwHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) { localDataPoolMap.emplace(RwDefinitions::RW_SPEED, &rwSpeed); + localDataPoolMap.emplace(RwDefinitions::RAMP_TIME, &rampTime); localDataPoolMap.emplace(RwDefinitions::TEMPERATURE_C, new PoolEntry({0})); diff --git a/mission/devices/RwHandler.h b/mission/devices/RwHandler.h index 43deb579..17f2b396 100644 --- a/mission/devices/RwHandler.h +++ b/mission/devices/RwHandler.h @@ -97,6 +97,7 @@ class RwHandler : public DeviceHandlerBase { uint8_t commandBuffer[RwDefinitions::MAX_CMD_SIZE]; PoolEntry rwSpeed = PoolEntry(0, false); + PoolEntry rampTime = PoolEntry(10, false); enum class InternalState { GET_RESET_STATUS, CLEAR_RESET_STATUS, READ_TEMPERATURE, GET_RW_SATUS }; From ea32d87c25955912be952335696348cb003b659a Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 10 Feb 2023 11:27:25 +0100 Subject: [PATCH 071/373] function now handles actuator cmd --- mission/controller/AcsController.cpp | 163 ++++++++++----------------- mission/controller/AcsController.h | 4 + 2 files changed, 66 insertions(+), 101 deletions(-) diff --git a/mission/controller/AcsController.cpp b/mission/controller/AcsController.cpp index bee21d71..29bd06b6 100644 --- a/mission/controller/AcsController.cpp +++ b/mission/controller/AcsController.cpp @@ -116,10 +116,10 @@ void AcsController::performSafe() { navigation.useMekf(&sensorValues, &gyrDataProcessed, &mgmDataProcessed, &susDataProcessed, &mekfData, &validMekf); - // Give desired satellite rate and sun direction to align + // give desired satellite rate and sun direction to align double satRateSafe[3] = {0, 0, 0}, sunTargetDir[3] = {0, 0, 0}; guidance.getTargetParamsSafe(sunTargetDir, satRateSafe); - // IF MEKF is working + // if MEKF is working double magMomMtq[3] = {0, 0, 0}, errAng = 0.0; bool magMomMtqValid = false; if (validMekf == returnvalue::OK) { @@ -137,8 +137,8 @@ void AcsController::performSafe() { sunTargetDir, satRateSafe, &errAng, magMomMtq, &magMomMtqValid); } - double dipolCmdUnits[3] = {0, 0, 0}; - actuatorCmd.cmdDipolMtq(magMomMtq, dipolCmdUnits); + int16_t cmdDipolMtqs[3] = {0, 0, 0}; + actuatorCmd.cmdDipolMtq(magMomMtq, cmdDipolMtqs); { PoolReadGuard pg(&ctrlValData); @@ -180,33 +180,15 @@ void AcsController::performSafe() { actuatorCmdData.rwTargetTorque.setValid(false); std::memcpy(actuatorCmdData.rwTargetSpeed.value, zeroVec, 4 * sizeof(int32_t)); actuatorCmdData.rwTargetSpeed.setValid(false); - std::memcpy(actuatorCmdData.mtqTargetDipole.value, dipolCmdUnits, 3 * sizeof(int16_t)); + std::memcpy(actuatorCmdData.mtqTargetDipole.value, cmdDipolMtqs, 3 * sizeof(int16_t)); actuatorCmdData.mtqTargetDipole.setValid(true); actuatorCmdData.setValidity(true, false); } } - // { - // PoolReadGuard pg(&dipoleSet); - // MutexGuard mg(torquer::lazyLock()); - // torquer::NEW_ACTUATION_FLAG = true; - // dipoleSet.setDipoles(dipolCmdUnits[0], dipolCmdUnits[1], dipolCmdUnits[2], 0); - // } - // { - // PoolReadGuard pg(&rw1SpeedSet); - // rw1SpeedSet.setRwSpeed(0); - // } - // { - // PoolReadGuard pg(&rw2SpeedSet); - // rw2SpeedSet.setRwSpeed(0); - // } - // { - // PoolReadGuard pg(&rw3SpeedSet); - // rw3SpeedSet.setRwSpeed(0); - // } - // { - // PoolReadGuard pg(&rw4SpeedSet); - // rw4SpeedSet.setRwSpeed(0); - // } + + commandActuators(cmdDipolMtqs[0], cmdDipolMtqs[1], cmdDipolMtqs[2], + acsParameters.magnetorquesParameter.torqueDuration, 0, 0, 0, 0, + acsParameters.rwHandlingParameters.rampTime); } void AcsController::performDetumble() { @@ -223,8 +205,8 @@ void AcsController::performDetumble() { detumble.bDotLaw(mgmDataProcessed.mgmVecTotDerivative.value, mgmDataProcessed.mgmVecTotDerivative.isValid(), mgmDataProcessed.mgmVecTot.value, mgmDataProcessed.mgmVecTot.isValid(), magMomMtq); - double dipolCmdUnits[3] = {0, 0, 0}; - actuatorCmd.cmdDipolMtq(magMomMtq, dipolCmdUnits); + int16_t cmdDipolMtqs[3] = {0, 0, 0}; + actuatorCmd.cmdDipolMtq(magMomMtq, cmdDipolMtqs); if (mekfData.satRotRateMekf.isValid() && VectorOperations::norm(mekfData.satRotRateMekf.value, 3) < @@ -243,10 +225,6 @@ void AcsController::performDetumble() { triggerEvent(acs::SAFE_RATE_RECOVERY); } - int16_t cmdDipolUnitsInt[3] = {0, 0, 0}; - for (int i = 0; i < 3; ++i) { - cmdDipolUnitsInt[i] = std::round(dipolCmdUnits[i]); - } { PoolReadGuard pg(&actuatorCmdData); if (pg.getReadResult() == returnvalue::OK) { @@ -254,34 +232,15 @@ void AcsController::performDetumble() { actuatorCmdData.rwTargetTorque.setValid(false); std::memset(actuatorCmdData.rwTargetSpeed.value, 0, 4 * sizeof(int32_t)); actuatorCmdData.rwTargetSpeed.setValid(false); - std::memcpy(actuatorCmdData.mtqTargetDipole.value, cmdDipolUnitsInt, 3 * sizeof(int16_t)); + std::memcpy(actuatorCmdData.mtqTargetDipole.value, cmdDipolMtqs, 3 * sizeof(int16_t)); actuatorCmdData.mtqTargetDipole.setValid(true); actuatorCmdData.setValidity(true, false); } } - // { - // PoolReadGuard pg(&dipoleSet); - // MutexGuard mg(torquer::lazyLock()); - // torquer::NEW_ACTUATION_FLAG = true; - // dipoleSet.setDipoles(cmdDipolUnitsInt[0], cmdDipolUnitsInt[1], cmdDipolUnitsInt[2], - // torqueDuration); - // } - // { - // PoolReadGuard pg(&rw1SpeedSet); - // rw1SpeedSet.setRwSpeed(0); - // } - // { - // PoolReadGuard pg(&rw2SpeedSet); - // rw2SpeedSet.setRwSpeed(0); - // } - // { - // PoolReadGuard pg(&rw3SpeedSet); - // rw3SpeedSet.setRwSpeed(0); - // } - // { - // PoolReadGuard pg(&rw4SpeedSet); - // rw4SpeedSet.setRwSpeed(0); - // } + + commandActuators(cmdDipolMtqs[0], cmdDipolMtqs[1], cmdDipolMtqs[2], + acsParameters.magnetorquesParameter.torqueDuration, 0, 0, 0, 0, + acsParameters.rwHandlingParameters.rampTime); } void AcsController::performPointingCtrl() { @@ -304,7 +263,7 @@ void AcsController::performPointingCtrl() { guidance.getDistributionMatrixRw(&sensorValues, *rwPseudoInv); double torquePtgRws[4] = {0, 0, 0, 0}, rwTrqNs[4] = {0, 0, 0, 0}; double torqueRws[4] = {0, 0, 0, 0}, torqueRwsScaled[4] = {0, 0, 0, 0}; - double mgtDpDes[3] = {0, 0, 0}, dipolUnits[3] = {0, 0, 0}; // Desaturation Dipol + double mgtDpDes[3] = {0, 0, 0}; switch (submode) { case acs::PTG_IDLE: @@ -424,60 +383,62 @@ void AcsController::performPointingCtrl() { if (enableAntiStiction) { bool rwAvailable[4] = {true, true, true, true}; // WHICH INPUT SENSOR SET? - int32_t rwSpeed[4] = { - (sensorValues.rw1Set.currSpeed.value), (sensorValues.rw2Set.currSpeed.value), - (sensorValues.rw3Set.currSpeed.value), (sensorValues.rw4Set.currSpeed.value)}; + int32_t rwSpeed[4] = {sensorValues.rw1Set.currSpeed.value, sensorValues.rw2Set.currSpeed.value, + sensorValues.rw3Set.currSpeed.value, sensorValues.rw4Set.currSpeed.value}; ptgCtrl.rwAntistiction(rwAvailable, rwSpeed, torqueRwsScaled); } - double cmdSpeedRws[4] = {0, 0, 0, 0}; // Should be given to the actuator reaction wheel as input - actuatorCmd.cmdSpeedToRws(&(sensorValues.rw1Set.currSpeed.value), - &(sensorValues.rw2Set.currSpeed.value), - &(sensorValues.rw3Set.currSpeed.value), - &(sensorValues.rw4Set.currSpeed.value), torqueRwsScaled, cmdSpeedRws); - actuatorCmd.cmdDipolMtq(mgtDpDes, dipolUnits); - - int16_t cmdDipolUnitsInt[3] = {0, 0, 0}; - for (int i = 0; i < 3; ++i) { - cmdDipolUnitsInt[i] = std::round(dipolUnits[i]); - } - int32_t cmdRwSpeedInt[4] = {0, 0, 0, 0}; - for (int i = 0; i < 4; ++i) { - cmdRwSpeedInt[i] = std::round(cmdSpeedRws[i]); - } + int32_t cmdSpeedRws[4] = {0, 0, 0, 0}; + actuatorCmd.cmdSpeedToRws(sensorValues.rw1Set.currSpeed.value, + sensorValues.rw2Set.currSpeed.value, + sensorValues.rw3Set.currSpeed.value, + sensorValues.rw4Set.currSpeed.value, torqueRwsScaled, cmdSpeedRws); + int16_t cmdDipolMtqs[3] = {0, 0, 0}; + actuatorCmd.cmdDipolMtq(mgtDpDes, cmdDipolMtqs); { PoolReadGuard pg(&actuatorCmdData); if (pg.getReadResult() == returnvalue::OK) { std::memcpy(actuatorCmdData.rwTargetTorque.value, rwTrqNs, 4 * sizeof(double)); - std::memcpy(actuatorCmdData.rwTargetSpeed.value, cmdRwSpeedInt, 4 * sizeof(int32_t)); - std::memcpy(actuatorCmdData.mtqTargetDipole.value, cmdDipolUnitsInt, 3 * sizeof(int16_t)); + std::memcpy(actuatorCmdData.rwTargetSpeed.value, cmdSpeedRws, 4 * sizeof(int32_t)); + std::memcpy(actuatorCmdData.mtqTargetDipole.value, cmdDipolMtqs, 3 * sizeof(int16_t)); actuatorCmdData.setValidity(true, true); } } - // { - // PoolReadGuard pg(&dipoleSet); - // MutexGuard mg(torquer::lazyLock()); - // torquer::NEW_ACTUATION_FLAG = true; - // dipoleSet.setDipoles(cmdDipolUnitsInt[0], cmdDipolUnitsInt[1], cmdDipolUnitsInt[2], - // torqueDuration); - // } - // { - // PoolReadGuard pg(&rw1SpeedSet); - // rw1SpeedSet.setRwSpeed(cmdRwSpeedInt[0]); - // } - // { - // PoolReadGuard pg(&rw2SpeedSet); - // rw2SpeedSet.setRwSpeed(cmdRwSpeedInt[1]); - // } - // { - // PoolReadGuard pg(&rw3SpeedSet); - // rw3SpeedSet.setRwSpeed(cmdRwSpeedInt[2]); - // } - // { - // PoolReadGuard pg(&rw4SpeedSet); - // rw4SpeedSet.setRwSpeed(cmdRwSpeedInt[3]); - // } + + commandActuators(cmdDipolMtqs[0], cmdDipolMtqs[1], cmdDipolMtqs[2], + acsParameters.magnetorquesParameter.torqueDuration, cmdSpeedRws[0], + cmdSpeedRws[1], cmdSpeedRws[2], cmdSpeedRws[3], + acsParameters.rwHandlingParameters.rampTime); +} + +ReturnValue_t AcsController::commandActuators(int16_t xDipole, int16_t yDipole, int16_t zDipole, + uint16_t dipoleTorqueDuration, int32_t rw1Speed, + int32_t rw2Speed, int32_t rw3Speed, int32_t rw4Speed, + uint16_t rampTime) { + { + PoolReadGuard pg(&dipoleSet); + MutexGuard mg(torquer::lazyLock()); + torquer::NEW_ACTUATION_FLAG = true; + dipoleSet.setDipoles(xDipole, yDipole, zDipole, dipoleTorqueDuration); + } + { + PoolReadGuard pg(&rw1SpeedSet); + rw1SpeedSet.setRwSpeed(rw1Speed, rampTime); + } + { + PoolReadGuard pg(&rw2SpeedSet); + rw2SpeedSet.setRwSpeed(rw2Speed, rampTime); + } + { + PoolReadGuard pg(&rw3SpeedSet); + rw3SpeedSet.setRwSpeed(rw3Speed, rampTime); + } + { + PoolReadGuard pg(&rw4SpeedSet); + rw4SpeedSet.setRwSpeed(rw4Speed, rampTime); + } + return returnvalue::OK; } ReturnValue_t AcsController::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, diff --git a/mission/controller/AcsController.h b/mission/controller/AcsController.h index d427bd5b..c79e4426 100644 --- a/mission/controller/AcsController.h +++ b/mission/controller/AcsController.h @@ -70,6 +70,10 @@ class AcsController : public ExtendedControllerBase, public ReceivesParameterMes void modeChanged(Mode_t mode, Submode_t submode); void announceMode(bool recursive); + ReturnValue_t commandActuators(int16_t xDipole, int16_t yDipole, int16_t zDipole, + uint16_t dipoleTorqueDuration, int32_t rw1Speed, int32_t rw2Speed, + int32_t rw3Speed, int32_t rw4Speed, uint16_t rampTime); + /* ACS Sensor Values */ ACS::SensorValues sensorValues; From 109560feb263f6078fb31db12fde99d9d091ae55 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 10 Feb 2023 11:30:52 +0100 Subject: [PATCH 072/373] disabled actCmd from acsCtrl again for now --- mission/controller/AcsController.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mission/controller/AcsController.cpp b/mission/controller/AcsController.cpp index 29bd06b6..7ed66045 100644 --- a/mission/controller/AcsController.cpp +++ b/mission/controller/AcsController.cpp @@ -186,9 +186,9 @@ void AcsController::performSafe() { } } - commandActuators(cmdDipolMtqs[0], cmdDipolMtqs[1], cmdDipolMtqs[2], - acsParameters.magnetorquesParameter.torqueDuration, 0, 0, 0, 0, - acsParameters.rwHandlingParameters.rampTime); + // commandActuators(cmdDipolMtqs[0], cmdDipolMtqs[1], cmdDipolMtqs[2], + // acsParameters.magnetorquesParameter.torqueDuration, 0, 0, 0, 0, + // acsParameters.rwHandlingParameters.rampTime); } void AcsController::performDetumble() { @@ -238,9 +238,9 @@ void AcsController::performDetumble() { } } - commandActuators(cmdDipolMtqs[0], cmdDipolMtqs[1], cmdDipolMtqs[2], - acsParameters.magnetorquesParameter.torqueDuration, 0, 0, 0, 0, - acsParameters.rwHandlingParameters.rampTime); + // commandActuators(cmdDipolMtqs[0], cmdDipolMtqs[1], cmdDipolMtqs[2], + // acsParameters.magnetorquesParameter.torqueDuration, 0, 0, 0, 0, + // acsParameters.rwHandlingParameters.rampTime); } void AcsController::performPointingCtrl() { @@ -406,10 +406,10 @@ void AcsController::performPointingCtrl() { } } - commandActuators(cmdDipolMtqs[0], cmdDipolMtqs[1], cmdDipolMtqs[2], - acsParameters.magnetorquesParameter.torqueDuration, cmdSpeedRws[0], - cmdSpeedRws[1], cmdSpeedRws[2], cmdSpeedRws[3], - acsParameters.rwHandlingParameters.rampTime); + // commandActuators(cmdDipolMtqs[0], cmdDipolMtqs[1], cmdDipolMtqs[2], + // acsParameters.magnetorquesParameter.torqueDuration, cmdSpeedRws[0], + // cmdSpeedRws[1], cmdSpeedRws[2], cmdSpeedRws[3], + // acsParameters.rwHandlingParameters.rampTime); } ReturnValue_t AcsController::commandActuators(int16_t xDipole, int16_t yDipole, int16_t zDipole, From bc4c6c3a5466e66fac8a02e2f2c1245cdd2acd35 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 10 Feb 2023 12:07:45 +0100 Subject: [PATCH 073/373] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d92d6113..1bbc760d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,11 +20,13 @@ change warranting a new major release: ## Added - First version of a TCS controller heater control loop. +- Function for the ACS controller to command MTQ and RWs called by all subroutines ## Changed - Reworked dummy handling for the TCS controller. - Generator scripts now generate files for hosted and for Q7S build. +- ActCmds now returns command vectors as integers as required by the actuators # [v1.26.2] 2023-02-08 From 33684f2ef7eeaba440382d3a5a51dfcd61d5724c Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 10 Feb 2023 12:48:17 +0100 Subject: [PATCH 074/373] fixed imtq setDipoles check --- mission/devices/devicedefinitions/imtqHandlerDefinitions.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mission/devices/devicedefinitions/imtqHandlerDefinitions.h b/mission/devices/devicedefinitions/imtqHandlerDefinitions.h index 2abf1c21..c3bc3d36 100644 --- a/mission/devices/devicedefinitions/imtqHandlerDefinitions.h +++ b/mission/devices/devicedefinitions/imtqHandlerDefinitions.h @@ -492,14 +492,14 @@ class DipoleActuationSet : public StaticLocalDataSet<4> { void setDipoles(int16_t xDipole_, int16_t yDipole_, int16_t zDipole_, uint16_t currentTorqueDurationMs_) { if (xDipole.value != xDipole_) { + xDipole = xDipole_; } - xDipole = xDipole_; if (yDipole.value != yDipole_) { + yDipole = yDipole_; } - yDipole = yDipole_; if (zDipole.value != zDipole_) { + zDipole = zDipole_; } - zDipole = zDipole_; currentTorqueDurationMs = currentTorqueDurationMs_; } From 08df102f3684b880c295a64b374793e84eef87e0 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 10 Feb 2023 13:16:50 +0100 Subject: [PATCH 075/373] rwHandler rwSpeedActuationSet handling --- mission/devices/RwHandler.cpp | 62 +++++++++++++++++++++++------------ mission/devices/RwHandler.h | 12 ++++--- 2 files changed, 49 insertions(+), 25 deletions(-) diff --git a/mission/devices/RwHandler.cpp b/mission/devices/RwHandler.cpp index e9383c4a..7a8b52f3 100644 --- a/mission/devices/RwHandler.cpp +++ b/mission/devices/RwHandler.cpp @@ -13,7 +13,8 @@ RwHandler::RwHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCooki enableGpio(enableGpio), statusSet(this), lastResetStatusSet(this), - tmDataset(this) { + tmDataset(this), + rwSpeedActuationSet(*this) { if (comCookie == nullptr) { sif::error << "RwHandler: Invalid com cookie" << std::endl; } @@ -97,16 +98,36 @@ ReturnValue_t RwHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand return returnvalue::OK; } case (RwDefinitions::SET_SPEED): { - if (commandDataLen != 6) { + if (commandData != nullptr && commandDataLen != 6) { sif::error << "RwHandler::buildCommandFromCommand: Received set speed command with" << " invalid length" << std::endl; return SET_SPEED_COMMAND_INVALID_LENGTH; } - result = checkSpeedAndRampTime(commandData, commandDataLen); + // Commands override anything which was set in the software + if (commandData != nullptr) { + rwSpeedActuationSet.setValidityBufferGeneration(false); + result = rwSpeedActuationSet.deSerialize(&commandData, &commandDataLen, + SerializeIF::Endianness::NETWORK); + rwSpeedActuationSet.setValidityBufferGeneration(true); + if (result != returnvalue::OK) { + return result; + } + } else { + // Read set rw speed value from local pool + PoolReadGuard pg(&rwSpeedActuationSet); + } + if (ACTUATION_WIRETAPPING) { + int32_t speed; + uint16_t rampTime; + rwSpeedActuationSet.getRwSpeed(speed, rampTime); + sif::debug << "Actuating RW with speed = " << speed << " and rampTime = " << rampTime + << std::endl; + } + result = checkSpeedAndRampTime(); if (result != returnvalue::OK) { return result; } - prepareSetSpeedCmd(commandData, commandDataLen); + result = prepareSetSpeedCmd(); return result; } case (RwDefinitions::GET_TEMPERATURE): { @@ -298,17 +319,15 @@ void RwHandler::prepareSimpleCommand(DeviceCommandId_t id) { rawPacketLen = 3; } -ReturnValue_t RwHandler::checkSpeedAndRampTime(const uint8_t* commandData, size_t commandDataLen) { - int32_t speed = - *commandData << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 | *(commandData + 3); - +ReturnValue_t RwHandler::checkSpeedAndRampTime() { + int32_t speed = 0; + uint16_t rampTime = 0; + rwSpeedActuationSet.getRwSpeed(speed, rampTime); if ((speed < -65000 || speed > 65000 || (speed > -1000 && speed < 1000)) && (speed != 0)) { sif::error << "RwHandler::checkSpeedAndRampTime: Command has invalid speed" << std::endl; return INVALID_SPEED; } - uint16_t rampTime = (*(commandData + 4) << 8) | *(commandData + 5); - if (rampTime < 10 || rampTime > 20000) { sif::error << "RwHandler::checkSpeedAndRampTime: Command has invalid ramp time" << std::endl; return INVALID_RAMP_TIME; @@ -317,23 +336,24 @@ ReturnValue_t RwHandler::checkSpeedAndRampTime(const uint8_t* commandData, size_ return returnvalue::OK; } -void RwHandler::prepareSetSpeedCmd(const uint8_t* commandData, size_t commandDataLen) { +ReturnValue_t RwHandler::prepareSetSpeedCmd() { commandBuffer[0] = static_cast(RwDefinitions::SET_SPEED); - - /** Speed (0.1 RPM) */ - commandBuffer[1] = *(commandData + 3); - commandBuffer[2] = *(commandData + 2); - commandBuffer[3] = *(commandData + 1); - commandBuffer[4] = *commandData; - /** Ramp time (ms) */ - commandBuffer[5] = *(commandData + 5); - commandBuffer[6] = *(commandData + 4); + uint8_t* serPtr = commandBuffer + 1; + size_t serSize = 1; + rwSpeedActuationSet.setValidityBufferGeneration(false); + ReturnValue_t result = rwSpeedActuationSet.serialize(&serPtr, &serSize, sizeof(commandBuffer), + SerializeIF::Endianness::LITTLE); + rwSpeedActuationSet.setValidityBufferGeneration(true); + if (result != returnvalue::OK) { + return result; + } uint16_t crc = CRC::crc16ccitt(commandBuffer, 7, 0xFFFF); commandBuffer[7] = static_cast(crc & 0xFF); - commandBuffer[8] = static_cast(crc >> 8 & 0xFF); + commandBuffer[8] = static_cast((crc >> 8) & 0xFF); rawPacket = commandBuffer; rawPacketLen = 9; + return result; } void RwHandler::handleResetStatusReply(const uint8_t* packet) { diff --git a/mission/devices/RwHandler.h b/mission/devices/RwHandler.h index 17f2b396..af59caa1 100644 --- a/mission/devices/RwHandler.h +++ b/mission/devices/RwHandler.h @@ -9,6 +9,8 @@ #include "events/subsystemIdRanges.h" #include "returnvalues/classIds.h" +static constexpr bool ACTUATION_WIRETAPPING = false; + class GpioIF; /** @@ -93,6 +95,7 @@ class RwHandler : public DeviceHandlerBase { RwDefinitions::StatusSet statusSet; RwDefinitions::LastResetSatus lastResetStatusSet; RwDefinitions::TmDataset tmDataset; + RwDefinitions::RwSpeedActuationSet rwSpeedActuationSet; uint8_t commandBuffer[RwDefinitions::MAX_CMD_SIZE]; @@ -117,13 +120,14 @@ class RwHandler : public DeviceHandlerBase { * range. * @return returnvalue::OK if successful, otherwise error code. */ - ReturnValue_t checkSpeedAndRampTime(const uint8_t* commandData, size_t commandDataLen); + ReturnValue_t checkSpeedAndRampTime(); /** - * @brief This function prepares the set speed command from the commandData received with - * an action message. + * @brief This function prepares the set speed command from the dataSet received with + * an action message or set in the software. + * @return returnvalue::OK if successful, otherwise error code. */ - void prepareSetSpeedCmd(const uint8_t* commandData, size_t commandDataLen); + ReturnValue_t prepareSetSpeedCmd(); /** * @brief This function writes the last reset status retrieved with the get last reset status From 285bd7116b2a8b08472e6ccfcc39dbce2362b678 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 10 Feb 2023 13:17:52 +0100 Subject: [PATCH 076/373] bump changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bbc760d..6f1896d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ change warranting a new major release: - First version of a TCS controller heater control loop. - Function for the ACS controller to command MTQ and RWs called by all subroutines +- RwHandler now handles commanding of RW speeds via RwSpeedActuationSet ## Changed From 35172185f9da2b55ea0e85018bf3a5543579519b Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 10 Feb 2023 13:29:13 +0100 Subject: [PATCH 077/373] fix --- mission/controller/acs/AcsParameters.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/mission/controller/acs/AcsParameters.cpp b/mission/controller/acs/AcsParameters.cpp index 30264963..44bed15f 100644 --- a/mission/controller/acs/AcsParameters.cpp +++ b/mission/controller/acs/AcsParameters.cpp @@ -280,6 +280,7 @@ ReturnValue_t AcsParameters::getParameter(uint8_t domainId, uint8_t parameterId, break; case 0x5: parameterWrapper->set(rwHandlingParameters.rampTime); + break; default: return INVALID_IDENTIFIER_ID; } From f4f6d1ed819f69a0291092584029fb6956a1467a Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 13 Feb 2023 10:33:08 +0100 Subject: [PATCH 078/373] added InternalState SET_SPEED to enable setting RW Speed from ACS Ctrl --- mission/devices/RwHandler.cpp | 7 ++++++- mission/devices/RwHandler.h | 10 ++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/mission/devices/RwHandler.cpp b/mission/devices/RwHandler.cpp index 7a8b52f3..88857b68 100644 --- a/mission/devices/RwHandler.cpp +++ b/mission/devices/RwHandler.cpp @@ -53,7 +53,11 @@ ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { break; case InternalState::GET_RW_SATUS: *id = RwDefinitions::GET_RW_STATUS; - internalState = InternalState::GET_RESET_STATUS; + internalState = InternalState::SET_SPEED; + break; + case InternalState::SET_SPEED: + *id = RwDefinitions::SET_SPEED; + internalState = InternalState::CLEAR_RESET_STATUS; break; case InternalState::CLEAR_RESET_STATUS: *id = RwDefinitions::CLEAR_LAST_RESET_STATUS; @@ -98,6 +102,7 @@ ReturnValue_t RwHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand return returnvalue::OK; } case (RwDefinitions::SET_SPEED): { + sif::debug << "hello" << std::endl; if (commandData != nullptr && commandDataLen != 6) { sif::error << "RwHandler::buildCommandFromCommand: Received set speed command with" << " invalid length" << std::endl; diff --git a/mission/devices/RwHandler.h b/mission/devices/RwHandler.h index af59caa1..148a6359 100644 --- a/mission/devices/RwHandler.h +++ b/mission/devices/RwHandler.h @@ -9,7 +9,7 @@ #include "events/subsystemIdRanges.h" #include "returnvalues/classIds.h" -static constexpr bool ACTUATION_WIRETAPPING = false; +static constexpr bool ACTUATION_WIRETAPPING = true; class GpioIF; @@ -102,7 +102,13 @@ class RwHandler : public DeviceHandlerBase { PoolEntry rwSpeed = PoolEntry(0, false); PoolEntry rampTime = PoolEntry(10, false); - enum class InternalState { GET_RESET_STATUS, CLEAR_RESET_STATUS, READ_TEMPERATURE, GET_RW_SATUS }; + enum class InternalState { + GET_RESET_STATUS, + CLEAR_RESET_STATUS, + READ_TEMPERATURE, + SET_SPEED, + GET_RW_SATUS + }; InternalState internalState = InternalState::GET_RESET_STATUS; From b5e096abcbad244e21eefa6226a4b92eb834c46b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 13 Feb 2023 10:40:39 +0100 Subject: [PATCH 079/373] start work on EM satsystem --- bsp_q7s/em/emObjectFactory.cpp | 3 ++- dummies/helpers.cpp | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/bsp_q7s/em/emObjectFactory.cpp b/bsp_q7s/em/emObjectFactory.cpp index 1a838b17..693da405 100644 --- a/bsp_q7s/em/emObjectFactory.cpp +++ b/bsp_q7s/em/emObjectFactory.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include "OBSWConfig.h" #include "bsp_q7s/core/CoreController.h" @@ -115,5 +116,5 @@ void ObjectFactory::produce(void* args) { HeaterHandler* heaterHandler = nullptr; ObjectFactory::createGenericHeaterComponents(*gpioComIF, *pwrSwitcher, heaterHandler); createThermalController(*heaterHandler); - satsystem::com::init(); + satsystem::init(); } diff --git a/dummies/helpers.cpp b/dummies/helpers.cpp index 7c8fab1c..d6bbf70f 100644 --- a/dummies/helpers.cpp +++ b/dummies/helpers.cpp @@ -24,6 +24,7 @@ #include "TemperatureSensorInserter.h" #include "dummies/Max31865Dummy.h" #include "dummies/Tmp1075Dummy.h" +#include "mission/system/tree/acsModeTree.h" using namespace dummy; @@ -48,6 +49,7 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitch) { } auto* imtqDummy = new ImtqDummy(objects::IMTQ_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); imtqDummy->enableThermalModule(ThermalStateCfg()); + imtqDummy->connectModeTreeParent(satsystem::acs::ACS_SUBSYSTEM); if (cfg.addPowerDummies) { new AcuDummy(objects::ACU_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); new PduDummy(objects::PDU1_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); From 53f31ca5a4df78887aaf3e22090159eb35d8509c Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 13 Feb 2023 10:42:05 +0100 Subject: [PATCH 080/373] lol --- .../pollingSequenceFactory.cpp | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+) diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index f9b69e45..6b184f58 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -639,6 +639,129 @@ ReturnValue_t pst::pstAcs(FixedTimeslotTaskIF *thisSequence, AcsPstCfg cfg) { } if (cfg.scheduleRws) { + thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + + thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::SEND_WRITE); + + thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::GET_WRITE); + + thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::SEND_READ); + + thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::GET_READ); + + thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + + thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::SEND_WRITE); + + thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::GET_WRITE); + + thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::SEND_READ); + + thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::GET_READ); + + thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + + thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::SEND_WRITE); + + thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::GET_WRITE); + + thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::SEND_READ); + + thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::GET_READ); + } + + if (cfg.scheduleRws) { + // this is the torquing cycle + thisSequence->addSlot(objects::RW1, length * config::acs::SCHED_BLOCK_2_PERIOD, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RW2, length * config::acs::SCHED_BLOCK_2_PERIOD, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RW3, length * config::acs::SCHED_BLOCK_2_PERIOD, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RW4, length * config::acs::SCHED_BLOCK_2_PERIOD, + DeviceHandlerIF::PERFORM_OPERATION); + + thisSequence->addSlot(objects::RW1, length * config::acs::SCHED_BLOCK_2_PERIOD, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RW2, length * config::acs::SCHED_BLOCK_2_PERIOD, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RW3, length * config::acs::SCHED_BLOCK_2_PERIOD, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RW4, length * config::acs::SCHED_BLOCK_2_PERIOD, + DeviceHandlerIF::SEND_WRITE); + + thisSequence->addSlot(objects::RW1, length * config::acs::SCHED_BLOCK_2_PERIOD, + DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW2, length * config::acs::SCHED_BLOCK_2_PERIOD, + DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW3, length * config::acs::SCHED_BLOCK_2_PERIOD, + DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW4, length * config::acs::SCHED_BLOCK_2_PERIOD, + DeviceHandlerIF::GET_WRITE); + + thisSequence->addSlot(objects::RW1, length * config::acs::SCHED_BLOCK_2_PERIOD, + DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW2, length * config::acs::SCHED_BLOCK_2_PERIOD, + DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW3, length * config::acs::SCHED_BLOCK_2_PERIOD, + DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW4, length * config::acs::SCHED_BLOCK_2_PERIOD, + DeviceHandlerIF::SEND_READ); + + thisSequence->addSlot(objects::RW1, length * config::acs::SCHED_BLOCK_2_PERIOD, + DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW2, length * config::acs::SCHED_BLOCK_2_PERIOD, + DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW3, length * config::acs::SCHED_BLOCK_2_PERIOD, + DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW4, length * config::acs::SCHED_BLOCK_2_PERIOD, + DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW1, length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::RW2, length * config::acs::SCHED_BLOCK_2_PERIOD, From 14c43c49dca652396a161dc083cb99acd6ed1ba8 Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 13 Feb 2023 10:58:12 +0100 Subject: [PATCH 081/373] scale rwCmdSpeed to appropriate range --- mission/controller/acs/ActuatorCmd.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/mission/controller/acs/ActuatorCmd.cpp b/mission/controller/acs/ActuatorCmd.cpp index cbe24e5b..b902593f 100644 --- a/mission/controller/acs/ActuatorCmd.cpp +++ b/mission/controller/acs/ActuatorCmd.cpp @@ -57,6 +57,7 @@ void ActuatorCmd::cmdSpeedToRws(const int32_t speedRw0, const int32_t speedRw1, deltaSpeedInt[i] = std::round(deltaSpeed[i]); } VectorOperations::add(speedRws, deltaSpeedInt, rwCmdSpeed, 4); + VectorOperations::mulScalar(rwCmdSpeed, 10, rwCmdSpeed, 4); } void ActuatorCmd::cmdDipolMtq(const double *dipolMoment, int16_t *dipolMomentActuator) { From 1d20c3b472e8e1d7e617d54204465a0c41302ebe Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 13 Feb 2023 11:04:43 +0100 Subject: [PATCH 082/373] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1dbd2f9c..57209a3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,8 @@ change warranting a new major release: ## Changed - ActCmds now returns command vectors as integers as required by the actuators + and scales them to the appropriate range +- All RwHandler are now polled five times per ACS cycle # [v1.27.0] 2023-02-13 From 068b31a3d6bac46dd3feaac02670af10c89250de Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 13 Feb 2023 11:07:09 +0100 Subject: [PATCH 083/373] changelog --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57209a3f..d3d64dce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,6 @@ change warranting a new major release: ## Added -- First version of a TCS controller heater control loop. - Function for the ACS controller to command MTQ and RWs called by all subroutines - RwHandler now handles commanding of RW speeds via RwSpeedActuationSet From 60c99fdbfb3f0d79033de583495a76cf356edc0c Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 13 Feb 2023 11:28:27 +0100 Subject: [PATCH 084/373] local parameter handler wip --- bsp_q7s/core/ObjectFactory.cpp | 6 + bsp_q7s/core/ObjectFactory.h | 2 + bsp_q7s/fmObjectFactory.cpp | 2 + bsp_q7s/memory/CMakeLists.txt | 2 +- bsp_q7s/memory/LocalParameterHandler.cpp | 22 +++ bsp_q7s/memory/LocalParameterHandler.h | 66 +++++++++ linux/ipcore/PdecConfig.cpp | 139 ++++++++++++++---- linux/ipcore/PdecConfig.h | 91 +++++++++++- linux/ipcore/PdecHandler.cpp | 107 +++++++------- linux/ipcore/PdecHandler.h | 58 ++++---- mission/config/configfile.h | 9 ++ mission/system/objects/ComSubsystem.h | 1 + mission/utility/GlobalConfigFileDefinitions.h | 2 + mission/utility/GlobalConfigHandler.cpp | 47 +++--- mission/utility/GlobalConfigHandler.h | 15 +- 15 files changed, 417 insertions(+), 152 deletions(-) create mode 100644 bsp_q7s/memory/LocalParameterHandler.cpp create mode 100644 bsp_q7s/memory/LocalParameterHandler.h create mode 100644 mission/config/configfile.h diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 1fb9efed..47ca4e18 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -51,6 +51,8 @@ #include "mission/system/tree/comModeTree.h" #include "mission/system/tree/payloadModeTree.h" #include "mission/system/tree/tcsModeTree.h" +#include "mission/utility/GlobalConfigHandler.h" +#include "mission/config/configfile.h" #include "tmtc/pusIds.h" #if OBSW_TEST_LIBGPIOD == 1 #include "linux/boardtest/LibgpiodTest.h" @@ -966,3 +968,7 @@ void ObjectFactory::testAcsBrdAss(AcsBoardAssembly* acsAss) { sif::warning << "Sending mode command failed" << std::endl; } } + +void ObjectFactory::createGlobalConfigHandler() { + new GlobalConfigHandler(objects::GLOBAL_JSON_CFG, configfile::sdrelative); +} diff --git a/bsp_q7s/core/ObjectFactory.h b/bsp_q7s/core/ObjectFactory.h index c55e8452..853fd9ce 100644 --- a/bsp_q7s/core/ObjectFactory.h +++ b/bsp_q7s/core/ObjectFactory.h @@ -48,6 +48,8 @@ void createTestComponents(LinuxLibgpioIF* gpioComIF); void testAcsBrdAss(AcsBoardAssembly* assAss); +void createGlobalConfigHandler(); + }; // namespace ObjectFactory #endif /* BSP_Q7S_OBJECTFACTORY_H_ */ diff --git a/bsp_q7s/fmObjectFactory.cpp b/bsp_q7s/fmObjectFactory.cpp index 44b53225..40d2454e 100644 --- a/bsp_q7s/fmObjectFactory.cpp +++ b/bsp_q7s/fmObjectFactory.cpp @@ -86,6 +86,8 @@ void ObjectFactory::produce(void* args) { createTestComponents(gpioComIF); #endif /* OBSW_ADD_TEST_CODE == 1 */ + createGlobalConfigHandler(); + createMiscComponents(); createThermalController(); createAcsController(true); diff --git a/bsp_q7s/memory/CMakeLists.txt b/bsp_q7s/memory/CMakeLists.txt index 06909a0a..4ff840c8 100644 --- a/bsp_q7s/memory/CMakeLists.txt +++ b/bsp_q7s/memory/CMakeLists.txt @@ -1 +1 @@ -target_sources(${OBSW_NAME} PRIVATE scratchApi.cpp) +target_sources(${OBSW_NAME} PRIVATE scratchApi.cpp LocalParameterHandler.cpp) diff --git a/bsp_q7s/memory/LocalParameterHandler.cpp b/bsp_q7s/memory/LocalParameterHandler.cpp new file mode 100644 index 00000000..03a5ba82 --- /dev/null +++ b/bsp_q7s/memory/LocalParameterHandler.cpp @@ -0,0 +1,22 @@ +#include "LocalParameterHandler.h" +#include + +LocalParameterHandler::LocalParameterHandler(std::string sdRelativeName, SdCardMountedIF* sdcMan) + : sdRelativeName(sdRelativeName), sdcMan(sdcMan) {} + +LocalParameterHandler::~LocalParameterHandler() { +} + +ReturnValue_t LocalParameterHandler::initialize() { + std::string mountPrefix = sdcMan->getCurrentMountPrefix(); + std::string fullname = mountPrefix + "/" + sdRelativeName; + setFullName(fullname); + ReturnValue_t result = readJsonFile(); + if (result != returnvalue::OK) { + sif::warning << "LocalParameterHandler::initialize: Failed to read json file" + << getFullName() << std::endl; + return result; + } + return returnvalue::OK; +} + diff --git a/bsp_q7s/memory/LocalParameterHandler.h b/bsp_q7s/memory/LocalParameterHandler.h new file mode 100644 index 00000000..57d646cb --- /dev/null +++ b/bsp_q7s/memory/LocalParameterHandler.h @@ -0,0 +1,66 @@ +#ifndef BSP_Q7S_MEMORY_LOCALPARAMETERHANDLER_H_ +#define BSP_Q7S_MEMORY_LOCALPARAMETERHANDLER_H_ + +#include + +#include +#include + +/** + * @brief Class to handle persistent parameters + * + * @details Use the insertValue function to add parameters + */ +class LocalParameterHandler : public NVMParameterBase { + public: + /** + * @brief Constructor + * + * @param sdRelativeName Absolute name of json file relative to mount + * directory of SD card. E.g. conf/example.json + * @param sdcMan Pointer to SD card manager + */ + LocalParameterHandler(std::string sdRelativeName, SdCardMountedIF* sdcMan); + virtual ~LocalParameterHandler(); + + /** + * @brief Will initialize the local parameter handler + * + * @return OK if successful, otherwise error return value + */ + ReturnValue_t initialize(); + + /** + * @brief Function to add parameter to json file + * + * @param key The string to identify the parameter + * @param value The value to set for this parameter + * + * @return OK if successful, otherwise error return value + * + * @details The function will add the parameter only if it is not already + * present in the json file + */ + template ReturnValue_t addParameter(std::string key, T value); + + private: + + // Name relative to mount point of SD card where parameters will be stored + std::string sdRelativeName; + + SdCardMountedIF* sdcMan; +}; + +template inline ReturnValue_t LocalParameterHandler::addParameter(std::string key, T value) { + ReturnValue_t result = insertValue(key, value); + if (result != returnvalue::OK) { + return result; + } + result = writeJsonFile(); + if (result != returnvalue::OK) { + return result; + } + return returnvalue::OK; +} + +#endif /* BSP_Q7S_MEMORY_LOCALPARAMETERHANDLER_H_ */ diff --git a/linux/ipcore/PdecConfig.cpp b/linux/ipcore/PdecConfig.cpp index 21de4610..152ea320 100644 --- a/linux/ipcore/PdecConfig.cpp +++ b/linux/ipcore/PdecConfig.cpp @@ -2,41 +2,126 @@ #include "fsfw/serviceinterface/ServiceInterface.h" -PdecConfig::PdecConfig() { initialize(); } +PdecConfig::PdecConfig() + : localParameterHandler("conf/pdecconfig", SdCardManager::instance()) { +} PdecConfig::~PdecConfig() {} -void PdecConfig::initialize() { - uint32_t word = 0; - word |= (VERSION_ID << 30); - - // Setting the bypass flag and the control command flag should not have any - // implication on the operation of the PDEC IP Core - word |= (BYPASS_FLAG << 29); - word |= (CONTROL_COMMAND_FLAG << 28); - - word |= (RESERVED_FIELD_A << 26); - word |= (SPACECRAFT_ID << 16); - word |= (VIRTUAL_CHANNEL << 10); - word |= (DUMMY_BITS << 8); - word |= POSITIVE_WINDOW; - configWords[0] = word; - word = 0; - word |= (NEGATIVE_WINDOW << 24); - word |= (HIGH_AU_MAP_ID << 16); - word |= (ENABLE_DERANDOMIZER << 8); - configWords[1] = word; +void PdecConfig::setMemoryBaseAddress(uint32_t* memoryBaseAddress_) { + memoryBaseAddress = memoryBaseAddress_; } -uint32_t PdecConfig::getConfigWord(uint8_t wordNo) { - if (wordNo >= CONFIG_WORDS_NUM) { - sif::error << "PdecConfig::getConfigWord: Invalid word number" << std::endl; - return 0; - } - return configWords[wordNo]; +ReturnValue_t PdecConfig::write() { + if (memoryBaseAddress == nullptr) { + sif::error << "PdecConfig::write: Memory base address not set" << std::endl; + return returnvalue::FAILED; + } + + writeFrameHeaderFirstOctet(); + writeFrameHeaderSecondOctet(); + writeMapConfig(); + return returnvalue::FAILED; } uint32_t PdecConfig::getImrReg() { return static_cast(enableNewFarIrq << 2) | static_cast(enableTcAbortIrq << 1) | static_cast(enableTcNewIrq); } + +ReturnValue_t PdecConfig::setPositiveWindow(uint8_t pw) { + if (memoryBaseAddress == nullptr) { + sif::error << "PdecConfig::setPositiveWindow: Memory base address not set" + << std::endl; + return returnvalue::FAILED; + } + positiveWindow = pw; + // Rewrite second config word which contains the positive window parameter + writeFrameHeaderSecondOctet(); + return returnvalue::OK; +} + +ReturnValue_t PdecConfig::setNegativeWindow(uint8_t nw) { + if (memoryBaseAddress == nullptr) { + sif::error << "PdecConfig::setPositiveWindow: Memory base address not set" + << std::endl; + return returnvalue::FAILED; + } + negativeWindow = nw; + // Rewrite second config word which contains the negative window parameter + writeFrameHeaderSecondOctet(); + return returnvalue::OK; +} + +uint8_t PdecConfig::getPositiveWindow() { + return positiveWindow; +} + +uint8_t PdecConfig::getNegativeWindow() { + return negativeWindow; +} + +void PdecConfig::writeFrameHeaderFirstOctet() { + uint32_t word = 0; + word |= (VERSION_ID << 30); + + // Setting the bypass flag and the control command flag should not have any + // implication on the operation of the PDEC IP Core + word |= (BYPASS_FLAG << 29); + word |= (CONTROL_COMMAND_FLAG << 28); + + word |= (RESERVED_FIELD_A << 26); + word |= (SPACECRAFT_ID << 16); + word |= (VIRTUAL_CHANNEL << 10); + word |= (DUMMY_BITS << 8); + word |= positiveWindow; + *(memoryBaseAddress + FRAME_HEADER_OFFSET) = word; +} + +void PdecConfig::writeFrameHeaderSecondOctet() { + uint32_t word = 0; + word = 0; + word |= (negativeWindow << 24); + word |= (HIGH_AU_MAP_ID << 16); + word |= (ENABLE_DERANDOMIZER << 8); + *(memoryBaseAddress + FRAME_HEADER_OFFSET + 1) = word; +} + +void PdecConfig::writeMapConfig() { + // Configure all MAP IDs as invalid + for (int idx = 0; idx <= MAX_MAP_ADDR; idx += 4) { + *(memoryBaseAddress + MAP_ADDR_LUT_OFFSET + idx / 4) = + NO_DESTINATION << 24 | NO_DESTINATION << 16 | NO_DESTINATION << 8 | NO_DESTINATION; + } + + // All TCs with MAP ID 7 will be routed to the PM module (can then be read from memory) + uint8_t routeToPm = calcMapAddrEntry(PM_BUFFER); + *(memoryBaseAddress + MAP_ADDR_LUT_OFFSET + 1) = + (NO_DESTINATION << 24) | (NO_DESTINATION << 16) | (NO_DESTINATION << 8) | routeToPm; + + // Write map id clock frequencies + for (int idx = 0; idx <= MAX_MAP_ADDR; idx += 4) { + *(memoryBaseAddress + MAP_CLK_FREQ_OFFSET + idx / 4) = + MAP_CLK_FREQ << 24 | MAP_CLK_FREQ << 16 | MAP_CLK_FREQ << 8 | MAP_CLK_FREQ; + } +} + +uint8_t PdecConfig::calcMapAddrEntry(uint8_t moduleId) { + uint8_t lutEntry = 0; + uint8_t parity = getOddParity(moduleId | (1 << VALID_POSITION)); + lutEntry = (parity << PARITY_POSITION) | (1 << VALID_POSITION) | moduleId; + return lutEntry; +} + +uint8_t PdecConfig::getOddParity(uint8_t number) { + uint8_t parityBit = 0; + uint8_t countBits = 0; + for (unsigned int idx = 0; idx < sizeof(number) * 8; idx++) { + countBits += (number >> idx) & 0x1; + } + parityBit = ~(countBits & 0x1) & 0x1; + return parityBit; +} + + + diff --git a/linux/ipcore/PdecConfig.h b/linux/ipcore/PdecConfig.h index 3d909581..0b665c6c 100644 --- a/linux/ipcore/PdecConfig.h +++ b/linux/ipcore/PdecConfig.h @@ -3,28 +3,51 @@ #include +#include "bsp_q7s/memory/LocalParameterHandler.h" +#include "bsp_q7s/fs/SdCardManager.h" #include "fsfw/returnvalues/returnvalue.h" +#include "pdec.h" /** * @brief This class generates the configuration words for the configuration memory of the PDEC * IP Cores. * - * @details Fields are initialized according to pecification in PDEC datasheet section 6.11.3.1 + * @details Fields are initialized according to specification in PDEC datasheet section 6.11.3.1 * PROM usage. * * @author J. Meier */ class PdecConfig { public: + /** + * @brief Constructor + */ PdecConfig(); virtual ~PdecConfig(); /** - * @brief Returns the configuration word by specifying the position. + * @brief Sets the memory base address pointer + */ + void setMemoryBaseAddress(uint32_t* memoryBaseAddress_); + + /** + * @brief Will write the config to the PDEC configuration memory. New config + * becomes active after resetting PDEC. + */ + ReturnValue_t write(); + + /** + * @brief Returns the value to write to the interrupt mask register. This + * value defines which interrupts should be enabled/disabled. */ - uint32_t getConfigWord(uint8_t wordNo); uint32_t getImrReg(); + ReturnValue_t setPositiveWindow(uint8_t pw); + ReturnValue_t setNegativeWindow(uint8_t nw); + + uint8_t getPositiveWindow(); + uint8_t getNegativeWindow(); + private: // TC transfer frame configuration parameters static const uint8_t VERSION_ID = 0; @@ -36,21 +59,73 @@ class PdecConfig { static const uint8_t RESERVED_FIELD_A = 0; static const uint16_t SPACECRAFT_ID = 0x3DC; static const uint16_t DUMMY_BITS = 0; - // Parameters to control the FARM for AD frames - // Set here for future use - static const uint8_t POSITIVE_WINDOW = 10; - static const uint8_t NEGATIVE_WINDOW = 151; static const uint8_t HIGH_AU_MAP_ID = 0xF; static const uint8_t ENABLE_DERANDOMIZER = 1; static const uint8_t CONFIG_WORDS_NUM = 2; + // 0x200 / 4 = 0x80 + static const uint32_t FRAME_HEADER_OFFSET = 0x80; + + static const uint32_t MAP_ADDR_LUT_OFFSET = 0xA0; + static const uint32_t MAP_CLK_FREQ_OFFSET = 0x90; + // MAP clock frequency. Must be a value between 1 and 13 otherwise the TC segment will be + // discarded + static const uint8_t MAP_CLK_FREQ = 2; + + static const uint8_t MAX_MAP_ADDR = 63; + // Writing this to the map address in the look up table will invalidate a MAP ID. + static const uint8_t NO_DESTINATION = 0; + static const uint8_t VALID_POSITION = 6; + static const uint8_t PARITY_POSITION = 7; + + /** + * TCs with map addresses (also know as Map IDs) assigned to this channel will be stored in + * the PDEC memory. + */ + static const uint8_t PM_BUFFER = 7; + + uint32_t* memoryBaseAddress = nullptr; + + // Pointer to object providing access to persistent configuration parameters + LocalParameterHandler localParameterHandler; + uint32_t configWords[CONFIG_WORDS_NUM]; bool enableTcNewIrq = true; bool enableTcAbortIrq = true; bool enableNewFarIrq = true; - void initialize(); + NVMParameterBase persistenParams; + + // Parameters to control the FARM for AD frames + // Set here for future use + uint8_t positiveWindow = 10; + uint8_t negativeWindow = 151; + + void writeFrameHeaderFirstOctet(); + void writeFrameHeaderSecondOctet(); + void writeMapConfig(); + + /** + * @brief This function calculates the entry for the configuration of the MAP ID routing. + * + * @param mapAddr The MAP ID to configure + * @param moduleId The destination module where all TCs with the map id mapAddr will be routed + * to. + * + * @details The PDEC has different modules where the TCs can be routed to. A lookup table is + * used which links the MAP ID field to the destination module. The entry for this + * lookup table is created by this function and must be stored in the configuration + * memory region of the PDEC. The entry has a specific format + */ + uint8_t calcMapAddrEntry(uint8_t moduleId); + + /** + * @brief This functions calculates the odd parity of the bits in number. + * + * @param number The number from which to calculate the odd parity. + */ + uint8_t getOddParity(uint8_t number); }; #endif /* LINUX_OBC_PDECCONFIG_H_ */ diff --git a/linux/ipcore/PdecHandler.cpp b/linux/ipcore/PdecHandler.cpp index 57d59841..3d1b9d58 100644 --- a/linux/ipcore/PdecHandler.cpp +++ b/linux/ipcore/PdecHandler.cpp @@ -22,13 +22,15 @@ using namespace pdec; uint32_t PdecHandler::CURRENT_FAR = 0; PdecHandler::PdecHandler(object_id_t objectId, object_id_t tcDestinationId, - LinuxLibgpioIF* gpioComIF, gpioId_t pdecReset, UioNames names) + LinuxLibgpioIF* gpioComIF, gpioId_t pdecReset, UioNames names, + object_id_t globalConfigHandlerId) : SystemObject(objectId), tcDestinationId(tcDestinationId), gpioComIF(gpioComIF), pdecReset(pdecReset), actionHelper(this, nullptr), - uioNames(names) { + uioNames(names), + globalConfigHandlerId(globalConfigHandlerId) { auto mqArgs = MqArgs(objectId, static_cast(this)); commandQueue = QueueFactory::instance()->createMessageQueue( QUEUE_SIZE, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); @@ -61,6 +63,8 @@ ReturnValue_t PdecHandler::initialize() { result = configMemMapper.getMappedAdress(&memoryBaseAddress, UioMapper::Permissions::READ_WRITE); if (result != returnvalue::OK) { return ObjectManagerIF::CHILD_INIT_FAILED; + } else { + pdecConfig.setMemoryBaseAddress(memoryBaseAddress); } UioMapper ramMapper(uioNames.ramMemory); result = ramMapper.getMappedAdress(&ramBaseAddress, UioMapper::Permissions::READ_WRITE); @@ -72,8 +76,19 @@ ReturnValue_t PdecHandler::initialize() { sif::error << "Can not use IRQ mode if IRQ UIO name is invalid" << std::endl; return returnvalue::FAILED; } - PdecConfig pdecConfig; - writePdecConfigDuringReset(pdecConfig); + + globalConfigHandler = ObjectManager::instance()->get(objects::GLOBAL_JSON_CFG); + if (globalConfigHandler == nullptr) { + sif::error << "PdecHandler::initialize: Invalid global config handler" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } + + pdecConfig.setGlobalConfigHandler(globalConfigHandler); + result = pdecConfig.write(); + if (result != returnvalue::OK) { + sif::error << "PdecHandler::initialize: Failed to write PDEC config" << std::endl; + return ObjectManagerIF::CHILD_INIT_FAILED; + } result = releasePdec(); if (result != returnvalue::OK) { @@ -233,26 +248,45 @@ void PdecHandler::readCommandQueue(void) { MessageQueueId_t PdecHandler::getCommandQueue() const { return commandQueue->getId(); } -void PdecHandler::writePdecConfigDuringReset(PdecConfig& pdecConfig) { - *(memoryBaseAddress + FRAME_HEADER_OFFSET) = pdecConfig.getConfigWord(0); - *(memoryBaseAddress + FRAME_HEADER_OFFSET + 1) = pdecConfig.getConfigWord(1); - - // Configure all MAP IDs as invalid - for (int idx = 0; idx <= MAX_MAP_ADDR; idx += 4) { - *(memoryBaseAddress + MAP_ADDR_LUT_OFFSET + idx / 4) = - NO_DESTINATION << 24 | NO_DESTINATION << 16 | NO_DESTINATION << 8 | NO_DESTINATION; +ReturnValue_t PdecHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) { + switch (actionId) { + case PRINT_CLCW: + printClcw(); + return EXECUTION_FINISHED; + case PRINT_PDEC_MON: + printPdecMon(); + return EXECUTION_FINISHED; + default: + return COMMAND_NOT_IMPLEMENTED; } +} - // All TCs with MAP ID 7 will be routed to the PM module (can then be read from memory) - uint8_t routeToPm = calcMapAddrEntry(PM_BUFFER); - *(memoryBaseAddress + MAP_ADDR_LUT_OFFSET + 1) = - (NO_DESTINATION << 24) | (NO_DESTINATION << 16) | (NO_DESTINATION << 8) | routeToPm; - - // Write map id clock frequencies - for (int idx = 0; idx <= MAX_MAP_ADDR; idx += 4) { - *(memoryBaseAddress + MAP_CLK_FREQ_OFFSET + idx / 4) = - MAP_CLK_FREQ << 24 | MAP_CLK_FREQ << 16 | MAP_CLK_FREQ << 8 | MAP_CLK_FREQ; +ReturnValue_t PdecHandler::getParameter(uint8_t domainId, uint8_t uniqueIdentifier, + ParameterWrapper* parameterWrapper, + const ParameterWrapper* newValues, uint16_t startAtIndex) { + if ((domainId == 0) and (uniqueIdentifier == ParameterId::POSITIVE_WINDOW)) { + uint8_t newVal = 0; + ReturnValue_t result = newValues->getElement(&newVal); + if (result != returnvalue::OK) { + return result; + } + parameterWrapper->set(); + com::setCurrentDatarate(static_cast(newVal)); + return returnvalue::OK; + } else if ((domainId == 0) and + (uniqueIdentifier == static_cast(com::ParameterId::TRANSMITTER_TIMEOUT))) { + uint8_t newVal = 0; + ReturnValue_t result = newValues->getElement(&newVal); + if (result != returnvalue::OK) { + return result; + } + parameterWrapper->set(transmitterTimeout); + transmitterTimeout = newVal; + transmitterCountdown.setTimeout(transmitterTimeout); + return returnvalue::OK; } + return returnvalue::OK; } ReturnValue_t PdecHandler::resetFarStatFlag() { @@ -518,23 +552,6 @@ void PdecHandler::printTC(uint32_t tcLength) { sif::info << tcSegmentStream.str() << std::endl; } -uint8_t PdecHandler::calcMapAddrEntry(uint8_t moduleId) { - uint8_t lutEntry = 0; - uint8_t parity = getOddParity(moduleId | (1 << VALID_POSITION)); - lutEntry = (parity << PARITY_POSITION) | (1 << VALID_POSITION) | moduleId; - return lutEntry; -} - -uint8_t PdecHandler::getOddParity(uint8_t number) { - uint8_t parityBit = 0; - uint8_t countBits = 0; - for (unsigned int idx = 0; idx < sizeof(number) * 8; idx++) { - countBits += (number >> idx) & 0x1; - } - parityBit = ~(countBits & 0x1) & 0x1; - return parityBit; -} - uint32_t PdecHandler::getClcw() { return *(registerBaseAddress + PDEC_CLCW_OFFSET); } uint32_t PdecHandler::getPdecMon() { return *(registerBaseAddress + PDEC_MON_OFFSET); } @@ -620,17 +637,3 @@ std::string PdecHandler::getMonStatusString(uint32_t status) { break; } } - -ReturnValue_t PdecHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size) { - switch (actionId) { - case PRINT_CLCW: - printClcw(); - return EXECUTION_FINISHED; - case PRINT_PDEC_MON: - printPdecMon(); - return EXECUTION_FINISHED; - default: - return COMMAND_NOT_IMPLEMENTED; - } -} diff --git a/linux/ipcore/PdecHandler.h b/linux/ipcore/PdecHandler.h index 6ebd9ce6..8664e732 100644 --- a/linux/ipcore/PdecHandler.h +++ b/linux/ipcore/PdecHandler.h @@ -8,6 +8,8 @@ #include "eive/definitions.h" #include "fsfw/action/ActionHelper.h" #include "fsfw/action/HasActionsIF.h" +#include "fsfw/parameters/HasParametersIF.h" +#include "fsfw/parameters/ParameterHelper.h" #include "fsfw/objectmanager/SystemObject.h" #include "fsfw/returnvalues/returnvalue.h" #include "fsfw/storagemanager/StorageManagerIF.h" @@ -15,6 +17,7 @@ #include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" #include "fsfw_hal/common/gpio/gpioDefinitions.h" #include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" +#include "mission/utility/GlobalConfigHandler.h" struct UioNames { const char* configMemory; @@ -41,7 +44,10 @@ struct UioNames { * * @author J. Meier */ -class PdecHandler : public SystemObject, public ExecutableObjectIF, public HasActionsIF { +class PdecHandler : public SystemObject, + public ExecutableObjectIF, + public HasActionsIF, + public HasParametersIF { public: static constexpr dur_millis_t IRQ_TIMEOUT_MS = 500; @@ -55,9 +61,10 @@ class PdecHandler : public SystemObject, public ExecutableObjectIF, public HasAc * @param pdecReset GPIO ID of GPIO connected to the reset signal of the PDEC. * @param uioConfigMemory String of uio device file same mapped to the PDEC memory space * @param uioregsiters String of uio device file same mapped to the PDEC register space + * @param globalConfigHandler Object ID of global config file handler */ PdecHandler(object_id_t objectId, object_id_t tcDestinationId, LinuxLibgpioIF* gpioComIF, - gpioId_t pdecReset, UioNames names); + gpioId_t pdecReset, UioNames names, object_id_t globalConfigHandlerId); virtual ~PdecHandler(); @@ -70,6 +77,10 @@ class PdecHandler : public SystemObject, public ExecutableObjectIF, public HasAc ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, const uint8_t* data, size_t size) override; + ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueIdentifier, + ParameterWrapper* parameterWrapper, const ParameterWrapper* newValues, + uint16_t startAtIndex) override; + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PDEC_HANDLER; //! [EXPORT] : [COMMENT] Frame acceptance report signals an invalid frame @@ -138,9 +149,6 @@ class PdecHandler : public SystemObject, public ExecutableObjectIF, public HasAc static const int REGISTER_MAP_SIZE = 0x4000; #endif /* BOARD_TE0720 == 1 */ - // 0x200 / 4 = 0x80 - static const uint32_t FRAME_HEADER_OFFSET = 0x80; - static const size_t MAX_TC_SEGMENT_SIZE = 1017; static const uint8_t MAP_ID_MASK = 0x3F; @@ -150,15 +158,6 @@ class PdecHandler : public SystemObject, public ExecutableObjectIF, public HasAc static const uint32_t PHYSICAL_RAM_BASE_ADDRESS = 0x26000000; #endif - static const uint32_t MAP_ADDR_LUT_OFFSET = 0xA0; - static const uint32_t MAP_CLK_FREQ_OFFSET = 0x90; - - static const uint8_t MAX_MAP_ADDR = 63; - // Writing this to the map address in the look up table will invalidate a MAP ID. - static const uint8_t NO_DESTINATION = 0; - static const uint8_t VALID_POSITION = 6; - static const uint8_t PARITY_POSITION = 7; - // Expected value stored in FAR register after reset static const uint32_t FAR_RESET = 0x7FE0; @@ -167,15 +166,13 @@ class PdecHandler : public SystemObject, public ExecutableObjectIF, public HasAc static const uint32_t NO_RF_MASK = 0x8000; static const uint32_t NO_BITLOCK_MASK = 0x4000; - /** - * TCs with map addresses (also know as Map IDs) assigned to this channel will be stored in - * the PDEC memory. - */ - static const uint8_t PM_BUFFER = 7; - - // MAP clock frequency. Must be a value between 1 and 13 otherwise the TC segment will be - // discarded - static const uint8_t MAP_CLK_FREQ = 2; + class ParameterId { + public: + // ID of the parameter to update the positive window of AD frames + static const uint8_t POSITIVE_WINDOW = 0; + // ID of the parameter to update the negative window of AD frames + static const uint8_t NEGATIVE_WINDOW = 1; + }; enum class FrameAna_t : uint8_t { ABANDONED_CLTU, @@ -249,6 +246,15 @@ class PdecHandler : public SystemObject, public ExecutableObjectIF, public HasAc UioNames uioNames; + // Object ID of global config file handler + object_id_t globalConfigHandlerId; + + ParameterHelper paramHelper; + + GlobalConfigHandler* globalConfigHandler = nullptr; + + PdecConfig pdecConfig; + /** * @brief Reads and handles messages stored in the commandQueue */ @@ -341,12 +347,6 @@ class PdecHandler : public SystemObject, public ExecutableObjectIF, public HasAc */ uint8_t calcMapAddrEntry(uint8_t moduleId); - /** - * @brief This functions calculates the odd parity of the bits in number. - * - * @param number The number from which to calculate the odd parity. - */ - uint8_t getOddParity(uint8_t number); /** * brief Returns the 32-bit wide communication link control word (CLCW) diff --git a/mission/config/configfile.h b/mission/config/configfile.h new file mode 100644 index 00000000..eb8fb0a5 --- /dev/null +++ b/mission/config/configfile.h @@ -0,0 +1,9 @@ +#ifndef MISSION_CONFIG_CONFIGFILE_H_ +#define MISSION_CONFIG_CONFIGFILE_H_ + +namespace configfile { + // Name of global config file relative to currently mounted SD card + static const char sdrelative[] = "config/global_config.json"; +} + +#endif /* MISSION_CONFIG_CONFIGFILE_H_ */ diff --git a/mission/system/objects/ComSubsystem.h b/mission/system/objects/ComSubsystem.h index ac8cc60f..b1bbeed9 100644 --- a/mission/system/objects/ComSubsystem.h +++ b/mission/system/objects/ComSubsystem.h @@ -50,6 +50,7 @@ class ComSubsystem : public Subsystem, public ReceivesParameterMessagesIF { // Maximum time after which the transmitter will be turned of. This is a // protection mechanism due prevent the syrlinks from overheating uint32_t transmitterTimeout = 0; + ParameterHelper paramHelper; MessageQueueIF* eventQueue = nullptr; diff --git a/mission/utility/GlobalConfigFileDefinitions.h b/mission/utility/GlobalConfigFileDefinitions.h index 2e7d133a..2c9b6b66 100644 --- a/mission/utility/GlobalConfigFileDefinitions.h +++ b/mission/utility/GlobalConfigFileDefinitions.h @@ -15,6 +15,8 @@ enum ParamIds : uint8_t { PARAM0 = 0, PARAM1 = 1, PARAM2 = 2, + PDEC_PW = 3, + PDEC_NW = 4 }; #endif /* MISSION_UTILITY_GLOBALCONFIGFILEDEFINITIONS_H_ */ diff --git a/mission/utility/GlobalConfigHandler.cpp b/mission/utility/GlobalConfigHandler.cpp index bb4b3d7d..ffd1963b 100644 --- a/mission/utility/GlobalConfigHandler.cpp +++ b/mission/utility/GlobalConfigHandler.cpp @@ -23,23 +23,24 @@ GlobalConfigHandler::GlobalConfigHandler(object_id_t objectId, std::string confi CONFIG_LOCK = MutexFactory::instance()->createMutex(); } } + ReturnValue_t GlobalConfigHandler::initialize() { ReturnValue_t result = SystemObject::initialize(); if (result != returnvalue::OK) { #if OBSW_VERBOSE_LEVEL >= 1 - sif::info << "GlobalConfigHandler::initialize: SystemObject::initialize() failed with " + sif::info << "GlobalConfigHandler::initialize: SystemObject::initialize failed with " << result << std::endl; #endif return result; } - result = ReadConfigFile(); + result = readConfigFile(); if (result != returnvalue::OK) { #if OBSW_VERBOSE_LEVEL >= 1 sif::info << "GlobalConfigHandler::initialize: Creating JSON file at " << getFullName() << std::endl; #endif - result = ResetConfigFile(); + result = resetConfigFile(); if (result != returnvalue::OK) { return result; } @@ -63,6 +64,7 @@ ReturnValue_t GlobalConfigHandler::lockConfigFile() { result = CONFIG_LOCK->lockMutex(MutexIF::TimeoutType::WAITING, 10); return result; } + ReturnValue_t GlobalConfigHandler::unlockConfigFile() { ReturnValue_t result = returnvalue::OK; result = CONFIG_LOCK->unlockMutex(); @@ -70,34 +72,21 @@ ReturnValue_t GlobalConfigHandler::unlockConfigFile() { } template -ReturnValue_t GlobalConfigHandler::setConfigFileValue(ParamIds paramID, T data) { +ReturnValue_t GlobalConfigHandler::setConfigFileValue(std::string paramName, T data) { ReturnValue_t result = returnvalue::OK; ReturnValue_t resultSet = returnvalue::OK; result = lockConfigFile(); if (result != returnvalue::OK) { #if OBSW_VERBOSE_LEVEL >= 1 - sif::info << "GlobalConfigHandler::setConfigFileValue lock mutex failed with " << result + sif::info << "GlobalConfigHandler::setConfigFileValue: Lock mutex failed with " << result << std::endl; #endif return result; } - std::string paramString; - paramString = PARAM_KEY_MAP[paramID]; - - // Check if key exists in map before setting value. No check is done in setValue! Somehow - // PARAM_KEY_MAP.count(paramID) == 0 does not work - if (paramString.empty() == true) { -#if OBSW_VERBOSE_LEVEL >= 1 - sif::info << "GlobalConfigHandler::setConfigFileValue ParamId " << PARAM_KEY_MAP[paramID] - << " not found!" << std::endl; -#endif - triggerEvent(SET_CONFIGFILEVALUE_FAILED, 1, 0); - return returnvalue::FAILED; - } - - resultSet = setValue(PARAM_KEY_MAP[paramID], data); + // If value exists it is updated otherwise a new entry will be created + resultSet = insertValue(paramName, data); if (resultSet != returnvalue::OK) { triggerEvent(SET_CONFIGFILEVALUE_FAILED, 0, 0); #if OBSW_VERBOSE_LEVEL >= 1 @@ -117,6 +106,7 @@ ReturnValue_t GlobalConfigHandler::setConfigFileValue(ParamIds paramID, T data) return resultSet; } + template ReturnValue_t GlobalConfigHandler::getConfigFileValue(ParamIds paramID, T& data) { ReturnValue_t result = returnvalue::OK; @@ -161,8 +151,10 @@ ReturnValue_t GlobalConfigHandler::resetConfigFileValues() { #endif return result; } - insertValue(PARAM_KEY_MAP[PARAM0], PARAM0_DEFAULT); - insertValue(PARAM_KEY_MAP[PARAM1], PARAM1_DEFAULT); + + for(const auto& keyMap: PARAM_KEY_MAP) { + insertValue(keyMap.second, PARAM0_DEFAULT); + } result = unlockConfigFile(); if (result != returnvalue::OK) { @@ -174,7 +166,8 @@ ReturnValue_t GlobalConfigHandler::resetConfigFileValues() { } return result; } -ReturnValue_t GlobalConfigHandler::WriteConfigFile() { + +ReturnValue_t GlobalConfigHandler::writeConfigFile() { ReturnValue_t result = returnvalue::OK; ReturnValue_t resultWrite = returnvalue::OK; result = lockConfigFile(); @@ -205,7 +198,8 @@ ReturnValue_t GlobalConfigHandler::WriteConfigFile() { } return resultWrite; } -ReturnValue_t GlobalConfigHandler::ReadConfigFile() { + +ReturnValue_t GlobalConfigHandler::readConfigFile() { ReturnValue_t result = returnvalue::OK; ReturnValue_t resultRead = returnvalue::OK; result = lockConfigFile(); @@ -237,7 +231,8 @@ ReturnValue_t GlobalConfigHandler::ReadConfigFile() { return resultRead; } -ReturnValue_t GlobalConfigHandler::ResetConfigFile() { + +ReturnValue_t GlobalConfigHandler::resetConfigFile() { ReturnValue_t result = returnvalue::OK; result = resetConfigFileValues(); if (result != returnvalue::OK) { @@ -253,7 +248,7 @@ ReturnValue_t GlobalConfigHandler::ResetConfigFile() { ReturnValue_t GlobalConfigHandler::setConfigFileName(std::string configFileName) { ReturnValue_t result = returnvalue::OK; setFullName(configFileName); - result = ResetConfigFile(); + result = resetConfigFile(); return result; } std::string GlobalConfigHandler::getConfigFileName() { return getFullName(); } diff --git a/mission/utility/GlobalConfigHandler.h b/mission/utility/GlobalConfigHandler.h index 80e141c6..1a2fe07f 100644 --- a/mission/utility/GlobalConfigHandler.h +++ b/mission/utility/GlobalConfigHandler.h @@ -15,6 +15,7 @@ #include #include +#include #include #include @@ -24,10 +25,6 @@ #include "fsfw/parameters/ParameterHelper.h" #include "mission/memory/NVMParameterBase.h" -static std::map PARAM_KEY_MAP = { - {PARAM0, "Parameter0"}, - {PARAM1, "Parameter1"}, -}; /* * Idea: This class is intended to be used as a subclass for the Core Controller. * Its tasks is managing a configuration JSON file containing config values important for various @@ -54,12 +51,12 @@ class GlobalConfigHandler : public SystemObject, ReturnValue_t initialize(); template - ReturnValue_t setConfigFileValue(ParamIds paramID, T data); + ReturnValue_t setConfigFileValue(std::string paramName, T data); template - ReturnValue_t getConfigFileValue(ParamIds paramID, T& data); + ReturnValue_t getConfigFileValue(std::string paramName, T& data); - ReturnValue_t ResetConfigFile(); - ReturnValue_t WriteConfigFile(); + ReturnValue_t resetConfigFile(); + ReturnValue_t writeConfigFile(); std::string getConfigFileName(); private: @@ -71,7 +68,7 @@ class GlobalConfigHandler : public SystemObject, ReturnValue_t setConfigFileName(std::string configFileName); - ReturnValue_t ReadConfigFile(); + ReturnValue_t readConfigFile(); MessageQueueIF* commandQueue; }; From 59a0a740327ce1b438460cfcc204d42d58602b10 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 13 Feb 2023 11:49:26 +0100 Subject: [PATCH 085/373] start adding assy components for EM --- bsp_q7s/core/ObjectFactory.cpp | 21 ++++---------- bsp_q7s/fmObjectFactory.cpp | 2 +- dummies/helpers.cpp | 51 ++++++++++++++++++++++----------- linux/ObjectFactory.cpp | 23 +++++---------- linux/ObjectFactory.h | 2 +- mission/core/GenericFactory.cpp | 41 ++++++++++++++++++++++++++ mission/core/GenericFactory.h | 7 +++++ 7 files changed, 98 insertions(+), 49 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 17170252..65a12ba7 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -692,33 +692,24 @@ void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF, std::array rwIds = {objects::RW1, objects::RW2, objects::RW3, objects::RW4}; std::array rwGpioIds = {gpioIds::EN_RW1, gpioIds::EN_RW2, gpioIds::EN_RW3, gpioIds::EN_RW4}; - std::array rws = {}; + std::array rws = {}; for (uint8_t idx = 0; idx < rwCookies.size(); idx++) { rwCookies[idx] = new SpiCookie(rwCookieParams[idx].first, rwCookieParams[idx].second, RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, nullptr); - rws[idx] = new RwHandler(rwIds[idx], objects::SPI_RW_COM_IF, rwCookies[idx], gpioComIF, - rwGpioIds[idx]); + auto* rwHandler = new RwHandler(rwIds[idx], objects::SPI_RW_COM_IF, rwCookies[idx], gpioComIF, + rwGpioIds[idx]); rwCookies[idx]->setCallbackArgs(rws[idx]); #if OBSW_TEST_RW == 1 rws[idx]->setStartUpImmediately(); #endif #if OBSW_DEBUG_RW == 1 - rws[idx]->setDebugMode(true); + rwHandler->setDebugMode(true); #endif + rws[idx] = rwHandler; } - RwHelper rwHelper(rwIds); - auto* rwAss = - new RwAssembly(objects::RW_ASS, pwrSwitcher, pcdu::Switches::PDU2_CH2_RW_5V, rwHelper); - for (uint8_t idx = 0; idx < rws.size(); idx++) { - ReturnValue_t result = rws[idx]->connectModeTreeParent(*rwAss); - if (result != returnvalue::OK) { - sif::error << "Connecting RW " << static_cast(idx) << " to RW assembly failed" - << std::endl; - } - } - rwAss->connectModeTreeParent(satsystem::acs::ACS_SUBSYSTEM); + createRwAssy(*pwrSwitcher, pcdu::Switches::PDU2_CH2_RW_5V, rws, rwIds); #endif /* OBSW_ADD_RW == 1 */ } diff --git a/bsp_q7s/fmObjectFactory.cpp b/bsp_q7s/fmObjectFactory.cpp index 4ca45e43..034b7cc1 100644 --- a/bsp_q7s/fmObjectFactory.cpp +++ b/bsp_q7s/fmObjectFactory.cpp @@ -39,7 +39,7 @@ void ObjectFactory::produce(void* args) { createRadSensorComponent(gpioComIF, *stackHandler); #endif #if OBSW_ADD_SUN_SENSORS == 1 - createSunSensorComponents(gpioComIF, spiMainComIF, pwrSwitcher, q7s::SPI_DEFAULT_DEV, true); + createSunSensorComponents(gpioComIF, spiMainComIF, *pwrSwitcher, q7s::SPI_DEFAULT_DEV, true); #endif #if OBSW_ADD_ACS_BOARD == 1 diff --git a/dummies/helpers.cpp b/dummies/helpers.cpp index d6bbf70f..20d1555b 100644 --- a/dummies/helpers.cpp +++ b/dummies/helpers.cpp @@ -24,6 +24,8 @@ #include "TemperatureSensorInserter.h" #include "dummies/Max31865Dummy.h" #include "dummies/Tmp1075Dummy.h" +#include "mission/core/GenericFactory.h" +#include "mission/devices/devicedefinitions/GomspaceDefinitions.h" #include "mission/system/tree/acsModeTree.h" using namespace dummy; @@ -38,10 +40,13 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitch) { if (cfg.addRtdComIFDummy) { new ComIFDummy(objects::SPI_RTD_COM_IF); } - new RwDummy(objects::RW1, objects::DUMMY_COM_IF, comCookieDummy); - new RwDummy(objects::RW2, objects::DUMMY_COM_IF, comCookieDummy); - new RwDummy(objects::RW3, objects::DUMMY_COM_IF, comCookieDummy); - new RwDummy(objects::RW4, objects::DUMMY_COM_IF, comCookieDummy); + std::array rwIds = {objects::RW1, objects::RW2, objects::RW3, objects::RW4}; + std::array rws; + rws[0] = new RwDummy(objects::RW1, objects::DUMMY_COM_IF, comCookieDummy); + rws[1] = new RwDummy(objects::RW2, objects::DUMMY_COM_IF, comCookieDummy); + rws[2] = new RwDummy(objects::RW3, objects::DUMMY_COM_IF, comCookieDummy); + rws[3] = new RwDummy(objects::RW4, objects::DUMMY_COM_IF, comCookieDummy); + ObjectFactory::createRwAssy(pwrSwitch, pcdu::Switches::PDU2_CH2_RW_5V, rws, rwIds); new SaDeplDummy(objects::SOLAR_ARRAY_DEPL_HANDLER); new StarTrackerDummy(objects::STAR_TRACKER, objects::DUMMY_COM_IF, comCookieDummy); if (cfg.addSyrlinksDummies) { @@ -70,18 +75,32 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitch) { } if (cfg.addSusDummies) { - new SusDummy(objects::SUS_0_N_LOC_XFYFZM_PT_XF, objects::DUMMY_COM_IF, comCookieDummy); - new SusDummy(objects::SUS_1_N_LOC_XBYFZM_PT_XB, objects::DUMMY_COM_IF, comCookieDummy); - new SusDummy(objects::SUS_2_N_LOC_XFYBZB_PT_YB, objects::DUMMY_COM_IF, comCookieDummy); - new SusDummy(objects::SUS_3_N_LOC_XFYBZF_PT_YF, objects::DUMMY_COM_IF, comCookieDummy); - new SusDummy(objects::SUS_4_N_LOC_XMYFZF_PT_ZF, objects::DUMMY_COM_IF, comCookieDummy); - new SusDummy(objects::SUS_5_N_LOC_XFYMZB_PT_ZB, objects::DUMMY_COM_IF, comCookieDummy); - new SusDummy(objects::SUS_6_R_LOC_XFYBZM_PT_XF, objects::DUMMY_COM_IF, comCookieDummy); - new SusDummy(objects::SUS_7_R_LOC_XBYBZM_PT_XB, objects::DUMMY_COM_IF, comCookieDummy); - new SusDummy(objects::SUS_8_R_LOC_XBYBZB_PT_YB, objects::DUMMY_COM_IF, comCookieDummy); - new SusDummy(objects::SUS_9_R_LOC_XBYBZB_PT_YF, objects::DUMMY_COM_IF, comCookieDummy); - new SusDummy(objects::SUS_10_N_LOC_XMYBZF_PT_ZF, objects::DUMMY_COM_IF, comCookieDummy); - new SusDummy(objects::SUS_11_R_LOC_XBYMZB_PT_ZB, objects::DUMMY_COM_IF, comCookieDummy); + std::array suses; + suses[0] = + new SusDummy(objects::SUS_0_N_LOC_XFYFZM_PT_XF, objects::DUMMY_COM_IF, comCookieDummy); + suses[1] = + new SusDummy(objects::SUS_1_N_LOC_XBYFZM_PT_XB, objects::DUMMY_COM_IF, comCookieDummy); + suses[2] = + new SusDummy(objects::SUS_2_N_LOC_XFYBZB_PT_YB, objects::DUMMY_COM_IF, comCookieDummy); + suses[3] = + new SusDummy(objects::SUS_3_N_LOC_XFYBZF_PT_YF, objects::DUMMY_COM_IF, comCookieDummy); + suses[4] = + new SusDummy(objects::SUS_4_N_LOC_XMYFZF_PT_ZF, objects::DUMMY_COM_IF, comCookieDummy); + suses[5] = + new SusDummy(objects::SUS_5_N_LOC_XFYMZB_PT_ZB, objects::DUMMY_COM_IF, comCookieDummy); + suses[6] = + new SusDummy(objects::SUS_6_R_LOC_XFYBZM_PT_XF, objects::DUMMY_COM_IF, comCookieDummy); + suses[7] = + new SusDummy(objects::SUS_7_R_LOC_XBYBZM_PT_XB, objects::DUMMY_COM_IF, comCookieDummy); + suses[8] = + new SusDummy(objects::SUS_8_R_LOC_XBYBZB_PT_YB, objects::DUMMY_COM_IF, comCookieDummy); + suses[9] = + new SusDummy(objects::SUS_9_R_LOC_XBYBZB_PT_YF, objects::DUMMY_COM_IF, comCookieDummy); + suses[10] = + new SusDummy(objects::SUS_10_N_LOC_XMYBZF_PT_ZF, objects::DUMMY_COM_IF, comCookieDummy); + suses[11] = + new SusDummy(objects::SUS_11_R_LOC_XBYMZB_PT_ZB, objects::DUMMY_COM_IF, comCookieDummy); + ObjectFactory::createSusAssy(pwrSwitch, suses); } if (cfg.addTempSensorDummies) { diff --git a/linux/ObjectFactory.cpp b/linux/ObjectFactory.cpp index 1003ead4..add6a755 100644 --- a/linux/ObjectFactory.cpp +++ b/linux/ObjectFactory.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -29,7 +30,7 @@ #include "mission/system/tree/tcsModeTree.h" void ObjectFactory::createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiComIF, - PowerSwitchIF* pwrSwitcher, std::string spiDev, + PowerSwitchIF& pwrSwitcher, std::string spiDev, bool swap0And6) { using namespace gpio; GpioCookie* gpioCookieSus = new GpioCookie(); @@ -173,22 +174,8 @@ void ObjectFactory::createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiCo fdir = new SusFdir(objects::SUS_11_R_LOC_XBYMZB_PT_ZB); susHandlers[11]->setCustomFdir(fdir); - std::array susIds = { - objects::SUS_0_N_LOC_XFYFZM_PT_XF, objects::SUS_1_N_LOC_XBYFZM_PT_XB, - objects::SUS_2_N_LOC_XFYBZB_PT_YB, objects::SUS_3_N_LOC_XFYBZF_PT_YF, - objects::SUS_4_N_LOC_XMYFZF_PT_ZF, objects::SUS_5_N_LOC_XFYMZB_PT_ZB, - objects::SUS_6_R_LOC_XFYBZM_PT_XF, objects::SUS_7_R_LOC_XBYBZM_PT_XB, - objects::SUS_8_R_LOC_XBYBZB_PT_YB, objects::SUS_9_R_LOC_XBYBZB_PT_YF, - objects::SUS_10_N_LOC_XMYBZF_PT_ZF, objects::SUS_11_R_LOC_XBYMZB_PT_ZB}; - SusAssHelper susAssHelper = SusAssHelper(susIds); - auto susAss = new SusAssembly(objects::SUS_BOARD_ASS, pwrSwitcher, susAssHelper); for (auto& sus : susHandlers) { if (sus != nullptr) { - ReturnValue_t result = sus->connectModeTreeParent(*susAss); - if (result != returnvalue::OK) { - sif::error << "Connecting SUS " << sus->getObjectId() << " to SUS assembly failed" - << std::endl; - } #if OBSW_TEST_SUS == 1 sus->setStartUpImmediately(); sus->setToGoToNormalMode(true); @@ -198,7 +185,11 @@ void ObjectFactory::createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiCo #endif } } - susAss->connectModeTreeParent(satsystem::acs::ACS_SUBSYSTEM); + std::array susDhbs; + for (unsigned i = 0; i < susDhbs.size(); i++) { + susDhbs[i] = susHandlers[i]; + } + createSusAssy(pwrSwitcher, susDhbs); #endif /* OBSW_ADD_SUN_SENSORS == 1 */ } diff --git a/linux/ObjectFactory.h b/linux/ObjectFactory.h index c7b12f9b..0a7ab516 100644 --- a/linux/ObjectFactory.h +++ b/linux/ObjectFactory.h @@ -20,7 +20,7 @@ class AcsController; namespace ObjectFactory { -void createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiComIF, PowerSwitchIF* pwrSwitcher, +void createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiComIF, PowerSwitchIF& pwrSwitcher, std::string spiDev, bool swap0And6); void createRtdComponents(std::string spiDev, GpioIF* gpioComIF, PowerSwitchIF* pwrSwitcher, SpiComIF* comIF); diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index 8c05ed4f..56ca3d97 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include #include #include @@ -35,6 +37,8 @@ #include "eive/definitions.h" #include "fsfw/pus/Service11TelecommandScheduling.h" #include "mission/cfdp/Config.h" +#include "mission/system/objects/RwAssembly.h" +#include "mission/system/tree/acsModeTree.h" #include "mission/system/tree/tcsModeTree.h" #include "objects/systemObjectList.h" #include "tmtc/pusIds.h" @@ -218,3 +222,40 @@ void ObjectFactory::createThermalController(HeaterHandler& heaterHandler) { auto* tcsCtrl = new ThermalController(objects::THERMAL_CONTROLLER, heaterHandler); tcsCtrl->connectModeTreeParent(satsystem::tcs::SUBSYSTEM); } +void ObjectFactory::createRwAssy(PowerSwitchIF& pwrSwitcher, power::Switch_t theSwitch, + std::array rws, + std::array rwIds) { + RwHelper rwHelper(rwIds); + auto* rwAss = new RwAssembly(objects::RW_ASS, &pwrSwitcher, theSwitch, rwHelper); + for (uint8_t idx = 0; idx < rwIds.size(); idx++) { + ReturnValue_t result = rws[idx]->connectModeTreeParent(*rwAss); + if (result != returnvalue::OK) { + sif::error << "Connecting RW " << static_cast(idx) << " to RW assembly failed" + << std::endl; + } + } + rwAss->connectModeTreeParent(satsystem::acs::ACS_SUBSYSTEM); +} + +void ObjectFactory::createSusAssy(PowerSwitchIF& pwrSwitcher, + std::array suses) { + std::array susIds = { + objects::SUS_0_N_LOC_XFYFZM_PT_XF, objects::SUS_1_N_LOC_XBYFZM_PT_XB, + objects::SUS_2_N_LOC_XFYBZB_PT_YB, objects::SUS_3_N_LOC_XFYBZF_PT_YF, + objects::SUS_4_N_LOC_XMYFZF_PT_ZF, objects::SUS_5_N_LOC_XFYMZB_PT_ZB, + objects::SUS_6_R_LOC_XFYBZM_PT_XF, objects::SUS_7_R_LOC_XBYBZM_PT_XB, + objects::SUS_8_R_LOC_XBYBZB_PT_YB, objects::SUS_9_R_LOC_XBYBZB_PT_YF, + objects::SUS_10_N_LOC_XMYBZF_PT_ZF, objects::SUS_11_R_LOC_XBYMZB_PT_ZB}; + SusAssHelper susAssHelper = SusAssHelper(susIds); + auto susAss = new SusAssembly(objects::SUS_BOARD_ASS, &pwrSwitcher, susAssHelper); + for (auto& sus : suses) { + if (sus != nullptr) { + ReturnValue_t result = sus->connectModeTreeParent(*susAss); + if (result != returnvalue::OK) { + sif::error << "Connecting SUS " << sus->getObjectId() << " to SUS assembly failed" + << std::endl; + } + } + } + susAss->connectModeTreeParent(satsystem::acs::ACS_SUBSYSTEM); +} diff --git a/mission/core/GenericFactory.h b/mission/core/GenericFactory.h index 04802d51..89d7f0d5 100644 --- a/mission/core/GenericFactory.h +++ b/mission/core/GenericFactory.h @@ -1,6 +1,9 @@ #ifndef MISSION_CORE_GENERICFACTORY_H_ #define MISSION_CORE_GENERICFACTORY_H_ +#include + +#include "fsfw/objectmanager/SystemObjectIF.h" #include "fsfw/power/PowerSwitchIF.h" #include "fsfw_hal/common/gpio/GpioIF.h" @@ -17,6 +20,10 @@ void createGenericHeaterComponents(GpioIF& gpioIF, PowerSwitchIF& pwrSwitcher, HeaterHandler*& heaterHandler); void createThermalController(HeaterHandler& heaterHandler); +void createRwAssy(PowerSwitchIF& pwrSwitcher, power::Switch_t theSwitch, + std::array rws, std::array rwIds); +void createSusAssy(PowerSwitchIF& pwrSwitcher, std::array suses); + } // namespace ObjectFactory #endif /* MISSION_CORE_GENERICFACTORY_H_ */ From 97a001a1da86ce464eddfb3bffc989bbc0c80950 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 13 Feb 2023 13:53:13 +0100 Subject: [PATCH 086/373] continue satsytem for EM --- bsp_q7s/core/ObjectFactory.cpp | 37 +++++++---------------- bsp_q7s/core/ObjectFactory.h | 2 +- bsp_q7s/fmObjectFactory.cpp | 2 +- dummies/CMakeLists.txt | 3 +- dummies/GpsCtrlDummy.cpp | 3 ++ dummies/GpsCtrlDummy.h | 12 ++++++++ dummies/{GpsDummy.cpp => GpsDhbDummy.cpp} | 27 ++++++++--------- dummies/{GpsDummy.h => GpsDhbDummy.h} | 12 ++++---- dummies/helpers.cpp | 30 +++++++++--------- dummies/helpers.h | 2 +- fsfw | 2 +- mission/core/GenericFactory.cpp | 22 ++++++++++++++ mission/core/GenericFactory.h | 3 ++ 13 files changed, 92 insertions(+), 65 deletions(-) create mode 100644 dummies/GpsCtrlDummy.cpp create mode 100644 dummies/GpsCtrlDummy.h rename dummies/{GpsDummy.cpp => GpsDhbDummy.cpp} (64%) rename dummies/{GpsDummy.h => GpsDhbDummy.h} (82%) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 65a12ba7..16ba3325 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -239,10 +239,10 @@ ReturnValue_t ObjectFactory::createRadSensorComponent(LinuxLibgpioIF* gpioComIF, } void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialComIF* uartComIF, - PowerSwitchIF* pwrSwitcher) { + PowerSwitchIF& pwrSwitcher) { using namespace gpio; GpioCookie* gpioCookieAcsBoard = new GpioCookie(); - std::vector> assemblyChildren; + std::array assemblyChildren; std::stringstream consumer; GpiodRegularByLineName* gpio = nullptr; @@ -352,7 +352,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialCo objects::MGM_0_LIS3_HANDLER, objects::SPI_MAIN_COM_IF, spiCookie, spi::LIS3_TRANSITION_DELAY); fdir = new AcsBoardFdir(objects::MGM_0_LIS3_HANDLER); mgmLis3Handler0->setCustomFdir(fdir); - assemblyChildren.push_back(*mgmLis3Handler0); + assemblyChildren[0] = mgmLis3Handler0; #if OBSW_TEST_ACS == 1 mgmLis3Handler->setStartUpImmediately(); mgmLis3Handler->setToGoToNormalMode(true); @@ -369,7 +369,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialCo spi::RM3100_TRANSITION_DELAY); fdir = new AcsBoardFdir(objects::MGM_1_RM3100_HANDLER); mgmRm3100Handler1->setCustomFdir(fdir); - assemblyChildren.push_back(*mgmRm3100Handler1); + assemblyChildren[1] = mgmRm3100Handler1; #if OBSW_TEST_ACS == 1 mgmRm3100Handler->setStartUpImmediately(); mgmRm3100Handler->setToGoToNormalMode(true); @@ -385,7 +385,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialCo objects::MGM_2_LIS3_HANDLER, objects::SPI_MAIN_COM_IF, spiCookie, spi::LIS3_TRANSITION_DELAY); fdir = new AcsBoardFdir(objects::MGM_2_LIS3_HANDLER); mgmLis3Handler2->setCustomFdir(fdir); - assemblyChildren.push_back(*mgmLis3Handler2); + assemblyChildren[2] = mgmLis3Handler2; #if OBSW_TEST_ACS == 1 mgmLis3Handler->setStartUpImmediately(); mgmLis3Handler->setToGoToNormalMode(true); @@ -402,7 +402,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialCo spi::RM3100_TRANSITION_DELAY); fdir = new AcsBoardFdir(objects::MGM_3_RM3100_HANDLER); mgmRm3100Handler3->setCustomFdir(fdir); - assemblyChildren.push_back(*mgmRm3100Handler3); + assemblyChildren[3] = mgmRm3100Handler3; #if OBSW_TEST_ACS == 1 mgmRm3100Handler->setStartUpImmediately(); mgmRm3100Handler->setToGoToNormalMode(true); @@ -421,7 +421,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialCo ADIS1650X::Type::ADIS16505); fdir = new AcsBoardFdir(objects::GYRO_0_ADIS_HANDLER); adisHandler->setCustomFdir(fdir); - assemblyChildren.push_back(*adisHandler); + assemblyChildren[4] = adisHandler; #if OBSW_TEST_ACS == 1 adisHandler->setStartUpImmediately(); adisHandler->setToGoToNormalModeImmediately(); @@ -437,7 +437,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialCo objects::GYRO_1_L3G_HANDLER, objects::SPI_MAIN_COM_IF, spiCookie, spi::L3G_TRANSITION_DELAY); fdir = new AcsBoardFdir(objects::GYRO_1_L3G_HANDLER); gyroL3gHandler1->setCustomFdir(fdir); - assemblyChildren.push_back(*gyroL3gHandler1); + assemblyChildren[5] = gyroL3gHandler1; #if OBSW_TEST_ACS == 1 gyroL3gHandler->setStartUpImmediately(); gyroL3gHandler->setToGoToNormalMode(true); @@ -454,7 +454,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialCo spiCookie, ADIS1650X::Type::ADIS16505); fdir = new AcsBoardFdir(objects::GYRO_2_ADIS_HANDLER); adisHandler->setCustomFdir(fdir); - assemblyChildren.push_back(*adisHandler); + assemblyChildren[6] = adisHandler; #if OBSW_TEST_ACS == 1 adisHandler->setStartUpImmediately(); adisHandler->setToGoToNormalModeImmediately(); @@ -467,7 +467,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialCo objects::GYRO_3_L3G_HANDLER, objects::SPI_MAIN_COM_IF, spiCookie, spi::L3G_TRANSITION_DELAY); fdir = new AcsBoardFdir(objects::GYRO_3_L3G_HANDLER); gyroL3gHandler3->setCustomFdir(fdir); - assemblyChildren.push_back(*gyroL3gHandler3); + assemblyChildren[7] = gyroL3gHandler3; #if OBSW_TEST_ACS == 1 gyroL3gHandler->setStartUpImmediately(); gyroL3gHandler->setToGoToNormalMode(true); @@ -485,22 +485,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialCo new GpsHyperionLinuxController(objects::GPS_CONTROLLER, objects::NO_OBJECT, debugGps); gpsCtrl->setResetPinTriggerFunction(gps::triggerGpioResetPin, &RESET_ARGS_GNSS); - AcsBoardHelper acsBoardHelper = AcsBoardHelper( - objects::MGM_0_LIS3_HANDLER, objects::MGM_1_RM3100_HANDLER, objects::MGM_2_LIS3_HANDLER, - objects::MGM_3_RM3100_HANDLER, objects::GYRO_0_ADIS_HANDLER, objects::GYRO_1_L3G_HANDLER, - objects::GYRO_2_ADIS_HANDLER, objects::GYRO_3_L3G_HANDLER, objects::GPS_CONTROLLER); - auto acsAss = - new AcsBoardAssembly(objects::ACS_BOARD_ASS, pwrSwitcher, acsBoardHelper, gpioComIF); - static_cast(acsAss); - for (auto& assChild : assemblyChildren) { - ReturnValue_t result = assChild.get().connectModeTreeParent(*acsAss); - if (result != returnvalue::OK) { - sif::error << "Connecting assembly for ACS board component " << assChild.get().getObjectId() - << " failed" << std::endl; - } - } - gpsCtrl->connectModeTreeParent(*acsAss); - acsAss->connectModeTreeParent(satsystem::acs::ACS_SUBSYSTEM); + ObjectFactory::createAcsBoardAssy(pwrSwitcher, assemblyChildren, gpsCtrl, gpioComIF); #endif /* OBSW_ADD_ACS_HANDLERS == 1 */ } diff --git a/bsp_q7s/core/ObjectFactory.h b/bsp_q7s/core/ObjectFactory.h index 61b629c8..9d0e4ea3 100644 --- a/bsp_q7s/core/ObjectFactory.h +++ b/bsp_q7s/core/ObjectFactory.h @@ -33,7 +33,7 @@ void createPlPcduComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* spiComIF, void createTmpComponents(); ReturnValue_t createRadSensorComponent(LinuxLibgpioIF* gpioComIF, Stack5VHandler& handler); void createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialComIF* uartComIF, - PowerSwitchIF* pwrSwitcher); + PowerSwitchIF& pwrSwitcher); void createHeaterComponents(GpioIF* gpioIF, PowerSwitchIF* pwrSwitcher, HealthTableIF* healthTable, HeaterHandler*& heaterHandler); void createImtqComponents(PowerSwitchIF* pwrSwitcher); diff --git a/bsp_q7s/fmObjectFactory.cpp b/bsp_q7s/fmObjectFactory.cpp index 034b7cc1..f04766eb 100644 --- a/bsp_q7s/fmObjectFactory.cpp +++ b/bsp_q7s/fmObjectFactory.cpp @@ -43,7 +43,7 @@ void ObjectFactory::produce(void* args) { #endif #if OBSW_ADD_ACS_BOARD == 1 - createAcsBoardComponents(gpioComIF, uartComIF, pwrSwitcher); + createAcsBoardComponents(gpioComIF, uartComIF, *pwrSwitcher); #endif HeaterHandler* heaterHandler; createHeaterComponents(gpioComIF, pwrSwitcher, healthTable, heaterHandler); diff --git a/dummies/CMakeLists.txt b/dummies/CMakeLists.txt index 330aecfe..38527dd6 100644 --- a/dummies/CMakeLists.txt +++ b/dummies/CMakeLists.txt @@ -14,7 +14,8 @@ target_sources( PduDummy.cpp P60DockDummy.cpp SaDeploymentDummy.cpp - GpsDummy.cpp + GpsDhbDummy.cpp + GpsCtrlDummy.cpp GyroAdisDummy.cpp GyroL3GD20Dummy.cpp MgmLIS3MDLDummy.cpp diff --git a/dummies/GpsCtrlDummy.cpp b/dummies/GpsCtrlDummy.cpp new file mode 100644 index 00000000..3a1f61ba --- /dev/null +++ b/dummies/GpsCtrlDummy.cpp @@ -0,0 +1,3 @@ +#include "GpsCtrlDummy.h" + +GpsCtrlDummy::GpsCtrlDummy(object_id_t objectId): ExtendedControllerBase(objectId, 20) {} diff --git a/dummies/GpsCtrlDummy.h b/dummies/GpsCtrlDummy.h new file mode 100644 index 00000000..3d6f40bc --- /dev/null +++ b/dummies/GpsCtrlDummy.h @@ -0,0 +1,12 @@ +#ifndef DUMMIES_GPSCTRLDUMMY_H_ +#define DUMMIES_GPSCTRLDUMMY_H_ + +#include + +class GpsCtrlDummy: public ExtendedControllerBase { +public: + GpsCtrlDummy(object_id_t objectId); +private: +}; + +#endif /* DUMMIES_GPSCTRLDUMMY_H_ */ diff --git a/dummies/GpsDummy.cpp b/dummies/GpsDhbDummy.cpp similarity index 64% rename from dummies/GpsDummy.cpp rename to dummies/GpsDhbDummy.cpp index 893e8464..84c82da4 100644 --- a/dummies/GpsDummy.cpp +++ b/dummies/GpsDhbDummy.cpp @@ -1,41 +1,40 @@ -#include "GpsDummy.h" - +#include #include -GpsDummy::GpsDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie) +GpsDhbDummy::GpsDhbDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie) : DeviceHandlerBase(objectId, comif, comCookie) {} -GpsDummy::~GpsDummy() {} +GpsDhbDummy::~GpsDhbDummy() {} -void GpsDummy::doStartUp() {} +void GpsDhbDummy::doStartUp() {} -void GpsDummy::doShutDown() {} +void GpsDhbDummy::doShutDown() {} -ReturnValue_t GpsDummy::buildNormalDeviceCommand(DeviceCommandId_t *id) { return NOTHING_TO_SEND; } +ReturnValue_t GpsDhbDummy::buildNormalDeviceCommand(DeviceCommandId_t *id) { return NOTHING_TO_SEND; } -ReturnValue_t GpsDummy::buildTransitionDeviceCommand(DeviceCommandId_t *id) { +ReturnValue_t GpsDhbDummy::buildTransitionDeviceCommand(DeviceCommandId_t *id) { return NOTHING_TO_SEND; } -ReturnValue_t GpsDummy::buildCommandFromCommand(DeviceCommandId_t deviceCommand, +ReturnValue_t GpsDhbDummy::buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData, size_t commandDataLen) { return returnvalue::OK; } -ReturnValue_t GpsDummy::scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId, +ReturnValue_t GpsDhbDummy::scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId, size_t *foundLen) { return returnvalue::OK; } -ReturnValue_t GpsDummy::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { +ReturnValue_t GpsDhbDummy::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { return returnvalue::OK; } -void GpsDummy::fillCommandAndReplyMap() {} +void GpsDhbDummy::fillCommandAndReplyMap() {} -uint32_t GpsDummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } +uint32_t GpsDhbDummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } -ReturnValue_t GpsDummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, +ReturnValue_t GpsDhbDummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { localDataPoolMap.emplace(GpsHyperion::LATITUDE, new PoolEntry({0.0}, 1)); localDataPoolMap.emplace(GpsHyperion::LONGITUDE, new PoolEntry({0.0}, 1)); diff --git a/dummies/GpsDummy.h b/dummies/GpsDhbDummy.h similarity index 82% rename from dummies/GpsDummy.h rename to dummies/GpsDhbDummy.h index b32b7f17..a1df7e45 100644 --- a/dummies/GpsDummy.h +++ b/dummies/GpsDhbDummy.h @@ -1,9 +1,9 @@ -#ifndef DUMMIES_GPSDUMMY_H_ -#define DUMMIES_GPSDUMMY_H_ +#ifndef DUMMIES_GPSDHBDUMMY_H_ +#define DUMMIES_GPSDHBDUMMY_H_ #include -class GpsDummy : public DeviceHandlerBase { +class GpsDhbDummy : public DeviceHandlerBase { public: static const DeviceCommandId_t SIMPLE_COMMAND = 1; static const DeviceCommandId_t PERIODIC_REPLY = 2; @@ -11,8 +11,8 @@ class GpsDummy : public DeviceHandlerBase { static const uint8_t SIMPLE_COMMAND_DATA = 1; static const uint8_t PERIODIC_REPLY_DATA = 2; - GpsDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie); - virtual ~GpsDummy(); + GpsDhbDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie); + virtual ~GpsDhbDummy(); protected: void doStartUp() override; @@ -30,4 +30,4 @@ class GpsDummy : public DeviceHandlerBase { LocalDataPoolManager &poolManager) override; }; -#endif /* DUMMIES_GPSDUMMY_H_ */ +#endif /* DUMMIES_GPSDHBDUMMY_H_ */ diff --git a/dummies/helpers.cpp b/dummies/helpers.cpp index 20d1555b..1fd8a37c 100644 --- a/dummies/helpers.cpp +++ b/dummies/helpers.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include @@ -30,7 +30,7 @@ using namespace dummy; -void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitch) { +void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitcher, GpioIF* gpioIF) { new ComIFDummy(objects::DUMMY_COM_IF); auto* comCookieDummy = new ComCookieDummy(); new BpxDummy(objects::BPX_BATT_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); @@ -46,7 +46,7 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitch) { rws[1] = new RwDummy(objects::RW2, objects::DUMMY_COM_IF, comCookieDummy); rws[2] = new RwDummy(objects::RW3, objects::DUMMY_COM_IF, comCookieDummy); rws[3] = new RwDummy(objects::RW4, objects::DUMMY_COM_IF, comCookieDummy); - ObjectFactory::createRwAssy(pwrSwitch, pcdu::Switches::PDU2_CH2_RW_5V, rws, rwIds); + ObjectFactory::createRwAssy(pwrSwitcher, pcdu::Switches::PDU2_CH2_RW_5V, rws, rwIds); new SaDeplDummy(objects::SOLAR_ARRAY_DEPL_HANDLER); new StarTrackerDummy(objects::STAR_TRACKER, objects::DUMMY_COM_IF, comCookieDummy); if (cfg.addSyrlinksDummies) { @@ -63,15 +63,17 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitch) { } if (cfg.addAcsBoardDummies) { - new GyroAdisDummy(objects::GYRO_0_ADIS_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); - new GyroL3GD20Dummy(objects::GYRO_1_L3G_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); - new GyroAdisDummy(objects::GYRO_2_ADIS_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); - new GyroL3GD20Dummy(objects::GYRO_3_L3G_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); - new MgmLIS3MDLDummy(objects::MGM_0_LIS3_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); - new MgmLIS3MDLDummy(objects::MGM_2_LIS3_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); - new MgmRm3100Dummy(objects::MGM_1_RM3100_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); - new MgmRm3100Dummy(objects::MGM_3_RM3100_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); - new GpsDummy(objects::GPS_CONTROLLER, objects::DUMMY_COM_IF, comCookieDummy); + std::array assemblyDhbs; + assemblyDhbs[0] = new MgmLIS3MDLDummy(objects::MGM_0_LIS3_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + assemblyDhbs[1] = new MgmLIS3MDLDummy(objects::MGM_2_LIS3_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + assemblyDhbs[2] = new MgmRm3100Dummy(objects::MGM_1_RM3100_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + assemblyDhbs[3] = new MgmRm3100Dummy(objects::MGM_3_RM3100_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + assemblyDhbs[4] = new GyroAdisDummy(objects::GYRO_0_ADIS_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + assemblyDhbs[5] = new GyroL3GD20Dummy(objects::GYRO_1_L3G_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + assemblyDhbs[6] = new GyroAdisDummy(objects::GYRO_2_ADIS_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + assemblyDhbs[7] = new GyroL3GD20Dummy(objects::GYRO_3_L3G_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + auto* gpsCtrl = new GpsDhbDummy(objects::GPS_CONTROLLER, objects::DUMMY_COM_IF, comCookieDummy); + ObjectFactory::createAcsBoardAssy(pwrSwitcher, assemblyDhbs, gpsCtrl, gpioIF); } if (cfg.addSusDummies) { @@ -100,7 +102,7 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitch) { new SusDummy(objects::SUS_10_N_LOC_XMYBZF_PT_ZF, objects::DUMMY_COM_IF, comCookieDummy); suses[11] = new SusDummy(objects::SUS_11_R_LOC_XBYMZB_PT_ZB, objects::DUMMY_COM_IF, comCookieDummy); - ObjectFactory::createSusAssy(pwrSwitch, suses); + ObjectFactory::createSusAssy(pwrSwitcher, suses); } if (cfg.addTempSensorDummies) { @@ -174,6 +176,6 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitch) { new TemperatureSensorInserter(objects::THERMAL_TEMP_INSERTER, tempSensorDummies, tempTmpSensorDummies); } - new CamSwitcher(objects::CAM_SWITCHER, pwrSwitch, power::NO_SWITCH); + new CamSwitcher(objects::CAM_SWITCHER, pwrSwitcher, power::NO_SWITCH); new PlPcduDummy(objects::PLPCDU_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); } diff --git a/dummies/helpers.h b/dummies/helpers.h index bbaab34d..1d30f451 100644 --- a/dummies/helpers.h +++ b/dummies/helpers.h @@ -14,6 +14,6 @@ struct DummyCfg { bool addRtdComIFDummy = true; }; -void createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitch); +void createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitch, GpioIF* gpioIF); } // namespace dummy diff --git a/fsfw b/fsfw index dac2d210..f0b8457b 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit dac2d210b597adfaf45bd5ae6a4c027599927601 +Subproject commit f0b8457ba2d9a34a42b10314c3cdccfd46ebf168 diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index 56ca3d97..6506c184 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -26,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -259,3 +261,23 @@ void ObjectFactory::createSusAssy(PowerSwitchIF& pwrSwitcher, } susAss->connectModeTreeParent(satsystem::acs::ACS_SUBSYSTEM); } + +void ObjectFactory::createAcsBoardAssy(PowerSwitchIF& pwrSwitcher, + std::array assemblyDhbs, + ExtendedControllerBase* gpsCtrl, GpioIF* gpioComIF) { + AcsBoardHelper acsBoardHelper = AcsBoardHelper( + objects::MGM_0_LIS3_HANDLER, objects::MGM_1_RM3100_HANDLER, objects::MGM_2_LIS3_HANDLER, + objects::MGM_3_RM3100_HANDLER, objects::GYRO_0_ADIS_HANDLER, objects::GYRO_1_L3G_HANDLER, + objects::GYRO_2_ADIS_HANDLER, objects::GYRO_3_L3G_HANDLER, objects::GPS_CONTROLLER); + auto acsAss = + new AcsBoardAssembly(objects::ACS_BOARD_ASS, &pwrSwitcher, acsBoardHelper, gpioComIF); + for (auto& assChild : assemblyDhbs) { + ReturnValue_t result = assChild->connectModeTreeParent(*acsAss); + if (result != returnvalue::OK) { + sif::error << "Connecting assembly for ACS board component " << assChild->getObjectId() + << " failed" << std::endl; + } + } + gpsCtrl->connectModeTreeParent(*acsAss); + acsAss->connectModeTreeParent(satsystem::acs::ACS_SUBSYSTEM); +} diff --git a/mission/core/GenericFactory.h b/mission/core/GenericFactory.h index 89d7f0d5..4b380336 100644 --- a/mission/core/GenericFactory.h +++ b/mission/core/GenericFactory.h @@ -11,6 +11,7 @@ class HeaterHandler; class HealthTableIF; class PusTmFunnel; class CfdpTmFunnel; +class ExtendedControllerBase; namespace ObjectFactory { @@ -23,6 +24,8 @@ void createThermalController(HeaterHandler& heaterHandler); void createRwAssy(PowerSwitchIF& pwrSwitcher, power::Switch_t theSwitch, std::array rws, std::array rwIds); void createSusAssy(PowerSwitchIF& pwrSwitcher, std::array suses); +void createAcsBoardAssy(PowerSwitchIF& pwrSwitcher, std::array assemblyDhbs, + ExtendedControllerBase* gpsCtrl, GpioIF* gpioComIF); } // namespace ObjectFactory From cec9ef6c5d90ea50a70daac85aba005e9492f498 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 13 Feb 2023 14:19:07 +0100 Subject: [PATCH 087/373] some fixes --- CHANGELOG.md | 7 +++++++ fsfw | 2 +- linux/devices/Max31865RtdLowlevelHandler.cpp | 8 ++++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 431606a0..58d85ccd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,13 @@ change warranting a new major release: # [unreleased] +# [v1.27.1] 2023-02-13 + +## Fixed + +- Fix for SPI ComIF: Set transfer size to 0 for failed transfers +- Fix shadowing issue with locks in MAX31865 low level handler + # [v1.27.0] 2023-02-13 eive-tmtc: v2.12.5 diff --git a/fsfw b/fsfw index dac2d210..f0b8457b 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit dac2d210b597adfaf45bd5ae6a4c027599927601 +Subproject commit f0b8457ba2d9a34a42b10314c3cdccfd46ebf168 diff --git a/linux/devices/Max31865RtdLowlevelHandler.cpp b/linux/devices/Max31865RtdLowlevelHandler.cpp index a6fe2061..52a107dc 100644 --- a/linux/devices/Max31865RtdLowlevelHandler.cpp +++ b/linux/devices/Max31865RtdLowlevelHandler.cpp @@ -70,8 +70,8 @@ bool Max31865RtdReader::periodicInitHandling() { return false; } if ((rtd->on or rtd->db.active) and not rtd->db.configured and rtd->cd.hasTimedOut()) { - ManualCsLockWrapper mg(csLock, gpioIF, rtd->spiCookie, csTimeoutType, csTimeoutMs); - if (mg.lockResult != returnvalue::OK or mg.gpioResult != returnvalue::OK) { + ManualCsLockWrapper mg1(csLock, gpioIF, rtd->spiCookie, csTimeoutType, csTimeoutMs); + if (mg1.lockResult != returnvalue::OK or mg1.gpioResult != returnvalue::OK) { sif::error << "Max31865RtdReader::periodicInitHandling: Manual CS lock failed" << std::endl; continue; } @@ -153,8 +153,8 @@ ReturnValue_t Max31865RtdReader::periodicReadHandling() { return returnvalue::FAILED; } if (rtdIsActive(rtd->idx)) { - ManualCsLockWrapper mg(csLock, gpioIF, rtd->spiCookie, csTimeoutType, csTimeoutMs); - if (mg.lockResult != returnvalue::OK or mg.gpioResult != returnvalue::OK) { + ManualCsLockWrapper mg1(csLock, gpioIF, rtd->spiCookie, csTimeoutType, csTimeoutMs); + if (mg1.lockResult != returnvalue::OK or mg1.gpioResult != returnvalue::OK) { sif::error << "Max31865RtdReader::periodicInitHandling: Manual CS lock failed" << std::endl; continue; } From 323140c846c0707612fca3c7560ae59c9bd6512c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 13 Feb 2023 14:19:24 +0100 Subject: [PATCH 088/373] bump revision --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8af127a1..782993be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ cmake_minimum_required(VERSION 3.13) set(OBSW_VERSION_MAJOR 1) set(OBSW_VERSION_MINOR 27) -set(OBSW_VERSION_REVISION 0) +set(OBSW_VERSION_REVISION 1) # set(CMAKE_VERBOSE TRUE) From b4d9ea6c1936cf99cce9ab96dba8220a33725442 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 13 Feb 2023 15:37:42 +0100 Subject: [PATCH 089/373] lets see if this fixes issues --- bsp_q7s/core/scheduling.cpp | 18 +++--------------- .../pollingsequence/pollingSequenceFactory.cpp | 3 ++- .../pollingsequence/pollingSequenceFactory.h | 2 +- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/bsp_q7s/core/scheduling.cpp b/bsp_q7s/core/scheduling.cpp index cc3108e8..32d64829 100644 --- a/bsp_q7s/core/scheduling.cpp +++ b/bsp_q7s/core/scheduling.cpp @@ -214,21 +214,9 @@ void scheduling::initTasks() { } #endif -#if OBSW_ADD_RTD_DEVICES == 1 - PeriodicTaskIF* tcsPollingTask = factory->createPeriodicTask( - "TCS_POLLING_TASK", 75, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 0.5, missedDeadlineFunc); - result = tcsPollingTask->addComponent(objects::SPI_RTD_COM_IF); - if (result != returnvalue::OK) { - scheduling::printAddObjectError("SPI_RTD_POLLING", objects::SPI_RTD_COM_IF); - } - - PeriodicTaskIF* tcsTask = factory->createPeriodicTask( - "TCS_TASK", 55, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc); - scheduling::scheduleRtdSensors(tcsTask); -#endif - PeriodicTaskIF* tcsSystemTask = factory->createPeriodicTask( - "TCS_TASK", 45, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.5, missedDeadlineFunc); + "TCS_TASK", 55, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.5, missedDeadlineFunc); + scheduling::scheduleRtdSensors(tcsSystemTask); result = tcsSystemTask->addComponent(objects::TCS_SUBSYSTEM); if (result != returnvalue::OK) { scheduling::printAddObjectError("TCS_SUBSYSTEM", objects::TCS_SUBSYSTEM); @@ -394,7 +382,7 @@ void scheduling::createPstTasks(TaskFactory& factory, TaskDeadlineMissedFunction #endif FixedTimeslotTaskIF* acsPst = factory.createFixedTimeslotTask( "ACS_PST", 85, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, acsPstPeriod, missedDeadlineFunc); - result = pst::pstAcs(acsPst, cfg); + result = pst::pstTcsAndAcs(acsPst, cfg); if (result != returnvalue::OK) { if (result == FixedTimeslotTaskIF::SLOT_LIST_EMPTY) { sif::warning << "scheduling::initTasks: ACS PST is empty" << std::endl; diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index f9b69e45..63b40df2 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -184,7 +184,7 @@ ReturnValue_t pst::pstTest(FixedTimeslotTaskIF *thisSequence) { return returnvalue::OK; } -ReturnValue_t pst::pstAcs(FixedTimeslotTaskIF *thisSequence, AcsPstCfg cfg) { +ReturnValue_t pst::pstTcsAndAcs(FixedTimeslotTaskIF *thisSequence, AcsPstCfg cfg) { /* Length of a communication cycle */ uint32_t length = thisSequence->getPeriodMs(); bool enableAside = true; @@ -684,5 +684,6 @@ ReturnValue_t pst::pstAcs(FixedTimeslotTaskIF *thisSequence, AcsPstCfg cfg) { thisSequence->addSlot(objects::RW4, length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::GET_READ); } + thisSequence->addSlot(objects::SPI_RTD_COM_IF, length * 0.5, 0); return returnvalue::OK; } diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h index 3e5ead52..99fba4ad 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h @@ -49,7 +49,7 @@ ReturnValue_t pstGompaceCan(FixedTimeslotTaskIF* thisSequence); ReturnValue_t pstSpiAndSyrlinks(FixedTimeslotTaskIF* thisSequence); -ReturnValue_t pstAcs(FixedTimeslotTaskIF* thisSequence, AcsPstCfg cfg); +ReturnValue_t pstTcsAndAcs(FixedTimeslotTaskIF* thisSequence, AcsPstCfg cfg); ReturnValue_t pstI2c(FixedTimeslotTaskIF* thisSequence); From ebc32d1cc2ebb8a9332cf85f3eddcff3d5e30aea Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 13 Feb 2023 15:42:45 +0100 Subject: [PATCH 090/373] changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58d85ccd..f94066d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,11 @@ change warranting a new major release: # [unreleased] +## Changed + +- Remove 2 TCS threads. +- Move low level polling into ACS PST, move high level device handlers into TCS system task. + # [v1.27.1] 2023-02-13 ## Fixed From efbb5d69c7c60b5785671cfa132e31ae9607d42e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 13 Feb 2023 15:44:19 +0100 Subject: [PATCH 091/373] remove removed task start --- bsp_q7s/core/scheduling.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/bsp_q7s/core/scheduling.cpp b/bsp_q7s/core/scheduling.cpp index 32d64829..2aad7a23 100644 --- a/bsp_q7s/core/scheduling.cpp +++ b/bsp_q7s/core/scheduling.cpp @@ -352,10 +352,6 @@ void scheduling::initTasks() { gpsTask->startTask(); #endif acsSysTask->startTask(); -#if OBSW_ADD_RTD_DEVICES == 1 - tcsPollingTask->startTask(); - tcsTask->startTask(); -#endif /* OBSW_ADD_RTD_DEVICES == 1 */ if (not tcsSystemTask->isEmpty()) { tcsSystemTask->startTask(); } From e2f8ca752f70d698de1d2138241c67f80610fb34 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 13 Feb 2023 15:59:44 +0100 Subject: [PATCH 092/373] continue satsystem --- dummies/GpsCtrlDummy.cpp | 20 +++++++++++++++++++- dummies/GpsCtrlDummy.h | 14 +++++++++++--- dummies/GpsDhbDummy.cpp | 13 ++++++++----- dummies/helpers.cpp | 27 ++++++++++++++++++--------- dummies/helpers.h | 2 ++ 5 files changed, 58 insertions(+), 18 deletions(-) diff --git a/dummies/GpsCtrlDummy.cpp b/dummies/GpsCtrlDummy.cpp index 3a1f61ba..e69261b4 100644 --- a/dummies/GpsCtrlDummy.cpp +++ b/dummies/GpsCtrlDummy.cpp @@ -1,3 +1,21 @@ #include "GpsCtrlDummy.h" -GpsCtrlDummy::GpsCtrlDummy(object_id_t objectId): ExtendedControllerBase(objectId, 20) {} +GpsCtrlDummy::GpsCtrlDummy(object_id_t objectId) : ExtendedControllerBase(objectId, 20) {} + +ReturnValue_t GpsCtrlDummy::handleCommandMessage(CommandMessage* message) { + return returnvalue::OK; +} + +void GpsCtrlDummy::performControlOperation() {} + +ReturnValue_t GpsCtrlDummy::checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t* msToReachTheMode) { + return returnvalue::OK; +} + +ReturnValue_t GpsCtrlDummy::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) { + return returnvalue::OK; +} + +LocalPoolDataSetBase* GpsCtrlDummy::getDataSetHandle(sid_t sid) { return nullptr; } diff --git a/dummies/GpsCtrlDummy.h b/dummies/GpsCtrlDummy.h index 3d6f40bc..128a9a85 100644 --- a/dummies/GpsCtrlDummy.h +++ b/dummies/GpsCtrlDummy.h @@ -3,10 +3,18 @@ #include -class GpsCtrlDummy: public ExtendedControllerBase { -public: +class GpsCtrlDummy : public ExtendedControllerBase { + public: GpsCtrlDummy(object_id_t objectId); -private: + + private: + ReturnValue_t handleCommandMessage(CommandMessage* message) override; + void performControlOperation() override; + ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t* msToReachTheMode) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; + LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; }; #endif /* DUMMIES_GPSCTRLDUMMY_H_ */ diff --git a/dummies/GpsDhbDummy.cpp b/dummies/GpsDhbDummy.cpp index 84c82da4..d46e6265 100644 --- a/dummies/GpsDhbDummy.cpp +++ b/dummies/GpsDhbDummy.cpp @@ -10,19 +10,22 @@ void GpsDhbDummy::doStartUp() {} void GpsDhbDummy::doShutDown() {} -ReturnValue_t GpsDhbDummy::buildNormalDeviceCommand(DeviceCommandId_t *id) { return NOTHING_TO_SEND; } +ReturnValue_t GpsDhbDummy::buildNormalDeviceCommand(DeviceCommandId_t *id) { + return NOTHING_TO_SEND; +} ReturnValue_t GpsDhbDummy::buildTransitionDeviceCommand(DeviceCommandId_t *id) { return NOTHING_TO_SEND; } ReturnValue_t GpsDhbDummy::buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t *commandData, size_t commandDataLen) { + const uint8_t *commandData, + size_t commandDataLen) { return returnvalue::OK; } -ReturnValue_t GpsDhbDummy::scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId, - size_t *foundLen) { +ReturnValue_t GpsDhbDummy::scanForReply(const uint8_t *start, size_t len, + DeviceCommandId_t *foundId, size_t *foundLen) { return returnvalue::OK; } @@ -35,7 +38,7 @@ void GpsDhbDummy::fillCommandAndReplyMap() {} uint32_t GpsDhbDummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } ReturnValue_t GpsDhbDummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, - LocalDataPoolManager &poolManager) { + LocalDataPoolManager &poolManager) { localDataPoolMap.emplace(GpsHyperion::LATITUDE, new PoolEntry({0.0}, 1)); localDataPoolMap.emplace(GpsHyperion::LONGITUDE, new PoolEntry({0.0}, 1)); localDataPoolMap.emplace(GpsHyperion::ALTITUDE, new PoolEntry({0.0})); diff --git a/dummies/helpers.cpp b/dummies/helpers.cpp index 1fd8a37c..b983f221 100644 --- a/dummies/helpers.cpp +++ b/dummies/helpers.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -64,15 +65,23 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitcher, GpioIF* gpio if (cfg.addAcsBoardDummies) { std::array assemblyDhbs; - assemblyDhbs[0] = new MgmLIS3MDLDummy(objects::MGM_0_LIS3_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); - assemblyDhbs[1] = new MgmLIS3MDLDummy(objects::MGM_2_LIS3_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); - assemblyDhbs[2] = new MgmRm3100Dummy(objects::MGM_1_RM3100_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); - assemblyDhbs[3] = new MgmRm3100Dummy(objects::MGM_3_RM3100_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); - assemblyDhbs[4] = new GyroAdisDummy(objects::GYRO_0_ADIS_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); - assemblyDhbs[5] = new GyroL3GD20Dummy(objects::GYRO_1_L3G_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); - assemblyDhbs[6] = new GyroAdisDummy(objects::GYRO_2_ADIS_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); - assemblyDhbs[7] = new GyroL3GD20Dummy(objects::GYRO_3_L3G_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); - auto* gpsCtrl = new GpsDhbDummy(objects::GPS_CONTROLLER, objects::DUMMY_COM_IF, comCookieDummy); + assemblyDhbs[0] = + new MgmLIS3MDLDummy(objects::MGM_0_LIS3_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + assemblyDhbs[1] = + new MgmLIS3MDLDummy(objects::MGM_2_LIS3_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + assemblyDhbs[2] = + new MgmRm3100Dummy(objects::MGM_1_RM3100_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + assemblyDhbs[3] = + new MgmRm3100Dummy(objects::MGM_3_RM3100_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + assemblyDhbs[4] = + new GyroAdisDummy(objects::GYRO_0_ADIS_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + assemblyDhbs[5] = + new GyroL3GD20Dummy(objects::GYRO_1_L3G_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + assemblyDhbs[6] = + new GyroAdisDummy(objects::GYRO_2_ADIS_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + assemblyDhbs[7] = + new GyroL3GD20Dummy(objects::GYRO_3_L3G_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + auto* gpsCtrl = new GpsCtrlDummy(objects::GPS_CONTROLLER); ObjectFactory::createAcsBoardAssy(pwrSwitcher, assemblyDhbs, gpsCtrl, gpioIF); } diff --git a/dummies/helpers.h b/dummies/helpers.h index 1d30f451..878702e3 100644 --- a/dummies/helpers.h +++ b/dummies/helpers.h @@ -2,6 +2,8 @@ #include +class GpioIF; + namespace dummy { struct DummyCfg { From 99913594fda899dbc1b8f5a374502008d2afa66c Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 13 Feb 2023 16:10:58 +0100 Subject: [PATCH 093/373] rfrmt --- .../pollingsequence/pollingSequenceFactory.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 31606768..2944856e 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -240,7 +240,6 @@ ReturnValue_t pst::pstTcsAndAcs(FixedTimeslotTaskIF *thisSequence, AcsPstCfg cfg thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * config::acs::SCHED_BLOCK_1_PERIOD, DeviceHandlerIF::GET_READ); } - if (enableBside) { // B side thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * config::acs::SCHED_BLOCK_1_PERIOD, @@ -293,7 +292,6 @@ ReturnValue_t pst::pstTcsAndAcs(FixedTimeslotTaskIF *thisSequence, AcsPstCfg cfg } } // SUS: 16 ms - bool addSus0 = true; bool addSus1 = true; bool addSus2 = true; @@ -441,7 +439,6 @@ ReturnValue_t pst::pstTcsAndAcs(FixedTimeslotTaskIF *thisSequence, AcsPstCfg cfg thisSequence->addSlot(objects::SUS_5_N_LOC_XFYMZB_PT_ZB, length * config::acs::SCHED_BLOCK_1_PERIOD, DeviceHandlerIF::GET_READ); } - if (addSus6) { thisSequence->addSlot(objects::SUS_6_R_LOC_XFYBZM_PT_XF, length * 0, DeviceHandlerIF::PERFORM_OPERATION); @@ -464,7 +461,6 @@ ReturnValue_t pst::pstTcsAndAcs(FixedTimeslotTaskIF *thisSequence, AcsPstCfg cfg thisSequence->addSlot(objects::SUS_6_R_LOC_XFYBZM_PT_XF, length * config::acs::SCHED_BLOCK_1_PERIOD, DeviceHandlerIF::GET_READ); } - if (addSus7) { thisSequence->addSlot(objects::SUS_7_R_LOC_XBYBZM_PT_XB, length * 0, DeviceHandlerIF::PERFORM_OPERATION); @@ -487,7 +483,6 @@ ReturnValue_t pst::pstTcsAndAcs(FixedTimeslotTaskIF *thisSequence, AcsPstCfg cfg thisSequence->addSlot(objects::SUS_7_R_LOC_XBYBZM_PT_XB, length * config::acs::SCHED_BLOCK_1_PERIOD, DeviceHandlerIF::GET_READ); } - if (addSus8) { thisSequence->addSlot(objects::SUS_8_R_LOC_XBYBZB_PT_YB, length * 0, DeviceHandlerIF::PERFORM_OPERATION); @@ -510,7 +505,6 @@ ReturnValue_t pst::pstTcsAndAcs(FixedTimeslotTaskIF *thisSequence, AcsPstCfg cfg thisSequence->addSlot(objects::SUS_8_R_LOC_XBYBZB_PT_YB, length * config::acs::SCHED_BLOCK_1_PERIOD, DeviceHandlerIF::GET_READ); } - if (addSus9) { thisSequence->addSlot(objects::SUS_9_R_LOC_XBYBZB_PT_YF, length * 0, DeviceHandlerIF::PERFORM_OPERATION); @@ -522,6 +516,7 @@ ReturnValue_t pst::pstTcsAndAcs(FixedTimeslotTaskIF *thisSequence, AcsPstCfg cfg DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::SUS_9_R_LOC_XBYBZB_PT_YF, length * 0, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::SUS_9_R_LOC_XBYBZB_PT_YF, length * config::acs::SCHED_BLOCK_1_PERIOD, DeviceHandlerIF::SEND_WRITE); @@ -532,7 +527,6 @@ ReturnValue_t pst::pstTcsAndAcs(FixedTimeslotTaskIF *thisSequence, AcsPstCfg cfg thisSequence->addSlot(objects::SUS_9_R_LOC_XBYBZB_PT_YF, length * config::acs::SCHED_BLOCK_1_PERIOD, DeviceHandlerIF::GET_READ); } - if (addSus10) { thisSequence->addSlot(objects::SUS_10_N_LOC_XMYBZF_PT_ZF, length * 0, DeviceHandlerIF::PERFORM_OPERATION); @@ -555,7 +549,6 @@ ReturnValue_t pst::pstTcsAndAcs(FixedTimeslotTaskIF *thisSequence, AcsPstCfg cfg thisSequence->addSlot(objects::SUS_10_N_LOC_XMYBZF_PT_ZF, length * config::acs::SCHED_BLOCK_1_PERIOD, DeviceHandlerIF::GET_READ); } - if (addSus11) { thisSequence->addSlot(objects::SUS_11_R_LOC_XBYMZB_PT_ZB, length * 0, DeviceHandlerIF::PERFORM_OPERATION); @@ -807,6 +800,8 @@ ReturnValue_t pst::pstTcsAndAcs(FixedTimeslotTaskIF *thisSequence, AcsPstCfg cfg thisSequence->addSlot(objects::RW4, length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::GET_READ); } + thisSequence->addSlot(objects::SPI_RTD_COM_IF, length * 0.5, 0); + return returnvalue::OK; } From 6c0234149ea3be3361d2ab8c05f1cf73a46a909a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 13 Feb 2023 16:19:14 +0100 Subject: [PATCH 094/373] compile fixes --- bsp_q7s/em/emObjectFactory.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bsp_q7s/em/emObjectFactory.cpp b/bsp_q7s/em/emObjectFactory.cpp index 693da405..1f94e0d6 100644 --- a/bsp_q7s/em/emObjectFactory.cpp +++ b/bsp_q7s/em/emObjectFactory.cpp @@ -55,7 +55,7 @@ void ObjectFactory::produce(void* args) { createPcduComponents(gpioComIF, &pwrSwitcher); #endif - dummy::createDummies(dummyCfg, *pwrSwitcher); + dummy::createDummies(dummyCfg, *pwrSwitcher, gpioComIF); new CoreController(objects::CORE_CONTROLLER); @@ -75,7 +75,7 @@ void ObjectFactory::produce(void* args) { // createRadSensorComponent(gpioComIF); #if OBSW_ADD_ACS_BOARD == 1 - createAcsBoardComponents(gpioComIF, uartComIF, pwrSwitcher); + createAcsBoardComponents(gpioComIF, uartComIF, *pwrSwitcher); #endif #if OBSW_ADD_MGT == 1 From 2813d229bbf6034eb075bf2b5c08577c183168ad Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 13 Feb 2023 16:39:26 +0100 Subject: [PATCH 095/373] comntinue --- bsp_q7s/core/ObjectFactory.cpp | 1 - dummies/helpers.cpp | 8 ++++++-- mission/core/GenericFactory.cpp | 2 ++ mission/core/GenericFactory.h | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 16ba3325..e202105b 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -242,7 +242,6 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialCo PowerSwitchIF& pwrSwitcher) { using namespace gpio; GpioCookie* gpioCookieAcsBoard = new GpioCookie(); - std::array assemblyChildren; std::stringstream consumer; GpiodRegularByLineName* gpio = nullptr; diff --git a/dummies/helpers.cpp b/dummies/helpers.cpp index b983f221..98474289 100644 --- a/dummies/helpers.cpp +++ b/dummies/helpers.cpp @@ -28,6 +28,7 @@ #include "mission/core/GenericFactory.h" #include "mission/devices/devicedefinitions/GomspaceDefinitions.h" #include "mission/system/tree/acsModeTree.h" +#include "mission/system/tree/payloadModeTree.h" using namespace dummy; @@ -49,7 +50,9 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitcher, GpioIF* gpio rws[3] = new RwDummy(objects::RW4, objects::DUMMY_COM_IF, comCookieDummy); ObjectFactory::createRwAssy(pwrSwitcher, pcdu::Switches::PDU2_CH2_RW_5V, rws, rwIds); new SaDeplDummy(objects::SOLAR_ARRAY_DEPL_HANDLER); - new StarTrackerDummy(objects::STAR_TRACKER, objects::DUMMY_COM_IF, comCookieDummy); + auto* strDummy = + new StarTrackerDummy(objects::STAR_TRACKER, objects::DUMMY_COM_IF, comCookieDummy); + strDummy->connectModeTreeParent(satsystem::acs::ACS_SUBSYSTEM); if (cfg.addSyrlinksDummies) { new SyrlinksDummy(objects::SYRLINKS_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); } @@ -185,6 +188,7 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitcher, GpioIF* gpio new TemperatureSensorInserter(objects::THERMAL_TEMP_INSERTER, tempSensorDummies, tempTmpSensorDummies); } - new CamSwitcher(objects::CAM_SWITCHER, pwrSwitcher, power::NO_SWITCH); + auto* camSwitcher = new CamSwitcher(objects::CAM_SWITCHER, pwrSwitcher, power::NO_SWITCH); + camSwitcher->connectModeTreeParent(satsystem::pl::SUBSYSTEM); new PlPcduDummy(objects::PLPCDU_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); } diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index 6506c184..7c8bd689 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -281,3 +281,5 @@ void ObjectFactory::createAcsBoardAssy(PowerSwitchIF& pwrSwitcher, gpsCtrl->connectModeTreeParent(*acsAss); acsAss->connectModeTreeParent(satsystem::acs::ACS_SUBSYSTEM); } + +void ObjectFactory::createTcsBoardAssy(PowerSwitchIF& pwrSwitcher) {} diff --git a/mission/core/GenericFactory.h b/mission/core/GenericFactory.h index 4b380336..dd7c6b18 100644 --- a/mission/core/GenericFactory.h +++ b/mission/core/GenericFactory.h @@ -26,6 +26,7 @@ void createRwAssy(PowerSwitchIF& pwrSwitcher, power::Switch_t theSwitch, void createSusAssy(PowerSwitchIF& pwrSwitcher, std::array suses); void createAcsBoardAssy(PowerSwitchIF& pwrSwitcher, std::array assemblyDhbs, ExtendedControllerBase* gpsCtrl, GpioIF* gpioComIF); +void createTcsBoardAssy(PowerSwitchIF& pwrSwitcher); } // namespace ObjectFactory From 17fa9a6e82f217c88fa830651e450da2247867a4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 13 Feb 2023 17:04:04 +0100 Subject: [PATCH 096/373] add TCS board assy for EM --- bsp_q7s/core/ObjectFactory.cpp | 1 + dummies/helpers.cpp | 5 +++++ linux/ObjectFactory.cpp | 33 +++++++-------------------------- mission/core/GenericFactory.cpp | 9 ++++++++- mission/core/GenericFactory.h | 23 ++++++++++++++++++++++- 5 files changed, 43 insertions(+), 28 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index e202105b..2bf36743 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -343,6 +343,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialCo #if OBSW_ADD_ACS_BOARD == 1 std::string spiDev = q7s::SPI_DEFAULT_DEV; + std::array assemblyChildren; SpiCookie* spiCookie = new SpiCookie(addresses::MGM_0_LIS3, gpioIds::MGM_0_LIS3_CS, MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); diff --git a/dummies/helpers.cpp b/dummies/helpers.cpp index 98474289..2115867f 100644 --- a/dummies/helpers.cpp +++ b/dummies/helpers.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include "TemperatureSensorInserter.h" #include "dummies/Max31865Dummy.h" @@ -187,6 +188,10 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitcher, GpioIF* gpio new TemperatureSensorInserter(objects::THERMAL_TEMP_INSERTER, tempSensorDummies, tempTmpSensorDummies); + TcsBoardAssembly* tcsBoardAssy = ObjectFactory::createTcsBoardAssy(pwrSwitcher); + for (auto& rtd : tempSensorDummies) { + rtd.second->connectModeTreeParent(*tcsBoardAssy); + } } auto* camSwitcher = new CamSwitcher(objects::CAM_SWITCHER, pwrSwitcher, power::NO_SWITCH); camSwitcher->connectModeTreeParent(satsystem::pl::SUBSYSTEM); diff --git a/linux/ObjectFactory.cpp b/linux/ObjectFactory.cpp index add6a755..1686eb03 100644 --- a/linux/ObjectFactory.cpp +++ b/linux/ObjectFactory.cpp @@ -270,32 +270,13 @@ void ObjectFactory::createRtdComponents(std::string spiDev, GpioIF* gpioComIF, {addresses::RTD_IC_18, gpioIds::RTD_IC_18}, }}; // HSPD: Heatspreader - std::array, NUM_RTDS> rtdInfos = {{ - {objects::RTD_0_IC3_PLOC_HEATSPREADER, "RTD_0_PLOC_HSPD"}, - {objects::RTD_1_IC4_PLOC_MISSIONBOARD, "RTD_1_PLOC_MISSIONBRD"}, - {objects::RTD_2_IC5_4K_CAMERA, "RTD_2_4K_CAMERA"}, - {objects::RTD_3_IC6_DAC_HEATSPREADER, "RTD_3_DAC_HSPD"}, - {objects::RTD_4_IC7_STARTRACKER, "RTD_4_STARTRACKER"}, - {objects::RTD_5_IC8_RW1_MX_MY, "RTD_5_RW1_MX_MY"}, - {objects::RTD_6_IC9_DRO, "RTD_6_DRO"}, - {objects::RTD_7_IC10_SCEX, "RTD_7_SCEX"}, - {objects::RTD_8_IC11_X8, "RTD_8_X8"}, - {objects::RTD_9_IC12_HPA, "RTD_9_HPA"}, - {objects::RTD_10_IC13_PL_TX, "RTD_10_PL_TX,"}, - {objects::RTD_11_IC14_MPA, "RTD_11_MPA"}, - {objects::RTD_12_IC15_ACU, "RTD_12_ACU"}, - {objects::RTD_13_IC16_PLPCDU_HEATSPREADER, "RTD_13_PLPCDU_HSPD"}, - {objects::RTD_14_IC17_TCS_BOARD, "RTD_14_TCS_BOARD"}, - {objects::RTD_15_IC18_IMTQ, "RTD_15_IMTQ"}, - }}; + std::array rtdCookies = {}; std::array rtds = {}; RtdFdir* rtdFdir = nullptr; - TcsBoardHelper helper(rtdInfos); - TcsBoardAssembly* tcsBoardAss = new TcsBoardAssembly( - objects::TCS_BOARD_ASS, pwrSwitcher, pcdu::Switches::PDU1_CH0_TCS_BOARD_3V3, helper); - tcsBoardAss->connectModeTreeParent(satsystem::tcs::SUBSYSTEM); + TcsBoardAssembly* tcsBoardAss = ObjectFactory::createTcsBoardAssy(*pwrSwitcher); + // Create special low level reader communication interface new Max31865RtdReader(objects::SPI_RTD_COM_IF, comIF, gpioComIF); for (uint8_t idx = 0; idx < NUM_RTDS; idx++) { @@ -303,16 +284,16 @@ void ObjectFactory::createRtdComponents(std::string spiDev, GpioIF* gpioComIF, MAX31865::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); rtdCookies[idx]->setMutexParams(MutexIF::TimeoutType::WAITING, spi::RTD_CS_TIMEOUT); Max31865ReaderCookie* rtdLowLevelCookie = - new Max31865ReaderCookie(rtdInfos[idx].first, idx, rtdInfos[idx].second, rtdCookies[idx]); + new Max31865ReaderCookie(RTD_INFOS[idx].first, idx, RTD_INFOS[idx].second, rtdCookies[idx]); rtds[idx] = - new Max31865EiveHandler(rtdInfos[idx].first, objects::SPI_RTD_COM_IF, rtdLowLevelCookie); - rtds[idx]->setDeviceInfo(idx, rtdInfos[idx].second); + new Max31865EiveHandler(RTD_INFOS[idx].first, objects::SPI_RTD_COM_IF, rtdLowLevelCookie); + rtds[idx]->setDeviceInfo(idx, RTD_INFOS[idx].second); ReturnValue_t result = rtds[idx]->connectModeTreeParent(*tcsBoardAss); if (result != returnvalue::OK) { sif::error << "Connecting RTD " << static_cast(idx) << " to RTD Assembly failed" << std::endl; } - rtdFdir = new RtdFdir(rtdInfos[idx].first); + rtdFdir = new RtdFdir(RTD_INFOS[idx].first); rtds[idx]->setCustomFdir(rtdFdir); #if OBSW_DEBUG_RTD == 1 rtds[idx]->setDebugMode(true, 5); diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index 7c8bd689..992c0093 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -282,4 +283,10 @@ void ObjectFactory::createAcsBoardAssy(PowerSwitchIF& pwrSwitcher, acsAss->connectModeTreeParent(satsystem::acs::ACS_SUBSYSTEM); } -void ObjectFactory::createTcsBoardAssy(PowerSwitchIF& pwrSwitcher) {} +TcsBoardAssembly* ObjectFactory::createTcsBoardAssy(PowerSwitchIF& pwrSwitcher) { + TcsBoardHelper helper(RTD_INFOS); + TcsBoardAssembly* tcsBoardAss = new TcsBoardAssembly( + objects::TCS_BOARD_ASS, &pwrSwitcher, pcdu::Switches::PDU1_CH0_TCS_BOARD_3V3, helper); + tcsBoardAss->connectModeTreeParent(satsystem::tcs::SUBSYSTEM); + return tcsBoardAss; +} diff --git a/mission/core/GenericFactory.h b/mission/core/GenericFactory.h index dd7c6b18..30f2d6bb 100644 --- a/mission/core/GenericFactory.h +++ b/mission/core/GenericFactory.h @@ -6,12 +6,33 @@ #include "fsfw/objectmanager/SystemObjectIF.h" #include "fsfw/power/PowerSwitchIF.h" #include "fsfw_hal/common/gpio/GpioIF.h" +#include "mission/devices/devicedefinitions/Max31865Definitions.h" class HeaterHandler; class HealthTableIF; class PusTmFunnel; class CfdpTmFunnel; class ExtendedControllerBase; +class TcsBoardAssembly; + +const std::array, EiveMax31855::NUM_RTDS> RTD_INFOS = {{ + {objects::RTD_0_IC3_PLOC_HEATSPREADER, "RTD_0_PLOC_HSPD"}, + {objects::RTD_1_IC4_PLOC_MISSIONBOARD, "RTD_1_PLOC_MISSIONBRD"}, + {objects::RTD_2_IC5_4K_CAMERA, "RTD_2_4K_CAMERA"}, + {objects::RTD_3_IC6_DAC_HEATSPREADER, "RTD_3_DAC_HSPD"}, + {objects::RTD_4_IC7_STARTRACKER, "RTD_4_STARTRACKER"}, + {objects::RTD_5_IC8_RW1_MX_MY, "RTD_5_RW1_MX_MY"}, + {objects::RTD_6_IC9_DRO, "RTD_6_DRO"}, + {objects::RTD_7_IC10_SCEX, "RTD_7_SCEX"}, + {objects::RTD_8_IC11_X8, "RTD_8_X8"}, + {objects::RTD_9_IC12_HPA, "RTD_9_HPA"}, + {objects::RTD_10_IC13_PL_TX, "RTD_10_PL_TX,"}, + {objects::RTD_11_IC14_MPA, "RTD_11_MPA"}, + {objects::RTD_12_IC15_ACU, "RTD_12_ACU"}, + {objects::RTD_13_IC16_PLPCDU_HEATSPREADER, "RTD_13_PLPCDU_HSPD"}, + {objects::RTD_14_IC17_TCS_BOARD, "RTD_14_TCS_BOARD"}, + {objects::RTD_15_IC18_IMTQ, "RTD_15_IMTQ"}, +}}; namespace ObjectFactory { @@ -26,7 +47,7 @@ void createRwAssy(PowerSwitchIF& pwrSwitcher, power::Switch_t theSwitch, void createSusAssy(PowerSwitchIF& pwrSwitcher, std::array suses); void createAcsBoardAssy(PowerSwitchIF& pwrSwitcher, std::array assemblyDhbs, ExtendedControllerBase* gpsCtrl, GpioIF* gpioComIF); -void createTcsBoardAssy(PowerSwitchIF& pwrSwitcher); +TcsBoardAssembly* createTcsBoardAssy(PowerSwitchIF& pwrSwitcher); } // namespace ObjectFactory From f5092b27ba86c36716d00476b8018ee5a81cb27c Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 13 Feb 2023 17:24:56 +0100 Subject: [PATCH 097/373] add SCEX dummy --- dummies/CMakeLists.txt | 1 + dummies/ScexDummy.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ dummies/ScexDummy.h | 34 ++++++++++++++++++++++++++++++++++ dummies/helpers.cpp | 3 +++ 4 files changed, 78 insertions(+) create mode 100644 dummies/ScexDummy.cpp create mode 100644 dummies/ScexDummy.h diff --git a/dummies/CMakeLists.txt b/dummies/CMakeLists.txt index 38527dd6..1e41f7d2 100644 --- a/dummies/CMakeLists.txt +++ b/dummies/CMakeLists.txt @@ -20,6 +20,7 @@ target_sources( GyroL3GD20Dummy.cpp MgmLIS3MDLDummy.cpp PlPcduDummy.cpp + ScexDummy.cpp CoreControllerDummy.cpp helpers.cpp MgmRm3100Dummy.cpp diff --git a/dummies/ScexDummy.cpp b/dummies/ScexDummy.cpp new file mode 100644 index 00000000..303570ff --- /dev/null +++ b/dummies/ScexDummy.cpp @@ -0,0 +1,40 @@ +#include "ScexDummy.h" + +ScexDummy::ScexDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie) + : DeviceHandlerBase(objectId, comif, comCookie) {} + +ScexDummy::~ScexDummy() {} + +void ScexDummy::doStartUp() {} + +void ScexDummy::doShutDown() {} + +ReturnValue_t ScexDummy::buildNormalDeviceCommand(DeviceCommandId_t *id) { return NOTHING_TO_SEND; } + +ReturnValue_t ScexDummy::buildTransitionDeviceCommand(DeviceCommandId_t *id) { + return NOTHING_TO_SEND; +} + +ReturnValue_t ScexDummy::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t *commandData, + size_t commandDataLen) { + return returnvalue::OK; +} + +ReturnValue_t ScexDummy::scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId, + size_t *foundLen) { + return returnvalue::OK; +} + +ReturnValue_t ScexDummy::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { + return returnvalue::OK; +} + +void ScexDummy::fillCommandAndReplyMap() {} + +uint32_t ScexDummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } + +ReturnValue_t ScexDummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + return returnvalue::OK; +} diff --git a/dummies/ScexDummy.h b/dummies/ScexDummy.h new file mode 100644 index 00000000..dc0cc73a --- /dev/null +++ b/dummies/ScexDummy.h @@ -0,0 +1,34 @@ +#ifndef DUMMIES_SCEXDUMMY_H_ +#define DUMMIES_SCEXDUMMY_H_ + +#include + +class ScexDummy : public DeviceHandlerBase { + public: + static const DeviceCommandId_t SIMPLE_COMMAND = 1; + static const DeviceCommandId_t PERIODIC_REPLY = 2; + + static const uint8_t SIMPLE_COMMAND_DATA = 1; + static const uint8_t PERIODIC_REPLY_DATA = 2; + + ScexDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie); + virtual ~ScexDummy(); + + protected: + void doStartUp() override; + void doShutDown() override; + ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData, + size_t commandDataLen) override; + ReturnValue_t scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId, + size_t *foundLen) override; + ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override; + void fillCommandAndReplyMap() override; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) override; +}; + + +#endif /* DUMMIES_SCEXDUMMY_H_ */ diff --git a/dummies/helpers.cpp b/dummies/helpers.cpp index 2115867f..ee509788 100644 --- a/dummies/helpers.cpp +++ b/dummies/helpers.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -195,5 +196,7 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitcher, GpioIF* gpio } auto* camSwitcher = new CamSwitcher(objects::CAM_SWITCHER, pwrSwitcher, power::NO_SWITCH); camSwitcher->connectModeTreeParent(satsystem::pl::SUBSYSTEM); + auto* scexDummy = new ScexDummy(objects::SCEX, objects::DUMMY_COM_IF, comCookieDummy); + scexDummy->connectModeTreeParent(satsystem::pl::SUBSYSTEM); new PlPcduDummy(objects::PLPCDU_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); } From 4cccafbe01bba0298c9a60837f93a37a6a98ecad Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 13 Feb 2023 17:59:08 +0100 Subject: [PATCH 098/373] no error im happy --- dummies/CMakeLists.txt | 2 + dummies/PlocMpsocDummy.cpp | 42 +++++++++++++++ dummies/PlocMpsocDummy.h | 30 +++++++++++ dummies/PlocSupervisorDummy.cpp | 44 +++++++++++++++ dummies/PlocSupervisorDummy.h | 30 +++++++++++ dummies/ScexDummy.h | 6 +-- dummies/helpers.cpp | 94 ++++++++++++++++++++------------- dummies/helpers.h | 1 + 8 files changed, 206 insertions(+), 43 deletions(-) create mode 100644 dummies/PlocMpsocDummy.cpp create mode 100644 dummies/PlocMpsocDummy.h create mode 100644 dummies/PlocSupervisorDummy.cpp create mode 100644 dummies/PlocSupervisorDummy.h diff --git a/dummies/CMakeLists.txt b/dummies/CMakeLists.txt index 1e41f7d2..810cc048 100644 --- a/dummies/CMakeLists.txt +++ b/dummies/CMakeLists.txt @@ -22,6 +22,8 @@ target_sources( PlPcduDummy.cpp ScexDummy.cpp CoreControllerDummy.cpp + PlocMpsocDummy.cpp + PlocSupervisorDummy.cpp helpers.cpp MgmRm3100Dummy.cpp Tmp1075Dummy.cpp) diff --git a/dummies/PlocMpsocDummy.cpp b/dummies/PlocMpsocDummy.cpp new file mode 100644 index 00000000..2df55b1d --- /dev/null +++ b/dummies/PlocMpsocDummy.cpp @@ -0,0 +1,42 @@ +#include "PlocMpsocDummy.h" + +PlocMpsocDummy::PlocMpsocDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie) + : DeviceHandlerBase(objectId, comif, comCookie) {} + +PlocMpsocDummy::~PlocMpsocDummy() {} + +void PlocMpsocDummy::doStartUp() {} + +void PlocMpsocDummy::doShutDown() {} + +ReturnValue_t PlocMpsocDummy::buildNormalDeviceCommand(DeviceCommandId_t *id) { + return NOTHING_TO_SEND; +} + +ReturnValue_t PlocMpsocDummy::buildTransitionDeviceCommand(DeviceCommandId_t *id) { + return NOTHING_TO_SEND; +} + +ReturnValue_t PlocMpsocDummy::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t *commandData, + size_t commandDataLen) { + return returnvalue::OK; +} + +ReturnValue_t PlocMpsocDummy::scanForReply(const uint8_t *start, size_t len, + DeviceCommandId_t *foundId, size_t *foundLen) { + return returnvalue::OK; +} + +ReturnValue_t PlocMpsocDummy::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { + return returnvalue::OK; +} + +void PlocMpsocDummy::fillCommandAndReplyMap() {} + +uint32_t PlocMpsocDummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } + +ReturnValue_t PlocMpsocDummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + return returnvalue::OK; +} diff --git a/dummies/PlocMpsocDummy.h b/dummies/PlocMpsocDummy.h new file mode 100644 index 00000000..7beaa76b --- /dev/null +++ b/dummies/PlocMpsocDummy.h @@ -0,0 +1,30 @@ +#pragma once + +#include + +class PlocMpsocDummy : public DeviceHandlerBase { + public: + static const DeviceCommandId_t SIMPLE_COMMAND = 1; + static const DeviceCommandId_t PERIODIC_REPLY = 2; + + static const uint8_t SIMPLE_COMMAND_DATA = 1; + static const uint8_t PERIODIC_REPLY_DATA = 2; + + PlocMpsocDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie); + virtual ~PlocMpsocDummy(); + + protected: + void doStartUp() override; + void doShutDown() override; + ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData, + size_t commandDataLen) override; + ReturnValue_t scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId, + size_t *foundLen) override; + ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override; + void fillCommandAndReplyMap() override; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) override; +}; diff --git a/dummies/PlocSupervisorDummy.cpp b/dummies/PlocSupervisorDummy.cpp new file mode 100644 index 00000000..d4730fe9 --- /dev/null +++ b/dummies/PlocSupervisorDummy.cpp @@ -0,0 +1,44 @@ +#include "PlocSupervisorDummy.h" + +PlocSupervisorDummy::PlocSupervisorDummy(object_id_t objectId, object_id_t comif, + CookieIF *comCookie) + : DeviceHandlerBase(objectId, comif, comCookie) {} + +PlocSupervisorDummy::~PlocSupervisorDummy() {} + +void PlocSupervisorDummy::doStartUp() {} + +void PlocSupervisorDummy::doShutDown() {} + +ReturnValue_t PlocSupervisorDummy::buildNormalDeviceCommand(DeviceCommandId_t *id) { + return NOTHING_TO_SEND; +} + +ReturnValue_t PlocSupervisorDummy::buildTransitionDeviceCommand(DeviceCommandId_t *id) { + return NOTHING_TO_SEND; +} + +ReturnValue_t PlocSupervisorDummy::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t *commandData, + size_t commandDataLen) { + return returnvalue::OK; +} + +ReturnValue_t PlocSupervisorDummy::scanForReply(const uint8_t *start, size_t len, + DeviceCommandId_t *foundId, size_t *foundLen) { + return returnvalue::OK; +} + +ReturnValue_t PlocSupervisorDummy::interpretDeviceReply(DeviceCommandId_t id, + const uint8_t *packet) { + return returnvalue::OK; +} + +void PlocSupervisorDummy::fillCommandAndReplyMap() {} + +uint32_t PlocSupervisorDummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } + +ReturnValue_t PlocSupervisorDummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) { + return returnvalue::OK; +} diff --git a/dummies/PlocSupervisorDummy.h b/dummies/PlocSupervisorDummy.h new file mode 100644 index 00000000..4118c893 --- /dev/null +++ b/dummies/PlocSupervisorDummy.h @@ -0,0 +1,30 @@ +#pragma once + +#include + +class PlocSupervisorDummy : public DeviceHandlerBase { + public: + static const DeviceCommandId_t SIMPLE_COMMAND = 1; + static const DeviceCommandId_t PERIODIC_REPLY = 2; + + static const uint8_t SIMPLE_COMMAND_DATA = 1; + static const uint8_t PERIODIC_REPLY_DATA = 2; + + PlocSupervisorDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie); + virtual ~PlocSupervisorDummy(); + + protected: + void doStartUp() override; + void doShutDown() override; + ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData, + size_t commandDataLen) override; + ReturnValue_t scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId, + size_t *foundLen) override; + ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override; + void fillCommandAndReplyMap() override; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) override; +}; diff --git a/dummies/ScexDummy.h b/dummies/ScexDummy.h index dc0cc73a..98762db3 100644 --- a/dummies/ScexDummy.h +++ b/dummies/ScexDummy.h @@ -1,5 +1,4 @@ -#ifndef DUMMIES_SCEXDUMMY_H_ -#define DUMMIES_SCEXDUMMY_H_ +#pragma once #include @@ -29,6 +28,3 @@ class ScexDummy : public DeviceHandlerBase { ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) override; }; - - -#endif /* DUMMIES_SCEXDUMMY_H_ */ diff --git a/dummies/helpers.cpp b/dummies/helpers.cpp index ee509788..a5b84451 100644 --- a/dummies/helpers.cpp +++ b/dummies/helpers.cpp @@ -15,12 +15,15 @@ #include #include #include +#include +#include #include #include #include #include #include #include +#include #include #include @@ -30,9 +33,9 @@ #include "mission/core/GenericFactory.h" #include "mission/devices/devicedefinitions/GomspaceDefinitions.h" #include "mission/system/tree/acsModeTree.h" +#include "mission/system/tree/comModeTree.h" #include "mission/system/tree/payloadModeTree.h" - -using namespace dummy; +#include "mission/system/tree/tcsModeTree.h" void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitcher, GpioIF* gpioIF) { new ComIFDummy(objects::DUMMY_COM_IF); @@ -56,7 +59,9 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitcher, GpioIF* gpio new StarTrackerDummy(objects::STAR_TRACKER, objects::DUMMY_COM_IF, comCookieDummy); strDummy->connectModeTreeParent(satsystem::acs::ACS_SUBSYSTEM); if (cfg.addSyrlinksDummies) { - new SyrlinksDummy(objects::SYRLINKS_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + auto* syrlinksDummy = + new SyrlinksDummy(objects::SYRLINKS_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + syrlinksDummy->connectModeTreeParent(satsystem::com::SUBSYSTEM); } auto* imtqDummy = new ImtqDummy(objects::IMTQ_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); imtqDummy->enableThermalModule(ThermalStateCfg()); @@ -120,83 +125,96 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitcher, GpioIF* gpio } if (cfg.addTempSensorDummies) { - std::map tempSensorDummies; - tempSensorDummies.emplace(objects::RTD_0_IC3_PLOC_HEATSPREADER, - new Max31865Dummy(objects::RTD_0_IC3_PLOC_HEATSPREADER, - objects::DUMMY_COM_IF, comCookieDummy)); - tempSensorDummies.emplace(objects::RTD_1_IC4_PLOC_MISSIONBOARD, - new Max31865Dummy(objects::RTD_1_IC4_PLOC_MISSIONBOARD, - objects::DUMMY_COM_IF, comCookieDummy)); - tempSensorDummies.emplace( + std::map rtdSensorDummies; + rtdSensorDummies.emplace(objects::RTD_0_IC3_PLOC_HEATSPREADER, + new Max31865Dummy(objects::RTD_0_IC3_PLOC_HEATSPREADER, + objects::DUMMY_COM_IF, comCookieDummy)); + rtdSensorDummies.emplace(objects::RTD_1_IC4_PLOC_MISSIONBOARD, + new Max31865Dummy(objects::RTD_1_IC4_PLOC_MISSIONBOARD, + objects::DUMMY_COM_IF, comCookieDummy)); + rtdSensorDummies.emplace( objects::RTD_2_IC5_4K_CAMERA, new Max31865Dummy(objects::RTD_2_IC5_4K_CAMERA, objects::DUMMY_COM_IF, comCookieDummy)); - tempSensorDummies.emplace(objects::RTD_3_IC6_DAC_HEATSPREADER, - new Max31865Dummy(objects::RTD_3_IC6_DAC_HEATSPREADER, - objects::DUMMY_COM_IF, comCookieDummy)); - tempSensorDummies.emplace( + rtdSensorDummies.emplace(objects::RTD_3_IC6_DAC_HEATSPREADER, + new Max31865Dummy(objects::RTD_3_IC6_DAC_HEATSPREADER, + objects::DUMMY_COM_IF, comCookieDummy)); + rtdSensorDummies.emplace( objects::RTD_4_IC7_STARTRACKER, new Max31865Dummy(objects::RTD_4_IC7_STARTRACKER, objects::DUMMY_COM_IF, comCookieDummy)); - tempSensorDummies.emplace( + rtdSensorDummies.emplace( objects::RTD_5_IC8_RW1_MX_MY, new Max31865Dummy(objects::RTD_5_IC8_RW1_MX_MY, objects::DUMMY_COM_IF, comCookieDummy)); - tempSensorDummies.emplace( + rtdSensorDummies.emplace( objects::RTD_6_IC9_DRO, new Max31865Dummy(objects::RTD_6_IC9_DRO, objects::DUMMY_COM_IF, comCookieDummy)); - tempSensorDummies.emplace( + rtdSensorDummies.emplace( objects::RTD_7_IC10_SCEX, new Max31865Dummy(objects::RTD_7_IC10_SCEX, objects::DUMMY_COM_IF, comCookieDummy)); - tempSensorDummies.emplace( + rtdSensorDummies.emplace( objects::RTD_8_IC11_X8, new Max31865Dummy(objects::RTD_8_IC11_X8, objects::DUMMY_COM_IF, comCookieDummy)); - tempSensorDummies.emplace( + rtdSensorDummies.emplace( objects::RTD_9_IC12_HPA, new Max31865Dummy(objects::RTD_9_IC12_HPA, objects::DUMMY_COM_IF, comCookieDummy)); - tempSensorDummies.emplace( + rtdSensorDummies.emplace( objects::RTD_10_IC13_PL_TX, new Max31865Dummy(objects::RTD_10_IC13_PL_TX, objects::DUMMY_COM_IF, comCookieDummy)); - tempSensorDummies.emplace( + rtdSensorDummies.emplace( objects::RTD_11_IC14_MPA, new Max31865Dummy(objects::RTD_11_IC14_MPA, objects::DUMMY_COM_IF, comCookieDummy)); - tempSensorDummies.emplace( + rtdSensorDummies.emplace( objects::RTD_12_IC15_ACU, new Max31865Dummy(objects::RTD_12_IC15_ACU, objects::DUMMY_COM_IF, comCookieDummy)); - tempSensorDummies.emplace(objects::RTD_13_IC16_PLPCDU_HEATSPREADER, - new Max31865Dummy(objects::RTD_13_IC16_PLPCDU_HEATSPREADER, - objects::DUMMY_COM_IF, comCookieDummy)); - tempSensorDummies.emplace( + rtdSensorDummies.emplace(objects::RTD_13_IC16_PLPCDU_HEATSPREADER, + new Max31865Dummy(objects::RTD_13_IC16_PLPCDU_HEATSPREADER, + objects::DUMMY_COM_IF, comCookieDummy)); + rtdSensorDummies.emplace( objects::RTD_14_IC17_TCS_BOARD, new Max31865Dummy(objects::RTD_14_IC17_TCS_BOARD, objects::DUMMY_COM_IF, comCookieDummy)); - tempSensorDummies.emplace( + rtdSensorDummies.emplace( objects::RTD_15_IC18_IMTQ, new Max31865Dummy(objects::RTD_15_IC18_IMTQ, objects::DUMMY_COM_IF, comCookieDummy)); - std::map tempTmpSensorDummies; - tempTmpSensorDummies.emplace( + std::map tmpSensorDummies; + tmpSensorDummies.emplace( objects::TMP1075_HANDLER_TCS_0, new Tmp1075Dummy(objects::TMP1075_HANDLER_TCS_0, objects::DUMMY_COM_IF, comCookieDummy)); - tempTmpSensorDummies.emplace( + tmpSensorDummies.emplace( objects::TMP1075_HANDLER_TCS_1, new Tmp1075Dummy(objects::TMP1075_HANDLER_TCS_1, objects::DUMMY_COM_IF, comCookieDummy)); - tempTmpSensorDummies.emplace( + tmpSensorDummies.emplace( objects::TMP1075_HANDLER_PLPCDU_0, new Tmp1075Dummy(objects::TMP1075_HANDLER_PLPCDU_0, objects::DUMMY_COM_IF, comCookieDummy)); - tempTmpSensorDummies.emplace( + tmpSensorDummies.emplace( objects::TMP1075_HANDLER_PLPCDU_1, new Tmp1075Dummy(objects::TMP1075_HANDLER_PLPCDU_1, objects::DUMMY_COM_IF, comCookieDummy)); - tempTmpSensorDummies.emplace( + tmpSensorDummies.emplace( objects::TMP1075_HANDLER_IF_BOARD, new Tmp1075Dummy(objects::TMP1075_HANDLER_IF_BOARD, objects::DUMMY_COM_IF, comCookieDummy)); - new TemperatureSensorInserter(objects::THERMAL_TEMP_INSERTER, tempSensorDummies, - tempTmpSensorDummies); + new TemperatureSensorInserter(objects::THERMAL_TEMP_INSERTER, rtdSensorDummies, + tmpSensorDummies); TcsBoardAssembly* tcsBoardAssy = ObjectFactory::createTcsBoardAssy(pwrSwitcher); - for (auto& rtd : tempSensorDummies) { + for (auto& rtd : rtdSensorDummies) { rtd.second->connectModeTreeParent(*tcsBoardAssy); } + for (auto& tmp : tmpSensorDummies) { + tmp.second->connectModeTreeParent(satsystem::tcs::SUBSYSTEM); + } } auto* camSwitcher = new CamSwitcher(objects::CAM_SWITCHER, pwrSwitcher, power::NO_SWITCH); camSwitcher->connectModeTreeParent(satsystem::pl::SUBSYSTEM); auto* scexDummy = new ScexDummy(objects::SCEX, objects::DUMMY_COM_IF, comCookieDummy); scexDummy->connectModeTreeParent(satsystem::pl::SUBSYSTEM); - new PlPcduDummy(objects::PLPCDU_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + auto* plPcduDummy = + new PlPcduDummy(objects::PLPCDU_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + plPcduDummy->connectModeTreeParent(satsystem::pl::SUBSYSTEM); + if (cfg.addPlocDummies) { + auto* plocMpsocDummy = + new PlocMpsocDummy(objects::PLOC_MPSOC_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + plocMpsocDummy->connectModeTreeParent(satsystem::pl::SUBSYSTEM); + auto* plocSupervisorDummy = new PlocSupervisorDummy(objects::PLOC_SUPERVISOR_HANDLER, + objects::DUMMY_COM_IF, comCookieDummy); + plocSupervisorDummy->connectModeTreeParent(satsystem::pl::SUBSYSTEM); + } } diff --git a/dummies/helpers.h b/dummies/helpers.h index 878702e3..2181c79c 100644 --- a/dummies/helpers.h +++ b/dummies/helpers.h @@ -14,6 +14,7 @@ struct DummyCfg { bool addSusDummies = true; bool addTempSensorDummies = true; bool addRtdComIFDummy = true; + bool addPlocDummies = true; }; void createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitch, GpioIF* gpioIF); From 6a1d4bd52fb922e7e1877625ad47a4631b60f1bb Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 13 Feb 2023 18:01:16 +0100 Subject: [PATCH 099/373] continue --- bsp_q7s/core/scheduling.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/bsp_q7s/core/scheduling.cpp b/bsp_q7s/core/scheduling.cpp index cc3108e8..b23a0e98 100644 --- a/bsp_q7s/core/scheduling.cpp +++ b/bsp_q7s/core/scheduling.cpp @@ -233,12 +233,10 @@ void scheduling::initTasks() { if (result != returnvalue::OK) { scheduling::printAddObjectError("TCS_SUBSYSTEM", objects::TCS_SUBSYSTEM); } -#if OBSW_ADD_RTD_DEVICES == 1 result = tcsSystemTask->addComponent(objects::TCS_BOARD_ASS); if (result != returnvalue::OK) { scheduling::printAddObjectError("TCS_BOARD_ASS", objects::TCS_BOARD_ASS); } -#endif /* OBSW_ADD_RTD_DEVICES */ #if OBSW_ADD_TCS_CTRL == 1 result = tcsSystemTask->addComponent(objects::THERMAL_CONTROLLER); if (result != returnvalue::OK) { From 131fff68474bbe4d165e37624f832c21eba4f535 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 10:02:12 +0100 Subject: [PATCH 100/373] update create dummeis --- bsp_hosted/ObjectFactory.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bsp_hosted/ObjectFactory.cpp b/bsp_hosted/ObjectFactory.cpp index f0308ee5..d2c3c3da 100644 --- a/bsp_hosted/ObjectFactory.cpp +++ b/bsp_hosted/ObjectFactory.cpp @@ -62,7 +62,6 @@ void ObjectFactory::produce(void* args) { auto* dummyGpioIF = new DummyGpioIF(); auto* dummySwitcher = new DummyPowerSwitcher(objects::PCDU_HANDLER, 18, 0); - static_cast(dummyGpioIF); #ifdef PLATFORM_UNIX new SerialComIF(objects::UART_COM_IF); #if OBSW_ADD_PLOC_MPSOC == 1 @@ -89,7 +88,7 @@ void ObjectFactory::produce(void* args) { #endif dummy::DummyCfg cfg; - dummy::createDummies(cfg, *dummySwitcher); + dummy::createDummies(cfg, *dummySwitcher, dummyGpioIF); HeaterHandler* heaterHandler = nullptr; // new ThermalController(objects::THERMAL_CONTROLLER); From 3c5a2568ef0d41bf70367e4e9b753d13e448dc58 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 10:24:43 +0100 Subject: [PATCH 101/373] updatr lwgps dependency --- thirdparty/lwgps | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/thirdparty/lwgps b/thirdparty/lwgps index 52999ddf..18ce34fa 160000 --- a/thirdparty/lwgps +++ b/thirdparty/lwgps @@ -1 +1 @@ -Subproject commit 52999ddfe5177493b96b55871961a8a97131596d +Subproject commit 18ce34faf729ed63c94517b2ae6a3d3741e0a054 From a75e035cc5c2eb34f00567a020f9b820d713622f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 10:36:53 +0100 Subject: [PATCH 102/373] fix cppcheck lints --- fsfw | 2 +- linux/ipcore/PdecConfig.cpp | 2 +- linux/ipcore/PdecHandler.cpp | 1 + linux/ipcore/pdec.h | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/fsfw b/fsfw index f0b8457b..d256ede8 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit f0b8457ba2d9a34a42b10314c3cdccfd46ebf168 +Subproject commit d256ede8c1d8e7a746d3a56d45313d2b863e0b28 diff --git a/linux/ipcore/PdecConfig.cpp b/linux/ipcore/PdecConfig.cpp index 21de4610..a476e8cd 100644 --- a/linux/ipcore/PdecConfig.cpp +++ b/linux/ipcore/PdecConfig.cpp @@ -22,7 +22,7 @@ void PdecConfig::initialize() { word |= POSITIVE_WINDOW; configWords[0] = word; word = 0; - word |= (NEGATIVE_WINDOW << 24); + word |= (static_cast(NEGATIVE_WINDOW) << 24); word |= (HIGH_AU_MAP_ID << 16); word |= (ENABLE_DERANDOMIZER << 8); configWords[1] = word; diff --git a/linux/ipcore/PdecHandler.cpp b/linux/ipcore/PdecHandler.cpp index 0598cc95..b6b684e9 100644 --- a/linux/ipcore/PdecHandler.cpp +++ b/linux/ipcore/PdecHandler.cpp @@ -99,6 +99,7 @@ ReturnValue_t PdecHandler::performOperation(uint8_t operationCode) { } else if (OP_MODE == Modes::IRQ) { return irqOperation(); } + return returnvalue::FAILED; } ReturnValue_t PdecHandler::polledOperation() { diff --git a/linux/ipcore/pdec.h b/linux/ipcore/pdec.h index 16b0c2e6..7485f744 100644 --- a/linux/ipcore/pdec.h +++ b/linux/ipcore/pdec.h @@ -15,7 +15,7 @@ static constexpr uint32_t NEW_FAR_MASK = 1 << 2; static constexpr uint32_t TC_ABORT_MASK = 1 << 1; static constexpr uint32_t TC_NEW_MASK = 1 << 0; -static constexpr uint32_t FAR_STAT_MASK = 1 << 31; +static constexpr uint32_t FAR_STAT_MASK = 1UL << 31; static const uint32_t FRAME_ANA_MASK = 0x70000000; static const uint32_t IREASON_MASK = 0x0E000000; From 66d20dc11873acca86b5c004b04703ccc8c52c0b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 10:59:35 +0100 Subject: [PATCH 103/373] add tracing for first tasks --- bsp_q7s/OBSWConfig.h.in | 1 + bsp_q7s/core/CoreController.cpp | 4 ++++ bsp_q7s/core/CoreController.h | 3 +++ bsp_q7s/core/scheduling.cpp | 8 ++++---- mission/CMakeLists.txt | 2 +- mission/controller/AcsController.cpp | 4 ++++ mission/controller/AcsController.h | 5 +++++ mission/devices/BpxBatteryHandler.cpp | 8 +++++++- mission/devices/BpxBatteryHandler.h | 6 ++++++ mission/devices/SolarArrayDeploymentHandler.cpp | 6 ++++++ mission/devices/SolarArrayDeploymentHandler.h | 3 +++ mission/trace.cpp | 10 ++++++++++ mission/trace.h | 12 ++++++++++++ 13 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 mission/trace.cpp create mode 100644 mission/trace.h diff --git a/bsp_q7s/OBSWConfig.h.in b/bsp_q7s/OBSWConfig.h.in index 687d9363..a86dd8c7 100644 --- a/bsp_q7s/OBSWConfig.h.in +++ b/bsp_q7s/OBSWConfig.h.in @@ -77,6 +77,7 @@ // If this is enabled, all other I2C code should be disabled #define OBSW_ADD_I2C_TEST_CODE 0 #define OBSW_ADD_UART_TEST_CODE 0 +#define OBSW_THREAD_TRACING 1 #define OBSW_TEST_ACS 0 #define OBSW_DEBUG_ACS 0 diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 116b4fc9..79dc68f5 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -9,6 +9,7 @@ #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/timemanager/Stopwatch.h" #include "fsfw/version.h" +#include "mission/trace.h" #include "watchdog/definitions.h" #if OBSW_ADD_TMTC_UDP_SERVER == 1 #include "fsfw/osal/common/UdpTmTcBridge.h" @@ -63,6 +64,9 @@ ReturnValue_t CoreController::handleCommandMessage(CommandMessage *message) { } void CoreController::performControlOperation() { +#if OBSW_THREAD_TRACING == 1 + trace::threadTrace(opCounter, "CORE CTRL"); +#endif EventMessage event; for (ReturnValue_t result = eventQueue->receiveMessage(&event); result == returnvalue::OK; result = eventQueue->receiveMessage(&event)) { diff --git a/bsp_q7s/core/CoreController.h b/bsp_q7s/core/CoreController.h index 9cbc6340..36cf5d27 100644 --- a/bsp_q7s/core/CoreController.h +++ b/bsp_q7s/core/CoreController.h @@ -222,6 +222,9 @@ class CoreController : public ExtendedControllerBase { std::string currMntPrefix; bool performOneShotSdCardOpsSwitch = false; uint8_t shortSdCardCdCounter = 0; +#if OBSW_THREAD_TRACING == 1 + uint32_t opCounter; +#endif Countdown sdCardCheckCd = Countdown(INIT_SD_CARD_CHECK_TIMEOUT); /** diff --git a/bsp_q7s/core/scheduling.cpp b/bsp_q7s/core/scheduling.cpp index ad76d308..5abe3fd5 100644 --- a/bsp_q7s/core/scheduling.cpp +++ b/bsp_q7s/core/scheduling.cpp @@ -374,9 +374,9 @@ void scheduling::createPstTasks(TaskFactory& factory, TaskDeadlineMissedFunction #else static constexpr float acsPstPeriod = 0.8; #endif - FixedTimeslotTaskIF* acsPst = factory.createFixedTimeslotTask( - "ACS_PST", 85, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, acsPstPeriod, missedDeadlineFunc); - result = pst::pstTcsAndAcs(acsPst, cfg); + FixedTimeslotTaskIF* acsTcsPst = factory.createFixedTimeslotTask( + "ACS_TCS_PST", 85, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, acsPstPeriod, missedDeadlineFunc); + result = pst::pstTcsAndAcs(acsTcsPst, cfg); if (result != returnvalue::OK) { if (result == FixedTimeslotTaskIF::SLOT_LIST_EMPTY) { sif::warning << "scheduling::initTasks: ACS PST is empty" << std::endl; @@ -384,7 +384,7 @@ void scheduling::createPstTasks(TaskFactory& factory, TaskDeadlineMissedFunction sif::error << "scheduling::initTasks: Creating ACS PST failed!" << std::endl; } } else { - taskVec.push_back(acsPst); + taskVec.push_back(acsTcsPst); } /* Polling Sequence Table Default */ diff --git a/mission/CMakeLists.txt b/mission/CMakeLists.txt index f284a675..37c4a2e2 100644 --- a/mission/CMakeLists.txt +++ b/mission/CMakeLists.txt @@ -9,4 +9,4 @@ add_subdirectory(csp) add_subdirectory(cfdp) add_subdirectory(config) -target_sources(${LIB_EIVE_MISSION} PRIVATE acsDefs.cpp) +target_sources(${LIB_EIVE_MISSION} PRIVATE acsDefs.cpp trace.cpp) diff --git a/mission/controller/AcsController.cpp b/mission/controller/AcsController.cpp index ef590b8c..72589fcc 100644 --- a/mission/controller/AcsController.cpp +++ b/mission/controller/AcsController.cpp @@ -4,6 +4,7 @@ #include "mission/acsDefs.h" #include "mission/config/torquer.h" +#include "mission/trace.h" AcsController::AcsController(object_id_t objectId) : ExtendedControllerBase(objectId), @@ -50,6 +51,9 @@ ReturnValue_t AcsController::getParameter(uint8_t domainId, uint8_t parameterId, } void AcsController::performControlOperation() { +#if OBSW_THREAD_TRACING == 1 + trace::threadTrace(opCounter, "ACS & TCS PST"); +#endif switch (internalState) { case InternalState::STARTUP: { initialCountdown.resetTimer(); diff --git a/mission/controller/AcsController.h b/mission/controller/AcsController.h index 1e017099..14972b3e 100644 --- a/mission/controller/AcsController.h +++ b/mission/controller/AcsController.h @@ -6,6 +6,7 @@ #include #include +#include "OBSWConfig.h" #include "acs/ActuatorCmd.h" #include "acs/Guidance.h" #include "acs/Navigation.h" @@ -51,6 +52,10 @@ class AcsController : public ExtendedControllerBase, public ReceivesParameterMes ParameterHelper parameterHelper; +#if OBSW_THREAD_TRACING == 1 + uint32_t opCounter = 0; +#endif + enum class InternalState { STARTUP, INITIAL_DELAY, READY }; InternalState internalState = InternalState::STARTUP; diff --git a/mission/devices/BpxBatteryHandler.cpp b/mission/devices/BpxBatteryHandler.cpp index 4e49bebe..efda26f8 100644 --- a/mission/devices/BpxBatteryHandler.cpp +++ b/mission/devices/BpxBatteryHandler.cpp @@ -2,7 +2,7 @@ #include -#include "OBSWConfig.h" +#include "mission/trace.h" BpxBatteryHandler::BpxBatteryHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie) : DeviceHandlerBase(objectId, comIF, comCookie), hkSet(this), cfgSet(this) {} @@ -280,3 +280,9 @@ void BpxBatteryHandler::setToGoToNormalMode(bool enable) { } void BpxBatteryHandler::setDebugMode(bool enable) { this->debugMode = enable; } + +void BpxBatteryHandler::performOperationHook() { +#if OBSW_THREAD_TRACING == 1 + trace::threadTrace(opCounter, "BPX BATT"); +#endif +} diff --git a/mission/devices/BpxBatteryHandler.h b/mission/devices/BpxBatteryHandler.h index ceb0ff8d..31448799 100644 --- a/mission/devices/BpxBatteryHandler.h +++ b/mission/devices/BpxBatteryHandler.h @@ -3,6 +3,7 @@ #include +#include "OBSWConfig.h" #include "devicedefinitions/BpxBatteryDefinitions.h" class BpxBatteryHandler : public DeviceHandlerBase { @@ -24,6 +25,10 @@ class BpxBatteryHandler : public DeviceHandlerBase { bool debugMode = false; bool goToNormalModeImmediately = false; uint8_t sentPingByte = BpxBattery::DEFAULT_PING_SENT_BYTE; +#if OBSW_THREAD_TRACING == 1 + uint32_t opCounter = 0; +#endif + BpxBatteryHk hkSet; DeviceCommandId_t lastCmd = DeviceHandlerIF::NO_COMMAND_ID; BpxBatteryCfg cfgSet; @@ -47,6 +52,7 @@ class BpxBatteryHandler : public DeviceHandlerBase { ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override; ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t* id) override; void fillCommandAndReplyMap() override; + void performOperationHook() override; ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t* commandData, size_t commandDataLen) override; ReturnValue_t scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId, diff --git a/mission/devices/SolarArrayDeploymentHandler.cpp b/mission/devices/SolarArrayDeploymentHandler.cpp index 2b4e22ac..2eacdea4 100644 --- a/mission/devices/SolarArrayDeploymentHandler.cpp +++ b/mission/devices/SolarArrayDeploymentHandler.cpp @@ -37,6 +37,12 @@ SolarArrayDeploymentHandler::~SolarArrayDeploymentHandler() = default; ReturnValue_t SolarArrayDeploymentHandler::performOperation(uint8_t operationCode) { using namespace std::filesystem; +#if OBSW_THREAD_TRACING == 1 + opCounter++; + if (opCounter % 5 == 0) { + sif::debug << "SA DEPL task running" << std::endl; + } +#endif if (opDivider.checkAndIncrement()) { auto activeSdc = sdcMan.getActiveSdCard(); if (activeSdc and activeSdc.value() == sd::SdCard::SLOT_0 and diff --git a/mission/devices/SolarArrayDeploymentHandler.h b/mission/devices/SolarArrayDeploymentHandler.h index 63f1d3de..27c466f1 100644 --- a/mission/devices/SolarArrayDeploymentHandler.h +++ b/mission/devices/SolarArrayDeploymentHandler.h @@ -172,6 +172,9 @@ class SolarArrayDeploymentHandler : public ExecutableObjectIF, bool firstAutonomousCycle = true; ActionId_t activeCmd = HasActionsIF::INVALID_ACTION_ID; std::optional initUptime; +#if OBSW_THREAD_TRACING == 1 + uint32_t opCounter; +#endif PeriodicOperationDivider opDivider = PeriodicOperationDivider(5); uint8_t retryCounter = 3; diff --git a/mission/trace.cpp b/mission/trace.cpp new file mode 100644 index 00000000..f12e5902 --- /dev/null +++ b/mission/trace.cpp @@ -0,0 +1,10 @@ +#include "trace.h" + +#include "fsfw/serviceinterface.h" + +void trace::threadTrace(uint32_t& counter, const char* name) { + counter++; + if (counter % 5 == 0) { + sif::debug << name << " running" << std::endl; + } +} diff --git a/mission/trace.h b/mission/trace.h new file mode 100644 index 00000000..a3fabbd9 --- /dev/null +++ b/mission/trace.h @@ -0,0 +1,12 @@ +#ifndef MISSION_TRACE_H_ +#define MISSION_TRACE_H_ + +#include + +namespace trace { + +void threadTrace(uint32_t& counter, const char* name); + +} + +#endif /* MISSION_TRACE_H_ */ From 2aac3c67ee7402a8a004f5231df830ccd52b3404 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 11:10:18 +0100 Subject: [PATCH 104/373] instrumented some more tasks --- bsp_q7s/OBSWConfig.h.in | 1 - bsp_q7s/core/CoreController.cpp | 1 - bsp_q7s/core/CoreController.h | 1 + linux/devices/ploc/PlocMPSoCHelper.cpp | 4 +++- linux/devices/ploc/PlocMPSoCHelper.h | 5 +++++ linux/devices/ploc/PlocSupvUartMan.cpp | 3 +++ linux/devices/ploc/PlocSupvUartMan.h | 5 +++++ mission/controller/AcsController.cpp | 1 - mission/controller/AcsController.h | 2 +- mission/devices/BpxBatteryHandler.cpp | 2 -- mission/devices/BpxBatteryHandler.h | 2 +- mission/devices/SolarArrayDeploymentHandler.cpp | 1 + mission/devices/SolarArrayDeploymentHandler.h | 3 ++- mission/trace.h | 2 ++ 14 files changed, 24 insertions(+), 9 deletions(-) diff --git a/bsp_q7s/OBSWConfig.h.in b/bsp_q7s/OBSWConfig.h.in index a86dd8c7..687d9363 100644 --- a/bsp_q7s/OBSWConfig.h.in +++ b/bsp_q7s/OBSWConfig.h.in @@ -77,7 +77,6 @@ // If this is enabled, all other I2C code should be disabled #define OBSW_ADD_I2C_TEST_CODE 0 #define OBSW_ADD_UART_TEST_CODE 0 -#define OBSW_THREAD_TRACING 1 #define OBSW_TEST_ACS 0 #define OBSW_DEBUG_ACS 0 diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 79dc68f5..4ff4965f 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -9,7 +9,6 @@ #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/timemanager/Stopwatch.h" #include "fsfw/version.h" -#include "mission/trace.h" #include "watchdog/definitions.h" #if OBSW_ADD_TMTC_UDP_SERVER == 1 #include "fsfw/osal/common/UdpTmTcBridge.h" diff --git a/bsp_q7s/core/CoreController.h b/bsp_q7s/core/CoreController.h index 36cf5d27..65ee20ef 100644 --- a/bsp_q7s/core/CoreController.h +++ b/bsp_q7s/core/CoreController.h @@ -12,6 +12,7 @@ #include "events/subsystemIdRanges.h" #include "fsfw/controller/ExtendedControllerBase.h" #include "mission/devices/devicedefinitions/GPSDefinitions.h" +#include "mission/trace.h" class Timer; class SdCardManager; diff --git a/linux/devices/ploc/PlocMPSoCHelper.cpp b/linux/devices/ploc/PlocMPSoCHelper.cpp index fcd5178b..fca2e51c 100644 --- a/linux/devices/ploc/PlocMPSoCHelper.cpp +++ b/linux/devices/ploc/PlocMPSoCHelper.cpp @@ -3,7 +3,6 @@ #include #include -#include "OBSWConfig.h" #ifdef XIPHOS_Q7S #include "bsp_q7s/fs/FilesystemHelper.h" #endif @@ -34,6 +33,9 @@ ReturnValue_t PlocMPSoCHelper::performOperation(uint8_t operationCode) { ReturnValue_t result = returnvalue::OK; semaphore.acquire(); while (true) { +#if OBSW_THREAD_TRACING == 1 + trace::threadTrace(opCounter, "PLOC MPSOC Helper"); +#endif switch (internalState) { case InternalState::IDLE: { semaphore.acquire(); diff --git a/linux/devices/ploc/PlocMPSoCHelper.h b/linux/devices/ploc/PlocMPSoCHelper.h index c39cc758..dea35a82 100644 --- a/linux/devices/ploc/PlocMPSoCHelper.h +++ b/linux/devices/ploc/PlocMPSoCHelper.h @@ -11,6 +11,7 @@ #include "fsfw/tmtcservices/SourceSequenceCounter.h" #include "fsfw_hal/linux/serial/SerialComIF.h" #include "linux/devices/devicedefinitions/PlocMPSoCDefinitions.h" +#include "mission/trace.h" #ifdef XIPHOS_Q7S #include "bsp_q7s/fs/SdCardManager.h" #endif @@ -116,6 +117,10 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF { struct FlashWrite flashWrite; +#if OBSW_THREAD_TRACING == 1 + uint32_t opCounter = 0; +#endif + enum class InternalState { IDLE, FLASH_WRITE, FLASH_READ }; InternalState internalState = InternalState::IDLE; diff --git a/linux/devices/ploc/PlocSupvUartMan.cpp b/linux/devices/ploc/PlocSupvUartMan.cpp index 1fd2b841..5113de40 100644 --- a/linux/devices/ploc/PlocSupvUartMan.cpp +++ b/linux/devices/ploc/PlocSupvUartMan.cpp @@ -101,6 +101,9 @@ ReturnValue_t PlocSupvUartManager::performOperation(uint8_t operationCode) { lock->unlockMutex(); semaphore->acquire(); putTaskToSleep = false; +#if OBSW_THREAD_TRACING == 1 + trace::threadTrace(opCounter, "PLOC SUPV Helper PST"); +#endif while (true) { if (putTaskToSleep) { performUartShutdown(); diff --git a/linux/devices/ploc/PlocSupvUartMan.h b/linux/devices/ploc/PlocSupvUartMan.h index e1539c97..b787815f 100644 --- a/linux/devices/ploc/PlocSupvUartMan.h +++ b/linux/devices/ploc/PlocSupvUartMan.h @@ -7,6 +7,7 @@ #include #include "OBSWConfig.h" +#include "mission/trace.h" #include "fsfw/container/FIFO.h" #include "fsfw/devicehandlers/CookieIF.h" #include "fsfw/objectmanager/SystemObject.h" @@ -15,6 +16,7 @@ #include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw_hal/linux/serial/SerialComIF.h" #include "linux/devices/devicedefinitions/PlocSupervisorDefinitions.h" +#include "mission/trace.h" #include "tas/crc.h" #ifdef XIPHOS_Q7S @@ -211,6 +213,9 @@ class PlocSupvUartManager : public DeviceCommunicationIF, supv::TmBase tmReader; int serialPort = 0; struct termios tty = {}; +#if OBSW_THREAD_TRACING == 1 + uint32_t opCounter = 0; +#endif struct EventBufferRequest { std::string path = ""; diff --git a/mission/controller/AcsController.cpp b/mission/controller/AcsController.cpp index 72589fcc..051fa8f0 100644 --- a/mission/controller/AcsController.cpp +++ b/mission/controller/AcsController.cpp @@ -4,7 +4,6 @@ #include "mission/acsDefs.h" #include "mission/config/torquer.h" -#include "mission/trace.h" AcsController::AcsController(object_id_t objectId) : ExtendedControllerBase(objectId), diff --git a/mission/controller/AcsController.h b/mission/controller/AcsController.h index 14972b3e..f5240b74 100644 --- a/mission/controller/AcsController.h +++ b/mission/controller/AcsController.h @@ -6,7 +6,6 @@ #include #include -#include "OBSWConfig.h" #include "acs/ActuatorCmd.h" #include "acs/Guidance.h" #include "acs/Navigation.h" @@ -20,6 +19,7 @@ #include "fsfw_hal/devicehandlers/MgmRM3100Handler.h" #include "mission/devices/devicedefinitions/SusDefinitions.h" #include "mission/devices/devicedefinitions/imtqHandlerDefinitions.h" +#include "mission/trace.h" class AcsController : public ExtendedControllerBase, public ReceivesParameterMessagesIF { public: diff --git a/mission/devices/BpxBatteryHandler.cpp b/mission/devices/BpxBatteryHandler.cpp index efda26f8..922bcd3b 100644 --- a/mission/devices/BpxBatteryHandler.cpp +++ b/mission/devices/BpxBatteryHandler.cpp @@ -2,8 +2,6 @@ #include -#include "mission/trace.h" - BpxBatteryHandler::BpxBatteryHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie) : DeviceHandlerBase(objectId, comIF, comCookie), hkSet(this), cfgSet(this) {} diff --git a/mission/devices/BpxBatteryHandler.h b/mission/devices/BpxBatteryHandler.h index 31448799..c42ed7fd 100644 --- a/mission/devices/BpxBatteryHandler.h +++ b/mission/devices/BpxBatteryHandler.h @@ -3,8 +3,8 @@ #include -#include "OBSWConfig.h" #include "devicedefinitions/BpxBatteryDefinitions.h" +#include "mission/trace.h" class BpxBatteryHandler : public DeviceHandlerBase { public: diff --git a/mission/devices/SolarArrayDeploymentHandler.cpp b/mission/devices/SolarArrayDeploymentHandler.cpp index 2eacdea4..cb8658bc 100644 --- a/mission/devices/SolarArrayDeploymentHandler.cpp +++ b/mission/devices/SolarArrayDeploymentHandler.cpp @@ -11,6 +11,7 @@ #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw_hal/common/gpio/GpioCookie.h" +#include "mission/trace.h" static constexpr bool DEBUG_MODE = true; diff --git a/mission/devices/SolarArrayDeploymentHandler.h b/mission/devices/SolarArrayDeploymentHandler.h index 27c466f1..61211ca3 100644 --- a/mission/devices/SolarArrayDeploymentHandler.h +++ b/mission/devices/SolarArrayDeploymentHandler.h @@ -19,6 +19,7 @@ #include "fsfw/timemanager/Countdown.h" #include "fsfw_hal/common/gpio/GpioIF.h" #include "mission/memory/SdCardMountedIF.h" +#include "mission/trace.h" #include "returnvalues/classIds.h" enum DeploymentChannels : uint8_t { SA_1 = 1, SA_2 = 2 }; @@ -173,7 +174,7 @@ class SolarArrayDeploymentHandler : public ExecutableObjectIF, ActionId_t activeCmd = HasActionsIF::INVALID_ACTION_ID; std::optional initUptime; #if OBSW_THREAD_TRACING == 1 - uint32_t opCounter; + uint32_t opCounter = 0; #endif PeriodicOperationDivider opDivider = PeriodicOperationDivider(5); uint8_t retryCounter = 3; diff --git a/mission/trace.h b/mission/trace.h index a3fabbd9..6f20a698 100644 --- a/mission/trace.h +++ b/mission/trace.h @@ -3,6 +3,8 @@ #include +#define OBSW_THREAD_TRACING 1 + namespace trace { void threadTrace(uint32_t& counter, const char* name); From a57384f6c43a20281884cde5cd984af71ed89b0f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 11:11:06 +0100 Subject: [PATCH 105/373] trace has settable div --- mission/trace.cpp | 4 ++-- mission/trace.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mission/trace.cpp b/mission/trace.cpp index f12e5902..6c9af0af 100644 --- a/mission/trace.cpp +++ b/mission/trace.cpp @@ -2,9 +2,9 @@ #include "fsfw/serviceinterface.h" -void trace::threadTrace(uint32_t& counter, const char* name) { +void trace::threadTrace(uint32_t& counter, const char* name, unsigned div) { counter++; - if (counter % 5 == 0) { + if (counter % div == 0) { sif::debug << name << " running" << std::endl; } } diff --git a/mission/trace.h b/mission/trace.h index 6f20a698..59fdd99e 100644 --- a/mission/trace.h +++ b/mission/trace.h @@ -7,7 +7,7 @@ namespace trace { -void threadTrace(uint32_t& counter, const char* name); +void threadTrace(uint32_t& counter, const char* name, unsigned div = 5); } From 9b2398888dfd11a8e4e5093492067b7bbca81d5b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 11:18:51 +0100 Subject: [PATCH 106/373] add some more traces --- linux/devices/GpsHyperionLinuxController.cpp | 3 +++ linux/devices/GpsHyperionLinuxController.h | 4 ++++ linux/devices/ploc/PlocSupvUartMan.h | 1 - mission/controller/ThermalController.cpp | 3 +++ mission/controller/ThermalController.h | 7 ++++++- 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/linux/devices/GpsHyperionLinuxController.cpp b/linux/devices/GpsHyperionLinuxController.cpp index afc76fcf..a6e0a1a3 100644 --- a/linux/devices/GpsHyperionLinuxController.cpp +++ b/linux/devices/GpsHyperionLinuxController.cpp @@ -102,6 +102,9 @@ ReturnValue_t GpsHyperionLinuxController::performOperation(uint8_t opCode) { handleQueue(); poolManager.performHkOperation(); while (true) { +#if OBSW_THREAD_TRACING == 1 + trace::threadTrace(opCounter, "GPS CTRL"); +#endif bool callAgainImmediately = readGpsDataFromGpsd(); if (not callAgainImmediately) { handleQueue(); diff --git a/linux/devices/GpsHyperionLinuxController.h b/linux/devices/GpsHyperionLinuxController.h index 5d4a35ff..1e97bc29 100644 --- a/linux/devices/GpsHyperionLinuxController.h +++ b/linux/devices/GpsHyperionLinuxController.h @@ -6,6 +6,7 @@ #include "fsfw/controller/ExtendedControllerBase.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h" #include "mission/devices/devicedefinitions/GPSDefinitions.h" +#include "mission/trace.h" #ifdef FSFW_OSAL_LINUX #include @@ -60,6 +61,9 @@ class GpsHyperionLinuxController : public ExtendedControllerBase { Countdown maxTimeToReachFix = Countdown(MAX_SECONDS_TO_REACH_FIX * 1000); bool modeCommanded = false; bool timeInit = false; +#if OBSW_THREAD_TRACING == 1 + uint32_t opCounter = 0; +#endif struct OneShotSwitches { void reset() { diff --git a/linux/devices/ploc/PlocSupvUartMan.h b/linux/devices/ploc/PlocSupvUartMan.h index b787815f..02bfb6c7 100644 --- a/linux/devices/ploc/PlocSupvUartMan.h +++ b/linux/devices/ploc/PlocSupvUartMan.h @@ -7,7 +7,6 @@ #include #include "OBSWConfig.h" -#include "mission/trace.h" #include "fsfw/container/FIFO.h" #include "fsfw/devicehandlers/CookieIF.h" #include "fsfw/objectmanager/SystemObject.h" diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 0521d9aa..53b7f13d 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -72,6 +72,9 @@ ReturnValue_t ThermalController::handleCommandMessage(CommandMessage* message) { } void ThermalController::performControlOperation() { +#if OBSW_THREAD_TRACING == 1 + trace::threadTrace(opCounter, "TCS Task"); +#endif switch (internalState) { case InternalState::STARTUP: { initialCountdown.resetTimer(); diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 03c7954c..6297b175 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -11,7 +11,8 @@ #include -#include "../devices/HeaterHandler.h" +#include "mission/devices/HeaterHandler.h" +#include "mission/trace.h" /** * NOP Limit: Hard limit for device, usually from datasheet. Device damage is possible lif NOP limit @@ -152,6 +153,10 @@ class ThermalController : public ExtendedControllerBase { // Initial delay to make sure all pool variables have been initialized their owners Countdown initialCountdown = Countdown(DELAY); +#if OBSW_THREAD_TRACING == 1 + uint32_t opCounter = 0; +#endif + std::array, 5> sensors; uint8_t numSensors = 0; From ecb22bdd85655d93e673646fe108a666daaee690 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 11:32:03 +0100 Subject: [PATCH 107/373] further cut down the number of threads --- bsp_q7s/core/scheduling.cpp | 56 ++++++++++++------------------- linux/scheduling.cpp | 66 ++++++++++++++++++------------------- linux/scheduling.h | 4 +-- 3 files changed, 56 insertions(+), 70 deletions(-) diff --git a/bsp_q7s/core/scheduling.cpp b/bsp_q7s/core/scheduling.cpp index 5abe3fd5..2fa8f015 100644 --- a/bsp_q7s/core/scheduling.cpp +++ b/bsp_q7s/core/scheduling.cpp @@ -154,6 +154,14 @@ void scheduling::initTasks() { if (result != returnvalue::OK) { scheduling::printAddObjectError("PL_SUBSYSTEM", objects::PL_SUBSYSTEM); } + result = genericSysTask->addComponent(objects::INTERNAL_ERROR_REPORTER); + if (result != returnvalue::OK) { + scheduling::printAddObjectError("ERROR_REPORTER", objects::INTERNAL_ERROR_REPORTER); + } + result = genericSysTask->addComponent(objects::PUS_SERVICE_17_TEST); + if (result != returnvalue::OK) { + scheduling::printAddObjectError("PUS_17", objects::PUS_SERVICE_17_TEST); + } #if OBSW_ADD_CCSDS_IP_CORES == 1 result = genericSysTask->addComponent(objects::CCSDS_HANDLER); @@ -266,14 +274,16 @@ void scheduling::initTasks() { #endif /* OBSW_ADD_PLOC_SUPERVISOR */ PeriodicTaskIF* plTask = factory->createPeriodicTask( - "PL_TASK", 25, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, missedDeadlineFunc); - scheduling::addMpsocSupvHandlers(plTask); + "PL_TASK", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc); plTask->addComponent(objects::CAM_SWITCHER); + scheduling::addMpsocSupvHandlers(plTask); +#if OBSW_ADD_SCEX_DEVICE == 1 + scheduling::scheduleScexDev(plTask); +#endif #if OBSW_ADD_SCEX_DEVICE == 1 - PeriodicTaskIF* scexDevHandler; PeriodicTaskIF* scexReaderTask; - scheduling::schedulingScex(*factory, scexDevHandler, scexReaderTask); + scheduling::scheduleScexReader(*factory, scexReaderTask); #endif std::vector pusTasks; @@ -330,7 +340,6 @@ void scheduling::initTasks() { taskStarter(pstTasks, "PST task vector"); taskStarter(pusTasks, "PUS task vector"); #if OBSW_ADD_SCEX_DEVICE == 1 - scexDevHandler->startTask(); scexReaderTask->startTask(); #endif @@ -435,42 +444,28 @@ void scheduling::createPusTasks(TaskFactory& factory, TaskDeadlineMissedFunction std::vector& taskVec) { ReturnValue_t result = returnvalue::OK; /* PUS Services */ - PeriodicTaskIF* pusVerification = factory.createPeriodicTask( - "PUS_VERIF", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION); + PeriodicTaskIF* pusHighPrio = factory.createPeriodicTask( + "PUS_HIGH_PRIO", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); + result = pusHighPrio->addComponent(objects::PUS_SERVICE_1_VERIFICATION); if (result != returnvalue::OK) { scheduling::printAddObjectError("PUS_VERIF", objects::PUS_SERVICE_1_VERIFICATION); } - taskVec.push_back(pusVerification); - - PeriodicTaskIF* pusEvents = factory.createPeriodicTask( - "PUS_EVENTS", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusEvents->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING); + result = pusHighPrio->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING); if (result != returnvalue::OK) { scheduling::printAddObjectError("PUS_EVENTS", objects::PUS_SERVICE_5_EVENT_REPORTING); } - result = pusEvents->addComponent(objects::EVENT_MANAGER); + result = pusHighPrio->addComponent(objects::EVENT_MANAGER); if (result != returnvalue::OK) { scheduling::printAddObjectError("PUS_MGMT", objects::EVENT_MANAGER); } - taskVec.push_back(pusEvents); - - PeriodicTaskIF* pusHighPrio = factory.createPeriodicTask( - "PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); - result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS); - if (result != returnvalue::OK) { - scheduling::printAddObjectError("PUS_2", objects::PUS_SERVICE_2_DEVICE_ACCESS); - } result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT); if (result != returnvalue::OK) { scheduling::printAddObjectError("PUS_9", objects::PUS_SERVICE_9_TIME_MGMT); } - taskVec.push_back(pusHighPrio); PeriodicTaskIF* pusMedPrio = factory.createPeriodicTask( "PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc); - result = pusMedPrio->addComponent(objects::PUS_SERVICE_3_HOUSEKEEPING); if (result != returnvalue::OK) { scheduling::printAddObjectError("PUS_3", objects::PUS_SERVICE_3_HOUSEKEEPING); @@ -495,20 +490,11 @@ void scheduling::createPusTasks(TaskFactory& factory, TaskDeadlineMissedFunction if (result != returnvalue::OK) { scheduling::printAddObjectError("PUS_201", objects::PUS_SERVICE_201_HEALTH); } - // Used for connection tests, therefore use higher priority - result = pusMedPrio->addComponent(objects::PUS_SERVICE_17_TEST); + result = pusMedPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS); if (result != returnvalue::OK) { - scheduling::printAddObjectError("PUS_17", objects::PUS_SERVICE_17_TEST); + scheduling::printAddObjectError("PUS_2", objects::PUS_SERVICE_2_DEVICE_ACCESS); } taskVec.push_back(pusMedPrio); - - PeriodicTaskIF* pusLowPrio = factory.createPeriodicTask( - "PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, missedDeadlineFunc); - result = pusLowPrio->addComponent(objects::INTERNAL_ERROR_REPORTER); - if (result != returnvalue::OK) { - scheduling::printAddObjectError("ERROR_REPORTER", objects::INTERNAL_ERROR_REPORTER); - } - taskVec.push_back(pusLowPrio); } void scheduling::createTestTasks(TaskFactory& factory, diff --git a/linux/scheduling.cpp b/linux/scheduling.cpp index f2e6ddec..85394dea 100644 --- a/linux/scheduling.cpp +++ b/linux/scheduling.cpp @@ -8,8 +8,7 @@ #include "ObjectFactory.h" #include "eive/objects.h" -void scheduling::schedulingScex(TaskFactory& factory, PeriodicTaskIF*& scexDevHandler, - PeriodicTaskIF*& scexReaderTask) { +void scheduling::scheduleScexReader(TaskFactory& factory, PeriodicTaskIF*& scexReaderTask) { using namespace scheduling; ReturnValue_t result = returnvalue::OK; #if OBSW_PRINT_MISSED_DEADLINES == 1 @@ -17,37 +16,6 @@ void scheduling::schedulingScex(TaskFactory& factory, PeriodicTaskIF*& scexDevHa #else void (*missedDeadlineFunc)(void) = nullptr; #endif - scexDevHandler = factory.createPeriodicTask( - "SCEX_DEV", 35, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 0.5, missedDeadlineFunc); - - result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::PERFORM_OPERATION); - if (result != returnvalue::OK) { - printAddObjectError("SCEX_DEV", objects::SCEX); - } - result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::SEND_WRITE); - if (result != returnvalue::OK) { - printAddObjectError("SCEX_DEV", objects::SCEX); - } - result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::GET_WRITE); - if (result != returnvalue::OK) { - printAddObjectError("SCEX_DEV", objects::SCEX); - } - result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::SEND_READ); - if (result != returnvalue::OK) { - printAddObjectError("SCEX_DEV", objects::SCEX); - } - result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::GET_READ); - if (result != returnvalue::OK) { - printAddObjectError("SCEX_DEV", objects::SCEX); - } - result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::SEND_READ); - if (result != returnvalue::OK) { - printAddObjectError("SCEX_DEV", objects::SCEX); - } - result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::GET_READ); - if (result != returnvalue::OK) { - printAddObjectError("SCEX_DEV", objects::SCEX); - } result = returnvalue::OK; scexReaderTask = factory.createPeriodicTask( @@ -79,3 +47,35 @@ void scheduling::addMpsocSupvHandlers(PeriodicTaskIF* plTask) { plTask->addComponent(objects::PLOC_MPSOC_HANDLER, DeviceHandlerIF::GET_READ); #endif } + +void scheduling::scheduleScexDev(PeriodicTaskIF*& scexDevHandler) { + ReturnValue_t result = + scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::PERFORM_OPERATION); + if (result != returnvalue::OK) { + printAddObjectError("SCEX_DEV", objects::SCEX); + } + result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::SEND_WRITE); + if (result != returnvalue::OK) { + printAddObjectError("SCEX_DEV", objects::SCEX); + } + result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::GET_WRITE); + if (result != returnvalue::OK) { + printAddObjectError("SCEX_DEV", objects::SCEX); + } + result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::SEND_READ); + if (result != returnvalue::OK) { + printAddObjectError("SCEX_DEV", objects::SCEX); + } + result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::GET_READ); + if (result != returnvalue::OK) { + printAddObjectError("SCEX_DEV", objects::SCEX); + } + result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::SEND_READ); + if (result != returnvalue::OK) { + printAddObjectError("SCEX_DEV", objects::SCEX); + } + result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::GET_READ); + if (result != returnvalue::OK) { + printAddObjectError("SCEX_DEV", objects::SCEX); + } +} diff --git a/linux/scheduling.h b/linux/scheduling.h index d33e9d1f..b5ec8ef2 100644 --- a/linux/scheduling.h +++ b/linux/scheduling.h @@ -3,7 +3,7 @@ #include namespace scheduling { -void schedulingScex(TaskFactory& factory, PeriodicTaskIF*& scexDevHandler, - PeriodicTaskIF*& scexReaderTask); +void scheduleScexDev(PeriodicTaskIF*& scexDevHandler); +void scheduleScexReader(TaskFactory& factory, PeriodicTaskIF*& scexReaderTask); void addMpsocSupvHandlers(PeriodicTaskIF* task); } // namespace scheduling From 2d4c881d3ab84914603494f6ad4d6df71e7713b9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 11:56:40 +0100 Subject: [PATCH 108/373] add missing include --- linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 63b40df2..062bf7e7 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -1,5 +1,7 @@ #include "pollingSequenceFactory.h" +#include "OBSWConfig.h" + #include #include #include From e0c33b21e92b201116f10d3243056da86acb24d0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 13:11:52 +0100 Subject: [PATCH 109/373] remove lwgps dependency --- CHANGELOG.md | 4 ++++ CMakeLists.txt | 2 +- linux/boardtest/UartTestClass.h | 4 ++-- test/TestTask.cpp | 15 +++++++++++---- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f94066d3..f49f4ed4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,10 @@ change warranting a new major release: - Remove 2 TCS threads. - Move low level polling into ACS PST, move high level device handlers into TCS system task. +## Removed + +- lwgps dependency not compiled anymore, is not used + # [v1.27.1] 2023-02-13 ## Fixed diff --git a/CMakeLists.txt b/CMakeLists.txt index 782993be..6d730eab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -204,7 +204,7 @@ set(LIB_FSFW_NAME fsfw) set(LIB_EIVE_MISSION eive-mission) set(LIB_ETL_TARGET etl::etl) set(LIB_CSP_NAME libcsp) -set(LIB_LWGPS_NAME lwgps) +# set(LIB_LWGPS_NAME lwgps) set(LIB_ARCSEC wire) set(LIB_GOMSPACE_CLIENTS gs_clients) set(LIB_GOMSPACE_CSP gs_csp) diff --git a/linux/boardtest/UartTestClass.h b/linux/boardtest/UartTestClass.h index b206de53..6cb0d31c 100644 --- a/linux/boardtest/UartTestClass.h +++ b/linux/boardtest/UartTestClass.h @@ -10,7 +10,7 @@ #include -#include "lwgps/lwgps.h" +//#include "lwgps/lwgps.h" #include "mission/devices/devicedefinitions/ScexDefinitions.h" #include "test/TestTask.h" @@ -59,7 +59,7 @@ class UartTestClass : public TestTask { DleEncoder dleEncoder = DleEncoder(); SerialCookie* uartCookie = nullptr; size_t encodedLen = 0; - lwgps_t gpsData = {}; + //lwgps_t gpsData = {}; struct termios tty = {}; int serialPort = 0; bool startFound = false; diff --git a/test/TestTask.cpp b/test/TestTask.cpp index 634fdd0d..33af5494 100644 --- a/test/TestTask.cpp +++ b/test/TestTask.cpp @@ -41,11 +41,15 @@ ReturnValue_t EiveTestTask::performOperation(uint8_t operationCode) { } #include -#include + + +// #include + /** * @brief Dummy data from GPS receiver. Will be replaced witgh hyperion data later. */ + const char gps_rx_data[] = "" "$GPRMC,183729,A,3907.356,N,12102.482,W,000.0,360.0,080301,015.5,E*6F\r\n" @@ -72,6 +76,7 @@ const char hyperion_gps_data[] = "$GNVTG,040.7,T,,M,000.0,N,000.0,K,A*10\r\n" "$GNZDA,173225.998892,27,02,2021,00,00*75\r\n"; + ReturnValue_t EiveTestTask::performOneShotAction() { #if OBSW_ADD_TEST_CODE == 1 // performLwgpsTest(); @@ -96,20 +101,22 @@ ReturnValue_t EiveTestTask::performActionB() { return result; } +/* void EiveTestTask::performLwgpsTest() { - /* Everything here will only be performed once. */ + // Everything here will only be performed once. sif::info << "Processing sample GPS output.." << std::endl; lwgps_t gpsStruct; sif::info << "Size of GPS struct: " << sizeof(gpsStruct) << std::endl; lwgps_init(&gpsStruct); - /* Process all input data */ + // Process all input data lwgps_process(&gpsStruct, hyperion_gps_data, strlen(hyperion_gps_data)); - /* Print messages */ + // Print messages printf("Valid status: %d\n", gpsStruct.is_valid); printf("Latitude: %f degrees\n", gpsStruct.latitude); printf("Longitude: %f degrees\n", gpsStruct.longitude); printf("Altitude: %f meters\n", gpsStruct.altitude); } +*/ From 3da5f1d6cc9b8240fe456c2abadf725193552a12 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 13:13:16 +0100 Subject: [PATCH 110/373] update .cproject file --- misc/eclipse/.cproject | 90 ++++++++++++++++++++++++++---------------- 1 file changed, 57 insertions(+), 33 deletions(-) diff --git a/misc/eclipse/.cproject b/misc/eclipse/.cproject index aaecb53e..0dfd812a 100644 --- a/misc/eclipse/.cproject +++ b/misc/eclipse/.cproject @@ -57,7 +57,7 @@ - + @@ -119,7 +119,7 @@ - + @@ -187,7 +187,7 @@ - + @@ -255,7 +255,7 @@ - + @@ -418,7 +418,7 @@ - + @@ -580,7 +580,7 @@ - + @@ -750,7 +750,7 @@ - + @@ -917,7 +917,7 @@ - + @@ -1084,7 +1084,7 @@ - + @@ -1149,7 +1149,7 @@ - + @@ -1317,7 +1317,7 @@ - + @@ -1386,7 +1386,7 @@ - + @@ -1451,18 +1451,9 @@ - - - - - - - - - @@ -1478,6 +1469,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1490,25 +1523,16 @@ - - - - + - + - - - - - - - + From ef09cdabc27bdcb9dbe73a4374359aae6c03c025 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 13:15:12 +0100 Subject: [PATCH 111/373] remove lwgps properly --- CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d730eab..a1f0b37d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -204,7 +204,7 @@ set(LIB_FSFW_NAME fsfw) set(LIB_EIVE_MISSION eive-mission) set(LIB_ETL_TARGET etl::etl) set(LIB_CSP_NAME libcsp) -# set(LIB_LWGPS_NAME lwgps) +set(LIB_LWGPS_NAME lwgps) set(LIB_ARCSEC wire) set(LIB_GOMSPACE_CLIENTS gs_clients) set(LIB_GOMSPACE_CSP gs_csp) @@ -424,7 +424,6 @@ add_subdirectory(${BSP_PATH}) add_subdirectory(${COMMON_PATH}) add_subdirectory(${DUMMY_PATH}) -add_subdirectory(${LIB_LWGPS_PATH}) add_subdirectory(${FSFW_PATH}) add_subdirectory(${LIB_EIVE_MISSION_PATH}) add_subdirectory(${TEST_PATH}) From 1de832509a7d6383abe509145d2107346dbcf4dd Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 13:40:07 +0100 Subject: [PATCH 112/373] do a commit --- mission/devices/ImtqHandler.cpp | 4 ++++ mission/devices/RwHandler.cpp | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/mission/devices/ImtqHandler.cpp b/mission/devices/ImtqHandler.cpp index 0e75c06d..b370b7d9 100644 --- a/mission/devices/ImtqHandler.cpp +++ b/mission/devices/ImtqHandler.cpp @@ -192,6 +192,10 @@ ReturnValue_t ImtqHandler::buildCommandFromCommand(DeviceCommandId_t deviceComma if (result != returnvalue::OK) { return result; } + result = dipoleSet.commit(); + if (result != returnvalue::OK) { + sif::error << "ImtqHandler::buildCommandFromCommand: commit failed" << std::endl; + } } else { // Read set dipole values from local pool PoolReadGuard pg(&dipoleSet); diff --git a/mission/devices/RwHandler.cpp b/mission/devices/RwHandler.cpp index 88857b68..5c6914be 100644 --- a/mission/devices/RwHandler.cpp +++ b/mission/devices/RwHandler.cpp @@ -102,7 +102,6 @@ ReturnValue_t RwHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand return returnvalue::OK; } case (RwDefinitions::SET_SPEED): { - sif::debug << "hello" << std::endl; if (commandData != nullptr && commandDataLen != 6) { sif::error << "RwHandler::buildCommandFromCommand: Received set speed command with" << " invalid length" << std::endl; @@ -117,6 +116,10 @@ ReturnValue_t RwHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand if (result != returnvalue::OK) { return result; } + result = rwSpeedActuationSet.commit(); + if (result != returnvalue::OK) { + sif::error << "RwHandler::buildCommandFromCommand: commit failed" << std::endl; + } } else { // Read set rw speed value from local pool PoolReadGuard pg(&rwSpeedActuationSet); From 650f24d0ffbeb868d76c20b226524602fa4ada9c Mon Sep 17 00:00:00 2001 From: meggert Date: Tue, 14 Feb 2023 13:54:06 +0100 Subject: [PATCH 113/373] convert Igrf13 model vector from nT to uT --- mission/controller/acs/Igrf13Model.cpp | 9 +++------ mission/controller/acs/Igrf13Model.h | 1 - 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/mission/controller/acs/Igrf13Model.cpp b/mission/controller/acs/Igrf13Model.cpp index 63992010..3f844434 100644 --- a/mission/controller/acs/Igrf13Model.cpp +++ b/mission/controller/acs/Igrf13Model.cpp @@ -20,6 +20,7 @@ Igrf13Model::~Igrf13Model() {} void Igrf13Model::magFieldComp(const double longitude, const double gcLatitude, const double altitude, timeval timeOfMagMeasurement, double* magFieldModelInertial) { + double magFieldModel[3] = {0, 0, 0}; double phi = longitude, theta = gcLatitude; // geocentric /* Here is the co-latitude needed*/ theta -= 90 * PI / 180; @@ -100,12 +101,8 @@ void Igrf13Model::magFieldComp(const double longitude, const double gcLatitude, magFieldModelInertial[2] = magFieldModel[0] * sin(gcLatitude) - magFieldModel[1] * cos(gcLatitude); - double normVecMagFieldInert[3] = {0, 0, 0}; - VectorOperations::normalize(magFieldModelInertial, normVecMagFieldInert, 3); - - magFieldModel[0] = 0; - magFieldModel[1] = 0; - magFieldModel[2] = 0; + // convert nT to uT + VectorOperations::mulScalar(magFieldModelInertial, 1e-3, magFieldModelInertial, 3); } void Igrf13Model::updateCoeffGH(timeval timeOfMagMeasurement) { diff --git a/mission/controller/acs/Igrf13Model.h b/mission/controller/acs/Igrf13Model.h index ea2c1044..187adde7 100644 --- a/mission/controller/acs/Igrf13Model.h +++ b/mission/controller/acs/Igrf13Model.h @@ -47,7 +47,6 @@ class Igrf13Model /*:public HasParametersIF*/ { // Coefficient wary over year, could be updated sometimes. void updateCoeffGH(timeval timeOfMagMeasurement); // Secular variation (SV) - double magFieldModel[3]; void schmidtNormalization(); private: From 6d428859f2a7fc78c45bf09e24f657633208e5ba Mon Sep 17 00:00:00 2001 From: meggert Date: Tue, 14 Feb 2023 13:56:30 +0100 Subject: [PATCH 114/373] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f94066d3..b772640d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ change warranting a new major release: - Remove 2 TCS threads. - Move low level polling into ACS PST, move high level device handlers into TCS system task. +- Igrf13 model vector now outputs as uT instead of nT # [v1.27.1] 2023-02-13 From 16eab6b26680c44df7d4ab493296ffe6eb8ea58d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 14:01:16 +0100 Subject: [PATCH 115/373] update forwarding scripts for UDP --- scripts/q7s-em-udp-forwarding.sh | 8 ++++++++ scripts/q7s-fm-udp-forwarding.sh | 8 ++++++++ scripts/q7s-ssh-udp-forwarding.sh | 8 -------- 3 files changed, 16 insertions(+), 8 deletions(-) create mode 100755 scripts/q7s-em-udp-forwarding.sh create mode 100755 scripts/q7s-fm-udp-forwarding.sh delete mode 100755 scripts/q7s-ssh-udp-forwarding.sh diff --git a/scripts/q7s-em-udp-forwarding.sh b/scripts/q7s-em-udp-forwarding.sh new file mode 100755 index 00000000..22830efe --- /dev/null +++ b/scripts/q7s-em-udp-forwarding.sh @@ -0,0 +1,8 @@ +#!/bin/bash +echo "Q7S UDP connection from local port 18000 -> TCP ssh tunnel -> EM port 7301" + + +socat udp4-listen:18000,reuseaddr,fork tcp:localhost:18002 & +ssh -L 18002:localhost:18123 eive@flatsat.eive.absatvirt.lw \ + 'CONSOLE_PREFIX="[Q7S EM UDP Tunnel]" \ + /bin/bash && socat tcp4-listen:18123,reuseaddr udp:192.168.133.10:7301' diff --git a/scripts/q7s-fm-udp-forwarding.sh b/scripts/q7s-fm-udp-forwarding.sh new file mode 100755 index 00000000..6bb2b3f2 --- /dev/null +++ b/scripts/q7s-fm-udp-forwarding.sh @@ -0,0 +1,8 @@ +#!/bin/bash +echo "Q7S UDP connection from local port 18000 -> TCP ssh tunnel -> FM port 7301" + + +socat udp4-listen:18000,reuseaddr,fork tcp:localhost:18002 & +ssh -L 18002:localhost:18123 eive@flatsat.eive.absatvirt.lw \ + 'CONSOLE_PREFIX="[Q7S FM UDP Tunnel]" \ + /bin/bash && socat tcp4-listen:18123,reuseaddr udp:192.168.155.55:7301' diff --git a/scripts/q7s-ssh-udp-forwarding.sh b/scripts/q7s-ssh-udp-forwarding.sh deleted file mode 100755 index 35303246..00000000 --- a/scripts/q7s-ssh-udp-forwarding.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -echo "Setting up all Q7S ports" -echo "upd connection from local port 18000 -> tcp ssh tunnel -> EM port 7301" - - -socat udp4-listen:18000,reuseaddr,fork tcp:localhost:18002 & -ssh -L 18002:localhost:18123 eive@flatsat.eive.absatvirt.lw 'socat tcp4-listen:18123,reuseaddr udp:192.168.133.10:7301' - From e07492c85515126257dbeccdf6a7eaf230a301cf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 14:10:37 +0100 Subject: [PATCH 116/373] bump tmtc --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 9b7471e9..20e107c7 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 9b7471e9097edd410995ba0c76125b626440d9be +Subproject commit 20e107c7ae373e7f36fca68957dbc36f4dd76f3b From bf70e8ece45b29eafbb7a92ad9fe975c695afab1 Mon Sep 17 00:00:00 2001 From: meggert Date: Tue, 14 Feb 2023 14:11:45 +0100 Subject: [PATCH 117/373] changed acsPst parts again to give more time to the sensors --- common/config/eive/definitions.h | 15 +- .../pollingSequenceFactory.cpp | 132 +++++++++--------- 2 files changed, 75 insertions(+), 72 deletions(-) diff --git a/common/config/eive/definitions.h b/common/config/eive/definitions.h index c572e21a..9e67176a 100644 --- a/common/config/eive/definitions.h +++ b/common/config/eive/definitions.h @@ -57,14 +57,17 @@ static constexpr uint32_t MAX_STORED_CMDS_TCP = 150; namespace acs { -static constexpr uint32_t SCHED_BLOCK_1_SENSORS_MS = 15; -static constexpr uint32_t SCHED_BLOCK_2_ACS_CTRL_MS = 40; -static constexpr uint32_t SCHED_BLOCK_3_ACTUATOR_MS = 45; +static constexpr uint32_t SCHED_BLOCK_1_SUS_READ_MS = 15; +static constexpr uint32_t SCHED_BLOCK_2_SENSOR_READ_MS = 30; +static constexpr uint32_t SCHED_BLOCK_3_ACS_CTRL_MS = 45; +static constexpr uint32_t SCHED_BLOCK_4_ACTUATOR_MS = 50; // 15 ms for FM -static constexpr float SCHED_BLOCK_1_PERIOD = static_cast(SCHED_BLOCK_1_SENSORS_MS) / 400.0; -static constexpr float SCHED_BLOCK_2_PERIOD = static_cast(SCHED_BLOCK_2_ACS_CTRL_MS) / 400.0; -static constexpr float SCHED_BLOCK_3_PERIOD = static_cast(SCHED_BLOCK_3_ACTUATOR_MS) / 400.0; +static constexpr float SCHED_BLOCK_1_PERIOD = static_cast(SCHED_BLOCK_1_SUS_READ_MS) / 400.0; +static constexpr float SCHED_BLOCK_2_PERIOD = + static_cast(SCHED_BLOCK_2_SENSOR_READ_MS) / 400.0; +static constexpr float SCHED_BLOCK_3_PERIOD = static_cast(SCHED_BLOCK_3_ACS_CTRL_MS) / 400.0; +static constexpr float SCHED_BLOCK_4_PERIOD = static_cast(SCHED_BLOCK_4_ACTUATOR_MS) / 400.0; } // namespace acs diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 63b40df2..b91fcd7a 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -192,103 +192,103 @@ ReturnValue_t pst::pstTcsAndAcs(FixedTimeslotTaskIF *thisSequence, AcsPstCfg cfg if (cfg.scheduleAcsBoard) { if (enableAside) { // A side - thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * config::acs::SCHED_BLOCK_1_PERIOD, + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * config::acs::SCHED_BLOCK_1_PERIOD, + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * config::acs::SCHED_BLOCK_1_PERIOD, + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * config::acs::SCHED_BLOCK_1_PERIOD, + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * config::acs::SCHED_BLOCK_1_PERIOD, + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, - length * config::acs::SCHED_BLOCK_1_PERIOD, + length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, - length * config::acs::SCHED_BLOCK_1_PERIOD, + length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, - length * config::acs::SCHED_BLOCK_1_PERIOD, DeviceHandlerIF::GET_WRITE); + length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::GET_WRITE); thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, - length * config::acs::SCHED_BLOCK_1_PERIOD, DeviceHandlerIF::SEND_READ); + length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, - length * config::acs::SCHED_BLOCK_1_PERIOD, DeviceHandlerIF::GET_READ); + length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, - length * config::acs::SCHED_BLOCK_1_PERIOD, + length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, - length * config::acs::SCHED_BLOCK_1_PERIOD, + length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, - length * config::acs::SCHED_BLOCK_1_PERIOD, DeviceHandlerIF::GET_WRITE); + length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::GET_WRITE); thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, - length * config::acs::SCHED_BLOCK_1_PERIOD, DeviceHandlerIF::SEND_READ); + length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, - length * config::acs::SCHED_BLOCK_1_PERIOD, DeviceHandlerIF::GET_READ); + length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * config::acs::SCHED_BLOCK_1_PERIOD, + thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * config::acs::SCHED_BLOCK_1_PERIOD, + thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * config::acs::SCHED_BLOCK_1_PERIOD, + thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * config::acs::SCHED_BLOCK_1_PERIOD, + thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * config::acs::SCHED_BLOCK_1_PERIOD, + thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::GET_READ); } if (enableBside) { // B side - thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * config::acs::SCHED_BLOCK_1_PERIOD, + thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * config::acs::SCHED_BLOCK_1_PERIOD, + thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * config::acs::SCHED_BLOCK_1_PERIOD, + thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * config::acs::SCHED_BLOCK_1_PERIOD, + thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * config::acs::SCHED_BLOCK_1_PERIOD, + thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, - length * config::acs::SCHED_BLOCK_1_PERIOD, + length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, - length * config::acs::SCHED_BLOCK_1_PERIOD, + length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, - length * config::acs::SCHED_BLOCK_1_PERIOD, DeviceHandlerIF::GET_WRITE); + length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::GET_WRITE); thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, - length * config::acs::SCHED_BLOCK_1_PERIOD, DeviceHandlerIF::SEND_READ); + length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, - length * config::acs::SCHED_BLOCK_1_PERIOD, DeviceHandlerIF::GET_READ); + length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, - length * config::acs::SCHED_BLOCK_1_PERIOD, + length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, - length * config::acs::SCHED_BLOCK_1_PERIOD, + length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, - length * config::acs::SCHED_BLOCK_1_PERIOD, DeviceHandlerIF::GET_WRITE); + length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::GET_WRITE); thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, - length * config::acs::SCHED_BLOCK_1_PERIOD, DeviceHandlerIF::SEND_READ); + length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, - length * config::acs::SCHED_BLOCK_1_PERIOD, DeviceHandlerIF::GET_READ); + length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * config::acs::SCHED_BLOCK_1_PERIOD, + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * config::acs::SCHED_BLOCK_1_PERIOD, + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * config::acs::SCHED_BLOCK_1_PERIOD, + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * config::acs::SCHED_BLOCK_1_PERIOD, + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * config::acs::SCHED_BLOCK_1_PERIOD, + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * config::acs::SCHED_BLOCK_2_PERIOD, DeviceHandlerIF::GET_READ); } } @@ -622,66 +622,66 @@ ReturnValue_t pst::pstTcsAndAcs(FixedTimeslotTaskIF *thisSequence, AcsPstCfg cfg DeviceHandlerIF::GET_READ); } - thisSequence->addSlot(objects::ACS_CONTROLLER, length * config::acs::SCHED_BLOCK_2_PERIOD, 0); + thisSequence->addSlot(objects::ACS_CONTROLLER, length * config::acs::SCHED_BLOCK_3_PERIOD, 0); if (cfg.scheduleImtq) { // This is the torquing cycle. - thisSequence->addSlot(objects::IMTQ_HANDLER, length * config::acs::SCHED_BLOCK_2_PERIOD, + thisSequence->addSlot(objects::IMTQ_HANDLER, length * config::acs::SCHED_BLOCK_4_PERIOD, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::IMTQ_HANDLER, length * config::acs::SCHED_BLOCK_2_PERIOD, + thisSequence->addSlot(objects::IMTQ_HANDLER, length * config::acs::SCHED_BLOCK_4_PERIOD, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::IMTQ_HANDLER, length * config::acs::SCHED_BLOCK_2_PERIOD, + thisSequence->addSlot(objects::IMTQ_HANDLER, length * config::acs::SCHED_BLOCK_4_PERIOD, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::IMTQ_HANDLER, length * config::acs::SCHED_BLOCK_2_PERIOD, + thisSequence->addSlot(objects::IMTQ_HANDLER, length * config::acs::SCHED_BLOCK_4_PERIOD, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::IMTQ_HANDLER, length * config::acs::SCHED_BLOCK_2_PERIOD, + thisSequence->addSlot(objects::IMTQ_HANDLER, length * config::acs::SCHED_BLOCK_4_PERIOD, DeviceHandlerIF::GET_READ); } if (cfg.scheduleRws) { - thisSequence->addSlot(objects::RW1, length * config::acs::SCHED_BLOCK_2_PERIOD, + thisSequence->addSlot(objects::RW1, length * config::acs::SCHED_BLOCK_4_PERIOD, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RW2, length * config::acs::SCHED_BLOCK_2_PERIOD, + thisSequence->addSlot(objects::RW2, length * config::acs::SCHED_BLOCK_4_PERIOD, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RW3, length * config::acs::SCHED_BLOCK_2_PERIOD, + thisSequence->addSlot(objects::RW3, length * config::acs::SCHED_BLOCK_4_PERIOD, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RW4, length * config::acs::SCHED_BLOCK_2_PERIOD, + thisSequence->addSlot(objects::RW4, length * config::acs::SCHED_BLOCK_4_PERIOD, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RW1, length * config::acs::SCHED_BLOCK_2_PERIOD, + thisSequence->addSlot(objects::RW1, length * config::acs::SCHED_BLOCK_4_PERIOD, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW2, length * config::acs::SCHED_BLOCK_2_PERIOD, + thisSequence->addSlot(objects::RW2, length * config::acs::SCHED_BLOCK_4_PERIOD, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW3, length * config::acs::SCHED_BLOCK_2_PERIOD, + thisSequence->addSlot(objects::RW3, length * config::acs::SCHED_BLOCK_4_PERIOD, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW4, length * config::acs::SCHED_BLOCK_2_PERIOD, + thisSequence->addSlot(objects::RW4, length * config::acs::SCHED_BLOCK_4_PERIOD, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW1, length * config::acs::SCHED_BLOCK_2_PERIOD, + thisSequence->addSlot(objects::RW1, length * config::acs::SCHED_BLOCK_4_PERIOD, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW2, length * config::acs::SCHED_BLOCK_2_PERIOD, + thisSequence->addSlot(objects::RW2, length * config::acs::SCHED_BLOCK_4_PERIOD, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW3, length * config::acs::SCHED_BLOCK_2_PERIOD, + thisSequence->addSlot(objects::RW3, length * config::acs::SCHED_BLOCK_4_PERIOD, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW4, length * config::acs::SCHED_BLOCK_2_PERIOD, + thisSequence->addSlot(objects::RW4, length * config::acs::SCHED_BLOCK_4_PERIOD, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW1, length * config::acs::SCHED_BLOCK_2_PERIOD, + thisSequence->addSlot(objects::RW1, length * config::acs::SCHED_BLOCK_4_PERIOD, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW2, length * config::acs::SCHED_BLOCK_2_PERIOD, + thisSequence->addSlot(objects::RW2, length * config::acs::SCHED_BLOCK_4_PERIOD, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW3, length * config::acs::SCHED_BLOCK_2_PERIOD, + thisSequence->addSlot(objects::RW3, length * config::acs::SCHED_BLOCK_4_PERIOD, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW4, length * config::acs::SCHED_BLOCK_2_PERIOD, + thisSequence->addSlot(objects::RW4, length * config::acs::SCHED_BLOCK_4_PERIOD, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW1, length * config::acs::SCHED_BLOCK_2_PERIOD, + thisSequence->addSlot(objects::RW1, length * config::acs::SCHED_BLOCK_4_PERIOD, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RW2, length * config::acs::SCHED_BLOCK_2_PERIOD, + thisSequence->addSlot(objects::RW2, length * config::acs::SCHED_BLOCK_4_PERIOD, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RW3, length * config::acs::SCHED_BLOCK_2_PERIOD, + thisSequence->addSlot(objects::RW3, length * config::acs::SCHED_BLOCK_4_PERIOD, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RW4, length * config::acs::SCHED_BLOCK_2_PERIOD, + thisSequence->addSlot(objects::RW4, length * config::acs::SCHED_BLOCK_4_PERIOD, DeviceHandlerIF::GET_READ); } thisSequence->addSlot(objects::SPI_RTD_COM_IF, length * 0.5, 0); From a0d09e7f2352a940810084e9c4aaf4d49879a82f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 14:15:30 +0100 Subject: [PATCH 118/373] go away --- CMakeLists.txt | 2 +- tmtc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a1f0b37d..5ce19479 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -491,7 +491,7 @@ endif() # Add libraries target_link_libraries(${LIB_EIVE_MISSION} - PUBLIC ${LIB_FSFW_NAME} ${LIB_LWGPS_NAME} ${LIB_OS_NAME}) + PUBLIC ${LIB_FSFW_NAME} ${LIB_OS_NAME}) target_link_libraries(${LIB_DUMMIES} PUBLIC ${LIB_FSFW_NAME} ${LIB_JSON_NAME}) diff --git a/tmtc b/tmtc index 9b7471e9..20e107c7 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 9b7471e9097edd410995ba0c76125b626440d9be +Subproject commit 20e107c7ae373e7f36fca68957dbc36f4dd76f3b From 35b9c7a4df590f28e8ed05c18378c74dd120c475 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 14:27:25 +0100 Subject: [PATCH 119/373] bump changelog --- CHANGELOG.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f49f4ed4..d01f4290 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,8 +19,17 @@ change warranting a new major release: ## Changed -- Remove 2 TCS threads. -- Move low level polling into ACS PST, move high level device handlers into TCS system task. +- Remove 2 TCS threads. Move low level polling into ACS PST, move high level device handlers into + TCS system task. +- Further reduce number of threads: + 1. Remove PUS low priority task, move assigned threads to the generic system task + 2. Group events and verification tasks into PUS high priority task + 3. Group all other components into PUS medium priority task + 4. Add SCEX device handler to PL task, remove dedicated thread + +## Added + +- Tracing supports which allows checking whether threads are running as usual. ## Removed From 024e06a3d33cf85303a62083fb027effef155ff7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 14:28:26 +0100 Subject: [PATCH 120/373] set define to 0 for PR --- mission/trace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mission/trace.h b/mission/trace.h index 59fdd99e..fbc99d37 100644 --- a/mission/trace.h +++ b/mission/trace.h @@ -3,7 +3,7 @@ #include -#define OBSW_THREAD_TRACING 1 +#define OBSW_THREAD_TRACING 0 namespace trace { From 6f84099c5e5e537a312d6221101f892fc8ef83aa Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 14:29:47 +0100 Subject: [PATCH 121/373] small update and afmt --- CMakeLists.txt | 4 ++-- linux/boardtest/UartTestClass.h | 2 +- linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp | 3 +-- mission/devices/SolarArrayDeploymentHandler.cpp | 5 +---- test/TestTask.cpp | 3 --- 5 files changed, 5 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ce19479..8a8055bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -490,8 +490,8 @@ endif() # ############################################################################## # Add libraries -target_link_libraries(${LIB_EIVE_MISSION} - PUBLIC ${LIB_FSFW_NAME} ${LIB_OS_NAME}) +target_link_libraries(${LIB_EIVE_MISSION} PUBLIC ${LIB_FSFW_NAME} + ${LIB_OS_NAME}) target_link_libraries(${LIB_DUMMIES} PUBLIC ${LIB_FSFW_NAME} ${LIB_JSON_NAME}) diff --git a/linux/boardtest/UartTestClass.h b/linux/boardtest/UartTestClass.h index 6cb0d31c..fd20e621 100644 --- a/linux/boardtest/UartTestClass.h +++ b/linux/boardtest/UartTestClass.h @@ -59,7 +59,7 @@ class UartTestClass : public TestTask { DleEncoder dleEncoder = DleEncoder(); SerialCookie* uartCookie = nullptr; size_t encodedLen = 0; - //lwgps_t gpsData = {}; + // lwgps_t gpsData = {}; struct termios tty = {}; int serialPort = 0; bool startFound = false; diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 062bf7e7..d8df8e9a 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -1,12 +1,11 @@ #include "pollingSequenceFactory.h" -#include "OBSWConfig.h" - #include #include #include #include +#include "OBSWConfig.h" #include "eive/definitions.h" #include "mission/devices/devicedefinitions/Max31865Definitions.h" diff --git a/mission/devices/SolarArrayDeploymentHandler.cpp b/mission/devices/SolarArrayDeploymentHandler.cpp index cb8658bc..77c826fd 100644 --- a/mission/devices/SolarArrayDeploymentHandler.cpp +++ b/mission/devices/SolarArrayDeploymentHandler.cpp @@ -39,10 +39,7 @@ SolarArrayDeploymentHandler::~SolarArrayDeploymentHandler() = default; ReturnValue_t SolarArrayDeploymentHandler::performOperation(uint8_t operationCode) { using namespace std::filesystem; #if OBSW_THREAD_TRACING == 1 - opCounter++; - if (opCounter % 5 == 0) { - sif::debug << "SA DEPL task running" << std::endl; - } + trace::threadTrace(opCounter, "SA DEPL"); #endif if (opDivider.checkAndIncrement()) { auto activeSdc = sdcMan.getActiveSdCard(); diff --git a/test/TestTask.cpp b/test/TestTask.cpp index 33af5494..2c6cb015 100644 --- a/test/TestTask.cpp +++ b/test/TestTask.cpp @@ -42,10 +42,8 @@ ReturnValue_t EiveTestTask::performOperation(uint8_t operationCode) { #include - // #include - /** * @brief Dummy data from GPS receiver. Will be replaced witgh hyperion data later. */ @@ -76,7 +74,6 @@ const char hyperion_gps_data[] = "$GNVTG,040.7,T,,M,000.0,N,000.0,K,A*10\r\n" "$GNZDA,173225.998892,27,02,2021,00,00*75\r\n"; - ReturnValue_t EiveTestTask::performOneShotAction() { #if OBSW_ADD_TEST_CODE == 1 // performLwgpsTest(); From a26924fa0461d10f48cf436ba8b4eb987abb5b31 Mon Sep 17 00:00:00 2001 From: meggert Date: Tue, 14 Feb 2023 14:32:54 +0100 Subject: [PATCH 122/373] frmt --- mission/controller/acs/ActuatorCmd.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/mission/controller/acs/ActuatorCmd.cpp b/mission/controller/acs/ActuatorCmd.cpp index 4e0052e0..01befd93 100644 --- a/mission/controller/acs/ActuatorCmd.cpp +++ b/mission/controller/acs/ActuatorCmd.cpp @@ -1,10 +1,3 @@ -/* - * ActuatorCmd.cpp - * - * Created on: 4 Aug 2022 - * Author: Robin Marquardt - */ - #include "ActuatorCmd.h" #include From d506b515fc63476304e2d7934096549ecce2fa13 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 14:33:12 +0100 Subject: [PATCH 123/373] bump fsfw --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index d256ede8..9de6c4b3 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit d256ede8c1d8e7a746d3a56d45313d2b863e0b28 +Subproject commit 9de6c4b3aa20ee63c28051d486be8a12df147f22 From 918cd7b237be07ca6ca3a3568eac58cb2eb6377d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 14:38:33 +0100 Subject: [PATCH 124/373] small tweak for scripts, bump fsfw --- fsfw | 2 +- scripts/q7s-em-udp-forwarding.sh | 3 +-- scripts/q7s-fm-udp-forwarding.sh | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/fsfw b/fsfw index d256ede8..9de6c4b3 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit d256ede8c1d8e7a746d3a56d45313d2b863e0b28 +Subproject commit 9de6c4b3aa20ee63c28051d486be8a12df147f22 diff --git a/scripts/q7s-em-udp-forwarding.sh b/scripts/q7s-em-udp-forwarding.sh index 22830efe..284e7889 100755 --- a/scripts/q7s-em-udp-forwarding.sh +++ b/scripts/q7s-em-udp-forwarding.sh @@ -4,5 +4,4 @@ echo "Q7S UDP connection from local port 18000 -> TCP ssh tunnel -> EM port 7301 socat udp4-listen:18000,reuseaddr,fork tcp:localhost:18002 & ssh -L 18002:localhost:18123 eive@flatsat.eive.absatvirt.lw \ - 'CONSOLE_PREFIX="[Q7S EM UDP Tunnel]" \ - /bin/bash && socat tcp4-listen:18123,reuseaddr udp:192.168.133.10:7301' + 'socat tcp4-listen:18123,reuseaddr udp:192.168.133.10:7301' diff --git a/scripts/q7s-fm-udp-forwarding.sh b/scripts/q7s-fm-udp-forwarding.sh index 6bb2b3f2..34c8421f 100755 --- a/scripts/q7s-fm-udp-forwarding.sh +++ b/scripts/q7s-fm-udp-forwarding.sh @@ -4,5 +4,4 @@ echo "Q7S UDP connection from local port 18000 -> TCP ssh tunnel -> FM port 7301 socat udp4-listen:18000,reuseaddr,fork tcp:localhost:18002 & ssh -L 18002:localhost:18123 eive@flatsat.eive.absatvirt.lw \ - 'CONSOLE_PREFIX="[Q7S FM UDP Tunnel]" \ - /bin/bash && socat tcp4-listen:18123,reuseaddr udp:192.168.155.55:7301' + 'socat tcp4-listen:18123,reuseaddr udp:192.168.155.55:7301' From 11e06f6b21b92d3e994980496ea97f147e5fb0d0 Mon Sep 17 00:00:00 2001 From: meggert Date: Tue, 14 Feb 2023 17:14:14 +0100 Subject: [PATCH 125/373] acsParam fix --- mission/controller/acs/AcsParameters.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mission/controller/acs/AcsParameters.h b/mission/controller/acs/AcsParameters.h index f1c0fb63..60efe01f 100644 --- a/mission/controller/acs/AcsParameters.h +++ b/mission/controller/acs/AcsParameters.h @@ -779,9 +779,9 @@ class AcsParameters : public HasParametersIF { /* var = sqrt(sigma), sigma = RND*sqrt(freq), following values are RND^2 and not var as freq is * assumed to be equal for the same class of sensors */ - float gyr02variance[3] = {pow(3.0e-3 * sqrt(2), 2), // RND_x = 3.0e-3 deg/s/sqrt(Hz) rms - pow(3.0e-3 * sqrt(2), 2), // RND_y = 3.0e-3 deg/s/sqrt(Hz) rms - pow(4.3e-3 * sqrt(2), 2)}; // RND_z = 4.3e-3 deg/s/sqrt(Hz) rms + float gyr02variance[3] = {pow(3.0e-3, 2), // RND_x = 3.0e-3 deg/s/sqrt(Hz) rms + pow(3.0e-3, 2), // RND_y = 3.0e-3 deg/s/sqrt(Hz) rms + pow(4.3e-3, 2)}; // RND_z = 4.3e-3 deg/s/sqrt(Hz) rms float gyr13variance[3] = {pow(11e-3, 2), pow(11e-3, 2), pow(11e-3, 2)}; uint8_t preferAdis = true; } gyrHandlingParameters; From 166fd77f7b6a17486d9fc43813183ab63e76cb88 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 18:41:43 +0100 Subject: [PATCH 126/373] stupid RW --- bsp_q7s/core/ObjectFactory.cpp | 4 +- .../pollingSequenceFactory.cpp | 148 +++++++++--------- mission/devices/ImtqHandler.cpp | 26 ++- mission/devices/RwHandler.cpp | 48 +++--- mission/devices/RwHandler.h | 9 +- 5 files changed, 116 insertions(+), 119 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 2bf36743..2631a628 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -683,8 +683,8 @@ void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF, RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, nullptr); auto* rwHandler = new RwHandler(rwIds[idx], objects::SPI_RW_COM_IF, rwCookies[idx], gpioComIF, - rwGpioIds[idx]); - rwCookies[idx]->setCallbackArgs(rws[idx]); + rwGpioIds[idx], idx); + rwCookies[idx]->setCallbackArgs(rwHandler); #if OBSW_TEST_RW == 1 rws[idx]->setStartUpImmediately(); #endif diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index e404cdf7..7e4cafeb 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -633,80 +633,80 @@ ReturnValue_t pst::pstTcsAndAcs(FixedTimeslotTaskIF *thisSequence, AcsPstCfg cfg } if (cfg.scheduleRws) { - thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - - thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::SEND_WRITE); - - thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::GET_WRITE); - - thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::SEND_READ); - - thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::GET_READ); - - thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - - thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::SEND_WRITE); - - thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::GET_WRITE); - - thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::SEND_READ); - - thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::GET_READ); - - thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - - thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::SEND_WRITE); - - thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::GET_WRITE); - - thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::SEND_READ); - - thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::GET_READ); + // thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + // + // thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::SEND_WRITE); + // thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::SEND_WRITE); + // thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::SEND_WRITE); + // thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::SEND_WRITE); + // + // thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::GET_WRITE); + // + // thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::SEND_READ); + // + // thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::GET_READ); + // thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::GET_READ); + // thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::GET_READ); + // thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::GET_READ); + // + // thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + // + // thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::SEND_WRITE); + // thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::SEND_WRITE); + // thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::SEND_WRITE); + // thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::SEND_WRITE); + // + // thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::GET_WRITE); + // + // thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::SEND_READ); + // + // thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::GET_READ); + // thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::GET_READ); + // thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::GET_READ); + // thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::GET_READ); + // + // thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + // + // thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::SEND_WRITE); + // thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::SEND_WRITE); + // thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::SEND_WRITE); + // thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::SEND_WRITE); + // + // thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::GET_WRITE); + // + // thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::SEND_READ); + // + // thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::GET_READ); + // thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::GET_READ); + // thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::GET_READ); + // thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::GET_READ); } if (cfg.scheduleRws) { diff --git a/mission/devices/ImtqHandler.cpp b/mission/devices/ImtqHandler.cpp index b370b7d9..93e9dae8 100644 --- a/mission/devices/ImtqHandler.cpp +++ b/mission/devices/ImtqHandler.cpp @@ -183,22 +183,20 @@ ReturnValue_t ImtqHandler::buildCommandFromCommand(DeviceCommandId_t deviceComma return DeviceHandlerIF::INVALID_COMMAND_PARAMETER; } ReturnValue_t result; - // Commands override anything which was set in the software - if (commandData != nullptr) { - dipoleSet.setValidityBufferGeneration(false); - result = - dipoleSet.deSerialize(&commandData, &commandDataLen, SerializeIF::Endianness::NETWORK); - dipoleSet.setValidityBufferGeneration(true); - if (result != returnvalue::OK) { - return result; - } - result = dipoleSet.commit(); - if (result != returnvalue::OK) { - sif::error << "ImtqHandler::buildCommandFromCommand: commit failed" << std::endl; - } - } else { + { // Read set dipole values from local pool PoolReadGuard pg(&dipoleSet); + + // Commands override anything which was set in the software + if (commandData != nullptr) { + dipoleSet.setValidityBufferGeneration(false); + result = dipoleSet.deSerialize(&commandData, &commandDataLen, + SerializeIF::Endianness::NETWORK); + dipoleSet.setValidityBufferGeneration(true); + if (result != returnvalue::OK) { + return result; + } + } } if (ACTUATION_WIRETAPPING) { sif::debug << "Actuating IMTQ with parameters x = " << dipoleSet.xDipole.value diff --git a/mission/devices/RwHandler.cpp b/mission/devices/RwHandler.cpp index 5c6914be..9d4a7255 100644 --- a/mission/devices/RwHandler.cpp +++ b/mission/devices/RwHandler.cpp @@ -7,14 +7,15 @@ #include "OBSWConfig.h" RwHandler::RwHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, - GpioIF* gpioComIF, gpioId_t enableGpio) + GpioIF* gpioComIF, gpioId_t enableGpio, uint8_t rwIdx) : DeviceHandlerBase(objectId, comIF, comCookie), gpioComIF(gpioComIF), enableGpio(enableGpio), statusSet(this), lastResetStatusSet(this), tmDataset(this), - rwSpeedActuationSet(*this) { + rwSpeedActuationSet(*this), + rwIdx(rwIdx) { if (comCookie == nullptr) { sif::error << "RwHandler: Invalid com cookie" << std::endl; } @@ -43,6 +44,10 @@ void RwHandler::doShutDown() { ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { switch (internalState) { + case InternalState::SET_SPEED: + *id = RwDefinitions::SET_SPEED; + internalState = InternalState::GET_RESET_STATUS; + break; case InternalState::GET_RESET_STATUS: *id = RwDefinitions::GET_LAST_RESET_STATUS; internalState = InternalState::READ_TEMPERATURE; @@ -53,10 +58,6 @@ ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { break; case InternalState::GET_RW_SATUS: *id = RwDefinitions::GET_RW_STATUS; - internalState = InternalState::SET_SPEED; - break; - case InternalState::SET_SPEED: - *id = RwDefinitions::SET_SPEED; internalState = InternalState::CLEAR_RESET_STATUS; break; case InternalState::CLEAR_RESET_STATUS: @@ -107,29 +108,26 @@ ReturnValue_t RwHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand << " invalid length" << std::endl; return SET_SPEED_COMMAND_INVALID_LENGTH; } - // Commands override anything which was set in the software - if (commandData != nullptr) { - rwSpeedActuationSet.setValidityBufferGeneration(false); - result = rwSpeedActuationSet.deSerialize(&commandData, &commandDataLen, - SerializeIF::Endianness::NETWORK); - rwSpeedActuationSet.setValidityBufferGeneration(true); - if (result != returnvalue::OK) { - return result; - } - result = rwSpeedActuationSet.commit(); - if (result != returnvalue::OK) { - sif::error << "RwHandler::buildCommandFromCommand: commit failed" << std::endl; - } - } else { - // Read set rw speed value from local pool + + { PoolReadGuard pg(&rwSpeedActuationSet); + // Commands override anything which was set in the software + if (commandData != nullptr) { + rwSpeedActuationSet.setValidityBufferGeneration(false); + result = rwSpeedActuationSet.deSerialize(&commandData, &commandDataLen, + SerializeIF::Endianness::NETWORK); + rwSpeedActuationSet.setValidityBufferGeneration(true); + if (result != returnvalue::OK) { + return result; + } + } } if (ACTUATION_WIRETAPPING) { - int32_t speed; - uint16_t rampTime; + int32_t speed = 0; + uint16_t rampTime = 0; rwSpeedActuationSet.getRwSpeed(speed, rampTime); - sif::debug << "Actuating RW with speed = " << speed << " and rampTime = " << rampTime - << std::endl; + sif::debug << "Actuating RW " << static_cast(rwIdx) << " with speed = " << speed + << " and rampTime = " << rampTime << std::endl; } result = checkSpeedAndRampTime(); if (result != returnvalue::OK) { diff --git a/mission/devices/RwHandler.h b/mission/devices/RwHandler.h index 148a6359..ee18960d 100644 --- a/mission/devices/RwHandler.h +++ b/mission/devices/RwHandler.h @@ -9,7 +9,7 @@ #include "events/subsystemIdRanges.h" #include "returnvalues/classIds.h" -static constexpr bool ACTUATION_WIRETAPPING = true; +static constexpr bool ACTUATION_WIRETAPPING = false; class GpioIF; @@ -36,7 +36,7 @@ class RwHandler : public DeviceHandlerBase { * to high to enable the device. */ RwHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, GpioIF* gpioComIF, - gpioId_t enableGpio); + gpioId_t enableGpio, uint8_t rwIdx); void setDebugMode(bool enable); @@ -98,9 +98,10 @@ class RwHandler : public DeviceHandlerBase { RwDefinitions::RwSpeedActuationSet rwSpeedActuationSet; uint8_t commandBuffer[RwDefinitions::MAX_CMD_SIZE]; + uint8_t rwIdx; - PoolEntry rwSpeed = PoolEntry(0, false); - PoolEntry rampTime = PoolEntry(10, false); + PoolEntry rwSpeed = PoolEntry({0}); + PoolEntry rampTime = PoolEntry({10}); enum class InternalState { GET_RESET_STATUS, From 177b573cd4ae4c47724167607f8df472834b9746 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 18:54:43 +0100 Subject: [PATCH 127/373] prep v1.27.2 --- CHANGELOG.md | 7 +++++++ CMakeLists.txt | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 417f6522..a8b2ef0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,13 @@ change warranting a new major release: # [unreleased] +# [v1.27.2] 2023-02-14 + +Reaction Wheel handling was determined to be (quasi) broken and needs to be fixed in future release +to be usable by ACS controller. + +eive-tmtc: v2.15.6 + ## Added - Function for the ACS controller to command MTQ and RWs called by all subroutines diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a8055bd..4f62c199 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ cmake_minimum_required(VERSION 3.13) set(OBSW_VERSION_MAJOR 1) set(OBSW_VERSION_MINOR 27) -set(OBSW_VERSION_REVISION 1) +set(OBSW_VERSION_REVISION 2) # set(CMAKE_VERBOSE TRUE) From a13ae7abcc5666e60c6077d498ec6eb32aaed725 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Wed, 15 Feb 2023 10:21:35 +0100 Subject: [PATCH 128/373] pdec ad frame config, wip --- fsfw | 2 +- linux/ipcore/PdecConfig.cpp | 6 +++++- linux/ipcore/PdecConfig.h | 10 ++-------- linux/ipcore/pdecconfigdefs.h | 20 ++++++++++++++++++++ tmtc | 2 +- 5 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 linux/ipcore/pdecconfigdefs.h diff --git a/fsfw b/fsfw index 01cc619e..dac2d210 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 01cc619e67b84cef514b045377771ff1e11caf80 +Subproject commit dac2d210b597adfaf45bd5ae6a4c027599927601 diff --git a/linux/ipcore/PdecConfig.cpp b/linux/ipcore/PdecConfig.cpp index 152ea320..173ee477 100644 --- a/linux/ipcore/PdecConfig.cpp +++ b/linux/ipcore/PdecConfig.cpp @@ -1,4 +1,5 @@ #include "PdecConfig.h" +#include "pdecconfigdefs.h" #include "fsfw/serviceinterface/ServiceInterface.h" @@ -74,11 +75,14 @@ void PdecConfig::writeFrameHeaderFirstOctet() { word |= (SPACECRAFT_ID << 16); word |= (VIRTUAL_CHANNEL << 10); word |= (DUMMY_BITS << 8); - word |= positiveWindow; + word |= localParameterHandler.getValue(pdecconfigdefs::paramkeys::POSITIVE_WINDOW, + pdecconfigdefs::defaultvalue::positiveWindow); *(memoryBaseAddress + FRAME_HEADER_OFFSET) = word; } void PdecConfig::writeFrameHeaderSecondOctet() { + uint8_t negativeWindow = localParameterHandler.getValue(pdecconfigdefs::paramkeys::NEGATIVE_WINDOW, + pdecconfigdefs::defaultvalue::negativeWindow); uint32_t word = 0; word = 0; word |= (negativeWindow << 24); diff --git a/linux/ipcore/PdecConfig.h b/linux/ipcore/PdecConfig.h index 0b665c6c..fa471775 100644 --- a/linux/ipcore/PdecConfig.h +++ b/linux/ipcore/PdecConfig.h @@ -1,7 +1,7 @@ #ifndef LINUX_OBC_PDECCONFIG_H_ #define LINUX_OBC_PDECCONFIG_H_ -#include +#include #include "bsp_q7s/memory/LocalParameterHandler.h" #include "bsp_q7s/fs/SdCardManager.h" @@ -49,6 +49,7 @@ class PdecConfig { uint8_t getNegativeWindow(); private: + // TC transfer frame configuration parameters static const uint8_t VERSION_ID = 0; // BD Frames @@ -95,13 +96,6 @@ class PdecConfig { bool enableTcAbortIrq = true; bool enableNewFarIrq = true; - NVMParameterBase persistenParams; - - // Parameters to control the FARM for AD frames - // Set here for future use - uint8_t positiveWindow = 10; - uint8_t negativeWindow = 151; - void writeFrameHeaderFirstOctet(); void writeFrameHeaderSecondOctet(); void writeMapConfig(); diff --git a/linux/ipcore/pdecconfigdefs.h b/linux/ipcore/pdecconfigdefs.h new file mode 100644 index 00000000..bc2cfa8c --- /dev/null +++ b/linux/ipcore/pdecconfigdefs.h @@ -0,0 +1,20 @@ +#ifndef LINUX_IPCORE_PDECCONFIGDEFS_H_ +#define LINUX_IPCORE_PDECCONFIGDEFS_H_ + +#include + +namespace pdecconfigdefs { + +namespace paramkeys { + static const std::string POSITIVE_WINDOW = "positive_window"; + static const std::string NEGATIVE_WINDOW = "negattive_window"; +} + +namespace defaultvalue { + static const uint8_t positiveWindow = 10; + static const uint8_t negativeWindow = 151; +} + +} + +#endif /* LINUX_IPCORE_PDECCONFIGDEFS_H_ */ diff --git a/tmtc b/tmtc index a3a3aaa8..8d036bcd 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit a3a3aaa8836b425c923eb97e49ed29b452377bf6 +Subproject commit 8d036bcd4fed1211ad5b15ddae7b42e61e22fcfd From 7c68de26d28bad54d0a86b1eb633092eef270bf5 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 15 Feb 2023 11:42:00 +0100 Subject: [PATCH 129/373] added actual variances for MGM sensor fusion --- mission/controller/acs/AcsParameters.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mission/controller/acs/AcsParameters.h b/mission/controller/acs/AcsParameters.h index b237a0f2..f68b10cf 100644 --- a/mission/controller/acs/AcsParameters.h +++ b/mission/controller/acs/AcsParameters.h @@ -73,9 +73,9 @@ class AcsParameters : public HasParametersIF { {-0.007534, 1.253879, 0.006812}, {-0.037072, 0.006812, 1.313158}}; - float mgm02variance[3] = {1, 1, 1}; - float mgm13variance[3] = {1, 1, 1}; - float mgm4variance[3] = {1, 1, 1}; + float mgm02variance[3] = {pow(3.2e-7, 2), pow(3.2e-7, 2), pow(4.1e-7, 2)}; + float mgm13variance[3] = {pow(1.5e-8, 2), pow(1.5e-8, 2), pow(1.5e-8, 2)}; + float mgm4variance[3] = {pow(1.7e-6, 2), pow(1.7e-6, 2), pow(1.7e-6, 2)}; } mgmHandlingParameters; struct SusHandlingParameters { From f784d4f2480b192e3cd2eb736790ea89f8cf72f7 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 15 Feb 2023 15:15:30 +0100 Subject: [PATCH 130/373] changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ecbb7302..9c1319d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,11 @@ change warranting a new major release: ## Changed - Igrf13 model vector now outputs as uT instead of nT +- Changed timings for `AcsPst` +- Added values for MGM sensor fusion + +## Fixed +- Fixed values for GYR sensor fusion # [v1.27.2] 2023-02-14 From 8b0eceb072a4edbcc45b1abb5ca6532286987461 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Feb 2023 17:02:22 +0100 Subject: [PATCH 131/373] continue rw refactoring --- bsp_q7s/callbacks/rwSpiCallback.cpp | 24 +- bsp_q7s/core/ObjectFactory.cpp | 8 +- dummies/RwDummy.cpp | 64 +-- linux/devices/CMakeLists.txt | 2 +- linux/devices/RwPollingTask.cpp | 401 ++++++++++++++++++ linux/devices/RwPollingTask.h | 78 ++++ mission/controller/AcsController.h | 10 +- mission/controller/ThermalController.cpp | 10 +- mission/controller/acs/SensorValues.h | 11 +- mission/devices/RwHandler.cpp | 184 ++++---- mission/devices/RwHandler.h | 30 +- .../devices/devicedefinitions/rwHelpers.cpp | 6 + .../{RwDefinitions.h => rwHelpers.h} | 123 ++++-- 13 files changed, 739 insertions(+), 212 deletions(-) create mode 100644 linux/devices/RwPollingTask.cpp create mode 100644 linux/devices/RwPollingTask.h create mode 100644 mission/devices/devicedefinitions/rwHelpers.cpp rename mission/devices/devicedefinitions/{RwDefinitions.h => rwHelpers.h} (67%) diff --git a/bsp_q7s/callbacks/rwSpiCallback.cpp b/bsp_q7s/callbacks/rwSpiCallback.cpp index 74ede602..7f71a004 100644 --- a/bsp_q7s/callbacks/rwSpiCallback.cpp +++ b/bsp_q7s/callbacks/rwSpiCallback.cpp @@ -76,7 +76,7 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; closeSpi(fileDescriptor, gpioId, &gpioIF, mutex); - return RwHandler::SPI_WRITE_FAILURE; + return rws::SPI_WRITE_FAILURE; } /** Encoding and sending command */ @@ -101,7 +101,7 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; closeSpi(fileDescriptor, gpioId, &gpioIF, mutex); - return RwHandler::SPI_WRITE_FAILURE; + return rws::SPI_WRITE_FAILURE; } idx++; } @@ -113,7 +113,7 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; closeSpi(fileDescriptor, gpioId, &gpioIF, mutex); - return RwHandler::SPI_WRITE_FAILURE; + return rws::SPI_WRITE_FAILURE; } uint8_t* rxBuf = nullptr; @@ -128,7 +128,7 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen // There must be a delay of at least 20 ms after sending the command. // Delay for 70 ms here and release the SPI bus for that duration. closeSpi(fileDescriptor, gpioId, &gpioIF, mutex); - usleep(RwDefinitions::SPI_REPLY_DELAY); + usleep(rws::SPI_REPLY_DELAY); result = openSpi(dev, O_RDWR, &gpioIF, gpioId, mutex, timeoutType, timeoutMs, fileDescriptor); if (result != returnvalue::OK) { return result; @@ -143,13 +143,13 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen if (read(fileDescriptor, &byteRead, 1) != 1) { sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; closeSpi(fileDescriptor, gpioId, &gpioIF, mutex); - return RwHandler::SPI_READ_FAILURE; + return rws::SPI_READ_FAILURE; } if (idx == 0) { if (byteRead != FLAG_BYTE) { sif::error << "Invalid data, expected start marker" << std::endl; closeSpi(fileDescriptor, gpioId, &gpioIF, mutex); - return RwHandler::NO_START_MARKER; + return rws::NO_START_MARKER; } } @@ -160,7 +160,7 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen if (idx == 9) { sif::error << "rwSpiCallback::spiCallback: Empty frame timeout" << std::endl; closeSpi(fileDescriptor, gpioId, &gpioIF, mutex); - return RwHandler::NO_REPLY; + return rws::NO_REPLY; } } @@ -175,7 +175,7 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen byteRead = 0; if (read(fileDescriptor, &byteRead, 1) != 1) { sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; - result = RwHandler::SPI_READ_FAILURE; + result = rws::SPI_READ_FAILURE; break; } } @@ -186,7 +186,7 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen } else if (byteRead == 0x7D) { if (read(fileDescriptor, &byteRead, 1) != 1) { sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; - result = RwHandler::SPI_READ_FAILURE; + result = rws::SPI_READ_FAILURE; break; } if (byteRead == 0x5E) { @@ -200,7 +200,7 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen } else { sif::error << "rwSpiCallback::spiCallback: Invalid substitute" << std::endl; closeSpi(fileDescriptor, gpioId, &gpioIF, mutex); - result = RwHandler::INVALID_SUBSTITUTE; + result = rws::INVALID_SUBSTITUTE; break; } } else { @@ -217,14 +217,14 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie* cookie, const uint8_t* sen if (decodedFrameLen == replyBufferSize) { if (read(fileDescriptor, &byteRead, 1) != 1) { sif::error << "rwSpiCallback::spiCallback: Failed to read last byte" << std::endl; - result = RwHandler::SPI_READ_FAILURE; + result = rws::SPI_READ_FAILURE; break; } if (byteRead != FLAG_BYTE) { sif::error << "rwSpiCallback::spiCallback: Missing end sign " << static_cast(FLAG_BYTE) << std::endl; decodedFrameLen--; - result = RwHandler::MISSING_END_SIGN; + result = rws::MISSING_END_SIGN; break; } } diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 2631a628..1f920f6d 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -58,6 +58,7 @@ #include #include #include +#include #include @@ -94,7 +95,6 @@ #include "mission/devices/devicedefinitions/GomspaceDefinitions.h" #include "mission/devices/devicedefinitions/Max31865Definitions.h" #include "mission/devices/devicedefinitions/RadSensorDefinitions.h" -#include "mission/devices/devicedefinitions/RwDefinitions.h" #include "mission/devices/devicedefinitions/SyrlinksDefinitions.h" #include "mission/devices/devicedefinitions/payloadPcduDefinitions.h" #include "mission/system/objects/AcsBoardAssembly.h" @@ -679,9 +679,9 @@ void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF, gpioIds::EN_RW4}; std::array rws = {}; for (uint8_t idx = 0; idx < rwCookies.size(); idx++) { - rwCookies[idx] = new SpiCookie(rwCookieParams[idx].first, rwCookieParams[idx].second, - RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, - &rwSpiCallback::spiCallback, nullptr); + rwCookies[idx] = + new SpiCookie(rwCookieParams[idx].first, rwCookieParams[idx].second, rws::MAX_REPLY_SIZE, + spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, nullptr); auto* rwHandler = new RwHandler(rwIds[idx], objects::SPI_RW_COM_IF, rwCookies[idx], gpioComIF, rwGpioIds[idx], idx); rwCookies[idx]->setCallbackArgs(rwHandler); diff --git a/dummies/RwDummy.cpp b/dummies/RwDummy.cpp index a21e7ab7..54e7ac83 100644 --- a/dummies/RwDummy.cpp +++ b/dummies/RwDummy.cpp @@ -1,6 +1,6 @@ #include "RwDummy.h" -#include +#include RwDummy::RwDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie) : DeviceHandlerBase(objectId, comif, comCookie) {} @@ -37,39 +37,39 @@ uint32_t RwDummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return ReturnValue_t RwDummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { - localDataPoolMap.emplace(RwDefinitions::TEMPERATURE_C, new PoolEntry({0})); + localDataPoolMap.emplace(rws::TEMPERATURE_C, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::CURR_SPEED, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::REFERENCE_SPEED, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::STATE, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::CLC_MODE, new PoolEntry({0})); + localDataPoolMap.emplace(rws::CURR_SPEED, new PoolEntry({0})); + localDataPoolMap.emplace(rws::REFERENCE_SPEED, new PoolEntry({0})); + localDataPoolMap.emplace(rws::STATE, new PoolEntry({0})); + localDataPoolMap.emplace(rws::CLC_MODE, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::LAST_RESET_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::CURRRENT_RESET_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(rws::LAST_RESET_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(rws::CURRRENT_RESET_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::TM_LAST_RESET_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::TM_MCU_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::PRESSURE_SENSOR_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::PRESSURE, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::TM_RW_STATE, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::TM_CLC_MODE, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::TM_RW_CURR_SPEED, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::TM_RW_REF_SPEED, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::INVALID_CRC_PACKETS, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::INVALID_LEN_PACKETS, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::INVALID_CMD_PACKETS, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::EXECUTED_REPLIES, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::COMMAND_REPLIES, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::UART_BYTES_WRITTEN, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::UART_BYTES_READ, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::UART_PARITY_ERRORS, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::UART_NOISE_ERRORS, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::UART_FRAME_ERRORS, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::UART_REG_OVERRUN_ERRORS, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::UART_TOTAL_ERRORS, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::SPI_BYTES_WRITTEN, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::SPI_BYTES_READ, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::SPI_REG_OVERRUN_ERRORS, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::SPI_TOTAL_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(rws::TM_LAST_RESET_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(rws::TM_MCU_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(rws::PRESSURE_SENSOR_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(rws::PRESSURE, new PoolEntry({0})); + localDataPoolMap.emplace(rws::TM_RW_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(rws::TM_CLC_MODE, new PoolEntry({0})); + localDataPoolMap.emplace(rws::TM_RW_CURR_SPEED, new PoolEntry({0})); + localDataPoolMap.emplace(rws::TM_RW_REF_SPEED, new PoolEntry({0})); + localDataPoolMap.emplace(rws::INVALID_CRC_PACKETS, new PoolEntry({0})); + localDataPoolMap.emplace(rws::INVALID_LEN_PACKETS, new PoolEntry({0})); + localDataPoolMap.emplace(rws::INVALID_CMD_PACKETS, new PoolEntry({0})); + localDataPoolMap.emplace(rws::EXECUTED_REPLIES, new PoolEntry({0})); + localDataPoolMap.emplace(rws::COMMAND_REPLIES, new PoolEntry({0})); + localDataPoolMap.emplace(rws::UART_BYTES_WRITTEN, new PoolEntry({0})); + localDataPoolMap.emplace(rws::UART_BYTES_READ, new PoolEntry({0})); + localDataPoolMap.emplace(rws::UART_PARITY_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(rws::UART_NOISE_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(rws::UART_FRAME_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(rws::UART_REG_OVERRUN_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(rws::UART_TOTAL_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(rws::SPI_BYTES_WRITTEN, new PoolEntry({0})); + localDataPoolMap.emplace(rws::SPI_BYTES_READ, new PoolEntry({0})); + localDataPoolMap.emplace(rws::SPI_REG_OVERRUN_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(rws::SPI_TOTAL_ERRORS, new PoolEntry({0})); return returnvalue::OK; } diff --git a/linux/devices/CMakeLists.txt b/linux/devices/CMakeLists.txt index 4864e01f..7251b802 100644 --- a/linux/devices/CMakeLists.txt +++ b/linux/devices/CMakeLists.txt @@ -4,7 +4,7 @@ endif() target_sources( ${OBSW_NAME} PRIVATE Max31865RtdLowlevelHandler.cpp ScexUartReader.cpp - ScexDleParser.cpp ScexHelper.cpp) + ScexDleParser.cpp ScexHelper.cpp RwPollingTask.cpp) add_subdirectory(ploc) diff --git a/linux/devices/RwPollingTask.cpp b/linux/devices/RwPollingTask.cpp new file mode 100644 index 00000000..ca663c07 --- /dev/null +++ b/linux/devices/RwPollingTask.cpp @@ -0,0 +1,401 @@ +#include "RwPollingTask.h" + +#include +#include +#include +#include +#include +#include + +#include "devConf.h" +#include "mission/devices/devicedefinitions/rwHelpers.h" + +RwPollingTask::RwPollingTask(object_id_t objectId, SpiComIF* spiIF) + : SystemObject(objectId), spiIF(spiIF) { + semaphore = SemaphoreFactory::instance()->createBinarySemaphore(); + semaphore->acquire(); + ipcLock = MutexFactory::instance()->createMutex(); +} + +ReturnValue_t RwPollingTask::performOperation(uint8_t operationCode) { + ipcLock->lockMutex(); + state = InternalState::IDLE; + ipcLock->unlockMutex(); + while (true) { + semaphore->acquire(); + for (unsigned idx = 0; idx < rwCookies.size(); idx++) { + prepareSetSpeedCmd(idx); + writeOneRw(idx); + } + readAllRws(fd, spiLock, dev) + // writeAndReadAllRws(sendData, sendDataLen) + int bytesRead = 0; + } + return returnvalue::OK; +} + +ReturnValue_t RwPollingTask::initialize() { return returnvalue::OK; } + +ReturnValue_t RwPollingTask::initializeInterface(CookieIF* cookie) { + spiIF->getSpiDev(); + // We are in protected section, so we can use the static variable here without issues. + // We don't need to set the speed because a SPI core is used, but the mode has to be set once + // correctly for all RWs + if (not modeAndSpeedWasSet) { + auto& dev = spiIF->getSpiDev(); + int fd = open(dev.c_str(), O_RDWR); + if (fd < 0) { + sif::error << "could not open RW SPI bus" << std::endl; + return returnvalue::FAILED; + } + spiIF->setSpiSpeedAndMode(fd, spi::RW_MODE, spi::RW_SPEED); + close(fd); + modeAndSpeedWasSet = true; + } + + return returnvalue::OK; +} + +ReturnValue_t RwPollingTask::sendMessage(CookieIF* cookie, const uint8_t* sendData, + size_t sendLen) { + if (sendLen < 6) { + return DeviceHandlerIF::INVALID_DATA; + } + int32_t speed = 0; + uint16_t rampTime = 0; + SerializeAdapter::deSerialize(&speed, &sendData, &sendLen, SerializeIF::Endianness::MACHINE); + SerializeAdapter::deSerialize(&rampTime, &sendData, &sendLen, SerializeIF::Endianness::MACHINE); + rws::SpecialRwRequest specialRequest = rws::SpecialRwRequest::REQUEST_NONE; + if (sendLen == 7 and sendData[6] < rws::SpecialRwRequest::NUM_REQUESTS) { + specialRequest = static_cast(sendData[6]); + } + RwCookie* rwCookie = dynamic_cast(cookie); + { + MutexGuard mg(ipcLock); + rwCookie->currentRwSpeed = speed; + rwCookie->currentRampTime = rampTime; + rwCookie->specialRequest = specialRequest; + if (state == InternalState::IDLE and rwCookie->rwIdx == 3) { + semaphore->release(); + } + } + return returnvalue::OK; +} + +ReturnValue_t RwPollingTask::getSendSuccess(CookieIF* cookie) { return returnvalue::OK; } + +ReturnValue_t RwPollingTask::requestReceiveMessage(CookieIF* cookie, size_t requestLen) { + return returnvalue::OK; +} + +ReturnValue_t RwPollingTask::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) { + RwCookie* rwCookie = dynamic_cast(cookie); + { + MutexGuard mg(ipcLock); + *buffer = rwCookie->replyBuf.data(); + *size = rwCookie->replyBuf.size(); + } + return returnvalue::OK; +} + +ReturnValue_t RwPollingTask::writeAndReadAllRws(const uint8_t* sendData, size_t sendDataLen) { + // Stopwatch watch; + ReturnValue_t result = returnvalue::OK; + + int fd = 0; + const std::string& dev = spiIF->getSpiDev(); + MutexIF* spiLock = spiIF->getCsMutex(); + result = openSpi(dev, O_RDWR, fd); + if (result != returnvalue::OK) { + return result; + } + for (unsigned idx = 0; idx < rwCookies.size(); idx++) { + ReturnValue_t result = sendOneMessage(fd, *rwCookies[idx], spiLock, sendData, sendDataLen); + if (result != returnvalue::OK) { + closeSpi(fd); + return returnvalue::FAILED; + } + } + + closeSpi(fd); + usleep(rws::SPI_REPLY_DELAY); + return readAllRws(fd, spiLock, dev.c_str()); +} + +ReturnValue_t RwPollingTask::openSpi(const std::string& devname, int flags, int& fd) { + fd = open(devname.c_str(), flags); + if (fd < 0) { + sif::error << "rwSpiCallback::spiCallback: Failed to open device file" << std::endl; + return SpiComIF::OPENING_FILE_FAILED; + } + + return returnvalue::OK; +} + +ReturnValue_t RwPollingTask::readNextReply(const char* spiDev, RwCookie& rwCookie, MutexIF* spiLock, + uint8_t* replyBuf) { + ReturnValue_t result = returnvalue::OK; + int fd = 0; + gpioId_t gpioId = rwCookie.getChipSelectPin(); + GpioIF& gpioIF = spiIF->getGpioInterface(); + pullCsLow(gpioId, spiLock, gpioIF); + for (unsigned idx = 0; idx < MAX_RETRIES_REPLY; idx++) { + result = openSpi(spiDev, O_RDWR, fd); + if (result != returnvalue::OK) { + return result; + } + /** + * The reaction wheel responds with empty frames while preparing the reply data. + * However, receiving more than 5 empty frames will be interpreted as an error. + */ + uint8_t byteRead = 0; + for (int idx = 0; idx < 5; idx++) { + if (read(fd, &byteRead, 1) != 1) { + sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; + pullCsHigh(gpioId, spiLock, gpioIF); + closeSpi(fd); + return rws::SPI_READ_FAILURE; + } + if (idx == 0) { + if (byteRead != FLAG_BYTE) { + sif::error << "Invalid data, expected start marker" << std::endl; + pullCsHigh(gpioId, spiLock, gpioIF); + closeSpi(fd); + return rws::NO_START_MARKER; + } + } + + if (byteRead != FLAG_BYTE) { + break; + } + + pullCsHigh(gpioId, spiLock, gpioIF); + closeSpi(fd); + if (idx == MAX_RETRIES_REPLY - 1) { + sif::error << "rwSpiCallback::spiCallback: Empty frame timeout" << std::endl; + return rws::NO_REPLY; + } + TaskFactory::delayTask(5); + } + +#if FSFW_HAL_SPI_WIRETAPPING == 1 + sif::info << "RW start marker detected" << std::endl; +#endif + + size_t decodedFrameLen = 0; + + while (decodedFrameLen < processingBuf.size()) { + /** First byte already read in */ + if (decodedFrameLen != 0) { + byteRead = 0; + if (read(fd, &byteRead, 1) != 1) { + sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; + result = rws::SPI_READ_FAILURE; + break; + } + } + + if (byteRead == FLAG_BYTE) { + /** Reached end of frame */ + break; + } else if (byteRead == 0x7D) { + if (read(fd, &byteRead, 1) != 1) { + sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; + result = rws::SPI_READ_FAILURE; + break; + } + if (byteRead == 0x5E) { + *(processingBuf.data() + decodedFrameLen) = 0x7E; + decodedFrameLen++; + continue; + } else if (byteRead == 0x5D) { + *(processingBuf.data() + decodedFrameLen) = 0x7D; + decodedFrameLen++; + continue; + } else { + sif::error << "rwSpiCallback::spiCallback: Invalid substitute" << std::endl; + closeSpi(fd); + result = rws::INVALID_SUBSTITUTE; + break; + } + } else { + *(processingBuf.data() + decodedFrameLen) = byteRead; + decodedFrameLen++; + continue; + } + + /** + * There might be the unlikely case that each byte in a get-telemetry reply has been + * replaced by its substitute. Than the next byte must correspond to the end sign 0x7E. + * Otherwise there might be something wrong. + */ + if (decodedFrameLen == processingBuf.size()) { + if (read(fd, &byteRead, 1) != 1) { + sif::error << "rwSpiCallback::spiCallback: Failed to read last byte" << std::endl; + result = rws::SPI_READ_FAILURE; + break; + } + if (byteRead != FLAG_BYTE) { + sif::error << "rwSpiCallback::spiCallback: Missing end sign " + << static_cast(FLAG_BYTE) << std::endl; + decodedFrameLen--; + result = rws::MISSING_END_SIGN; + break; + } + } + result = returnvalue::OK; + } + } + return returnvalue::OK; +} + +ReturnValue_t RwPollingTask::writeOneRw(uint8_t rwIdx) { + int fd = 0; + const std::string& dev = spiIF->getSpiDev(); + MutexIF* spiLock = spiIF->getCsMutex(); + ReturnValue_t result = openSpi(dev, O_RDWR, fd); + if (result != returnvalue::OK) { + return result; + } + ReturnValue_t result = + sendOneMessage(fd, *rwCookies[rwIdx], spiLock, writeBuffer.data(), writeLen); + if (result != returnvalue::OK) { + closeSpi(fd); + return returnvalue::FAILED; + } + return returnvalue::OK; +} + +ReturnValue_t RwPollingTask::readAllRws(int fd, MutexIF* spiLock, const char* dev) { + for (unsigned idx = 0; idx < rwCookies.size(); idx++) { + if (spiLock == nullptr) { + sif::debug << "rwSpiCallback::spiCallback: Mutex or GPIO interface invalid" << std::endl; + return returnvalue::FAILED; + } + uint8_t* replyBuf; + readNextReply(dev, *rwCookies[idx], spiLock, replyBuf); + } + + closeSpi(fd); + return returnvalue::OK; +} + +// This closes the SPI +void RwPollingTask::closeSpi(int fd) { + // This will perform the function to close the SPI + close(fd); + // The SPI is now closed. +} + +ReturnValue_t RwPollingTask::sendOneMessage(int fd, RwCookie& rwCookie, MutexIF* spiLock, + const uint8_t* data, size_t dataLen) { + gpioId_t gpioId = rwCookie.getChipSelectPin(); + GpioIF& gpioIF = spiIF->getGpioInterface(); + if (spiLock == nullptr) { + sif::debug << "rwSpiCallback::spiCallback: Mutex or GPIO interface invalid" << std::endl; + return returnvalue::FAILED; + } + pullCsLow(gpioId, spiLock, gpioIF); + /** Sending frame start sign */ + writeBuffer[0] = FLAG_BYTE; + size_t writeSize = 1; + if (write(fd, writeBuffer.data(), writeSize) != static_cast(writeSize)) { + sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; + pullCsHigh(gpioId, spiLock, gpioIF); + return rws::SPI_WRITE_FAILURE; + } + /** Encoding and sending command */ + size_t idx = 0; + while (idx < dataLen) { + switch (*(data + idx)) { + case 0x7E: + writeBuffer[0] = 0x7D; + writeBuffer[1] = 0x5E; + writeSize = 2; + break; + case 0x7D: + writeBuffer[0] = 0x7D; + writeBuffer[1] = 0x5D; + writeSize = 2; + break; + default: + writeBuffer[0] = *(data + idx); + writeSize = 1; + break; + } + } + if (write(fd, writeBuffer.data(), writeSize) != static_cast(writeSize)) { + sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; + pullCsHigh(gpioId, spiLock, gpioIF); + return rws::SPI_WRITE_FAILURE; + } + idx++; + /** Sending frame end sign */ + writeBuffer[0] = FLAG_BYTE; + writeSize = 1; + + if (write(fd, writeBuffer.data(), writeSize) != static_cast(writeSize)) { + sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; + pullCsHigh(gpioId, spiLock, gpioIF); + return rws::SPI_WRITE_FAILURE; + } + return returnvalue::OK; +} + +ReturnValue_t RwPollingTask::pullCsLow(gpioId_t gpioId, MutexIF* spiLock, GpioIF& gpioIF) { + ReturnValue_t result = spiLock->lockMutex(TIMEOUT_TYPE, TIMEOUT_MS); + if (result != returnvalue::OK) { + sif::debug << "rwSpiCallback::spiCallback: Failed to lock mutex" << std::endl; + return result; + } + // Pull SPI CS low. For now, no support for active high given + if (gpioId != gpio::NO_GPIO) { + ReturnValue_t result = gpioIF.pullLow(gpioId); + if (result != returnvalue::OK) { + sif::error << "rwSpiCallback::spiCallback: Failed to pull chip select low" << std::endl; + return result; + } + } + return returnvalue::OK; +} + +void RwPollingTask::pullCsHigh(gpioId_t gpioId, MutexIF* spiLock, GpioIF& gpioIF) { + if (gpioId != gpio::NO_GPIO) { + if (gpioIF.pullHigh(gpioId) != returnvalue::OK) { + sif::error << "closeSpi: Failed to pull chip select high" << std::endl; + } + } + if (spiLock->unlockMutex() != returnvalue::OK) { + sif::error << "rwSpiCallback::closeSpi: Failed to unlock mutex" << std::endl; + ; + } +} + +void RwPollingTask::prepareSimpleCommand(DeviceCommandId_t id) { + writeBuffer[0] = static_cast(id); + uint16_t crc = CRC::crc16ccitt(writeBuffer.data(), 1, 0xFFFF); + writeBuffer[1] = static_cast(crc & 0xFF); + writeBuffer[2] = static_cast(crc >> 8 & 0xFF); +} + +ReturnValue_t RwPollingTask::prepareSetSpeedCmd(uint8_t rwIdx) { + writeBuffer[0] = static_cast(rws::SET_SPEED); + uint8_t* serPtr = writeBuffer.data() + 1; + int32_t speedToSet = 0; + uint16_t rampTimeToSet = 10; + { + MutexGuard mg(ipcLock); + speedToSet = rwCookies[rwIdx]->currentRwSpeed; + rampTimeToSet = rwCookies[rwIdx]->currentRampTime; + } + size_t serLen = 0; + SerializeAdapter::serialize(&speedToSet, &serPtr, &serLen, writeBuffer.size(), + SerializeIF::Endianness::LITTLE); + SerializeAdapter::serialize(&rampTimeToSet, &serPtr, &serLen, writeBuffer.size(), + SerializeIF::Endianness::LITTLE); + + uint16_t crc = CRC::crc16ccitt(writeBuffer.data(), 7, 0xFFFF); + writeBuffer[7] = static_cast(crc & 0xFF); + writeBuffer[8] = static_cast((crc >> 8) & 0xFF); + return returnvalue::OK; +} diff --git a/linux/devices/RwPollingTask.h b/linux/devices/RwPollingTask.h new file mode 100644 index 00000000..d649a66a --- /dev/null +++ b/linux/devices/RwPollingTask.h @@ -0,0 +1,78 @@ +#ifndef LINUX_DEVICES_RWPOLLINGTASK_H_ +#define LINUX_DEVICES_RWPOLLINGTASK_H_ + +#include +#include +#include +#include +#include +#include + +#include "mission/devices/devicedefinitions/rwHelpers.h" + +class RwCookie : public SpiCookie { + friend class RwPollingTask; + + public: + RwCookie(uint8_t rwIdx, address_t spiAddress, gpioId_t chipSelect, const size_t maxSize, + spi::SpiModes spiMode, uint32_t spiSpeed) + : SpiCookie(spiAddress, chipSelect, maxSize, spiMode, spiSpeed), rwIdx(rwIdx) {} + + private: + std::array replyBuf{}; + int32_t currentRwSpeed = 0; + uint16_t currentRampTime = 0; + rws::SpecialRwRequest specialRequest = rws::SpecialRwRequest::NONE; + uint8_t rwIdx; +}; + +class RwPollingTask : public SystemObject, public ExecutableObjectIF, public DeviceCommunicationIF { + public: + RwPollingTask(object_id_t objectId, SpiComIF* spiIF); + + ReturnValue_t performOperation(uint8_t operationCode) override; + ReturnValue_t initialize() override; + + private: + enum class InternalState { IDLE, BUSY } state = InternalState::IDLE; + SemaphoreIF* semaphore; + bool debugMode = false; + bool modeAndSpeedWasSet = false; + MutexIF* ipcLock; + SpiComIF* spiIF; + std::array rwCookies; + std::array writeBuffer; + size_t writeLen = 0; + std::array processingBuf; + //! This is the end and start marker of the frame datalinklayer + static constexpr uint8_t FLAG_BYTE = 0x7E; + static constexpr MutexIF::TimeoutType TIMEOUT_TYPE = MutexIF::TimeoutType::WAITING; + static constexpr uint32_t TIMEOUT_MS = 20; + static constexpr uint8_t MAX_RETRIES_REPLY = 5; + + ReturnValue_t writeAndReadAllRws(const uint8_t* sendData, size_t sendDataLen); + ReturnValue_t writeOneRw(uint8_t rwIdx); + ReturnValue_t readAllRws(int fd, MutexIF* spiLock, const char* dev); + ReturnValue_t sendOneMessage(int fd, RwCookie& rwCookie, MutexIF* spiLock, const uint8_t* data, + size_t dataLen); + ReturnValue_t readNextReply(const char* spiDev, RwCookie& rwCookie, MutexIF* spiLock, + uint8_t* replyBuf); + ReturnValue_t initializeInterface(CookieIF* cookie) override; + + ReturnValue_t sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) override; + + ReturnValue_t getSendSuccess(CookieIF* cookie) override; + + ReturnValue_t requestReceiveMessage(CookieIF* cookie, size_t requestLen) override; + + ReturnValue_t readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) override; + ReturnValue_t openSpi(const std::string& devname, int flags, int& fd); + ReturnValue_t pullCsLow(gpioId_t gpioId, MutexIF* spiLock, GpioIF& gpioIF); + void prepareSimpleCommand(DeviceCommandId_t id); + ReturnValue_t prepareSetSpeedCmd(uint8_t rwIdx); + + void pullCsHigh(gpioId_t gpioId, MutexIF* spiLock, GpioIF& gpioIF); + void closeSpi(int); +}; + +#endif /* LINUX_DEVICES_RWPOLLINGTASK_H_ */ diff --git a/mission/controller/AcsController.h b/mission/controller/AcsController.h index c0e719f2..34fa9c33 100644 --- a/mission/controller/AcsController.h +++ b/mission/controller/AcsController.h @@ -5,6 +5,7 @@ #include #include #include +#include #include "acs/ActuatorCmd.h" #include "acs/Guidance.h" @@ -17,7 +18,6 @@ #include "eive/objects.h" #include "fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h" #include "fsfw_hal/devicehandlers/MgmRM3100Handler.h" -#include "mission/devices/devicedefinitions/RwDefinitions.h" #include "mission/devices/devicedefinitions/SusDefinitions.h" #include "mission/devices/devicedefinitions/imtqHandlerDefinitions.h" #include "mission/trace.h" @@ -84,10 +84,10 @@ class AcsController : public ExtendedControllerBase, public ReceivesParameterMes /* ACS Actuation Datasets */ IMTQ::DipoleActuationSet dipoleSet = IMTQ::DipoleActuationSet(objects::IMTQ_HANDLER); - RwDefinitions::RwSpeedActuationSet rw1SpeedSet = RwDefinitions::RwSpeedActuationSet(objects::RW1); - RwDefinitions::RwSpeedActuationSet rw2SpeedSet = RwDefinitions::RwSpeedActuationSet(objects::RW2); - RwDefinitions::RwSpeedActuationSet rw3SpeedSet = RwDefinitions::RwSpeedActuationSet(objects::RW3); - RwDefinitions::RwSpeedActuationSet rw4SpeedSet = RwDefinitions::RwSpeedActuationSet(objects::RW4); + rws::RwSpeedActuationSet rw1SpeedSet = rws::RwSpeedActuationSet(objects::RW1); + rws::RwSpeedActuationSet rw2SpeedSet = rws::RwSpeedActuationSet(objects::RW2); + rws::RwSpeedActuationSet rw3SpeedSet = rws::RwSpeedActuationSet(objects::RW3); + rws::RwSpeedActuationSet rw4SpeedSet = rws::RwSpeedActuationSet(objects::RW4); /* ACS Datasets */ // MGMs acsctrl::MgmDataRaw mgmDataRaw; diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 53b7f13d..f4e46c69 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -9,10 +9,10 @@ #include #include #include -#include #include #include #include +#include #include ThermalController::ThermalController(object_id_t objectId, HeaterHandler& heater) @@ -689,7 +689,7 @@ void ThermalController::copyDevices() { } { - lp_var_t tempRw1 = lp_var_t(objects::RW1, RwDefinitions::TEMPERATURE_C); + lp_var_t tempRw1 = lp_var_t(objects::RW1, rws::TEMPERATURE_C); PoolReadGuard pg(&tempRw1, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg.getReadResult() != returnvalue::OK) { sif::warning << "ThermalController: Failed to read reaction wheel 1 temperature" << std::endl; @@ -702,7 +702,7 @@ void ThermalController::copyDevices() { } { - lp_var_t tempRw2 = lp_var_t(objects::RW2, RwDefinitions::TEMPERATURE_C); + lp_var_t tempRw2 = lp_var_t(objects::RW2, rws::TEMPERATURE_C); PoolReadGuard pg(&tempRw2, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg.getReadResult() != returnvalue::OK) { sif::warning << "ThermalController: Failed to read reaction wheel 2 temperature" << std::endl; @@ -715,7 +715,7 @@ void ThermalController::copyDevices() { } { - lp_var_t tempRw3 = lp_var_t(objects::RW3, RwDefinitions::TEMPERATURE_C); + lp_var_t tempRw3 = lp_var_t(objects::RW3, rws::TEMPERATURE_C); PoolReadGuard pg(&tempRw3, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg.getReadResult() != returnvalue::OK) { sif::warning << "ThermalController: Failed to read reaction wheel 3 temperature" << std::endl; @@ -728,7 +728,7 @@ void ThermalController::copyDevices() { } { - lp_var_t tempRw4 = lp_var_t(objects::RW4, RwDefinitions::TEMPERATURE_C); + lp_var_t tempRw4 = lp_var_t(objects::RW4, rws::TEMPERATURE_C); PoolReadGuard pg(&tempRw4, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg.getReadResult() != returnvalue::OK) { sif::warning << "ThermalController: Failed to read reaction wheel 4 temperature" << std::endl; diff --git a/mission/controller/acs/SensorValues.h b/mission/controller/acs/SensorValues.h index ec1795fc..92d4c5ff 100644 --- a/mission/controller/acs/SensorValues.h +++ b/mission/controller/acs/SensorValues.h @@ -1,13 +1,14 @@ #ifndef SENSORVALUES_H_ #define SENSORVALUES_H_ +#include + #include "fsfw_hal/devicehandlers/GyroL3GD20Handler.h" #include "fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h" #include "fsfw_hal/devicehandlers/MgmRM3100Handler.h" #include "linux/devices/devicedefinitions/StarTrackerDefinitions.h" #include "mission/devices/devicedefinitions/GPSDefinitions.h" #include "mission/devices/devicedefinitions/GyroADIS1650XDefinitions.h" -#include "mission/devices/devicedefinitions/RwDefinitions.h" #include "mission/devices/devicedefinitions/SusDefinitions.h" #include "mission/devices/devicedefinitions/imtqHandlerDefinitions.h" @@ -62,10 +63,10 @@ class SensorValues { // bool mgt0valid; - RwDefinitions::StatusSet rw1Set = RwDefinitions::StatusSet(objects::RW1); - RwDefinitions::StatusSet rw2Set = RwDefinitions::StatusSet(objects::RW2); - RwDefinitions::StatusSet rw3Set = RwDefinitions::StatusSet(objects::RW3); - RwDefinitions::StatusSet rw4Set = RwDefinitions::StatusSet(objects::RW4); + rws::StatusSet rw1Set = rws::StatusSet(objects::RW1); + rws::StatusSet rw2Set = rws::StatusSet(objects::RW2); + rws::StatusSet rw3Set = rws::StatusSet(objects::RW3); + rws::StatusSet rw4Set = rws::StatusSet(objects::RW4); }; } /* namespace ACS */ diff --git a/mission/devices/RwHandler.cpp b/mission/devices/RwHandler.cpp index 9d4a7255..c5bd1e6e 100644 --- a/mission/devices/RwHandler.cpp +++ b/mission/devices/RwHandler.cpp @@ -45,23 +45,23 @@ void RwHandler::doShutDown() { ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { switch (internalState) { case InternalState::SET_SPEED: - *id = RwDefinitions::SET_SPEED; + *id = rws::SET_SPEED; internalState = InternalState::GET_RESET_STATUS; break; case InternalState::GET_RESET_STATUS: - *id = RwDefinitions::GET_LAST_RESET_STATUS; + *id = rws::GET_LAST_RESET_STATUS; internalState = InternalState::READ_TEMPERATURE; break; case InternalState::READ_TEMPERATURE: - *id = RwDefinitions::GET_TEMPERATURE; + *id = rws::GET_TEMPERATURE; internalState = InternalState::GET_RW_SATUS; break; case InternalState::GET_RW_SATUS: - *id = RwDefinitions::GET_RW_STATUS; + *id = rws::GET_RW_STATUS; internalState = InternalState::CLEAR_RESET_STATUS; break; case InternalState::CLEAR_RESET_STATUS: - *id = RwDefinitions::CLEAR_LAST_RESET_STATUS; + *id = rws::CLEAR_LAST_RESET_STATUS; /** After reset status is cleared, reset status will be polled again for verification */ internalState = InternalState::GET_RESET_STATUS; break; @@ -82,27 +82,27 @@ ReturnValue_t RwHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand ReturnValue_t result = returnvalue::OK; switch (deviceCommand) { - case (RwDefinitions::RESET_MCU): { + case (rws::RESET_MCU): { prepareSimpleCommand(deviceCommand); return returnvalue::OK; } - case (RwDefinitions::GET_LAST_RESET_STATUS): { + case (rws::GET_LAST_RESET_STATUS): { prepareSimpleCommand(deviceCommand); return returnvalue::OK; } - case (RwDefinitions::CLEAR_LAST_RESET_STATUS): { + case (rws::CLEAR_LAST_RESET_STATUS): { prepareSimpleCommand(deviceCommand); return returnvalue::OK; } - case (RwDefinitions::GET_RW_STATUS): { + case (rws::GET_RW_STATUS): { prepareSimpleCommand(deviceCommand); return returnvalue::OK; } - case (RwDefinitions::INIT_RW_CONTROLLER): { + case (rws::INIT_RW_CONTROLLER): { prepareSimpleCommand(deviceCommand); return returnvalue::OK; } - case (RwDefinitions::SET_SPEED): { + case (rws::SET_SPEED): { if (commandData != nullptr && commandDataLen != 6) { sif::error << "RwHandler::buildCommandFromCommand: Received set speed command with" << " invalid length" << std::endl; @@ -136,11 +136,11 @@ ReturnValue_t RwHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand result = prepareSetSpeedCmd(); return result; } - case (RwDefinitions::GET_TEMPERATURE): { + case (rws::GET_TEMPERATURE): { prepareSimpleCommand(deviceCommand); return returnvalue::OK; } - case (RwDefinitions::GET_TM): { + case (rws::GET_TM): { prepareSimpleCommand(deviceCommand); return returnvalue::OK; } @@ -151,60 +151,56 @@ ReturnValue_t RwHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand } void RwHandler::fillCommandAndReplyMap() { - this->insertInCommandMap(RwDefinitions::RESET_MCU); - this->insertInCommandAndReplyMap(RwDefinitions::GET_LAST_RESET_STATUS, 1, &lastResetStatusSet, - RwDefinitions::SIZE_GET_RESET_STATUS); - this->insertInCommandAndReplyMap(RwDefinitions::CLEAR_LAST_RESET_STATUS, 1, nullptr, - RwDefinitions::SIZE_CLEAR_RESET_STATUS); - this->insertInCommandAndReplyMap(RwDefinitions::GET_RW_STATUS, 1, &statusSet, - RwDefinitions::SIZE_GET_RW_STATUS); - this->insertInCommandAndReplyMap(RwDefinitions::INIT_RW_CONTROLLER, 1, nullptr, - RwDefinitions::SIZE_INIT_RW); - this->insertInCommandAndReplyMap(RwDefinitions::GET_TEMPERATURE, 1, nullptr, - RwDefinitions::SIZE_GET_TEMPERATURE_REPLY); - this->insertInCommandAndReplyMap(RwDefinitions::SET_SPEED, 1, nullptr, - RwDefinitions::SIZE_SET_SPEED_REPLY); - this->insertInCommandAndReplyMap(RwDefinitions::GET_TM, 1, &tmDataset, - RwDefinitions::SIZE_GET_TELEMETRY_REPLY); + this->insertInCommandMap(rws::RESET_MCU); + this->insertInCommandAndReplyMap(rws::GET_LAST_RESET_STATUS, 1, &lastResetStatusSet, + rws::SIZE_GET_RESET_STATUS); + this->insertInCommandAndReplyMap(rws::CLEAR_LAST_RESET_STATUS, 1, nullptr, + rws::SIZE_CLEAR_RESET_STATUS); + this->insertInCommandAndReplyMap(rws::GET_RW_STATUS, 1, &statusSet, rws::SIZE_GET_RW_STATUS); + this->insertInCommandAndReplyMap(rws::INIT_RW_CONTROLLER, 1, nullptr, rws::SIZE_INIT_RW); + this->insertInCommandAndReplyMap(rws::GET_TEMPERATURE, 1, nullptr, + rws::SIZE_GET_TEMPERATURE_REPLY); + this->insertInCommandAndReplyMap(rws::SET_SPEED, 1, nullptr, rws::SIZE_SET_SPEED_REPLY); + this->insertInCommandAndReplyMap(rws::GET_TM, 1, &tmDataset, rws::SIZE_GET_TELEMETRY_REPLY); } ReturnValue_t RwHandler::scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId, size_t* foundLen) { uint8_t replyByte = *start; switch (replyByte) { - case (RwDefinitions::GET_LAST_RESET_STATUS): { - *foundLen = RwDefinitions::SIZE_GET_RESET_STATUS; - *foundId = RwDefinitions::GET_LAST_RESET_STATUS; + case (rws::GET_LAST_RESET_STATUS): { + *foundLen = rws::SIZE_GET_RESET_STATUS; + *foundId = rws::GET_LAST_RESET_STATUS; break; } - case (RwDefinitions::CLEAR_LAST_RESET_STATUS): { - *foundLen = RwDefinitions::SIZE_CLEAR_RESET_STATUS; - *foundId = RwDefinitions::CLEAR_LAST_RESET_STATUS; + case (rws::CLEAR_LAST_RESET_STATUS): { + *foundLen = rws::SIZE_CLEAR_RESET_STATUS; + *foundId = rws::CLEAR_LAST_RESET_STATUS; break; } - case (RwDefinitions::GET_RW_STATUS): { - *foundLen = RwDefinitions::SIZE_GET_RW_STATUS; - *foundId = RwDefinitions::GET_RW_STATUS; + case (rws::GET_RW_STATUS): { + *foundLen = rws::SIZE_GET_RW_STATUS; + *foundId = rws::GET_RW_STATUS; break; } - case (RwDefinitions::INIT_RW_CONTROLLER): { - *foundLen = RwDefinitions::SIZE_INIT_RW; - *foundId = RwDefinitions::INIT_RW_CONTROLLER; + case (rws::INIT_RW_CONTROLLER): { + *foundLen = rws::SIZE_INIT_RW; + *foundId = rws::INIT_RW_CONTROLLER; break; } - case (RwDefinitions::SET_SPEED): { - *foundLen = RwDefinitions::SIZE_SET_SPEED_REPLY; - *foundId = RwDefinitions::SET_SPEED; + case (rws::SET_SPEED): { + *foundLen = rws::SIZE_SET_SPEED_REPLY; + *foundId = rws::SET_SPEED; break; } - case (RwDefinitions::GET_TEMPERATURE): { - *foundLen = RwDefinitions::SIZE_GET_TEMPERATURE_REPLY; - *foundId = RwDefinitions::GET_TEMPERATURE; + case (rws::GET_TEMPERATURE): { + *foundLen = rws::SIZE_GET_TEMPERATURE_REPLY; + *foundId = rws::GET_TEMPERATURE; break; } - case (RwDefinitions::GET_TM): { - *foundLen = RwDefinitions::SIZE_GET_TELEMETRY_REPLY; - *foundId = RwDefinitions::GET_TM; + case (rws::GET_TM): { + *foundLen = rws::SIZE_GET_TELEMETRY_REPLY; + *foundId = rws::GET_TM; break; } default: { @@ -221,7 +217,7 @@ ReturnValue_t RwHandler::scanForReply(const uint8_t* start, size_t remainingSize ReturnValue_t RwHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { /** Check result code */ - if (*(packet + 1) == RwDefinitions::STATE_ERROR) { + if (*(packet + 1) == rws::STATE_ERROR) { sif::error << "RwHandler::interpretDeviceReply: Command execution failed. Command id: " << id << std::endl; return EXECUTION_FAILED; @@ -236,24 +232,24 @@ ReturnValue_t RwHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_ } switch (id) { - case (RwDefinitions::GET_LAST_RESET_STATUS): { + case (rws::GET_LAST_RESET_STATUS): { handleResetStatusReply(packet); break; } - case (RwDefinitions::GET_RW_STATUS): { + case (rws::GET_RW_STATUS): { handleGetRwStatusReply(packet); break; } - case (RwDefinitions::CLEAR_LAST_RESET_STATUS): - case (RwDefinitions::INIT_RW_CONTROLLER): - case (RwDefinitions::SET_SPEED): + case (rws::CLEAR_LAST_RESET_STATUS): + case (rws::INIT_RW_CONTROLLER): + case (rws::SET_SPEED): // no reply data expected break; - case (RwDefinitions::GET_TEMPERATURE): { + case (rws::GET_TEMPERATURE): { handleTemperatureReply(packet); break; } - case (RwDefinitions::GET_TM): { + case (rws::GET_TM): { handleGetTelemetryReply(packet); break; } @@ -270,43 +266,43 @@ uint32_t RwHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { retur ReturnValue_t RwHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) { - localDataPoolMap.emplace(RwDefinitions::RW_SPEED, &rwSpeed); - localDataPoolMap.emplace(RwDefinitions::RAMP_TIME, &rampTime); + localDataPoolMap.emplace(rws::RW_SPEED, &rwSpeed); + localDataPoolMap.emplace(rws::RAMP_TIME, &rampTime); - localDataPoolMap.emplace(RwDefinitions::TEMPERATURE_C, new PoolEntry({0})); + localDataPoolMap.emplace(rws::TEMPERATURE_C, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::CURR_SPEED, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::REFERENCE_SPEED, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::STATE, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::CLC_MODE, new PoolEntry({0})); + localDataPoolMap.emplace(rws::CURR_SPEED, new PoolEntry({0})); + localDataPoolMap.emplace(rws::REFERENCE_SPEED, new PoolEntry({0})); + localDataPoolMap.emplace(rws::STATE, new PoolEntry({0})); + localDataPoolMap.emplace(rws::CLC_MODE, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::LAST_RESET_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::CURRRENT_RESET_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(rws::LAST_RESET_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(rws::CURRRENT_RESET_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::TM_LAST_RESET_STATUS, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::TM_MCU_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::PRESSURE_SENSOR_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::PRESSURE, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::TM_RW_STATE, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::TM_CLC_MODE, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::TM_RW_CURR_SPEED, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::TM_RW_REF_SPEED, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::INVALID_CRC_PACKETS, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::INVALID_LEN_PACKETS, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::INVALID_CMD_PACKETS, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::EXECUTED_REPLIES, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::COMMAND_REPLIES, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::UART_BYTES_WRITTEN, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::UART_BYTES_READ, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::UART_PARITY_ERRORS, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::UART_NOISE_ERRORS, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::UART_FRAME_ERRORS, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::UART_REG_OVERRUN_ERRORS, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::UART_TOTAL_ERRORS, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::SPI_BYTES_WRITTEN, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::SPI_BYTES_READ, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::SPI_REG_OVERRUN_ERRORS, new PoolEntry({0})); - localDataPoolMap.emplace(RwDefinitions::SPI_TOTAL_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(rws::TM_LAST_RESET_STATUS, new PoolEntry({0})); + localDataPoolMap.emplace(rws::TM_MCU_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(rws::PRESSURE_SENSOR_TEMPERATURE, new PoolEntry({0})); + localDataPoolMap.emplace(rws::PRESSURE, new PoolEntry({0})); + localDataPoolMap.emplace(rws::TM_RW_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(rws::TM_CLC_MODE, new PoolEntry({0})); + localDataPoolMap.emplace(rws::TM_RW_CURR_SPEED, new PoolEntry({0})); + localDataPoolMap.emplace(rws::TM_RW_REF_SPEED, new PoolEntry({0})); + localDataPoolMap.emplace(rws::INVALID_CRC_PACKETS, new PoolEntry({0})); + localDataPoolMap.emplace(rws::INVALID_LEN_PACKETS, new PoolEntry({0})); + localDataPoolMap.emplace(rws::INVALID_CMD_PACKETS, new PoolEntry({0})); + localDataPoolMap.emplace(rws::EXECUTED_REPLIES, new PoolEntry({0})); + localDataPoolMap.emplace(rws::COMMAND_REPLIES, new PoolEntry({0})); + localDataPoolMap.emplace(rws::UART_BYTES_WRITTEN, new PoolEntry({0})); + localDataPoolMap.emplace(rws::UART_BYTES_READ, new PoolEntry({0})); + localDataPoolMap.emplace(rws::UART_PARITY_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(rws::UART_NOISE_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(rws::UART_FRAME_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(rws::UART_REG_OVERRUN_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(rws::UART_TOTAL_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(rws::SPI_BYTES_WRITTEN, new PoolEntry({0})); + localDataPoolMap.emplace(rws::SPI_BYTES_READ, new PoolEntry({0})); + localDataPoolMap.emplace(rws::SPI_REG_OVERRUN_ERRORS, new PoolEntry({0})); + localDataPoolMap.emplace(rws::SPI_TOTAL_ERRORS, new PoolEntry({0})); poolManager.subscribeForDiagPeriodicPacket( subdp::DiagnosticsHkPeriodicParams(statusSet.getSid(), false, 5.0)); poolManager.subscribeForRegularPeriodicPacket( @@ -343,7 +339,7 @@ ReturnValue_t RwHandler::checkSpeedAndRampTime() { } ReturnValue_t RwHandler::prepareSetSpeedCmd() { - commandBuffer[0] = static_cast(RwDefinitions::SET_SPEED); + commandBuffer[0] = static_cast(rws::SET_SPEED); uint8_t* serPtr = commandBuffer + 1; size_t serSize = 1; rwSpeedActuationSet.setValidityBufferGeneration(false); @@ -369,7 +365,7 @@ void RwHandler::handleResetStatusReply(const uint8_t* packet) { if (resetStatus != 0) { internalState = InternalState::CLEAR_RESET_STATUS; lastResetStatusSet.lastNonClearedResetStatus = resetStatus; - triggerEvent(RwDefinitions::RESET_OCCURED, resetStatus, 0); + triggerEvent(rws::RESET_OCCURED, resetStatus, 0); } lastResetStatusSet.currentResetStatus = resetStatus; if (debugMode) { @@ -408,10 +404,10 @@ void RwHandler::handleGetRwStatusReply(const uint8_t* packet) { statusSet.setValidity(true, true); - if (statusSet.state == RwDefinitions::STATE_ERROR) { + if (statusSet.state == rws::STATE_ERROR) { // This requires the commanding of the init reaction wheel controller command to recover // from error state which must be handled by the FDIR instance. - triggerEvent(RwDefinitions::ERROR_STATE, statusSet.state.value, 0); + triggerEvent(rws::ERROR_STATE, statusSet.state.value, 0); sif::error << "RwHandler::handleGetRwStatusReply: Reaction wheel in error state" << std::endl; } diff --git a/mission/devices/RwHandler.h b/mission/devices/RwHandler.h index ee18960d..7db3ef3b 100644 --- a/mission/devices/RwHandler.h +++ b/mission/devices/RwHandler.h @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include "events/subsystemIdRanges.h" @@ -42,24 +42,6 @@ class RwHandler : public DeviceHandlerBase { virtual ~RwHandler(); - static const uint8_t INTERFACE_ID = CLASS_ID::RW_HANDLER; - - static const ReturnValue_t SPI_WRITE_FAILURE = MAKE_RETURN_CODE(0xB0); - //! [EXPORT] : [COMMENT] Used by the spi send function to tell a failing read call - static const ReturnValue_t SPI_READ_FAILURE = MAKE_RETURN_CODE(0xB1); - //! [EXPORT] : [COMMENT] Can be used by the HDLC decoding mechanism to inform about a missing - //! start sign 0x7E - static const ReturnValue_t MISSING_START_SIGN = MAKE_RETURN_CODE(0xB2); - //! [EXPORT] : [COMMENT] Can be used by the HDLC decoding mechanism to inform about an invalid - //! substitution combination - static const ReturnValue_t INVALID_SUBSTITUTE = MAKE_RETURN_CODE(0xB3); - //! [EXPORT] : [COMMENT] HDLC decoding mechanism never receives the end sign 0x7E - static const ReturnValue_t MISSING_END_SIGN = MAKE_RETURN_CODE(0xB4); - //! [EXPORT] : [COMMENT] Reaction wheel only responds with empty frames. - static const ReturnValue_t NO_REPLY = MAKE_RETURN_CODE(0xB5); - //! [EXPORT] : [COMMENT] Expected a start marker as first byte - static const ReturnValue_t NO_START_MARKER = MAKE_RETURN_CODE(0xB6); - protected: void doStartUp() override; void doShutDown() override; @@ -92,12 +74,12 @@ class RwHandler : public DeviceHandlerBase { gpioId_t enableGpio = gpio::NO_GPIO; bool debugMode = false; - RwDefinitions::StatusSet statusSet; - RwDefinitions::LastResetSatus lastResetStatusSet; - RwDefinitions::TmDataset tmDataset; - RwDefinitions::RwSpeedActuationSet rwSpeedActuationSet; + rws::StatusSet statusSet; + rws::LastResetSatus lastResetStatusSet; + rws::TmDataset tmDataset; + rws::RwSpeedActuationSet rwSpeedActuationSet; - uint8_t commandBuffer[RwDefinitions::MAX_CMD_SIZE]; + uint8_t commandBuffer[rws::MAX_CMD_SIZE]; uint8_t rwIdx; PoolEntry rwSpeed = PoolEntry({0}); diff --git a/mission/devices/devicedefinitions/rwHelpers.cpp b/mission/devices/devicedefinitions/rwHelpers.cpp new file mode 100644 index 00000000..4c246eb8 --- /dev/null +++ b/mission/devices/devicedefinitions/rwHelpers.cpp @@ -0,0 +1,6 @@ +#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_RWHELPERS_CPP_ +#define MISSION_DEVICES_DEVICEDEFINITIONS_RWHELPERS_CPP_ + +#include "rwHelpers.h" + +#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_RWHELPERS_CPP_ */ diff --git a/mission/devices/devicedefinitions/RwDefinitions.h b/mission/devices/devicedefinitions/rwHelpers.h similarity index 67% rename from mission/devices/devicedefinitions/RwDefinitions.h rename to mission/devices/devicedefinitions/rwHelpers.h index b3cb0fe4..743813fa 100644 --- a/mission/devices/devicedefinitions/RwDefinitions.h +++ b/mission/devices/devicedefinitions/rwHelpers.h @@ -1,5 +1,5 @@ -#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_RWDEFINITIONS_H_ -#define MISSION_DEVICES_DEVICEDEFINITIONS_RWDEFINITIONS_H_ +#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_RWHELPERS_H_ +#define MISSION_DEVICES_DEVICEDEFINITIONS_RWHELPERS_H_ #include #include @@ -8,7 +8,83 @@ #include "events/subsystemIdRanges.h" #include "objects/systemObjectList.h" -namespace RwDefinitions { +namespace rws { + +static const size_t SIZE_GET_RESET_STATUS = 5; +static const size_t SIZE_CLEAR_RESET_STATUS = 4; +static const size_t SIZE_INIT_RW = 4; +static const size_t SIZE_GET_RW_STATUS = 14; +static const size_t SIZE_SET_SPEED_REPLY = 4; +static const size_t SIZE_GET_TEMPERATURE_REPLY = 8; +/** Max size when requesting telemetry */ +static const size_t SIZE_GET_TELEMETRY_REPLY = 91; + +enum SpecialRwRequest : uint8_t { + REQUEST_NONE = 0, + RESET_MCU = 1, + INIT_RW_CONTROLLER = 2, + GET_TM = 3, + NUM_REQUESTS +}; + +struct RwReplies { + friend class RwPollingTask; + + public: + RwReplies(const uint8_t* rawData) : rawData(rawData) { + rwStatusReply = rawData; + setSpeedReply = rawData + SIZE_GET_RW_STATUS; + getLastResetStatusReply = setSpeedReply + SIZE_SET_SPEED_REPLY; + clearLastResetStatusReply = getLastResetStatusReply + SIZE_GET_RESET_STATUS; + readTemperatureReply = clearLastResetStatusReply + SIZE_CLEAR_RESET_STATUS; + hkDataReply = readTemperatureReply + SIZE_GET_TEMPERATURE_REPLY; + initRwControllerReply = hkDataReply + SIZE_GET_TELEMETRY_REPLY; + } + + const uint8_t* getClearLastResetStatusReply() const { return clearLastResetStatusReply; } + + const uint8_t* getGetLastResetStatusReply() const { return getLastResetStatusReply; } + + const uint8_t* getHkDataReply() const { return hkDataReply; } + + const uint8_t* getInitRwControllerReply() const { return initRwControllerReply; } + + const uint8_t* getRawData() const { return rawData; } + + const uint8_t* getReadTemperatureReply() const { return readTemperatureReply; } + + const uint8_t* getRwStatusReply() const { return rwStatusReply; } + + const uint8_t* getSetSpeedReply() const { return setSpeedReply; } + + private: + const uint8_t* rawData; + const uint8_t* rwStatusReply; + const uint8_t* setSpeedReply; + const uint8_t* getLastResetStatusReply; + const uint8_t* clearLastResetStatusReply; + const uint8_t* readTemperatureReply; + const uint8_t* hkDataReply; + const uint8_t* initRwControllerReply; +}; + +static const uint8_t INTERFACE_ID = CLASS_ID::RW_HANDLER; + +static const ReturnValue_t SPI_WRITE_FAILURE = MAKE_RETURN_CODE(0xB0); +//! [EXPORT] : [COMMENT] Used by the spi send function to tell a failing read call +static const ReturnValue_t SPI_READ_FAILURE = MAKE_RETURN_CODE(0xB1); +//! [EXPORT] : [COMMENT] Can be used by the HDLC decoding mechanism to inform about a missing +//! start sign 0x7E +static const ReturnValue_t MISSING_START_SIGN = MAKE_RETURN_CODE(0xB2); +//! [EXPORT] : [COMMENT] Can be used by the HDLC decoding mechanism to inform about an invalid +//! substitution combination +static const ReturnValue_t INVALID_SUBSTITUTE = MAKE_RETURN_CODE(0xB3); +//! [EXPORT] : [COMMENT] HDLC decoding mechanism never receives the end sign 0x7E +static const ReturnValue_t MISSING_END_SIGN = MAKE_RETURN_CODE(0xB4); +//! [EXPORT] : [COMMENT] Reaction wheel only responds with empty frames. +static const ReturnValue_t NO_REPLY = MAKE_RETURN_CODE(0xB5); +//! [EXPORT] : [COMMENT] Expected a start marker as first byte +static const ReturnValue_t NO_START_MARKER = MAKE_RETURN_CODE(0xB6); static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::RW_HANDLER; @@ -17,7 +93,8 @@ static constexpr Event ERROR_STATE = MAKE_EVENT(1, severity::HIGH); static constexpr Event RESET_OCCURED = event::makeEvent(SUBSYSTEM_ID, 2, severity::LOW); -static const uint32_t SPI_REPLY_DELAY = 70000; // us +//! Minimal delay as specified by the datasheet. +static const uint32_t SPI_REPLY_DELAY = 20000; // us enum PoolIds : lp_id_t { TEMPERATURE_C, @@ -86,15 +163,6 @@ enum SetIds : uint32_t { SPEED_CMD_SET = 10, }; -static const size_t SIZE_GET_RESET_STATUS = 5; -static const size_t SIZE_CLEAR_RESET_STATUS = 4; -static const size_t SIZE_INIT_RW = 4; -static const size_t SIZE_GET_RW_STATUS = 14; -static const size_t SIZE_SET_SPEED_REPLY = 4; -static const size_t SIZE_GET_TEMPERATURE_REPLY = 8; -/** Max size when requesting telemetry */ -static const size_t SIZE_GET_TELEMETRY_REPLY = 91; - /** Set speed command has maximum size */ static const size_t MAX_CMD_SIZE = 9; /** @@ -112,11 +180,10 @@ static const uint8_t TM_SET_ENTRIES = 24; */ class StatusSet : public StaticLocalDataSet { public: - StatusSet(HasLocalDataPoolIF* owner) - : StaticLocalDataSet(owner, RwDefinitions::SetIds::STATUS_SET_ID) {} + StatusSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, rws::SetIds::STATUS_SET_ID) {} StatusSet(object_id_t objectId) - : StaticLocalDataSet(sid_t(objectId, RwDefinitions::SetIds::STATUS_SET_ID)) {} + : StaticLocalDataSet(sid_t(objectId, rws::SetIds::STATUS_SET_ID)) {} lp_var_t temperatureCelcius = lp_var_t(sid.objectId, PoolIds::TEMPERATURE_C, this); @@ -133,10 +200,10 @@ class StatusSet : public StaticLocalDataSet { class LastResetSatus : public StaticLocalDataSet { public: LastResetSatus(HasLocalDataPoolIF* owner) - : StaticLocalDataSet(owner, RwDefinitions::SetIds::LAST_RESET_ID) {} + : StaticLocalDataSet(owner, rws::SetIds::LAST_RESET_ID) {} LastResetSatus(object_id_t objectId) - : StaticLocalDataSet(sid_t(objectId, RwDefinitions::SetIds::LAST_RESET_ID)) {} + : StaticLocalDataSet(sid_t(objectId, rws::SetIds::LAST_RESET_ID)) {} // If a reset occurs, the status code will be cached into this variable lp_var_t lastNonClearedResetStatus = @@ -153,11 +220,9 @@ class LastResetSatus : public StaticLocalDataSet { */ class TmDataset : public StaticLocalDataSet { public: - TmDataset(HasLocalDataPoolIF* owner) - : StaticLocalDataSet(owner, RwDefinitions::SetIds::TM_SET_ID) {} + TmDataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, rws::SetIds::TM_SET_ID) {} - TmDataset(object_id_t objectId) - : StaticLocalDataSet(sid_t(objectId, RwDefinitions::SetIds::TM_SET_ID)) {} + TmDataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, rws::SetIds::TM_SET_ID)) {} lp_var_t lastResetStatus = lp_var_t(sid.objectId, PoolIds::TM_LAST_RESET_STATUS, this); @@ -209,9 +274,9 @@ class RwSpeedActuationSet : public StaticLocalDataSet<2> { public: RwSpeedActuationSet(HasLocalDataPoolIF& owner) - : StaticLocalDataSet(&owner, RwDefinitions::SetIds::SPEED_CMD_SET) {} + : StaticLocalDataSet(&owner, rws::SetIds::SPEED_CMD_SET) {} RwSpeedActuationSet(object_id_t objectId) - : StaticLocalDataSet(sid_t(objectId, RwDefinitions::SetIds::SPEED_CMD_SET)) {} + : StaticLocalDataSet(sid_t(objectId, rws::SetIds::SPEED_CMD_SET)) {} void setRwSpeed(int32_t rwSpeed_, uint16_t rampTime_) { if (rwSpeed.value != rwSpeed_) { @@ -228,12 +293,10 @@ class RwSpeedActuationSet : public StaticLocalDataSet<2> { } private: - lp_var_t rwSpeed = - lp_var_t(sid.objectId, RwDefinitions::PoolIds::RW_SPEED, this); - lp_var_t rampTime = - lp_var_t(sid.objectId, RwDefinitions::PoolIds::RAMP_TIME, this); + lp_var_t rwSpeed = lp_var_t(sid.objectId, rws::PoolIds::RW_SPEED, this); + lp_var_t rampTime = lp_var_t(sid.objectId, rws::PoolIds::RAMP_TIME, this); }; -} // namespace RwDefinitions +} // namespace rws -#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_RWDEFINITIONS_H_ */ +#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_RWHELPERS_H_ */ From 8c001b64433d18c47b2b53b7de200224eb8a4d7e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Feb 2023 19:16:42 +0100 Subject: [PATCH 132/373] heading towards completion for low level rw polling task --- linux/devices/RwPollingTask.cpp | 205 ++++++++++++------ linux/devices/RwPollingTask.h | 28 ++- mission/devices/devicedefinitions/rwHelpers.h | 89 ++++---- 3 files changed, 205 insertions(+), 117 deletions(-) diff --git a/linux/devices/RwPollingTask.cpp b/linux/devices/RwPollingTask.cpp index ca663c07..657f8853 100644 --- a/linux/devices/RwPollingTask.cpp +++ b/linux/devices/RwPollingTask.cpp @@ -15,35 +15,66 @@ RwPollingTask::RwPollingTask(object_id_t objectId, SpiComIF* spiIF) semaphore = SemaphoreFactory::instance()->createBinarySemaphore(); semaphore->acquire(); ipcLock = MutexFactory::instance()->createMutex(); + spiLock = spiIF->getCsMutex(); + spiDev = spiIF->getSpiDev().c_str(); } ReturnValue_t RwPollingTask::performOperation(uint8_t operationCode) { - ipcLock->lockMutex(); - state = InternalState::IDLE; - ipcLock->unlockMutex(); while (true) { + ipcLock->lockMutex(); + state = InternalState::IDLE; + ipcLock->unlockMutex(); semaphore->acquire(); + int fd = 0; + ReturnValue_t result = openSpi(O_RDWR, fd); + if (result != returnvalue::OK) { + continue; + } for (unsigned idx = 0; idx < rwCookies.size(); idx++) { prepareSetSpeedCmd(idx); - writeOneRw(idx); + if (writeOneRwCmd(idx, fd) != returnvalue::OK) { + continue; + } } - readAllRws(fd, spiLock, dev) - // writeAndReadAllRws(sendData, sendDataLen) - int bytesRead = 0; + closeSpi(fd); + usleep(rws::SPI_REPLY_DELAY); + if (readAllRws(fd, rws::SET_SPEED) != returnvalue::OK) { + continue; + } + prepareSimpleCommand(rws::GET_LAST_RESET_STATUS); + if (writeAndReadAllRws(rws::GET_LAST_RESET_STATUS) != returnvalue::OK) { + continue; + } + prepareSimpleCommand(rws::GET_RW_STATUS); + if (writeAndReadAllRws(rws::GET_RW_STATUS) != returnvalue::OK) { + continue; + } + prepareSimpleCommand(rws::GET_TEMPERATURE); + if (writeAndReadAllRws(rws::GET_TEMPERATURE) != returnvalue::OK) { + continue; + } + prepareSimpleCommand(rws::CLEAR_LAST_RESET_STATUS); + if (writeAndReadAllRws(rws::CLEAR_LAST_RESET_STATUS) != returnvalue::OK) { + continue; + } + } + + return returnvalue::OK; +} + +ReturnValue_t RwPollingTask::initialize() { + if (spiDev == nullptr) { + sif::error << "SPI device is invalid" << std::endl; + return returnvalue::FAILED; } return returnvalue::OK; } -ReturnValue_t RwPollingTask::initialize() { return returnvalue::OK; } - ReturnValue_t RwPollingTask::initializeInterface(CookieIF* cookie) { - spiIF->getSpiDev(); - // We are in protected section, so we can use the static variable here without issues. // We don't need to set the speed because a SPI core is used, but the mode has to be set once // correctly for all RWs if (not modeAndSpeedWasSet) { - auto& dev = spiIF->getSpiDev(); - int fd = open(dev.c_str(), O_RDWR); + int fd = open(spiDev, O_RDWR); if (fd < 0) { sif::error << "could not open RW SPI bus" << std::endl; return returnvalue::FAILED; @@ -66,16 +97,20 @@ ReturnValue_t RwPollingTask::sendMessage(CookieIF* cookie, const uint8_t* sendDa SerializeAdapter::deSerialize(&speed, &sendData, &sendLen, SerializeIF::Endianness::MACHINE); SerializeAdapter::deSerialize(&rampTime, &sendData, &sendLen, SerializeIF::Endianness::MACHINE); rws::SpecialRwRequest specialRequest = rws::SpecialRwRequest::REQUEST_NONE; - if (sendLen == 7 and sendData[6] < rws::SpecialRwRequest::NUM_REQUESTS) { + if (sendLen == 7 and sendData[6] < static_cast(rws::SpecialRwRequest::NUM_REQUESTS)) { specialRequest = static_cast(sendData[6]); } RwCookie* rwCookie = dynamic_cast(cookie); + if (rwCookie == nullptr) { + return returnvalue::FAILED; + } { MutexGuard mg(ipcLock); rwCookie->currentRwSpeed = speed; rwCookie->currentRampTime = rampTime; rwCookie->specialRequest = specialRequest; if (state == InternalState::IDLE and rwCookie->rwIdx == 3) { + state = InternalState::BUSY; semaphore->release(); } } @@ -98,19 +133,17 @@ ReturnValue_t RwPollingTask::readReceivedMessage(CookieIF* cookie, uint8_t** buf return returnvalue::OK; } -ReturnValue_t RwPollingTask::writeAndReadAllRws(const uint8_t* sendData, size_t sendDataLen) { +ReturnValue_t RwPollingTask::writeAndReadAllRws(DeviceCommandId_t id) { // Stopwatch watch; ReturnValue_t result = returnvalue::OK; int fd = 0; - const std::string& dev = spiIF->getSpiDev(); - MutexIF* spiLock = spiIF->getCsMutex(); - result = openSpi(dev, O_RDWR, fd); + result = openSpi(O_RDWR, fd); if (result != returnvalue::OK) { return result; } for (unsigned idx = 0; idx < rwCookies.size(); idx++) { - ReturnValue_t result = sendOneMessage(fd, *rwCookies[idx], spiLock, sendData, sendDataLen); + ReturnValue_t result = sendOneMessage(fd, *rwCookies[idx]); if (result != returnvalue::OK) { closeSpi(fd); return returnvalue::FAILED; @@ -119,11 +152,11 @@ ReturnValue_t RwPollingTask::writeAndReadAllRws(const uint8_t* sendData, size_t closeSpi(fd); usleep(rws::SPI_REPLY_DELAY); - return readAllRws(fd, spiLock, dev.c_str()); + return readAllRws(fd, id); } -ReturnValue_t RwPollingTask::openSpi(const std::string& devname, int flags, int& fd) { - fd = open(devname.c_str(), flags); +ReturnValue_t RwPollingTask::openSpi(int flags, int& fd) { + fd = open(spiDev, flags); if (fd < 0) { sif::error << "rwSpiCallback::spiCallback: Failed to open device file" << std::endl; return SpiComIF::OPENING_FILE_FAILED; @@ -132,15 +165,15 @@ ReturnValue_t RwPollingTask::openSpi(const std::string& devname, int flags, int& return returnvalue::OK; } -ReturnValue_t RwPollingTask::readNextReply(const char* spiDev, RwCookie& rwCookie, MutexIF* spiLock, - uint8_t* replyBuf) { +ReturnValue_t RwPollingTask::readNextReply(RwCookie& rwCookie, uint8_t* replyBuf, + size_t maxReplyLen) { ReturnValue_t result = returnvalue::OK; int fd = 0; gpioId_t gpioId = rwCookie.getChipSelectPin(); GpioIF& gpioIF = spiIF->getGpioInterface(); pullCsLow(gpioId, spiLock, gpioIF); for (unsigned idx = 0; idx < MAX_RETRIES_REPLY; idx++) { - result = openSpi(spiDev, O_RDWR, fd); + result = openSpi(O_RDWR, fd); if (result != returnvalue::OK) { return result; } @@ -184,7 +217,7 @@ ReturnValue_t RwPollingTask::readNextReply(const char* spiDev, RwCookie& rwCooki size_t decodedFrameLen = 0; - while (decodedFrameLen < processingBuf.size()) { + while (decodedFrameLen < maxReplyLen) { /** First byte already read in */ if (decodedFrameLen != 0) { byteRead = 0; @@ -205,11 +238,11 @@ ReturnValue_t RwPollingTask::readNextReply(const char* spiDev, RwCookie& rwCooki break; } if (byteRead == 0x5E) { - *(processingBuf.data() + decodedFrameLen) = 0x7E; + *(replyBuf + decodedFrameLen) = 0x7E; decodedFrameLen++; continue; } else if (byteRead == 0x5D) { - *(processingBuf.data() + decodedFrameLen) = 0x7D; + *(replyBuf + decodedFrameLen) = 0x7D; decodedFrameLen++; continue; } else { @@ -219,7 +252,7 @@ ReturnValue_t RwPollingTask::readNextReply(const char* spiDev, RwCookie& rwCooki break; } } else { - *(processingBuf.data() + decodedFrameLen) = byteRead; + *(replyBuf + decodedFrameLen) = byteRead; decodedFrameLen++; continue; } @@ -229,7 +262,7 @@ ReturnValue_t RwPollingTask::readNextReply(const char* spiDev, RwCookie& rwCooki * replaced by its substitute. Than the next byte must correspond to the end sign 0x7E. * Otherwise there might be something wrong. */ - if (decodedFrameLen == processingBuf.size()) { + if (decodedFrameLen == maxReplyLen) { if (read(fd, &byteRead, 1) != 1) { sif::error << "rwSpiCallback::spiCallback: Failed to read last byte" << std::endl; result = rws::SPI_READ_FAILURE; @@ -249,16 +282,8 @@ ReturnValue_t RwPollingTask::readNextReply(const char* spiDev, RwCookie& rwCooki return returnvalue::OK; } -ReturnValue_t RwPollingTask::writeOneRw(uint8_t rwIdx) { - int fd = 0; - const std::string& dev = spiIF->getSpiDev(); - MutexIF* spiLock = spiIF->getCsMutex(); - ReturnValue_t result = openSpi(dev, O_RDWR, fd); - if (result != returnvalue::OK) { - return result; - } - ReturnValue_t result = - sendOneMessage(fd, *rwCookies[rwIdx], spiLock, writeBuffer.data(), writeLen); +ReturnValue_t RwPollingTask::writeOneRwCmd(uint8_t rwIdx, int fd) { + ReturnValue_t result = sendOneMessage(fd, *rwCookies[rwIdx]); if (result != returnvalue::OK) { closeSpi(fd); return returnvalue::FAILED; @@ -266,20 +291,83 @@ ReturnValue_t RwPollingTask::writeOneRw(uint8_t rwIdx) { return returnvalue::OK; } -ReturnValue_t RwPollingTask::readAllRws(int fd, MutexIF* spiLock, const char* dev) { +ReturnValue_t RwPollingTask::readAllRws(int fd, DeviceCommandId_t id) { + ReturnValue_t result = openSpi(O_RDWR, fd); + if (result != returnvalue::OK) { + return result; + } for (unsigned idx = 0; idx < rwCookies.size(); idx++) { if (spiLock == nullptr) { sif::debug << "rwSpiCallback::spiCallback: Mutex or GPIO interface invalid" << std::endl; return returnvalue::FAILED; } + // TODO: Fix buffer to write to uint8_t* replyBuf; - readNextReply(dev, *rwCookies[idx], spiLock, replyBuf); + size_t maxReadLen = idAndIdxToReadBuffer(id, idx, &replyBuf); + readNextReply(*rwCookies[idx], replyBuf, maxReadLen); } closeSpi(fd); return returnvalue::OK; } +size_t RwPollingTask::idAndIdxToReadBuffer(DeviceCommandId_t id, uint8_t rwIdx, uint8_t** ptr) { + uint8_t* rawStart = rwCookies[rwIdx]->replyBuf.data(); + RwReplies replies(rawStart); + switch (id) { + case (rws::GET_RW_STATUS): { + *ptr = replies.rwStatusReply; + return rws::SIZE_GET_RW_STATUS; + } + case (rws::SET_SPEED): { + *ptr = replies.setSpeedReply; + return rws::SIZE_SET_SPEED_REPLY; + } + case (rws::CLEAR_LAST_RESET_STATUS): { + *ptr = replies.clearLastResetStatusReply; + return rws::SIZE_CLEAR_RESET_STATUS; + } + case (rws::GET_LAST_RESET_STATUS): { + *ptr = replies.getLastResetStatusReply; + return rws::SIZE_GET_RESET_STATUS; + } + case (rws::GET_TEMPERATURE): { + *ptr = replies.readTemperatureReply; + return rws::SIZE_GET_TEMPERATURE_REPLY; + } + case (rws::GET_TM): { + *ptr = replies.hkDataReply; + return rws::SIZE_GET_TELEMETRY_REPLY; + } + case (rws::INIT_RW_CONTROLLER): { + *ptr = replies.initRwControllerReply; + return rws::SIZE_INIT_RW; + } + default: { + sif::error << "no reply buffer for rw command " << id << std::endl; + *ptr = replies.dummyPointer; + return 0; + } + } +} + +void RwPollingTask::encodeHdlc(const uint8_t* sourceBuf, size_t sourceLen, size_t& encodedLen) { + encodedBuffer[0] = FLAG_BYTE; + encodedLen = 1; + for (size_t sourceIdx = 0; sourceIdx < sourceLen; sourceIdx++) { + if (sourceBuf[sourceIdx] == 0x7E) { + encodedBuffer[encodedLen++] = 0x7D; + encodedBuffer[encodedLen++] = 0x5E; + } else if (sourceBuf[sourceIdx] == 0x7D) { + encodedBuffer[encodedLen++] = 0x7D; + encodedBuffer[encodedLen++] = 0x5D; + } else { + encodedBuffer[encodedLen++] = sourceBuf[sourceIdx]; + } + } + encodedBuffer[encodedLen++] = FLAG_BYTE; +} + // This closes the SPI void RwPollingTask::closeSpi(int fd) { // This will perform the function to close the SPI @@ -287,8 +375,7 @@ void RwPollingTask::closeSpi(int fd) { // The SPI is now closed. } -ReturnValue_t RwPollingTask::sendOneMessage(int fd, RwCookie& rwCookie, MutexIF* spiLock, - const uint8_t* data, size_t dataLen) { +ReturnValue_t RwPollingTask::sendOneMessage(int fd, RwCookie& rwCookie) { gpioId_t gpioId = rwCookie.getChipSelectPin(); GpioIF& gpioIF = spiIF->getGpioInterface(); if (spiLock == nullptr) { @@ -296,15 +383,8 @@ ReturnValue_t RwPollingTask::sendOneMessage(int fd, RwCookie& rwCookie, MutexIF* return returnvalue::FAILED; } pullCsLow(gpioId, spiLock, gpioIF); - /** Sending frame start sign */ - writeBuffer[0] = FLAG_BYTE; - size_t writeSize = 1; - if (write(fd, writeBuffer.data(), writeSize) != static_cast(writeSize)) { - sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; - pullCsHigh(gpioId, spiLock, gpioIF); - return rws::SPI_WRITE_FAILURE; - } - /** Encoding and sending command */ + /* + //Encoding and sending command size_t idx = 0; while (idx < dataLen) { switch (*(data + idx)) { @@ -324,21 +404,16 @@ ReturnValue_t RwPollingTask::sendOneMessage(int fd, RwCookie& rwCookie, MutexIF* break; } } - if (write(fd, writeBuffer.data(), writeSize) != static_cast(writeSize)) { - sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; - pullCsHigh(gpioId, spiLock, gpioIF); - return rws::SPI_WRITE_FAILURE; - } - idx++; - /** Sending frame end sign */ - writeBuffer[0] = FLAG_BYTE; - writeSize = 1; - - if (write(fd, writeBuffer.data(), writeSize) != static_cast(writeSize)) { + */ + // Add datalinklayer like specified in the datasheet. + size_t lenToSend = 0; + encodeHdlc(writeBuffer.data(), writeLen, lenToSend); + if (write(fd, encodedBuffer.data(), lenToSend) != static_cast(lenToSend)) { sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; pullCsHigh(gpioId, spiLock, gpioIF); return rws::SPI_WRITE_FAILURE; } + pullCsHigh(gpioId, spiLock, gpioIF); return returnvalue::OK; } @@ -376,6 +451,7 @@ void RwPollingTask::prepareSimpleCommand(DeviceCommandId_t id) { uint16_t crc = CRC::crc16ccitt(writeBuffer.data(), 1, 0xFFFF); writeBuffer[1] = static_cast(crc & 0xFF); writeBuffer[2] = static_cast(crc >> 8 & 0xFF); + writeLen = 3; } ReturnValue_t RwPollingTask::prepareSetSpeedCmd(uint8_t rwIdx) { @@ -397,5 +473,6 @@ ReturnValue_t RwPollingTask::prepareSetSpeedCmd(uint8_t rwIdx) { uint16_t crc = CRC::crc16ccitt(writeBuffer.data(), 7, 0xFFFF); writeBuffer[7] = static_cast(crc & 0xFF); writeBuffer[8] = static_cast((crc >> 8) & 0xFF); + writeLen = 9; return returnvalue::OK; } diff --git a/linux/devices/RwPollingTask.h b/linux/devices/RwPollingTask.h index d649a66a..2b7d899f 100644 --- a/linux/devices/RwPollingTask.h +++ b/linux/devices/RwPollingTask.h @@ -14,15 +14,16 @@ class RwCookie : public SpiCookie { friend class RwPollingTask; public: + static constexpr size_t REPLY_BUF_LEN = 524; RwCookie(uint8_t rwIdx, address_t spiAddress, gpioId_t chipSelect, const size_t maxSize, spi::SpiModes spiMode, uint32_t spiSpeed) : SpiCookie(spiAddress, chipSelect, maxSize, spiMode, spiSpeed), rwIdx(rwIdx) {} private: - std::array replyBuf{}; + std::array replyBuf{}; int32_t currentRwSpeed = 0; uint16_t currentRampTime = 0; - rws::SpecialRwRequest specialRequest = rws::SpecialRwRequest::NONE; + rws::SpecialRwRequest specialRequest = rws::SpecialRwRequest::REQUEST_NONE; uint8_t rwIdx; }; @@ -39,24 +40,26 @@ class RwPollingTask : public SystemObject, public ExecutableObjectIF, public Dev bool debugMode = false; bool modeAndSpeedWasSet = false; MutexIF* ipcLock; + MutexIF* spiLock; + const char* spiDev; SpiComIF* spiIF; std::array rwCookies; std::array writeBuffer; + std::array encodedBuffer; + size_t writeLen = 0; - std::array processingBuf; //! This is the end and start marker of the frame datalinklayer static constexpr uint8_t FLAG_BYTE = 0x7E; static constexpr MutexIF::TimeoutType TIMEOUT_TYPE = MutexIF::TimeoutType::WAITING; static constexpr uint32_t TIMEOUT_MS = 20; static constexpr uint8_t MAX_RETRIES_REPLY = 5; - ReturnValue_t writeAndReadAllRws(const uint8_t* sendData, size_t sendDataLen); - ReturnValue_t writeOneRw(uint8_t rwIdx); - ReturnValue_t readAllRws(int fd, MutexIF* spiLock, const char* dev); - ReturnValue_t sendOneMessage(int fd, RwCookie& rwCookie, MutexIF* spiLock, const uint8_t* data, - size_t dataLen); - ReturnValue_t readNextReply(const char* spiDev, RwCookie& rwCookie, MutexIF* spiLock, - uint8_t* replyBuf); + ReturnValue_t writeAndReadAllRws(DeviceCommandId_t id); + ReturnValue_t writeOneRwCmd(uint8_t rwIdx, int fd); + ReturnValue_t readAllRws(int fd, DeviceCommandId_t id); + + ReturnValue_t sendOneMessage(int fd, RwCookie& rwCookie); + ReturnValue_t readNextReply(RwCookie& rwCookie, uint8_t* replyBuf, size_t maxReplyLen); ReturnValue_t initializeInterface(CookieIF* cookie) override; ReturnValue_t sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) override; @@ -66,11 +69,14 @@ class RwPollingTask : public SystemObject, public ExecutableObjectIF, public Dev ReturnValue_t requestReceiveMessage(CookieIF* cookie, size_t requestLen) override; ReturnValue_t readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) override; - ReturnValue_t openSpi(const std::string& devname, int flags, int& fd); + ReturnValue_t openSpi(int flags, int& fd); ReturnValue_t pullCsLow(gpioId_t gpioId, MutexIF* spiLock, GpioIF& gpioIF); void prepareSimpleCommand(DeviceCommandId_t id); ReturnValue_t prepareSetSpeedCmd(uint8_t rwIdx); + size_t idAndIdxToReadBuffer(DeviceCommandId_t id, uint8_t rwIdx, uint8_t** readPtr); + void encodeHdlc(const uint8_t* sourceBuf, size_t sourceLen, size_t& encodedLen); + void pullCsHigh(gpioId_t gpioId, MutexIF* spiLock, GpioIF& gpioIF); void closeSpi(int); }; diff --git a/mission/devices/devicedefinitions/rwHelpers.h b/mission/devices/devicedefinitions/rwHelpers.h index 743813fa..55b17859 100644 --- a/mission/devices/devicedefinitions/rwHelpers.h +++ b/mission/devices/devicedefinitions/rwHelpers.h @@ -19,7 +19,7 @@ static const size_t SIZE_GET_TEMPERATURE_REPLY = 8; /** Max size when requesting telemetry */ static const size_t SIZE_GET_TELEMETRY_REPLY = 91; -enum SpecialRwRequest : uint8_t { +enum class SpecialRwRequest : uint8_t { REQUEST_NONE = 0, RESET_MCU = 1, INIT_RW_CONTROLLER = 2, @@ -27,47 +27,6 @@ enum SpecialRwRequest : uint8_t { NUM_REQUESTS }; -struct RwReplies { - friend class RwPollingTask; - - public: - RwReplies(const uint8_t* rawData) : rawData(rawData) { - rwStatusReply = rawData; - setSpeedReply = rawData + SIZE_GET_RW_STATUS; - getLastResetStatusReply = setSpeedReply + SIZE_SET_SPEED_REPLY; - clearLastResetStatusReply = getLastResetStatusReply + SIZE_GET_RESET_STATUS; - readTemperatureReply = clearLastResetStatusReply + SIZE_CLEAR_RESET_STATUS; - hkDataReply = readTemperatureReply + SIZE_GET_TEMPERATURE_REPLY; - initRwControllerReply = hkDataReply + SIZE_GET_TELEMETRY_REPLY; - } - - const uint8_t* getClearLastResetStatusReply() const { return clearLastResetStatusReply; } - - const uint8_t* getGetLastResetStatusReply() const { return getLastResetStatusReply; } - - const uint8_t* getHkDataReply() const { return hkDataReply; } - - const uint8_t* getInitRwControllerReply() const { return initRwControllerReply; } - - const uint8_t* getRawData() const { return rawData; } - - const uint8_t* getReadTemperatureReply() const { return readTemperatureReply; } - - const uint8_t* getRwStatusReply() const { return rwStatusReply; } - - const uint8_t* getSetSpeedReply() const { return setSpeedReply; } - - private: - const uint8_t* rawData; - const uint8_t* rwStatusReply; - const uint8_t* setSpeedReply; - const uint8_t* getLastResetStatusReply; - const uint8_t* clearLastResetStatusReply; - const uint8_t* readTemperatureReply; - const uint8_t* hkDataReply; - const uint8_t* initRwControllerReply; -}; - static const uint8_t INTERFACE_ID = CLASS_ID::RW_HANDLER; static const ReturnValue_t SPI_WRITE_FAILURE = MAKE_RETURN_CODE(0xB0); @@ -299,4 +258,50 @@ class RwSpeedActuationSet : public StaticLocalDataSet<2> { } // namespace rws +struct RwReplies { + friend class RwPollingTask; + + public: + RwReplies(const uint8_t* rawData) : rawData(const_cast(rawData)) { initPointers(); } + + const uint8_t* getClearLastResetStatusReply() const { return clearLastResetStatusReply; } + + const uint8_t* getGetLastResetStatusReply() const { return getLastResetStatusReply; } + + const uint8_t* getHkDataReply() const { return hkDataReply; } + + const uint8_t* getInitRwControllerReply() const { return initRwControllerReply; } + + const uint8_t* getRawData() const { return rawData; } + + const uint8_t* getReadTemperatureReply() const { return readTemperatureReply; } + + const uint8_t* getRwStatusReply() const { return rwStatusReply; } + + const uint8_t* getSetSpeedReply() const { return setSpeedReply; } + + private: + RwReplies(uint8_t* rwData) : rawData(rwData) { initPointers(); } + + void initPointers() { + rwStatusReply = rawData; + setSpeedReply = rawData + rws::SIZE_GET_RW_STATUS; + getLastResetStatusReply = setSpeedReply + rws::SIZE_SET_SPEED_REPLY; + clearLastResetStatusReply = getLastResetStatusReply + rws::SIZE_GET_RESET_STATUS; + readTemperatureReply = clearLastResetStatusReply + rws::SIZE_CLEAR_RESET_STATUS; + hkDataReply = readTemperatureReply + rws::SIZE_GET_TEMPERATURE_REPLY; + initRwControllerReply = hkDataReply + rws::SIZE_GET_TELEMETRY_REPLY; + dummyPointer = initRwControllerReply + rws::SIZE_INIT_RW; + } + uint8_t* rawData; + uint8_t* rwStatusReply; + uint8_t* setSpeedReply; + uint8_t* getLastResetStatusReply; + uint8_t* clearLastResetStatusReply; + uint8_t* readTemperatureReply; + uint8_t* hkDataReply; + uint8_t* initRwControllerReply; + uint8_t* dummyPointer; +}; + #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_RWHELPERS_H_ */ From 655e01c2d13979111a11f226151a45d63ee42175 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Feb 2023 19:27:19 +0100 Subject: [PATCH 133/373] some more bugfixes --- linux/devices/RwPollingTask.cpp | 136 ++++++++++++++++---------------- linux/devices/RwPollingTask.h | 2 +- 2 files changed, 70 insertions(+), 68 deletions(-) diff --git a/linux/devices/RwPollingTask.cpp b/linux/devices/RwPollingTask.cpp index 657f8853..b300136a 100644 --- a/linux/devices/RwPollingTask.cpp +++ b/linux/devices/RwPollingTask.cpp @@ -172,6 +172,7 @@ ReturnValue_t RwPollingTask::readNextReply(RwCookie& rwCookie, uint8_t* replyBuf gpioId_t gpioId = rwCookie.getChipSelectPin(); GpioIF& gpioIF = spiIF->getGpioInterface(); pullCsLow(gpioId, spiLock, gpioIF); + uint8_t byteRead = 0; for (unsigned idx = 0; idx < MAX_RETRIES_REPLY; idx++) { result = openSpi(O_RDWR, fd); if (result != returnvalue::OK) { @@ -181,18 +182,17 @@ ReturnValue_t RwPollingTask::readNextReply(RwCookie& rwCookie, uint8_t* replyBuf * The reaction wheel responds with empty frames while preparing the reply data. * However, receiving more than 5 empty frames will be interpreted as an error. */ - uint8_t byteRead = 0; for (int idx = 0; idx < 5; idx++) { if (read(fd, &byteRead, 1) != 1) { sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; - pullCsHigh(gpioId, spiLock, gpioIF); + pullCsHigh(gpioId, gpioIF); closeSpi(fd); return rws::SPI_READ_FAILURE; } if (idx == 0) { if (byteRead != FLAG_BYTE) { sif::error << "Invalid data, expected start marker" << std::endl; - pullCsHigh(gpioId, spiLock, gpioIF); + pullCsHigh(gpioId, gpioIF); closeSpi(fd); return rws::NO_START_MARKER; } @@ -202,7 +202,7 @@ ReturnValue_t RwPollingTask::readNextReply(RwCookie& rwCookie, uint8_t* replyBuf break; } - pullCsHigh(gpioId, spiLock, gpioIF); + pullCsHigh(gpioId, gpioIF); closeSpi(fd); if (idx == MAX_RETRIES_REPLY - 1) { sif::error << "rwSpiCallback::spiCallback: Empty frame timeout" << std::endl; @@ -210,76 +210,78 @@ ReturnValue_t RwPollingTask::readNextReply(RwCookie& rwCookie, uint8_t* replyBuf } TaskFactory::delayTask(5); } - + } #if FSFW_HAL_SPI_WIRETAPPING == 1 - sif::info << "RW start marker detected" << std::endl; + sif::info << "RW start marker detected" << std::endl; #endif - size_t decodedFrameLen = 0; + size_t decodedFrameLen = 0; - while (decodedFrameLen < maxReplyLen) { - /** First byte already read in */ - if (decodedFrameLen != 0) { - byteRead = 0; - if (read(fd, &byteRead, 1) != 1) { - sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; - result = rws::SPI_READ_FAILURE; - break; - } - } - - if (byteRead == FLAG_BYTE) { - /** Reached end of frame */ + while (decodedFrameLen < maxReplyLen) { + // First byte already read in + if (decodedFrameLen != 0) { + byteRead = 0; + if (read(fd, &byteRead, 1) != 1) { + sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; + result = rws::SPI_READ_FAILURE; break; - } else if (byteRead == 0x7D) { - if (read(fd, &byteRead, 1) != 1) { - sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; - result = rws::SPI_READ_FAILURE; - break; - } - if (byteRead == 0x5E) { - *(replyBuf + decodedFrameLen) = 0x7E; - decodedFrameLen++; - continue; - } else if (byteRead == 0x5D) { - *(replyBuf + decodedFrameLen) = 0x7D; - decodedFrameLen++; - continue; - } else { - sif::error << "rwSpiCallback::spiCallback: Invalid substitute" << std::endl; - closeSpi(fd); - result = rws::INVALID_SUBSTITUTE; - break; - } - } else { - *(replyBuf + decodedFrameLen) = byteRead; + } + } + + if (byteRead == FLAG_BYTE) { + // Reached end of frame + break; + } else if (byteRead == 0x7D) { + if (read(fd, &byteRead, 1) != 1) { + sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; + result = rws::SPI_READ_FAILURE; + break; + } + if (byteRead == 0x5E) { + *(replyBuf + decodedFrameLen) = 0x7E; decodedFrameLen++; continue; + } else if (byteRead == 0x5D) { + *(replyBuf + decodedFrameLen) = 0x7D; + decodedFrameLen++; + continue; + } else { + sif::error << "rwSpiCallback::spiCallback: Invalid substitute" << std::endl; + result = rws::INVALID_SUBSTITUTE; + break; } - - /** - * There might be the unlikely case that each byte in a get-telemetry reply has been - * replaced by its substitute. Than the next byte must correspond to the end sign 0x7E. - * Otherwise there might be something wrong. - */ - if (decodedFrameLen == maxReplyLen) { - if (read(fd, &byteRead, 1) != 1) { - sif::error << "rwSpiCallback::spiCallback: Failed to read last byte" << std::endl; - result = rws::SPI_READ_FAILURE; - break; - } - if (byteRead != FLAG_BYTE) { - sif::error << "rwSpiCallback::spiCallback: Missing end sign " - << static_cast(FLAG_BYTE) << std::endl; - decodedFrameLen--; - result = rws::MISSING_END_SIGN; - break; - } - } - result = returnvalue::OK; + } else { + *(replyBuf + decodedFrameLen) = byteRead; + decodedFrameLen++; + continue; } + + // Check end marker. + /** + * There might be the unlikely case that each byte in a get-telemetry reply has been + * replaced by its substitute. Then the next byte must correspond to the end sign 0x7E. + * Otherwise there might be something wrong. + */ + if (decodedFrameLen == maxReplyLen) { + if (read(fd, &byteRead, 1) != 1) { + sif::error << "rwSpiCallback::spiCallback: Failed to read last byte" << std::endl; + result = rws::SPI_READ_FAILURE; + break; + } + if (byteRead != FLAG_BYTE) { + sif::error << "rwSpiCallback::spiCallback: Missing end sign " << static_cast(FLAG_BYTE) + << std::endl; + decodedFrameLen--; + result = rws::MISSING_END_SIGN; + break; + } + } + result = returnvalue::OK; } - return returnvalue::OK; + + pullCsHigh(gpioId, gpioIF); + closeSpi(fd); + return result; } ReturnValue_t RwPollingTask::writeOneRwCmd(uint8_t rwIdx, int fd) { @@ -410,10 +412,10 @@ ReturnValue_t RwPollingTask::sendOneMessage(int fd, RwCookie& rwCookie) { encodeHdlc(writeBuffer.data(), writeLen, lenToSend); if (write(fd, encodedBuffer.data(), lenToSend) != static_cast(lenToSend)) { sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; - pullCsHigh(gpioId, spiLock, gpioIF); + pullCsHigh(gpioId, gpioIF); return rws::SPI_WRITE_FAILURE; } - pullCsHigh(gpioId, spiLock, gpioIF); + pullCsHigh(gpioId, gpioIF); return returnvalue::OK; } @@ -434,7 +436,7 @@ ReturnValue_t RwPollingTask::pullCsLow(gpioId_t gpioId, MutexIF* spiLock, GpioIF return returnvalue::OK; } -void RwPollingTask::pullCsHigh(gpioId_t gpioId, MutexIF* spiLock, GpioIF& gpioIF) { +void RwPollingTask::pullCsHigh(gpioId_t gpioId, GpioIF& gpioIF) { if (gpioId != gpio::NO_GPIO) { if (gpioIF.pullHigh(gpioId) != returnvalue::OK) { sif::error << "closeSpi: Failed to pull chip select high" << std::endl; diff --git a/linux/devices/RwPollingTask.h b/linux/devices/RwPollingTask.h index 2b7d899f..701771f1 100644 --- a/linux/devices/RwPollingTask.h +++ b/linux/devices/RwPollingTask.h @@ -77,7 +77,7 @@ class RwPollingTask : public SystemObject, public ExecutableObjectIF, public Dev size_t idAndIdxToReadBuffer(DeviceCommandId_t id, uint8_t rwIdx, uint8_t** readPtr); void encodeHdlc(const uint8_t* sourceBuf, size_t sourceLen, size_t& encodedLen); - void pullCsHigh(gpioId_t gpioId, MutexIF* spiLock, GpioIF& gpioIF); + void pullCsHigh(gpioId_t gpioId, GpioIF& gpioIF); void closeSpi(int); }; From 9fdb41506b070ee0c0254eef417f307b984880a1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Feb 2023 19:58:32 +0100 Subject: [PATCH 134/373] added basic unittests for hdlc encoder --- linux/devices/RwPollingTask.cpp | 53 +++---------------- linux/devices/RwPollingTask.h | 3 -- misc/eclipse/.cproject | 35 +++++++----- .../devices/devicedefinitions/CMakeLists.txt | 2 +- .../devices/devicedefinitions/rwHelpers.cpp | 18 +++++++ mission/devices/devicedefinitions/rwHelpers.h | 8 +++ unittest/CMakeLists.txt | 1 + unittest/hdlcEncodingRw.cpp | 38 +++++++++++++ 8 files changed, 95 insertions(+), 63 deletions(-) create mode 100644 unittest/hdlcEncodingRw.cpp diff --git a/linux/devices/RwPollingTask.cpp b/linux/devices/RwPollingTask.cpp index b300136a..c8744301 100644 --- a/linux/devices/RwPollingTask.cpp +++ b/linux/devices/RwPollingTask.cpp @@ -190,7 +190,7 @@ ReturnValue_t RwPollingTask::readNextReply(RwCookie& rwCookie, uint8_t* replyBuf return rws::SPI_READ_FAILURE; } if (idx == 0) { - if (byteRead != FLAG_BYTE) { + if (byteRead != rws::FRAME_DELIMITER) { sif::error << "Invalid data, expected start marker" << std::endl; pullCsHigh(gpioId, gpioIF); closeSpi(fd); @@ -198,7 +198,7 @@ ReturnValue_t RwPollingTask::readNextReply(RwCookie& rwCookie, uint8_t* replyBuf } } - if (byteRead != FLAG_BYTE) { + if (byteRead != rws::FRAME_DELIMITER) { break; } @@ -228,7 +228,7 @@ ReturnValue_t RwPollingTask::readNextReply(RwCookie& rwCookie, uint8_t* replyBuf } } - if (byteRead == FLAG_BYTE) { + if (byteRead == rws::FRAME_DELIMITER) { // Reached end of frame break; } else if (byteRead == 0x7D) { @@ -268,9 +268,9 @@ ReturnValue_t RwPollingTask::readNextReply(RwCookie& rwCookie, uint8_t* replyBuf result = rws::SPI_READ_FAILURE; break; } - if (byteRead != FLAG_BYTE) { - sif::error << "rwSpiCallback::spiCallback: Missing end sign " << static_cast(FLAG_BYTE) - << std::endl; + if (byteRead != rws::FRAME_DELIMITER) { + sif::error << "rwSpiCallback::spiCallback: Missing end sign " + << static_cast(rws::FRAME_DELIMITER) << std::endl; decodedFrameLen--; result = rws::MISSING_END_SIGN; break; @@ -353,23 +353,6 @@ size_t RwPollingTask::idAndIdxToReadBuffer(DeviceCommandId_t id, uint8_t rwIdx, } } -void RwPollingTask::encodeHdlc(const uint8_t* sourceBuf, size_t sourceLen, size_t& encodedLen) { - encodedBuffer[0] = FLAG_BYTE; - encodedLen = 1; - for (size_t sourceIdx = 0; sourceIdx < sourceLen; sourceIdx++) { - if (sourceBuf[sourceIdx] == 0x7E) { - encodedBuffer[encodedLen++] = 0x7D; - encodedBuffer[encodedLen++] = 0x5E; - } else if (sourceBuf[sourceIdx] == 0x7D) { - encodedBuffer[encodedLen++] = 0x7D; - encodedBuffer[encodedLen++] = 0x5D; - } else { - encodedBuffer[encodedLen++] = sourceBuf[sourceIdx]; - } - } - encodedBuffer[encodedLen++] = FLAG_BYTE; -} - // This closes the SPI void RwPollingTask::closeSpi(int fd) { // This will perform the function to close the SPI @@ -385,31 +368,9 @@ ReturnValue_t RwPollingTask::sendOneMessage(int fd, RwCookie& rwCookie) { return returnvalue::FAILED; } pullCsLow(gpioId, spiLock, gpioIF); - /* - //Encoding and sending command - size_t idx = 0; - while (idx < dataLen) { - switch (*(data + idx)) { - case 0x7E: - writeBuffer[0] = 0x7D; - writeBuffer[1] = 0x5E; - writeSize = 2; - break; - case 0x7D: - writeBuffer[0] = 0x7D; - writeBuffer[1] = 0x5D; - writeSize = 2; - break; - default: - writeBuffer[0] = *(data + idx); - writeSize = 1; - break; - } - } - */ // Add datalinklayer like specified in the datasheet. size_t lenToSend = 0; - encodeHdlc(writeBuffer.data(), writeLen, lenToSend); + rws::encodeHdlc(writeBuffer.data(), writeLen, encodedBuffer.data(), lenToSend); if (write(fd, encodedBuffer.data(), lenToSend) != static_cast(lenToSend)) { sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; pullCsHigh(gpioId, gpioIF); diff --git a/linux/devices/RwPollingTask.h b/linux/devices/RwPollingTask.h index 701771f1..b9895865 100644 --- a/linux/devices/RwPollingTask.h +++ b/linux/devices/RwPollingTask.h @@ -48,8 +48,6 @@ class RwPollingTask : public SystemObject, public ExecutableObjectIF, public Dev std::array encodedBuffer; size_t writeLen = 0; - //! This is the end and start marker of the frame datalinklayer - static constexpr uint8_t FLAG_BYTE = 0x7E; static constexpr MutexIF::TimeoutType TIMEOUT_TYPE = MutexIF::TimeoutType::WAITING; static constexpr uint32_t TIMEOUT_MS = 20; static constexpr uint8_t MAX_RETRIES_REPLY = 5; @@ -75,7 +73,6 @@ class RwPollingTask : public SystemObject, public ExecutableObjectIF, public Dev ReturnValue_t prepareSetSpeedCmd(uint8_t rwIdx); size_t idAndIdxToReadBuffer(DeviceCommandId_t id, uint8_t rwIdx, uint8_t** readPtr); - void encodeHdlc(const uint8_t* sourceBuf, size_t sourceLen, size_t& encodedLen); void pullCsHigh(gpioId_t gpioId, GpioIF& gpioIF); void closeSpi(int); diff --git a/misc/eclipse/.cproject b/misc/eclipse/.cproject index 0dfd812a..0f3348a8 100644 --- a/misc/eclipse/.cproject +++ b/misc/eclipse/.cproject @@ -57,7 +57,8 @@ - + + @@ -119,7 +120,8 @@ - + + @@ -187,7 +189,8 @@ - + + @@ -255,7 +258,8 @@ - + + @@ -418,7 +422,8 @@ - + + @@ -580,7 +585,8 @@ - + + @@ -680,7 +686,7 @@