From 677457bbe7b5dda3bc71363d7f1ff3bb1c8020db Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 4 Apr 2023 15:59:45 +0200 Subject: [PATCH 1/7] syrlinks HK tweaks --- fsfw | 2 +- mission/com/SyrlinksHandler.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/fsfw b/fsfw index 9fca7581..6650c293 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 9fca7581dd75d074df343802c922e48f95b677eb +Subproject commit 6650c293da09d8851c2bd6c4d6e6c5a8390d003e diff --git a/mission/com/SyrlinksHandler.cpp b/mission/com/SyrlinksHandler.cpp index 297ffd88..92546194 100644 --- a/mission/com/SyrlinksHandler.cpp +++ b/mission/com/SyrlinksHandler.cpp @@ -652,7 +652,7 @@ ReturnValue_t SyrlinksHandler::initializeLocalDataPool(localpool::DataPool& loca poolManager.subscribeForDiagPeriodicPacket( subdp::DiagnosticsHkPeriodicParams(rxDataset.getSid(), enableHkSets, 60.0)); poolManager.subscribeForRegularPeriodicPacket( - subdp::RegularHkPeriodicParams(temperatureSet.getSid(), enableHkSets, 20.0)); + subdp::RegularHkPeriodicParams(temperatureSet.getSid(), enableHkSets, 60.0)); return returnvalue::OK; } @@ -737,6 +737,9 @@ void SyrlinksHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) { internalState = InternalState::IDLE; }; auto txOnHandler = [&](InternalState selMod) { + txDataset.setReportingEnabled(true); + poolManager.changeCollectionInterval(txDataset.getSid(), 10.0); + poolManager.changeCollectionInterval(temperatureSet.getSid(), 5.0); if (internalState == InternalState::IDLE) { transitionCommandPending = false; commandExecuted = false; @@ -760,6 +763,8 @@ void SyrlinksHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) { return false; }; auto txStandbyHandler = [&]() { + txDataset.setReportingEnabled(false); + poolManager.changeCollectionInterval(temperatureSet.getSid(), 60.0); if (internalState == InternalState::IDLE) { transitionCommandPending = false; internalState = InternalState::SET_TX_STANDBY; -- 2.43.0 From 8d4b980c32386ef6de4d3205baa7b899cb2a9f21 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 4 Apr 2023 16:46:07 +0200 Subject: [PATCH 2/7] this should fix some bugs --- bsp_q7s/core/scheduling.cpp | 2 +- mission/com/SyrlinksHandler.cpp | 165 +++++++++++++++----------------- mission/com/SyrlinksHandler.h | 13 ++- mission/pollingSeqTables.cpp | 36 +------ 4 files changed, 89 insertions(+), 127 deletions(-) diff --git a/bsp_q7s/core/scheduling.cpp b/bsp_q7s/core/scheduling.cpp index 2d767687..e248938a 100644 --- a/bsp_q7s/core/scheduling.cpp +++ b/bsp_q7s/core/scheduling.cpp @@ -538,7 +538,7 @@ void scheduling::createPstTasks(TaskFactory& factory, TaskDeadlineMissedFunction FixedTimeslotTaskIF* gomSpacePstTask = factory.createFixedTimeslotTask("GS_PST_TASK", 65, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, - 0.5, missedDeadlineFunc, &RR_SCHEDULING); + 0.25, missedDeadlineFunc, &RR_SCHEDULING); result = pst::pstGompaceCan(gomSpacePstTask); if (result != returnvalue::OK) { if (result != FixedTimeslotTaskIF::SLOT_LIST_EMPTY) { diff --git a/mission/com/SyrlinksHandler.cpp b/mission/com/SyrlinksHandler.cpp index 92546194..0b536be2 100644 --- a/mission/com/SyrlinksHandler.cpp +++ b/mission/com/SyrlinksHandler.cpp @@ -21,15 +21,14 @@ SyrlinksHandler::~SyrlinksHandler() = default; void SyrlinksHandler::doStartUp() { if (internalState == InternalState::OFF) { - transitionCommandPending = false; internalState = InternalState::ENABLE_TEMPERATURE_PROTECTION; commandExecuted = false; } if (internalState == InternalState::ENABLE_TEMPERATURE_PROTECTION) { if (commandExecuted) { // Go to normal mode immediately and disable transmitter on startup. - setMode(_MODE_TO_NORMAL); - internalState = InternalState::IDLE; + setMode(_MODE_TO_ON); + internalState = InternalState::TX_TRANSITION; commandExecuted = false; } } @@ -37,15 +36,16 @@ void SyrlinksHandler::doStartUp() { void SyrlinksHandler::doShutDown() { // In any case, always disable TX first. - if (internalState != InternalState::SET_TX_STANDBY) { - internalState = InternalState::SET_TX_STANDBY; - transitionCommandPending = false; + if (internalState != InternalState::TX_TRANSITION) { + internalState = InternalState::TX_TRANSITION; + transState = TransitionState::SET_TX_STANDBY; commandExecuted = false; } - if (internalState == InternalState::SET_TX_STANDBY) { + if (internalState == InternalState::TX_TRANSITION) { if (commandExecuted) { temperatureSet.setValidity(false, true); internalState = InternalState::OFF; + transState = TransitionState::IDLE; commandExecuted = false; setMode(_MODE_POWER_DOWN); } @@ -104,25 +104,32 @@ ReturnValue_t SyrlinksHandler::buildTransitionDeviceCommand(DeviceCommandId_t* i *id = syrlinks::WRITE_LCL_CONFIG; return buildCommandFromCommand(*id, nullptr, 0); } - case InternalState::SET_TX_MODULATION: { - *id = syrlinks::SET_TX_MODE_MODULATION; - return buildCommandFromCommand(*id, nullptr, 0); - } - case InternalState::SELECT_MODULATION_BPSK: { - *id = syrlinks::SET_WAVEFORM_BPSK; - return buildCommandFromCommand(*id, nullptr, 0); - } - case InternalState::SELECT_MODULATION_0QPSK: { - *id = syrlinks::SET_WAVEFORM_0QPSK; - return buildCommandFromCommand(*id, nullptr, 0); - } - case InternalState::SET_TX_CW: { - *id = syrlinks::SET_TX_MODE_CW; - return buildCommandFromCommand(*id, nullptr, 0); - } - case InternalState::SET_TX_STANDBY: { - *id = syrlinks::SET_TX_MODE_STANDBY; - return buildCommandFromCommand(*id, nullptr, 0); + case InternalState::TX_TRANSITION: { + switch (transState) { + case TransitionState::SET_TX_MODULATION: { + *id = syrlinks::SET_TX_MODE_MODULATION; + return buildCommandFromCommand(*id, nullptr, 0); + } + case TransitionState::SELECT_MODULATION_BPSK: { + *id = syrlinks::SET_WAVEFORM_BPSK; + return buildCommandFromCommand(*id, nullptr, 0); + } + case TransitionState::SELECT_MODULATION_0QPSK: { + *id = syrlinks::SET_WAVEFORM_0QPSK; + return buildCommandFromCommand(*id, nullptr, 0); + } + case TransitionState::SET_TX_CW: { + *id = syrlinks::SET_TX_MODE_CW; + return buildCommandFromCommand(*id, nullptr, 0); + } + case TransitionState::SET_TX_STANDBY: { + *id = syrlinks::SET_TX_MODE_STANDBY; + return buildCommandFromCommand(*id, nullptr, 0); + } + default: { + break; + } + } } default: { break; @@ -675,12 +682,31 @@ ReturnValue_t SyrlinksHandler::handleAckReply(const uint8_t* packet) { break; } case (syrlinks::SET_WAVEFORM_BPSK): - case (syrlinks::SET_WAVEFORM_0QPSK): - case (syrlinks::SET_TX_MODE_STANDBY): - case (syrlinks::SET_TX_MODE_MODULATION): + case (syrlinks::SET_WAVEFORM_0QPSK): { + if (result == returnvalue::OK and isTransitionalMode()) { + transState = TransitionState::SET_TX_MODULATION; + commandExecuted = true; + } + break; + } + case (syrlinks::SET_TX_MODE_STANDBY): { + if (result == returnvalue::OK and isTransitionalMode()) { + transState = TransitionState::DONE; + commandExecuted = true; + } + break; + } + case (syrlinks::SET_TX_MODE_MODULATION): { + if (result == returnvalue::OK and isTransitionalMode()) { + transState = TransitionState::DONE; + commandExecuted = true; + } + break; + } case (syrlinks::SET_TX_MODE_CW): { if (result == returnvalue::OK and isTransitionalMode()) { commandExecuted = true; + transState = TransitionState::DONE; } break; } @@ -731,77 +757,41 @@ void SyrlinksHandler::setDebugMode(bool enable) { this->debugMode = enable; } void SyrlinksHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) { Mode_t tgtMode = getBaseMode(getMode()); - auto commandDone = [&]() { + if (transState == TransitionState::DONE) { setMode(tgtMode); - transitionCommandPending = false; internalState = InternalState::IDLE; - }; - auto txOnHandler = [&](InternalState selMod) { - txDataset.setReportingEnabled(true); - poolManager.changeCollectionInterval(txDataset.getSid(), 10.0); - poolManager.changeCollectionInterval(temperatureSet.getSid(), 5.0); - if (internalState == InternalState::IDLE) { - transitionCommandPending = false; - commandExecuted = false; - internalState = selMod; - } - // Select modulation first (BPSK or 0QPSK). - if (internalState == selMod) { - if (commandExecuted) { - transitionCommandPending = false; - internalState = InternalState::SET_TX_MODULATION; - commandExecuted = false; - } - } - // Now go into modulation mode. - if (internalState == InternalState::SET_TX_MODULATION) { - if (commandExecuted) { - commandDone(); - return true; - } - } - return false; - }; + transState = TransitionState::IDLE; + return; + } auto txStandbyHandler = [&]() { txDataset.setReportingEnabled(false); poolManager.changeCollectionInterval(temperatureSet.getSid(), 60.0); - if (internalState == InternalState::IDLE) { - transitionCommandPending = false; - internalState = InternalState::SET_TX_STANDBY; - commandExecuted = false; - } - if (internalState == InternalState::SET_TX_STANDBY) { - if (commandExecuted) { - commandDone(); - return; - } - } + }; + auto txOnHandler = [&]() { + txDataset.setReportingEnabled(true); + poolManager.changeCollectionInterval(txDataset.getSid(), 10.0); + poolManager.changeCollectionInterval(temperatureSet.getSid(), 5.0); }; if (tgtMode == HasModesIF::MODE_ON or tgtMode == DeviceHandlerIF::MODE_NORMAL) { switch (getSubmode()) { case (com::Submode::RX_AND_TX_DEFAULT_DATARATE): { auto currentDatarate = com::getCurrentDatarate(); + txOnHandler(); if (currentDatarate == com::Datarate::LOW_RATE_MODULATION_BPSK) { - if (txOnHandler(InternalState::SELECT_MODULATION_BPSK)) { - return; - } + transState = TransitionState::SELECT_MODULATION_BPSK; } else if (currentDatarate == com::Datarate::HIGH_RATE_MODULATION_0QPSK) { - if (txOnHandler(InternalState::SELECT_MODULATION_0QPSK)) { - return; - } + transState = TransitionState::SELECT_MODULATION_0QPSK; } break; } case (com::Submode::RX_AND_TX_LOW_DATARATE): { - if (txOnHandler(InternalState::SELECT_MODULATION_BPSK)) { - return; - } + txOnHandler(); + transState = TransitionState::SELECT_MODULATION_BPSK; break; } case (com::Submode::RX_AND_TX_HIGH_DATARATE): { - if (txOnHandler(InternalState::SELECT_MODULATION_0QPSK)) { - return; - } + txOnHandler(); + transState = TransitionState::SELECT_MODULATION_0QPSK; break; } case (com::Submode::RX_ONLY): { @@ -809,21 +799,16 @@ void SyrlinksHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) { return; } case (com::Submode::RX_AND_TX_CW): { - if (internalState == InternalState::IDLE) { - internalState = InternalState::SET_TX_STANDBY; - commandExecuted = false; - } - if (commandExecuted) { - commandDone(); - return; - } + txOnHandler(); + transState = TransitionState::SET_TX_CW; break; } default: { - commandDone(); + DeviceHandlerBase::doTransition(modeFrom, subModeFrom); } } } else if (tgtMode == HasModesIF::MODE_OFF) { txStandbyHandler(); + transState = TransitionState::SET_TX_STANDBY; } } diff --git a/mission/com/SyrlinksHandler.h b/mission/com/SyrlinksHandler.h index 97541ecb..44427085 100644 --- a/mission/com/SyrlinksHandler.h +++ b/mission/com/SyrlinksHandler.h @@ -112,22 +112,25 @@ class SyrlinksHandler : public DeviceHandlerBase { float tempPowerAmplifier = 0; float tempBasebandBoard = 0; bool commandExecuted = false; - bool transitionCommandPending = false; uint8_t commandBuffer[syrlinks::MAX_COMMAND_SIZE]; enum class InternalState { OFF, ENABLE_TEMPERATURE_PROTECTION, + TX_TRANSITION, + IDLE + } internalState = InternalState::OFF; + + enum class TransitionState { + IDLE, SELECT_MODULATION_BPSK, SELECT_MODULATION_0QPSK, SET_TX_MODULATION, SET_TX_CW, SET_TX_STANDBY, - IDLE - }; - - InternalState internalState = InternalState::OFF; + DONE + } transState = TransitionState::IDLE; /** * This object is used to store the id of the next command to execute. This controls the diff --git a/mission/pollingSeqTables.cpp b/mission/pollingSeqTables.cpp index 574cc9c1..7e444acd 100644 --- a/mission/pollingSeqTables.cpp +++ b/mission/pollingSeqTables.cpp @@ -26,8 +26,7 @@ ReturnValue_t pst::pstSyrlinks(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::SYRLINKS_HANDLER, length * 0, DeviceHandlerIF::GET_WRITE); thisSequence->addSlot(objects::SYRLINKS_HANDLER, length * 0.25, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::SYRLINKS_HANDLER, length * 0.25, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::SYRLINKS_HANDLER, length * 0.4, - DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SYRLINKS_HANDLER, length * 0.4, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::SYRLINKS_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); thisSequence->addSlot(objects::SYRLINKS_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); @@ -119,35 +118,10 @@ ReturnValue_t pst::pstGompaceCan(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.25, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::ACU_HANDLER, length * 0.25, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0.25, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.25, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.25, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::ACU_HANDLER, length * 0.25, DeviceHandlerIF::GET_READ); - - thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0.5, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.5, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.5, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::ACU_HANDLER, length * 0.5, DeviceHandlerIF::PERFORM_OPERATION); - - thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0.5, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.5, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.5, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::ACU_HANDLER, length * 0.5, DeviceHandlerIF::SEND_WRITE); - - thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0.5, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.5, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.5, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::ACU_HANDLER, length * 0.5, DeviceHandlerIF::GET_WRITE); - - thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::ACU_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); - - thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0.75, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.75, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.75, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::ACU_HANDLER, length * 0.75, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0.5, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.5, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.5, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::ACU_HANDLER, length * 0.5, DeviceHandlerIF::GET_READ); if (thisSequence->checkSequence() != returnvalue::OK) { sif::error << "GomSpace PST initialization failed" << std::endl; return returnvalue::FAILED; -- 2.43.0 From 104a8cab3359eea414a7ee84bda3152e4fdf238f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 4 Apr 2023 17:49:01 +0200 Subject: [PATCH 3/7] seems to work now --- mission/com/SyrlinksHandler.cpp | 42 ++++++++++++++++++++------------- mission/com/SyrlinksHandler.h | 2 +- tmtc | 2 +- 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/mission/com/SyrlinksHandler.cpp b/mission/com/SyrlinksHandler.cpp index 0b536be2..352781a6 100644 --- a/mission/com/SyrlinksHandler.cpp +++ b/mission/com/SyrlinksHandler.cpp @@ -99,9 +99,13 @@ ReturnValue_t SyrlinksHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { } ReturnValue_t SyrlinksHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { + if(transState == TransitionState::CMD_PENDING or transState == TransitionState::DONE) { + return NOTHING_TO_SEND; + } switch (internalState) { case InternalState::ENABLE_TEMPERATURE_PROTECTION: { *id = syrlinks::WRITE_LCL_CONFIG; + transState = TransitionState::CMD_PENDING; return buildCommandFromCommand(*id, nullptr, 0); } case InternalState::TX_TRANSITION: { @@ -127,9 +131,11 @@ ReturnValue_t SyrlinksHandler::buildTransitionDeviceCommand(DeviceCommandId_t* i return buildCommandFromCommand(*id, nullptr, 0); } default: { - break; + return NOTHING_TO_SEND; } } + transState = TransitionState::CMD_PENDING; + break; } default: { break; @@ -629,8 +635,6 @@ void SyrlinksHandler::parseAgcHighByte(const uint8_t* packet) { agcValueHighByte = convertHexStringToUint8(reinterpret_cast(packet + offset)); } -void SyrlinksHandler::setNormalDatapoolEntriesInvalid() {} - uint32_t SyrlinksHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 2500; } ReturnValue_t SyrlinksHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, @@ -663,7 +667,7 @@ ReturnValue_t SyrlinksHandler::initializeLocalDataPool(localpool::DataPool& loca return returnvalue::OK; } -void SyrlinksHandler::setModeNormal() { setMode(MODE_NORMAL); } +void SyrlinksHandler::setModeNormal() { setMode(_MODE_TO_NORMAL); } float SyrlinksHandler::calcTempVal(uint16_t raw) { return 0.126984 * raw - 67.87; } @@ -730,7 +734,7 @@ ReturnValue_t SyrlinksHandler::handleAckReply(const uint8_t* packet) { ReturnValue_t SyrlinksHandler::isModeCombinationValid(Mode_t mode, Submode_t submode) { if (mode == HasModesIF::MODE_ON or mode == DeviceHandlerIF::MODE_NORMAL) { - if (submode >= com::Submode::NUM_SUBMODES) { + if (submode >= com::Submode::NUM_SUBMODES or submode < com::Submode::RX_ONLY) { return HasModesIF::INVALID_SUBMODE; } return returnvalue::OK; @@ -758,40 +762,44 @@ void SyrlinksHandler::setDebugMode(bool enable) { this->debugMode = enable; } void SyrlinksHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) { Mode_t tgtMode = getBaseMode(getMode()); if (transState == TransitionState::DONE) { - setMode(tgtMode); internalState = InternalState::IDLE; transState = TransitionState::IDLE; + DeviceHandlerBase::doTransition(modeFrom, subModeFrom); return; } auto txStandbyHandler = [&]() { txDataset.setReportingEnabled(false); poolManager.changeCollectionInterval(temperatureSet.getSid(), 60.0); + transState = TransitionState::SET_TX_STANDBY; + internalState = InternalState::TX_TRANSITION; }; - auto txOnHandler = [&]() { + auto txOnHandler = [&](TransitionState tgtTransitionState) { txDataset.setReportingEnabled(true); poolManager.changeCollectionInterval(txDataset.getSid(), 10.0); poolManager.changeCollectionInterval(temperatureSet.getSid(), 5.0); + internalState = InternalState::TX_TRANSITION; + transState = tgtTransitionState; }; if (tgtMode == HasModesIF::MODE_ON or tgtMode == DeviceHandlerIF::MODE_NORMAL) { + if(getSubmode() == subModeFrom) { + DeviceHandlerBase::doTransition(modeFrom, subModeFrom); + } switch (getSubmode()) { case (com::Submode::RX_AND_TX_DEFAULT_DATARATE): { auto currentDatarate = com::getCurrentDatarate(); - txOnHandler(); if (currentDatarate == com::Datarate::LOW_RATE_MODULATION_BPSK) { - transState = TransitionState::SELECT_MODULATION_BPSK; + txOnHandler(TransitionState::SELECT_MODULATION_BPSK); } else if (currentDatarate == com::Datarate::HIGH_RATE_MODULATION_0QPSK) { - transState = TransitionState::SELECT_MODULATION_0QPSK; + txOnHandler(TransitionState::SELECT_MODULATION_0QPSK); } break; } case (com::Submode::RX_AND_TX_LOW_DATARATE): { - txOnHandler(); - transState = TransitionState::SELECT_MODULATION_BPSK; + txOnHandler(TransitionState::SELECT_MODULATION_BPSK); break; } case (com::Submode::RX_AND_TX_HIGH_DATARATE): { - txOnHandler(); - transState = TransitionState::SELECT_MODULATION_0QPSK; + txOnHandler(TransitionState::SELECT_MODULATION_0QPSK); break; } case (com::Submode::RX_ONLY): { @@ -799,16 +807,16 @@ void SyrlinksHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) { return; } case (com::Submode::RX_AND_TX_CW): { - txOnHandler(); - transState = TransitionState::SET_TX_CW; + txOnHandler(TransitionState::SET_TX_CW); break; } default: { + sif::error << "SyrlinksHandler: Unexpected submode " << getSubmode() << std::endl; DeviceHandlerBase::doTransition(modeFrom, subModeFrom); } } } else if (tgtMode == HasModesIF::MODE_OFF) { txStandbyHandler(); - transState = TransitionState::SET_TX_STANDBY; } + DeviceHandlerBase::doTransition(modeFrom, subModeFrom); } diff --git a/mission/com/SyrlinksHandler.h b/mission/com/SyrlinksHandler.h index 44427085..2c9d620f 100644 --- a/mission/com/SyrlinksHandler.h +++ b/mission/com/SyrlinksHandler.h @@ -46,7 +46,6 @@ class SyrlinksHandler : public DeviceHandlerBase { size_t* foundLen) override; ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) override; ReturnValue_t getSwitches(const uint8_t** switches, uint8_t* numberOfSwitches) override; - void setNormalDatapoolEntriesInvalid() override; uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) override; @@ -129,6 +128,7 @@ class SyrlinksHandler : public DeviceHandlerBase { SET_TX_MODULATION, SET_TX_CW, SET_TX_STANDBY, + CMD_PENDING, DONE } transState = TransitionState::IDLE; diff --git a/tmtc b/tmtc index 6975fae5..50668ca7 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 6975fae511ca7b2fdef70858f8715908f300f434 +Subproject commit 50668ca7a74edd4219456e393cd10f7858591130 -- 2.43.0 From 697dcab345477c82bab58446e1d06164fec95c3d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 4 Apr 2023 17:52:03 +0200 Subject: [PATCH 4/7] changelog --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 206b2fff..baa91398 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,16 @@ will consitute of a breaking change warranting a new major release: # [unreleased] +## Fixed + +- Generic HK handling: Bug where HKs were generated a lot more often than required. This is the case + if a device handler `PERFORM_OPERATION` step is performed more than once per PST cycle. + +## Changed + +- Doubled GS PST interval instead of scheduling everything twice. +- Syrlinks now only has one `PERFORM_OPERATION` step, but still has two communication steps. + # [v1.43.0] 2023-04-04 - q7s-package: v2.4.0 -- 2.43.0 From 04178b8831498198830f083c982aa0e58a34a598 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 4 Apr 2023 18:04:09 +0200 Subject: [PATCH 5/7] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7717a230..5ec0f9e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ will consitute of a breaking change warranting a new major release: - Generic HK handling: Bug where HKs were generated a lot more often than required. This is the case if a device handler `PERFORM_OPERATION` step is performed more than once per PST cycle. +- Syrlinks now goes to `_MODE_TO_ON` when finishing the `doStartUp` transition. ## Changed -- 2.43.0 From 57b41701ce380401dd3f45a0d9c46033b73a3288 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 4 Apr 2023 20:34:28 +0200 Subject: [PATCH 6/7] hopefully those were the last fixes --- bsp_q7s/core/ObjectFactory.cpp | 2 +- mission/com/SyrlinksHandler.cpp | 27 +++++++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 3f29de5e..3b71c6cd 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -62,9 +62,9 @@ #include "mission/system/acs/acsModeTree.h" #include "mission/system/com/SyrlinksFdir.h" #include "mission/system/com/comModeTree.h" -#include "mission/system/power/GomspacePowerFdir.h" #include "mission/system/fdir/RtdFdir.h" #include "mission/system/objects/TcsBoardAssembly.h" +#include "mission/system/power/GomspacePowerFdir.h" #include "mission/system/tree/payloadModeTree.h" #include "mission/system/tree/tcsModeTree.h" #include "mission/tmtc/tmFilters.h" diff --git a/mission/com/SyrlinksHandler.cpp b/mission/com/SyrlinksHandler.cpp index 352781a6..1ee490a7 100644 --- a/mission/com/SyrlinksHandler.cpp +++ b/mission/com/SyrlinksHandler.cpp @@ -28,7 +28,8 @@ void SyrlinksHandler::doStartUp() { if (commandExecuted) { // Go to normal mode immediately and disable transmitter on startup. setMode(_MODE_TO_ON); - internalState = InternalState::TX_TRANSITION; + internalState = InternalState::IDLE; + transState = TransitionState::IDLE; commandExecuted = false; } } @@ -99,7 +100,7 @@ ReturnValue_t SyrlinksHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { } ReturnValue_t SyrlinksHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { - if(transState == TransitionState::CMD_PENDING or transState == TransitionState::DONE) { + if (transState == TransitionState::CMD_PENDING or transState == TransitionState::DONE) { return NOTHING_TO_SEND; } switch (internalState) { @@ -761,11 +762,13 @@ void SyrlinksHandler::setDebugMode(bool enable) { this->debugMode = enable; } void SyrlinksHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) { Mode_t tgtMode = getBaseMode(getMode()); - if (transState == TransitionState::DONE) { + auto doneHandler = [&]() { internalState = InternalState::IDLE; transState = TransitionState::IDLE; DeviceHandlerBase::doTransition(modeFrom, subModeFrom); - return; + }; + if (transState == TransitionState::DONE) { + return doneHandler(); } auto txStandbyHandler = [&]() { txDataset.setReportingEnabled(false); @@ -777,13 +780,20 @@ void SyrlinksHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) { txDataset.setReportingEnabled(true); poolManager.changeCollectionInterval(txDataset.getSid(), 10.0); poolManager.changeCollectionInterval(temperatureSet.getSid(), 5.0); - internalState = InternalState::TX_TRANSITION; transState = tgtTransitionState; + internalState = InternalState::TX_TRANSITION; }; + if (tgtMode == HasModesIF::MODE_ON or tgtMode == DeviceHandlerIF::MODE_NORMAL) { - if(getSubmode() == subModeFrom) { - DeviceHandlerBase::doTransition(modeFrom, subModeFrom); + // If submode has not changed, no special transition handling necessary. + if (getSubmode() == subModeFrom) { + return doneHandler(); } + // Transition is on-going, wait for it to finish. + if (transState != TransitionState::IDLE) { + return; + } + // Transition start logic. switch (getSubmode()) { case (com::Submode::RX_AND_TX_DEFAULT_DATARATE): { auto currentDatarate = com::getCurrentDatarate(); @@ -817,6 +827,7 @@ void SyrlinksHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) { } } else if (tgtMode == HasModesIF::MODE_OFF) { txStandbyHandler(); + } else { + return doneHandler(); } - DeviceHandlerBase::doTransition(modeFrom, subModeFrom); } -- 2.43.0 From c835b31e7fdd582dcccebd1c6bf809dc124981c1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 4 Apr 2023 20:36:52 +0200 Subject: [PATCH 7/7] minor fix --- mission/pollingSeqTables.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mission/pollingSeqTables.cpp b/mission/pollingSeqTables.cpp index 7e444acd..0367ef27 100644 --- a/mission/pollingSeqTables.cpp +++ b/mission/pollingSeqTables.cpp @@ -113,10 +113,10 @@ ReturnValue_t pst::pstGompaceCan(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::PDU2_HANDLER, length * 0, DeviceHandlerIF::GET_WRITE); thisSequence->addSlot(objects::ACU_HANDLER, length * 0, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0.25, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.25, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.25, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::ACU_HANDLER, length * 0.25, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0.5, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.5, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.5, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::ACU_HANDLER, length * 0.5, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::P60DOCK_HANDLER, length * 0.5, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.5, DeviceHandlerIF::GET_READ); -- 2.43.0