2021-03-29 14:37:52 +02:00
|
|
|
#ifndef MISSION_DEVICES_PLOCHANDLER_H_
|
|
|
|
#define MISSION_DEVICES_PLOCHANDLER_H_
|
|
|
|
|
|
|
|
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
|
2021-04-11 12:04:13 +02:00
|
|
|
#include <mission/devices/devicedefinitions/PlocDefinitions.h>
|
2021-03-29 14:37:52 +02:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief This is the device handler for the ISIS Magnetorquer iMTQ.
|
|
|
|
*
|
|
|
|
* @author J. Meier
|
|
|
|
*/
|
|
|
|
class PlocHandler: public DeviceHandlerBase {
|
|
|
|
public:
|
|
|
|
|
|
|
|
PlocHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie);
|
|
|
|
virtual ~PlocHandler();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Sets mode to MODE_NORMAL. Can be used for debugging.
|
|
|
|
*/
|
|
|
|
void setModeNormal();
|
|
|
|
|
|
|
|
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;
|
|
|
|
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
|
|
|
LocalDataPoolManager& poolManager) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2021-04-11 12:04:13 +02:00
|
|
|
static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_HANDLER;
|
2021-03-29 14:37:52 +02:00
|
|
|
|
2021-04-11 12:04:13 +02:00
|
|
|
static const ReturnValue_t TC_ACK_FAILURE = MAKE_RETURN_CODE(0xA0);
|
|
|
|
static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA1);
|
2021-04-15 13:17:15 +02:00
|
|
|
static const ReturnValue_t EXE_REPLY_CRC_FAILURE = MAKE_RETURN_CODE(0xA1);
|
2021-03-29 14:37:52 +02:00
|
|
|
|
2021-04-12 10:16:59 +02:00
|
|
|
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_HANDLER;
|
|
|
|
|
2021-04-11 12:04:13 +02:00
|
|
|
static const Event REQUESTING_TM_READ_REPORT_FAILED = MAKE_EVENT(0, severity::LOW);
|
|
|
|
static const Event TM_READ_RPT_INVALID_CRC = MAKE_EVENT(1, severity::LOW);
|
|
|
|
static const Event ACK_FAILURE = MAKE_EVENT(2, severity::LOW);
|
2021-04-15 13:17:15 +02:00
|
|
|
static const Event CRC_FAILURE_IN_ACK_REPLY = MAKE_EVENT(2, severity::LOW);
|
2021-04-11 12:04:13 +02:00
|
|
|
static const Event EXE_FAILURE = MAKE_EVENT(3, severity::LOW);
|
|
|
|
static const Event EXE_RPT_INVALID_CRC = MAKE_EVENT(4, severity::LOW);
|
2021-03-29 14:37:52 +02:00
|
|
|
|
2021-04-11 12:04:13 +02:00
|
|
|
static const uint16_t APID_MASK = 0x7FF;
|
2021-03-29 14:37:52 +02:00
|
|
|
|
2021-04-11 12:04:13 +02:00
|
|
|
DeviceCommandId_t rememberCommandId = PLOC::NONE;
|
|
|
|
|
2021-04-15 13:17:15 +02:00
|
|
|
uint8_t commandBuffer[PLOC::MAX_COMMAND_SIZE];
|
|
|
|
|
2021-04-11 12:04:13 +02:00
|
|
|
/**
|
2021-04-15 13:17:15 +02:00
|
|
|
* @brief This function fills the commandBuffer to initiate the write memory command.
|
|
|
|
*
|
|
|
|
* @param commandData Pointer to action command data.
|
|
|
|
* @param commanDataLen Size of command data in bytes.
|
|
|
|
*
|
|
|
|
* @return RETURN_OK if successful, else RETURN_FAILURE.
|
2021-04-11 12:04:13 +02:00
|
|
|
*/
|
2021-04-15 13:17:15 +02:00
|
|
|
ReturnValue_t prepareTcMemWriteCommand(const uint8_t * commandData, size_t commandDataLen);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief This function fills the commandBuffer to initiate the write reads command.
|
|
|
|
*
|
|
|
|
* @param commandData Pointer to action command data.
|
|
|
|
* @param commanDataLen Size of command data in bytes.
|
|
|
|
*
|
|
|
|
* @return RETURN_OK if successful, else RETURN_FAILURE.
|
|
|
|
*/
|
|
|
|
ReturnValue_t prepareTcMemReadCommand(const uint8_t * commandData, size_t commandDataLen);
|
2021-03-29 14:37:52 +02:00
|
|
|
|
|
|
|
/**
|
2021-04-11 12:04:13 +02:00
|
|
|
* @brief This function checks the crc of the received PLOC reply.
|
|
|
|
*
|
|
|
|
* @param start Pointer to the first byte of the reply.
|
|
|
|
* @param foundLen Pointer to the length of the whole packet.
|
2021-03-29 14:37:52 +02:00
|
|
|
*
|
2021-04-11 12:04:13 +02:00
|
|
|
* @return RETURN_OK if CRC is ok, otherwise CRC_FAILURE.
|
|
|
|
*/
|
2021-04-15 13:17:15 +02:00
|
|
|
ReturnValue_t verifyPacket(const uint8_t* start, size_t foundLen);
|
2021-04-11 12:04:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief This function reads and handles the execution reply.
|
2021-04-15 13:17:15 +02:00
|
|
|
* @param RETURN_OK if reading and handling of reply successful, otherwise failure value.
|
2021-04-11 12:04:13 +02:00
|
|
|
*/
|
2021-04-15 13:17:15 +02:00
|
|
|
ReturnValue_t receiveExecutionReport();
|
2021-04-11 12:04:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief This function handles the data of a execution report.
|
2021-03-29 14:37:52 +02:00
|
|
|
*
|
2021-04-11 12:04:13 +02:00
|
|
|
* @param receivedData Pointer to the received data
|
|
|
|
* @param receivedDataLen Size in bytes of the received data
|
2021-04-15 13:17:15 +02:00
|
|
|
*
|
|
|
|
* @return RETURN_OK if successful, otherwise an error code.
|
2021-03-29 14:37:52 +02:00
|
|
|
*/
|
2021-04-11 12:04:13 +02:00
|
|
|
void handleExecutionReport(const uint8_t* receivedData, size_t receivedDataLen);
|
2021-03-29 14:37:52 +02:00
|
|
|
|
|
|
|
/**
|
2021-04-11 12:04:13 +02:00
|
|
|
* @brief This function reads and handles the memory read report telemetry packet received
|
|
|
|
* after requesting the packet with the TC_MEM_READ command.
|
|
|
|
*
|
|
|
|
* @details In case of a valid packet the received memory content will be forwarded to the
|
|
|
|
* commanding object via an action message.
|
|
|
|
*/
|
2021-04-15 13:17:15 +02:00
|
|
|
ReturnValue_t receiveTmMemoryReadReport();
|
2021-03-29 14:37:52 +02:00
|
|
|
|
2021-04-11 12:04:13 +02:00
|
|
|
/**
|
|
|
|
* @brief This function handles action message replies in case the telemetry has been
|
|
|
|
* requested by another object.
|
2021-03-29 14:37:52 +02:00
|
|
|
*
|
2021-04-11 12:04:13 +02:00
|
|
|
* @param data Pointer to the telemtry data.
|
|
|
|
* @param dataSize Size of telemetry in bytes.
|
|
|
|
* @param replyId Id of the reply. This will be added to the ActionMessage.
|
2021-03-29 14:37:52 +02:00
|
|
|
*/
|
2021-04-11 12:04:13 +02:00
|
|
|
void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId);
|
2021-03-29 14:37:52 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* MISSION_DEVICES_PLOCHANDLER_H_ */
|