diff --git a/mission/persistentTmStoreDefs.h b/mission/persistentTmStoreDefs.h index 01fe6781..2498536d 100644 --- a/mission/persistentTmStoreDefs.h +++ b/mission/persistentTmStoreDefs.h @@ -28,15 +28,15 @@ static constexpr Event BUSY_DUMPING_EVENT = event::makeEvent(SUBSYSTEM_ID, 2, se //! [EXPORT] : [COMMENT] Dump was cancelled. P1: Object ID of store. static constexpr Event DUMP_WAS_CANCELLED = event::makeEvent(SUBSYSTEM_ID, 3, severity::LOW); -//! [EXPORT] : [COMMENT] P1: Number of dumped packets. +//! [EXPORT] : [COMMENT] P1: Number of dumped packets. P2: Total dumped bytes. static constexpr Event DUMP_OK_STORE_DONE = event::makeEvent(SUBSYSTEM_ID, 5, severity::INFO); -//! [EXPORT] : [COMMENT] P1: Number of dumped packets. +//! [EXPORT] : [COMMENT] P1: Number of dumped packets. P2: Total dumped bytes. static constexpr Event DUMP_NOK_STORE_DONE = event::makeEvent(SUBSYSTEM_ID, 6, severity::INFO); -//! [EXPORT] : [COMMENT] P1: Number of dumped packets. +//! [EXPORT] : [COMMENT] P1: Number of dumped packets. P2: Total dumped bytes. static constexpr Event DUMP_MISC_STORE_DONE = event::makeEvent(SUBSYSTEM_ID, 7, severity::INFO); -//! [EXPORT] : [COMMENT] P1: Number of dumped packets. +//! [EXPORT] : [COMMENT] P1: Number of dumped packets. P2: Total dumped bytes. static constexpr Event DUMP_HK_STORE_DONE = event::makeEvent(SUBSYSTEM_ID, 8, severity::INFO); -//! [EXPORT] : [COMMENT] P1: Number of dumped packets. +//! [EXPORT] : [COMMENT] P1: Number of dumped packets. P2: Total dumped bytes. static constexpr Event DUMP_CFDP_STORE_DONE = event::makeEvent(SUBSYSTEM_ID, 9, severity::INFO); }; // namespace persTmStore diff --git a/mission/tmtc/PersistentLogTmStoreTask.cpp b/mission/tmtc/PersistentLogTmStoreTask.cpp index 3d0d99ee..aac51c55 100644 --- a/mission/tmtc/PersistentLogTmStoreTask.cpp +++ b/mission/tmtc/PersistentLogTmStoreTask.cpp @@ -6,7 +6,10 @@ PersistentLogTmStoreTask::PersistentLogTmStoreTask(object_id_t objectId, StorageManagerIF& ipcStore, LogStores stores, VirtualChannel& channel, SdCardMountedIF& sdcMan) - : TmStoreTaskBase(objectId, ipcStore, channel, sdcMan), stores(stores) {} + : TmStoreTaskBase(objectId, ipcStore, channel, sdcMan), stores(stores), + okStoreContext(persTmStore::DUMP_OK_STORE_DONE), + notOkStoreContext(persTmStore::DUMP_NOK_STORE_DONE), + miscStoreContext(persTmStore::DUMP_MISC_STORE_DONE) {} ReturnValue_t PersistentLogTmStoreTask::performOperation(uint8_t opCode) { while (true) { @@ -15,15 +18,15 @@ ReturnValue_t PersistentLogTmStoreTask::performOperation(uint8_t opCode) { } bool someonesBusy = false; bool busy = false; - busy = handleOneStore(stores.okStore, persTmStore::DUMP_OK_STORE_DONE); + busy = handleOneStore(stores.okStore, okStoreContext); if (busy) { someonesBusy = true; } - busy = handleOneStore(stores.notOkStore, persTmStore::DUMP_NOK_STORE_DONE); + busy = handleOneStore(stores.notOkStore, notOkStoreContext); if (busy) { someonesBusy = true; } - busy = handleOneStore(stores.miscStore, persTmStore::DUMP_MISC_STORE_DONE); + busy = handleOneStore(stores.miscStore, miscStoreContext); if (busy) { someonesBusy = true; } diff --git a/mission/tmtc/PersistentLogTmStoreTask.h b/mission/tmtc/PersistentLogTmStoreTask.h index fc4242db..8cd74f20 100644 --- a/mission/tmtc/PersistentLogTmStoreTask.h +++ b/mission/tmtc/PersistentLogTmStoreTask.h @@ -28,6 +28,9 @@ class PersistentLogTmStoreTask : public TmStoreTaskBase, public ExecutableObject private: LogStores stores; + DumpContext okStoreContext; + DumpContext notOkStoreContext; + DumpContext miscStoreContext; Countdown tcHandlingCd = Countdown(400); bool initStoresIfPossible(); diff --git a/mission/tmtc/PersistentSingleTmStoreTask.cpp b/mission/tmtc/PersistentSingleTmStoreTask.cpp index e3e1688e..3588b9fd 100644 --- a/mission/tmtc/PersistentSingleTmStoreTask.cpp +++ b/mission/tmtc/PersistentSingleTmStoreTask.cpp @@ -7,7 +7,7 @@ PersistentSingleTmStoreTask::PersistentSingleTmStoreTask( VirtualChannel& channel, Event eventIfDumpDone, SdCardMountedIF& sdcMan) : TmStoreTaskBase(objectId, ipcStore, channel, sdcMan), storeWithQueue(tmStore), - eventIfDumpDone(eventIfDumpDone) {} + dumpContext(eventIfDumpDone) {} ReturnValue_t PersistentSingleTmStoreTask::performOperation(uint8_t opCode) { while (true) { @@ -15,7 +15,7 @@ ReturnValue_t PersistentSingleTmStoreTask::performOperation(uint8_t opCode) { if (not cyclicStoreCheck()) { continue; } - bool busy = handleOneStore(storeWithQueue, eventIfDumpDone); + bool busy = handleOneStore(storeWithQueue, dumpContext); if (not busy) { TaskFactory::delayTask(40); } diff --git a/mission/tmtc/PersistentSingleTmStoreTask.h b/mission/tmtc/PersistentSingleTmStoreTask.h index 08ec8b17..b21ddf1d 100644 --- a/mission/tmtc/PersistentSingleTmStoreTask.h +++ b/mission/tmtc/PersistentSingleTmStoreTask.h @@ -17,8 +17,7 @@ class PersistentSingleTmStoreTask : public TmStoreTaskBase, public ExecutableObj private: PersistentTmStoreWithTmQueue& storeWithQueue; - Event eventIfDumpDone; - uint32_t numberOfDumpedPackets = 0; + DumpContext dumpContext; Countdown tcHandlingCd = Countdown(400); bool initStoresIfPossible(); diff --git a/mission/tmtc/TmStoreTaskBase.cpp b/mission/tmtc/TmStoreTaskBase.cpp index 5c0402fe..d8b6bdcb 100644 --- a/mission/tmtc/TmStoreTaskBase.cpp +++ b/mission/tmtc/TmStoreTaskBase.cpp @@ -11,8 +11,8 @@ TmStoreTaskBase::TmStoreTaskBase(object_id_t objectId, StorageManagerIF& ipcStor VirtualChannel& channel, SdCardMountedIF& sdcMan) : SystemObject(objectId), ipcStore(ipcStore), channel(channel), sdcMan(sdcMan) {} -bool TmStoreTaskBase::handleOneStore(PersistentTmStoreWithTmQueue& store, Event eventIfDone, - uint32_t& numberOfDumpedPackets) { +bool TmStoreTaskBase::handleOneStore(PersistentTmStoreWithTmQueue& store, + DumpContext& dumpContext) { ReturnValue_t result; bool tmToStoreReceived = false; bool tcRequestReceived = false; @@ -24,17 +24,21 @@ bool TmStoreTaskBase::handleOneStore(PersistentTmStoreWithTmQueue& store, Event } // Dump TMs when applicable if (store.getState() == PersistentTmStore::State::DUMPING) { - size_t dumpedLen; + size_t dumpedLen = 0; bool fileHasSwapped; if (not channel.isBusy()) { tmSinkBusyCd.resetTimer(); - // TODO: We could continously dump until a file swap during active downlink.. result = store.dumpNextPacket(channel, dumpedLen, fileHasSwapped); + if ((result == PersistentTmStore::DUMP_DONE or result == returnvalue::OK) and dumpedLen > 0) { + dumpContext.dumpedBytes += dumpedLen; + dumpContext.numberOfDumpedPackets += 1; + } if (result == PersistentTmStore::DUMP_DONE) { uint32_t startTime; uint32_t endTime; store.getStartAndEndTimeCurrentOrLastDump(startTime, endTime); - triggerEvent(eventIfDone, numberOfDumpedPackets); + triggerEvent(dumpContext.eventIfDone, dumpContext.numberOfDumpedPackets, + dumpContext.dumpedBytes); dumpsPerformed = true; } else if (result == returnvalue::OK) { dumpsPerformed = true; @@ -52,6 +56,7 @@ bool TmStoreTaskBase::handleOneStore(PersistentTmStoreWithTmQueue& store, Event if (execCmd == TmStoreMessage::DOWNLINK_STORE_CONTENT_TIME) { cancelDumpCd.resetTimer(); tmSinkBusyCd.resetTimer(); + dumpContext.reset(); } tcRequestReceived = true; } diff --git a/mission/tmtc/TmStoreTaskBase.h b/mission/tmtc/TmStoreTaskBase.h index c29db8bf..2d899be3 100644 --- a/mission/tmtc/TmStoreTaskBase.h +++ b/mission/tmtc/TmStoreTaskBase.h @@ -7,6 +7,17 @@ class TmStoreTaskBase : public SystemObject { public: + struct DumpContext { + DumpContext(Event eventIfDone) : eventIfDone(eventIfDone) {} + void reset() { + numberOfDumpedPackets = 0; + dumpedBytes = 0; + } + const Event eventIfDone; + uint32_t numberOfDumpedPackets = 0; + uint32_t dumpedBytes = 0; + }; + TmStoreTaskBase(object_id_t objectId, StorageManagerIF& ipcStore, VirtualChannel& channel, SdCardMountedIF& sdcMan); @@ -16,7 +27,7 @@ class TmStoreTaskBase : public SystemObject { * @param store * @return */ - bool handleOneStore(PersistentTmStoreWithTmQueue& store, Event eventIfDone); + bool handleOneStore(PersistentTmStoreWithTmQueue& store, DumpContext& dumpContext); /** * Occasionally check whether SD card is okay to be used. If not, poll whether it is ready to diff --git a/tmtc b/tmtc index cd0fd4d5..4686550e 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit cd0fd4d5a7142554c95d90574b5539931adcd5ff +Subproject commit 4686550eb9455175227559dc36902469255e36b7