add syrlinks submode handling
Some checks are pending
EIVE/eive-obsw/pipeline/head Build started...
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
Robin Müller 2023-01-24 19:40:27 +01:00
parent 1f08d85319
commit ae6f6538d2
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
4 changed files with 117 additions and 21 deletions

View File

@ -56,6 +56,7 @@
#endif
#include <mission/devices/ImtqHandler.h>
#include <mission/devices/PcduHandler.h>
#include <mission/devices/SyrlinksHandler.h>
#include <sstream>
@ -88,7 +89,6 @@
#include "mission/devices/RadiationSensorHandler.h"
#include "mission/devices/RwHandler.h"
#include "mission/devices/SolarArrayDeploymentHandler.h"
#include <mission/devices/SyrlinksHandler.h>
#include "mission/devices/Tmp1075Handler.h"
#include "mission/devices/devicedefinitions/GomspaceDefinitions.h"
#include "mission/devices/devicedefinitions/Max31865Definitions.h"
@ -587,7 +587,7 @@ void ObjectFactory::createSyrlinksComponents(PowerSwitchIF* pwrSwitcher) {
auto syrlinksFdir = new SyrlinksFdir(objects::SYRLINKS_HK_HANDLER);
auto syrlinksHandler =
new SyrlinksHandler(objects::SYRLINKS_HK_HANDLER, objects::UART_COM_IF, syrlinksUartCookie,
pcdu::PDU1_CH1_SYRLINKS_12V, syrlinksFdir);
pcdu::PDU1_CH1_SYRLINKS_12V, syrlinksFdir);
syrlinksHandler->setPowerSwitcher(pwrSwitcher);
#if OBSW_DEBUG_SYRLINKS == 1
syrlinksHandler->setDebugMode(true);

View File

@ -1,10 +1,11 @@
#include <fsfw/datapool/PoolReadGuard.h>
#include <fsfw/globalfunctions/CRC.h>
#include <mission/devices/SyrlinksHandler.h>
#include "OBSWConfig.h"
SyrlinksHandler::SyrlinksHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie,
power::Switch_t powerSwitch, FailureIsolationBase* customFdir)
power::Switch_t powerSwitch, FailureIsolationBase* customFdir)
: DeviceHandlerBase(objectId, comIF, comCookie, customFdir),
rxDataset(this),
txDataset(this),
@ -15,16 +16,17 @@ SyrlinksHandler::SyrlinksHandler(object_id_t objectId, object_id_t comIF, Cookie
}
}
SyrlinksHandler::~SyrlinksHandler() {}
SyrlinksHandler::~SyrlinksHandler() = default;
void SyrlinksHandler::doStartUp() {
switch (startupState) {
case StartupState::OFF: {
startupState = StartupState::ENABLE_TEMPERATURE_PROTECTION;
switch (internalState) {
case InternalState::OFF: {
internalState = InternalState::ENABLE_TEMPERATURE_PROTECTION;
break;
}
case StartupState::DONE: {
case InternalState::IDLE: {
setMode(_MODE_TO_ON);
commandExecuted = false;
break;
}
default:
@ -34,6 +36,8 @@ void SyrlinksHandler::doStartUp() {
void SyrlinksHandler::doShutDown() {
setMode(_MODE_POWER_DOWN);
commandExecuted = false;
internalState = InternalState::OFF;
temperatureSet.setValidity(false, true);
}
@ -84,11 +88,23 @@ ReturnValue_t SyrlinksHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
}
ReturnValue_t SyrlinksHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
switch (startupState) {
case StartupState::ENABLE_TEMPERATURE_PROTECTION: {
switch (internalState) {
case InternalState::ENABLE_TEMPERATURE_PROTECTION: {
*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::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:
break;
}
@ -96,8 +112,8 @@ ReturnValue_t SyrlinksHandler::buildTransitionDeviceCommand(DeviceCommandId_t* i
}
ReturnValue_t SyrlinksHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t* commandData,
size_t commandDataLen) {
const uint8_t* commandData,
size_t commandDataLen) {
switch (deviceCommand) {
case (syrlinks::RESET_UNIT): {
prepareCommand(resetCommand, deviceCommand);
@ -223,7 +239,7 @@ void SyrlinksHandler::fillCommandAndReplyMap() {
}
ReturnValue_t SyrlinksHandler::scanForReply(const uint8_t* start, size_t remainingSize,
DeviceCommandId_t* foundId, size_t* foundLen) {
DeviceCommandId_t* foundId, size_t* foundLen) {
ReturnValue_t result = returnvalue::OK;
if (*start != '<') {
@ -592,7 +608,7 @@ void SyrlinksHandler::setNormalDatapoolEntriesInvalid() {}
uint32_t SyrlinksHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; }
ReturnValue_t SyrlinksHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) {
LocalDataPoolManager& poolManager) {
localDataPoolMap.emplace(syrlinks::RX_STATUS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(syrlinks::RX_SENSITIVITY, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(syrlinks::RX_FREQUENCY_SHIFT, new PoolEntry<int32_t>({0}));
@ -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 result =
parseReplyStatus(reinterpret_cast<const char*>(packet + syrlinks::MESSAGE_HEADER_SIZE));
if (rememberCommandId == syrlinks::WRITE_LCL_CONFIG and result != returnvalue::OK) {
startupState = StartupState::OFF;
} else if (rememberCommandId == syrlinks::WRITE_LCL_CONFIG and result == returnvalue::OK) {
startupState = StartupState::DONE;
switch (rememberCommandId) {
case (syrlinks::WRITE_LCL_CONFIG): {
if (result != returnvalue::OK) {
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;
}
@ -640,3 +682,40 @@ void SyrlinksHandler::prepareCommand(std::string command, DeviceCommandId_t comm
}
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);
}
}

View File

@ -21,7 +21,7 @@
class SyrlinksHandler : public DeviceHandlerBase {
public:
SyrlinksHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie,
power::Switch_t powerSwitch, FailureIsolationBase* customFdir);
power::Switch_t powerSwitch, FailureIsolationBase* customFdir);
virtual ~SyrlinksHandler();
/**
@ -34,6 +34,7 @@ class SyrlinksHandler : public DeviceHandlerBase {
protected:
void doStartUp() override;
void doShutDown() override;
void doTransition(Mode_t modeFrom, Submode_t subModeFrom) 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,
@ -104,12 +105,20 @@ class SyrlinksHandler : public DeviceHandlerBase {
uint16_t rawTempBasebandBoard = 0;
float tempPowerAmplifier = 0;
float tempBasebandBoard = 0;
bool commandExecuted = false;
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

View File

@ -6,6 +6,14 @@
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 Event FDIR_REACTION_IGNORED = event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM);