Merge branch 'mueller/refactor-tmtc-stack' into mueller/cfdp-routers

This commit is contained in:
Robin Müller 2022-09-05 16:29:10 +02:00
commit ead22c8bd6
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
8 changed files with 11 additions and 10 deletions

View File

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

View File

@ -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<uint8_t *>(*buffer + 1), lengthField);
value.setConstBuffer(const_cast<uint8_t *>(*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; }

View File

@ -119,7 +119,7 @@ const uint8_t* SerialBufferAdapter<count_t>::getConstBuffer() const {
}
template <typename count_t>
void SerialBufferAdapter<count_t>::setBuffer(const uint8_t* buf, count_t bufLen) {
void SerialBufferAdapter<count_t>::setConstBuffer(const uint8_t* buf, count_t bufLen) {
this->buffer = nullptr;
this->bufferLength = bufLen;
this->constBuffer = buf;

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -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();

View File

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