From 4dca9f21d45f7bef151c8c2811f12c5e81a355d6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 26 Jan 2023 14:00:39 +0100 Subject: [PATCH] add new submode for default datarate handling --- mission/comDefs.h | 10 ++ mission/devices/SyrlinksHandler.cpp | 95 ++++++++++--------- mission/devices/SyrlinksHandler.h | 2 + .../devicedefinitions/SyrlinksDefinitions.h | 9 +- tmtc | 2 +- 5 files changed, 69 insertions(+), 49 deletions(-) create mode 100644 mission/comDefs.h diff --git a/mission/comDefs.h b/mission/comDefs.h new file mode 100644 index 00000000..24f8ae88 --- /dev/null +++ b/mission/comDefs.h @@ -0,0 +1,10 @@ +#ifndef MISSION_COMDEFS_H_ +#define MISSION_COMDEFS_H_ + +namespace com { + +enum class Datarate { LOW_RATE_MODULATION_BPSK, HIGH_RATE_MODULATION_0QPSK }; + +} + +#endif /* MISSION_COMDEFS_H_ */ diff --git a/mission/devices/SyrlinksHandler.cpp b/mission/devices/SyrlinksHandler.cpp index 60f32e3f..e3b89de6 100644 --- a/mission/devices/SyrlinksHandler.cpp +++ b/mission/devices/SyrlinksHandler.cpp @@ -19,17 +19,17 @@ SyrlinksHandler::SyrlinksHandler(object_id_t objectId, object_id_t comIF, Cookie SyrlinksHandler::~SyrlinksHandler() = default; void SyrlinksHandler::doStartUp() { - if(internalState != InternalState::OFF) { + if (internalState != InternalState::OFF) { sif::error << "SyrlinksHandler::doStartUp: Not in internal OFF mode, possible config error" - << std::endl; + << std::endl; internalState = InternalState::OFF; } - if(internalState == InternalState::OFF) { - internalState = InternalState::ENABLE_TEMPERATURE_PROTECTION; - commandExecuted = false; + if (internalState == InternalState::OFF) { + internalState = InternalState::ENABLE_TEMPERATURE_PROTECTION; + commandExecuted = false; } - if(internalState == InternalState::ENABLE_TEMPERATURE_PROTECTION) { - if(commandExecuted) { + if (internalState == InternalState::ENABLE_TEMPERATURE_PROTECTION) { + if (commandExecuted) { // Got to normal mode immediately. setMode(_MODE_TO_NORMAL); internalState = InternalState::IDLE; @@ -222,10 +222,10 @@ void SyrlinksHandler::fillCommandAndReplyMap() { true, syrlinks::ACK_REPLY); this->insertInCommandAndReplyMap(syrlinks::WRITE_LCL_CONFIG, 1, nullptr, syrlinks::ACK_SIZE, false, true, syrlinks::ACK_REPLY); - this->insertInCommandAndReplyMap(syrlinks::SET_WAVEFORM_BPSK, 1, nullptr, syrlinks::ACK_SIZE, false, - true, syrlinks::ACK_REPLY); - this->insertInCommandAndReplyMap(syrlinks::SET_WAVEFORM_0QPSK, 1, nullptr, syrlinks::ACK_SIZE, false, - true, syrlinks::ACK_REPLY); + this->insertInCommandAndReplyMap(syrlinks::SET_WAVEFORM_BPSK, 1, nullptr, syrlinks::ACK_SIZE, + false, true, syrlinks::ACK_REPLY); + this->insertInCommandAndReplyMap(syrlinks::SET_WAVEFORM_0QPSK, 1, nullptr, syrlinks::ACK_SIZE, + false, true, syrlinks::ACK_REPLY); this->insertInCommandMap(syrlinks::ENABLE_DEBUG); this->insertInCommandMap(syrlinks::DISABLE_DEBUG); this->insertInCommandAndReplyMap(syrlinks::READ_LCL_CONFIG, 1, nullptr, @@ -661,8 +661,8 @@ ReturnValue_t SyrlinksHandler::handleAckReply(const uint8_t* packet) { } break; } - case(syrlinks::SET_WAVEFORM_BPSK): - case(syrlinks::SET_WAVEFORM_0QPSK): + 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_TX_MODE_CW): { @@ -700,47 +700,54 @@ void SyrlinksHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) { setMode(tgtMode); internalState = InternalState::IDLE; }; + auto txOnHandler = [&](InternalState selMod) { + if (internalState == InternalState::IDLE) { + commandExecuted = false; + internalState = selMod; + } + // Select modulation first (BPSK or 0QPSK). + if (internalState == selMod) { + if (commandExecuted) { + 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; + }; if (tgtMode == HasModesIF::MODE_ON or tgtMode == DeviceHandlerIF::MODE_NORMAL) { switch (getSubmode()) { - case (syrlinks::Submode::TX_MODULATION_LOW_DATARATE): { - if (internalState == InternalState::IDLE) { - commandExecuted = false; - internalState = InternalState::SELECT_MODULATION_BPSK; - } - if (internalState == InternalState::SELECT_MODULATION_BPSK) { - if (commandExecuted) { - internalState = InternalState::SET_TX_MODULATION; - commandExecuted = false; + case (syrlinks::Submode::RX_AND_TX_DEFAULT_DATARATE): { + if (datarateCfg == com::Datarate::LOW_RATE_MODULATION_BPSK) { + if (txOnHandler(InternalState::SELECT_MODULATION_BPSK)) { + return; } - } - if (internalState == InternalState::SET_TX_MODULATION) { - if (commandExecuted) { - commandDone(); + } else if (datarateCfg == com::Datarate::HIGH_RATE_MODULATION_0QPSK) { + if (txOnHandler(InternalState::SELECT_MODULATION_0QPSK)) { return; } } break; } - case (syrlinks::Submode::TX_MODULATION_HIGH_DATARATE): { - if (internalState == InternalState::IDLE) { - commandExecuted = false; - internalState = InternalState::SELECT_MODULATION_0QPSK; - } - if (internalState == InternalState::SELECT_MODULATION_0QPSK) { - if (commandExecuted) { - internalState = InternalState::SET_TX_MODULATION; - commandExecuted = false; - } - } - if (internalState == InternalState::SET_TX_MODULATION) { - if (commandExecuted) { - commandDone(); - return; - } + case (syrlinks::Submode::RX_AND_TX_LOW_DATARATE): { + if (txOnHandler(InternalState::SELECT_MODULATION_BPSK)) { + return; } break; } - case (syrlinks::Submode::TX_STANDBY): { + case (syrlinks::Submode::RX_AND_TX_HIGH_DATARATE): { + if (txOnHandler(InternalState::SELECT_MODULATION_0QPSK)) { + return; + } + break; + } + case (syrlinks::Submode::RX_ONLY): { if (internalState == InternalState::IDLE) { internalState = InternalState::SET_TX_STANDBY; commandExecuted = false; @@ -753,7 +760,7 @@ void SyrlinksHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) { } break; } - case (syrlinks::Submode::TX_CW): { + case (syrlinks::Submode::RX_AND_TX_CW): { if (internalState == InternalState::IDLE) { internalState = InternalState::SET_TX_STANDBY; commandExecuted = false; diff --git a/mission/devices/SyrlinksHandler.h b/mission/devices/SyrlinksHandler.h index c2405502..bd6e8a62 100644 --- a/mission/devices/SyrlinksHandler.h +++ b/mission/devices/SyrlinksHandler.h @@ -7,6 +7,7 @@ #include "fsfw/devicehandlers/DeviceHandlerBase.h" #include "fsfw/timemanager/Countdown.h" #include "fsfw_hal/linux/gpio/Gpio.h" +#include "mission/comDefs.h" #include "mission/devices/devicedefinitions/SyrlinksDefinitions.h" #include "returnvalues/classIds.h" @@ -99,6 +100,7 @@ class SyrlinksHandler : public DeviceHandlerBase { syrlinks::TemperatureSet temperatureSet; const power::Switch_t powerSwitch = power::NO_SWITCH; + com::Datarate datarateCfg = com::Datarate::LOW_RATE_MODULATION_BPSK; bool debugMode = false; uint8_t agcValueHighByte = 0; diff --git a/mission/devices/devicedefinitions/SyrlinksDefinitions.h b/mission/devices/devicedefinitions/SyrlinksDefinitions.h index 5b904835..4484ea75 100644 --- a/mission/devices/devicedefinitions/SyrlinksDefinitions.h +++ b/mission/devices/devicedefinitions/SyrlinksDefinitions.h @@ -8,10 +8,11 @@ namespace syrlinks { enum Submode { DEFAULT, - TX_STANDBY, - TX_MODULATION_LOW_DATARATE, - TX_MODULATION_HIGH_DATARATE, - TX_CW, + RX_ONLY, + RX_AND_TX_DEFAULT_DATARATE, + RX_AND_TX_LOW_DATARATE, + RX_AND_TX_HIGH_DATARATE, + RX_AND_TX_CW, NUM_SUBMODES }; diff --git a/tmtc b/tmtc index c36c7ca5..99d5ed01 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit c36c7ca5bbe12b74f096414383eedfc16576a9d2 +Subproject commit 99d5ed014bc3264b621c066ba0fb035b1037a637