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;