From 130a3ce727d4fb9fe13aac23fc84a1594e8c0730 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 13 Dec 2022 14:38:30 +0100 Subject: [PATCH] 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;