extend syrlinks code a bit
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
Robin Müller 2023-01-25 17:02:46 +01:00
parent a4bf6d9872
commit b879533d41
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
4 changed files with 73 additions and 17 deletions

View File

@ -674,6 +674,16 @@ ReturnValue_t SyrlinksHandler::handleAckReply(const uint8_t* packet) {
return result;
}
ReturnValue_t SyrlinksHandler::isModeCombinationValid(Mode_t mode, Submode_t submode) {
if (mode == HasModesIF::MODE_ON or mode == DeviceHandlerIF::MODE_NORMAL) {
if (submode >= syrlinks::Submode::NUM_SUBMODES) {
return HasModesIF::INVALID_SUBMODE;
}
return returnvalue::OK;
}
return DeviceHandlerBase::isModeCombinationValid(mode, submode);
}
void SyrlinksHandler::prepareCommand(std::string command, DeviceCommandId_t commandId) {
command.copy(reinterpret_cast<char*>(commandBuffer), command.size(), 0);
rawPacketLen = command.size();
@ -685,37 +695,79 @@ void SyrlinksHandler::setDebugMode(bool enable) { this->debugMode = enable; }
void SyrlinksHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {
Mode_t tgtMode = getBaseMode(getMode());
auto commandDone = [&]() {
setMode(tgtMode);
internalState = InternalState::IDLE;
};
if (tgtMode == HasModesIF::MODE_ON or tgtMode == DeviceHandlerIF::MODE_NORMAL) {
switch (getSubmode()) {
case (syrlinks::Submode::TX_MODULATION): {
if (commandExecuted) {
setMode(tgtMode);
return;
case (syrlinks::Submode::TX_MODULATION_LOW_DATARATE): {
if (internalState == InternalState::IDLE) {
commandExecuted = false;
internalState = InternalState::SELECT_MODULATION_QPSK;
}
if (internalState == InternalState::SELECT_MODULATION_QPSK) {
if (commandExecuted) {
internalState = InternalState::SET_TX_MODULATION;
commandExecuted = false;
}
}
if (internalState == InternalState::SET_TX_MODULATION) {
if (commandExecuted) {
commandDone();
return;
}
}
break;
}
case (syrlinks::Submode::TX_MODULATION_HIGH_DATARATE): {
if (internalState == InternalState::IDLE) {
commandExecuted = false;
internalState = InternalState::SELECT_MODULATION_0BPSK;
}
if (internalState == InternalState::SELECT_MODULATION_0BPSK) {
if (commandExecuted) {
internalState = InternalState::SET_TX_MODULATION;
commandExecuted = false;
}
}
if (internalState == InternalState::SET_TX_MODULATION) {
if (commandExecuted) {
commandDone();
return;
}
}
internalState = InternalState::SET_TX_MODULATION;
break;
}
case (syrlinks::Submode::TX_STANDBY): {
if (commandExecuted) {
setMode(tgtMode);
return;
if (internalState == InternalState::IDLE) {
internalState = InternalState::SET_TX_STANDBY;
commandExecuted = false;
}
if (internalState == InternalState::SET_TX_STANDBY) {
if (commandExecuted) {
commandDone();
return;
}
}
internalState = InternalState::SET_TX_STANDBY;
break;
}
case (syrlinks::Submode::TX_CW): {
if (internalState == InternalState::IDLE) {
internalState = InternalState::SET_TX_STANDBY;
commandExecuted = false;
}
if (commandExecuted) {
setMode(tgtMode);
commandDone();
return;
}
internalState = InternalState::SET_TX_CW;
break;
}
default: {
setMode(tgtMode);
commandDone();
}
}
} else {
setMode(tgtMode);
commandDone();
}
}

View File

@ -35,6 +35,7 @@ class SyrlinksHandler : public DeviceHandlerBase {
void doStartUp() override;
void doShutDown() override;
void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override;
ReturnValue_t isModeCombinationValid(Mode_t mode, Submode_t submode) override;
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override;
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t* id) override;
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t* commandData,
@ -112,6 +113,8 @@ class SyrlinksHandler : public DeviceHandlerBase {
enum class InternalState {
OFF,
ENABLE_TEMPERATURE_PROTECTION,
SELECT_MODULATION_0BPSK,
SELECT_MODULATION_QPSK,
SET_TX_MODULATION,
SET_TX_CW,
SET_TX_STANDBY,

View File

@ -9,9 +9,10 @@ namespace syrlinks {
enum Submode {
DEFAULT,
TX_STANDBY,
TX_MODULATION,
// TODO: Is this needed?
TX_CW
TX_MODULATION_LOW_DATARATE,
TX_MODULATION_HIGH_DATARATE,
TX_CW,
NUM_SUBMODES
};
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SYRLINKS;

2
tmtc

@ -1 +1 @@
Subproject commit 49ccb4be8d42d6916be00ff9d8462a1f65481a6c
Subproject commit 8a7880bc35d1069577b7e0427c1f45c54ac5241c