diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 00e87330..8ed42ff9 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -21,9 +21,9 @@ #include #include #include +#include #include #include -#include #include #include #include diff --git a/linux/ipcore/PapbVcInterface.cpp b/linux/ipcore/PapbVcInterface.cpp index eacfce33..5849aecd 100644 --- a/linux/ipcore/PapbVcInterface.cpp +++ b/linux/ipcore/PapbVcInterface.cpp @@ -65,7 +65,7 @@ ReturnValue_t PapbVcInterface::pollPapbBusySignal(uint32_t maxPollRetries) const gpio::Levels papbBusyState = gpio::Levels::LOW; ReturnValue_t result; uint32_t busyIdx = 0; - nextDelay.tv_nsec = 0; + nextDelay.tv_nsec = FIRST_DELAY_PAPB_POLLING_NS; while (true) { /** Check if PAPB interface is ready to receive data */ @@ -87,9 +87,7 @@ ReturnValue_t PapbVcInterface::pollPapbBusySignal(uint32_t maxPollRetries) const // Ignore signal handling here for now. nanosleep(&nextDelay, &remDelay); // Adaptive delay. - if (nextDelay.tv_nsec == 0) { - nextDelay.tv_nsec = FIRST_NON_NULL_DELAY_NS; - } else if (nextDelay.tv_nsec * 2 <= MAX_DELAY_PAPB_POLLING_NS) { + if (nextDelay.tv_nsec * 2 <= MAX_DELAY_PAPB_POLLING_NS) { nextDelay.tv_nsec *= 2; } } diff --git a/linux/ipcore/PapbVcInterface.h b/linux/ipcore/PapbVcInterface.h index b4454dae..cfc885fc 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 long int FIRST_NON_NULL_DELAY_NS = 10; + static constexpr long int FIRST_DELAY_PAPB_POLLING_NS = 10; static constexpr long int MAX_DELAY_PAPB_POLLING_NS = 40; LinuxLibgpioIF* gpioComIF = nullptr; @@ -89,7 +89,7 @@ class PapbVcInterface : public VirtualChannelIF { std::string uioFile; int mapNum = 0; mutable struct timespec nextDelay = {.tv_sec = 0, .tv_nsec = 0}; - const struct timespec BETWEEN_POLL_DELAY = {.tv_sec = 0, .tv_nsec = 5}; + const struct timespec BETWEEN_POLL_DELAY = {.tv_sec = 0, .tv_nsec = 2}; mutable struct timespec remDelay; volatile uint32_t* vcBaseReg = nullptr; diff --git a/mission/com/CcsdsIpCoreHandler.cpp b/mission/com/CcsdsIpCoreHandler.cpp index 806096b8..212acd8d 100644 --- a/mission/com/CcsdsIpCoreHandler.cpp +++ b/mission/com/CcsdsIpCoreHandler.cpp @@ -165,9 +165,11 @@ ReturnValue_t CcsdsIpCoreHandler::executeAction(ActionId_t actionId, MessageQueu break; } case EN_TRANSMITTER: { - enableTransmit(); if (mode == HasModesIF::MODE_OFF) { + enableTransmit(true); mode = HasModesIF::MODE_ON; + } else { + enableTransmit(false); } return EXECUTION_FINISHED; } @@ -205,9 +207,11 @@ ReturnValue_t CcsdsIpCoreHandler::executeAction(ActionId_t actionId, MessageQueu void CcsdsIpCoreHandler::updateLinkState() { linkState = LINK_UP; } -void CcsdsIpCoreHandler::enableTransmit() { - // Reset PTME on each transmit enable. - updateBatPriorityFromParam(); +void CcsdsIpCoreHandler::enableTransmit(bool resetPtmeUpdateParams) { + if (resetPtmeUpdateParams) { + // Reset PTME on each transmit enable. + updateBatPriorityFromParam(); + } #ifndef TE0720_1CFA gpioIF->pullHigh(ptmeGpios.enableTxClock); gpioIF->pullHigh(ptmeGpios.enableTxData); @@ -243,7 +247,11 @@ void CcsdsIpCoreHandler::startTransition(Mode_t mode, Submode_t submode) { } }; if (mode == HasModesIF::MODE_ON) { - enableTransmit(); + if (this->mode != HasModesIF::MODE_ON) { + enableTransmit(true); + } else { + enableTransmit(false); + } if (submode == static_cast(com::CcsdsSubmode::DATARATE_DEFAULT)) { com::Datarate currentDatarate = com::getCurrentDatarate(); if (currentDatarate == com::Datarate::LOW_RATE_MODULATION_BPSK) { diff --git a/mission/com/CcsdsIpCoreHandler.h b/mission/com/CcsdsIpCoreHandler.h index 0fad0aae..f01d7ab3 100644 --- a/mission/com/CcsdsIpCoreHandler.h +++ b/mission/com/CcsdsIpCoreHandler.h @@ -172,7 +172,7 @@ class CcsdsIpCoreHandler : public SystemObject, /** * @brief Starts transmit timer and enables transmitter. */ - void enableTransmit(); + void enableTransmit(bool resetPtmeUpdateParams); /** * @brief Disables the transmitter by pulling the enable tx clock and tx data pin of the diff --git a/mission/tmtc/PersistentSingleTmStoreTask.cpp b/mission/tmtc/PersistentSingleTmStoreTask.cpp index a2d57208..1c93f14e 100644 --- a/mission/tmtc/PersistentSingleTmStoreTask.cpp +++ b/mission/tmtc/PersistentSingleTmStoreTask.cpp @@ -20,8 +20,9 @@ ReturnValue_t PersistentSingleTmStoreTask::performOperation(uint8_t opCode) { if (not busy) { TaskFactory::delayTask(100); } else if (dumpContext.vcBusyDuringDump) { + sif::debug << "VC busy, delaying" << std::endl; // TODO: Might not be necessary - TaskFactory::delayTask(10); + TaskFactory::delayTask(2); } } } diff --git a/mission/tmtc/TmStoreTaskBase.cpp b/mission/tmtc/TmStoreTaskBase.cpp index 7ca03488..993c127d 100644 --- a/mission/tmtc/TmStoreTaskBase.cpp +++ b/mission/tmtc/TmStoreTaskBase.cpp @@ -115,10 +115,10 @@ ReturnValue_t TmStoreTaskBase::handleOneDump(PersistentTmStoreWithTmQueue& store } else { // The PTME might be at full load, so it might sense to delay for a bit to let it do // its work until some more bandwidth is available. Set a flag here so the upper layer can - // do ths. + // do this. dumpContext.vcBusyDuringDump = true; dumpContext.ptmeBusyCounter++; - if (dumpContext.ptmeBusyCounter == 100) { + if (dumpContext.ptmeBusyCounter == 200) { // If this happens, something is probably wrong. sif::warning << "PTME busy for longer period. Cancelling dump" << std::endl; cancelDump(dumpContext, store, channel.isTxOn());