compiling both with and without introspection

This commit is contained in:
Ulrich Mohr 2022-08-25 16:28:01 +02:00
parent 3c762e7437
commit 06b6c0838a
9 changed files with 74 additions and 74 deletions

View File

@ -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) {

View File

@ -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<uint32_t> 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(&paramReply, 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<uint8_t>(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<uint8_t>(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<uint8_t>(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;
}

View File

@ -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;

View File

@ -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();

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -7,35 +7,35 @@
class GomspaceDeviceHandler;
class PingAction : public TemplateAction<GomspaceDeviceHandler, PingAction, GomspaceCommands> {
class PingAction : public TemplateAction<GomspaceDeviceHandler, PingAction, GOMSPACE::GomspaceCommands> {
public:
PingAction(GomspaceDeviceHandler* owner) : TemplateAction(owner, GomspaceCommands::PING) {}
PingAction(GomspaceDeviceHandler* owner) : TemplateAction(owner, GOMSPACE::PING) {}
// TODO array
Parameter<uint8_t> pingData = Parameter<uint8_t>::createParameter(this, "Ping Data");
};
class RebootAction : public TemplateAction<GomspaceDeviceHandler, RebootAction, GomspaceCommands> {
class RebootAction : public TemplateAction<GomspaceDeviceHandler, RebootAction, GOMSPACE::GomspaceCommands> {
public:
RebootAction(GomspaceDeviceHandler* owner) : TemplateAction(owner, GomspaceCommands::REBOOT) {}
RebootAction(GomspaceDeviceHandler* owner) : TemplateAction(owner, GOMSPACE::REBOOT) {}
};
class GndwdtResetAction
: public TemplateAction<GomspaceDeviceHandler, GndwdtResetAction, GomspaceCommands> {
: public TemplateAction<GomspaceDeviceHandler, GndwdtResetAction, GOMSPACE::GomspaceCommands> {
public:
GndwdtResetAction(GomspaceDeviceHandler* owner)
: TemplateAction(owner, GomspaceCommands::GNDWDT_RESET) {}
: TemplateAction(owner, GOMSPACE::GNDWDT_RESET) {}
};
class ParamGetAction
: public TemplateAction<GomspaceDeviceHandler, ParamGetAction, GomspaceCommands> {
: public TemplateAction<GomspaceDeviceHandler, ParamGetAction, GOMSPACE::GomspaceCommands> {
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> tableId =
Parameter<TableId>::createParameter(this, "Table");
@ -45,13 +45,13 @@ Parameter<uint16_t> address = Parameter<uint16_t>::createParameter(this, "Addres
};
class ParamSetAction
: public TemplateAction<GomspaceDeviceHandler, ParamSetAction, GomspaceCommands> {
: public TemplateAction<GomspaceDeviceHandler, ParamSetAction, GOMSPACE::GomspaceCommands> {
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<uint16_t> address = Parameter<uint16_t>::createParameter(this, "Address");
Parameter<uint32_t> parameter = Parameter<uint32_t>::createParameter(this, "Parameter Value");
@ -60,22 +60,22 @@ class ParamSetAction
};
class RequestHkTableAction
: public TemplateAction<GomspaceDeviceHandler, RequestHkTableAction, GomspaceCommands> {
: public TemplateAction<GomspaceDeviceHandler, RequestHkTableAction, GOMSPACE::GomspaceCommands> {
public:
RequestHkTableAction(GomspaceDeviceHandler* owner)
: TemplateAction(owner, GomspaceCommands::REQUEST_HK_TABLE) {}
: TemplateAction(owner, GOMSPACE::REQUEST_HK_TABLE) {}
};
class PrintSwitchVIAction
: public TemplateAction<GomspaceDeviceHandler, PrintSwitchVIAction, GomspaceCommands> {
: public TemplateAction<GomspaceDeviceHandler, PrintSwitchVIAction, GOMSPACE::GomspaceCommands> {
public:
PrintSwitchVIAction(GomspaceDeviceHandler* owner)
: TemplateAction(owner, GomspaceCommands::PRINT_SWITCH_V_I) {}
: TemplateAction(owner, GOMSPACE::PRINT_SWITCH_V_I) {}
};
class PrintLatchupsAction
: public TemplateAction<GomspaceDeviceHandler, PrintLatchupsAction, GomspaceCommands> {
: public TemplateAction<GomspaceDeviceHandler, PrintLatchupsAction, GOMSPACE::GomspaceCommands> {
public:
PrintLatchupsAction(GomspaceDeviceHandler* owner)
: TemplateAction(owner, GomspaceCommands::PRINT_LATCHUPS) {}
: TemplateAction(owner, GOMSPACE::PRINT_LATCHUPS) {}
};

View File

@ -4,7 +4,7 @@
#include <fsfw/datapoollocal/LocalPoolVariable.h>
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
#include <fsfw/introspection/Enum.h>
#include <fsfw/introspection/ClasslessEnum.h>
#include <fsfw/power/definitions.h>
#include <cstdint>
@ -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 };