tmtc update
This commit is contained in:
@ -5,7 +5,8 @@ GomspaceDeviceHandler::GomspaceDeviceHandler(object_id_t objectId, object_id_t c
|
||||
CookieIF * comCookie, uint16_t maxConfigTableAddress, uint16_t maxHkTableAddress,
|
||||
uint16_t hkTableReplySize, LocalPoolDataSetBase* hkTableDataset) :
|
||||
DeviceHandlerBase(objectId, comIF, comCookie), maxConfigTableAddress(maxConfigTableAddress),
|
||||
maxHkTableAddress(maxHkTableAddress), hkTableReplySize(hkTableReplySize), hkTableDataset(hkTableDataset) {
|
||||
maxHkTableAddress(maxHkTableAddress), hkTableReplySize(hkTableReplySize),
|
||||
hkTableDataset(hkTableDataset) {
|
||||
if (comCookie == NULL) {
|
||||
sif::error << "GomspaceDeviceHandler::GomspaceDeviceHandler: Invalid com cookie"
|
||||
<< std::endl;
|
||||
@ -28,157 +29,157 @@ void GomspaceDeviceHandler::doShutDown(){
|
||||
}
|
||||
|
||||
ReturnValue_t GomspaceDeviceHandler::buildNormalDeviceCommand(
|
||||
DeviceCommandId_t * id) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
DeviceCommandId_t * id) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t GomspaceDeviceHandler::buildTransitionDeviceCommand(
|
||||
DeviceCommandId_t * id){
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
DeviceCommandId_t * id){
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t GomspaceDeviceHandler::buildCommandFromCommand(
|
||||
DeviceCommandId_t deviceCommand, const uint8_t * commandData,
|
||||
size_t commandDataLen) {
|
||||
ReturnValue_t result;
|
||||
switch(deviceCommand) {
|
||||
case(GOMSPACE::PING): {
|
||||
result = generatePingCommand(commandData, commandDataLen);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(GOMSPACE::REBOOT): {
|
||||
generateRebootCommand();
|
||||
break;
|
||||
}
|
||||
case(GOMSPACE::PARAM_SET):{
|
||||
result = generateSetParamCommand(commandData, commandDataLen);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
return result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(GOMSPACE::PARAM_GET):{
|
||||
result = generateGetParamCommand(commandData, commandDataLen);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
return result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(GOMSPACE::GNDWDT_RESET): {
|
||||
result = generateResetWatchdogCmd();
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
return result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(GOMSPACE::REQUEST_HK_TABLE): {
|
||||
result = generateRequestFullHkTableCmd(hkTableReplySize);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
DeviceCommandId_t deviceCommand, const uint8_t * commandData,
|
||||
size_t commandDataLen) {
|
||||
ReturnValue_t result;
|
||||
switch(deviceCommand) {
|
||||
case(GOMSPACE::PING): {
|
||||
result = generatePingCommand(commandData, commandDataLen);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
case(GOMSPACE::REBOOT): {
|
||||
generateRebootCommand();
|
||||
break;
|
||||
}
|
||||
case(GOMSPACE::PARAM_SET):{
|
||||
result = generateSetParamCommand(commandData, commandDataLen);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
return result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(GOMSPACE::PARAM_GET):{
|
||||
result = generateGetParamCommand(commandData, commandDataLen);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
return result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(GOMSPACE::GNDWDT_RESET): {
|
||||
result = generateResetWatchdogCmd();
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
return result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(GOMSPACE::REQUEST_HK_TABLE): {
|
||||
result = generateRequestFullHkTableCmd(hkTableReplySize);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
return result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void GomspaceDeviceHandler::fillCommandAndReplyMap(){
|
||||
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->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);
|
||||
}
|
||||
|
||||
ReturnValue_t GomspaceDeviceHandler::scanForReply(const uint8_t *start,
|
||||
size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) {
|
||||
switch(rememberCommandId) {
|
||||
case(GOMSPACE::PING):
|
||||
*foundId = GOMSPACE::PING;
|
||||
*foundLen = PING_REPLY_SIZE;
|
||||
rememberCommandId = GOMSPACE::NONE;
|
||||
break;
|
||||
case(GOMSPACE::PARAM_GET): {
|
||||
*foundId = GOMSPACE::PARAM_GET;
|
||||
*foundLen = rememberRequestedSize + GOMSPACE::GS_HDR_LENGTH;
|
||||
rememberCommandId = GOMSPACE::NONE;
|
||||
break;
|
||||
}
|
||||
case(GOMSPACE::PARAM_SET): {
|
||||
*foundId = GOMSPACE::PARAM_SET;
|
||||
*foundLen = rememberRequestedSize;
|
||||
rememberCommandId = GOMSPACE::NONE;
|
||||
break;
|
||||
}
|
||||
case(GOMSPACE::REQUEST_HK_TABLE): {
|
||||
*foundId = GOMSPACE::REQUEST_HK_TABLE;
|
||||
*foundLen = rememberRequestedSize + GOMSPACE::GS_HDR_LENGTH;
|
||||
rememberCommandId = GOMSPACE::NONE;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return IGNORE_REPLY_DATA;
|
||||
}
|
||||
switch(rememberCommandId) {
|
||||
case(GOMSPACE::PING):
|
||||
*foundId = GOMSPACE::PING;
|
||||
*foundLen = PING_REPLY_SIZE;
|
||||
rememberCommandId = GOMSPACE::NONE;
|
||||
break;
|
||||
case(GOMSPACE::PARAM_GET): {
|
||||
*foundId = GOMSPACE::PARAM_GET;
|
||||
*foundLen = rememberRequestedSize + GOMSPACE::GS_HDR_LENGTH;
|
||||
rememberCommandId = GOMSPACE::NONE;
|
||||
break;
|
||||
}
|
||||
case(GOMSPACE::PARAM_SET): {
|
||||
*foundId = GOMSPACE::PARAM_SET;
|
||||
*foundLen = rememberRequestedSize;
|
||||
rememberCommandId = GOMSPACE::NONE;
|
||||
break;
|
||||
}
|
||||
case(GOMSPACE::REQUEST_HK_TABLE): {
|
||||
*foundId = GOMSPACE::REQUEST_HK_TABLE;
|
||||
*foundLen = rememberRequestedSize + GOMSPACE::GS_HDR_LENGTH;
|
||||
rememberCommandId = GOMSPACE::NONE;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return IGNORE_REPLY_DATA;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t GomspaceDeviceHandler::interpretDeviceReply(DeviceCommandId_t id,
|
||||
const uint8_t *packet) {
|
||||
switch(id) {
|
||||
case(GOMSPACE::PING): {
|
||||
SerializeElement<uint32_t> replyTime = *packet;
|
||||
handleDeviceTM(&replyTime, id, true);
|
||||
break;
|
||||
}
|
||||
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)){
|
||||
sif::error << "GomspaceDeviceHandler: PARAM_GET: Invalid payload "
|
||||
<< "size in reply" << std::endl;
|
||||
return INVALID_PAYLOAD_SIZE;
|
||||
}
|
||||
uint8_t tempPayloadBuffer[payloadLength];
|
||||
/* Extract information from received data */
|
||||
CspGetParamReply cspGetParamReply(tempPayloadBuffer, payloadLength);
|
||||
size_t size = GOMSPACE::GS_HDR_LENGTH + payloadLength;
|
||||
ReturnValue_t result = cspGetParamReply.deSerialize(&packet, &size,
|
||||
SerializeIF::Endianness::BIG);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
sif::error << "GomspaceDeviceHandler: Failed to deserialize get parameter"
|
||||
<< "reply" << std::endl;
|
||||
return result;
|
||||
}
|
||||
uint8_t action = cspGetParamReply.getAction();
|
||||
uint8_t tableId = cspGetParamReply.getTableId();
|
||||
uint16_t address = cspGetParamReply.getAddress();
|
||||
/* Pack relevant information into a tm packet */
|
||||
ParamReply paramReply(action, tableId, address, payloadLength,
|
||||
tempPayloadBuffer);
|
||||
handleDeviceTM(¶mReply, id, true);
|
||||
break;
|
||||
}
|
||||
case(GOMSPACE::PARAM_SET): {
|
||||
/* When setting a parameter, the p60dock sends back the state of the
|
||||
* operation */
|
||||
if(*packet != PARAM_SET_OK){
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(GOMSPACE::REQUEST_HK_TABLE): {
|
||||
letChildHandleHkReply(id, packet);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch(id) {
|
||||
case(GOMSPACE::PING): {
|
||||
SerializeElement<uint32_t> replyTime = *packet;
|
||||
handleDeviceTM(&replyTime, id, true);
|
||||
break;
|
||||
}
|
||||
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)){
|
||||
sif::error << "GomspaceDeviceHandler: PARAM_GET: Invalid payload "
|
||||
<< "size in reply" << std::endl;
|
||||
return INVALID_PAYLOAD_SIZE;
|
||||
}
|
||||
uint8_t tempPayloadBuffer[payloadLength];
|
||||
/* Extract information from received data */
|
||||
CspGetParamReply cspGetParamReply(tempPayloadBuffer, payloadLength);
|
||||
size_t size = GOMSPACE::GS_HDR_LENGTH + payloadLength;
|
||||
ReturnValue_t result = cspGetParamReply.deSerialize(&packet, &size,
|
||||
SerializeIF::Endianness::BIG);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
sif::error << "GomspaceDeviceHandler: Failed to deserialize get parameter"
|
||||
<< "reply" << std::endl;
|
||||
return result;
|
||||
}
|
||||
uint8_t action = cspGetParamReply.getAction();
|
||||
uint8_t tableId = cspGetParamReply.getTableId();
|
||||
uint16_t address = cspGetParamReply.getAddress();
|
||||
/* Pack relevant information into a tm packet */
|
||||
ParamReply paramReply(action, tableId, address, payloadLength,
|
||||
tempPayloadBuffer);
|
||||
handleDeviceTM(¶mReply, id, true);
|
||||
break;
|
||||
}
|
||||
case(GOMSPACE::PARAM_SET): {
|
||||
/* When setting a parameter, the p60dock sends back the state of the
|
||||
* operation */
|
||||
if(*packet != PARAM_SET_OK){
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(GOMSPACE::REQUEST_HK_TABLE): {
|
||||
letChildHandleHkReply(id, packet);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
@ -187,173 +188,173 @@ void GomspaceDeviceHandler::setNormalDatapoolEntriesInvalid(){
|
||||
}
|
||||
|
||||
ReturnValue_t GomspaceDeviceHandler::generateSetParamCommand(
|
||||
const uint8_t * commandData, size_t commandDataLen) {
|
||||
SetParamMessageUnpacker setParamMessageUnpacker;
|
||||
ReturnValue_t result = setParamMessageUnpacker.deSerialize(&commandData,
|
||||
&commandDataLen, SerializeIF::Endianness::BIG);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
sif::error << "GomspaceDeviceHandler: Failed to deserialize set parameter "
|
||||
"message" << std::endl;
|
||||
return result;
|
||||
}
|
||||
/* Get and check address */
|
||||
uint16_t address = setParamMessageUnpacker.getAddress();
|
||||
if(address > maxConfigTableAddress){
|
||||
sif::error << "GomspaceDeviceHandler: Invalid address for set parameter "
|
||||
<< "action" << std::endl;
|
||||
return INVALID_ADDRESS;
|
||||
}
|
||||
uint16_t checksum = GOMSPACE::IGNORE_CHECKSUM;
|
||||
uint16_t seq = 0;
|
||||
uint16_t total = 0;
|
||||
/* CSP reply only contains the transaction state */
|
||||
uint16_t querySize = 1;
|
||||
const uint8_t* parameterPtr = setParamMessageUnpacker.getParameter();
|
||||
uint8_t parameterSize = setParamMessageUnpacker.getParameterSize();
|
||||
uint16_t payloadlength = sizeof(address) + parameterSize;
|
||||
const uint8_t * commandData, size_t commandDataLen) {
|
||||
SetParamMessageUnpacker setParamMessageUnpacker;
|
||||
ReturnValue_t result = setParamMessageUnpacker.deSerialize(&commandData,
|
||||
&commandDataLen, SerializeIF::Endianness::BIG);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
sif::error << "GomspaceDeviceHandler: Failed to deserialize set parameter "
|
||||
"message" << std::endl;
|
||||
return result;
|
||||
}
|
||||
/* Get and check address */
|
||||
uint16_t address = setParamMessageUnpacker.getAddress();
|
||||
if(address > maxConfigTableAddress){
|
||||
sif::error << "GomspaceDeviceHandler: Invalid address for set parameter "
|
||||
<< "action" << std::endl;
|
||||
return INVALID_ADDRESS;
|
||||
}
|
||||
uint16_t checksum = GOMSPACE::IGNORE_CHECKSUM;
|
||||
uint16_t seq = 0;
|
||||
uint16_t total = 0;
|
||||
/* CSP reply only contains the transaction state */
|
||||
uint16_t querySize = 1;
|
||||
const uint8_t* parameterPtr = setParamMessageUnpacker.getParameter();
|
||||
uint8_t parameterSize = setParamMessageUnpacker.getParameterSize();
|
||||
uint16_t payloadlength = sizeof(address) + parameterSize;
|
||||
|
||||
/* Generate command for CspComIF */
|
||||
CspSetParamCommand setParamCmd(querySize, payloadlength, checksum, seq,
|
||||
total, address, parameterPtr, parameterSize);
|
||||
size_t cspPacketLen = 0;
|
||||
uint8_t* buffer = cspPacket;
|
||||
result = setParamCmd.serialize(&buffer, &cspPacketLen, sizeof(cspPacket),
|
||||
SerializeIF::Endianness::BIG);
|
||||
/* Generate command for CspComIF */
|
||||
CspSetParamCommand setParamCmd(querySize, payloadlength, checksum, seq,
|
||||
total, address, parameterPtr, parameterSize);
|
||||
size_t cspPacketLen = 0;
|
||||
uint8_t* buffer = cspPacket;
|
||||
result = setParamCmd.serialize(&buffer, &cspPacketLen, sizeof(cspPacket),
|
||||
SerializeIF::Endianness::BIG);
|
||||
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
sif::error << "GomspaceDeviceHandler: Failed to serialize command for "
|
||||
<< "CspComIF" << std::endl;
|
||||
return result;
|
||||
}
|
||||
if(cspPacketLen > MAX_PACKET_LEN){
|
||||
sif::error << "GomspaceDeviceHandler: Invalid length of set parameter "
|
||||
"command" << std::endl;
|
||||
return PACKET_TOO_LONG;
|
||||
}
|
||||
rawPacket = cspPacket;
|
||||
rawPacketLen = cspPacketLen;
|
||||
rememberRequestedSize = querySize;
|
||||
rememberCommandId = GOMSPACE::PARAM_SET;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
sif::error << "GomspaceDeviceHandler: Failed to serialize command for "
|
||||
<< "CspComIF" << std::endl;
|
||||
return result;
|
||||
}
|
||||
if(cspPacketLen > MAX_PACKET_LEN){
|
||||
sif::error << "GomspaceDeviceHandler: Invalid length of set parameter "
|
||||
"command" << std::endl;
|
||||
return PACKET_TOO_LONG;
|
||||
}
|
||||
rawPacket = cspPacket;
|
||||
rawPacketLen = cspPacketLen;
|
||||
rememberRequestedSize = querySize;
|
||||
rememberCommandId = GOMSPACE::PARAM_SET;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t GomspaceDeviceHandler::generateGetParamCommand(
|
||||
const uint8_t * commandData, size_t commandDataLen){
|
||||
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;
|
||||
}
|
||||
/* Get and check address */
|
||||
uint16_t address = getParamMessage.getAddress();
|
||||
if(address > maxHkTableAddress && 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){
|
||||
sif::error << "GomspaceDeviceHandler: Invalid address to get parameter from "
|
||||
<< "configuration table" << std::endl;
|
||||
return INVALID_ADDRESS;
|
||||
}
|
||||
uint16_t length = sizeof(address);
|
||||
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;
|
||||
}
|
||||
uint16_t querySize = parameterSize + GOMSPACE::GS_HDR_LENGTH;
|
||||
const uint8_t * commandData, size_t commandDataLen){
|
||||
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;
|
||||
}
|
||||
/* Get and check address */
|
||||
uint16_t address = getParamMessage.getAddress();
|
||||
if(address > maxHkTableAddress && 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){
|
||||
sif::error << "GomspaceDeviceHandler: Invalid address to get parameter from "
|
||||
<< "configuration table" << std::endl;
|
||||
return INVALID_ADDRESS;
|
||||
}
|
||||
uint16_t length = sizeof(address);
|
||||
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;
|
||||
}
|
||||
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);
|
||||
size_t cspPacketLen = 0;
|
||||
uint8_t* buffer = cspPacket;
|
||||
result = getParamCmd.serialize(&buffer, &cspPacketLen, sizeof(cspPacket),
|
||||
SerializeIF::Endianness::BIG);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
sif::error << "GomspaceDeviceHandler: Failed to serialize command to "
|
||||
<< "get parameter" << std::endl;
|
||||
}
|
||||
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;
|
||||
rememberCommandId = GOMSPACE::PARAM_GET;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
/* Generate the CSP command to send to the P60 Dock */
|
||||
CspGetParamCommand getParamCmd(querySize, tableId, length,
|
||||
checksum, seq, total, address);
|
||||
size_t cspPacketLen = 0;
|
||||
uint8_t* buffer = cspPacket;
|
||||
result = getParamCmd.serialize(&buffer, &cspPacketLen, sizeof(cspPacket),
|
||||
SerializeIF::Endianness::BIG);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
sif::error << "GomspaceDeviceHandler: Failed to serialize command to "
|
||||
<< "get parameter" << std::endl;
|
||||
}
|
||||
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;
|
||||
rememberCommandId = GOMSPACE::PARAM_GET;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t GomspaceDeviceHandler::generatePingCommand(
|
||||
const uint8_t * commandData, size_t commandDataLen) {
|
||||
CspPingCommand cspPingCommand(commandData, commandDataLen);
|
||||
size_t cspPacketLen = 0;
|
||||
uint8_t* buffer = cspPacket;
|
||||
ReturnValue_t result = cspPingCommand.serialize(&buffer, &cspPacketLen,
|
||||
sizeof(cspPacket),
|
||||
SerializeIF::Endianness::BIG);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
sif::error << "GomspaceDeviceHandler: Failed to serialize ping command"
|
||||
<< std::endl;
|
||||
return result;
|
||||
}
|
||||
if(cspPacketLen > MAX_PACKET_LEN){
|
||||
sif::error << "GomspaceDeviceHandler: Received invalid ping message"
|
||||
<< std::endl;
|
||||
return PACKET_TOO_LONG;
|
||||
}
|
||||
rawPacket = cspPacket;
|
||||
rawPacketLen = cspPacketLen;
|
||||
rememberCommandId = GOMSPACE::PING;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
const uint8_t * commandData, size_t commandDataLen) {
|
||||
CspPingCommand cspPingCommand(commandData, commandDataLen);
|
||||
size_t cspPacketLen = 0;
|
||||
uint8_t* buffer = cspPacket;
|
||||
ReturnValue_t result = cspPingCommand.serialize(&buffer, &cspPacketLen,
|
||||
sizeof(cspPacket),
|
||||
SerializeIF::Endianness::BIG);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
sif::error << "GomspaceDeviceHandler: Failed to serialize ping command"
|
||||
<< std::endl;
|
||||
return result;
|
||||
}
|
||||
if(cspPacketLen > MAX_PACKET_LEN){
|
||||
sif::error << "GomspaceDeviceHandler: Received invalid ping message"
|
||||
<< std::endl;
|
||||
return PACKET_TOO_LONG;
|
||||
}
|
||||
rawPacket = cspPacket;
|
||||
rawPacketLen = cspPacketLen;
|
||||
rememberCommandId = GOMSPACE::PING;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void GomspaceDeviceHandler::generateRebootCommand(){
|
||||
uint8_t cspPort = GOMSPACE::REBOOT_PORT;
|
||||
uint16_t querySize = 0;
|
||||
*cspPacket = GOMSPACE::REBOOT_PORT;
|
||||
*(cspPacket + 1) = querySize;
|
||||
size_t cspPacketLen = sizeof(cspPort) + sizeof(cspPacketLen);
|
||||
rawPacket = cspPacket;
|
||||
rawPacketLen = cspPacketLen;
|
||||
uint8_t cspPort = GOMSPACE::REBOOT_PORT;
|
||||
uint16_t querySize = 0;
|
||||
*cspPacket = GOMSPACE::REBOOT_PORT;
|
||||
*(cspPacket + 1) = querySize;
|
||||
size_t cspPacketLen = sizeof(cspPort) + sizeof(cspPacketLen);
|
||||
rawPacket = cspPacket;
|
||||
rawPacketLen = cspPacketLen;
|
||||
}
|
||||
|
||||
ReturnValue_t GomspaceDeviceHandler::generateResetWatchdogCmd(){
|
||||
WatchdogResetCommand watchdogResetCommand;
|
||||
size_t cspPacketLen = 0;
|
||||
uint8_t* buffer = cspPacket;
|
||||
ReturnValue_t result = watchdogResetCommand.serialize(&buffer,
|
||||
&cspPacketLen, sizeof(cspPacket), SerializeIF::Endianness::BIG);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
sif::error << "GomspaceDeviceHandler: Failed to serialize watchdog reset "
|
||||
<< "command" << std::endl;
|
||||
return result;
|
||||
}
|
||||
rawPacket = cspPacket;
|
||||
rawPacketLen = cspPacketLen;
|
||||
rememberRequestedSize = 0; // No bytes will be queried with the ground
|
||||
// watchdog command.
|
||||
rememberCommandId = GOMSPACE::GNDWDT_RESET;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
WatchdogResetCommand watchdogResetCommand;
|
||||
size_t cspPacketLen = 0;
|
||||
uint8_t* buffer = cspPacket;
|
||||
ReturnValue_t result = watchdogResetCommand.serialize(&buffer,
|
||||
&cspPacketLen, sizeof(cspPacket), SerializeIF::Endianness::BIG);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
sif::error << "GomspaceDeviceHandler: Failed to serialize watchdog reset "
|
||||
<< "command" << std::endl;
|
||||
return result;
|
||||
}
|
||||
rawPacket = cspPacket;
|
||||
rawPacketLen = cspPacketLen;
|
||||
rememberRequestedSize = 0; // No bytes will be queried with the ground
|
||||
// watchdog command.
|
||||
rememberCommandId = GOMSPACE::GNDWDT_RESET;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t GomspaceDeviceHandler::generateRequestFullHkTableCmd(uint16_t hkTableReplySize) {
|
||||
@ -379,8 +380,8 @@ ReturnValue_t GomspaceDeviceHandler::generateRequestFullHkTableCmd(uint16_t hkTa
|
||||
}
|
||||
|
||||
uint32_t GomspaceDeviceHandler::getTransitionDelayMs(Mode_t modeFrom,
|
||||
Mode_t modeTo) {
|
||||
return 0;
|
||||
Mode_t modeTo) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
LocalPoolDataSetBase* GomspaceDeviceHandler::getDataSetHandle(sid_t sid) {
|
||||
|
@ -1,8 +1,9 @@
|
||||
#ifndef MISSION_DEVICES_GOMSPACEDEVICEHANDLER_H_
|
||||
#define MISSION_DEVICES_GOMSPACEDEVICEHANDLER_H_
|
||||
|
||||
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
|
||||
#include <mission/devices/devicedefinitions/GomspaceDefinitions.h>
|
||||
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
|
||||
#include "mission/devices/devicedefinitions/GomspaceDefinitions.h"
|
||||
#include "returnvalues/classIds.h"
|
||||
|
||||
/**
|
||||
* @brief This is the device handler class for all gomspace devices.
|
||||
@ -18,117 +19,119 @@
|
||||
class GomspaceDeviceHandler: public DeviceHandlerBase {
|
||||
public:
|
||||
|
||||
static const ReturnValue_t PACKET_TOO_LONG = MAKE_RETURN_CODE(0xE0);
|
||||
static const ReturnValue_t INVALID_TABLE_ID = MAKE_RETURN_CODE(0xE1);
|
||||
static const ReturnValue_t INVALID_ADDRESS = MAKE_RETURN_CODE(0xE2);
|
||||
static const ReturnValue_t INVALID_PARAM_SIZE = MAKE_RETURN_CODE(0xE3);
|
||||
static const ReturnValue_t INVALID_PAYLOAD_SIZE = MAKE_RETURN_CODE(0xE4);
|
||||
static const ReturnValue_t UNKNOWN_REPLY_ID = MAKE_RETURN_CODE(0xE5);
|
||||
static constexpr uint8_t CLASS_ID = CLASS_ID::GOM_SPACE_HANDLER;
|
||||
static const ReturnValue_t PACKET_TOO_LONG = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 0);
|
||||
static const ReturnValue_t INVALID_TABLE_ID = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 1);
|
||||
static const ReturnValue_t INVALID_ADDRESS = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 2);
|
||||
static const ReturnValue_t INVALID_PARAM_SIZE = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 3);
|
||||
static const ReturnValue_t INVALID_PAYLOAD_SIZE =
|
||||
HasReturnvaluesIF::makeReturnCode(CLASS_ID, 4);
|
||||
static const ReturnValue_t UNKNOWN_REPLY_ID = HasReturnvaluesIF::makeReturnCode(CLASS_ID, 5);
|
||||
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param maxConfigTableAddress The maximum memory address of the configu-
|
||||
* ration table of a gomspace device.
|
||||
* @param maxHkTableAddress The maximum memory address of a value in the
|
||||
* houskeeping (telemetry) table of a gomspace
|
||||
* device.
|
||||
*/
|
||||
GomspaceDeviceHandler(object_id_t objectId, object_id_t comIF,
|
||||
CookieIF * comCookie, uint16_t maxConfigTableAddress, uint16_t maxHkTableAddress,
|
||||
uint16_t hkTableReplySize, LocalPoolDataSetBase* hkTableDataset);
|
||||
virtual ~GomspaceDeviceHandler();
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param maxConfigTableAddress The maximum memory address of the configu-
|
||||
* ration table of a gomspace device.
|
||||
* @param maxHkTableAddress The maximum memory address of a value in the
|
||||
* houskeeping (telemetry) table of a gomspace
|
||||
* device.
|
||||
*/
|
||||
GomspaceDeviceHandler(object_id_t objectId, object_id_t comIF,
|
||||
CookieIF * comCookie, uint16_t maxConfigTableAddress, uint16_t maxHkTableAddress,
|
||||
uint16_t hkTableReplySize, LocalPoolDataSetBase* hkTableDataset);
|
||||
virtual ~GomspaceDeviceHandler();
|
||||
|
||||
/**
|
||||
* @brief This function can be used to set a gomspace device to normal mode immediately after
|
||||
* object creation.
|
||||
*/
|
||||
void setModeNormal();
|
||||
/**
|
||||
* @brief This function can be used to set a gomspace device to normal mode immediately after
|
||||
* object creation.
|
||||
*/
|
||||
void setModeNormal();
|
||||
|
||||
protected:
|
||||
|
||||
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;
|
||||
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 = GOMSPACE::NONE;
|
||||
uint8_t cspPacket[MAX_PACKET_LEN];
|
||||
uint8_t rememberRequestedSize = 0;
|
||||
uint8_t rememberCommandId = GOMSPACE::NONE;
|
||||
uint8_t cspPacket[MAX_PACKET_LEN];
|
||||
|
||||
uint16_t maxConfigTableAddress;
|
||||
uint16_t maxHkTableAddress;
|
||||
uint16_t maxConfigTableAddress;
|
||||
uint16_t maxHkTableAddress;
|
||||
|
||||
/** The size of the reply following a full hk table request.*/
|
||||
uint16_t hkTableReplySize;
|
||||
/** The size of the reply following a full hk table request.*/
|
||||
uint16_t hkTableReplySize;
|
||||
|
||||
LocalPoolDataSetBase* hkTableDataset = nullptr;
|
||||
LocalPoolDataSetBase* hkTableDataset = nullptr;
|
||||
|
||||
void doStartUp() override;
|
||||
void doShutDown() override;
|
||||
virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id)
|
||||
override;
|
||||
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override;
|
||||
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);
|
||||
void doStartUp() override;
|
||||
void doShutDown() override;
|
||||
virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id)
|
||||
override;
|
||||
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override;
|
||||
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);
|
||||
|
||||
/**
|
||||
* @brief Because housekeeping tables are device specific the handling of the reply is
|
||||
* given to the child class.
|
||||
* @param id The id of the command which initiates the full table request.
|
||||
* @param packet Pointer to the reply containing the hk table.
|
||||
*/
|
||||
virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) = 0;
|
||||
/**
|
||||
* @brief Because housekeeping tables are device specific the handling of the reply is
|
||||
* given to the child class.
|
||||
* @param id The id of the command which initiates the full table request.
|
||||
* @param packet Pointer to the reply containing the hk table.
|
||||
*/
|
||||
virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) = 0;
|
||||
|
||||
virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
|
||||
virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* @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);
|
||||
/**
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @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 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 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 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();
|
||||
/**
|
||||
* @brief Function to generate the command to force a ground watchdog
|
||||
* reset in a gomspace device.
|
||||
*/
|
||||
ReturnValue_t generateResetWatchdogCmd();
|
||||
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user