From 4e8e85f45052e4492bff0a2f7d00c346ad61e519 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 10 Mar 2023 17:32:22 +0100 Subject: [PATCH] some bugfixes --- common/config/eive/definitions.h | 1 + mission/core/GenericFactory.cpp | 7 ++++--- mission/tmtc/PersistentTmStore.cpp | 25 ++++++++++++++++++++----- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/common/config/eive/definitions.h b/common/config/eive/definitions.h index cbd66e41..d6a1e757 100644 --- a/common/config/eive/definitions.h +++ b/common/config/eive/definitions.h @@ -54,6 +54,7 @@ static constexpr uint32_t HK_STORE_QUEUE_SIZE = 300; static constexpr uint32_t CFDP_STORE_QUEUE_SIZE = 300; static constexpr uint32_t MAX_PUS_FUNNEL_QUEUE_DEPTH = 100; +static constexpr uint32_t MAX_CFDP_FUNNEL_QUEUE_DEPTH = 80; static constexpr uint32_t MAX_STORED_CMDS_UDP = 120; static constexpr uint32_t MAX_STORED_CMDS_TCP = 150; diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index b6fc5ca1..39eeb582 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -149,9 +149,6 @@ 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); - PusTmFunnel::FunnelCfg cfdpFunnelCfg(objects::CFDP_TM_FUNNEL, "CfdpTmFunnel", **tmStore, - **ipcStore, 50); - *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. @@ -213,6 +210,10 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFun ->addPersistentTmStoreRouting(filters::cfdpFilter(), stores.cfdpStore->getReportReceptionQueue(0)); } + PusTmFunnel::FunnelCfg cfdpFunnelCfg(objects::CFDP_TM_FUNNEL, "CfdpTmFunnel", **tmStore, + **ipcStore, config::MAX_CFDP_FUNNEL_QUEUE_DEPTH); + *cfdpFunnel = new CfdpTmFunnel(cfdpFunnelCfg, stores.cfdpStore->getReportReceptionQueue(0), + *ramToFileStore, config::EIVE_CFDP_APID); #if OBSW_ADD_TCPIP_SERVERS == 1 #if OBSW_ADD_TMTC_UDP_SERVER == 1 diff --git a/mission/tmtc/PersistentTmStore.cpp b/mission/tmtc/PersistentTmStore.cpp index ccfe8821..9ed0218f 100644 --- a/mission/tmtc/PersistentTmStore.cpp +++ b/mission/tmtc/PersistentTmStore.cpp @@ -92,10 +92,18 @@ ReturnValue_t PersistentTmStore::storePacket(PusTmReader& reader) { bool createNewFile = false; std::optional suffix = std::nullopt; + std::error_code e; + size_t fileSize = file_size(activeFile.value(), e); + if (e) { + sif::error << "PersistentTmStore: Could not retrieve file size, " + "error " + << e.message() << std::endl; + return returnvalue::FAILED; + } if (currentTv.tv_sec > activeFileTv.tv_sec + static_cast(rolloverDiffSeconds)) { createNewFile = true; currentSameSecNumber = 0; - } else if (file_size(activeFile.value()) + reader.getFullPacketLen() > fileBuf.size()) { + } else if (fileSize + reader.getFullPacketLen() > fileBuf.size()) { createNewFile = true; if (currentSameSecNumber >= MAX_FILES_IN_ONE_SECOND) { currentSameSecNumber = 0; @@ -158,7 +166,8 @@ void PersistentTmStore::deleteUpTo(uint32_t unixSeconds) { } time_t fileEpoch = timegm(&fileTime); if (fileEpoch + rolloverDiffSeconds < unixSeconds) { - std::filesystem::remove(file.path()); + std::error_code e; + std::filesystem::remove(file.path(), e); } } } @@ -184,10 +193,15 @@ ReturnValue_t PersistentTmStore::loadNextDumpFile() { using namespace std::filesystem; std::error_code e; for (; dumpParams.dirIter != directory_iterator(); dumpParams.dirIter++) { + dumpParams.dirEntry = *dumpParams.dirIter; if (dumpParams.dirEntry.is_directory(e)) { continue; } - dumpParams.fileSize = std::filesystem::file_size(dumpParams.dirEntry.path()); + dumpParams.fileSize = std::filesystem::file_size(dumpParams.dirEntry.path(), e); + if (e) { + sif::error << "PersistentTmStore: Could not retrieve file size: " << e.message() << std::endl; + continue; + } // Can't even read CCSDS header. if (dumpParams.fileSize <= 6) { continue; @@ -195,7 +209,7 @@ ReturnValue_t PersistentTmStore::loadNextDumpFile() { if (dumpParams.fileSize > fileBuf.size()) { sif::error << "PersistentTmStore: File too large, is deleted" << std::endl; triggerEvent(FILE_TOO_LARGE, dumpParams.fileSize, fileBuf.size()); - std::remove(dumpParams.dirEntry.path().c_str()); + std::filesystem::remove(dumpParams.dirEntry.path(), e); continue; } const path& file = dumpParams.dirEntry.path(); @@ -249,7 +263,8 @@ ReturnValue_t PersistentTmStore::dumpNextPacket(DirectTmSinkIF& tmSink, size_t& // Delete the file and load next. Could use better algorithm to partially // restore the file dump, but for now do not trust the file. dumpedLen = 0; - std::remove(dumpParams.dirEntry.path().c_str()); + std::error_code e; + std::filesystem::remove(dumpParams.dirEntry.path().c_str(), e); fileHasSwapped = true; return loadNextDumpFile(); }