eive-obsw/mission/devices/GomspaceDeviceHandler.h

109 lines
4.0 KiB
C
Raw Normal View History

2020-12-20 13:31:44 +01:00
#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:
2020-12-20 17:35:03 +01:00
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);
2020-12-20 13:31:44 +01:00
/**
* @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;
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_ */