From 3583e30ee66a06f96a36da1b8bae3bf0e581d7a9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Sep 2022 16:27:20 +0200 Subject: [PATCH] rename const buf setter --- src/fsfw/cfdp/tlv/Lv.cpp | 4 ++-- src/fsfw/cfdp/tlv/Tlv.cpp | 4 ++-- src/fsfw/serialize/SerialBufferAdapter.cpp | 2 +- src/fsfw/serialize/SerialBufferAdapter.h | 2 +- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp | 2 +- src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h | 2 +- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 2 +- unittests/serialize/testSerialBufferAdapter.cpp | 3 ++- 8 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/fsfw/cfdp/tlv/Lv.cpp b/src/fsfw/cfdp/tlv/Lv.cpp index 9c72b260..8105ade6 100644 --- a/src/fsfw/cfdp/tlv/Lv.cpp +++ b/src/fsfw/cfdp/tlv/Lv.cpp @@ -21,7 +21,7 @@ cfdp::Lv& cfdp::Lv::operator=(const Lv& other) { if (value == nullptr or otherSize == 0) { this->zeroLen = true; } - this->value.setBuffer(value, otherSize); + this->value.setConstBuffer(value, otherSize); return *this; } @@ -70,7 +70,7 @@ ReturnValue_t cfdp::Lv::deSerialize(const uint8_t** buffer, size_t* size, } zeroLen = false; // Zero-copy implementation - value.setBuffer(const_cast(*buffer + 1), lengthField); + value.setConstBuffer(const_cast(*buffer + 1), lengthField); *buffer += 1 + lengthField; *size -= 1 + lengthField; return returnvalue::OK; diff --git a/src/fsfw/cfdp/tlv/Tlv.cpp b/src/fsfw/cfdp/tlv/Tlv.cpp index 3a394741..435466be 100644 --- a/src/fsfw/cfdp/tlv/Tlv.cpp +++ b/src/fsfw/cfdp/tlv/Tlv.cpp @@ -75,7 +75,7 @@ ReturnValue_t cfdp::Tlv::deSerialize(const uint8_t **buffer, size_t *size, } zeroLen = false; // Zero-copy implementation - value.setBuffer(const_cast(*buffer + 1), lengthField); + value.setConstBuffer(const_cast(*buffer + 1), lengthField); *buffer += 1 + lengthField; *size -= 1 + lengthField; return returnvalue::OK; @@ -96,7 +96,7 @@ void cfdp::Tlv::setValue(uint8_t *value, size_t len) { if (len > 0) { zeroLen = false; } - this->value.setBuffer(value, len); + this->value.setConstBuffer(value, len); } uint8_t cfdp::Tlv::getLengthField() const { return this->value.getSerializedSize() - 1; } diff --git a/src/fsfw/serialize/SerialBufferAdapter.cpp b/src/fsfw/serialize/SerialBufferAdapter.cpp index f387a1fc..cf28d2ba 100644 --- a/src/fsfw/serialize/SerialBufferAdapter.cpp +++ b/src/fsfw/serialize/SerialBufferAdapter.cpp @@ -119,7 +119,7 @@ const uint8_t* SerialBufferAdapter::getConstBuffer() const { } template -void SerialBufferAdapter::setBuffer(const uint8_t* buf, count_t bufLen) { +void SerialBufferAdapter::setConstBuffer(const uint8_t* buf, count_t bufLen) { this->buffer = nullptr; this->bufferLength = bufLen; this->constBuffer = buf; diff --git a/src/fsfw/serialize/SerialBufferAdapter.h b/src/fsfw/serialize/SerialBufferAdapter.h index 45ac5f0f..b156bb02 100644 --- a/src/fsfw/serialize/SerialBufferAdapter.h +++ b/src/fsfw/serialize/SerialBufferAdapter.h @@ -65,7 +65,7 @@ class SerialBufferAdapter : public SerializeIF { uint8_t* getBuffer(); [[nodiscard]] const uint8_t* getConstBuffer() const; - void setBuffer(const uint8_t* buf, count_t bufLen); + void setConstBuffer(const uint8_t* buf, count_t bufLen); private: bool serializeLength = false; diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp index 50e75d80..34d8396d 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.cpp @@ -84,7 +84,7 @@ SpacePacketParams &PusTcCreator::getSpParams() { return spCreator.getParams(); } ReturnValue_t PusTcCreator::setRawUserData(const uint8_t *data, size_t len) { // TODO: Check length field? - pusParams.bufAdapter.setBuffer(data, len); + pusParams.bufAdapter.setConstBuffer(data, len); pusParams.appData = &pusParams.bufAdapter; updateSpLengthField(); return returnvalue::OK; diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h index 0bd210b0..abccef8d 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcCreator.h @@ -13,7 +13,7 @@ struct PusTcParams { PusTcParams(uint8_t service_, uint8_t subservice_) : service(service_), subservice(subservice_) {} void setRawAppData(const uint8_t *data, size_t len) { - bufAdapter.setBuffer(data, len); + bufAdapter.setConstBuffer(data, len); appData = &bufAdapter; } diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index 02955ffe..41512c07 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -131,7 +131,7 @@ ReturnValue_t PusTmCreator::setRawUserData(const uint8_t* data, size_t len) { if (data == nullptr or len == 0) { pusParams.sourceData = nullptr; } else { - pusParams.adapter.setBuffer(data, len); + pusParams.adapter.setConstBuffer(data, len); pusParams.sourceData = &pusParams.adapter; } updateSpLengthField(); diff --git a/unittests/serialize/testSerialBufferAdapter.cpp b/unittests/serialize/testSerialBufferAdapter.cpp index e5ea379e..abd179e4 100644 --- a/unittests/serialize/testSerialBufferAdapter.cpp +++ b/unittests/serialize/testSerialBufferAdapter.cpp @@ -64,7 +64,8 @@ TEST_CASE("Serial Buffer Adapter", "[single-file]") { SECTION("Test set buffer function") { SerialBufferAdapter tv_serial_buffer_adapter_loc = SerialBufferAdapter((uint8_t*)nullptr, 0, true); - tv_serial_buffer_adapter_loc.setBuffer(test_serial_buffer.data(), test_serial_buffer.size()); + tv_serial_buffer_adapter_loc.setConstBuffer(test_serial_buffer.data(), + test_serial_buffer.size()); serialized_size = 0; arrayPtr = testArray.data(); SerializeAdapter::serialize(&test_value_bool, &arrayPtr, &serialized_size, testArray.size(),