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);