rename setBuffer to setConstBuffer

This commit is contained in:
Robin Müller 2022-09-05 16:31:56 +02:00
parent eb03bf52a6
commit 16688316a8
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
8 changed files with 25 additions and 25 deletions

View File

@ -360,7 +360,8 @@ if(NOT FSFW_CONFIG_PATH)
if(NOT FSFW_BUILD_DOCS) if(NOT FSFW_BUILD_DOCS)
message( message(
WARNING WARNING
"${MSG_PREFIX} Flight Software Framework configuration path FSFW_CONFIG_PATH not set") "${MSG_PREFIX} Flight Software Framework configuration path FSFW_CONFIG_PATH not set"
)
message( message(
WARNING WARNING
"${MSG_PREFIX} Setting default configuration from ${DEF_CONF_PATH} ..") "${MSG_PREFIX} Setting default configuration from ${DEF_CONF_PATH} ..")

View File

@ -21,7 +21,7 @@ cfdp::Lv& cfdp::Lv::operator=(const Lv& other) {
if (value == nullptr or otherSize == 0) { if (value == nullptr or otherSize == 0) {
this->zeroLen = true; this->zeroLen = true;
} }
this->value.setBuffer(value, otherSize); this->value.setConstBuffer(value, otherSize);
return *this; return *this;
} }
@ -70,7 +70,7 @@ ReturnValue_t cfdp::Lv::deSerialize(const uint8_t** buffer, size_t* size,
} }
zeroLen = false; zeroLen = false;
// Zero-copy implementation // Zero-copy implementation
value.setBuffer(const_cast<uint8_t*>(*buffer + 1), lengthField); value.setConstBuffer(*buffer + 1, lengthField);
*buffer += 1 + lengthField; *buffer += 1 + lengthField;
*size -= 1 + lengthField; *size -= 1 + lengthField;
return returnvalue::OK; return returnvalue::OK;

View File

@ -75,7 +75,7 @@ ReturnValue_t cfdp::Tlv::deSerialize(const uint8_t **buffer, size_t *size,
} }
zeroLen = false; zeroLen = false;
// Zero-copy implementation // Zero-copy implementation
value.setBuffer(const_cast<uint8_t *>(*buffer + 1), lengthField); value.setConstBuffer(*buffer + 1, lengthField);
*buffer += 1 + lengthField; *buffer += 1 + lengthField;
*size -= 1 + lengthField; *size -= 1 + lengthField;
return returnvalue::OK; return returnvalue::OK;
@ -96,7 +96,7 @@ void cfdp::Tlv::setValue(uint8_t *value, size_t len) {
if (len > 0) { if (len > 0) {
zeroLen = false; zeroLen = false;
} }
this->value.setBuffer(value, len); this->value.setConstBuffer(value, len);
} }
uint8_t cfdp::Tlv::getLengthField() const { return this->value.getSerializedSize() - 1; } uint8_t cfdp::Tlv::getLengthField() const { return this->value.getSerializedSize() - 1; }

View File

@ -571,7 +571,7 @@ inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::getMapFilterFr
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
if(fromTimestamp > toTimestamp) { if (fromTimestamp > toTimestamp) {
return INVALID_TIME_WINDOW; return INVALID_TIME_WINDOW;
} }
itBegin = telecommandMap.begin(); itBegin = telecommandMap.begin();
@ -580,7 +580,7 @@ inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::getMapFilterFr
itBegin++; itBegin++;
} }
//start looking for end beginning at begin // start looking for end beginning at begin
itEnd = itBegin; itEnd = itBegin;
while (itEnd->first <= toTimestamp && itEnd != telecommandMap.end()) { while (itEnd->first <= toTimestamp && itEnd != telecommandMap.end()) {
itEnd++; itEnd++;

View File

@ -21,7 +21,7 @@ SerialBufferAdapter<count_t>::SerialBufferAdapter(uint8_t* buffer, count_t buffe
bufferLength(bufferLength) {} bufferLength(bufferLength) {}
template <typename count_t> template <typename count_t>
SerialBufferAdapter<count_t>::~SerialBufferAdapter() {} SerialBufferAdapter<count_t>::~SerialBufferAdapter() = default;
template <typename count_t> template <typename count_t>
ReturnValue_t SerialBufferAdapter<count_t>::serialize(uint8_t** buffer, size_t* size, ReturnValue_t SerialBufferAdapter<count_t>::serialize(uint8_t** buffer, size_t* size,
@ -119,10 +119,10 @@ const uint8_t* SerialBufferAdapter<count_t>::getConstBuffer() const {
} }
template <typename count_t> template <typename count_t>
void SerialBufferAdapter<count_t>::setBuffer(uint8_t* buffer, count_t bufferLength) { void SerialBufferAdapter<count_t>::setConstBuffer(const uint8_t* buf, count_t bufLen) {
this->buffer = buffer; this->buffer = nullptr;
this->constBuffer = buffer; this->bufferLength = bufLen;
this->bufferLength = bufferLength; this->constBuffer = buf;
} }
// forward Template declaration for linker // forward Template declaration for linker

View File

@ -21,6 +21,7 @@
template <typename count_t> template <typename count_t>
class SerialBufferAdapter : public SerializeIF { class SerialBufferAdapter : public SerializeIF {
public: public:
SerialBufferAdapter() = default;
/** /**
* Constructor for constant uint8_t buffer. Length field can be serialized optionally. * Constructor for constant uint8_t buffer. Length field can be serialized optionally.
* Type of length can be supplied as template type. * Type of length can be supplied as template type.
@ -40,12 +41,12 @@ class SerialBufferAdapter : public SerializeIF {
*/ */
SerialBufferAdapter(uint8_t* buffer, count_t bufferLength, bool serializeLength = false); SerialBufferAdapter(uint8_t* buffer, count_t bufferLength, bool serializeLength = false);
virtual ~SerialBufferAdapter(); ~SerialBufferAdapter() override;
virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
Endianness streamEndianness) const override; Endianness streamEndianness) const override;
virtual size_t getSerializedSize() const override; [[nodiscard]] size_t getSerializedSize() const override;
/** /**
* @brief This function deserializes a buffer into the member buffer. * @brief This function deserializes a buffer into the member buffer.
@ -59,12 +60,12 @@ class SerialBufferAdapter : public SerializeIF {
* @param bigEndian * @param bigEndian
* @return * @return
*/ */
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
Endianness streamEndianness) override; Endianness streamEndianness) override;
uint8_t* getBuffer(); uint8_t* getBuffer();
const uint8_t* getConstBuffer() const; [[nodiscard]] const uint8_t* getConstBuffer() const;
void setBuffer(uint8_t* buffer, count_t bufferLength); void setConstBuffer(const uint8_t* buf, count_t bufLen);
private: private:
bool serializeLength = false; bool serializeLength = false;

View File

@ -17,7 +17,6 @@
*/ */
class SpacePacketParser { class SpacePacketParser {
public: public:
struct FoundPacketInfo { struct FoundPacketInfo {
size_t startIdx = 0; size_t startIdx = 0;
size_t sizeFound = 0; size_t sizeFound = 0;
@ -51,9 +50,7 @@ class SpacePacketParser {
ReturnValue_t parseSpacePackets(const uint8_t** buffer, const size_t maxSize, ReturnValue_t parseSpacePackets(const uint8_t** buffer, const size_t maxSize,
FoundPacketInfo& packetInfo); FoundPacketInfo& packetInfo);
size_t getAmountRead() { size_t getAmountRead() { return amountRead; }
return amountRead;
}
void reset() { void reset() {
nextStartIdx = 0; nextStartIdx = 0;

View File

@ -64,7 +64,8 @@ TEST_CASE("Serial Buffer Adapter", "[single-file]") {
SECTION("Test set buffer function") { SECTION("Test set buffer function") {
SerialBufferAdapter<uint8_t> tv_serial_buffer_adapter_loc = SerialBufferAdapter<uint8_t> tv_serial_buffer_adapter_loc =
SerialBufferAdapter<uint8_t>((uint8_t*)nullptr, 0, true); SerialBufferAdapter<uint8_t>((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; serialized_size = 0;
arrayPtr = testArray.data(); arrayPtr = testArray.data();
SerializeAdapter::serialize(&test_value_bool, &arrayPtr, &serialized_size, testArray.size(), SerializeAdapter::serialize(&test_value_bool, &arrayPtr, &serialized_size, testArray.size(),