diff --git a/mission/tmtc/PersistentLogTmStoreTask.cpp b/mission/tmtc/PersistentLogTmStoreTask.cpp index 2b7e1333..906c7547 100644 --- a/mission/tmtc/PersistentLogTmStoreTask.cpp +++ b/mission/tmtc/PersistentLogTmStoreTask.cpp @@ -14,13 +14,22 @@ PersistentLogTmStoreTask::PersistentLogTmStoreTask(object_id_t objectId, Storage ReturnValue_t PersistentLogTmStoreTask::performOperation(uint8_t opCode) { bool someonesBusy = false; - auto stateHandlingForStore = [&](bool storeIsBusy) { + bool vcBusyDuringDump = false; + bool byteFlowControl = false; + auto stateHandlingForStore = [&](bool storeIsBusy, DumpContext& ctx) { if (storeIsBusy) { someonesBusy = true; } if (fileHasSwapped) { someFileWasSwapped = fileHasSwapped; } + if(ctx.vcBusyDuringDump) { + vcBusyDuringDump = true; + } + if(ctx.dumpedBytes - ctx.bytesDumpedAtLastDelay >= 2048) { + byteFlowControl = true; + ctx.bytesDumpedAtLastDelay = ctx.dumpedBytes; + } }; while (true) { if (not cyclicStoreCheck()) { @@ -28,13 +37,21 @@ ReturnValue_t PersistentLogTmStoreTask::performOperation(uint8_t opCode) { } someonesBusy = false; someFileWasSwapped = false; - stateHandlingForStore(handleOneStore(stores.okStore, okStoreContext)); - stateHandlingForStore(handleOneStore(stores.notOkStore, notOkStoreContext)); - stateHandlingForStore(handleOneStore(stores.miscStore, miscStoreContext)); + vcBusyDuringDump = false; + stateHandlingForStore(handleOneStore(stores.okStore, okStoreContext), okStoreContext); + stateHandlingForStore(handleOneStore(stores.notOkStore, notOkStoreContext), notOkStoreContext); + stateHandlingForStore(handleOneStore(stores.miscStore, miscStoreContext), miscStoreContext); if (not someonesBusy) { TaskFactory::delayTask(100); } else if (someFileWasSwapped) { - TaskFactory::delayTask(2); + TaskFactory::delayTask(20); + } else if(vcBusyDuringDump) { + TaskFactory::delayTask(20); + } else if(byteFlowControl) { + TaskFactory::delayTask(10); + } else { + // TODO: Lower this as much as possible... + TaskFactory::delayTask(10); } } } diff --git a/mission/tmtc/PersistentSingleTmStoreTask.cpp b/mission/tmtc/PersistentSingleTmStoreTask.cpp index 2584d975..ae6b8700 100644 --- a/mission/tmtc/PersistentSingleTmStoreTask.cpp +++ b/mission/tmtc/PersistentSingleTmStoreTask.cpp @@ -24,17 +24,13 @@ ReturnValue_t PersistentSingleTmStoreTask::performOperation(uint8_t opCode) { } else if (fileHasSwapped) { TaskFactory::delayTask(20); } else if (dumpContext.packetWasDumped and - dumpContext.numberOfDumpedPackets - dumpContext.bytesDumpedAtLastDelay >= 2048) { + dumpContext.dumpedBytes - dumpContext.bytesDumpedAtLastDelay >= 2048) { dumpContext.bytesDumpedAtLastDelay = dumpContext.dumpedBytes; TaskFactory::delayTask(20); } else { - TaskFactory::delayTask(10); + // TODO: Lower this as much as possible... + TaskFactory::delayTask(5); } - // else if(dumpContext.numberOfDumpedPackets % 20 == 0) { - // Manual load management because I don't know what the scheduler is doing.. - // Removing this delay can lead to evil side effects. - // TaskFactory::delayTask(5); - //} } }