continuing on gomspace handlers
This commit is contained in:
parent
1f47c970af
commit
da2acd1fa8
@ -33,69 +33,11 @@ ReturnValue_t GomspaceDeviceHandler::buildTransitionDeviceCommand(DeviceCommandI
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
|
||||
ReturnValue_t GomspaceDeviceHandler::handleAction(NoneAction* action) {}
|
||||
ReturnValue_t GomspaceDeviceHandler::handleAction(RebootAction* action) {}
|
||||
ReturnValue_t GomspaceDeviceHandler::handleAction(GndwdtResetAction* action) {}
|
||||
ReturnValue_t GomspaceDeviceHandler::handleAction(ParamGetAction* action) {}
|
||||
ReturnValue_t GomspaceDeviceHandler::handleAction(ParamSetAction* action) {}
|
||||
ReturnValue_t GomspaceDeviceHandler::handleAction(RequestHkTableAction* action) {}
|
||||
ReturnValue_t GomspaceDeviceHandler::handleAction(PrintSwitchVIAction* action) {}
|
||||
ReturnValue_t GomspaceDeviceHandler::handleAction(PrintLatchupsAction* action) {}
|
||||
|
||||
ReturnValue_t GomspaceDeviceHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
|
||||
const uint8_t* commandData,
|
||||
size_t commandDataLen) {
|
||||
ReturnValue_t result = childCommandHook(deviceCommand, commandData, commandDataLen);
|
||||
switch (deviceCommand) {
|
||||
case (GomspaceCommands::PING): {
|
||||
//result = generatePingCommand(commandData, commandDataLen);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case (GomspaceCommands::REBOOT): {
|
||||
generateRebootCommand();
|
||||
break;
|
||||
}
|
||||
case (GomspaceCommands::PARAM_SET): {
|
||||
result = generateSetParamCommand(commandData, commandDataLen);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case (GomspaceCommands::PARAM_GET): {
|
||||
result = generateGetParamCommand(commandData, commandDataLen);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case (GomspaceCommands::GNDWDT_RESET): {
|
||||
result = generateResetWatchdogCmd();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case (GomspaceCommands::PRINT_SWITCH_V_I):
|
||||
case (GomspaceCommands::PRINT_LATCHUPS): {
|
||||
result = printStatus(deviceCommand);
|
||||
break;
|
||||
}
|
||||
case (GomspaceCommands::REQUEST_HK_TABLE): {
|
||||
result = generateRequestFullHkTableCmd(hkTableReplySize);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
ReturnValue_t GomspaceDeviceHandler::handleAction(PrintSwitchVIAction* action) {
|
||||
return printStatus(action->getId());
|
||||
}
|
||||
ReturnValue_t GomspaceDeviceHandler::handleAction(PrintLatchupsAction* action) {
|
||||
return printStatus(action->getId());
|
||||
}
|
||||
|
||||
void GomspaceDeviceHandler::fillCommandAndReplyMap() {
|
||||
@ -182,7 +124,8 @@ ReturnValue_t GomspaceDeviceHandler::interpretDeviceReply(DeviceCommandId_t id,
|
||||
if (*packet != PARAM_SET_OK) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
setParamCallback(setParamCacher, true);
|
||||
// TODO fix
|
||||
setParamCallback(setParamCacher.getParameter(), setParamCacher.getParameter(), setParamCacher.getParameterSize(), true);
|
||||
break;
|
||||
}
|
||||
case (GomspaceCommands::REQUEST_HK_TABLE): {
|
||||
@ -197,29 +140,23 @@ ReturnValue_t GomspaceDeviceHandler::interpretDeviceReply(DeviceCommandId_t id,
|
||||
|
||||
void GomspaceDeviceHandler::setNormalDatapoolEntriesInvalid() {}
|
||||
|
||||
ReturnValue_t GomspaceDeviceHandler::generateSetParamCommand(const uint8_t* commandData,
|
||||
size_t commandDataLen) {
|
||||
ReturnValue_t result =
|
||||
setParamCacher.deSerialize(&commandData, &commandDataLen, SerializeIF::Endianness::BIG);
|
||||
ReturnValue_t GomspaceDeviceHandler::handleAction(ParamSetAction* action) {
|
||||
// This breaks layering but I really don't want to accept this command..
|
||||
if (setParamCacher.getAddress() == PDU2::CONFIG_ADDRESS_OUT_EN_Q7S and
|
||||
if (action->address == PDU2::CONFIG_ADDRESS_OUT_EN_Q7S and
|
||||
this->getObjectId() == objects::PDU2_HANDLER) {
|
||||
triggerEvent(power::SWITCHING_Q7S_DENIED, 0, 0);
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::error << "GomspaceDeviceHandler: Failed to deserialize set parameter "
|
||||
"message"
|
||||
<< std::endl;
|
||||
return result;
|
||||
}
|
||||
result = setParamCallback(setParamCacher, false);
|
||||
//cache for later use
|
||||
setParamCacher.set(action->address, action->parameter,
|
||||
static_cast<uint8_t>(action->parameterSize.value));
|
||||
ReturnValue_t result = setParamCallback(action->address, action->parameter,
|
||||
static_cast<uint8_t>(action->parameterSize.value), false);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
/* Get and check address */
|
||||
uint16_t address = setParamCacher.getAddress();
|
||||
if (address > maxConfigTableAddress) {
|
||||
if (action->address > maxConfigTableAddress) {
|
||||
sif::error << "GomspaceDeviceHandler: Invalid address for set parameter "
|
||||
<< "action" << std::endl;
|
||||
return INVALID_ADDRESS;
|
||||
@ -229,13 +166,52 @@ ReturnValue_t GomspaceDeviceHandler::generateSetParamCommand(const uint8_t* comm
|
||||
uint16_t total = 0;
|
||||
/* CSP reply only contains the transaction state */
|
||||
uint16_t querySize = 1;
|
||||
const uint8_t* parameterPtr = setParamCacher.getParameter();
|
||||
uint8_t parameterSize = setParamCacher.getParameterSize();
|
||||
uint16_t payloadlength = sizeof(address) + parameterSize;
|
||||
size_t parameterSize = 0;
|
||||
uint8_t parameterBytes[4];
|
||||
uint8_t* uselessPointer = parameterBytes;
|
||||
switch (action->parameterSize.value) {
|
||||
case ParamSetAction::ParameterByteSize::ONE_BYTE: {
|
||||
if (action->parameter > 255) {
|
||||
return INVALID_PARAMETERS;
|
||||
}
|
||||
uint8_t oneByte = action->parameter.value;
|
||||
result = SerializeAdapter::serialize<uint8_t>(&oneByte, &uselessPointer, ¶meterSize,
|
||||
sizeof(parameterBytes),
|
||||
SerializeIF::Endianness::BIG);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
parameterSize = 1;
|
||||
} break;
|
||||
case ParamSetAction::ParameterByteSize::TWO_BYTES: {
|
||||
if (action->parameter > 65535) {
|
||||
return INVALID_PARAMETERS;
|
||||
}
|
||||
uint16_t twoBytes = action->parameter.value;
|
||||
result = SerializeAdapter::serialize<uint16_t>(&twoBytes, &uselessPointer, ¶meterSize,
|
||||
sizeof(parameterBytes),
|
||||
SerializeIF::Endianness::BIG);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
parameterSize = 2;
|
||||
} break;
|
||||
case ParamSetAction::ParameterByteSize::FOUR_BYTES:
|
||||
result = SerializeAdapter::serialize<uint32_t>(&(action->parameter.value), &uselessPointer,
|
||||
¶meterSize, sizeof(parameterBytes),
|
||||
SerializeIF::Endianness::BIG);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
parameterSize = 4;
|
||||
break;
|
||||
}
|
||||
|
||||
uint16_t payloadlength = sizeof(action->address) + parameterSize;
|
||||
|
||||
/* Generate command for CspComIF */
|
||||
CspSetParamCommand setParamCmd(querySize, payloadlength, checksum, seq, total, address,
|
||||
parameterPtr, parameterSize);
|
||||
CspSetParamCommand setParamCmd(querySize, payloadlength, checksum, seq, total, action->address,
|
||||
parameterBytes, parameterSize);
|
||||
size_t cspPacketLen = 0;
|
||||
uint8_t* buffer = cspPacket;
|
||||
result = setParamCmd.serialize(&buffer, &cspPacketLen, sizeof(cspPacket),
|
||||
@ -259,34 +235,18 @@ ReturnValue_t GomspaceDeviceHandler::generateSetParamCommand(const uint8_t* comm
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t GomspaceDeviceHandler::generateGetParamCommand(const uint8_t* commandData,
|
||||
size_t commandDataLen) {
|
||||
ReturnValue_t GomspaceDeviceHandler::handleAction(ParamGetAction* action) {
|
||||
ReturnValue_t result;
|
||||
/* Unpack the received action message */
|
||||
GetParamMessageUnpacker getParamMessage;
|
||||
result = getParamMessage.deSerialize(&commandData, &commandDataLen, SerializeIF::Endianness::BIG);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::error << "Failed to deserialize message to extract information "
|
||||
"from get parameter message"
|
||||
<< std::endl;
|
||||
return result;
|
||||
}
|
||||
/* Get an check table id to read from */
|
||||
uint8_t tableId = getParamMessage.getTableId();
|
||||
if (tableId != CONFIG_TABLE_ID && tableId != HK_TABLE_ID) {
|
||||
sif::error << "GomspaceDeviceHandler: Invalid table id in get parameter"
|
||||
" message"
|
||||
<< std::endl;
|
||||
return INVALID_TABLE_ID;
|
||||
}
|
||||
uint8_t tableId = static_cast<uint8_t>(action->tableId.value);
|
||||
|
||||
/* Get and check address */
|
||||
uint16_t address = getParamMessage.getAddress();
|
||||
if (address > maxHkTableAddress && tableId == HK_TABLE_ID) {
|
||||
uint16_t address = action->address;
|
||||
if (address > maxHkTableAddress && tableId == ParamGetAction::TableId::HK_TABLE_ID) {
|
||||
sif::error << "GomspaceDeviceHandler: Invalid address to get parameter from "
|
||||
<< "housekeeping table" << std::endl;
|
||||
return INVALID_ADDRESS;
|
||||
}
|
||||
if (address > maxConfigTableAddress && tableId == CONFIG_TABLE_ID) {
|
||||
if (address > maxConfigTableAddress && tableId == ParamGetAction::TableId::CONFIG_TABLE_ID) {
|
||||
sif::error << "GomspaceDeviceHandler: Invalid address to get parameter from "
|
||||
<< "configuration table" << std::endl;
|
||||
return INVALID_ADDRESS;
|
||||
@ -295,12 +255,7 @@ ReturnValue_t GomspaceDeviceHandler::generateGetParamCommand(const uint8_t* comm
|
||||
uint16_t checksum = GOMSPACE::IGNORE_CHECKSUM;
|
||||
uint16_t seq = 0;
|
||||
uint16_t total = 0;
|
||||
uint8_t parameterSize = getParamMessage.getParameterSize();
|
||||
if (parameterSize > sizeof(uint32_t)) {
|
||||
sif::error << "GomspaceDeviceHandler: GET_PARAM: Invalid parameter "
|
||||
<< "size" << std::endl;
|
||||
return INVALID_PARAM_SIZE;
|
||||
}
|
||||
uint8_t parameterSize = static_cast<uint8_t>(action->parameterSize.value);
|
||||
uint16_t querySize = parameterSize + GOMSPACE::GS_HDR_LENGTH;
|
||||
|
||||
/* Generate the CSP command to send to the P60 Dock */
|
||||
@ -313,12 +268,14 @@ ReturnValue_t GomspaceDeviceHandler::generateGetParamCommand(const uint8_t* comm
|
||||
sif::error << "GomspaceDeviceHandler: Failed to serialize command to "
|
||||
<< "get parameter" << std::endl;
|
||||
}
|
||||
if (cspPacketLen > MAX_PACKET_LEN) {
|
||||
|
||||
// checked by serialize above
|
||||
/* if (cspPacketLen > MAX_PACKET_LEN) {
|
||||
sif::error << "GomspaceDeviceHandler: Received invalid get parameter "
|
||||
"command"
|
||||
<< std::endl;
|
||||
return PACKET_TOO_LONG;
|
||||
}
|
||||
}*/
|
||||
rawPacket = cspPacket;
|
||||
rawPacketLen = cspPacketLen;
|
||||
rememberRequestedSize = querySize;
|
||||
@ -327,7 +284,7 @@ ReturnValue_t GomspaceDeviceHandler::generateGetParamCommand(const uint8_t* comm
|
||||
}
|
||||
|
||||
ReturnValue_t GomspaceDeviceHandler::handleAction(PingAction* action) {
|
||||
/*CspPingCommand cspPingCommand(commandData, commandDataLen);
|
||||
CspPingCommand cspPingCommand(&action->pingData.value, 1); // TODO array
|
||||
size_t cspPacketLen = 0;
|
||||
uint8_t* buffer = cspPacket;
|
||||
ReturnValue_t result = cspPingCommand.serialize(&buffer, &cspPacketLen, sizeof(cspPacket),
|
||||
@ -336,24 +293,27 @@ ReturnValue_t GomspaceDeviceHandler::handleAction(PingAction* action) {
|
||||
sif::error << "GomspaceDeviceHandler: Failed to serialize ping command" << std::endl;
|
||||
return result;
|
||||
}
|
||||
/* Checked by the serialize function
|
||||
if (cspPacketLen > MAX_PACKET_LEN) {
|
||||
sif::error << "GomspaceDeviceHandler: Received invalid ping message" << std::endl;
|
||||
return PACKET_TOO_LONG;
|
||||
}
|
||||
}*/
|
||||
rawPacket = cspPacket;
|
||||
rawPacketLen = cspPacketLen;*/
|
||||
rawPacketLen = cspPacketLen;
|
||||
rememberCommandId = GomspaceCommands::PING;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void GomspaceDeviceHandler::generateRebootCommand() {
|
||||
ReturnValue_t GomspaceDeviceHandler::handleAction(RebootAction* action) {
|
||||
uint8_t cspPort = GOMSPACE::REBOOT_PORT;
|
||||
uint16_t querySize = 0;
|
||||
*cspPacket = GOMSPACE::REBOOT_PORT;
|
||||
// TODO the following two lines look strange...
|
||||
*(cspPacket + 1) = querySize;
|
||||
size_t cspPacketLen = sizeof(cspPort) + sizeof(cspPacketLen);
|
||||
rawPacket = cspPacket;
|
||||
rawPacketLen = cspPacketLen;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t GomspaceDeviceHandler::childCommandHook(DeviceCommandId_t cmd,
|
||||
@ -362,8 +322,8 @@ ReturnValue_t GomspaceDeviceHandler::childCommandHook(DeviceCommandId_t cmd,
|
||||
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
ReturnValue_t GomspaceDeviceHandler::setParamCallback(SetParamMessageUnpacker& unpacker,
|
||||
bool afterExecution) {
|
||||
ReturnValue_t GomspaceDeviceHandler::setParamCallback(uint16_t address, uint32_t value,
|
||||
uint8_t valueBytes, bool afterExecution) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
@ -405,7 +365,7 @@ ReturnValue_t GomspaceDeviceHandler::initializePduPool(
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t GomspaceDeviceHandler::generateResetWatchdogCmd() {
|
||||
ReturnValue_t GomspaceDeviceHandler::handleAction(GndwdtResetAction* action) {
|
||||
WatchdogResetCommand watchdogResetCommand;
|
||||
size_t cspPacketLen = 0;
|
||||
uint8_t* buffer = cspPacket;
|
||||
@ -424,9 +384,9 @@ ReturnValue_t GomspaceDeviceHandler::generateResetWatchdogCmd() {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t GomspaceDeviceHandler::generateRequestFullHkTableCmd(uint16_t hkTableReplySize) {
|
||||
ReturnValue_t GomspaceDeviceHandler::handleAction(RequestHkTableAction* action) {
|
||||
uint16_t querySize = hkTableReplySize;
|
||||
uint8_t tableId = HK_TABLE_ID;
|
||||
uint8_t tableId = ParamGetAction::TableId::HK_TABLE_ID;
|
||||
RequestFullTableCommand requestFullTableCommand(querySize, tableId);
|
||||
|
||||
size_t cspPacketLen = 0;
|
||||
|
@ -49,11 +49,34 @@ class GomspaceDeviceHandler : public DeviceHandlerBase {
|
||||
*/
|
||||
void setModeNormal();
|
||||
|
||||
/**
|
||||
* @brief Function to generate the ping command for the ComIF.
|
||||
*/
|
||||
ReturnValue_t handleAction(PingAction *action);
|
||||
ReturnValue_t handleAction(NoneAction *action);
|
||||
|
||||
/**
|
||||
* @brief Function to generate the command to reboot a gomspace device
|
||||
* via the ComIF.
|
||||
*/
|
||||
ReturnValue_t handleAction(RebootAction *action);
|
||||
|
||||
/**
|
||||
* @brief Function to generate the command to force a ground watchdog
|
||||
* reset in a gomspace device.
|
||||
*/
|
||||
ReturnValue_t handleAction(GndwdtResetAction *action);
|
||||
|
||||
/**
|
||||
* @brief Function to generate the command to get a parameter from a
|
||||
* gomspace device. Command will be sent to the ComIF over the
|
||||
* rawPacket buffer.
|
||||
*/
|
||||
ReturnValue_t handleAction(ParamGetAction *action);
|
||||
|
||||
/**
|
||||
* @brief Function to generate the command to set a parameter. Command
|
||||
* will be sent to the ComIF over the rawPacket buffer.
|
||||
*/
|
||||
ReturnValue_t handleAction(ParamSetAction *action);
|
||||
ReturnValue_t handleAction(RequestHkTableAction *action);
|
||||
ReturnValue_t handleAction(PrintSwitchVIAction *action);
|
||||
@ -63,8 +86,6 @@ class GomspaceDeviceHandler : public DeviceHandlerBase {
|
||||
static const uint8_t MAX_PACKET_LEN = 36;
|
||||
static const uint8_t PARAM_SET_OK = 1;
|
||||
static const uint8_t PING_REPLY_SIZE = 2;
|
||||
static const uint8_t CONFIG_TABLE_ID = 1;
|
||||
static const uint8_t HK_TABLE_ID = 4;
|
||||
|
||||
uint8_t rememberRequestedSize = 0;
|
||||
uint8_t rememberCommandId = GomspaceCommands::NONE;
|
||||
@ -79,32 +100,24 @@ class GomspaceDeviceHandler : public DeviceHandlerBase {
|
||||
LocalPoolDataSetBase *hkTableDataset = nullptr;
|
||||
|
||||
PingAction pingAction = PingAction(this);
|
||||
NoneAction noneAction = NoneAction(this);
|
||||
RebootAction rebootAction = RebootAction(this);
|
||||
GndwdtResetAction gndwdtResetAction = GndwdtResetAction(this);
|
||||
ParamGetAction paramGetAction = ParamGetAction(this);
|
||||
ParamSetAction paramSetAction = ParamSetAction(this);
|
||||
RequestHkTableAction requestHkTableAction = RequestHkTableAction(this);
|
||||
PrintSwitchVIAction printSwitchVIAction = PrintSwitchVIAction(this);
|
||||
PrintLatchupsAction printLatchupsAction = PrintLatchupsAction(this);
|
||||
RebootAction rebootAction = RebootAction(this);
|
||||
GndwdtResetAction gndwdtResetAction = GndwdtResetAction(this);
|
||||
ParamGetAction paramGetAction = ParamGetAction(this);
|
||||
ParamSetAction paramSetAction = ParamSetAction(this);
|
||||
RequestHkTableAction requestHkTableAction = RequestHkTableAction(this);
|
||||
PrintSwitchVIAction printSwitchVIAction = PrintSwitchVIAction(this);
|
||||
PrintLatchupsAction printLatchupsAction = PrintLatchupsAction(this);
|
||||
|
||||
void doStartUp() override;
|
||||
void doShutDown() override;
|
||||
virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override;
|
||||
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override;
|
||||
virtual void fillCommandAndReplyMap() override;
|
||||
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData,
|
||||
size_t commandDataLen) override;
|
||||
ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize, DeviceCommandId_t *foundId,
|
||||
size_t *foundLen) override;
|
||||
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override;
|
||||
void setNormalDatapoolEntriesInvalid() override;
|
||||
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
|
||||
/**
|
||||
* @brief The command to generate a request to receive the full housekeeping table is device
|
||||
* specific. Thus the child has to build this command.
|
||||
*/
|
||||
virtual ReturnValue_t generateRequestFullHkTableCmd(uint16_t hkTableSize);
|
||||
|
||||
/**
|
||||
* This command handles printing the HK table to the console. This is useful for debugging
|
||||
@ -138,46 +151,18 @@ PrintLatchupsAction printLatchupsAction = PrintLatchupsAction(this);
|
||||
std::array<uint8_t, PDU::CHANNELS_LEN> initOutEnb);
|
||||
|
||||
private:
|
||||
SetParamMessageUnpacker setParamCacher;
|
||||
/**
|
||||
* @brief Function to generate the command to set a parameter. Command
|
||||
* will be sent to the ComIF over the rawPacket buffer.
|
||||
*/
|
||||
ReturnValue_t generateSetParamCommand(const uint8_t *commandData, size_t commandDataLen);
|
||||
SetParamMessageCache setParamCacher;
|
||||
|
||||
/**
|
||||
* Callback is called on a parameter set command. It is called before executing it and after
|
||||
* Callback is called on a parameter set command. It is called before executing it and
|
||||
* after successful execution
|
||||
* @param unpacker Passed before
|
||||
* @param beforeSet False for callback before execution, true if called after successful
|
||||
* execution
|
||||
* @return
|
||||
*/
|
||||
virtual ReturnValue_t setParamCallback(SetParamMessageUnpacker &unpacker, bool afterExecution);
|
||||
|
||||
/**
|
||||
* @brief Function to generate the command to get a parameter from a
|
||||
* gomspace device. Command will be sent to the ComIF over the
|
||||
* rawPacket buffer.
|
||||
*/
|
||||
ReturnValue_t generateGetParamCommand(const uint8_t *commandData, size_t commandDataLen);
|
||||
|
||||
/**
|
||||
* @brief Function to generate the ping command for the ComIF.
|
||||
*/
|
||||
//ReturnValue_t generatePingCommand(const uint8_t *commandData, size_t commandDataLen);
|
||||
|
||||
/**
|
||||
* @brief Function to generate the command to reboot a gomspace device
|
||||
* via the ComIF.
|
||||
*/
|
||||
void generateRebootCommand();
|
||||
|
||||
/**
|
||||
* @brief Function to generate the command to force a ground watchdog
|
||||
* reset in a gomspace device.
|
||||
*/
|
||||
ReturnValue_t generateResetWatchdogCmd();
|
||||
virtual ReturnValue_t setParamCallback(uint16_t address, uint32_t value, uint8_t valueBytes,
|
||||
bool afterExecution);
|
||||
};
|
||||
|
||||
#endif /* MISSION_DEVICES_GOMSPACEDEVICEHANDLER_H_ */
|
||||
|
@ -29,49 +29,48 @@ void PDU1Handler::assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook, vo
|
||||
this->hookArgs = args;
|
||||
}
|
||||
|
||||
ReturnValue_t PDU1Handler::setParamCallback(SetParamMessageUnpacker &unpacker,
|
||||
bool afterExecution) {
|
||||
ReturnValue_t PDU1Handler::setParamCallback(uint16_t address, uint32_t value, uint8_t valueBytes, bool afterExecution) {
|
||||
using namespace PDU1;
|
||||
GOMSPACE::Pdu pdu = GOMSPACE::Pdu::PDU1;
|
||||
if (not afterExecution) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
if (channelSwitchHook != nullptr and unpacker.getParameterSize() == 1) {
|
||||
switch (unpacker.getAddress()) {
|
||||
if (channelSwitchHook != nullptr and valueBytes == 1) {
|
||||
switch (address) {
|
||||
case (CONFIG_ADDRESS_OUT_EN_TCS_BOARD_3V3): {
|
||||
channelSwitchHook(pdu, 0, unpacker.getParameter()[0], hookArgs);
|
||||
channelSwitchHook(pdu, 0, value, hookArgs);
|
||||
break;
|
||||
}
|
||||
case (CONFIG_ADDRESS_OUT_EN_SYRLINKS): {
|
||||
channelSwitchHook(pdu, 1, unpacker.getParameter()[0], hookArgs);
|
||||
channelSwitchHook(pdu, 1, value, hookArgs);
|
||||
break;
|
||||
}
|
||||
case (CONFIG_ADDRESS_OUT_EN_STAR_TRACKER): {
|
||||
channelSwitchHook(pdu, 2, unpacker.getParameter()[0], hookArgs);
|
||||
channelSwitchHook(pdu, 2, value, hookArgs);
|
||||
break;
|
||||
}
|
||||
case (CONFIG_ADDRESS_OUT_EN_MGT): {
|
||||
channelSwitchHook(pdu, 3, unpacker.getParameter()[0], hookArgs);
|
||||
channelSwitchHook(pdu, 3, value, hookArgs);
|
||||
break;
|
||||
}
|
||||
case (CONFIG_ADDRESS_OUT_EN_SUS_NOMINAL): {
|
||||
channelSwitchHook(pdu, 4, unpacker.getParameter()[0], hookArgs);
|
||||
channelSwitchHook(pdu, 4, value, hookArgs);
|
||||
break;
|
||||
}
|
||||
case (CONFIG_ADDRESS_OUT_EN_SOLAR_CELL_EXP): {
|
||||
channelSwitchHook(pdu, 5, unpacker.getParameter()[0], hookArgs);
|
||||
channelSwitchHook(pdu, 5, value, hookArgs);
|
||||
break;
|
||||
}
|
||||
case (CONFIG_ADDRESS_OUT_EN_PLOC): {
|
||||
channelSwitchHook(pdu, 6, unpacker.getParameter()[0], hookArgs);
|
||||
channelSwitchHook(pdu, 6, value, hookArgs);
|
||||
break;
|
||||
}
|
||||
case (CONFIG_ADDRESS_OUT_EN_ACS_BOARD_SIDE_A): {
|
||||
channelSwitchHook(pdu, 7, unpacker.getParameter()[0], hookArgs);
|
||||
channelSwitchHook(pdu, 7, value, hookArgs);
|
||||
break;
|
||||
}
|
||||
case (CONFIG_ADDRESS_OUT_EN_CHANNEL8): {
|
||||
channelSwitchHook(pdu, 8, unpacker.getParameter()[0], hookArgs);
|
||||
channelSwitchHook(pdu, 8, value, hookArgs);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class PDU1Handler : public GomspaceDeviceHandler {
|
||||
virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t* packet) override;
|
||||
ReturnValue_t printStatus(DeviceCommandId_t cmd) override;
|
||||
LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
|
||||
ReturnValue_t setParamCallback(SetParamMessageUnpacker& unpacker, bool afterExectuion) override;
|
||||
ReturnValue_t setParamCallback(uint16_t address, uint32_t value, uint8_t valueBytes, bool afterExecution) override;
|
||||
|
||||
private:
|
||||
static constexpr uint8_t MAX_CHANNEL_STR_WIDTH = 24;
|
||||
|
@ -127,49 +127,48 @@ void PDU2Handler::printHkTableLatchups() {
|
||||
printerHelper("Payload Camera", Channels::PAYLOAD_CAMERA);
|
||||
}
|
||||
|
||||
ReturnValue_t PDU2Handler::setParamCallback(SetParamMessageUnpacker &unpacker,
|
||||
bool afterExecution) {
|
||||
ReturnValue_t PDU2Handler::setParamCallback(uint16_t address, uint32_t value, uint8_t valueBytes, bool afterExecution) {
|
||||
using namespace PDU2;
|
||||
GOMSPACE::Pdu pdu = GOMSPACE::Pdu::PDU2;
|
||||
if (not afterExecution) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
if (channelSwitchHook != nullptr and unpacker.getParameterSize() == 1) {
|
||||
switch (unpacker.getAddress()) {
|
||||
if (channelSwitchHook != nullptr and valueBytes == 1) {
|
||||
switch (address) {
|
||||
case (CONFIG_ADDRESS_OUT_EN_Q7S): {
|
||||
channelSwitchHook(pdu, 0, unpacker.getParameter()[0], hookArgs);
|
||||
channelSwitchHook(pdu, 0, value, hookArgs);
|
||||
break;
|
||||
}
|
||||
case (CONFIG_ADDRESS_OUT_EN_PAYLOAD_PCDU_CH1): {
|
||||
channelSwitchHook(pdu, 1, unpacker.getParameter()[0], hookArgs);
|
||||
channelSwitchHook(pdu, 1, value, hookArgs);
|
||||
break;
|
||||
}
|
||||
case (CONFIG_ADDRESS_OUT_EN_RW): {
|
||||
channelSwitchHook(pdu, 2, unpacker.getParameter()[0], hookArgs);
|
||||
channelSwitchHook(pdu, 2, value, hookArgs);
|
||||
break;
|
||||
}
|
||||
case (CONFIG_ADDRESS_OUT_EN_TCS_BOARD_HEATER_IN): {
|
||||
channelSwitchHook(pdu, 3, unpacker.getParameter()[0], hookArgs);
|
||||
channelSwitchHook(pdu, 3, value, hookArgs);
|
||||
break;
|
||||
}
|
||||
case (CONFIG_ADDRESS_OUT_EN_SUS_REDUNDANT): {
|
||||
channelSwitchHook(pdu, 4, unpacker.getParameter()[0], hookArgs);
|
||||
channelSwitchHook(pdu, 4, value, hookArgs);
|
||||
break;
|
||||
}
|
||||
case (CONFIG_ADDRESS_OUT_EN_DEPLOYMENT_MECHANISM): {
|
||||
channelSwitchHook(pdu, 5, unpacker.getParameter()[0], hookArgs);
|
||||
channelSwitchHook(pdu, 5, value, hookArgs);
|
||||
break;
|
||||
}
|
||||
case (CONFIG_ADDRESS_OUT_EN_PAYLOAD_PCDU_CH6): {
|
||||
channelSwitchHook(pdu, 6, unpacker.getParameter()[0], hookArgs);
|
||||
channelSwitchHook(pdu, 6, value, hookArgs);
|
||||
break;
|
||||
}
|
||||
case (CONFIG_ADDRESS_OUT_EN_ACS_BOARD_SIDE_B): {
|
||||
channelSwitchHook(pdu, 7, unpacker.getParameter()[0], hookArgs);
|
||||
channelSwitchHook(pdu, 7, value, hookArgs);
|
||||
break;
|
||||
}
|
||||
case (CONFIG_ADDRESS_OUT_EN_PAYLOAD_CAMERA): {
|
||||
channelSwitchHook(pdu, 8, unpacker.getParameter()[0], hookArgs);
|
||||
channelSwitchHook(pdu, 8, value, hookArgs);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ class PDU2Handler : public GomspaceDeviceHandler {
|
||||
virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override;
|
||||
virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t* packet) override;
|
||||
ReturnValue_t printStatus(DeviceCommandId_t cmd) override;
|
||||
ReturnValue_t setParamCallback(SetParamMessageUnpacker& unpacker, bool afterExecution) override;
|
||||
ReturnValue_t setParamCallback(uint16_t address, uint32_t value, uint8_t valueBytes, bool afterExecution) override;
|
||||
LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
|
||||
|
||||
private:
|
||||
|
@ -332,14 +332,37 @@ class Pdu2FullTableReply : public SerialLinkedListAdapter<SerializeIF> {
|
||||
LinkedElement<SerializeIF> dataset;
|
||||
};
|
||||
|
||||
class SetParamMessageCache {
|
||||
public:
|
||||
SetParamMessageCache(): address(0), parameter(0), parameterSize(1) {}
|
||||
|
||||
void set(uint16_t address, uint32_t parameter, uint8_t parameterSize) {
|
||||
this->address = address;
|
||||
this->parameter = parameter;
|
||||
this->parameterSize = parameterSize;
|
||||
}
|
||||
|
||||
uint16_t getAddress() { return address; }
|
||||
|
||||
uint32_t getParameter() { return parameter; }
|
||||
|
||||
uint8_t getParameterSize() { return parameterSize; }
|
||||
|
||||
private:
|
||||
uint16_t address;
|
||||
uint32_t parameter;
|
||||
uint8_t parameterSize;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief This class helps to unpack information from an action message
|
||||
* to set a parameter in gomspace devices. The action message can be
|
||||
* for example received from the PUS Service 8.
|
||||
*/
|
||||
/*
|
||||
class SetParamMessageUnpacker : public SerialLinkedListAdapter<SerializeIF> {
|
||||
public:
|
||||
/* Largest parameter is a uint32_t */
|
||||
// Largest parameter is a uint32_t
|
||||
static const uint32_t MAX_SIZE = 4;
|
||||
|
||||
SetParamMessageUnpacker() { setLinks(); }
|
||||
@ -358,7 +381,7 @@ class SetParamMessageUnpacker : public SerialLinkedListAdapter<SerializeIF> {
|
||||
SetParamMessageUnpacker(const SetParamMessageUnpacker &message);
|
||||
SerializeElement<uint16_t> address;
|
||||
SerializeElement<SerialFixedArrayListAdapter<uint8_t, MAX_SIZE, uint8_t>> parameter;
|
||||
};
|
||||
};*/
|
||||
|
||||
/**
|
||||
* @brief This class generates a message which can be sent to the GomspaceDeviceHandler to
|
||||
@ -405,6 +428,7 @@ class GomspaceSetParamMessage : public SerialLinkedListAdapter<SerializeIF> {
|
||||
* to get a parameter from gomspace devices. The action message can be
|
||||
* for example received from the PUS Service 8.
|
||||
*/
|
||||
/*
|
||||
class GetParamMessageUnpacker : public SerialLinkedListAdapter<SerializeIF> {
|
||||
public:
|
||||
GetParamMessageUnpacker() { setLinks(); }
|
||||
@ -424,8 +448,8 @@ class GetParamMessageUnpacker : public SerialLinkedListAdapter<SerializeIF> {
|
||||
}
|
||||
SerializeElement<uint8_t> tableId;
|
||||
SerializeElement<uint16_t> address; // The memory address offset within the table
|
||||
/* The size of the requested value (e.g. temperature is a uint16_t value) */
|
||||
// The size of the requested value (e.g. temperature is a uint16_t value)
|
||||
SerializeElement<uint8_t> parameterSize;
|
||||
};
|
||||
};*/
|
||||
|
||||
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEPACKETS_H_ */
|
||||
|
@ -10,11 +10,9 @@ class GomspaceDeviceHandler;
|
||||
class PingAction : public TemplateAction<GomspaceDeviceHandler, PingAction, GomspaceCommands> {
|
||||
public:
|
||||
PingAction(GomspaceDeviceHandler* owner) : TemplateAction(owner, GomspaceCommands::PING) {}
|
||||
};
|
||||
|
||||
class NoneAction : public TemplateAction<GomspaceDeviceHandler, NoneAction, GomspaceCommands> {
|
||||
public:
|
||||
NoneAction(GomspaceDeviceHandler* owner) : TemplateAction(owner, GomspaceCommands::NONE) {}
|
||||
// TODO array
|
||||
Parameter<uint8_t> pingData = Parameter<uint8_t>::createParameter(this, "Ping Data");
|
||||
};
|
||||
|
||||
class RebootAction : public TemplateAction<GomspaceDeviceHandler, RebootAction, GomspaceCommands> {
|
||||
@ -32,15 +30,33 @@ class GndwdtResetAction
|
||||
class ParamGetAction
|
||||
: public TemplateAction<GomspaceDeviceHandler, ParamGetAction, 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) {}
|
||||
|
||||
Parameter<TableId> tableId =
|
||||
Parameter<TableId>::createParameter(this, "Table");
|
||||
Parameter<uint16_t> address = Parameter<uint16_t>::createParameter(this, "Address");
|
||||
Parameter<ParameterByteSize> parameterSize =
|
||||
Parameter<ParameterByteSize>::createParameter(this, "Parameter Size");
|
||||
};
|
||||
|
||||
class ParamSetAction
|
||||
: public TemplateAction<GomspaceDeviceHandler, ParamSetAction, 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) {}
|
||||
|
||||
Parameter<uint16_t> address = Parameter<uint16_t>::createParameter(this, "Address");
|
||||
Parameter<uint32_t> parameter = Parameter<uint32_t>::createParameter(this, "Parameter Value");
|
||||
Parameter<ParameterByteSize> parameterSize =
|
||||
Parameter<ParameterByteSize>::createParameter(this, "Parameter Size");
|
||||
};
|
||||
|
||||
class RequestHkTableAction
|
||||
|
Loading…
x
Reference in New Issue
Block a user