From 664670573a116c995d16e7154163732de4a84c8f Mon Sep 17 00:00:00 2001 From: EIVE Cleanroom Date: Mon, 21 Mar 2022 11:05:41 +0100 Subject: [PATCH] tc replay stop wip --- fsfw | 2 +- .../devicedefinitions/PlocMPSoCDefinitions.h | 84 +++++++++++++++++++ linux/devices/ploc/PlocMPSoCHandler.cpp | 14 ++++ linux/devices/ploc/PlocMPSoCHandler.h | 2 +- tmtc | 2 +- 5 files changed, 101 insertions(+), 3 deletions(-) diff --git a/fsfw b/fsfw index bac8b408..1b7e0371 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit bac8b4088009a71afbb0225e634dabcbff0d9ec1 +Subproject commit 1b7e0371c337f9edae70f7bf1845a8a4854a6b8f diff --git a/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h b/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h index e19bca50..ea51c0aa 100644 --- a/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h +++ b/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h @@ -85,6 +85,8 @@ public: //! [EXPORT] : [COMMENT] Received command with invalid length static const ReturnValue_t INVALID_LENGTH = MAKE_RETURN_CODE(0xC0); + //! [EXPORT] : [COMMENT] Command has invalid parameter + static const ReturnValue_t INVALID_PARAMETER = MAKE_RETURN_CODE(0xC1); /** * @brief Constructor @@ -364,11 +366,93 @@ public: return RETURN_FAILED; } std::memcpy(this->getPacketData(), writeData, writeLen); + addCrc(); this->setPacketDataLength(static_cast(writeLen + CRC_SIZE - 1)); return RETURN_OK; } }; +/** + * @brief This class helps to build the replay start command. + */ +class TcReplayStart: public TcBase { +public: + /** + * @brief Constructor + */ + TcReplayStart(uint16_t sequenceCount) : TcBase(apid::TC_REPLAY_START, sequenceCount) { + } + +protected: + + ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + result = lengthCheck(commandDataLen); + if (result != RETURN_OK) { + return result; + } + result = lengthData(commandData); + if (result != RETURN_OK) { + return result; + } + std::memcpy(this->localData.fields.buffer, commandData, commandDataLen); + this->setPacketDataLength(commandDataLen + CRC_SIZE - 1); + return result; + } + +private: + + static const size_t COMMAND_DATA_LENGTH = 1; + static const uint8_t REPEATING = 0; + static const uint8_t ONCE = 1; + + ReturnValue_t lengthCheck(size_t commandDataLen) { + if (commandDataLen != COMMAND_DATA_LENGTH) { + sif::warning << "TcReplayStart: Command has invalid length " << commandDataLen << std::endl; + return INVALID_LENGTH; + } + return RETURN_OK; + } + + ReturnValue_t checkData(uint8_t replay) { + if (replay != REPEATING && replay != ONCE) { + sif::warning << "TcReplayStart::checkData: Invalid replay value" << std::endl; + return INVALID_PARAMETER; + } + return RETURN_OK; + } +}; + +/** + * @brief This class helps to build the replay stop command. + */ +class TcReplayStart: public TcBase { +public: + /** + * @brief Constructor + */ + TcReplayStart(uint16_t sequenceCount) : TcBase(apid::TC_REPLAY_START, sequenceCount) { + } + +protected: + + ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + result = lengthCheck(commandDataLen); + if (result != RETURN_OK) { + return result; + } + result = lengthData(commandData); + if (result != RETURN_OK) { + return result; + } + std::memcpy(this->localData.fields.buffer, commandData, commandDataLen); + this->setPacketDataLength(commandDataLen + CRC_SIZE - 1); + return result; + } + +}; + } #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ */ diff --git a/linux/devices/ploc/PlocMPSoCHandler.cpp b/linux/devices/ploc/PlocMPSoCHandler.cpp index d8e4d2c6..de808a0e 100644 --- a/linux/devices/ploc/PlocMPSoCHandler.cpp +++ b/linux/devices/ploc/PlocMPSoCHandler.cpp @@ -311,6 +311,20 @@ ReturnValue_t PlocMPSoCHandler::prepareTcFlashDelete(const uint8_t * commandData return RETURN_OK; } +ReturnValue_t PlocMPSoCHandler::prepareTcReplayStart( + const uint8_t * commandData, size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + sequenceCount++; + mpsoc::TcReplayStart tcReplayStart(sequenceCount); + result = tcReplayStart.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; diff --git a/linux/devices/ploc/PlocMPSoCHandler.h b/linux/devices/ploc/PlocMPSoCHandler.h index 81828ca3..b6cc8914 100644 --- a/linux/devices/ploc/PlocMPSoCHandler.h +++ b/linux/devices/ploc/PlocMPSoCHandler.h @@ -130,7 +130,7 @@ private: 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 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); diff --git a/tmtc b/tmtc index 1af59ea7..9005ccab 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 1af59ea7a53cd0cbbaf433710d99c6c27369a3d1 +Subproject commit 9005ccab3a07f569c45369f591c12b7613ffcac3