From f32f68d0e00fd1c789e7ca9d9bfb3417a9d4bb2c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 7 Nov 2022 11:26:36 +0100 Subject: [PATCH] continue switch to new packet format --- .../PlocSupervisorDefinitions.h | 16 +++++++++------- linux/devices/ploc/PlocSupervisorHandler.cpp | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/linux/devices/devicedefinitions/PlocSupervisorDefinitions.h b/linux/devices/devicedefinitions/PlocSupervisorDefinitions.h index 257a8c53..e0c4f960 100644 --- a/linux/devices/devicedefinitions/PlocSupervisorDefinitions.h +++ b/linux/devices/devicedefinitions/PlocSupervisorDefinitions.h @@ -378,6 +378,10 @@ class TcBase : public ploc::SpTcBase { } } + void setLenFromPayloadLen(size_t payloadLen) { + spParams.setFullPayloadLen(ccsds::HEADER_LEN + SECONDARY_HEADER_LEN + payloadLen + CRC_LEN); + } + private: uint8_t serviceId = 0; @@ -387,6 +391,7 @@ class TcBase : public ploc::SpTcBase { return returnvalue::FAILED; } std::memset(spParams.buf + ccsds::HEADER_LEN, 0, TIMESTAMP_LEN); + payloadStart = spParams.buf + SECONDARY_HEADER_LEN; return returnvalue::OK; } }; @@ -413,7 +418,7 @@ class NoPayloadPacket : public TcBase { * @brief This class can be used to generate the space packet selecting the boot image of * of the MPSoC. */ -class MPSoCBootSelect : public ploc::SpTcBase { +class MPSoCBootSelect : public TcBase { public: static const uint8_t NVM0 = 0; static const uint8_t NVM1 = 1; @@ -428,8 +433,8 @@ class MPSoCBootSelect : public ploc::SpTcBase { * * @note Selection of partitions is currently not supported. */ - MPSoCBootSelect(ploc::SpTcParams params) : ploc::SpTcBase(params) { - spParams.setFullPayloadLen(DATA_FIELD_LENGTH); + MPSoCBootSelect(TcParams params) : TcBase(params) { + params.setLenFromPayloadLen(4); spParams.creator.setApid(APID_SEL_MPSOC_BOOT_IMAGE); spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT); } @@ -444,16 +449,13 @@ class MPSoCBootSelect : public ploc::SpTcBase { } private: - static const uint16_t DATA_FIELD_LENGTH = 6; - static const uint8_t MEM_OFFSET = 0; static const uint8_t BP0_OFFSET = 1; static const uint8_t BP1_OFFSET = 2; static const uint8_t BP2_OFFSET = 3; - static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; void initPacket(uint8_t mem = 0, uint8_t bp0 = 0, uint8_t bp1 = 0, uint8_t bp2 = 0) { - std::memcpy(payloadStart + MEM_OFFSET, &mem, sizeof(mem)); + payloadStart[0] = mem; std::memcpy(payloadStart + BP0_OFFSET, &bp0, sizeof(bp0)); std::memcpy(payloadStart + BP1_OFFSET, &bp1, sizeof(bp1)); std::memcpy(payloadStart + BP2_OFFSET, &bp2, sizeof(bp2)); diff --git a/linux/devices/ploc/PlocSupervisorHandler.cpp b/linux/devices/ploc/PlocSupervisorHandler.cpp index 853741cf..65eda209 100644 --- a/linux/devices/ploc/PlocSupervisorHandler.cpp +++ b/linux/devices/ploc/PlocSupervisorHandler.cpp @@ -1431,7 +1431,7 @@ ReturnValue_t PlocSupervisorHandler::prepareEmptyCmd(uint16_t apid, uint8_t serv ReturnValue_t PlocSupervisorHandler::prepareSelBootImageCmd(const uint8_t* commandData) { supv::MPSoCBootSelect packet(spParams); ReturnValue_t result = - packet.buildPacket(*commandData, *(commandData + 1), *(commandData + 2), *(commandData + 3)); + packet.buildPacket(commandData[0], commandData[1], commandData[2], commandData[3]); if (result != returnvalue::OK) { return result; }