From e0024e738e6f6bfc2c5bc3cbf11a4cecbd8c8a51 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 10 Mar 2023 16:49:12 +0100 Subject: [PATCH] dedicated store for RAM to FileStore IPC --- bsp_q7s/fmObjectFactory.cpp | 2 ++ common/config/eive/objects.h | 1 + mission/core/GenericFactory.cpp | 22 ++++++++++------------ mission/tmtc/CfdpTmFunnel.cpp | 18 ++++++++++++++++-- mission/tmtc/CfdpTmFunnel.h | 5 ++++- mission/tmtc/PusTmFunnel.cpp | 8 ++++---- mission/tmtc/PusTmFunnel.h | 4 +++- 7 files changed, 40 insertions(+), 20 deletions(-) diff --git a/bsp_q7s/fmObjectFactory.cpp b/bsp_q7s/fmObjectFactory.cpp index 3aab4409..34a7c9dc 100644 --- a/bsp_q7s/fmObjectFactory.cpp +++ b/bsp_q7s/fmObjectFactory.cpp @@ -1,4 +1,6 @@ #include +#include +#include #include #include "OBSWConfig.h" diff --git a/common/config/eive/objects.h b/common/config/eive/objects.h index 00b509f2..e22133e2 100644 --- a/common/config/eive/objects.h +++ b/common/config/eive/objects.h @@ -172,6 +172,7 @@ enum commonObjects : uint32_t { LOG_STORE_AND_TM_TASK = 0x73040001, HK_STORE_AND_TM_TASK = 0x73040002, CFDP_STORE_AND_TM_TASK = 0x73040003, + DOWNLINK_RAM_STORE = 0x73040004, // Other stuff THERMAL_TEMP_INSERTER = 0x90000003, diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index fe1a6319..b6fc5ca1 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -119,6 +119,9 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFun {100, 256}, {50, 512}, {50, 1024}, {10, 2048}}; *ipcStore = new PoolManager(objects::IPC_STORE, poolCfg); } + PoolManager::LocalPoolConfig poolCfg = {{300, 32}, {400, 64}, {250, 128}, + {150, 512}, {150, 1024}, {150, 2048}}; + auto* ramToFileStore = new PoolManager(objects::DOWNLINK_RAM_STORE, poolCfg); #if OBSW_ADD_TCPIP_SERVERS == 1 #if OBSW_ADD_TMTC_UDP_SERVER == 1 @@ -148,18 +151,17 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFun PusTmFunnel::FunnelCfg cfdpFunnelCfg(objects::CFDP_TM_FUNNEL, "CfdpTmFunnel", **tmStore, **ipcStore, 50); - *cfdpFunnel = new CfdpTmFunnel(cfdpFunnelCfg, config::EIVE_CFDP_APID); + *cfdpFunnel = new CfdpTmFunnel(cfdpFunnelCfg, *ramToFileStore, config::EIVE_CFDP_APID); PusTmFunnel::FunnelCfg pusFunnelCfg(objects::PUS_TM_FUNNEL, "PusTmFunnel", **tmStore, **ipcStore, config::MAX_PUS_FUNNEL_QUEUE_DEPTH); // The PUS funnel routes all live TM to the live destinations and to the TM stores. - *pusFunnel = new PusTmFunnel(pusFunnelCfg, *timeStamper, sdcMan); + *pusFunnel = new PusTmFunnel(pusFunnelCfg, *ramToFileStore, *timeStamper, sdcMan); // MISC store and PUS funnel to MISC store routing - // TODO: Make queue depth configurable { PersistentTmStoreArgs storeArgs(objects::MISC_TM_STORE, "tm", "misc", - RolloverInterval::HOURLY, 2, **tmStore, sdcMan); + RolloverInterval::HOURLY, 2, *ramToFileStore, sdcMan); stores.miscStore = new PersistentTmStoreWithTmQueue(storeArgs, "MISC STORE", config::MISC_STORE_QUEUE_SIZE); (*pusFunnel) @@ -168,10 +170,9 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFun } // OK store and PUS Funnel to OK store routing - // TODO: Make queue depth configurable { PersistentTmStoreArgs storeArgs(objects::OK_TM_STORE, "tm", "ok", RolloverInterval::MINUTELY, - 30, **tmStore, sdcMan); + 30, *ramToFileStore, sdcMan); stores.okStore = new PersistentTmStoreWithTmQueue(storeArgs, "OK STORE", config::OK_STORE_QUEUE_SIZE); (*pusFunnel) @@ -180,10 +181,9 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFun } // NOT OK store and PUS funnel to NOT OK store routing - // TODO: Make queue depth configurable { PersistentTmStoreArgs storeArgs(objects::NOT_OK_TM_STORE, "tm", "nok", - RolloverInterval::MINUTELY, 30, **tmStore, sdcMan); + RolloverInterval::MINUTELY, 30, *ramToFileStore, sdcMan); stores.notOkStore = new PersistentTmStoreWithTmQueue(storeArgs, "NOT OK STORE", config::NOK_STORE_QUEUE_SIZE); (*pusFunnel) @@ -192,10 +192,9 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFun } // HK store and PUS funnel to HK store routing - // TODO: Make queue depth configurable { PersistentTmStoreArgs storeArgs(objects::HK_TM_STORE, "tm", "hk", RolloverInterval::MINUTELY, - 15, **tmStore, sdcMan); + 15, *ramToFileStore, sdcMan); stores.hkStore = new PersistentTmStoreWithTmQueue(storeArgs, "HK STORE", config::HK_STORE_QUEUE_SIZE); (*pusFunnel) @@ -204,10 +203,9 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFun } // CFDP store and PUS funnel to CFDP store routing - // TODO: Make queue depth configurable { PersistentTmStoreArgs storeArgs(objects::CFDP_TM_STORE, "tm", "cfdp", - RolloverInterval::MINUTELY, 30, **tmStore, sdcMan); + RolloverInterval::MINUTELY, 30, *ramToFileStore, sdcMan); stores.cfdpStore = new PersistentTmStoreWithTmQueue(storeArgs, "CFDP STORE", config::CFDP_STORE_QUEUE_SIZE); diff --git a/mission/tmtc/CfdpTmFunnel.cpp b/mission/tmtc/CfdpTmFunnel.cpp index 26b308da..8bbbb3f6 100644 --- a/mission/tmtc/CfdpTmFunnel.cpp +++ b/mission/tmtc/CfdpTmFunnel.cpp @@ -4,8 +4,12 @@ #include "fsfw/tmtcpacket/ccsds/SpacePacketCreator.h" #include "fsfw/tmtcservices/TmTcMessage.h" -CfdpTmFunnel::CfdpTmFunnel(TmFunnelBase::FunnelCfg cfg, uint16_t cfdpInCcsdsApid) - : TmFunnelBase(cfg), cfdpInCcsdsApid(cfdpInCcsdsApid) {} +CfdpTmFunnel::CfdpTmFunnel(TmFunnelBase::FunnelCfg cfg, MessageQueueId_t fileStoreDest, + StorageManagerIF& ramToFileStore, uint16_t cfdpInCcsdsApid) + : TmFunnelBase(cfg), + fileStoreDest(fileStoreDest), + ramToFileStore(ramToFileStore), + cfdpInCcsdsApid(cfdpInCcsdsApid) {} const char* CfdpTmFunnel::getName() const { return "CFDP TM Funnel"; } @@ -76,5 +80,15 @@ ReturnValue_t CfdpTmFunnel::handlePacket(TmTcMessage& msg) { msg.setStorageId(newStoreId); store_address_t origStoreId = newStoreId; // TODO: Also route to persistent TM store + + store_address_t storageId; + result = ramToFileStore.addData(&storageId, newPacketData, packetLen); + TmTcMessage fileMsg(storageId); + if (result != returnvalue::OK) { + sif::error << "PusLiveDemux::handlePacket: Store too full to create data copy" << std::endl; + } else { + tmQueue->sendMessage(fileStoreDest, &fileMsg); + } + return demultiplexLivePackets(origStoreId, newPacketData, packetLen); } diff --git a/mission/tmtc/CfdpTmFunnel.h b/mission/tmtc/CfdpTmFunnel.h index 717573a0..a4d1bc70 100644 --- a/mission/tmtc/CfdpTmFunnel.h +++ b/mission/tmtc/CfdpTmFunnel.h @@ -12,7 +12,8 @@ class CfdpTmFunnel : public TmFunnelBase { public: - CfdpTmFunnel(TmFunnelBase::FunnelCfg cfg, uint16_t cfdpInCcsdsApid); + CfdpTmFunnel(TmFunnelBase::FunnelCfg cfg, MessageQueueId_t fileStoreDest, + StorageManagerIF& ramToFileStore, uint16_t cfdpInCcsdsApid); [[nodiscard]] const char* getName() const override; ReturnValue_t performOperation(uint8_t opCode); ReturnValue_t initialize() override; @@ -20,6 +21,8 @@ class CfdpTmFunnel : public TmFunnelBase { private: ReturnValue_t handlePacket(TmTcMessage& msg); + MessageQueueId_t fileStoreDest; + StorageManagerIF& ramToFileStore; uint16_t sourceSequenceCount = 0; uint16_t cfdpInCcsdsApid; }; diff --git a/mission/tmtc/PusTmFunnel.cpp b/mission/tmtc/PusTmFunnel.cpp index 69d60a52..dbc8f1c4 100644 --- a/mission/tmtc/PusTmFunnel.cpp +++ b/mission/tmtc/PusTmFunnel.cpp @@ -10,9 +10,9 @@ #include "fsfw/tmtcpacket/pus/tm/PusTmZcWriter.h" #include "tmtc/pusIds.h" -PusTmFunnel::PusTmFunnel(TmFunnelBase::FunnelCfg cfg, TimeReaderIF &timeReader, - SdCardMountedIF &sdcMan) - : TmFunnelBase(cfg), timeReader(timeReader), sdcMan(sdcMan) {} +PusTmFunnel::PusTmFunnel(TmFunnelBase::FunnelCfg cfg, StorageManagerIF &ramToFileStore, + TimeReaderIF &timeReader, SdCardMountedIF &sdcMan) + : TmFunnelBase(cfg), ramToFileStore(ramToFileStore), timeReader(timeReader), sdcMan(sdcMan) {} PusTmFunnel::~PusTmFunnel() = default; @@ -66,7 +66,7 @@ ReturnValue_t PusTmFunnel::handleTmPacket(TmTcMessage &message) { MessageQueueId_t destination; if (persistentTmMap.packetMatches(packet, destination)) { store_address_t storageId; - result = tmStore.addData(&storageId, packetData, size); + result = ramToFileStore.addData(&storageId, packetData, size); TmTcMessage msg(storageId); if (result != returnvalue::OK) { sif::error << "PusLiveDemux::handlePacket: Store too full to create data copy" << std::endl; diff --git a/mission/tmtc/PusTmFunnel.h b/mission/tmtc/PusTmFunnel.h index 6c1835d1..ba6e8d3e 100644 --- a/mission/tmtc/PusTmFunnel.h +++ b/mission/tmtc/PusTmFunnel.h @@ -24,7 +24,8 @@ */ class PusTmFunnel : public TmFunnelBase { public: - PusTmFunnel(TmFunnelBase::FunnelCfg cfg, TimeReaderIF &timeReader, SdCardMountedIF &sdcMan); + PusTmFunnel(TmFunnelBase::FunnelCfg cfg, StorageManagerIF &ramToFileStore, + TimeReaderIF &timeReader, SdCardMountedIF &sdcMan); [[nodiscard]] const char *getName() const override; ~PusTmFunnel() override; @@ -36,6 +37,7 @@ class PusTmFunnel : public TmFunnelBase { static constexpr dur_millis_t TV_UPDATE_INTERVAL_SECS = 60 * 5; uint16_t sourceSequenceCount = 0; + StorageManagerIF &ramToFileStore; TimeReaderIF &timeReader; bool storesInitialized = false; SdCardMountedIF &sdcMan;