diff --git a/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h b/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h index 9348359f..b4b85efc 100644 --- a/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h +++ b/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h @@ -16,6 +16,12 @@ static const DeviceCommandId_t TM_MEMORY_READ_REPORT = 6; static const DeviceCommandId_t TC_FLASHFOPEN = 7; static const DeviceCommandId_t TC_FLASHFCLOSE = 8; static const DeviceCommandId_t TC_FLASHWRITE = 9; +static const DeviceCommandId_t TC_FLASHDELETE = 10; +static const DeviceCommandId_t TC_REPLAY_START = 11; +static const DeviceCommandId_t TC_REPLAY_STOP = 12; +static const DeviceCommandId_t TC_REPLAY_WRITE_SEQUENCE = 13; +static const DeviceCommandId_t TC_DOWNLINK_PWR_ON = 14; +static const DeviceCommandId_t TC_DOWNLINK_PWR_OFF = 15; static const uint16_t SIZE_ACK_REPORT = 14; static const uint16_t SIZE_EXE_REPORT = 14; @@ -25,11 +31,17 @@ static const uint16_t SIZE_TM_MEM_READ_REPORT = 18; * SpacePacket apids of PLOC telecommands and telemetry. */ namespace apid { + static const uint16_t TC_REPLAY_START = 0x110; + static const uint16_t TC_REPLAY_STOP = 0x111; + static const uint16_t TC_REPLAY_WRITE_SEQUENCE = 0x112; + static const uint16_t TC_DOWNLINK_PWR_ON = 0x113; static const uint16_t TC_MEM_WRITE = 0x114; static const uint16_t TC_MEM_READ = 0x115; static const uint16_t TC_FLASHWRITE = 0x117; static const uint16_t TC_FLASHFOPEN = 0x119; static const uint16_t TC_FLASHFCLOSE = 0x11A; + static const uint16_t TC_FLASHDELETE = 0x11C; + static const uint16_t TC_DOWLINK_PWR_OFF = 0x124; static const uint16_t TM_MEMORY_READ_REPORT = 0x404; static const uint16_t ACK_SUCCESS = 0x400; static const uint16_t ACK_FAILURE = 0x401; @@ -313,6 +325,29 @@ public: } }; +/** + * @brief Class to help creation of flash fclose command. + */ +class FlashDelete: public TcBase { +public: + + FlashDelete(uint16_t sequenceCount) : + TcBase(apid::TC_FLASHDELETE , sequenceCount) { + } + + ReturnValue_t createPacket(std::string filename) { + ReturnValue_t result = RETURN_OK; + size_t nameSize = filename.size(); + std::memcpy(this->getPacketData(), filename.c_str(), nameSize); + result = addCrc(); + if (result != RETURN_OK) { + return result; + } + this->setPacketDataLength(nameSize + CRC_SIZE - 1); + return result; + } +}; + /** * @brief Class to build flash write space packet. */ diff --git a/linux/devices/ploc/PlocMPSoCHandler.cpp b/linux/devices/ploc/PlocMPSoCHandler.cpp index e36a7240..2d99545a 100644 --- a/linux/devices/ploc/PlocMPSoCHandler.cpp +++ b/linux/devices/ploc/PlocMPSoCHandler.cpp @@ -131,11 +131,15 @@ ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand( ReturnValue_t result = RETURN_OK; switch(deviceCommand) { case(mpsoc::TC_MEM_WRITE): { - result = prepareTcMemWriteCommand(commandData, commandDataLen); + result = prepareTcMemWrite(commandData, commandDataLen); break; } case(mpsoc::TC_MEM_READ): { - result = prepareTcMemReadCommand(commandData, commandDataLen); + result = prepareTcMemRead(commandData, commandDataLen); + break; + } + case(mpsoc::TC_FLASHDELETE): { + result = prepareTcFlashDelete(commandData, commandDataLen); break; } default: @@ -260,7 +264,7 @@ void PlocMPSoCHandler::handleEvent(EventMessage* eventMessage) { } } -ReturnValue_t PlocMPSoCHandler::prepareTcMemWriteCommand(const uint8_t * commandData, +ReturnValue_t PlocMPSoCHandler::prepareTcMemWrite(const uint8_t * commandData, size_t commandDataLen) { ReturnValue_t result = RETURN_OK; sequenceCount++; @@ -274,13 +278,14 @@ ReturnValue_t PlocMPSoCHandler::prepareTcMemWriteCommand(const uint8_t * command return RETURN_OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcMemReadCommand(const uint8_t * commandData, +ReturnValue_t PlocMPSoCHandler::prepareTcMemRead(const uint8_t * commandData, size_t commandDataLen) { ReturnValue_t result = RETURN_OK; sequenceCount++; mpsoc::TcMemRead tcMemRead(sequenceCount); result = tcMemRead.createPacket(commandData, commandDataLen); if (result != RETURN_OK) { + sequenceCount--; return result; } copyToCommandBuffer(&tcMemRead); @@ -288,6 +293,20 @@ ReturnValue_t PlocMPSoCHandler::prepareTcMemReadCommand(const uint8_t * commandD return RETURN_OK; } +ReturnValue_t PlocMPSoCHandler::prepareTcFlashDelete(const uint8_t * commandData, + size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + sequenceCount++; + mpsoc::TcFlashDelete tcFlashDelete(sequenceCount); + result = tcFlashDelete.createPacket(commandData, commandDataLen); + if (result != RETURN_OK) { + sequenceCount--; + return result; + } + copyToCommandBuffer(&tcFlashDelete); + return RETURN_OK; +} + void PlocMPSoCHandler::copyToCommandBuffer(mpsoc::TcBase* tc) { if (tc == nullptr) { sif::debug << "PlocMPSoCHandler::copyToCommandBuffer: Invalid TC" << std::endl; @@ -420,6 +439,7 @@ ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator switch (command->first) { case mpsoc::TC_MEM_WRITE: + case mpsoc::TC_FLASHDELETE: enabledReplies = 2; break; case mpsoc::TC_MEM_READ: { diff --git a/linux/devices/ploc/PlocMPSoCHandler.h b/linux/devices/ploc/PlocMPSoCHandler.h index ec81451f..60977bd0 100644 --- a/linux/devices/ploc/PlocMPSoCHandler.h +++ b/linux/devices/ploc/PlocMPSoCHandler.h @@ -124,8 +124,13 @@ private: */ void handleEvent(EventMessage* eventMessage); - ReturnValue_t prepareTcMemWriteCommand(const uint8_t * commandData, size_t commandDataLen); - ReturnValue_t prepareTcMemReadCommand(const uint8_t * commandData, size_t commandDataLen); + ReturnValue_t prepareTcMemWrite(const uint8_t * commandData, size_t commandDataLen); + ReturnValue_t prepareTcMemRead(const uint8_t * commandData, size_t commandDataLen); + ReturnValue_t prepareTcFlashDelete(const uint8_t * commandData, size_t commandDataLen); +// ReturnValue_t prepareTcReplayStart(const uint8_t * commandData, size_t commandDataLen); +// ReturnValue_t prepareTcReplayStop(const uint8_t * commandData, size_t commandDataLen); +// ReturnValue_t prepareTcDownlinkPwrOff(const uint8_t * commandData, size_t commandDataLen); +// ReturnValue_t prepareTcDownlinkPwrOn(const uint8_t * commandData, size_t commandDataLen); /** * @brief Copies space packet into command buffer