this logic should work
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
Robin Müller 2022-12-12 18:17:59 +01:00
parent a9699ad969
commit 293082a7e8
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
2 changed files with 19 additions and 10 deletions

View File

@ -61,8 +61,6 @@ ReturnValue_t TmStore::storePacket(PusTmReader& reader) {
create_directory(baseDir);
}
if (not mostRecentFile) {
// TODO: Find most recent file by iterating through all files and remembering the file
// with the most recent timestamp.
for (auto const& file : directory_iterator(baseDir)) {
if (file.is_directory()) {
continue;
@ -72,13 +70,21 @@ ReturnValue_t TmStore::storePacket(PusTmReader& reader) {
if (pathStr.find(baseName) == std::string::npos) {
continue;
}
float seconds = 0.0;
char* prefix = nullptr;
int count = sscanf(pathStr.c_str(),
"%s_%4" SCNu32 "-%2" SCNu32 "-%2" SCNu32 "T%2" SCNu32 ":%2" SCNu32 ":%fZ",
prefix, &tod.year, &tod.month, &tod.day, &tod.hour, &tod.minute, &seconds);
tod.second = std::floor(seconds);
static_cast<void>(count);
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);
if (count != 6) {
continue;
}
timeval tv{};
Clock::convertTimeOfDayToTimeval(&tod, &tv);
if (not mostRecentTv || tv > mostRecentTv.value()) {
mostRecentTv = tv;
mostRecentFile = file.path();
}
}
}
// TODO: Need to find the file of the most recent file.

View File

@ -7,6 +7,8 @@
#include <fsfw/tmtcservices/AcceptsTelemetryIF.h>
#include <mission/memory/SdCardMountedIF.h>
#include <filesystem>
struct PacketFilter {
std::optional<std::vector<uint16_t>> apid;
std::optional<std::vector<uint8_t>> services;
@ -37,7 +39,8 @@ class TmStore : public SystemObject {
uint8_t intervalFactor;
char NAME_BUF[524] = {};
std::array<uint8_t, 8192> fileBuf{};
std::optional<std::string> mostRecentFile;
std::optional<timeval> mostRecentTv;
std::optional<std::filesystem::path> mostRecentFile;
SdCardMountedIF& sdcMan;
};