ssize_t in deSerialize replaced by size_t

This commit is contained in:
Robin Müller 2020-04-15 15:53:46 +02:00
parent af27a2441a
commit 906f941f32
47 changed files with 191 additions and 129 deletions

View File

@ -201,7 +201,7 @@ public:
return printSize; return printSize;
} }
virtual ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size, virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian) { bool bigEndian) {
ReturnValue_t result = SerializeAdapter<uint32_t>::deSerialize(&this->_size, ReturnValue_t result = SerializeAdapter<uint32_t>::deSerialize(&this->_size,
buffer, size, bigEndian); buffer, size, bigEndian);

View File

@ -80,7 +80,7 @@ size_t DataPoolParameterWrapper::getSerializedSize() const {
} }
ReturnValue_t DataPoolParameterWrapper::deSerialize(const uint8_t** buffer, ReturnValue_t DataPoolParameterWrapper::deSerialize(const uint8_t** buffer,
ssize_t* size, bool bigEndian) { size_t* size, bool bigEndian) {
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }

View File

@ -16,7 +16,7 @@ public:
virtual size_t getSerializedSize() const; virtual size_t getSerializedSize() const;
virtual ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size, virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian); bool bigEndian);
ReturnValue_t copyFrom(const ParameterWrapper *from, ReturnValue_t copyFrom(const ParameterWrapper *from,

View File

@ -136,7 +136,7 @@ void DataSet::setValid(uint8_t valid) {
} }
} }
ReturnValue_t DataSet::deSerialize(const uint8_t** buffer, ssize_t* size, ReturnValue_t DataSet::deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian) { bool bigEndian) {
ReturnValue_t result = RETURN_FAILED; ReturnValue_t result = RETURN_FAILED;
for (uint16_t count = 0; count < fill_count; count++) { for (uint16_t count = 0; count < fill_count; count++) {

View File

@ -126,7 +126,7 @@ public:
virtual size_t getSerializedSize() const; virtual size_t getSerializedSize() const;
ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size, ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian); bool bigEndian);
private: private:

View File

@ -136,7 +136,7 @@ public:
return SerializeAdapter<T>::getSerializedSize(&value); return SerializeAdapter<T>::getSerializedSize(&value);
} }
virtual ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size, virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian) { bool bigEndian) {
return SerializeAdapter<T>::deSerialize(&value, buffer, size, bigEndian); return SerializeAdapter<T>::deSerialize(&value, buffer, size, bigEndian);
} }

View File

@ -197,11 +197,11 @@ size_t PoolRawAccess::getSerializedSize() const {
return typeSize; return typeSize;
} }
ReturnValue_t PoolRawAccess::deSerialize(const uint8_t** buffer, ssize_t* size, ReturnValue_t PoolRawAccess::deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian) { bool bigEndian) {
*size -= typeSize; // TODO: Needs to be tested!!!
if (*size >= 0) { if (*size >= typeSize) {
*size -= typeSize;
if (bigEndian) { if (bigEndian) {
#ifndef BYTE_ORDER_SYSTEM #ifndef BYTE_ORDER_SYSTEM
#error BYTE_ORDER_SYSTEM not defined #error BYTE_ORDER_SYSTEM not defined
@ -212,12 +212,14 @@ ReturnValue_t PoolRawAccess::deSerialize(const uint8_t** buffer, ssize_t* size,
#elif BYTE_ORDER_SYSTEM == BIG_ENDIAN #elif BYTE_ORDER_SYSTEM == BIG_ENDIAN
memcpy(value, *buffer, typeSize); memcpy(value, *buffer, typeSize);
#endif #endif
} else { }
else {
memcpy(value, *buffer, typeSize); memcpy(value, *buffer, typeSize);
} }
*buffer += typeSize; *buffer += typeSize;
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} else { }
else {
return SerializeIF::STREAM_TOO_SHORT; return SerializeIF::STREAM_TOO_SHORT;
} }
} }

View File

@ -127,7 +127,7 @@ public:
size_t getSerializedSize() const; size_t getSerializedSize() const;
ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size, ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian); bool bigEndian);
protected: protected:

View File

@ -25,7 +25,7 @@ ReturnValue_t PoolRawAccessHelper::serialize(uint8_t **buffer, size_t *size,
const size_t max_size, bool bigEndian) { const size_t max_size, bool bigEndian) {
SerializationArgs serializationArgs = {buffer, size, max_size, bigEndian}; SerializationArgs serializationArgs = {buffer, size, max_size, bigEndian};
ReturnValue_t result; ReturnValue_t result;
ssize_t remainingParametersSize = numberOfParameters * 4; size_t remainingParametersSize = numberOfParameters * 4;
for(uint8_t count=0; count < numberOfParameters; count++) { for(uint8_t count=0; count < numberOfParameters; count++) {
result = serializeCurrentPoolEntryIntoBuffer(serializationArgs, result = serializeCurrentPoolEntryIntoBuffer(serializationArgs,
&remainingParametersSize, false); &remainingParametersSize, false);
@ -44,7 +44,7 @@ ReturnValue_t PoolRawAccessHelper::serializeWithValidityMask(uint8_t ** buffer,
size_t * size, const size_t max_size, bool bigEndian) { size_t * size, const size_t max_size, bool bigEndian) {
ReturnValue_t result; ReturnValue_t result;
SerializationArgs argStruct = {buffer, size, max_size, bigEndian}; SerializationArgs argStruct = {buffer, size, max_size, bigEndian};
ssize_t remainingParametersSize = numberOfParameters * 4; size_t remainingParametersSize = numberOfParameters * 4;
uint8_t validityMaskSize = ceil((float)numberOfParameters/8.0); uint8_t validityMaskSize = ceil((float)numberOfParameters/8.0);
uint8_t validityMask[validityMaskSize]; uint8_t validityMask[validityMaskSize];
memset(validityMask,0, validityMaskSize); memset(validityMask,0, validityMaskSize);
@ -67,49 +67,60 @@ ReturnValue_t PoolRawAccessHelper::serializeWithValidityMask(uint8_t ** buffer,
return result; return result;
} }
ReturnValue_t PoolRawAccessHelper::serializeCurrentPoolEntryIntoBuffer(SerializationArgs argStruct, ReturnValue_t PoolRawAccessHelper::serializeCurrentPoolEntryIntoBuffer(
ssize_t * remainingParameters, bool withValidMask, uint8_t * validityMask) { SerializationArgs argStruct, size_t * remainingParameters,
bool withValidMask, uint8_t * validityMask) {
uint32_t currentPoolId; uint32_t currentPoolId;
// Deserialize current pool ID from pool ID buffer // Deserialize current pool ID from pool ID buffer
ReturnValue_t result = AutoSerializeAdapter::deSerialize(&currentPoolId, ReturnValue_t result = AutoSerializeAdapter::deSerialize(&currentPoolId,
&poolIdBuffer,remainingParameters,true); &poolIdBuffer,remainingParameters,true);
if(result != RETURN_OK) { if(result != RETURN_OK) {
debug << std::hex << "Pool Raw Access Helper: Error deSeralizing pool IDs" << std::dec << std::endl; debug << std::hex << "Pool Raw Access Helper: Error deSeralizing "
"pool IDs" << std::dec << std::endl;
return result; return result;
} }
result = handlePoolEntrySerialization(currentPoolId, argStruct, withValidMask, validityMask); result = handlePoolEntrySerialization(currentPoolId, argStruct,
withValidMask, validityMask);
return result; return result;
} }
ReturnValue_t PoolRawAccessHelper::handlePoolEntrySerialization(uint32_t currentPoolId,SerializationArgs argStruct, ReturnValue_t PoolRawAccessHelper::handlePoolEntrySerialization(
bool withValidMask, uint8_t * validityMask) { uint32_t currentPoolId,SerializationArgs argStruct, bool withValidMask,
uint8_t * validityMask) {
ReturnValue_t result = RETURN_FAILED; ReturnValue_t result = RETURN_FAILED;
uint8_t arrayPosition = 0; uint8_t arrayPosition = 0;
uint8_t counter = 0; uint8_t counter = 0;
bool poolEntrySerialized = false; bool poolEntrySerialized = false;
//debug << "Pool Raw Access Helper: Handling Pool ID: " << std::hex << currentPoolId << std::endl; //debug << "Pool Raw Access Helper: Handling Pool ID: "
// << std::hex << currentPoolId << std::endl;
while(not poolEntrySerialized) { while(not poolEntrySerialized) {
if(counter > DataSet::DATA_SET_MAX_SIZE) { if(counter > DataSet::DATA_SET_MAX_SIZE) {
error << "Pool Raw Access Helper: Config error, max. number of possible data set variables exceeded" << std::endl; error << "Pool Raw Access Helper: Config error, "
"max. number of possible data set variables exceeded"
<< std::endl;
return result; return result;
} }
counter ++; counter ++;
DataSet currentDataSet = DataSet(); DataSet currentDataSet = DataSet();
//debug << "Current array position: " << (int)arrayPosition << std::endl; //debug << "Current array position: " << (int)arrayPosition << std::endl;
PoolRawAccess currentPoolRawAccess(currentPoolId,arrayPosition,&currentDataSet,PoolVariableIF::VAR_READ); PoolRawAccess currentPoolRawAccess(currentPoolId,arrayPosition,
&currentDataSet,PoolVariableIF::VAR_READ);
result = currentDataSet.read(); result = currentDataSet.read();
if (result != RETURN_OK) { if (result != RETURN_OK) {
debug << std::hex << "Pool Raw Access Helper: Error reading raw dataset with returncode 0x" debug << std::hex << "Pool Raw Access Helper: Error reading raw "
"dataset with returncode 0x"
<< result << std::dec << std::endl; << result << std::dec << std::endl;
return result; return result;
} }
result = checkRemainingSize(&currentPoolRawAccess, &poolEntrySerialized, &arrayPosition); result = checkRemainingSize(&currentPoolRawAccess, &poolEntrySerialized,
&arrayPosition);
if(result != RETURN_OK) { if(result != RETURN_OK) {
error << "Pool Raw Access Helper: Configuration Error at pool ID " << std::hex << currentPoolId error << "Pool Raw Access Helper: Configuration Error at pool ID "
<< std::hex << currentPoolId
<< ". Size till end smaller than 0" << std::dec << std::endl; << ". Size till end smaller than 0" << std::dec << std::endl;
return result; return result;
} }
@ -125,8 +136,9 @@ ReturnValue_t PoolRawAccessHelper::handlePoolEntrySerialization(uint32_t current
result = currentDataSet.serialize(argStruct.buffer, argStruct.size, result = currentDataSet.serialize(argStruct.buffer, argStruct.size,
argStruct.max_size, argStruct.bigEndian); argStruct.max_size, argStruct.bigEndian);
if (result != RETURN_OK) { if (result != RETURN_OK) {
debug << "Pool Raw Access Helper: Error serializing pool data with ID 0x" << std::hex << debug << "Pool Raw Access Helper: Error serializing pool data with "
currentPoolId << " into send buffer with return code " << result << std::dec << std::endl; "ID 0x" << std::hex << currentPoolId << " into send buffer "
"with return code " << result << std::dec << std::endl;
return result; return result;
} }
@ -134,9 +146,10 @@ ReturnValue_t PoolRawAccessHelper::handlePoolEntrySerialization(uint32_t current
return result; return result;
} }
ReturnValue_t PoolRawAccessHelper::checkRemainingSize(PoolRawAccess * currentPoolRawAccess, ReturnValue_t PoolRawAccessHelper::checkRemainingSize(PoolRawAccess*
bool * isSerialized, uint8_t * arrayPosition) { currentPoolRawAccess, bool * isSerialized, uint8_t * arrayPosition) {
int8_t remainingSize = currentPoolRawAccess->getSizeTillEnd() - currentPoolRawAccess->getSizeOfType(); int8_t remainingSize = currentPoolRawAccess->getSizeTillEnd() -
currentPoolRawAccess->getSizeOfType();
if(remainingSize == 0) { if(remainingSize == 0) {
*isSerialized = true; *isSerialized = true;
} }
@ -158,7 +171,8 @@ void PoolRawAccessHelper::handleMaskModification(uint8_t * validityMask) {
} }
} }
uint8_t PoolRawAccessHelper::bitSetter(uint8_t byte, uint8_t position, bool value) { uint8_t PoolRawAccessHelper::bitSetter(uint8_t byte, uint8_t position,
bool value) {
if(position < 1 or position > 8) { if(position < 1 or position > 8) {
debug << "Pool Raw Access: Bit setting invalid position" << std::endl; debug << "Pool Raw Access: Bit setting invalid position" << std::endl;
return byte; return byte;

View File

@ -80,13 +80,15 @@ private:
* @param hkDataSize * @param hkDataSize
* @param max_size * @param max_size
* @param bigEndian * @param bigEndian
* @param withValidMask Can be set optionally to set a provided validity mask * @param withValidMask Can be set optionally to set a
* @param validityMask Can be supplied and will be set if @c withValidMask is set to true * provided validity mask
* @param validityMask Can be supplied and will be set if
* @c withValidMask is set to true
* @return * @return
*/ */
ReturnValue_t serializeCurrentPoolEntryIntoBuffer(SerializationArgs argStruct, ReturnValue_t serializeCurrentPoolEntryIntoBuffer(
ssize_t * remainingParameters, bool withValidMask = false, SerializationArgs argStruct, size_t * remainingParameters,
uint8_t * validityMask = nullptr); bool withValidMask = false, uint8_t * validityMask = nullptr);
ReturnValue_t handlePoolEntrySerialization(uint32_t currentPoolId, ReturnValue_t handlePoolEntrySerialization(uint32_t currentPoolId,
SerializationArgs argStruct, bool withValidMask = false, SerializationArgs argStruct, bool withValidMask = false,

View File

@ -203,7 +203,7 @@ public:
return SerializeAdapter<T>::getSerializedSize(&value); return SerializeAdapter<T>::getSerializedSize(&value);
} }
virtual ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size, virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian) { bool bigEndian) {
return SerializeAdapter<T>::deSerialize(&value, buffer, size, bigEndian); return SerializeAdapter<T>::deSerialize(&value, buffer, size, bigEndian);
} }

View File

@ -215,7 +215,7 @@ public:
return vector_size * SerializeAdapter<T>::getSerializedSize(value); return vector_size * SerializeAdapter<T>::getSerializedSize(value);
} }
virtual ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size, virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian) { bool bigEndian) {
uint16_t i; uint16_t i;
ReturnValue_t result; ReturnValue_t result;

View File

@ -31,7 +31,7 @@ size_t DeviceTmReportingWrapper::getSerializedSize() const {
} }
ReturnValue_t DeviceTmReportingWrapper::deSerialize(const uint8_t** buffer, ReturnValue_t DeviceTmReportingWrapper::deSerialize(const uint8_t** buffer,
ssize_t* size, bool bigEndian) { size_t* size, bool bigEndian) {
ReturnValue_t result = SerializeAdapter<object_id_t>::deSerialize(&objectId, ReturnValue_t result = SerializeAdapter<object_id_t>::deSerialize(&objectId,
buffer, size, bigEndian); buffer, size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {

View File

@ -16,7 +16,7 @@ public:
virtual size_t getSerializedSize() const; virtual size_t getSerializedSize() const;
virtual ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size, virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian); bool bigEndian);
private: private:
object_id_t objectId; object_id_t objectId;

View File

@ -18,7 +18,7 @@ public:
size_t getSerializedSize() const { size_t getSerializedSize() const {
return rangeMatcher.getSerializedSize(); return rangeMatcher.getSerializedSize();
} }
ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size, ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian) { bool bigEndian) {
return rangeMatcher.deSerialize(buffer, size, bigEndian); return rangeMatcher.deSerialize(buffer, size, bigEndian);
} }

View File

@ -85,7 +85,7 @@ size_t Type::getSerializedSize() const {
return 2 * SerializeAdapter<uint8_t>::getSerializedSize(&dontcare); return 2 * SerializeAdapter<uint8_t>::getSerializedSize(&dontcare);
} }
ReturnValue_t Type::deSerialize(const uint8_t** buffer, ssize_t* size, ReturnValue_t Type::deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian) { bool bigEndian) {
uint8_t ptc; uint8_t ptc;
uint8_t pfc; uint8_t pfc;

View File

@ -44,7 +44,7 @@ public:
virtual size_t getSerializedSize() const; virtual size_t getSerializedSize() const;
virtual ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size, virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian); bool bigEndian);
private: private:

View File

@ -115,7 +115,7 @@ public:
return size; return size;
} }
ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size, ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian) { bool bigEndian) {
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }

View File

@ -29,32 +29,38 @@ public:
ReturnValue_t serialize(uint8_t** buffer, size_t* size, ReturnValue_t serialize(uint8_t** buffer, size_t* size,
const size_t max_size, bool bigEndian) const { const size_t max_size, bool bigEndian) const {
ReturnValue_t result = SerializeAdapter<T>::serialize(&lowerBound, buffer, size, max_size, bigEndian); ReturnValue_t result = SerializeAdapter<T>::serialize(&lowerBound,
buffer, size, max_size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
result = SerializeAdapter<T>::serialize(&upperBound, buffer, size, max_size, bigEndian); result = SerializeAdapter<T>::serialize(&upperBound, buffer, size,
max_size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
return SerializeAdapter<bool>::serialize(&inverted, buffer, size, max_size, bigEndian); return SerializeAdapter<bool>::serialize(&inverted, buffer, size,
max_size, bigEndian);
} }
size_t getSerializedSize() const { size_t getSerializedSize() const {
return sizeof(lowerBound) + sizeof(upperBound) + sizeof(bool); return sizeof(lowerBound) + sizeof(upperBound) + sizeof(bool);
} }
ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size, ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian) { bool bigEndian) {
ReturnValue_t result = SerializeAdapter<T>::deSerialize(&lowerBound, buffer, size, bigEndian); ReturnValue_t result = SerializeAdapter<T>::deSerialize(&lowerBound,
buffer, size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
result = SerializeAdapter<T>::deSerialize(&upperBound, buffer, size, bigEndian); result = SerializeAdapter<T>::deSerialize(&upperBound, buffer,
size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
return SerializeAdapter<bool>::deSerialize(&inverted, buffer, size, bigEndian); return SerializeAdapter<bool>::deSerialize(&inverted, buffer,
size, bigEndian);
} }
protected: protected:
bool doMatch(T input) { bool doMatch(T input) {

View File

@ -112,7 +112,7 @@ ReturnValue_t ParameterWrapper::deSerializeData(uint8_t startingRow,
//treat from as a continuous Stream as we copy all of it //treat from as a continuous Stream as we copy all of it
const uint8_t *fromAsStream = (const uint8_t *) from; const uint8_t *fromAsStream = (const uint8_t *) from;
ssize_t streamSize = fromRows * fromColumns * sizeof(T); size_t streamSize = fromRows * fromColumns * sizeof(T);
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
@ -137,12 +137,12 @@ ReturnValue_t ParameterWrapper::deSerializeData(uint8_t startingRow,
} }
ReturnValue_t ParameterWrapper::deSerialize(const uint8_t** buffer, ReturnValue_t ParameterWrapper::deSerialize(const uint8_t** buffer,
ssize_t* size, bool bigEndian) { size_t* size, bool bigEndian) {
return deSerialize(buffer, size, bigEndian, 0); return deSerialize(buffer, size, bigEndian, 0);
} }
ReturnValue_t ParameterWrapper::deSerialize(const uint8_t** buffer, ReturnValue_t ParameterWrapper::deSerialize(const uint8_t** buffer,
ssize_t* size, bool bigEndian, uint16_t startWritingAtIndex) { size_t* size, bool bigEndian, uint16_t startWritingAtIndex) {
ParameterWrapper streamDescription; ParameterWrapper streamDescription;
ReturnValue_t result = streamDescription.set(*buffer, *size, buffer, size); ReturnValue_t result = streamDescription.set(*buffer, *size, buffer, size);
@ -153,8 +153,10 @@ ReturnValue_t ParameterWrapper::deSerialize(const uint8_t** buffer,
return copyFrom(&streamDescription, startWritingAtIndex); return copyFrom(&streamDescription, startWritingAtIndex);
} }
ReturnValue_t ParameterWrapper::set(const uint8_t* stream, ssize_t streamSize, ReturnValue_t ParameterWrapper::set(const uint8_t* stream, size_t streamSize,
const uint8_t **remainingStream, ssize_t *remainingSize) { const uint8_t **remainingStream, size_t *remainingSize) {
// TODO: Replaced ssize_t for remainingSize and streamSize
// is the logic here correct?
ReturnValue_t result = SerializeAdapter<Type>::deSerialize(&type, &stream, ReturnValue_t result = SerializeAdapter<Type>::deSerialize(&type, &stream,
&streamSize, true); &streamSize, true);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
@ -172,22 +174,22 @@ ReturnValue_t ParameterWrapper::set(const uint8_t* stream, ssize_t streamSize,
return result; return result;
} }
int32_t dataSize = type.getSize() * rows * columns; size_t dataSize = type.getSize() * rows * columns;
if (streamSize < dataSize) { if (streamSize < dataSize) {
return SerializeIF::STREAM_TOO_SHORT; return SerializeIF::STREAM_TOO_SHORT;
} }
data = NULL; data = nullptr;
readonlyData = stream; readonlyData = stream;
pointsToStream = true; pointsToStream = true;
stream += dataSize; stream += dataSize;
if (remainingStream != NULL) { if (remainingStream != nullptr) {
*remainingStream = stream; *remainingStream = stream;
} }
streamSize -= dataSize; streamSize -= dataSize;
if (remainingSize != NULL) { if (remainingSize != nullptr) {
*remainingSize = streamSize; *remainingSize = streamSize;
} }

View File

@ -30,10 +30,10 @@ public:
virtual size_t getSerializedSize() const; virtual size_t getSerializedSize() const;
virtual ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size, virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian); bool bigEndian);
virtual ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size, virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian, uint16_t startWritingAtIndex = 0); bool bigEndian, uint16_t startWritingAtIndex = 0);
template<typename T> template<typename T>
@ -111,8 +111,8 @@ public:
void setMatrix(const T& member) { void setMatrix(const T& member) {
this->set(member[0], sizeof(member)/sizeof(member[0]), sizeof(member[0])/sizeof(member[0][0])); this->set(member[0], sizeof(member)/sizeof(member[0]), sizeof(member[0])/sizeof(member[0][0]));
} }
ReturnValue_t set(const uint8_t *stream, ssize_t streamSize, ReturnValue_t set(const uint8_t *stream, size_t streamSize,
const uint8_t **remainingStream = NULL, ssize_t *remainingSize = const uint8_t **remainingStream = NULL, size_t *remainingSize =
NULL); NULL);
ReturnValue_t copyFrom(const ParameterWrapper *from, ReturnValue_t copyFrom(const ParameterWrapper *from,

View File

@ -108,7 +108,7 @@ uint32_t Fuse::getSerializedSize() const {
return size; return size;
} }
ReturnValue_t Fuse::deSerialize(const uint8_t** buffer, ssize_t* size, ReturnValue_t Fuse::deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian) { bool bigEndian) {
ReturnValue_t result = RETURN_FAILED; ReturnValue_t result = RETURN_FAILED;
for (DeviceList::iterator iter = devices.begin(); iter != devices.end(); for (DeviceList::iterator iter = devices.begin(); iter != devices.end();

View File

@ -52,7 +52,7 @@ public:
ReturnValue_t serialize(uint8_t** buffer, size_t* size, ReturnValue_t serialize(uint8_t** buffer, size_t* size,
const size_t max_size, bool bigEndian) const; const size_t max_size, bool bigEndian) const;
uint32_t getSerializedSize() const; uint32_t getSerializedSize() const;
ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size, ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian); bool bigEndian);
void setAllMonitorsToUnchecked(); void setAllMonitorsToUnchecked();
ReturnValue_t performOperation(uint8_t opCode); ReturnValue_t performOperation(uint8_t opCode);

View File

@ -56,7 +56,7 @@ float PowerComponent::getMax() {
return max; return max;
} }
ReturnValue_t PowerComponent::deSerialize(const uint8_t** buffer, ssize_t* size, ReturnValue_t PowerComponent::deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian) { bool bigEndian) {
ReturnValue_t result = SerializeAdapter<float>::deSerialize(&min, buffer, ReturnValue_t result = SerializeAdapter<float>::deSerialize(&min, buffer,
size, bigEndian); size, bigEndian);

View File

@ -24,7 +24,7 @@ public:
size_t getSerializedSize() const; size_t getSerializedSize() const;
ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size, ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian); bool bigEndian);
ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId, ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId,

View File

@ -56,16 +56,19 @@ public:
return printSize; return printSize;
} }
virtual ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size, virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian) { bool bigEndian) {
return deSerialize(adaptee, buffer, size, bigEndian); return deSerialize(adaptee, buffer, size, bigEndian);
} }
static ReturnValue_t deSerialize(ArrayList<T, count_t>* list, static ReturnValue_t deSerialize(ArrayList<T, count_t>* list,
const uint8_t** buffer, ssize_t* size, bool bigEndian) { const uint8_t** buffer, size_t* size, bool bigEndian) {
count_t tempSize = 0; count_t tempSize = 0;
ReturnValue_t result = SerializeAdapter<count_t>::deSerialize(&tempSize, ReturnValue_t result = SerializeAdapter<count_t>::deSerialize(&tempSize,
buffer, size, bigEndian); buffer, size, bigEndian);
if(result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
if (tempSize > list->maxSize()) { if (tempSize > list->maxSize()) {
return SerializeIF::TOO_MANY_ELEMENTS; return SerializeIF::TOO_MANY_ELEMENTS;
} }

View File

@ -61,36 +61,38 @@ size_t SerialBufferAdapter<count_t>::getSerializedSize() const {
return bufferLength; return bufferLength;
} }
} }
template<typename count_t> template<typename count_t>
ReturnValue_t SerialBufferAdapter<count_t>::deSerialize(const uint8_t** buffer, ReturnValue_t SerialBufferAdapter<count_t>::deSerialize(const uint8_t** buffer,
ssize_t* size, bool bigEndian) { size_t* size, bool bigEndian) {
//TODO Ignores Endian flag! //TODO Ignores Endian flag!
if (buffer != NULL) { // (Robin) the one of the buffer? wouldn't that be an issue for serialize
if(serializeLength){ // as well? SerialFixedArrayListAdapter implements swapping of buffer
// Suggestion (would require removing rest of the block inside this if clause !): // fields (if buffer type is not uint8_t)
//ReturnValue_t result = AutoSerializeAdapter::deSerialize(&bufferLength,buffer,size,bigEndian); if (buffer != nullptr) {
//if (result != HasReturnvaluesIF::RETURN_OK) { if(serializeLength) {
// return result;
//}
count_t serializedSize = AutoSerializeAdapter::getSerializedSize( count_t serializedSize = AutoSerializeAdapter::getSerializedSize(
&bufferLength); &bufferLength);
if((*size - bufferLength - serializedSize) >= 0){ if(bufferLength + serializedSize >= *size) {
*buffer += serializedSize; *buffer += serializedSize;
*size -= serializedSize; *size -= serializedSize;
}else{ }
else {
return STREAM_TOO_SHORT; return STREAM_TOO_SHORT;
} }
} }
//No Else If, go on with buffer //No Else If, go on with buffer
if (*size - bufferLength >= 0) { if (bufferLength >= *size) {
*size -= bufferLength; *size -= bufferLength;
memcpy(m_buffer, *buffer, bufferLength); memcpy(m_buffer, *buffer, bufferLength);
(*buffer) += bufferLength; (*buffer) += bufferLength;
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} else { }
else {
return STREAM_TOO_SHORT; return STREAM_TOO_SHORT;
} }
} else { }
else {
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
} }

View File

@ -49,7 +49,19 @@ public:
virtual size_t getSerializedSize() const; virtual size_t getSerializedSize() const;
virtual ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size, /**
* @brief This function deserializes a buffer into the member buffer.
* @details
* If a length field is present, it is ignored, as the size should have
* been set in the constructor. If the size is not known beforehand,
* consider using SerialFixedArrayListAdapter instead.
* @param buffer [out] Resulting buffer
* @param size remaining size to deserialize, should be larger than buffer
* + size field size
* @param bigEndian
* @return
*/
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian); bool bigEndian);
uint8_t * getBuffer(); uint8_t * getBuffer();

View File

@ -22,32 +22,38 @@
* @ingroup serialize * @ingroup serialize
*/ */
template<typename BUFFER_TYPE, uint32_t MAX_SIZE, typename count_t = uint8_t> template<typename BUFFER_TYPE, uint32_t MAX_SIZE, typename count_t = uint8_t>
class SerialFixedArrayListAdapter : public FixedArrayList<BUFFER_TYPE, MAX_SIZE, count_t>, public SerializeIF { class SerialFixedArrayListAdapter :
public FixedArrayList<BUFFER_TYPE, MAX_SIZE, count_t>,
public SerializeIF {
public: public:
/** /**
* Constructor Arguments are forwarded to FixedArrayList constructor * Constructor Arguments are forwarded to FixedArrayList constructor
* @param args * @param args
*/ */
template<typename... Args> template<typename... Args>
SerialFixedArrayListAdapter(Args... args) : FixedArrayList<BUFFER_TYPE, MAX_SIZE, count_t>(std::forward<Args>(args)...) { SerialFixedArrayListAdapter(Args... args) :
} FixedArrayList<BUFFER_TYPE, MAX_SIZE, count_t>(std::forward<Args>(args)...)
{}
ReturnValue_t serialize(uint8_t** buffer, size_t* size, ReturnValue_t serialize(uint8_t** buffer, size_t* size,
const size_t max_size, bool bigEndian) const { const size_t max_size, bool bigEndian) const {
return SerialArrayListAdapter<BUFFER_TYPE, count_t>::serialize(this, buffer, size, max_size, bigEndian); return SerialArrayListAdapter<BUFFER_TYPE, count_t>::serialize(this,
buffer, size, max_size, bigEndian);
} }
size_t getSerializedSize() const { size_t getSerializedSize() const {
return SerialArrayListAdapter<BUFFER_TYPE, count_t>::getSerializedSize(this); return SerialArrayListAdapter<BUFFER_TYPE, count_t>::
getSerializedSize(this);
} }
ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size, ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian) { bool bigEndian) {
return SerialArrayListAdapter<BUFFER_TYPE, count_t>::deSerialize(this, return SerialArrayListAdapter<BUFFER_TYPE, count_t>::deSerialize(this,
buffer, size, bigEndian); buffer, size, bigEndian);
} }
void swapArrayListEndianness() { void swapArrayListEndianness() {
SerialArrayListAdapter<BUFFER_TYPE, count_t>::swapArrayListEndianness(this); SerialArrayListAdapter<BUFFER_TYPE, count_t>::
swapArrayListEndianness(this);
} }
}; };

View File

@ -122,13 +122,13 @@ public:
* @param bigEndian Specify endianness * @param bigEndian Specify endianness
* @return * @return
*/ */
virtual ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size, virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian) { bool bigEndian) {
return deSerialize(SinglyLinkedList<T>::start, buffer, size, bigEndian); return deSerialize(SinglyLinkedList<T>::start, buffer, size, bigEndian);
} }
static ReturnValue_t deSerialize(LinkedElement<T>* element, static ReturnValue_t deSerialize(LinkedElement<T>* element,
const uint8_t** buffer, ssize_t* size, bool bigEndian) { const uint8_t** buffer, size_t* size, bool bigEndian) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
while ((result == HasReturnvaluesIF::RETURN_OK) && (element != NULL)) { while ((result == HasReturnvaluesIF::RETURN_OK) && (element != NULL)) {
result = element->value->deSerialize(buffer, size, bigEndian); result = element->value->deSerialize(buffer, size, bigEndian);

View File

@ -78,7 +78,7 @@ public:
} }
template<typename T> template<typename T>
static ReturnValue_t deSerialize(T* object, const uint8_t** buffer, static ReturnValue_t deSerialize(T* object, const uint8_t** buffer,
ssize_t* size, bool bigEndian) { size_t* size, bool bigEndian) {
SerializeAdapter_<T, IsDerivedFrom<T, SerializeIF>::Is> adapter; SerializeAdapter_<T, IsDerivedFrom<T, SerializeIF>::Is> adapter;
return adapter.deSerialize(object, buffer, size, bigEndian); return adapter.deSerialize(object, buffer, size, bigEndian);
} }
@ -98,7 +98,7 @@ public:
} }
static ReturnValue_t deSerialize(T* object, const uint8_t** buffer, static ReturnValue_t deSerialize(T* object, const uint8_t** buffer,
ssize_t* size, bool bigEndian) { size_t* size, bool bigEndian) {
SerializeAdapter_<T, IsDerivedFrom<T, SerializeIF>::Is> adapter; SerializeAdapter_<T, IsDerivedFrom<T, SerializeIF>::Is> adapter;
return adapter.deSerialize(object, buffer, size, bigEndian); return adapter.deSerialize(object, buffer, size, bigEndian);
} }

View File

@ -33,7 +33,7 @@ public:
size_t* size, const size_t max_size, bool bigEndian) { size_t* size, const size_t max_size, bool bigEndian) {
// function eventuelly serializes structs here. // function eventuelly serializes structs here.
// does this work on every architecture? // does this work on every architecture?
//static_assert(std::is_fundamental<T>::value); // static_assert(std::is_fundamental<T>::value);
size_t ignoredSize = 0; size_t ignoredSize = 0;
if (size == nullptr) { if (size == nullptr) {
size = &ignoredSize; size = &ignoredSize;
@ -57,18 +57,17 @@ public:
/** /**
* Deserialize buffer into object * Deserialize buffer into object
* @param object [out] Object to be deserialized with buffer data * @param object [out] Object to be deserialized with buffer data
* @param buffer buffer containing the data. Non-Const pointer to non-const * @param buffer contains the data. Non-Const pointer to non-const
* pointer to const buffer. * pointer to const data.
* @param size int32_t type to allow value to be values smaller than 0, * @param size Size to deSerialize. wil be decremented by sizeof(T)
* needed for range/size checking
* @param bigEndian Specify endianness * @param bigEndian Specify endianness
* @return * @return
*/ */
ReturnValue_t deSerialize(T* object, const uint8_t** buffer, ssize_t* size, ReturnValue_t deSerialize(T* object, const uint8_t** buffer, size_t* size,
bool bigEndian) { bool bigEndian) {
T tmp; T tmp;
*size -= sizeof(T); if (*size >= sizeof(T)) {
if (*size >= 0) { *size -= sizeof(T);
memcpy(&tmp, *buffer, sizeof(T)); memcpy(&tmp, *buffer, sizeof(T));
if (bigEndian) { if (bigEndian) {
*object = EndianSwapper::swap<T>(tmp); *object = EndianSwapper::swap<T>(tmp);
@ -109,7 +108,7 @@ public:
return object->getSerializedSize(); return object->getSerializedSize();
} }
ReturnValue_t deSerialize(T* object, const uint8_t** buffer, ssize_t* size, ReturnValue_t deSerialize(T* object, const uint8_t** buffer, size_t* size,
bool bigEndian) { bool bigEndian) {
return object->deSerialize(buffer, size, bigEndian); return object->deSerialize(buffer, size, bigEndian);
} }

View File

@ -41,7 +41,7 @@ public:
return SerializeAdapter<T>::getSerializedSize(&entry); return SerializeAdapter<T>::getSerializedSize(&entry);
} }
virtual ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size, virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian) { bool bigEndian) {
return SerializeAdapter<T>::deSerialize(&entry, buffer, size, bigEndian); return SerializeAdapter<T>::deSerialize(&entry, buffer, size, bigEndian);
} }

View File

@ -47,7 +47,7 @@ public:
virtual size_t getSerializedSize() const = 0; virtual size_t getSerializedSize() const = 0;
virtual ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size, virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian) = 0; bool bigEndian) = 0;
}; };

View File

@ -144,7 +144,8 @@ public:
* @li RETURN_FAILED if data could not be added. * @li RETURN_FAILED if data could not be added.
* storageId is unchanged then. * storageId is unchanged then.
*/ */
virtual ReturnValue_t getFreeElement(store_address_t* storageId, const uint32_t size, uint8_t** p_data, bool ignoreFault = false ) = 0; virtual ReturnValue_t getFreeElement(store_address_t* storageId,
const uint32_t size, uint8_t** p_data, bool ignoreFault = false ) = 0;
/** /**
* Clears the whole store. * Clears the whole store.
* Use with care! * Use with care!

View File

@ -168,7 +168,7 @@ ReturnValue_t Subsystem::handleCommandMessage(CommandMessage* message) {
&sizeRead); &sizeRead);
if (result == RETURN_OK) { if (result == RETURN_OK) {
Mode_t fallbackId; Mode_t fallbackId;
ssize_t size = sizeRead; size_t size = sizeRead;
result = SerializeAdapter<Mode_t>::deSerialize(&fallbackId, result = SerializeAdapter<Mode_t>::deSerialize(&fallbackId,
&pointer, &size, true); &pointer, &size, true);
if (result == RETURN_OK) { if (result == RETURN_OK) {
@ -193,7 +193,7 @@ ReturnValue_t Subsystem::handleCommandMessage(CommandMessage* message) {
ModeSequenceMessage::getStoreAddress(message), &pointer, ModeSequenceMessage::getStoreAddress(message), &pointer,
&sizeRead); &sizeRead);
if (result == RETURN_OK) { if (result == RETURN_OK) {
ssize_t size = sizeRead; size_t size = sizeRead;
result = SerialArrayListAdapter<ModeListEntry>::deSerialize(&table, result = SerialArrayListAdapter<ModeListEntry>::deSerialize(&table,
&pointer, &size, true); &pointer, &size, true);
if (result == RETURN_OK) { if (result == RETURN_OK) {

View File

@ -53,7 +53,7 @@ public:
return sizeof(value1) + sizeof(value2) + sizeof(value3) + sizeof(value4); return sizeof(value1) + sizeof(value2) + sizeof(value3) + sizeof(value4);
} }
virtual ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size, virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian) { bool bigEndian) {
ReturnValue_t result; ReturnValue_t result;

View File

@ -157,7 +157,7 @@ ReturnValue_t UnitTestClass::test_autoserialization() {
// Unit Test AutoSerializeAdapter serialize // Unit Test AutoSerializeAdapter serialize
current_id = TestIds::AUTO_SERIALIZATION_DESERIALIZE; current_id = TestIds::AUTO_SERIALIZATION_DESERIALIZE;
p_array = test_array.data(); p_array = test_array.data();
ssize_t remaining_size = serialized_size; size_t remaining_size = serialized_size;
AutoSerializeAdapter::deSerialize(&test_value_bool, AutoSerializeAdapter::deSerialize(&test_value_bool,
const_cast<const uint8_t**>(&p_array), &remaining_size, false); const_cast<const uint8_t**>(&p_array), &remaining_size, false);
AutoSerializeAdapter::deSerialize(&tv_uint8, AutoSerializeAdapter::deSerialize(&tv_uint8,
@ -197,6 +197,8 @@ ReturnValue_t UnitTestClass::test_autoserialization() {
abs(tv_sdouble - (-2.2421e19)) > 0.01) { abs(tv_sdouble - (-2.2421e19)) > 0.01) {
return put_error(current_id); return put_error(current_id);
} }
// Check overflow
return RETURN_OK; return RETURN_OK;
} }
@ -285,9 +287,16 @@ ReturnValue_t UnitTestClass::test_serial_buffer_adapter() {
return RETURN_OK; return RETURN_OK;
} }
ReturnValue_t UnitTestClass::put_error(TestIds current_id) { ReturnValue_t UnitTestClass::put_error(TestIds currentId) {
auto errorIter = testResultMap.find(currentId);
if(errorIter != testResultMap.end()) {
testResultMap.emplace(currentId, 1);
}
else {
errorIter->second ++;
}
error << "Unit Tester failed at test ID " error << "Unit Tester failed at test ID "
<< static_cast<uint32_t>(current_id) << "\r\n" << std::flush; << static_cast<uint32_t>(currentId) << "\r\n" << std::flush;
return RETURN_FAILED; return RETURN_FAILED;
} }

View File

@ -56,7 +56,8 @@ private:
TestIds current_id = TestIds::MISC; TestIds current_id = TestIds::MISC;
std::array<uint8_t, 512> test_array; std::array<uint8_t, 512> test_array;
using TestResultMap = std::map<uint32_t, ReturnValue_t>; using error_count_t = uint8_t;
using TestResultMap = std::map<TestIds, error_count_t>;
using TestBuffer = std::vector<uint8_t>; using TestBuffer = std::vector<uint8_t>;
TestResultMap testResultMap; TestResultMap testResultMap;

View File

@ -40,11 +40,11 @@ ReturnValue_t ThermalComponent::setTargetState(int8_t newState) {
} }
} }
ReturnValue_t ThermalComponent::setLimits(const uint8_t* data, ssize_t size) { ReturnValue_t ThermalComponent::setLimits(const uint8_t* data, size_t size) {
if (size != 4 * sizeof(parameters.lowerOpLimit)) { if (size != 4 * sizeof(parameters.lowerOpLimit)) {
return MonitoringIF::INVALID_SIZE; return MonitoringIF::INVALID_SIZE;
} }
ssize_t readSize = size; size_t readSize = size;
SerializeAdapter<float>::deSerialize(&nopParameters.lowerNopLimit, &data, SerializeAdapter<float>::deSerialize(&nopParameters.lowerNopLimit, &data,
&readSize, true); &readSize, true);
SerializeAdapter<float>::deSerialize(&parameters.lowerOpLimit, &data, SerializeAdapter<float>::deSerialize(&parameters.lowerOpLimit, &data,

View File

@ -53,7 +53,7 @@ public:
ReturnValue_t setTargetState(int8_t newState); ReturnValue_t setTargetState(int8_t newState);
virtual ReturnValue_t setLimits( const uint8_t* data, ssize_t size); virtual ReturnValue_t setLimits( const uint8_t* data, size_t size);
virtual ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId, virtual ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId,
ParameterWrapper *parameterWrapper, ParameterWrapper *parameterWrapper,

View File

@ -48,7 +48,7 @@ public:
return sizeof(apid) + sizeof(ssc); return sizeof(apid) + sizeof(ssc);
} }
ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size, ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian) { bool bigEndian) {
ReturnValue_t result = SerializeAdapter<uint16_t>::deSerialize(&apid, ReturnValue_t result = SerializeAdapter<uint16_t>::deSerialize(&apid,
buffer, size, bigEndian); buffer, size, bigEndian);
@ -257,7 +257,7 @@ public:
}; };
ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size, ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian) { bool bigEndian) {
ReturnValue_t result = AutoSerializeAdapter::deSerialize(&apid, buffer, ReturnValue_t result = AutoSerializeAdapter::deSerialize(&apid, buffer,
size, bigEndian); size, bigEndian);

View File

@ -30,9 +30,10 @@ public:
size_t getSerializedSize() const { size_t getSerializedSize() const {
return SerializeAdapter<uint16_t>::getSerializedSize(&apid); return SerializeAdapter<uint16_t>::getSerializedSize(&apid);
} }
ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size, ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian) { bool bigEndian) {
return SerializeAdapter<uint16_t>::deSerialize(&apid, buffer, size, bigEndian); return SerializeAdapter<uint16_t>::deSerialize(&apid, buffer,
size, bigEndian);
} }
}; };

View File

@ -30,9 +30,10 @@ public:
size_t getSerializedSize() const { size_t getSerializedSize() const {
return SerializeAdapter<uint8_t>::getSerializedSize(&service); return SerializeAdapter<uint8_t>::getSerializedSize(&service);
} }
ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size, ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian) { bool bigEndian) {
return SerializeAdapter<uint8_t>::deSerialize(&service, buffer, size, bigEndian); return SerializeAdapter<uint8_t>::deSerialize(&service, buffer,
size, bigEndian);
} }
}; };

View File

@ -28,9 +28,10 @@ public:
size_t getSerializedSize() const { size_t getSerializedSize() const {
return SerializeAdapter<uint8_t>::getSerializedSize(&subService); return SerializeAdapter<uint8_t>::getSerializedSize(&subService);
} }
ReturnValue_t deSerialize(const uint8_t** buffer, ssize_t* size, ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian) { bool bigEndian) {
return SerializeAdapter<uint8_t>::deSerialize(&subService, buffer, size, bigEndian); return SerializeAdapter<uint8_t>::deSerialize(&subService, buffer,
size, bigEndian);
} }
private: private:
uint8_t subService; uint8_t subService;

View File

@ -28,7 +28,7 @@ const uint8_t* TcPacketBase::getApplicationData() const {
return &tcData->data; return &tcData->data;
} }
uint16_t TcPacketBase::getApplicationDataSize() { size_t TcPacketBase::getApplicationDataSize() {
return getPacketDataLength() - sizeof(tcData->data_field) - CRC_SIZE + 1; return getPacketDataLength() - sizeof(tcData->data_field) - CRC_SIZE + 1;
} }

View File

@ -151,7 +151,7 @@ public:
* @return The size of the PUS Application Data (without Error Control * @return The size of the PUS Application Data (without Error Control
* field) * field)
*/ */
uint16_t getApplicationDataSize(); size_t getApplicationDataSize();
/** /**
* This getter returns the Error Control Field of the packet. * This getter returns the Error Control Field of the packet.
* *