Persistent TM Store #320

Merged
muellerr merged 109 commits from mueller/pus-15-tm-storage into develop 2023-02-24 19:03:39 +01:00
3 changed files with 26 additions and 7 deletions
Showing only changes of commit 279697b326 - Show all commits

View File

@ -3,8 +3,8 @@
#include <mission/memory/SdCardMountedIF.h> #include <mission/memory/SdCardMountedIF.h>
#include <algorithm> #include <algorithm>
#include <filesystem>
#include <cinttypes> #include <cinttypes>
#include <filesystem>
using namespace returnvalue; using namespace returnvalue;
@ -55,7 +55,7 @@ ReturnValue_t TmStore::passPacket(PusTmReader& reader) {
ReturnValue_t TmStore::storePacket(PusTmReader& reader) { ReturnValue_t TmStore::storePacket(PusTmReader& reader) {
using namespace std::filesystem; using namespace std::filesystem;
std::string currentPrefix = sdcMan.getCurrentMountPrefix(); std::string currentPrefix = sdcMan.getCurrentMountPrefix();
path baseDir = currentPrefix / baseName; path baseDir = path(currentPrefix) / baseName;
// It is assumed here that the filesystem is usable. // It is assumed here that the filesystem is usable.
if (not exists(baseDir)) { if (not exists(baseDir)) {
create_directory(baseDir); create_directory(baseDir);
@ -74,9 +74,9 @@ ReturnValue_t TmStore::storePacket(PusTmReader& reader) {
} }
float seconds = 0.0; float seconds = 0.0;
char* prefix = nullptr; char* prefix = nullptr;
int count = sscanf(pathStr.c_str(), "%s_%4" SCNu32 "-%2" SCNu32 "-%2" int count = sscanf(pathStr.c_str(),
SCNu32 "T%2" SCNu32 ":%2" SCNu32 ":%fZ", prefix, &tod.year, &tod.month, &tod.day, "%s_%4" SCNu32 "-%2" SCNu32 "-%2" SCNu32 "T%2" SCNu32 ":%2" SCNu32 ":%fZ",
&tod.hour, &tod.minute, &seconds); prefix, &tod.year, &tod.month, &tod.day, &tod.hour, &tod.minute, &seconds);
tod.second = std::floor(seconds); tod.second = std::floor(seconds);
static_cast<void>(count); static_cast<void>(count);
} }

View File

@ -4,5 +4,6 @@ add_subdirectory(mocks)
target_sources(${UNITTEST_NAME} PRIVATE target_sources(${UNITTEST_NAME} PRIVATE
main.cpp main.cpp
testEnvironment.cpp testEnvironment.cpp
testStampInFilename.cpp
printChar.cpp printChar.cpp
) )

View File

@ -0,0 +1,18 @@
#include <catch2/catch_test_macros.hpp>
#include <cinttypes>
#include "fsfw/timemanager/Clock.h"
TEST_CASE("Stamp in Filename", "[Stamp In Filename]") {
Clock::TimeOfDay_t tod;
std::string baseName = "verif";
std::string pathStr = "verif_2022-05-25T16:55:23Z.bin";
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 ":%2" SCNu32 "Z",
prefix, &tod.year, &tod.month, &tod.day, &tod.hour, &tod.minute, &tod.second);
static_cast<void>(count);
}