#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ #include #include #include #include "MPSoCReturnValuesIF.h" #include "OBSWConfig.h" #include "PlocMPSoCCommonDefinitions.h" #include "eive/definitions.h" #include "fsfw/globalfunctions/CRC.h" #include "fsfw/serialize/SerializeAdapter.h" #include "fsfw/tmtcpacket/SpacePacket.h" class PlocMPSoCHandler; FSFW_ENUM(PlocMpSoCCommands, DeviceCommandId_t, ((NONE, 0, "No Command"))((TC_MEM_WRITE, 1, "Write to Memory"))( (TC_MEM_READ, 2, "Read from Memory"))((ACK_REPORT, 3, ""))((EXE_REPORT, 5, ""))( (TM_MEMORY_READ_REPORT, 6, ""))((TC_FLASHWRITE, 9, "Write Flash"))( (TC_FLASHDELETE, 10, "Delete Flash"))((TC_REPLAY_START, 11, "Start Replay"))( (TC_REPLAY_STOP, 12, "Stop Replay"))((TC_REPLAY_WRITE_SEQUENCE, 13, "Write Sequence"))((TC_DOWNLINK_PWR_ON, 14, "Set Downlink Power On"))( (TC_DOWNLINK_PWR_OFF, 15, "Set Downlink Power Off"))((TC_MODE_REPLAY, 16, "Set Replay Mode"))( (TC_CAM_CMD_SEND, 17, "Set Replay Mode"))((TC_MODE_IDLE, 18, "Set Idle Mode"))( (TM_CAM_CMD_RPT, 19, ""))((SET_UART_TX_TRISTATE, 20, "Set UART TX to Tristate"))( (RELEASE_UART_TX, 21, "Release UART TX"))((OBSW_RESET_SEQ_COUNT, 50, "Reset OBSW Reset Sequence Count"))) class PlocMpSoCMemWriteAction : public TemplateAction { public: PlocMpSoCMemWriteAction(PlocMPSoCHandler *owner) : TemplateAction(owner, PlocMpSoCCommands::TC_MEM_WRITE){}; Parameter address = Parameter::createParameter(this, "Memory Address"); Parameter memoryData = Parameter::createParameter(this, "Data to be written"); }; class PlocMpSoCMemReadAction : public TemplateAction { public: PlocMpSoCMemReadAction(PlocMPSoCHandler *owner) : TemplateAction(owner, PlocMpSoCCommands::TC_MEM_READ){}; }; class PlocMpSoCFlashDeleteAction : public TemplateAction { public: PlocMpSoCFlashDeleteAction(PlocMPSoCHandler *owner) : TemplateAction(owner, PlocMpSoCCommands::TC_FLASHDELETE){}; }; class PlocMpSoCReplayStartAction : public TemplateAction { public: PlocMpSoCReplayStartAction(PlocMPSoCHandler *owner) : TemplateAction(owner, PlocMpSoCCommands::TC_REPLAY_START){}; }; class PlocMpSoCReplayStopAction : public TemplateAction { public: PlocMpSoCReplayStopAction(PlocMPSoCHandler *owner) : TemplateAction(owner, PlocMpSoCCommands::TC_REPLAY_STOP){}; }; class PlocMpSoCReplayWriteSequenceAction : public TemplateAction { public: PlocMpSoCReplayWriteSequenceAction(PlocMPSoCHandler *owner) : TemplateAction(owner, PlocMpSoCCommands::TC_REPLAY_WRITE_SEQUENCE){}; }; class PlocMpSoCDownlinkPwrOnAction : public TemplateAction { public: PlocMpSoCDownlinkPwrOnAction(PlocMPSoCHandler *owner) : TemplateAction(owner, PlocMpSoCCommands::TC_DOWNLINK_PWR_ON){}; }; class PlocMpSoCDownlinkPwrOffAction : public TemplateAction { public: PlocMpSoCDownlinkPwrOffAction(PlocMPSoCHandler *owner) : TemplateAction(owner, PlocMpSoCCommands::TC_DOWNLINK_PWR_OFF){}; }; class PlocMpSoCModeReplayAction : public TemplateAction { public: PlocMpSoCModeReplayAction(PlocMPSoCHandler *owner) : TemplateAction(owner, PlocMpSoCCommands::TC_MODE_REPLAY){}; }; class PlocMpSoCCamCmdSendAction : public TemplateAction { public: PlocMpSoCCamCmdSendAction(PlocMPSoCHandler *owner) : TemplateAction(owner, PlocMpSoCCommands::TC_CAM_CMD_SEND){}; }; class PlocMpSoCModeIdleAction : public TemplateAction { public: PlocMpSoCModeIdleAction(PlocMPSoCHandler *owner) : TemplateAction(owner, PlocMpSoCCommands::TC_MODE_IDLE){}; }; class PlocMpSoCFlashWriteAction : public TemplateAction { public: PlocMpSoCFlashWriteAction(PlocMPSoCHandler *owner) : TemplateAction(owner, PlocMpSoCCommands::TC_FLASHWRITE){}; }; class PlocMpSoCUartTxTristateAction : public TemplateAction { public: PlocMpSoCUartTxTristateAction(PlocMPSoCHandler *owner) : TemplateAction(owner, PlocMpSoCCommands::SET_UART_TX_TRISTATE){}; }; class PlocMpSoCReleaseUartTxAction : public TemplateAction { public: PlocMpSoCReleaseUartTxAction(PlocMPSoCHandler *owner) : TemplateAction(owner, PlocMpSoCCommands::RELEASE_UART_TX){}; }; class PlocMpSoCObswResetSeqCountAction : public TemplateAction { public: PlocMpSoCObswResetSeqCountAction(PlocMPSoCHandler *owner) : TemplateAction(owner, PlocMpSoCCommands::OBSW_RESET_SEQ_COUNT){}; }; namespace mpsoc { /** * @brief This class helps to generate the space packet to write data to a memory address within * the PLOC. */ class TcMemWrite : public TcBase { public: /** * @brief Constructor */ TcMemWrite(uint16_t sequenceCount) : TcBase(apid::TC_MEM_WRITE, sequenceCount) {} protected: ReturnValue_t initPacket(void *actionIn) { auto action = (PlocMpSoCMemWriteAction *)(actionIn); //TODO ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; // faking until framework code is ready // uint16_t length = action->memoryData.length; uint16_t dataLength = 1; result = lengthCheck(dataLength); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } uint8_t *pointer = this->localData.fields.buffer; size_t size = 0; size_t maxSize = PACKET_MAX_SIZE; SerializeAdapter::serialize(&action->address.value, &pointer, &size, maxSize, SerializeIF::Endianness::BIG); SerializeAdapter::serialize(&dataLength, &pointer, &size, maxSize, SerializeIF::Endianness::BIG); std::memcpy(pointer, &action->memoryData.value, dataLength); this->setPacketDataLength(dataLength * sizeof(action->memoryData.value) + FIX_LENGTH - 1); return result; } private: // Min length consists of 4 byte data (1 word) static const size_t MIN_COMMAND_DATA_LENGTH = 1; static const size_t FIX_LENGTH = 8; ReturnValue_t lengthCheck(size_t commandDataLen) { if (commandDataLen < MIN_COMMAND_DATA_LENGTH) { sif::warning << "TcMemWrite: Command has invalid length " << commandDataLen << std::endl; return INVALID_LENGTH; } return HasReturnvaluesIF::RETURN_OK; } }; } // namespace mpsoc #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ */