From 1a0e632d2f442f13a439a35fa8d270641d041568 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 27 Mar 2023 17:42:54 +0200 Subject: [PATCH] go down to nanoseconds --- linux/ipcore/PapbVcInterface.cpp | 9 +++++---- linux/ipcore/PapbVcInterface.h | 3 ++- mission/tmtc/PersistentLogTmStoreTask.cpp | 2 +- mission/tmtc/PersistentSingleTmStoreTask.cpp | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/linux/ipcore/PapbVcInterface.cpp b/linux/ipcore/PapbVcInterface.cpp index 57dcb963..e41bf23b 100644 --- a/linux/ipcore/PapbVcInterface.cpp +++ b/linux/ipcore/PapbVcInterface.cpp @@ -3,6 +3,7 @@ #include #include "fsfw/serviceinterface/ServiceInterface.h" +#include PapbVcInterface::PapbVcInterface(LinuxLibgpioIF* gpioComIF, gpioId_t papbBusyId, gpioId_t papbEmptyId, std::string uioFile, int mapNum) @@ -56,7 +57,7 @@ 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; + struct timespec nextDelay = {.tv_sec = 0, .tv_nsec = 10}; while (true) { /** Check if PAPB interface is ready to receive data */ @@ -75,9 +76,9 @@ ReturnValue_t PapbVcInterface::pollPapbBusySignal(uint32_t maxPollRetries) const return PAPB_BUSY; } - usleep(nextDelay); - if (nextDelay * 2 <= MAX_DELAY_PAPB_POLLING_US) { - nextDelay *= 2; + nanosleep(&nextDelay, const_cast(&remDelay)); + if (nextDelay.tv_nsec * 2 <= MAX_DELAY_PAPB_POLLING_NS) { + nextDelay.tv_nsec *= 2; } } return returnvalue::OK; diff --git a/linux/ipcore/PapbVcInterface.h b/linux/ipcore/PapbVcInterface.h index f0cd327b..59200207 100644 --- a/linux/ipcore/PapbVcInterface.h +++ b/linux/ipcore/PapbVcInterface.h @@ -76,7 +76,7 @@ class PapbVcInterface : public VirtualChannelIF { */ static const int DATA_REG_OFFSET = 256; - static constexpr uint32_t MAX_DELAY_PAPB_POLLING_US = 4; + static constexpr long int MAX_DELAY_PAPB_POLLING_NS = 40; LinuxLibgpioIF* gpioComIF = nullptr; @@ -87,6 +87,7 @@ class PapbVcInterface : public VirtualChannelIF { std::string uioFile; int mapNum = 0; + struct timespec remDelay; volatile uint32_t* vcBaseReg = nullptr; diff --git a/mission/tmtc/PersistentLogTmStoreTask.cpp b/mission/tmtc/PersistentLogTmStoreTask.cpp index 2b7e1333..2f30dafc 100644 --- a/mission/tmtc/PersistentLogTmStoreTask.cpp +++ b/mission/tmtc/PersistentLogTmStoreTask.cpp @@ -34,7 +34,7 @@ ReturnValue_t PersistentLogTmStoreTask::performOperation(uint8_t opCode) { if (not someonesBusy) { TaskFactory::delayTask(100); } else if (someFileWasSwapped) { - TaskFactory::delayTask(2); + TaskFactory::delayTask(1); } } } diff --git a/mission/tmtc/PersistentSingleTmStoreTask.cpp b/mission/tmtc/PersistentSingleTmStoreTask.cpp index 32ae06c4..693d2c2c 100644 --- a/mission/tmtc/PersistentSingleTmStoreTask.cpp +++ b/mission/tmtc/PersistentSingleTmStoreTask.cpp @@ -19,7 +19,7 @@ ReturnValue_t PersistentSingleTmStoreTask::performOperation(uint8_t opCode) { if (not busy) { TaskFactory::delayTask(100); } else if (fileHasSwapped) { - TaskFactory::delayTask(2); + TaskFactory::delayTask(1); } } }