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-03-29 14:37:52 +02:00
|
|
|
|
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);
|
|
|
|
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;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief This function checks wheter a telemetry packet is expected or not.
|
|
|
|
*/
|
|
|
|
ReturnValue_t receiveTm();
|
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.
|
|
|
|
*/
|
|
|
|
ReturnValue_t verifyPacket(const uint8_t* start, size_t* foundLen);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief This function reads and handles the execution reply.
|
|
|
|
*/
|
|
|
|
void receiveExecutionReport();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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-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.
|
|
|
|
*/
|
|
|
|
void 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_ */
|