rename const buf setter
This commit is contained in:
parent
1e395dc402
commit
3583e30ee6
@ -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(const_cast<uint8_t*>(*buffer + 1), lengthField);
|
||||||
*buffer += 1 + lengthField;
|
*buffer += 1 + lengthField;
|
||||||
*size -= 1 + lengthField;
|
*size -= 1 + lengthField;
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
|
@ -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(const_cast<uint8_t *>(*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; }
|
||||||
|
@ -119,7 +119,7 @@ const uint8_t* SerialBufferAdapter<count_t>::getConstBuffer() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename count_t>
|
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->buffer = nullptr;
|
||||||
this->bufferLength = bufLen;
|
this->bufferLength = bufLen;
|
||||||
this->constBuffer = buf;
|
this->constBuffer = buf;
|
||||||
|
@ -65,7 +65,7 @@ class SerialBufferAdapter : public SerializeIF {
|
|||||||
|
|
||||||
uint8_t* getBuffer();
|
uint8_t* getBuffer();
|
||||||
[[nodiscard]] const uint8_t* getConstBuffer() const;
|
[[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:
|
private:
|
||||||
bool serializeLength = false;
|
bool serializeLength = false;
|
||||||
|
@ -84,7 +84,7 @@ SpacePacketParams &PusTcCreator::getSpParams() { return spCreator.getParams(); }
|
|||||||
|
|
||||||
ReturnValue_t PusTcCreator::setRawUserData(const uint8_t *data, size_t len) {
|
ReturnValue_t PusTcCreator::setRawUserData(const uint8_t *data, size_t len) {
|
||||||
// TODO: Check length field?
|
// TODO: Check length field?
|
||||||
pusParams.bufAdapter.setBuffer(data, len);
|
pusParams.bufAdapter.setConstBuffer(data, len);
|
||||||
pusParams.appData = &pusParams.bufAdapter;
|
pusParams.appData = &pusParams.bufAdapter;
|
||||||
updateSpLengthField();
|
updateSpLengthField();
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
|
@ -13,7 +13,7 @@ struct PusTcParams {
|
|||||||
PusTcParams(uint8_t service_, uint8_t subservice_) : service(service_), subservice(subservice_) {}
|
PusTcParams(uint8_t service_, uint8_t subservice_) : service(service_), subservice(subservice_) {}
|
||||||
|
|
||||||
void setRawAppData(const uint8_t *data, size_t len) {
|
void setRawAppData(const uint8_t *data, size_t len) {
|
||||||
bufAdapter.setBuffer(data, len);
|
bufAdapter.setConstBuffer(data, len);
|
||||||
appData = &bufAdapter;
|
appData = &bufAdapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ ReturnValue_t PusTmCreator::setRawUserData(const uint8_t* data, size_t len) {
|
|||||||
if (data == nullptr or len == 0) {
|
if (data == nullptr or len == 0) {
|
||||||
pusParams.sourceData = nullptr;
|
pusParams.sourceData = nullptr;
|
||||||
} else {
|
} else {
|
||||||
pusParams.adapter.setBuffer(data, len);
|
pusParams.adapter.setConstBuffer(data, len);
|
||||||
pusParams.sourceData = &pusParams.adapter;
|
pusParams.sourceData = &pusParams.adapter;
|
||||||
}
|
}
|
||||||
updateSpLengthField();
|
updateSpLengthField();
|
||||||
|
@ -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(),
|
||||||
|
Loading…
Reference in New Issue
Block a user