diff --git a/mission/devices/ACUHandler.cpp b/mission/devices/ACUHandler.cpp index 2594d0b8..91fa1a4d 100644 --- a/mission/devices/ACUHandler.cpp +++ b/mission/devices/ACUHandler.cpp @@ -12,7 +12,7 @@ ACUHandler::ACUHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCoo ACUHandler::~ACUHandler() {} ReturnValue_t ACUHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) { - *id = GomspaceCommands::REQUEST_HK_TABLE; + *id = GOMSPACE::REQUEST_HK_TABLE; return requestHkTableAction.handle(); } @@ -190,7 +190,7 @@ void ACUHandler::setDebugMode(bool enable) { this->debugMode = enable; } ReturnValue_t ACUHandler::printStatus(DeviceCommandId_t cmd) { ReturnValue_t result = RETURN_OK; switch (cmd) { - case (GomspaceCommands::PRINT_SWITCH_V_I): { + case (GOMSPACE::PRINT_SWITCH_V_I): { PoolReadGuard pg(&coreHk); result = pg.getReadResult(); if (result != HasReturnvaluesIF::RETURN_OK) { diff --git a/mission/devices/GomspaceDeviceHandler.cpp b/mission/devices/GomspaceDeviceHandler.cpp index 09dc9de7..fecbf735 100644 --- a/mission/devices/GomspaceDeviceHandler.cpp +++ b/mission/devices/GomspaceDeviceHandler.cpp @@ -41,40 +41,40 @@ ReturnValue_t GomspaceDeviceHandler::handleAction(PrintLatchupsAction* action) { } void GomspaceDeviceHandler::fillCommandAndReplyMap() { - this->insertInCommandAndReplyMap(GomspaceCommands::PING, 3); - this->insertInCommandMap(GomspaceCommands::REBOOT); - this->insertInCommandAndReplyMap(GomspaceCommands::PARAM_SET, 3); - this->insertInCommandAndReplyMap(GomspaceCommands::PARAM_GET, 3); - this->insertInCommandAndReplyMap(GomspaceCommands::REQUEST_HK_TABLE, 3); - this->insertInCommandMap(GomspaceCommands::GNDWDT_RESET); - this->insertInCommandMap(GomspaceCommands::PRINT_SWITCH_V_I); - this->insertInCommandMap(GomspaceCommands::PRINT_LATCHUPS); + this->insertInCommandAndReplyMap(GOMSPACE::PING, 3); + this->insertInCommandMap(GOMSPACE::REBOOT); + this->insertInCommandAndReplyMap(GOMSPACE::PARAM_SET, 3); + this->insertInCommandAndReplyMap(GOMSPACE::PARAM_GET, 3); + this->insertInCommandAndReplyMap(GOMSPACE::REQUEST_HK_TABLE, 3); + this->insertInCommandMap(GOMSPACE::GNDWDT_RESET); + this->insertInCommandMap(GOMSPACE::PRINT_SWITCH_V_I); + this->insertInCommandMap(GOMSPACE::PRINT_LATCHUPS); } ReturnValue_t GomspaceDeviceHandler::scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId, size_t* foundLen) { switch (rememberCommandId) { - case (GomspaceCommands::PING): - *foundId = GomspaceCommands::PING; + case (GOMSPACE::PING): + *foundId = GOMSPACE::PING; *foundLen = PING_REPLY_SIZE; - rememberCommandId = GomspaceCommands::NONE; + rememberCommandId = GOMSPACE::NONE; break; - case (GomspaceCommands::PARAM_GET): { - *foundId = GomspaceCommands::PARAM_GET; + case (GOMSPACE::PARAM_GET): { + *foundId = GOMSPACE::PARAM_GET; *foundLen = rememberRequestedSize + GOMSPACE::GS_HDR_LENGTH; - rememberCommandId = GomspaceCommands::NONE; + rememberCommandId = GOMSPACE::NONE; break; } - case (GomspaceCommands::PARAM_SET): { - *foundId = GomspaceCommands::PARAM_SET; + case (GOMSPACE::PARAM_SET): { + *foundId = GOMSPACE::PARAM_SET; *foundLen = rememberRequestedSize; - rememberCommandId = GomspaceCommands::NONE; + rememberCommandId = GOMSPACE::NONE; break; } - case (GomspaceCommands::REQUEST_HK_TABLE): { - *foundId = GomspaceCommands::REQUEST_HK_TABLE; + case (GOMSPACE::REQUEST_HK_TABLE): { + *foundId = GOMSPACE::REQUEST_HK_TABLE; *foundLen = rememberRequestedSize + GOMSPACE::GS_HDR_LENGTH; - rememberCommandId = GomspaceCommands::NONE; + rememberCommandId = GOMSPACE::NONE; break; } default: @@ -86,12 +86,12 @@ ReturnValue_t GomspaceDeviceHandler::scanForReply(const uint8_t* start, size_t r ReturnValue_t GomspaceDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { switch (id) { - case (GomspaceCommands::PING): { + case (GOMSPACE::PING): { SerializeElement replyTime = *packet; handleDeviceTM(&replyTime, id, true); break; } - case (GomspaceCommands::PARAM_GET): { + case (GOMSPACE::PARAM_GET): { // -2 to subtract address size from gomspace parameter reply packet uint16_t payloadLength = (*(packet + 2) << 8 | *(packet + 3)) - 2; if (payloadLength > sizeof(uint32_t)) { @@ -118,7 +118,7 @@ ReturnValue_t GomspaceDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, handleDeviceTM(¶mReply, id, true); break; } - case (GomspaceCommands::PARAM_SET): { + case (GOMSPACE::PARAM_SET): { /* When setting a parameter, the p60dock sends back the state of the * operation */ if (*packet != PARAM_SET_OK) { @@ -128,7 +128,7 @@ ReturnValue_t GomspaceDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, setParamCallback(setParamCacher.getParameter(), setParamCacher.getParameter(), setParamCacher.getParameterSize(), true); break; } - case (GomspaceCommands::REQUEST_HK_TABLE): { + case (GOMSPACE::REQUEST_HK_TABLE): { letChildHandleHkReply(id, packet); break; } @@ -231,13 +231,13 @@ ReturnValue_t GomspaceDeviceHandler::handleAction(ParamSetAction* action) { rawPacket = cspPacket; rawPacketLen = cspPacketLen; rememberRequestedSize = querySize; - rememberCommandId = GomspaceCommands::PARAM_SET; + rememberCommandId = GOMSPACE::PARAM_SET; return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t GomspaceDeviceHandler::handleAction(ParamGetAction* action) { ReturnValue_t result; - uint8_t tableId = static_cast(action->tableId.value); + auto tableId = action->tableId.value; /* Get and check address */ uint16_t address = action->address; @@ -259,7 +259,7 @@ ReturnValue_t GomspaceDeviceHandler::handleAction(ParamGetAction* action) { uint16_t querySize = parameterSize + GOMSPACE::GS_HDR_LENGTH; /* Generate the CSP command to send to the P60 Dock */ - CspGetParamCommand getParamCmd(querySize, tableId, length, checksum, seq, total, address); + CspGetParamCommand getParamCmd(querySize, static_cast(tableId), length, checksum, seq, total, address); size_t cspPacketLen = 0; uint8_t* buffer = cspPacket; result = getParamCmd.serialize(&buffer, &cspPacketLen, sizeof(cspPacket), @@ -279,7 +279,7 @@ ReturnValue_t GomspaceDeviceHandler::handleAction(ParamGetAction* action) { rawPacket = cspPacket; rawPacketLen = cspPacketLen; rememberRequestedSize = querySize; - rememberCommandId = GomspaceCommands::PARAM_GET; + rememberCommandId = GOMSPACE::PARAM_GET; return HasReturnvaluesIF::RETURN_OK; } @@ -300,7 +300,7 @@ ReturnValue_t GomspaceDeviceHandler::handleAction(PingAction* action) { }*/ rawPacket = cspPacket; rawPacketLen = cspPacketLen; - rememberCommandId = GomspaceCommands::PING; + rememberCommandId = GOMSPACE::PING; return HasReturnvaluesIF::RETURN_OK; } @@ -380,13 +380,13 @@ ReturnValue_t GomspaceDeviceHandler::handleAction(GndwdtResetAction* action) { rawPacketLen = cspPacketLen; rememberRequestedSize = 0; // No bytes will be queried with the ground // watchdog command. - rememberCommandId = GomspaceCommands::GNDWDT_RESET; + rememberCommandId = GOMSPACE::GNDWDT_RESET; return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t GomspaceDeviceHandler::handleAction(RequestHkTableAction* action) { uint16_t querySize = hkTableReplySize; - uint8_t tableId = ParamGetAction::TableId::HK_TABLE_ID; + uint8_t tableId = static_cast(ParamGetAction::TableId::HK_TABLE_ID); RequestFullTableCommand requestFullTableCommand(querySize, tableId); size_t cspPacketLen = 0; @@ -402,7 +402,7 @@ ReturnValue_t GomspaceDeviceHandler::handleAction(RequestHkTableAction* action) rawPacket = cspPacket; rawPacketLen = cspPacketLen; rememberRequestedSize = querySize; - rememberCommandId = GomspaceCommands::REQUEST_HK_TABLE; + rememberCommandId = GOMSPACE::REQUEST_HK_TABLE; return RETURN_OK; } diff --git a/mission/devices/GomspaceDeviceHandler.h b/mission/devices/GomspaceDeviceHandler.h index bf381891..5cd80a06 100644 --- a/mission/devices/GomspaceDeviceHandler.h +++ b/mission/devices/GomspaceDeviceHandler.h @@ -88,7 +88,7 @@ class GomspaceDeviceHandler : public DeviceHandlerBase { static const uint8_t PING_REPLY_SIZE = 2; uint8_t rememberRequestedSize = 0; - uint8_t rememberCommandId = GomspaceCommands::NONE; + uint8_t rememberCommandId = GOMSPACE::NONE; uint8_t cspPacket[MAX_PACKET_LEN]; uint16_t maxConfigTableAddress; diff --git a/mission/devices/P60DockHandler.cpp b/mission/devices/P60DockHandler.cpp index 83c06cea..410bd8bd 100644 --- a/mission/devices/P60DockHandler.cpp +++ b/mission/devices/P60DockHandler.cpp @@ -15,7 +15,7 @@ P60DockHandler::P60DockHandler(object_id_t objectId, object_id_t comIF, CookieIF P60DockHandler::~P60DockHandler() {} ReturnValue_t P60DockHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) { - *id = GomspaceCommands::REQUEST_HK_TABLE; + *id = GOMSPACE::REQUEST_HK_TABLE; return requestHkTableAction.handle(); } @@ -233,7 +233,7 @@ ReturnValue_t P60DockHandler::initializeLocalDataPool(localpool::DataPool &local ReturnValue_t P60DockHandler::printStatus(DeviceCommandId_t cmd) { ReturnValue_t result = RETURN_OK; switch (cmd) { - case (GomspaceCommands::PRINT_SWITCH_V_I): { + case (GOMSPACE::PRINT_SWITCH_V_I): { PoolReadGuard pg0(&coreHk); PoolReadGuard pg1(&auxHk); if (pg0.getReadResult() != HasReturnvaluesIF::RETURN_OK or @@ -243,7 +243,7 @@ ReturnValue_t P60DockHandler::printStatus(DeviceCommandId_t cmd) { printHkTableSwitchIV(); return HasReturnvaluesIF::RETURN_OK; } - case (GomspaceCommands::PRINT_LATCHUPS): { + case (GOMSPACE::PRINT_LATCHUPS): { PoolReadGuard pg(&auxHk); result = pg.getReadResult(); printHkTableLatchups(); diff --git a/mission/devices/PCDUHandler.cpp b/mission/devices/PCDUHandler.cpp index fc2851b5..8e9f1918 100644 --- a/mission/devices/PCDUHandler.cpp +++ b/mission/devices/PCDUHandler.cpp @@ -353,7 +353,7 @@ ReturnValue_t PCDUHandler::sendSwitchCommand(uint8_t switchNr, ReturnValue_t onO result = IPCStore->addData(&storeAddress, command, sizeof(command)); CommandMessage message; - ActionMessage::setCommand(&message, GomspaceCommands::PARAM_SET, storeAddress); + ActionMessage::setCommand(&message, GOMSPACE::PARAM_SET, storeAddress); result = commandQueue->sendMessage(pdu->getCommandQueue(), &message, 0); if (result != RETURN_OK) { diff --git a/mission/devices/PDU1Handler.cpp b/mission/devices/PDU1Handler.cpp index 3cf97679..74480cb8 100644 --- a/mission/devices/PDU1Handler.cpp +++ b/mission/devices/PDU1Handler.cpp @@ -15,7 +15,7 @@ PDU1Handler::PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF *comC PDU1Handler::~PDU1Handler() {} ReturnValue_t PDU1Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) { - *id = GomspaceCommands::REQUEST_HK_TABLE; + *id = GOMSPACE::REQUEST_HK_TABLE; return requestHkTableAction.handle(); } @@ -102,7 +102,7 @@ LocalPoolDataSetBase *PDU1Handler::getDataSetHandle(sid_t sid) { ReturnValue_t PDU1Handler::printStatus(DeviceCommandId_t cmd) { ReturnValue_t result = RETURN_OK; switch (cmd) { - case (GomspaceCommands::PRINT_SWITCH_V_I): { + case (GOMSPACE::PRINT_SWITCH_V_I): { PoolReadGuard pg(&coreHk); result = pg.getReadResult(); if (result != HasReturnvaluesIF::RETURN_OK) { @@ -111,7 +111,7 @@ ReturnValue_t PDU1Handler::printStatus(DeviceCommandId_t cmd) { printHkTableSwitchVI(); break; } - case (GomspaceCommands::PRINT_LATCHUPS): { + case (GOMSPACE::PRINT_LATCHUPS): { PoolReadGuard pg(&auxHk); result = pg.getReadResult(); if (result != HasReturnvaluesIF::RETURN_OK) { diff --git a/mission/devices/PDU2Handler.cpp b/mission/devices/PDU2Handler.cpp index 7bd76f74..b728a379 100644 --- a/mission/devices/PDU2Handler.cpp +++ b/mission/devices/PDU2Handler.cpp @@ -15,7 +15,7 @@ PDU2Handler::PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF *comC PDU2Handler::~PDU2Handler() {} ReturnValue_t PDU2Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) { - *id = GomspaceCommands::REQUEST_HK_TABLE; + *id = GOMSPACE::REQUEST_HK_TABLE; return requestHkTableAction.handle(); } @@ -57,7 +57,7 @@ ReturnValue_t PDU2Handler::initializeLocalDataPool(localpool::DataPool &localDat ReturnValue_t PDU2Handler::printStatus(DeviceCommandId_t cmd) { ReturnValue_t result = RETURN_OK; switch (cmd) { - case (GomspaceCommands::PRINT_SWITCH_V_I): { + case (GOMSPACE::PRINT_SWITCH_V_I): { PoolReadGuard pg(&coreHk); result = pg.getReadResult(); if (result != HasReturnvaluesIF::RETURN_OK) { @@ -66,7 +66,7 @@ ReturnValue_t PDU2Handler::printStatus(DeviceCommandId_t cmd) { printHkTableSwitchVI(); break; } - case (GomspaceCommands::PRINT_LATCHUPS): { + case (GOMSPACE::PRINT_LATCHUPS): { PoolReadGuard pg(&auxHk); result = pg.getReadResult(); if (result != HasReturnvaluesIF::RETURN_OK) { diff --git a/mission/devices/devicedefinitions/GomspaceActions.h b/mission/devices/devicedefinitions/GomspaceActions.h index 6e8c5333..ce1e94d4 100644 --- a/mission/devices/devicedefinitions/GomspaceActions.h +++ b/mission/devices/devicedefinitions/GomspaceActions.h @@ -7,35 +7,35 @@ class GomspaceDeviceHandler; -class PingAction : public TemplateAction { +class PingAction : public TemplateAction { public: - PingAction(GomspaceDeviceHandler* owner) : TemplateAction(owner, GomspaceCommands::PING) {} + PingAction(GomspaceDeviceHandler* owner) : TemplateAction(owner, GOMSPACE::PING) {} // TODO array Parameter pingData = Parameter::createParameter(this, "Ping Data"); }; -class RebootAction : public TemplateAction { +class RebootAction : public TemplateAction { public: - RebootAction(GomspaceDeviceHandler* owner) : TemplateAction(owner, GomspaceCommands::REBOOT) {} + RebootAction(GomspaceDeviceHandler* owner) : TemplateAction(owner, GOMSPACE::REBOOT) {} }; class GndwdtResetAction - : public TemplateAction { + : public TemplateAction { public: GndwdtResetAction(GomspaceDeviceHandler* owner) - : TemplateAction(owner, GomspaceCommands::GNDWDT_RESET) {} + : TemplateAction(owner, GOMSPACE::GNDWDT_RESET) {} }; class ParamGetAction - : public TemplateAction { + : public TemplateAction { public: FSFW_ENUM(ParameterByteSize, uint8_t, ((ONE_BYTE, 1, "One Byte"))((TWO_BYTES, 2, "Two Bytes"))((FOUR_BYTES, 4, "Four Bytes"))) FSFW_ENUM(TableId, uint8_t, ((CONFIG_TABLE_ID, 1, "Config Table"))((HK_TABLE_ID, 4, "Housekeeping Table"))) ParamGetAction(GomspaceDeviceHandler* owner) - : TemplateAction(owner, GomspaceCommands::PARAM_GET) {} + : TemplateAction(owner, GOMSPACE::PARAM_GET) {} Parameter tableId = Parameter::createParameter(this, "Table"); @@ -45,13 +45,13 @@ Parameter address = Parameter::createParameter(this, "Addres }; class ParamSetAction - : public TemplateAction { + : public TemplateAction { public: FSFW_ENUM(ParameterByteSize, uint8_t, ((ONE_BYTE, 1, "One Byte"))((TWO_BYTES, 2, "Two Bytes"))((FOUR_BYTES, 4, "Four Bytes"))) ParamSetAction(GomspaceDeviceHandler* owner) - : TemplateAction(owner, GomspaceCommands::PARAM_SET) {} + : TemplateAction(owner, GOMSPACE::PARAM_SET) {} Parameter address = Parameter::createParameter(this, "Address"); Parameter parameter = Parameter::createParameter(this, "Parameter Value"); @@ -60,22 +60,22 @@ class ParamSetAction }; class RequestHkTableAction - : public TemplateAction { + : public TemplateAction { public: RequestHkTableAction(GomspaceDeviceHandler* owner) - : TemplateAction(owner, GomspaceCommands::REQUEST_HK_TABLE) {} + : TemplateAction(owner, GOMSPACE::REQUEST_HK_TABLE) {} }; class PrintSwitchVIAction - : public TemplateAction { + : public TemplateAction { public: PrintSwitchVIAction(GomspaceDeviceHandler* owner) - : TemplateAction(owner, GomspaceCommands::PRINT_SWITCH_V_I) {} + : TemplateAction(owner, GOMSPACE::PRINT_SWITCH_V_I) {} }; class PrintLatchupsAction - : public TemplateAction { + : public TemplateAction { public: PrintLatchupsAction(GomspaceDeviceHandler* owner) - : TemplateAction(owner, GomspaceCommands::PRINT_LATCHUPS) {} + : TemplateAction(owner, GOMSPACE::PRINT_LATCHUPS) {} }; \ No newline at end of file diff --git a/mission/devices/devicedefinitions/GomspaceDefinitions.h b/mission/devices/devicedefinitions/GomspaceDefinitions.h index 3a05125e..7b7c90e8 100644 --- a/mission/devices/devicedefinitions/GomspaceDefinitions.h +++ b/mission/devices/devicedefinitions/GomspaceDefinitions.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include @@ -13,6 +13,18 @@ namespace GOMSPACE { +/** + * Device commands are derived from the rparam.h of the gomspace lib.. + * IDs above 50 are reserved for device specific commands. + */ +FSFW_CLASSLESS_ENUM( + GomspaceCommands, DeviceCommandId_t, + ((PING, 1, "Ping"))((NONE, 2, "None (used internally)"))((REBOOT, 4, "Reboot"))( + (GNDWDT_RESET, 9, "Reset Watchdog"))((PARAM_GET, 0, "Get Parameter"))( + (PARAM_SET, 255, "Set Parameter"))((REQUEST_HK_TABLE, 16, "Request Housekeeping Table"))( + (PRINT_SWITCH_V_I, 32, "Print switch states, voltages and currents to the console"))( + (PRINT_LATCHUPS, 33, "Print Latchups to the console"))) + enum class Pdu { PDU1, PDU2 }; using ChannelSwitchHook = void (*)(Pdu pdu, uint8_t channel, bool on, void* args); @@ -29,18 +41,6 @@ static const uint8_t P60_PORT_GNDWDT_RESET = 9; } // namespace GOMSPACE -/** - * Device commands are derived from the rparam.h of the gomspace lib.. - * IDs above 50 are reserved for device specific commands. - */ -FSFW_ENUM(GomspaceCommands, DeviceCommandId_t, - ((PING, 1, "Ping"))((NONE, 2, "None (used internally)"))((REBOOT, 4, "Reboot"))( - (GNDWDT_RESET, 9, "Reset Watchdog"))((PARAM_GET, 0, "Get Parameter"))( - (PARAM_SET, 255, "Set Parameter"))((REQUEST_HK_TABLE, 16, - "Request Housekeeping Table"))( - (PRINT_SWITCH_V_I, 32, "Print switch states, voltages and currents to the console"))( - (PRINT_LATCHUPS, 33, "Print Latchups to the console"))) - namespace P60System { enum class BatteryModes : uint8_t { CRITICAL = 1, SAFE = 2, NORMAL = 3, FULL = 4 };