Refactor TM handling #450

Merged
muellerr merged 47 commits from refactor_tm_handling into develop 2023-03-11 15:05:22 +01:00
Showing only changes of commit 5ea2767662 - Show all commits

View File

@ -65,7 +65,7 @@ ReturnValue_t PersistentTmStore::handleCommandQueue(StorageManagerIF& ipcStore)
SerializeAdapter::deSerialize(&dumpUntilUnixSeconds, accessor.second.data() + 4, &size, SerializeAdapter::deSerialize(&dumpUntilUnixSeconds, accessor.second.data() + 4, &size,
SerializeIF::Endianness::NETWORK); SerializeIF::Endianness::NETWORK);
result = startDumpFromUpTo(dumpFromUnixSeconds, dumpUntilUnixSeconds); result = startDumpFromUpTo(dumpFromUnixSeconds, dumpUntilUnixSeconds);
if (result != returnvalue::OK and result == BUSY_DUMPING) { if (result == BUSY_DUMPING) {
triggerEvent(persTmStore::BUSY_DUMPING_EVENT); triggerEvent(persTmStore::BUSY_DUMPING_EVENT);
} }
} }
@ -197,14 +197,11 @@ ReturnValue_t PersistentTmStore::loadNextDumpFile() {
using namespace std::filesystem; using namespace std::filesystem;
dumpParams.currentSize = 0; dumpParams.currentSize = 0;
std::error_code e; std::error_code e;
dumpParams.dirIter++;
for (; dumpParams.dirIter != directory_iterator(); dumpParams.dirIter++) { for (; dumpParams.dirIter != directory_iterator(); dumpParams.dirIter++) {
dumpParams.dirEntry = *dumpParams.dirIter; dumpParams.dirEntry = *dumpParams.dirIter;
if (dumpParams.dirEntry.is_directory(e)) { if (dumpParams.dirEntry.is_directory(e)) {
continue; continue;
} }
sif::debug << "handling file " << dumpParams.dirEntry << std::endl;
dumpParams.fileSize = std::filesystem::file_size(dumpParams.dirEntry.path(), e); dumpParams.fileSize = std::filesystem::file_size(dumpParams.dirEntry.path(), e);
if (e) { if (e) {
sif::error << "PersistentTmStore: Could not retrieve file size: " << e.message() << std::endl; sif::error << "PersistentTmStore: Could not retrieve file size: " << e.message() << std::endl;
@ -237,6 +234,8 @@ ReturnValue_t PersistentTmStore::loadNextDumpFile() {
} }
ifile.read(reinterpret_cast<char*>(fileBuf.data()), ifile.read(reinterpret_cast<char*>(fileBuf.data()),
static_cast<std::streamsize>(dumpParams.fileSize)); static_cast<std::streamsize>(dumpParams.fileSize));
// Increment iterator for next cycle.
dumpParams.dirIter++;
break; break;
} }
} }
@ -252,7 +251,6 @@ ReturnValue_t PersistentTmStore::dumpNextPacket(DirectTmSinkIF& tmSink, size_t&
if (state == State::IDLE) { if (state == State::IDLE) {
return returnvalue::FAILED; return returnvalue::FAILED;
} }
sif::debug << "Current file idx: " << dumpParams.currentSize << std::endl;
PusTmReader reader(&timeReader, fileBuf.data() + dumpParams.currentSize, PusTmReader reader(&timeReader, fileBuf.data() + dumpParams.currentSize,
fileBuf.size() - dumpParams.currentSize); fileBuf.size() - dumpParams.currentSize);
// CRC check to fully ensure this is a valid TM // CRC check to fully ensure this is a valid TM