From c1394576617d03e60f5b690320fad4cd5325ddd0 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 18 Oct 2023 13:32:09 +0200 Subject: [PATCH 1/4] reduce sus fdir events --- mission/acs/SusHandler.cpp | 14 ++++++++++---- mission/acs/SusHandler.h | 13 ++++++++----- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/mission/acs/SusHandler.cpp b/mission/acs/SusHandler.cpp index 4b9778e5..fd06b9ab 100644 --- a/mission/acs/SusHandler.cpp +++ b/mission/acs/SusHandler.cpp @@ -97,9 +97,7 @@ ReturnValue_t SusHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8 // appear sometimes for the SUS device: Allow invalid message up to a certain threshold // before triggering FDIR reactions. if (reply->tempRaw == 0xfff and not waitingForRecovery) { - if (invalidMsgCounter == 0) { - triggerEvent(TEMPERATURE_ALL_ONES_START); - } else if (invalidMsgCounter == susMax1227::MAX_INVALID_MSG_COUNT) { + if (invalidMsgCounter == susMax1227::MAX_INVALID_MSG_COUNT) { triggerEvent(DeviceHandlerIF::DEVICE_WANTS_HARD_REBOOT); waitingForRecovery = true; } @@ -110,8 +108,16 @@ ReturnValue_t SusHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8 return returnvalue::OK; } if (invalidMsgCounter > 0) { - triggerEvent(TEMPERATURE_ALL_ONES_RECOVERY, invalidMsgCounter); + invalidMsgPeriodCounter++; + if (invalidMsgCounter > invalidMsgCounterMax) { + invalidMsgCounterMax = invalidMsgCounter; + } invalidMsgCounter = 0; + invalidMsgCountdown.resetTimer(); + } + if (invalidMsgCountdown.hasTimedOut() and invalidMsgPeriodCounter > 0) { + triggerEvent(TEMPERATURE_ALL_ONES_RECOVERY, invalidMsgPeriodCounter, invalidMsgCounterMax); + invalidMsgPeriodCounter = 0; } dataset.setValidity(true, true); dataset.tempC = max1227::getTemperature(reply->tempRaw); diff --git a/mission/acs/SusHandler.h b/mission/acs/SusHandler.h index 88e2b163..e35185b7 100644 --- a/mission/acs/SusHandler.h +++ b/mission/acs/SusHandler.h @@ -17,11 +17,9 @@ class SusHandler : public DeviceHandlerBase { static const uint8_t INTERFACE_ID = CLASS_ID::SUS_HANDLER; static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SUS_HANDLER; - //! [EXPORT] : [COMMENT] Detected invalid values, starting invalid message counting - static constexpr Event TEMPERATURE_ALL_ONES_START = - event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM); - //! [EXPORT] : [COMMENT] Detected valid values again, resetting invalid message counter. - //! P1: Invalid message counter. + //! [EXPORT] : [COMMENT] Detected valid values for a prolonged time again, resetting all counters. + //! P1: Number of periods with invalid messages. + //! P2: Maximum invalid message counter. static constexpr Event TEMPERATURE_ALL_ONES_RECOVERY = event::makeEvent(SUBSYSTEM_ID, 1, severity::INFO); @@ -54,8 +52,13 @@ class SusHandler : public DeviceHandlerBase { susMax1227::SusDataset dataset; acs::SusRequest request{}; uint8_t susIdx; + + // After 1 minute, trigger the event for the invalid messages. + Countdown invalidMsgCountdown = Countdown(60000); bool waitingForRecovery = true; uint32_t invalidMsgCounter = 0; + uint32_t invalidMsgCounterMax = 0; + uint32_t invalidMsgPeriodCounter = 0; uint32_t transitionDelay = 1000; bool goToNormalMode = false; From 665b7d95f7929add0eda2097fba90432248af6f3 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 18 Oct 2023 13:35:18 +0200 Subject: [PATCH 2/4] actually lets keep this --- mission/acs/SusHandler.cpp | 4 +++- mission/acs/SusHandler.h | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/mission/acs/SusHandler.cpp b/mission/acs/SusHandler.cpp index fd06b9ab..58280636 100644 --- a/mission/acs/SusHandler.cpp +++ b/mission/acs/SusHandler.cpp @@ -97,7 +97,9 @@ ReturnValue_t SusHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8 // appear sometimes for the SUS device: Allow invalid message up to a certain threshold // before triggering FDIR reactions. if (reply->tempRaw == 0xfff and not waitingForRecovery) { - if (invalidMsgCounter == susMax1227::MAX_INVALID_MSG_COUNT) { + if (invalidMsgCounter == 0 and invalidMsgPeriodCounter == 0) { + triggerEvent(TEMPERATURE_ALL_ONES_START); + } else if (invalidMsgCounter == susMax1227::MAX_INVALID_MSG_COUNT) { triggerEvent(DeviceHandlerIF::DEVICE_WANTS_HARD_REBOOT); waitingForRecovery = true; } diff --git a/mission/acs/SusHandler.h b/mission/acs/SusHandler.h index e35185b7..43c49dcb 100644 --- a/mission/acs/SusHandler.h +++ b/mission/acs/SusHandler.h @@ -17,6 +17,9 @@ class SusHandler : public DeviceHandlerBase { static const uint8_t INTERFACE_ID = CLASS_ID::SUS_HANDLER; static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SUS_HANDLER; + //! [EXPORT] : [COMMENT] Detected invalid values, starting invalid message counting + static constexpr Event TEMPERATURE_ALL_ONES_START = + event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM); //! [EXPORT] : [COMMENT] Detected valid values for a prolonged time again, resetting all counters. //! P1: Number of periods with invalid messages. //! P2: Maximum invalid message counter. From 8b6fa63c60d3fb49f7f797255caea13769ae4d4f Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 18 Oct 2023 14:29:33 +0200 Subject: [PATCH 3/4] changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 09055dd7..78803876 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,12 @@ will consitute of a breaking change warranting a new major release: is not in normal mode. - MPSoC debug mode. +## Changed + +- SUS FDIR should now trigger less events. The finish event is now only triggered once the + SUS has been working properly for a minute again. It will then display the number of periods + during which the SUS was not working as well as the maximum amount of invalid messages. + # [v7.1.0] 2023-10-11 - Bumped `eive-tmtc` to v5.8.0. From 35e7fba576e427a9618c1ad618417df3a026b2c8 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 27 Oct 2023 09:50:40 +0200 Subject: [PATCH 4/4] smoll fix --- mission/acs/SusHandler.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/mission/acs/SusHandler.cpp b/mission/acs/SusHandler.cpp index 58280636..193bdb5c 100644 --- a/mission/acs/SusHandler.cpp +++ b/mission/acs/SusHandler.cpp @@ -120,6 +120,7 @@ ReturnValue_t SusHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8 if (invalidMsgCountdown.hasTimedOut() and invalidMsgPeriodCounter > 0) { triggerEvent(TEMPERATURE_ALL_ONES_RECOVERY, invalidMsgPeriodCounter, invalidMsgCounterMax); invalidMsgPeriodCounter = 0; + invalidMsgCounterMax = 0; } dataset.setValidity(true, true); dataset.tempC = max1227::getTemperature(reply->tempRaw);