From e1c06ce1f50eb966e1825a60c046c65115b44286 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 15 Aug 2022 18:58:56 +0200 Subject: [PATCH] possible bugfix --- .../devicedefinitions/PlocMPSoCDefinitions.h | 8 ++++---- mission/devices/devicedefinitions/SpBase.h | 13 ++++++++----- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h b/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h index adcd4271..eb46791f 100644 --- a/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h +++ b/linux/devices/devicedefinitions/PlocMPSoCDefinitions.h @@ -174,7 +174,7 @@ class TcBase : public ploc::SpTcBase, public MPSoCReturnValuesIF { } } - updateFields(); + updateSpFields(); res = checkSizeAndSerializeHeader(); if (res != result::OK) { return res; @@ -306,7 +306,7 @@ class FlashFopen : public ploc::SpTcBase { *(spParams.buf + nameSize) = NULL_TERMINATOR; std::memcpy(payloadStart + nameSize + sizeof(NULL_TERMINATOR), &accessMode, sizeof(accessMode)); spParams.setPayloadLen(nameSize + sizeof(NULL_TERMINATOR) + sizeof(accessMode)); - updateFields(); + updateSpFields(); return calcCrc(); } @@ -354,7 +354,7 @@ class TcFlashWrite : public ploc::SpTcBase { } std::memcpy(payloadStart + sizeof(writeLen), writeData, writeLen); spParams.setPayloadLen(static_cast(writeLen) + 4); - updateFields(); + updateSpFields(); auto res = checkSizeAndSerializeHeader(); if (res != result::OK) { return res; @@ -379,7 +379,7 @@ class TcFlashDelete : public ploc::SpTcBase { std::memcpy(payloadStart, filename.c_str(), nameSize); *(payloadStart + nameSize) = NULL_TERMINATOR; spParams.setPayloadLen(nameSize + sizeof(NULL_TERMINATOR)); - updateFields(); + updateSpFields(); auto res = checkSizeAndSerializeHeader(); if (res != result::OK) { return res; diff --git a/mission/devices/devicedefinitions/SpBase.h b/mission/devices/devicedefinitions/SpBase.h index c03c7360..c3a683cb 100644 --- a/mission/devices/devicedefinitions/SpBase.h +++ b/mission/devices/devicedefinitions/SpBase.h @@ -26,16 +26,19 @@ struct SpTcParams { class SpTcBase { public: - SpTcBase(SpTcParams params) : spParams(params) { updateFields(); } + SpTcBase(SpTcParams params) : spParams(params) { + payloadStart = spParams.buf + ccsds::HEADER_LEN; + updateSpFields(); + } SpTcBase(SpTcParams params, uint16_t apid, uint16_t seqCount) : spParams(params) { spParams.creator.setApid(apid); spParams.creator.setSeqCount(seqCount); - updateFields(); + payloadStart = spParams.buf + ccsds::HEADER_LEN; + updateSpFields(); } - void updateFields() { - payloadStart = spParams.buf + ccsds::HEADER_LEN; + void updateSpFields() { spParams.creator.setDataLen(spParams.dataFieldLen - 1); spParams.creator.setPacketType(ccsds::PacketType::TC); } @@ -55,7 +58,7 @@ class SpTcBase { } ReturnValue_t serializeHeader() { - updateFields(); + updateSpFields(); size_t serLen = 0; return spParams.creator.serializeBe(spParams.buf, serLen, spParams.maxSize); }