From c53c052876eade22eda09ff92dab7b9e96ccabae Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 27 Mar 2023 17:02:02 +0200 Subject: [PATCH] lower delays --- linux/ipcore/PapbVcInterface.cpp | 17 ++++++++++------- linux/ipcore/PapbVcInterface.h | 4 +++- mission/tmtc/PersistentLogTmStoreTask.cpp | 8 ++------ mission/tmtc/PersistentSingleTmStoreTask.cpp | 10 ++-------- mission/tmtc/PersistentTmStore.cpp | 2 +- tmtc | 2 +- 6 files changed, 19 insertions(+), 24 deletions(-) diff --git a/linux/ipcore/PapbVcInterface.cpp b/linux/ipcore/PapbVcInterface.cpp index 8c98df90..57dcb963 100644 --- a/linux/ipcore/PapbVcInterface.cpp +++ b/linux/ipcore/PapbVcInterface.cpp @@ -26,20 +26,20 @@ ReturnValue_t PapbVcInterface::initialize() { } ReturnValue_t PapbVcInterface::write(const uint8_t* data, size_t size) { - if (pollPapbBusySignal(0, 0) == returnvalue::OK) { + if (pollPapbBusySignal(0) == returnvalue::OK) { startPacketTransfer(); } else { return DirectTmSinkIF::IS_BUSY; } for (size_t idx = 0; idx < size; idx++) { - if (pollPapbBusySignal(10, 10) == returnvalue::OK) { + if (pollPapbBusySignal(5) == returnvalue::OK) { *(vcBaseReg + DATA_REG_OFFSET) = static_cast(data[idx]); } else { abortPacketTransfer(); return returnvalue::FAILED; } } - if (pollPapbBusySignal(10, 10) == returnvalue::OK) { + if (pollPapbBusySignal(5) == returnvalue::OK) { completePacketTransfer(); } else { abortPacketTransfer(); @@ -52,11 +52,11 @@ void PapbVcInterface::startPacketTransfer() { *vcBaseReg = CONFIG_START; } void PapbVcInterface::completePacketTransfer() { *vcBaseReg = CONFIG_END; } -ReturnValue_t PapbVcInterface::pollPapbBusySignal(uint32_t maxPollRetries, - uint32_t retryDelayUs) const { +ReturnValue_t PapbVcInterface::pollPapbBusySignal(uint32_t maxPollRetries) const { gpio::Levels papbBusyState = gpio::Levels::LOW; ReturnValue_t result; uint32_t busyIdx = 0; + uint32_t nextDelay = 1; while (true) { /** Check if PAPB interface is ready to receive data */ @@ -75,7 +75,10 @@ ReturnValue_t PapbVcInterface::pollPapbBusySignal(uint32_t maxPollRetries, return PAPB_BUSY; } - usleep(retryDelayUs); + usleep(nextDelay); + if (nextDelay * 2 <= MAX_DELAY_PAPB_POLLING_US) { + nextDelay *= 2; + } } return returnvalue::OK; } @@ -100,7 +103,7 @@ void PapbVcInterface::isVcInterfaceBufferEmpty() { return; } -bool PapbVcInterface::isBusy() const { return pollPapbBusySignal(0, 0) == PAPB_BUSY; } +bool PapbVcInterface::isBusy() const { return pollPapbBusySignal(0) == PAPB_BUSY; } void PapbVcInterface::cancelTransfer() { abortPacketTransfer(); } diff --git a/linux/ipcore/PapbVcInterface.h b/linux/ipcore/PapbVcInterface.h index 7491398c..f0cd327b 100644 --- a/linux/ipcore/PapbVcInterface.h +++ b/linux/ipcore/PapbVcInterface.h @@ -76,6 +76,8 @@ class PapbVcInterface : public VirtualChannelIF { */ static const int DATA_REG_OFFSET = 256; + static constexpr uint32_t MAX_DELAY_PAPB_POLLING_US = 4; + LinuxLibgpioIF* gpioComIF = nullptr; /** Pulled to low when virtual channel not ready to receive data */ @@ -111,7 +113,7 @@ class PapbVcInterface : public VirtualChannelIF { * * @return returnvalue::OK when ready to receive data else PAPB_BUSY. */ - ReturnValue_t pollPapbBusySignal(uint32_t maxPollRetries, uint32_t retryDelayUs) const; + ReturnValue_t pollPapbBusySignal(uint32_t maxPollRetries) const; /** * @brief This function can be used for debugging to check whether there are packets in diff --git a/mission/tmtc/PersistentLogTmStoreTask.cpp b/mission/tmtc/PersistentLogTmStoreTask.cpp index ccabb16d..2b7e1333 100644 --- a/mission/tmtc/PersistentLogTmStoreTask.cpp +++ b/mission/tmtc/PersistentLogTmStoreTask.cpp @@ -33,12 +33,8 @@ ReturnValue_t PersistentLogTmStoreTask::performOperation(uint8_t opCode) { stateHandlingForStore(handleOneStore(stores.miscStore, miscStoreContext)); if (not someonesBusy) { TaskFactory::delayTask(100); - } else /* and graceDelayDuringDumping.hasTimedOut()*/ { - if (someFileWasSwapped) { - TaskFactory::delayTask(20); - } - // TaskFactory::delayTask(2); - // graceDelayDuringDumping.resetTimer(); + } else if (someFileWasSwapped) { + TaskFactory::delayTask(2); } } } diff --git a/mission/tmtc/PersistentSingleTmStoreTask.cpp b/mission/tmtc/PersistentSingleTmStoreTask.cpp index a814694e..32ae06c4 100644 --- a/mission/tmtc/PersistentSingleTmStoreTask.cpp +++ b/mission/tmtc/PersistentSingleTmStoreTask.cpp @@ -18,14 +18,8 @@ ReturnValue_t PersistentSingleTmStoreTask::performOperation(uint8_t opCode) { bool busy = handleOneStore(storeWithQueue, dumpContext); if (not busy) { TaskFactory::delayTask(100); - } else { - if (fileHasSwapped) { - TaskFactory::delayTask(20); - } - // if (fileHasSwapped and graceDelayDuringDumping.hasTimedOut()) { - // TaskFactory::delayTask(2); - // graceDelayDuringDumping.resetTimer(); - // } + } else if (fileHasSwapped) { + TaskFactory::delayTask(2); } } } diff --git a/mission/tmtc/PersistentTmStore.cpp b/mission/tmtc/PersistentTmStore.cpp index 6cbcac86..949657d5 100644 --- a/mission/tmtc/PersistentTmStore.cpp +++ b/mission/tmtc/PersistentTmStore.cpp @@ -212,7 +212,7 @@ ReturnValue_t PersistentTmStore::loadNextDumpFile() { sif::error << "PersistentTmStore: Could not retrieve file size: " << e.message() << std::endl; continue; } - sif::debug << "Path: " << dumpParams.dirEntry.path() << std::endl; + // sif::debug << "Path: " << dumpParams.dirEntry.path() << std::endl; // File empty or can't even read CCSDS header. if (dumpParams.fileSize <= 6) { diff --git a/tmtc b/tmtc index f6fcb2fb..3f352346 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit f6fcb2fb282d79b1e250722eba46a319603b0232 +Subproject commit 3f3523465a141bc2a2c36cbc9cbbf6ab7b3a9d70