diff --git a/bsp_q7s/core/scheduling.cpp b/bsp_q7s/core/scheduling.cpp index f6727420..782a2666 100644 --- a/bsp_q7s/core/scheduling.cpp +++ b/bsp_q7s/core/scheduling.cpp @@ -186,19 +186,19 @@ void scheduling::initTasks() { scheduling::printAddObjectError("LIVE_TM", objects::LIVE_TM_TASK); } PeriodicTaskIF* logTmTask = factory->createPeriodicTask( - "LOG_STORE_AND_TM", 45, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, nullptr); + "LOG_STORE_AND_TM", 15, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, nullptr); result = logTmTask->addComponent(objects::LOG_STORE_AND_TM_TASK); if (result != returnvalue::OK) { scheduling::printAddObjectError("LOG_STORE_AND_TM", objects::LOG_STORE_AND_TM_TASK); } PeriodicTaskIF* hkTmTask = factory->createPeriodicTask( - "HK_STORE_AND_TM", 45, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, nullptr); + "HK_STORE_AND_TM", 15, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, nullptr); result = hkTmTask->addComponent(objects::HK_STORE_AND_TM_TASK); if (result != returnvalue::OK) { scheduling::printAddObjectError("HK_STORE_AND_TM", objects::HK_STORE_AND_TM_TASK); } PeriodicTaskIF* cfdpTmTask = factory->createPeriodicTask( - "CFDP_STORE_AND_TM", 45, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, nullptr); + "CFDP_STORE_AND_TM", 15, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, nullptr); result = cfdpTmTask->addComponent(objects::CFDP_STORE_AND_TM_TASK); if (result != returnvalue::OK) { scheduling::printAddObjectError("CFDP_STORE_AND_TM", objects::CFDP_STORE_AND_TM_TASK); @@ -326,7 +326,7 @@ void scheduling::initTasks() { #if OBSW_ADD_PLOC_SUPERVISOR == 1 PeriodicTaskIF* supvHelperTask = factory->createPeriodicTask( - "PLOC_SUPV_HELPER", 10, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, missedDeadlineFunc); + "PLOC_SUPV_HELPER", 20, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, missedDeadlineFunc); result = supvHelperTask->addComponent(objects::PLOC_SUPERVISOR_HELPER); if (result != returnvalue::OK) { scheduling::printAddObjectError("PLOC_SUPV_HELPER", objects::PLOC_SUPERVISOR_HELPER); diff --git a/mission/tmtc/PersistentLogTmStoreTask.cpp b/mission/tmtc/PersistentLogTmStoreTask.cpp index dc17ec58..41d90875 100644 --- a/mission/tmtc/PersistentLogTmStoreTask.cpp +++ b/mission/tmtc/PersistentLogTmStoreTask.cpp @@ -13,26 +13,29 @@ PersistentLogTmStoreTask::PersistentLogTmStoreTask(object_id_t objectId, Storage miscStoreContext(persTmStore::DUMP_MISC_STORE_DONE) {} ReturnValue_t PersistentLogTmStoreTask::performOperation(uint8_t opCode) { + bool someonesBusy = false; + auto stateHandlingForStore = [&](bool storeIsBusy) { + if (storeIsBusy) { + someonesBusy = true; + } + if (fileHasSwapped) { + someFileWasSwapped = fileHasSwapped; + } + }; while (true) { if (not cyclicStoreCheck()) { continue; } - bool someonesBusy = false; - bool busy = false; - busy = handleOneStore(stores.okStore, okStoreContext); - if (busy) { - someonesBusy = true; - } - busy = handleOneStore(stores.notOkStore, notOkStoreContext); - if (busy) { - someonesBusy = true; - } - busy = handleOneStore(stores.miscStore, miscStoreContext); - if (busy) { - someonesBusy = true; - } + someFileWasSwapped = false; + bool busy = handleOneStore(stores.okStore, okStoreContext); + stateHandlingForStore(busy); + stateHandlingForStore(handleOneStore(stores.notOkStore, notOkStoreContext)); + stateHandlingForStore(handleOneStore(stores.miscStore, miscStoreContext)); if (not someonesBusy) { TaskFactory::delayTask(40); + } else if (someFileWasSwapped and graceDelayDuringDumping.hasTimedOut()) { + TaskFactory::delayTask(2); + graceDelayDuringDumping.resetTimer(); } } } diff --git a/mission/tmtc/PersistentLogTmStoreTask.h b/mission/tmtc/PersistentLogTmStoreTask.h index 8cd74f20..99cb9118 100644 --- a/mission/tmtc/PersistentLogTmStoreTask.h +++ b/mission/tmtc/PersistentLogTmStoreTask.h @@ -32,6 +32,8 @@ class PersistentLogTmStoreTask : public TmStoreTaskBase, public ExecutableObject DumpContext notOkStoreContext; DumpContext miscStoreContext; Countdown tcHandlingCd = Countdown(400); + Countdown graceDelayDuringDumping = Countdown(200); + bool someFileWasSwapped = false; bool initStoresIfPossible(); }; diff --git a/mission/tmtc/PersistentSingleTmStoreTask.cpp b/mission/tmtc/PersistentSingleTmStoreTask.cpp index 3588b9fd..af394672 100644 --- a/mission/tmtc/PersistentSingleTmStoreTask.cpp +++ b/mission/tmtc/PersistentSingleTmStoreTask.cpp @@ -18,6 +18,11 @@ ReturnValue_t PersistentSingleTmStoreTask::performOperation(uint8_t opCode) { bool busy = handleOneStore(storeWithQueue, dumpContext); if (not busy) { TaskFactory::delayTask(40); + } else { + if (fileHasSwapped and graceDelayDuringDumping.hasTimedOut()) { + TaskFactory::delayTask(2); + graceDelayDuringDumping.resetTimer(); + } } } } diff --git a/mission/tmtc/PersistentSingleTmStoreTask.h b/mission/tmtc/PersistentSingleTmStoreTask.h index b21ddf1d..7a4dd7ca 100644 --- a/mission/tmtc/PersistentSingleTmStoreTask.h +++ b/mission/tmtc/PersistentSingleTmStoreTask.h @@ -19,6 +19,7 @@ class PersistentSingleTmStoreTask : public TmStoreTaskBase, public ExecutableObj PersistentTmStoreWithTmQueue& storeWithQueue; DumpContext dumpContext; Countdown tcHandlingCd = Countdown(400); + Countdown graceDelayDuringDumping = Countdown(100); bool initStoresIfPossible(); }; diff --git a/mission/tmtc/TmStoreTaskBase.cpp b/mission/tmtc/TmStoreTaskBase.cpp index 8328c65e..50ec63e4 100644 --- a/mission/tmtc/TmStoreTaskBase.cpp +++ b/mission/tmtc/TmStoreTaskBase.cpp @@ -25,7 +25,6 @@ bool TmStoreTaskBase::handleOneStore(PersistentTmStoreWithTmQueue& store, // Dump TMs when applicable if (store.getState() == PersistentTmStore::State::DUMPING) { size_t dumpedLen = 0; - bool fileHasSwapped; // if (not channel.isBusy()) { tmSinkBusyCd.resetTimer(); result = store.dumpNextPacket(channel, dumpedLen, fileHasSwapped); diff --git a/mission/tmtc/TmStoreTaskBase.h b/mission/tmtc/TmStoreTaskBase.h index 2d899be3..1f0834d6 100644 --- a/mission/tmtc/TmStoreTaskBase.h +++ b/mission/tmtc/TmStoreTaskBase.h @@ -45,6 +45,7 @@ class TmStoreTaskBase : public SystemObject { Countdown tmSinkBusyCd = Countdown(60 * 1000); VirtualChannel& channel; bool storesInitialized = false; + bool fileHasSwapped = false; SdCardMountedIF& sdcMan; };