Merge remote-tracking branch 'origin/develop' into mueller/master
This commit is contained in:
@ -2,6 +2,8 @@
|
||||
#include <fsfwconfig/objects/systemObjectList.h>
|
||||
#include <fsfwconfig/tmtc/apid.h>
|
||||
#include <fsfwconfig/tmtc/pusIds.h>
|
||||
#include <fsfwconfig/OBSWconfig.h>
|
||||
#include <fsfwconfig/devices/addresses.h>
|
||||
|
||||
#include <fsfw/events/EventManager.h>
|
||||
#include <fsfw/health/HealthTable.h>
|
||||
@ -9,6 +11,7 @@
|
||||
#include <fsfw/pus/CService200ModeCommanding.h>
|
||||
#include <fsfw/pus/Service17Test.h>
|
||||
#include <fsfw/pus/Service1TelecommandVerification.h>
|
||||
#include <fsfw/pus/Service3Housekeeping.h>
|
||||
#include <fsfw/pus/Service2DeviceAccess.h>
|
||||
#include <fsfw/pus/Service5EventReporting.h>
|
||||
#include <fsfw/pus/Service8FunctionManagement.h>
|
||||
@ -18,7 +21,14 @@
|
||||
#include <fsfw/tcdistribution/PUSDistributor.h>
|
||||
#include <fsfw/timemanager/TimeStamper.h>
|
||||
#include <mission/utility/TmFunnel.h>
|
||||
#include <bsp_linux/comIF/cookies/CspCookie.h>
|
||||
#include <bsp_linux/comIF/CspComIF.h>
|
||||
#include "mission/devices/GomspaceDeviceHandler.h"
|
||||
#include "mission/devices/devicedefinitions/GomspaceDefinitions.h"
|
||||
|
||||
#if ADD_TEST_CODE == 1
|
||||
//#include <test/testtasks/TestTask.h>
|
||||
#endif
|
||||
|
||||
void ObjectFactory::produceGenericObjects() {
|
||||
/* Framework objects */
|
||||
@ -61,6 +71,8 @@ void ObjectFactory::produceGenericObjects() {
|
||||
apid::EIVE_OBSW, pus::PUS_SERVICE_1, objects::TM_FUNNEL, 20);
|
||||
new Service2DeviceAccess(objects::PUS_SERVICE_2_DEVICE_ACCESS,
|
||||
apid::EIVE_OBSW, pus::PUS_SERVICE_2, 3, 10);
|
||||
new Service3Housekeeping(objects::PUS_SERVICE_3_HOUSEKEEPING,
|
||||
apid::EIVE_OBSW, pus::PUS_SERVICE_3);
|
||||
new Service5EventReporting(objects::PUS_SERVICE_5_EVENT_REPORTING,
|
||||
apid::EIVE_OBSW, pus::PUS_SERVICE_5, 50);
|
||||
new Service8FunctionManagement(objects::PUS_SERVICE_8_FUNCTION_MGMT,
|
||||
@ -72,8 +84,35 @@ void ObjectFactory::produceGenericObjects() {
|
||||
new CService200ModeCommanding(objects::PUS_SERVICE_200_MODE_MGMT,
|
||||
apid::EIVE_OBSW, pus::PUS_SERVICE_200);
|
||||
|
||||
/* Cookies */
|
||||
CspCookie* p60DockCspCookie = new CspCookie(P60Dock::MAX_REPLY_LENGTH,
|
||||
addresses::P60DOCK);
|
||||
CspCookie* pdu1CspCookie = new CspCookie(PDU::MAX_REPLY_LENGTH,
|
||||
addresses::PDU1);
|
||||
CspCookie* pdu2CspCookie = new CspCookie(PDU::MAX_REPLY_LENGTH,
|
||||
addresses::PDU2);
|
||||
CspCookie* acuCspCookie = new CspCookie(ACU::MAX_REPLY_LENGTH,
|
||||
addresses::ACU);
|
||||
|
||||
/* Communication interfaces */
|
||||
new CspComIF(objects::CSP_COM_IF);
|
||||
|
||||
/* Device Handler */
|
||||
new GomspaceDeviceHandler(objects::P60DOCK_HANDLER, objects::CSP_COM_IF,
|
||||
p60DockCspCookie, P60Dock::MAX_CONFIGTABLE_ADDRESS,
|
||||
P60Dock::MAX_HKTABLE_ADDRESS);
|
||||
new GomspaceDeviceHandler(objects::PDU1_HANDLER, objects::CSP_COM_IF,
|
||||
pdu1CspCookie, PDU::MAX_CONFIGTABLE_ADDRESS,
|
||||
PDU::MAX_HKTABLE_ADDRESS);
|
||||
new GomspaceDeviceHandler(objects::PDU2_HANDLER, objects::CSP_COM_IF,
|
||||
pdu2CspCookie, PDU::MAX_CONFIGTABLE_ADDRESS,
|
||||
PDU::MAX_HKTABLE_ADDRESS);
|
||||
new GomspaceDeviceHandler(objects::ACU_HANDLER, objects::CSP_COM_IF,
|
||||
acuCspCookie, ACU::MAX_CONFIGTABLE_ADDRESS,
|
||||
ACU::MAX_HKTABLE_ADDRESS);
|
||||
|
||||
/* Test Device Handler */
|
||||
#if OBSW_ADD_TEST_CODE == 1
|
||||
new TestTask(objects::TEST_TASK);
|
||||
#if ADD_TEST_CODE == 1
|
||||
// new TestTask(objects::TEST_TASK);
|
||||
#endif
|
||||
}
|
||||
|
339
mission/devices/GomspaceDeviceHandler.cpp
Normal file
339
mission/devices/GomspaceDeviceHandler.cpp
Normal file
@ -0,0 +1,339 @@
|
||||
#include <mission/devices/GomspaceDeviceHandler.h>
|
||||
#include <mission/devices/devicedefinitions/GomSpacePackets.h>
|
||||
|
||||
GomspaceDeviceHandler::GomspaceDeviceHandler(object_id_t objectId, object_id_t comIF,
|
||||
CookieIF * comCookie, uint16_t maxConfigTableAddress,
|
||||
uint16_t maxHkTableAddress) :
|
||||
DeviceHandlerBase(objectId, comIF, comCookie), maxConfigTableAddress(
|
||||
maxConfigTableAddress), maxHkTableAddress(maxHkTableAddress) {
|
||||
mode = MODE_NORMAL;
|
||||
if (comCookie == NULL) {
|
||||
sif::error << "GomspaceDeviceHandler invalid com cookie" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
GomspaceDeviceHandler::~GomspaceDeviceHandler() {
|
||||
}
|
||||
|
||||
|
||||
void GomspaceDeviceHandler::doStartUp(){
|
||||
}
|
||||
|
||||
void GomspaceDeviceHandler::doShutDown(){
|
||||
|
||||
}
|
||||
|
||||
ReturnValue_t GomspaceDeviceHandler::buildNormalDeviceCommand(
|
||||
DeviceCommandId_t * id) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t GomspaceDeviceHandler::buildTransitionDeviceCommand(
|
||||
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(PING): {
|
||||
result = generatePingCommand(commandData, commandDataLen);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(REBOOT): {
|
||||
generateRebootCommand();
|
||||
break;
|
||||
}
|
||||
case(PARAM_SET):{
|
||||
result = generateSetParamCommand(commandData, commandDataLen);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
return result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(PARAM_GET):{
|
||||
result = generateGetParamCommand(commandData, commandDataLen);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
return result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(GNDWDT_RESET): {
|
||||
result = generateResetWatchdogCmd();
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
return result;
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void GomspaceDeviceHandler::fillCommandAndReplyMap(){
|
||||
this->insertInCommandAndReplyMap(PING, 3);
|
||||
this->insertInCommandMap(REBOOT);
|
||||
this->insertInCommandAndReplyMap(PARAM_SET, 3);
|
||||
this->insertInCommandAndReplyMap(PARAM_GET, 3);
|
||||
this->insertInCommandMap(GNDWDT_RESET);
|
||||
}
|
||||
|
||||
ReturnValue_t GomspaceDeviceHandler::scanForReply(const uint8_t *start,
|
||||
size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) {
|
||||
switch(rememberCommandId) {
|
||||
case(PING):
|
||||
*foundId = PING;
|
||||
*foundLen = PING_REPLY_SIZE;
|
||||
rememberCommandId = NONE;
|
||||
break;
|
||||
case(PARAM_GET): {
|
||||
*foundId = PARAM_GET;
|
||||
*foundLen = rememberRequestedSize + CspGetParamReply::GS_HDR_LENGTH;
|
||||
rememberCommandId = NONE;
|
||||
break;
|
||||
}
|
||||
case(PARAM_SET): {
|
||||
*foundId = PARAM_SET;
|
||||
*foundLen = rememberRequestedSize;
|
||||
rememberCommandId = 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(PING): {
|
||||
SerializeElement<uint32_t> replyTime = *packet;
|
||||
handleDeviceTM(&replyTime, id, true);
|
||||
break;
|
||||
}
|
||||
case(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 = CspGetParamReply::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(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;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
/* 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 = 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 + CspGetParamCommand::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 = 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 = 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;
|
||||
}
|
||||
|
||||
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 = GNDWDT_RESET;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
uint32_t GomspaceDeviceHandler::getTransitionDelayMs(Mode_t modeFrom,
|
||||
Mode_t modeTo) {
|
||||
return 0;
|
||||
}
|
109
mission/devices/GomspaceDeviceHandler.h
Normal file
109
mission/devices/GomspaceDeviceHandler.h
Normal file
@ -0,0 +1,109 @@
|
||||
#ifndef MISSION_DEVICES_GOMSPACEDEVICEHANDLER_H_
|
||||
#define MISSION_DEVICES_GOMSPACEDEVICEHANDLER_H_
|
||||
|
||||
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
|
||||
|
||||
/**
|
||||
* @brief This is the device handler class for all gomspace devices.
|
||||
*
|
||||
* @details All gomspace devices are similar with respect to commanding. Thus
|
||||
* most of the functionality to command a gomspace device can be
|
||||
* accommodated in one class. For device specific functions, a new
|
||||
* class could be created by inheriting from the GomspaceDeviceHandler.
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* @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);
|
||||
virtual ~GomspaceDeviceHandler();
|
||||
|
||||
protected:
|
||||
void doStartUp() override;
|
||||
void doShutDown() override;
|
||||
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;
|
||||
|
||||
private:
|
||||
|
||||
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;
|
||||
/* Device commands are derived from the rparam.h of the gomspace lib */
|
||||
static const DeviceCommandId_t PING = 0x1; //!< [EXPORT] : [COMMAND]
|
||||
static const DeviceCommandId_t NONE = 0x2; // Set when no command is pending
|
||||
static const DeviceCommandId_t REBOOT = 0x4; //!< [EXPORT] : [COMMAND]
|
||||
static const DeviceCommandId_t GNDWDT_RESET = 0x9; //!< [EXPORT] : [COMMAND]
|
||||
static const DeviceCommandId_t PARAM_GET = 0x00; //!< [EXPORT] : [COMMAND]
|
||||
static const DeviceCommandId_t PARAM_SET = 0xFF; //!< [EXPORT] : [COMMAND]
|
||||
|
||||
uint8_t rememberRequestedSize = 0;
|
||||
uint8_t rememberCommandId = NONE;
|
||||
uint8_t cspPacket[MAX_PACKET_LEN];
|
||||
|
||||
uint16_t maxConfigTableAddress;
|
||||
uint16_t maxHkTableAddress;
|
||||
|
||||
/**
|
||||
* @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 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();
|
||||
|
||||
};
|
||||
|
||||
#endif /* MISSION_DEVICES_GOMSPACEDEVICEHANDLER_H_ */
|
362
mission/devices/devicedefinitions/GomSpacePackets.h
Normal file
362
mission/devices/devicedefinitions/GomSpacePackets.h
Normal file
@ -0,0 +1,362 @@
|
||||
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEPACKETS_H_
|
||||
#define MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEPACKETS_H_
|
||||
|
||||
#include "fsfw/serialize/SerialBufferAdapter.h"
|
||||
#include "fsfw/serialize/SerializeElement.h"
|
||||
#include "fsfw/serialize/SerialLinkedListAdapter.h"
|
||||
#include "fsfw/serialize/SerialFixedArrayListAdapter.h"
|
||||
|
||||
namespace GOMSPACE{
|
||||
static const uint16_t IGNORE_CHECKSUM = 0xbb0;
|
||||
/* CSP port to ping gomspace devices. */
|
||||
static const uint8_t PING_PORT = 1;
|
||||
static const uint8_t REBOOT_PORT = 4;
|
||||
/* CSP port of gomspace devices to request or set parameters */
|
||||
static const uint8_t PARAM_PORT = 7;
|
||||
static const uint8_t P60_PORT_GNDWDT_RESET = 9;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief This class can be used to generated the command for the CspComIF
|
||||
* to reset the watchdog in a gomspace device.
|
||||
*/
|
||||
class WatchdogResetCommand : public SerialLinkedListAdapter<SerializeIF> {
|
||||
public:
|
||||
|
||||
WatchdogResetCommand() {
|
||||
setLinks();
|
||||
}
|
||||
|
||||
private:
|
||||
WatchdogResetCommand(const WatchdogResetCommand &command);
|
||||
void setLinks() {
|
||||
setStart(&cspPort);
|
||||
cspPort.setNext(&querySize);
|
||||
querySize.setNext(&magic);
|
||||
}
|
||||
SerializeElement<uint8_t> cspPort = GOMSPACE::P60_PORT_GNDWDT_RESET;
|
||||
SerializeElement<uint16_t> querySize = 1;
|
||||
/* Sending 0x78 to port 9 of a gomspace device resets the ground watchdog */
|
||||
SerializeElement<uint8_t> magic = 0x78;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief A serial linked list adapter implementation to generate ping
|
||||
* commands for devices supporting the CSP protocol. This command can
|
||||
* be sent to the CspComIF which will send out the ping request.
|
||||
*
|
||||
* @details A ping request simply sends back the received data provided by the
|
||||
* data buffer. cspPort and querySize are only informations required
|
||||
* by the CspComI and other than the data array not physically
|
||||
* transmitted to the target device.
|
||||
*/
|
||||
class CspPingCommand : public SerialLinkedListAdapter<SerializeIF> {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param querySize_ The size of bytes replied by the ping request.
|
||||
* Amounts to the number of bytes send.
|
||||
* @param data_ Pointer to data which should be sent to the device.
|
||||
* All data will be sent back by the ping target.
|
||||
*/
|
||||
CspPingCommand(const uint8_t* data_, uint16_t querySize_) :
|
||||
querySize(querySize_), data(data_, querySize_) {
|
||||
setLinks();
|
||||
}
|
||||
|
||||
private:
|
||||
CspPingCommand(const CspPingCommand &command);
|
||||
void setLinks() {
|
||||
setStart(&cspPort);
|
||||
cspPort.setNext(&querySize);
|
||||
querySize.setNext(&data);
|
||||
}
|
||||
SerializeElement<uint8_t> cspPort = GOMSPACE::PING_PORT;
|
||||
SerializeElement<uint16_t> querySize;
|
||||
SerializeElement<SerialBufferAdapter<uint8_t>> data;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief A serial linked list adapter implementation of the gs_rparam_query_t
|
||||
* struct defined in rparam.h. Can be used to build the message to set
|
||||
* a parameter in gomspace devices.
|
||||
*
|
||||
* @note cspPort and querySize will not be sent with the CSP packet to the
|
||||
* gomspace device but are required for the CspComIF to get the port
|
||||
* and the size to query.
|
||||
*/
|
||||
class CspSetParamCommand : public SerialLinkedListAdapter<SerializeIF> {
|
||||
public:
|
||||
|
||||
static const uint8_t GS_HDR_LENGTH = 12;
|
||||
|
||||
CspSetParamCommand(uint16_t querySize_, uint16_t payloadlength_,
|
||||
uint16_t checksum_, uint16_t seq_, uint16_t total_, uint16_t addr_,
|
||||
const uint8_t* parameter_, uint8_t parameterCount_) :
|
||||
querySize(querySize_), payloadlength(
|
||||
payloadlength_), checksum(checksum_), seq(seq_), total(
|
||||
total_), addr(addr_), parameter(parameter_, parameterCount_) {
|
||||
setLinks();
|
||||
}
|
||||
|
||||
private:
|
||||
CspSetParamCommand(const CspSetParamCommand &command);
|
||||
void setLinks() {
|
||||
setStart(&cspPort);
|
||||
cspPort.setNext(&querySize);
|
||||
querySize.setNext(&action);
|
||||
action.setNext(&tableId);
|
||||
tableId.setNext(&payloadlength);
|
||||
payloadlength.setNext(&checksum);
|
||||
checksum.setNext(&seq);
|
||||
seq.setNext(&total);
|
||||
total.setNext(&addr);
|
||||
addr.setNext(¶meter);
|
||||
}
|
||||
SerializeElement<uint8_t> cspPort = GOMSPACE::PARAM_PORT;
|
||||
/* Only a parameter will be set. No data will be queried with this command */
|
||||
SerializeElement<uint16_t> querySize;
|
||||
SerializeElement<uint8_t> action = 0xFF; // param set
|
||||
/* We will never set a parameter in a table other than the configuration
|
||||
* table */
|
||||
SerializeElement<uint8_t> tableId = 1;
|
||||
SerializeElement<uint16_t> payloadlength;
|
||||
SerializeElement<uint16_t> checksum;
|
||||
SerializeElement<uint16_t> seq;
|
||||
SerializeElement<uint16_t> total;
|
||||
SerializeElement<uint16_t> addr;
|
||||
SerializeElement<SerialBufferAdapter<uint8_t>> parameter;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief This class can be used to generate a get param command for the
|
||||
* gomspace devices which will be sent to the device communication
|
||||
* interface object.
|
||||
*
|
||||
* @note cspPort and querySize only serve as information for the CspComIF
|
||||
* and will not be transmitted physically to the target device.
|
||||
*/
|
||||
class CspGetParamCommand : public SerialLinkedListAdapter<SerializeIF> {
|
||||
public:
|
||||
/* The size of the header of a gomspace CSP packet. */
|
||||
static const uint8_t GS_HDR_LENGTH = 12;
|
||||
|
||||
CspGetParamCommand(uint16_t querySize_, uint8_t tableId_,
|
||||
uint16_t addresslength_, uint16_t checksum_, uint16_t seq_,
|
||||
uint16_t total_, uint16_t addr_) :
|
||||
querySize(querySize_), tableId(tableId_), addresslength(
|
||||
addresslength_), checksum(checksum_), seq(seq_), total(
|
||||
total_), addr(addr_) {
|
||||
fixedValuesInit();
|
||||
setLinks();
|
||||
}
|
||||
|
||||
private:
|
||||
CspGetParamCommand(const CspGetParamCommand &command);
|
||||
void setLinks() {
|
||||
setStart(&cspPort);
|
||||
cspPort.setNext(&querySize);
|
||||
querySize.setNext(&action);
|
||||
action.setNext(&tableId);
|
||||
tableId.setNext(&addresslength);
|
||||
addresslength.setNext(&checksum);
|
||||
checksum.setNext(&seq);
|
||||
seq.setNext(&total);
|
||||
total.setNext(&addr);
|
||||
}
|
||||
void fixedValuesInit(){
|
||||
cspPort.entry = GOMSPACE::PARAM_PORT;
|
||||
}
|
||||
SerializeElement<uint8_t> cspPort;
|
||||
SerializeElement<uint16_t> querySize; // size of bytes to query
|
||||
/* Following information will also be physically transmitted to the target
|
||||
* device*/
|
||||
SerializeElement<uint8_t> action = 0x00; // get param
|
||||
SerializeElement<uint8_t> tableId;
|
||||
SerializeElement<uint16_t> addresslength; // size of address
|
||||
SerializeElement<uint16_t> checksum;
|
||||
SerializeElement<uint16_t> seq;
|
||||
SerializeElement<uint16_t> total;
|
||||
SerializeElement<uint16_t> addr;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief This class can be used to deserialize replies from gomspace devices
|
||||
* and extract the relevant data.
|
||||
*/
|
||||
class CspGetParamReply : public SerialLinkedListAdapter<SerializeIF> {
|
||||
public:
|
||||
/* The size of the header of a gomspace CSP packet. */
|
||||
static const uint8_t GS_HDR_LENGTH = 12;
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param payloadBuffer Pointer to a buffer to store the payload data of
|
||||
* the CSP packet.
|
||||
* @param payloadBufferSz The size of the payload buffer where the payload
|
||||
* data will be stored.
|
||||
*/
|
||||
CspGetParamReply(uint8_t* payloadBuffer_, uint8_t payloadBufferSz_) :
|
||||
payload(payloadBuffer_, payloadBufferSz_) {
|
||||
setLinks();
|
||||
}
|
||||
|
||||
uint8_t getAction(){
|
||||
return action;
|
||||
}
|
||||
|
||||
uint8_t getTableId(){
|
||||
return tableId;
|
||||
}
|
||||
|
||||
uint16_t getLength(){
|
||||
return length;
|
||||
}
|
||||
|
||||
uint16_t getAddress(){
|
||||
return addr;
|
||||
}
|
||||
|
||||
private:
|
||||
CspGetParamReply(const CspGetParamReply &reply);
|
||||
void setLinks() {
|
||||
setStart(&action);
|
||||
action.setNext(&tableId);
|
||||
tableId.setNext(&length);
|
||||
length.setNext(&checksum);
|
||||
checksum.setNext(&seq);
|
||||
seq.setNext(&total);
|
||||
total.setNext(&addr);
|
||||
addr.setNext(&payload);
|
||||
}
|
||||
|
||||
SerializeElement<uint8_t> action;
|
||||
SerializeElement<uint8_t> tableId;
|
||||
SerializeElement<uint16_t> length; //length of address field + payload data
|
||||
SerializeElement<uint16_t> checksum;
|
||||
SerializeElement<uint16_t> seq;
|
||||
SerializeElement<uint16_t> total;
|
||||
SerializeElement<uint16_t> addr;
|
||||
SerializeElement<SerialBufferAdapter<uint8_t>> payload;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief This class generates telemetry packets containing data from
|
||||
* CSP get-parameter-replies.
|
||||
*/
|
||||
class ParamReply : public SerialLinkedListAdapter<SerializeIF> {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param payloadBuffer Pointer to a buffer to store the payload data of
|
||||
* the CSP packet.
|
||||
* @param payloadBufferSz The size of the payload buffer where the payload
|
||||
* data will be stored.
|
||||
*/
|
||||
ParamReply(uint8_t action_, uint8_t tableId_, uint16_t addr_,
|
||||
uint16_t payloadLength_, uint8_t* payloadBuffer_) :
|
||||
action(action_), tableId(tableId_), addr(addr_), payloadLength(
|
||||
payloadLength_), payload(payloadBuffer_, payloadLength) {
|
||||
setLinks();
|
||||
}
|
||||
|
||||
private:
|
||||
ParamReply(const CspGetParamReply &reply);
|
||||
void setLinks() {
|
||||
setStart(&action);
|
||||
action.setNext(&tableId);
|
||||
tableId.setNext(&addr);
|
||||
addr.setNext(&payloadLength);
|
||||
payloadLength.setNext(&payload);
|
||||
}
|
||||
SerializeElement<uint8_t> action;
|
||||
SerializeElement<uint8_t> tableId;
|
||||
SerializeElement<uint16_t> addr;
|
||||
SerializeElement<uint16_t> payloadLength;
|
||||
SerializeElement<SerialBufferAdapter<uint16_t>> payload;
|
||||
};
|
||||
|
||||
/**
|
||||
* @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 */
|
||||
static const uint32_t MAX_SIZE = 4;
|
||||
|
||||
SetParamMessageUnpacker() {
|
||||
setLinks();
|
||||
}
|
||||
|
||||
uint16_t getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
uint8_t* getParameter() {
|
||||
return parameter->front();
|
||||
}
|
||||
|
||||
uint8_t getParameterSize(){
|
||||
return parameter->size;
|
||||
}
|
||||
|
||||
private:
|
||||
void setLinks() {
|
||||
setStart(&address);
|
||||
address.setNext(¶meter);
|
||||
}
|
||||
SetParamMessageUnpacker(const SetParamMessageUnpacker &message);
|
||||
SerializeElement<uint16_t> address;
|
||||
SerializeElement<SerialFixedArrayListAdapter<uint8_t, MAX_SIZE, uint8_t>> parameter;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief This class helps to unpack information from an action message
|
||||
* 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();
|
||||
}
|
||||
|
||||
uint8_t getTableId() {
|
||||
return tableId;
|
||||
}
|
||||
|
||||
uint16_t getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
uint8_t getParameterSize(){
|
||||
return parameterSize;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
GetParamMessageUnpacker(const GetParamMessageUnpacker &message);
|
||||
void setLinks() {
|
||||
setStart(&tableId);
|
||||
tableId.setNext(&address);
|
||||
address.setNext(¶meterSize);
|
||||
}
|
||||
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) */
|
||||
SerializeElement<uint8_t> parameterSize;
|
||||
};
|
||||
|
||||
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEPACKETS_H_ */
|
39
mission/devices/devicedefinitions/GomspaceDefinitions.h
Normal file
39
mission/devices/devicedefinitions/GomspaceDefinitions.h
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* GomspaceDefinitions.h
|
||||
*
|
||||
* @brief This file holds all definitions specific for devices from gomspace.
|
||||
* @date 20.12.2020
|
||||
* @author J. Meier
|
||||
*/
|
||||
|
||||
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEDEFINITIONS_H_
|
||||
#define MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEDEFINITIONS_H_
|
||||
|
||||
|
||||
namespace P60Dock{
|
||||
/* The maximum size of a reply from the P60 dock. Maximum size is reached
|
||||
* when retrieving the full parameter configuration table. 412 bytes of
|
||||
* payload data and 12 bytes of CSP header data. */
|
||||
static const uint16_t MAX_REPLY_LENGTH = 424;
|
||||
|
||||
static const uint16_t MAX_CONFIGTABLE_ADDRESS = 408;
|
||||
static const uint16_t MAX_HKTABLE_ADDRESS = 187;
|
||||
}
|
||||
|
||||
|
||||
namespace PDU{
|
||||
/* When retrieving full configuration parameter table */
|
||||
static const uint16_t MAX_REPLY_LENGTH = 318;
|
||||
static const uint16_t MAX_CONFIGTABLE_ADDRESS = 316;
|
||||
static const uint16_t MAX_HKTABLE_ADDRESS = 140;
|
||||
}
|
||||
|
||||
|
||||
namespace ACU{
|
||||
/* When receiving full houskeeping (telemetry) table */
|
||||
static const uint16_t MAX_REPLY_LENGTH = 124;
|
||||
static const uint16_t MAX_CONFIGTABLE_ADDRESS = 26;
|
||||
static const uint16_t MAX_HKTABLE_ADDRESS = 120;
|
||||
}
|
||||
|
||||
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEDEFINITIONS_H_ */
|
Reference in New Issue
Block a user