GomSpace commands #293

Merged
meierj merged 6 commits from mueller/new-gomspace-commdsn into develop 2022-09-02 12:40:45 +02:00
9 changed files with 176 additions and 42 deletions

2
fsfw

@ -1 +1 @@
Subproject commit 2fa76d366325372e92a2188f71f143a485e652fc
Subproject commit cf8fe7ea728bea077b9936bcf0db96845bc6419e

View File

@ -166,6 +166,26 @@ ReturnValue_t CspComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s
if (result != 0) {
return returnvalue::FAILED;
}
} else if(req == GOMSPACE::SpecialRequestTypes::SAVE_TABLE) {
if(sendLen < 2) {
return returnvalue::FAILED;
}
const TableInfo* tableInfo = reinterpret_cast<const TableInfo*>(sendData);
int result = gs_rparam_save(cspAddress, cspCookie->getTimeout(), tableInfo->sourceTable,
tableInfo->targetTable);
if (result != 0) {
return returnvalue::FAILED;
}
} else if(req == GOMSPACE::SpecialRequestTypes::LOAD_TABLE) {
if(sendLen < 2) {
return returnvalue::FAILED;
}
const TableInfo* tableInfo = reinterpret_cast<const TableInfo*>(sendData);
int result = gs_rparam_load(cspAddress, cspCookie->getTimeout(), tableInfo->sourceTable,
tableInfo->targetTable);
if (result != 0) {
return returnvalue::FAILED;
}
}
} else {
/* No CSP fixed port was selected. Send data to the specified port and

View File

@ -96,7 +96,7 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_) {
PsbParams(objects::PUS_SERVICE_5_EVENT_REPORTING, apid::EIVE_OBSW, pus::PUS_SERVICE_5), 15,
45);
new Service8FunctionManagement(objects::PUS_SERVICE_8_FUNCTION_MGMT, apid::EIVE_OBSW,
pus::PUS_SERVICE_8, 3, 60);
pus::PUS_SERVICE_8, 16, 60);
new Service9TimeManagement(
PsbParams(objects::PUS_SERVICE_9_TIME_MGMT, apid::EIVE_OBSW, pus::PUS_SERVICE_9));

View File

@ -1,10 +1,11 @@
#include "CspCookie.h"
using namespace GOMSPACE;
CspCookie::CspCookie(uint16_t maxReplyLength_, uint8_t cspAddress_, uint32_t timeoutMs)
: maxReplyLength(maxReplyLength_),
cspAddress(cspAddress_),
timeoutMs(timeoutMs),
reqType(GOMSPACE::DEFAULT_COM_IF) {}
reqType(SpecialRequestTypes::DEFAULT_COM_IF) {}
CspCookie::~CspCookie() {}

View File

@ -28,7 +28,7 @@ class CspCookie : public CookieIF {
uint32_t getTimeout() const;
private:
uint8_t cspPort;
uint8_t cspPort = 0;
uint16_t maxReplyLength;
uint8_t cspAddress;
size_t replyLen = 0;

View File

@ -44,6 +44,8 @@ ReturnValue_t GomspaceDeviceHandler::buildTransitionDeviceCommand(DeviceCommandI
ReturnValue_t GomspaceDeviceHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t* commandData,
size_t commandDataLen) {
auto* cspCookie = dynamic_cast<CspCookie*>(comCookie);
cspCookie->setRequest(SpecialRequestTypes::DEFAULT_COM_IF, 0);
ReturnValue_t result = childCommandHook(deviceCommand, commandData, commandDataLen);
switch (deviceCommand) {
case (GOMSPACE::PING): {
@ -84,37 +86,87 @@ ReturnValue_t GomspaceDeviceHandler::buildCommandFromCommand(DeviceCommandId_t d
break;
}
case (GOMSPACE::REQUEST_HK_TABLE): {
auto reqType = SpecialRequestTypes::DEFAULT_COM_IF;
if (getObjectId() == objects::PDU1_HANDLER or getObjectId() == objects::PDU2_HANDLER) {
reqType = SpecialRequestTypes::GET_PDU_HK;
} else if (getObjectId() == objects::ACU_HANDLER) {
reqType = SpecialRequestTypes::GET_ACU_HK;
} else if (getObjectId() == objects::P60DOCK_HANDLER) {
reqType = SpecialRequestTypes::GET_P60DOCK_HK;
DeviceType devType;
if(getDevType(devType) != returnvalue::OK) {
return returnvalue::FAILED;
}
result = generateRequestFullTableCmd(reqType, GOMSPACE::TableIds::HK, tableCfg.hkTableSize,
deviceCommand);
result =
generateRequestFullHkTableCmd(devType, tableCfg.hkTableSize, deviceCommand, cspCookie);
if (result != returnvalue::OK) {
return result;
}
break;
}
case (GOMSPACE::REQUEST_CONFIG_TABLE): {
auto reqType = SpecialRequestTypes::DEFAULT_COM_IF;
if (getObjectId() == objects::PDU1_HANDLER or getObjectId() == objects::PDU2_HANDLER) {
reqType = SpecialRequestTypes::GET_PDU_CONFIG;
} else if (getObjectId() == objects::ACU_HANDLER) {
reqType = SpecialRequestTypes::GET_ACU_CONFIG;
} else if (getObjectId() == objects::P60DOCK_HANDLER) {
reqType = SpecialRequestTypes::GET_P60DOCK_CONFIG;
DeviceType devType;
if(getDevType(devType) != returnvalue::OK) {
return returnvalue::FAILED;
}
result = generateRequestFullTableCmd(reqType, GOMSPACE::TableIds::CONFIG,
tableCfg.cfgTableSize, deviceCommand);
result = generateRequestFullCfgTableCmd(devType, tableCfg.cfgTableSize,
deviceCommand, cspCookie);
if (result != returnvalue::OK) {
return result;
}
break;
}
case (GOMSPACE::LOAD_TABLE): {
if (commandDataLen != 2) {
return HasActionsIF::INVALID_PARAMETERS;
}
auto* info = reinterpret_cast<GOMSPACE::TableInfo*>(cspPacket);
info->sourceTable = commandData[0];
info->targetTable = commandData[1];
rawPacket = cspPacket;
rawPacketLen = sizeof(GOMSPACE::TableInfo);
cspCookie->setCspPort(CspPorts::P60_PORT_RPARAM_ENUM);
cspCookie->setRequest(SpecialRequestTypes::LOAD_TABLE, 0);
rememberCommandId = deviceCommand;
break;
}
case (GOMSPACE::SAVE_TABLE_FILE): {
if (commandDataLen > 2) {
return HasActionsIF::INVALID_PARAMETERS;
}
auto* info = reinterpret_cast<GOMSPACE::TableInfo*>(cspPacket);
if (commandData[0] != 0 and commandData[0] != 1 and commandData[0] != 2 and
commandData[0] != 4) {
return HasActionsIF::INVALID_PARAMETERS;
}
info->sourceTable = commandData[0];
if (info->sourceTable != 4) {
if (commandDataLen == 2) {
info->targetTable = commandData[1];
} else {
info->targetTable = info->sourceTable;
}
} else {
// Will be ignored, still set the value which is always used
info->targetTable = 4;
}
rawPacket = cspPacket;
rawPacketLen = sizeof(GOMSPACE::TableInfo);
cspCookie->setCspPort(CspPorts::P60_PORT_RPARAM_ENUM);
cspCookie->setRequest(SpecialRequestTypes::SAVE_TABLE, 0);
rememberCommandId = deviceCommand;
break;
}
case (GOMSPACE::SAVE_TABLE_DEFAULT): {
if (commandDataLen != 1) {
return HasActionsIF::INVALID_PARAMETERS;
}
auto* info = reinterpret_cast<GOMSPACE::TableInfo*>(cspPacket);
if (commandData[0] != 0 and commandData[0] != 1 and commandData[0] != 2) {
return HasActionsIF::INVALID_PARAMETERS;
}
info->sourceTable = commandData[0];
info->targetTable = info->sourceTable + 4;
rawPacket = cspPacket;
rawPacketLen = sizeof(GOMSPACE::TableInfo);
cspCookie->setCspPort(CspPorts::P60_PORT_RPARAM_ENUM);
cspCookie->setRequest(SpecialRequestTypes::SAVE_TABLE, 0);
rememberCommandId = deviceCommand;
break;
}
default:
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
}
@ -131,6 +183,9 @@ void GomspaceDeviceHandler::fillCommandAndReplyMap() {
this->insertInCommandMap(GOMSPACE::GNDWDT_RESET);
this->insertInCommandMap(GOMSPACE::PRINT_SWITCH_V_I);
this->insertInCommandMap(GOMSPACE::PRINT_LATCHUPS);
insertInCommandMap(GOMSPACE::SAVE_TABLE_FILE);
insertInCommandMap(GOMSPACE::SAVE_TABLE_DEFAULT);
insertInCommandMap(GOMSPACE::LOAD_TABLE);
}
ReturnValue_t GomspaceDeviceHandler::scanForReply(const uint8_t* start, size_t remainingSize,
@ -443,6 +498,19 @@ bool GomspaceDeviceHandler::validTableId(uint8_t id) {
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() {
WatchdogResetCommand watchdogResetCommand;
size_t cspPacketLen = 0;
@ -462,19 +530,40 @@ ReturnValue_t GomspaceDeviceHandler::generateResetWatchdogCmd() {
return returnvalue::OK;
}
ReturnValue_t GomspaceDeviceHandler::generateRequestFullTableCmd(SpecialRequestTypes reqType,
uint8_t tableId,
ReturnValue_t GomspaceDeviceHandler::generateRequestFullHkTableCmd(DeviceType dev,
uint16_t tableReplySize,
DeviceCommandId_t id) {
uint16_t querySize = tableReplySize;
if (reqType == SpecialRequestTypes::DEFAULT_COM_IF) {
sif::warning << "Default communication for table requests not implemented anymore" << std::endl;
return returnvalue::FAILED;
DeviceCommandId_t id,
CspCookie* cspCookie) {
if (dev == DeviceType::ACU) {
cspCookie->setRequest(SpecialRequestTypes::GET_ACU_HK, tableReplySize);
} else if (dev == DeviceType::P60DOCK) {
cspCookie->setRequest(SpecialRequestTypes::GET_P60DOCK_HK, tableReplySize);
} else if (dev == DeviceType::PDU) {
cspCookie->setRequest(SpecialRequestTypes::GET_PDU_HK, tableReplySize);
}
auto* cspCookie = dynamic_cast<CspCookie*>(comCookie);
cspCookie->setRequest(reqType, tableReplySize);
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;
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
* specific. Thus the child has to build this command.
*/
virtual ReturnValue_t generateRequestFullTableCmd(GOMSPACE::SpecialRequestTypes reqType,
uint8_t tableId, uint16_t tableSize,
DeviceCommandId_t id);
ReturnValue_t generateRequestFullHkTableCmd(GOMSPACE::DeviceType devType, uint16_t tableSize,
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
* purposes

View File

@ -18,14 +18,23 @@
namespace GOMSPACE {
enum SpecialRequestTypes {
struct TableInfo {
uint8_t sourceTable;
uint8_t targetTable;
};
enum DeviceType { PDU, ACU, P60DOCK };
enum class SpecialRequestTypes {
DEFAULT_COM_IF,
GET_PDU_HK,
GET_PDU_CONFIG,
GET_ACU_HK,
GET_ACU_CONFIG,
GET_P60DOCK_HK,
GET_P60DOCK_CONFIG
GET_P60DOCK_CONFIG,
SAVE_TABLE,
LOAD_TABLE
};
enum CspPorts : uint8_t {
@ -53,14 +62,18 @@ static const uint8_t P60_PORT_GNDWDT_RESET = 9;
* Device commands are derived from the rparam.h of the gomspace lib..
* IDs above 50 are reserved for device specific commands.
*/
static const DeviceCommandId_t PARAM_GET = 0; //!< [EXPORT] : [COMMAND]
static const DeviceCommandId_t PING = 1; //!< [EXPORT] : [COMMAND]
static const DeviceCommandId_t NONE = 2; // Set when no command is pending
static const DeviceCommandId_t REBOOT = 4; //!< [EXPORT] : [COMMAND]
static const DeviceCommandId_t GNDWDT_RESET = 9; //!< [EXPORT] : [COMMAND]
static const DeviceCommandId_t PARAM_GET = 0; //!< [EXPORT] : [COMMAND]
static const DeviceCommandId_t PARAM_SET = 255; //!< [EXPORT] : [COMMAND]
static const DeviceCommandId_t REQUEST_HK_TABLE = 16; //!< [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_DEFAULT = 19;
static const DeviceCommandId_t LOAD_TABLE = 20;
static const DeviceCommandId_t PARAM_SET = 255; //!< [EXPORT] : [COMMAND]
// Not implemented yet
// static const DeviceCommandId_t REQUEST_CALIB_TABLE = 18; //!< [EXPORT] : [COMMAND]
//! [EXPORT] : [COMMAND] Print switch states, voltages and currents to the console

2
tmtc

@ -1 +1 @@
Subproject commit 05dd17386070b9f333977f1f2b9f5651f9053b65
Subproject commit f366b1c3f61f9d19bc0a5829caecdd2ae4285601