Refactor TM handling #450

Merged
muellerr merged 47 commits from refactor_tm_handling into develop 2023-03-11 15:05:22 +01:00
3 changed files with 7 additions and 3 deletions
Showing only changes of commit 2374dea493 - Show all commits

View File

@ -222,7 +222,7 @@ ReturnValue_t PersistentTmStore::loadNextDumpFile() {
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t PersistentTmStore::dumpNextPacket(DirectTmSinkIF& tmSink, size_t& dumpedLen) { ReturnValue_t PersistentTmStore::dumpNextPacket(DirectTmSinkIF& tmSink, size_t& dumpedLen, bool& fileHasSwapped) {
if (state == State::IDLE) { if (state == State::IDLE) {
return returnvalue::FAILED; return returnvalue::FAILED;
} }
@ -239,6 +239,7 @@ ReturnValue_t PersistentTmStore::dumpNextPacket(DirectTmSinkIF& tmSink, size_t&
dumpParams.currentSize += reader.getFullPacketLen(); dumpParams.currentSize += reader.getFullPacketLen();
dumpedLen = reader.getFullPacketLen(); dumpedLen = reader.getFullPacketLen();
if (dumpParams.currentSize >= dumpParams.fileSize) { if (dumpParams.currentSize >= dumpParams.fileSize) {
fileHasSwapped = true;
return loadNextDumpFile(); return loadNextDumpFile();
} }
} else { } else {
@ -248,6 +249,7 @@ ReturnValue_t PersistentTmStore::dumpNextPacket(DirectTmSinkIF& tmSink, size_t&
// restore the file dump, but for now do not trust the file. // restore the file dump, but for now do not trust the file.
dumpedLen = 0; dumpedLen = 0;
std::remove(dumpParams.dirEntry.path().c_str()); std::remove(dumpParams.dirEntry.path().c_str());
fileHasSwapped = true;
return loadNextDumpFile(); return loadNextDumpFile();
} }
return returnvalue::OK; return returnvalue::OK;

View File

@ -66,7 +66,7 @@ class PersistentTmStore : public TmStoreFrontendSimpleIF, public SystemObject {
void deleteUpTo(uint32_t unixSeconds); void deleteUpTo(uint32_t unixSeconds);
ReturnValue_t startDumpFrom(uint32_t fromUnixSeconds); ReturnValue_t startDumpFrom(uint32_t fromUnixSeconds);
ReturnValue_t startDumpFromUpTo(uint32_t fromUnixSeconds, uint32_t upToUnixSeconds); ReturnValue_t startDumpFromUpTo(uint32_t fromUnixSeconds, uint32_t upToUnixSeconds);
ReturnValue_t dumpNextPacket(DirectTmSinkIF& tmSink, size_t& dumpedLen); ReturnValue_t dumpNextPacket(DirectTmSinkIF& tmSink, size_t& dumpedLen, bool& fileHasSwapped);
ReturnValue_t storePacket(PusTmReader& reader); ReturnValue_t storePacket(PusTmReader& reader);

View File

@ -23,9 +23,11 @@ bool TmStoreTaskBase::handleOneStore(PersistentTmStoreWithTmQueue& store) {
// Dump TMs when applicable // Dump TMs when applicable
if (store.getState() == PersistentTmStore::State::DUMPING) { if (store.getState() == PersistentTmStore::State::DUMPING) {
size_t dumpedLen; size_t dumpedLen;
bool fileHasSwapped;
// TODO: Maybe do a bit of a delay every 100-200 packets? // TODO: Maybe do a bit of a delay every 100-200 packets?
// TODO: We could continously dump until a file swap during active downlink..
// TODO: handle returnvalue? // TODO: handle returnvalue?
result = store.dumpNextPacket(channel, dumpedLen); result = store.dumpNextPacket(channel, dumpedLen, fileHasSwapped);
if (result == returnvalue::OK) { if (result == returnvalue::OK) {
dumpsPerformed = true; dumpsPerformed = true;
} }