set buffer expects const pointer now

This commit is contained in:
Robin Müller 2022-09-05 16:25:02 +02:00
parent f5421e9abd
commit 1e395dc402
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
5 changed files with 5 additions and 13 deletions

View File

@ -119,14 +119,7 @@ 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>::setBuffer(const uint8_t* buf, count_t bufLen) {
this->buffer = buffer;
this->constBuffer = buffer;
this->bufferLength = bufferLength;
}
template <typename count_t>
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;

View File

@ -65,8 +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(uint8_t* buffer, count_t bufferLength); 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;

View File

@ -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.setConstBuffer(data, len); pusParams.bufAdapter.setBuffer(data, len);
pusParams.appData = &pusParams.bufAdapter; pusParams.appData = &pusParams.bufAdapter;
updateSpLengthField(); updateSpLengthField();
return returnvalue::OK; return returnvalue::OK;

View File

@ -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.setConstBuffer(data, len); bufAdapter.setBuffer(data, len);
appData = &bufAdapter; 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) { if (data == nullptr or len == 0) {
pusParams.sourceData = nullptr; pusParams.sourceData = nullptr;
} else { } else {
pusParams.adapter.setConstBuffer(data, len); pusParams.adapter.setBuffer(data, len);
pusParams.sourceData = &pusParams.adapter; pusParams.sourceData = &pusParams.adapter;
} }
updateSpLengthField(); updateSpLengthField();