From 669c3630a9c819c4b3d30f7cb4487f7ff2bc79cd Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 4 Aug 2023 14:23:10 +0200 Subject: [PATCH] reworked PDEC FDIR --- mission/system/EiveSystem.cpp | 59 +++++++++++++++++------------------ mission/system/EiveSystem.h | 5 +-- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/mission/system/EiveSystem.cpp b/mission/system/EiveSystem.cpp index 41f52cde..8461b528 100644 --- a/mission/system/EiveSystem.cpp +++ b/mission/system/EiveSystem.cpp @@ -296,39 +296,38 @@ ReturnValue_t EiveSystem::sendFullRebootCommand() { } void EiveSystem::pdecRecoveryLogic() { - if (pdecResetWasAttempted and pdecResetWasAttemptedCd.hasTimedOut()) { - pdecResetWasAttempted = false; + if (pdecResetCounter >= PDEC_RESET_MAX_COUNT_BEFORE_REBOOT) { + // If a PTME reset was already attempted and there is still an issue receiving TC frames, + // reboot the system. + if (waitingForPdecReboot) { + return; + } + triggerEvent(core::PDEC_REBOOT); + // Some delay to ensure that the event is stored in the persistent TM store as well. + TaskFactory::delayTask(500); + // Send reboot command. + ReturnValue_t result = sendSelfRebootCommand(); + if (result != returnvalue::OK) { + sif::error << "Sending a reboot command has failed" << std::endl; + // If the previous operation failed, it should be re-attempted the next task cycle. + pdecResetCounterResetCd.resetTimer(); + return; + } + waitingForPdecReboot = true; + return; + } + if (pdecResetCounterResetCd.hasTimedOut()) { + pdecResetCounter = 0; } if (frameDirtyCheckCd.hasTimedOut()) { if (frameDirtyErrorCounter >= FRAME_DIRTY_COM_REBOOT_LIMIT) { - // If a PTME reset was already attempted and there is still an issue receiving TC frames, - // reboot the system. - if (pdecResetWasAttempted) { - if (waitingForPdecReboot) { - return; - } - triggerEvent(core::PDEC_REBOOT); - // Some delay to ensure that the event is stored in the persistent TM store as well. - TaskFactory::delayTask(500); - // Send reboot command. - ReturnValue_t result = sendSelfRebootCommand(); - if (result != returnvalue::OK) { - sif::error << "Sending a reboot command has failed" << std::endl; - // If the previous operation failed, it should be re-attempted the next task cycle. - pdecResetWasAttemptedCd.resetTimer(); - return; - } - waitingForPdecReboot = true; - return; - } else { - // Try one full PDEC reset. - CommandMessage msg; - store_address_t dummy{}; - ActionMessage::setCommand(&msg, pdec::RESET_PDEC_WITH_REINIITALIZATION, dummy); - commandQueue->sendMessage(pdecHandlerQueueId, &msg); - pdecResetWasAttemptedCd.resetTimer(); - pdecResetWasAttempted = true; - } + // Try one full PDEC reset. + CommandMessage msg; + store_address_t dummy{}; + ActionMessage::setCommand(&msg, pdec::RESET_PDEC_WITH_REINIITALIZATION, dummy); + commandQueue->sendMessage(pdecHandlerQueueId, &msg); + pdecResetCounterResetCd.resetTimer(); + pdecResetCounter++; } frameDirtyErrorCounter = 0; frameDirtyCheckCd.resetTimer(); diff --git a/mission/system/EiveSystem.h b/mission/system/EiveSystem.h index c724ba34..e6ff19b9 100644 --- a/mission/system/EiveSystem.h +++ b/mission/system/EiveSystem.h @@ -10,6 +10,7 @@ class EiveSystem : public Subsystem, public HasActionsIF { public: static constexpr uint8_t FRAME_DIRTY_COM_REBOOT_LIMIT = 4; + static constexpr uint32_t PDEC_RESET_MAX_COUNT_BEFORE_REBOOT = 10; static constexpr ActionId_t EXECUTE_I2C_REBOOT = 10; @@ -39,11 +40,11 @@ class EiveSystem : public Subsystem, public HasActionsIF { Countdown frameDirtyCheckCd = Countdown(10000); // If the PDEC reset was already attempted in the last 2 minutes, there is a high chance that // only a full reboot will fix the issue. - Countdown pdecResetWasAttemptedCd = Countdown(120000); - bool pdecResetWasAttempted = false; + Countdown pdecResetCounterResetCd = Countdown(120000); bool waitingForI2cReboot = false; bool waitingForPdecReboot = false; + uint32_t pdecResetCounter = 0; ActionHelper actionHelper; PowerSwitchIF* powerSwitcher = nullptr; std::atomic_uint16_t& i2cErrors;