From 56a4378a633b2b1afcef089b7a21a91c33f9cc4d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 16 Mar 2023 18:05:23 +0100 Subject: [PATCH] that should be transition safe --- mission/system/objects/ComSubsystem.cpp | 25 +++++++++++++++++++++---- mission/system/objects/ComSubsystem.h | 2 ++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/mission/system/objects/ComSubsystem.cpp b/mission/system/objects/ComSubsystem.cpp index 1d0d9b32..c6a8cfc9 100644 --- a/mission/system/objects/ComSubsystem.cpp +++ b/mission/system/objects/ComSubsystem.cpp @@ -24,6 +24,11 @@ ComSubsystem::ComSubsystem(object_id_t setObjectId, uint32_t maxNumberOfSequence void ComSubsystem::performChildOperation() { readEventQueue(); + if (performRecoveryToRxOnly and not isInTransition) { + startRxOnlyRecovery(true); + // To avoid immediately enabling TX after falling back. + rememberBitLock = false; + } // Execute default rate sequence after transition has been completed if (rememberBitLock and not isInTransition) { startRxAndTxLowRateSeq(); @@ -151,10 +156,16 @@ void ComSubsystem::handleEventMessage(EventMessage *eventMessage) { Event event = eventMessage->getEvent(); switch (event) { case tcsCtrl::SYRLINKS_OVERHEATING: { - // TODO: To prevent simply overwriting/cancelling on-going transitions, set flag here and - // execute transition at a later stage. - modeHelper.setForced(true); - startTransition(com::RX_ONLY, 0); + // This event overrides the bit lock. + rememberBitLock = false; + if (mode == com::RX_ONLY) { + return; + } + if (isInTransition) { + performRecoveryToRxOnly = true; + return; + } + startRxOnlyRecovery(true); break; } case PdecHandler::BIT_LOCK_PDEC: { @@ -204,6 +215,12 @@ void ComSubsystem::checkTransmitterCountdown() { } } +void ComSubsystem::startRxOnlyRecovery(bool forced) { + modeHelper.setForced(forced); + startTransition(com::RX_ONLY, 0); + performRecoveryToRxOnly = false; +} + bool ComSubsystem::isTxMode(Mode_t mode) { if ((mode == com::Submode::RX_AND_TX_DEFAULT_DATARATE) || (mode == com::Submode::RX_AND_TX_LOW_DATARATE) || diff --git a/mission/system/objects/ComSubsystem.h b/mission/system/objects/ComSubsystem.h index 854a877b..dbc8eda8 100644 --- a/mission/system/objects/ComSubsystem.h +++ b/mission/system/objects/ComSubsystem.h @@ -57,6 +57,7 @@ class ComSubsystem : public Subsystem, public ReceivesParameterMessagesIF { * @brief Enables transmitter in low rate mode */ void startRxAndTxLowRateSeq(); + void startRxOnlyRecovery(bool forced); /** * @brief Returns true if mode is a mode where the transmitter is on @@ -73,6 +74,7 @@ class ComSubsystem : public Subsystem, public ReceivesParameterMessagesIF { MessageQueueIF *eventQueue = nullptr; bool enableTxWhenCarrierLock = false; + bool performRecoveryToRxOnly = false; // Countdown will be started as soon as the transmitter was enabled Countdown transmitterCountdown;