From 1cc62238c2f35af3186e9d7cff77295f59770faf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 26 Jun 2023 14:39:03 +0200 Subject: [PATCH 1/9] only reset PTME on rate change init --- linux/ipcore/AxiPtmeConfig.cpp | 6 ++++++ linux/ipcore/AxiPtmeConfig.h | 1 + linux/ipcore/PtmeConfig.cpp | 5 +++++ linux/ipcore/PtmeConfig.h | 1 + mission/com/CcsdsIpCoreHandler.cpp | 1 + 5 files changed, 14 insertions(+) diff --git a/linux/ipcore/AxiPtmeConfig.cpp b/linux/ipcore/AxiPtmeConfig.cpp index 6dee3e2f..d3d5662a 100644 --- a/linux/ipcore/AxiPtmeConfig.cpp +++ b/linux/ipcore/AxiPtmeConfig.cpp @@ -41,6 +41,12 @@ ReturnValue_t AxiPtmeConfig::writeCaduRateReg(uint8_t rateVal) { return returnvalue::OK; } +uint8_t AxiPtmeConfig::readCaduRateReg() { + ReturnValue_t result = returnvalue::OK; + MutexGuard mg(mutex); + return static_cast(*(baseAddress + CADU_BITRATE_REG)); +} + void AxiPtmeConfig::enableTxclockManipulator() { writeBit(COMMON_CONFIG_REG, true, BitPos::EN_TX_CLK_MANIPULATOR); } diff --git a/linux/ipcore/AxiPtmeConfig.h b/linux/ipcore/AxiPtmeConfig.h index 98188775..ebdf4d38 100644 --- a/linux/ipcore/AxiPtmeConfig.h +++ b/linux/ipcore/AxiPtmeConfig.h @@ -38,6 +38,7 @@ class AxiPtmeConfig : public SystemObject { * frequency of the clock connected to the bit clock input of PTME. */ ReturnValue_t writeCaduRateReg(uint8_t rateVal); + uint8_t readCaduRateReg(); /** * @brief Next to functions control the tx clock manipulator component diff --git a/linux/ipcore/PtmeConfig.cpp b/linux/ipcore/PtmeConfig.cpp index 5f247b54..5b6b9343 100644 --- a/linux/ipcore/PtmeConfig.cpp +++ b/linux/ipcore/PtmeConfig.cpp @@ -26,6 +26,11 @@ ReturnValue_t PtmeConfig::setRate(uint32_t bitRate) { return axiPtmeConfig->writeCaduRateReg(static_cast(rateVal)); } +uint32_t PtmeConfig::getRate() { + uint8_t rateReg = axiPtmeConfig->readCaduRateReg(); + return (BIT_CLK_FREQ / (rateReg + 1)); +} + void PtmeConfig::invertTxClock(bool invert) { if (invert) { axiPtmeConfig->enableTxclockInversion(); diff --git a/linux/ipcore/PtmeConfig.h b/linux/ipcore/PtmeConfig.h index 87614187..11eeff7d 100644 --- a/linux/ipcore/PtmeConfig.h +++ b/linux/ipcore/PtmeConfig.h @@ -32,6 +32,7 @@ class PtmeConfig : public SystemObject { * of the CADU clock due to the convolutional code added by the s-Band transceiver. */ ReturnValue_t setRate(uint32_t bitRate); + uint32_t getRate(); /** * @brief Will change the time the tx data signal is updated with respect to the tx clock diff --git a/mission/com/CcsdsIpCoreHandler.cpp b/mission/com/CcsdsIpCoreHandler.cpp index 625c90cd..766fd67c 100644 --- a/mission/com/CcsdsIpCoreHandler.cpp +++ b/mission/com/CcsdsIpCoreHandler.cpp @@ -255,6 +255,7 @@ void CcsdsIpCoreHandler::startTransition(Mode_t mode, Submode_t submode) { updateContext.setModeAfterUpdate = true; return; } + if(ptmeConfig.setRate(bitRate)) // No rate change, so enable transmitter right away. enableTransmit(); } else if (mode == HasModesIF::MODE_OFF) { From eb27ab4bb037981f20714318440baf16678353a9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 28 Jun 2023 13:32:35 +0200 Subject: [PATCH 2/9] fix and optimization --- mission/com/CcsdsIpCoreHandler.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mission/com/CcsdsIpCoreHandler.cpp b/mission/com/CcsdsIpCoreHandler.cpp index 766fd67c..78533165 100644 --- a/mission/com/CcsdsIpCoreHandler.cpp +++ b/mission/com/CcsdsIpCoreHandler.cpp @@ -246,7 +246,12 @@ ReturnValue_t CcsdsIpCoreHandler::checkModeCommand(Mode_t mode, Submode_t submod void CcsdsIpCoreHandler::startTransition(Mode_t mode, Submode_t submode) { triggerEvent(CHANGING_MODE, mode, submode); if (mode == HasModesIF::MODE_ON) { - if (this->submode != submode) { + // Check whether the rate actually changes. + if ((this->submode != submode) and + ((submode == static_cast(com::CcsdsSubmode::DATARATE_LOW) and + ptmeConfig.getRate() != RATE_100KBPS)) or + ((submode == static_cast(com::CcsdsSubmode::DATARATE_HIGH) and + ptmeConfig.getRate() != RATE_500KBPS))) { initPtmeUpdateAfterXCycles(); updateContext.enableTransmitAfterPtmeUpdate = true; updateContext.updateClockRate = true; @@ -255,7 +260,6 @@ void CcsdsIpCoreHandler::startTransition(Mode_t mode, Submode_t submode) { updateContext.setModeAfterUpdate = true; return; } - if(ptmeConfig.setRate(bitRate)) // No rate change, so enable transmitter right away. enableTransmit(); } else if (mode == HasModesIF::MODE_OFF) { From 4c63fed69d0a3737d5157b7743bf74fab82c927e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 28 Jun 2023 13:35:38 +0200 Subject: [PATCH 3/9] that is annoying --- mission/com/CcsdsIpCoreHandler.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mission/com/CcsdsIpCoreHandler.cpp b/mission/com/CcsdsIpCoreHandler.cpp index 78533165..2e068add 100644 --- a/mission/com/CcsdsIpCoreHandler.cpp +++ b/mission/com/CcsdsIpCoreHandler.cpp @@ -246,12 +246,13 @@ ReturnValue_t CcsdsIpCoreHandler::checkModeCommand(Mode_t mode, Submode_t submod void CcsdsIpCoreHandler::startTransition(Mode_t mode, Submode_t submode) { triggerEvent(CHANGING_MODE, mode, submode); if (mode == HasModesIF::MODE_ON) { + uint32_t currenRate = ptmeConfig.getRate(); // Check whether the rate actually changes. if ((this->submode != submode) and - ((submode == static_cast(com::CcsdsSubmode::DATARATE_LOW) and - ptmeConfig.getRate() != RATE_100KBPS)) or - ((submode == static_cast(com::CcsdsSubmode::DATARATE_HIGH) and - ptmeConfig.getRate() != RATE_500KBPS))) { + (((submode == static_cast(com::CcsdsSubmode::DATARATE_LOW) and + (currenRate != RATE_100KBPS))) or + ((submode == static_cast(com::CcsdsSubmode::DATARATE_HIGH) and + (currenRate != RATE_500KBPS))))) { initPtmeUpdateAfterXCycles(); updateContext.enableTransmitAfterPtmeUpdate = true; updateContext.updateClockRate = true; From 87c05705ec4f10ec020e160d432de77365cb7149 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 28 Jun 2023 15:43:44 +0200 Subject: [PATCH 4/9] core ctrl bugfix --- bsp_q7s/core/CoreController.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 4387e788..cea6c700 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -170,9 +170,6 @@ ReturnValue_t CoreController::initialize() { sdStateMachine(); - triggerEvent(core::REBOOT_SW, CURRENT_CHIP, CURRENT_COPY); - announceCurrentImageInfo(); - announceVersionInfo(); EventManagerIF *eventManager = ObjectManager::instance()->get(objects::EVENT_MANAGER); if (eventManager == nullptr or eventQueue == nullptr) { @@ -189,17 +186,22 @@ ReturnValue_t CoreController::initialize() { if (result != returnvalue::OK) { sif::warning << "Subscribing for GPS GPS_FIX_CHANGE event failed" << std::endl; } - + triggerEvent(core::REBOOT_SW, CURRENT_CHIP, CURRENT_COPY); + announceCurrentImageInfo(); + // This has to come before the version announce because it might be required for retrieving + // the firmware version. if (common::OBSW_VERSION_MAJOR >= 6 or common::OBSW_VERSION_MAJOR == 4) { UioMapper sysRomMapper(q7s::UIO_SYS_ROM); result = sysRomMapper.getMappedAdress(&mappedSysRomAddr, UioMapper::Permissions::READ_ONLY); if (result != returnvalue::OK) { // TODO: This might be a reason to switch to another image.. sif::error << "Getting mapped SYS ROM UIO address failed" << std::endl; - return ObjectManager::CHILD_INIT_FAILED; + result = ObjectManager::CHILD_INIT_FAILED; } } - return returnvalue::OK; + announceVersionInfo(); + + return result; } ReturnValue_t CoreController::initializeAfterTaskCreation() { From ad3c0e2a0e4d061302d9cd1e12c4f46d23f58d70 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 29 Jun 2023 01:28:40 +0200 Subject: [PATCH 5/9] small fix for persistent TM store --- CHANGELOG.md | 8 +++++++- mission/com/TmStoreTaskBase.cpp | 30 ++++++++++++++++++------------ mission/com/TmStoreTaskBase.h | 2 ++ mission/tmtc/PersistentTmStore.cpp | 10 +++++++--- 4 files changed, 34 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fda0e54..95718644 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,13 @@ will consitute of a breaking change warranting a new major release: - Important bugfixes for PTME. See `q7s-package` CHANGELOG. -# [v5.1.0] to be released +# [v5.2.0] 2023-06-29 + +## Fixed + +- Empty dumps (no TM in time range) will now correctly be completed immediately + +# [v5.1.0] 2023-06-28 - `eive-tmtc` version v5.1.0 diff --git a/mission/com/TmStoreTaskBase.cpp b/mission/com/TmStoreTaskBase.cpp index 0470dc04..80900975 100644 --- a/mission/com/TmStoreTaskBase.cpp +++ b/mission/com/TmStoreTaskBase.cpp @@ -45,13 +45,19 @@ bool TmStoreTaskBase::handleOneStore(PersistentTmStoreWithTmQueue& store, } else { Command_t execCmd; // Handle TC requests, for example deletion or retrieval requests. + // TODO: Not really clean here.. would be better if the executed command is returns as an + // enumeration. result = store.handleCommandQueue(ipcStore, execCmd); - if (result == returnvalue::OK) { - if (execCmd == TmStoreMessage::DOWNLINK_STORE_CONTENT_TIME) { + if (execCmd == TmStoreMessage::DOWNLINK_STORE_CONTENT_TIME) { + if (result == PersistentTmStore::DUMP_DONE) { + dumpDoneHandler(store, dumpContext); + } else if (result == returnvalue::OK) { cancelDumpCd.resetTimer(); tmSinkBusyCd.resetTimer(); dumpContext.reset(); } + } + if (execCmd != CommandMessageIF::CMD_NONE) { tcRequestReceived = true; } } @@ -119,21 +125,13 @@ ReturnValue_t TmStoreTaskBase::performDump(PersistentTmStoreWithTmQueue& store, DumpContext& dumpContext, bool& dumpPerformed) { size_t dumpedLen = 0; - auto dumpDoneHandler = [&]() { - uint32_t startTime; - uint32_t endTime; - store.getStartAndEndTimeCurrentOrLastDump(startTime, endTime); - triggerEvent(dumpContext.eventIfDone, dumpContext.numberOfDumpedPackets, - dumpContext.dumpedBytes); - dumpContext.reset(); - }; // Dump the next packet into the PTME. dumpContext.ptmeBusyCounter = 0; tmSinkBusyCd.resetTimer(); ReturnValue_t result = store.getNextDumpPacket(tmReader, fileHasSwapped); if (fileHasSwapped and result == PersistentTmStore::DUMP_DONE) { // This can happen if a file is corrupted and the next file swap completes the dump. - dumpDoneHandler(); + dumpDoneHandler(store, dumpContext); return returnvalue::OK; } else if (result != returnvalue::OK) { sif::error << "PersistentTmStore: Getting next dump packet failed" << std::endl; @@ -157,7 +155,7 @@ ReturnValue_t TmStoreTaskBase::performDump(PersistentTmStoreWithTmQueue& store, } } if (result == PersistentTmStore::DUMP_DONE) { - dumpDoneHandler(); + dumpDoneHandler(store, dumpContext); } return returnvalue::OK; } @@ -198,6 +196,14 @@ ReturnValue_t TmStoreTaskBase::connectModeTreeParent(HasModeTreeChildrenIF& pare return modetree::connectModeTreeParent(parent, *this, nullptr, modeHelper); } +void TmStoreTaskBase::dumpDoneHandler(PersistentTmStore& store, DumpContext& dumpContext) { + uint32_t startTime; + uint32_t endTime; + store.getStartAndEndTimeCurrentOrLastDump(startTime, endTime); + triggerEvent(dumpContext.eventIfDone, dumpContext.numberOfDumpedPackets, dumpContext.dumpedBytes); + dumpContext.reset(); +} + ModeTreeChildIF& TmStoreTaskBase::getModeTreeChildIF() { return *this; } void TmStoreTaskBase::readCommandQueue(void) { diff --git a/mission/com/TmStoreTaskBase.h b/mission/com/TmStoreTaskBase.h index ef61bd19..2bcd3b1e 100644 --- a/mission/com/TmStoreTaskBase.h +++ b/mission/com/TmStoreTaskBase.h @@ -96,6 +96,8 @@ class TmStoreTaskBase : public SystemObject, ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, uint32_t* msToReachTheMode) override; + void dumpDoneHandler(PersistentTmStore& store, DumpContext& dumpContext); + void announceMode(bool recursive) override; object_id_t getObjectId() const override; const HasHealthIF* getOptHealthIF() const override; diff --git a/mission/tmtc/PersistentTmStore.cpp b/mission/tmtc/PersistentTmStore.cpp index acef0b3a..2f884dac 100644 --- a/mission/tmtc/PersistentTmStore.cpp +++ b/mission/tmtc/PersistentTmStore.cpp @@ -128,6 +128,7 @@ ReturnValue_t PersistentTmStore::assignAndOrCreateMostRecentFile() { ReturnValue_t PersistentTmStore::handleCommandQueue(StorageManagerIF& ipcStore, Command_t& execCmd) { + execCmd = CommandMessageIF::CMD_NONE; CommandMessage cmdMessage; ReturnValue_t result = tcQueue->receiveMessage(&cmdMessage); if (result != returnvalue::OK) { @@ -162,9 +163,9 @@ ReturnValue_t PersistentTmStore::handleCommandQueue(StorageManagerIF& ipcStore, result = startDumpFromUpTo(dumpFromUnixSeconds, dumpUntilUnixSeconds); if (result == BUSY_DUMPING) { triggerEvent(persTmStore::BUSY_DUMPING_EVENT); - } else { - execCmd = cmd; + return result; } + execCmd = cmd; } } return result; @@ -359,7 +360,10 @@ ReturnValue_t PersistentTmStore::loadNextDumpFile() { } ReturnValue_t PersistentTmStore::getNextDumpPacket(PusTmReader& reader, bool& fileHasSwapped) { - if (state == State::IDLE or dumpParams.pendingPacketDump) { + if (state == State::IDLE) { + return DUMP_DONE; + } + if (dumpParams.pendingPacketDump) { return returnvalue::FAILED; } fileHasSwapped = false; From 0a12dbf2bed3fd0557b556ed527398b4324f2692 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 29 Jun 2023 08:53:08 +0200 Subject: [PATCH 6/9] changelog --- CHANGELOG.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fda0e54..5d82a812 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,14 @@ will consitute of a breaking change warranting a new major release: - Important bugfixes for PTME. See `q7s-package` CHANGELOG. -# [v5.1.0] to be released +# [v5.2.0] to be released + +## Fixed + +- The firmware information event was not triggered even when possible because of an ordering + bug in the initializer function. + +# [v5.1.0] 2023-06-28 - `eive-tmtc` version v5.1.0 From 33985937b7e9adf4918268bac36f2c910bc9ec99 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 29 Jun 2023 09:44:09 +0200 Subject: [PATCH 7/9] typo --- mission/com/CcsdsIpCoreHandler.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mission/com/CcsdsIpCoreHandler.cpp b/mission/com/CcsdsIpCoreHandler.cpp index 2e068add..19dd4f5a 100644 --- a/mission/com/CcsdsIpCoreHandler.cpp +++ b/mission/com/CcsdsIpCoreHandler.cpp @@ -246,13 +246,13 @@ ReturnValue_t CcsdsIpCoreHandler::checkModeCommand(Mode_t mode, Submode_t submod void CcsdsIpCoreHandler::startTransition(Mode_t mode, Submode_t submode) { triggerEvent(CHANGING_MODE, mode, submode); if (mode == HasModesIF::MODE_ON) { - uint32_t currenRate = ptmeConfig.getRate(); + uint32_t currentRate = ptmeConfig.getRate(); // Check whether the rate actually changes. if ((this->submode != submode) and (((submode == static_cast(com::CcsdsSubmode::DATARATE_LOW) and - (currenRate != RATE_100KBPS))) or + (currentRate != RATE_100KBPS))) or ((submode == static_cast(com::CcsdsSubmode::DATARATE_HIGH) and - (currenRate != RATE_500KBPS))))) { + (currentRate != RATE_500KBPS))))) { initPtmeUpdateAfterXCycles(); updateContext.enableTransmitAfterPtmeUpdate = true; updateContext.updateClockRate = true; From 825de04f3be535880e61e1fcdac9d3acef725f95 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 29 Jun 2023 10:15:36 +0200 Subject: [PATCH 8/9] changelog --- CHANGELOG.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fda0e54..4f8b027b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,14 @@ will consitute of a breaking change warranting a new major release: - Important bugfixes for PTME. See `q7s-package` CHANGELOG. -# [v5.1.0] to be released +# [v5.2.0] to be released + +## Changed + +- PTME was always reset on submode changes. The reset will now only be performed if the actual data + rate changes. + +# [v5.1.0] 2023-06-28 - `eive-tmtc` version v5.1.0 From 51cbe46cf52d601cb22e0f4e45c749f472608823 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 29 Jun 2023 14:49:57 +0200 Subject: [PATCH 9/9] why indeed --- linux/ipcore/AxiPtmeConfig.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/linux/ipcore/AxiPtmeConfig.cpp b/linux/ipcore/AxiPtmeConfig.cpp index d3d5662a..b21edf5b 100644 --- a/linux/ipcore/AxiPtmeConfig.cpp +++ b/linux/ipcore/AxiPtmeConfig.cpp @@ -16,9 +16,9 @@ AxiPtmeConfig::AxiPtmeConfig(object_id_t objectId, std::string axiUio, int mapNu AxiPtmeConfig::~AxiPtmeConfig() {} ReturnValue_t AxiPtmeConfig::initialize() { - ReturnValue_t result = returnvalue::OK; UioMapper uioMapper(axiUio, mapNum); - result = uioMapper.getMappedAdress(&baseAddress, UioMapper::Permissions::READ_WRITE); + ReturnValue_t result = + uioMapper.getMappedAdress(&baseAddress, UioMapper::Permissions::READ_WRITE); if (result != returnvalue::OK) { return result; } @@ -26,8 +26,7 @@ ReturnValue_t AxiPtmeConfig::initialize() { } ReturnValue_t AxiPtmeConfig::writeCaduRateReg(uint8_t rateVal) { - ReturnValue_t result = returnvalue::OK; - result = mutex->lockMutex(timeoutType, mutexTimeout); + ReturnValue_t result = mutex->lockMutex(timeoutType, mutexTimeout); if (result != returnvalue::OK) { sif::warning << "AxiPtmeConfig::writeCaduRateReg: Failed to lock mutex" << std::endl; return returnvalue::FAILED; @@ -42,7 +41,6 @@ ReturnValue_t AxiPtmeConfig::writeCaduRateReg(uint8_t rateVal) { } uint8_t AxiPtmeConfig::readCaduRateReg() { - ReturnValue_t result = returnvalue::OK; MutexGuard mg(mutex); return static_cast(*(baseAddress + CADU_BITRATE_REG)); }