some simplifications
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
Robin Müller 2022-09-01 15:23:39 +02:00
parent 3d71cce30b
commit 4e92fd4421
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
4 changed files with 80 additions and 40 deletions

View File

@ -86,48 +86,41 @@ ReturnValue_t GomspaceDeviceHandler::buildCommandFromCommand(DeviceCommandId_t d
break; break;
} }
case (GOMSPACE::REQUEST_HK_TABLE): { case (GOMSPACE::REQUEST_HK_TABLE): {
auto reqType = SpecialRequestTypes::DEFAULT_COM_IF; DeviceType devType;
if (getObjectId() == objects::PDU1_HANDLER or getObjectId() == objects::PDU2_HANDLER) { if(getDevType(devType) != returnvalue::OK) {
reqType = SpecialRequestTypes::GET_PDU_HK; return returnvalue::FAILED;
} else if (getObjectId() == objects::ACU_HANDLER) {
reqType = SpecialRequestTypes::GET_ACU_HK;
} else if (getObjectId() == objects::P60DOCK_HANDLER) {
reqType = SpecialRequestTypes::GET_P60DOCK_HK;
} }
result = generateRequestFullTableCmd(reqType, GOMSPACE::TableIds::HK, tableCfg.hkTableSize, result =
deviceCommand, cspCookie); generateRequestFullHkTableCmd(devType, tableCfg.hkTableSize, deviceCommand, cspCookie);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
break; break;
} }
case (GOMSPACE::REQUEST_CONFIG_TABLE): { case (GOMSPACE::REQUEST_CONFIG_TABLE): {
auto reqType = SpecialRequestTypes::DEFAULT_COM_IF; DeviceType devType;
if (getObjectId() == objects::PDU1_HANDLER or getObjectId() == objects::PDU2_HANDLER) { if(getDevType(devType) != returnvalue::OK) {
reqType = SpecialRequestTypes::GET_PDU_CONFIG; return returnvalue::FAILED;
} else if (getObjectId() == objects::ACU_HANDLER) {
reqType = SpecialRequestTypes::GET_ACU_CONFIG;
} else if (getObjectId() == objects::P60DOCK_HANDLER) {
reqType = SpecialRequestTypes::GET_P60DOCK_CONFIG;
} }
result = generateRequestFullTableCmd(reqType, GOMSPACE::TableIds::CONFIG, result = generateRequestFullCfgTableCmd(devType, tableCfg.cfgTableSize,
tableCfg.cfgTableSize, deviceCommand, cspCookie); deviceCommand, cspCookie);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
break; break;
} }
case (GOMSPACE::SAVE_TABLE_FILE): { case (GOMSPACE::SAVE_TABLE_FILE): {
if(commandDataLen > 2) { if (commandDataLen > 2) {
return HasActionsIF::INVALID_PARAMETERS; return HasActionsIF::INVALID_PARAMETERS;
} }
auto* info = reinterpret_cast<GOMSPACE::TableInfo*>(cspPacket); auto* info = reinterpret_cast<GOMSPACE::TableInfo*>(cspPacket);
if(commandData[0] != 0 and commandData[0] != 1 and commandData[0] != 2 and commandData[0] != 4) { if (commandData[0] != 0 and commandData[0] != 1 and commandData[0] != 2 and
commandData[0] != 4) {
return HasActionsIF::INVALID_PARAMETERS; return HasActionsIF::INVALID_PARAMETERS;
} }
info->sourceTable = commandData[0]; info->sourceTable = commandData[0];
if (info->sourceTable != 4) { if (info->sourceTable != 4) {
if(commandDataLen == 2) { if (commandDataLen == 2) {
info->targetTable = commandData[1]; info->targetTable = commandData[1];
} else { } else {
info->targetTable = info->sourceTable; info->targetTable = info->sourceTable;
@ -142,11 +135,11 @@ ReturnValue_t GomspaceDeviceHandler::buildCommandFromCommand(DeviceCommandId_t d
break; break;
} }
case (GOMSPACE::SAVE_TABLE_DEFAULT): { case (GOMSPACE::SAVE_TABLE_DEFAULT): {
if(commandDataLen != 1) { if (commandDataLen != 1) {
return HasActionsIF::INVALID_PARAMETERS; return HasActionsIF::INVALID_PARAMETERS;
} }
auto* info = reinterpret_cast<GOMSPACE::TableInfo*>(cspPacket); auto* info = reinterpret_cast<GOMSPACE::TableInfo*>(cspPacket);
if(commandData[0] != 0 and commandData[0] != 1 and commandData[0] != 2) { if (commandData[0] != 0 and commandData[0] != 1 and commandData[0] != 2) {
return HasActionsIF::INVALID_PARAMETERS; return HasActionsIF::INVALID_PARAMETERS;
} }
info->sourceTable = commandData[0]; info->sourceTable = commandData[0];
@ -486,6 +479,19 @@ bool GomspaceDeviceHandler::validTableId(uint8_t id) {
return false; return false;
} }
ReturnValue_t GomspaceDeviceHandler::getDevType(GOMSPACE::DeviceType& type) const {
if (getObjectId() == objects::PDU1_HANDLER or getObjectId() == objects::PDU2_HANDLER) {
type = DeviceType::PDU;
} else if (getObjectId() == objects::ACU_HANDLER) {
type = DeviceType::ACU;
} else if (getObjectId() == objects::P60DOCK_HANDLER) {
type = DeviceType::P60DOCK;
} else {
return returnvalue::FAILED;
}
return returnvalue::OK;
}
ReturnValue_t GomspaceDeviceHandler::generateResetWatchdogCmd() { ReturnValue_t GomspaceDeviceHandler::generateResetWatchdogCmd() {
WatchdogResetCommand watchdogResetCommand; WatchdogResetCommand watchdogResetCommand;
size_t cspPacketLen = 0; size_t cspPacketLen = 0;
@ -505,19 +511,40 @@ ReturnValue_t GomspaceDeviceHandler::generateResetWatchdogCmd() {
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t GomspaceDeviceHandler::generateRequestFullTableCmd(SpecialRequestTypes reqType, ReturnValue_t GomspaceDeviceHandler::generateRequestFullHkTableCmd(DeviceType dev,
uint8_t tableId, uint16_t tableReplySize,
uint16_t tableReplySize, DeviceCommandId_t id,
DeviceCommandId_t id, CspCookie* cspCookie) {
CspCookie* cspCookie) { if (dev == DeviceType::ACU) {
uint16_t querySize = tableReplySize; cspCookie->setRequest(SpecialRequestTypes::GET_ACU_HK, tableReplySize);
if (reqType == SpecialRequestTypes::DEFAULT_COM_IF) { } else if (dev == DeviceType::P60DOCK) {
sif::warning << "Default communication for table requests not implemented anymore" << std::endl; cspCookie->setRequest(SpecialRequestTypes::GET_P60DOCK_HK, tableReplySize);
return returnvalue::FAILED; } else if (dev == DeviceType::PDU) {
cspCookie->setRequest(SpecialRequestTypes::GET_PDU_HK, tableReplySize);
} }
cspCookie->setRequest(reqType, tableReplySize);
cspCookie->setCspPort(CspPorts::P60_PORT_RPARAM_ENUM); cspCookie->setCspPort(CspPorts::P60_PORT_RPARAM_ENUM);
rememberRequestedSize = querySize; rememberRequestedSize = tableReplySize;
rememberCommandId = id;
return returnvalue::OK;
}
ReturnValue_t GomspaceDeviceHandler::generateRequestFullCfgTableCmd(DeviceType dev,
uint16_t tableReplySize,
DeviceCommandId_t id,
CspCookie* cspCookie) {
if (dev == DeviceType::ACU) {
cspCookie->setRequest(SpecialRequestTypes::GET_ACU_CONFIG, tableReplySize);
} else if (dev == DeviceType::P60DOCK) {
cspCookie->setRequest(SpecialRequestTypes::GET_P60DOCK_CONFIG, tableReplySize);
} else if (dev == DeviceType::PDU) {
cspCookie->setRequest(SpecialRequestTypes::GET_PDU_CONFIG, tableReplySize);
}
cspCookie->setCspPort(CspPorts::P60_PORT_RPARAM_ENUM);
// Unfortunately, this does not work..
// cspPacket[0] = defaultTable;
// rawPacket = cspPacket;
// rawPacketLen = 1;
rememberRequestedSize = tableReplySize;
rememberCommandId = id; rememberCommandId = id;
return returnvalue::OK; return returnvalue::OK;
} }

View File

@ -82,10 +82,21 @@ class GomspaceDeviceHandler : public DeviceHandlerBase {
* @brief The command to generate a request to receive the full housekeeping table is device * @brief The command to generate a request to receive the full housekeeping table is device
* specific. Thus the child has to build this command. * specific. Thus the child has to build this command.
*/ */
virtual ReturnValue_t generateRequestFullTableCmd(GOMSPACE::SpecialRequestTypes reqType, ReturnValue_t generateRequestFullHkTableCmd(GOMSPACE::DeviceType devType, uint16_t tableSize,
uint8_t tableId, uint16_t tableSize, DeviceCommandId_t id, CspCookie *cspCookie);
DeviceCommandId_t id, CspCookie* cspCookie); /**
* Unfortunately, it was not possible to specify the table ID (e.g. request table from
* default store)
* @param devType
* @param tableSize
* @param id
* @param cspCookie
* @return
*/
ReturnValue_t generateRequestFullCfgTableCmd(GOMSPACE::DeviceType devType,
uint16_t tableSize, DeviceCommandId_t id,
CspCookie *cspCookie);
ReturnValue_t getDevType(GOMSPACE::DeviceType& type) const;
/** /**
* This command handles printing the HK table to the console. This is useful for debugging * This command handles printing the HK table to the console. This is useful for debugging
* purposes * purposes

View File

@ -23,6 +23,8 @@ struct TableInfo {
uint8_t targetTable; uint8_t targetTable;
}; };
enum DeviceType { PDU, ACU, P60DOCK };
enum SpecialRequestTypes { enum SpecialRequestTypes {
DEFAULT_COM_IF, DEFAULT_COM_IF,
GET_PDU_HK, GET_PDU_HK,
@ -68,7 +70,7 @@ static const DeviceCommandId_t REQUEST_HK_TABLE = 16; //!< [EXPORT] : [COMM
static const DeviceCommandId_t REQUEST_CONFIG_TABLE = 17; //!< [EXPORT] : [COMMAND] static const DeviceCommandId_t REQUEST_CONFIG_TABLE = 17; //!< [EXPORT] : [COMMAND]
static const DeviceCommandId_t SAVE_TABLE_FILE = 18; static const DeviceCommandId_t SAVE_TABLE_FILE = 18;
static const DeviceCommandId_t SAVE_TABLE_DEFAULT = 19; static const DeviceCommandId_t SAVE_TABLE_DEFAULT = 19;
static const DeviceCommandId_t PARAM_SET = 255; //!< [EXPORT] : [COMMAND] static const DeviceCommandId_t PARAM_SET = 255; //!< [EXPORT] : [COMMAND]
// Not implemented yet // Not implemented yet
// static const DeviceCommandId_t REQUEST_CALIB_TABLE = 18; //!< [EXPORT] : [COMMAND] // static const DeviceCommandId_t REQUEST_CALIB_TABLE = 18; //!< [EXPORT] : [COMMAND]

2
tmtc

@ -1 +1 @@
Subproject commit cc31a756856623ecc2eec80e155557ac208f10a2 Subproject commit abecbe44016313f1b51a29d1358fccb9f541d542