add syrlinks submode handling
This commit is contained in:
parent
1f08d85319
commit
ae6f6538d2
@ -56,6 +56,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <mission/devices/ImtqHandler.h>
|
#include <mission/devices/ImtqHandler.h>
|
||||||
#include <mission/devices/PcduHandler.h>
|
#include <mission/devices/PcduHandler.h>
|
||||||
|
#include <mission/devices/SyrlinksHandler.h>
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
@ -88,7 +89,6 @@
|
|||||||
#include "mission/devices/RadiationSensorHandler.h"
|
#include "mission/devices/RadiationSensorHandler.h"
|
||||||
#include "mission/devices/RwHandler.h"
|
#include "mission/devices/RwHandler.h"
|
||||||
#include "mission/devices/SolarArrayDeploymentHandler.h"
|
#include "mission/devices/SolarArrayDeploymentHandler.h"
|
||||||
#include <mission/devices/SyrlinksHandler.h>
|
|
||||||
#include "mission/devices/Tmp1075Handler.h"
|
#include "mission/devices/Tmp1075Handler.h"
|
||||||
#include "mission/devices/devicedefinitions/GomspaceDefinitions.h"
|
#include "mission/devices/devicedefinitions/GomspaceDefinitions.h"
|
||||||
#include "mission/devices/devicedefinitions/Max31865Definitions.h"
|
#include "mission/devices/devicedefinitions/Max31865Definitions.h"
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include <fsfw/datapool/PoolReadGuard.h>
|
#include <fsfw/datapool/PoolReadGuard.h>
|
||||||
#include <fsfw/globalfunctions/CRC.h>
|
#include <fsfw/globalfunctions/CRC.h>
|
||||||
#include <mission/devices/SyrlinksHandler.h>
|
#include <mission/devices/SyrlinksHandler.h>
|
||||||
|
|
||||||
#include "OBSWConfig.h"
|
#include "OBSWConfig.h"
|
||||||
|
|
||||||
SyrlinksHandler::SyrlinksHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie,
|
SyrlinksHandler::SyrlinksHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie,
|
||||||
@ -15,16 +16,17 @@ SyrlinksHandler::SyrlinksHandler(object_id_t objectId, object_id_t comIF, Cookie
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SyrlinksHandler::~SyrlinksHandler() {}
|
SyrlinksHandler::~SyrlinksHandler() = default;
|
||||||
|
|
||||||
void SyrlinksHandler::doStartUp() {
|
void SyrlinksHandler::doStartUp() {
|
||||||
switch (startupState) {
|
switch (internalState) {
|
||||||
case StartupState::OFF: {
|
case InternalState::OFF: {
|
||||||
startupState = StartupState::ENABLE_TEMPERATURE_PROTECTION;
|
internalState = InternalState::ENABLE_TEMPERATURE_PROTECTION;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case StartupState::DONE: {
|
case InternalState::IDLE: {
|
||||||
setMode(_MODE_TO_ON);
|
setMode(_MODE_TO_ON);
|
||||||
|
commandExecuted = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -34,6 +36,8 @@ void SyrlinksHandler::doStartUp() {
|
|||||||
|
|
||||||
void SyrlinksHandler::doShutDown() {
|
void SyrlinksHandler::doShutDown() {
|
||||||
setMode(_MODE_POWER_DOWN);
|
setMode(_MODE_POWER_DOWN);
|
||||||
|
commandExecuted = false;
|
||||||
|
internalState = InternalState::OFF;
|
||||||
temperatureSet.setValidity(false, true);
|
temperatureSet.setValidity(false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,11 +88,23 @@ ReturnValue_t SyrlinksHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t SyrlinksHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
|
ReturnValue_t SyrlinksHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
|
||||||
switch (startupState) {
|
switch (internalState) {
|
||||||
case StartupState::ENABLE_TEMPERATURE_PROTECTION: {
|
case InternalState::ENABLE_TEMPERATURE_PROTECTION: {
|
||||||
*id = syrlinks::WRITE_LCL_CONFIG;
|
*id = syrlinks::WRITE_LCL_CONFIG;
|
||||||
return buildCommandFromCommand(*id, nullptr, 0);
|
return buildCommandFromCommand(*id, nullptr, 0);
|
||||||
}
|
}
|
||||||
|
case InternalState::SET_TX_MODULATION: {
|
||||||
|
*id = syrlinks::SET_TX_MODE_MODULATION;
|
||||||
|
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);
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -624,10 +640,36 @@ float SyrlinksHandler::calcTempVal(uint16_t raw) { return 0.126984 * raw - 67.87
|
|||||||
ReturnValue_t SyrlinksHandler::handleAckReply(const uint8_t* packet) {
|
ReturnValue_t SyrlinksHandler::handleAckReply(const uint8_t* packet) {
|
||||||
ReturnValue_t result =
|
ReturnValue_t result =
|
||||||
parseReplyStatus(reinterpret_cast<const char*>(packet + syrlinks::MESSAGE_HEADER_SIZE));
|
parseReplyStatus(reinterpret_cast<const char*>(packet + syrlinks::MESSAGE_HEADER_SIZE));
|
||||||
if (rememberCommandId == syrlinks::WRITE_LCL_CONFIG and result != returnvalue::OK) {
|
switch (rememberCommandId) {
|
||||||
startupState = StartupState::OFF;
|
case (syrlinks::WRITE_LCL_CONFIG): {
|
||||||
} else if (rememberCommandId == syrlinks::WRITE_LCL_CONFIG and result == returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
startupState = StartupState::DONE;
|
internalState = InternalState::OFF;
|
||||||
|
} else if (result == returnvalue::OK) {
|
||||||
|
internalState = InternalState::IDLE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (syrlinks::SET_TX_MODE_STANDBY): {
|
||||||
|
if (result == returnvalue::OK) {
|
||||||
|
internalState = InternalState::IDLE;
|
||||||
|
commandExecuted = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (syrlinks::SET_TX_MODE_MODULATION): {
|
||||||
|
if (result == returnvalue::OK) {
|
||||||
|
internalState = InternalState::IDLE;
|
||||||
|
commandExecuted = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (syrlinks::SET_TX_MODE_CW): {
|
||||||
|
if (result == returnvalue::OK) {
|
||||||
|
internalState = InternalState::IDLE;
|
||||||
|
commandExecuted = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -640,3 +682,40 @@ void SyrlinksHandler::prepareCommand(std::string command, DeviceCommandId_t comm
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SyrlinksHandler::setDebugMode(bool enable) { this->debugMode = enable; }
|
void SyrlinksHandler::setDebugMode(bool enable) { this->debugMode = enable; }
|
||||||
|
|
||||||
|
void SyrlinksHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {
|
||||||
|
Mode_t tgtMode = getBaseMode(getMode());
|
||||||
|
if (tgtMode == HasModesIF::MODE_ON or tgtMode == DeviceHandlerIF::MODE_NORMAL) {
|
||||||
|
switch (getSubmode()) {
|
||||||
|
case (syrlinks::Submode::TX_MODULATION): {
|
||||||
|
if (commandExecuted) {
|
||||||
|
setMode(tgtMode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
internalState = InternalState::SET_TX_MODULATION;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (syrlinks::Submode::TX_STANDBY): {
|
||||||
|
if (commandExecuted) {
|
||||||
|
setMode(tgtMode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
internalState = InternalState::SET_TX_STANDBY;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (syrlinks::Submode::TX_CW): {
|
||||||
|
if (commandExecuted) {
|
||||||
|
setMode(tgtMode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
internalState = InternalState::SET_TX_CW;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
setMode(tgtMode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setMode(tgtMode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -34,6 +34,7 @@ class SyrlinksHandler : public DeviceHandlerBase {
|
|||||||
protected:
|
protected:
|
||||||
void doStartUp() override;
|
void doStartUp() override;
|
||||||
void doShutDown() override;
|
void doShutDown() override;
|
||||||
|
void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override;
|
||||||
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override;
|
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override;
|
||||||
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t* id) override;
|
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t* id) override;
|
||||||
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t* commandData,
|
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t* commandData,
|
||||||
@ -104,12 +105,20 @@ class SyrlinksHandler : public DeviceHandlerBase {
|
|||||||
uint16_t rawTempBasebandBoard = 0;
|
uint16_t rawTempBasebandBoard = 0;
|
||||||
float tempPowerAmplifier = 0;
|
float tempPowerAmplifier = 0;
|
||||||
float tempBasebandBoard = 0;
|
float tempBasebandBoard = 0;
|
||||||
|
bool commandExecuted = false;
|
||||||
|
|
||||||
uint8_t commandBuffer[syrlinks::MAX_COMMAND_SIZE];
|
uint8_t commandBuffer[syrlinks::MAX_COMMAND_SIZE];
|
||||||
|
|
||||||
enum class StartupState { OFF, ENABLE_TEMPERATURE_PROTECTION, DONE };
|
enum class InternalState {
|
||||||
|
OFF,
|
||||||
|
ENABLE_TEMPERATURE_PROTECTION,
|
||||||
|
SET_TX_MODULATION,
|
||||||
|
SET_TX_CW,
|
||||||
|
SET_TX_STANDBY,
|
||||||
|
IDLE
|
||||||
|
};
|
||||||
|
|
||||||
StartupState startupState = StartupState::OFF;
|
InternalState internalState = InternalState::OFF;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This object is used to store the id of the next command to execute. This controls the
|
* This object is used to store the id of the next command to execute. This controls the
|
||||||
|
@ -6,6 +6,14 @@
|
|||||||
|
|
||||||
namespace syrlinks {
|
namespace syrlinks {
|
||||||
|
|
||||||
|
enum Submode {
|
||||||
|
DEFAULT,
|
||||||
|
TX_STANDBY,
|
||||||
|
TX_MODULATION,
|
||||||
|
// TODO: Is this needed?
|
||||||
|
TX_CW
|
||||||
|
};
|
||||||
|
|
||||||
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SYRLINKS;
|
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SYRLINKS;
|
||||||
|
|
||||||
static constexpr Event FDIR_REACTION_IGNORED = event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM);
|
static constexpr Event FDIR_REACTION_IGNORED = event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user