working on updating SerializeIF, to quote Basti: This is going to be horrible

This commit is contained in:
Ulrich Mohr 2020-04-21 21:34:03 +02:00
parent 05c1330b68
commit 2093329481
35 changed files with 389 additions and 341 deletions

View File

@ -150,13 +150,13 @@ public:
virtual ReturnValue_t serialize(uint8_t** buffer, uint32_t* size, virtual ReturnValue_t serialize(uint8_t** buffer, uint32_t* size,
const uint32_t max_size, bool bigEndian) const { const uint32_t max_size, bool bigEndian) const {
ReturnValue_t result = SerializeAdapter<uint32_t>::serialize(&this->_size, ReturnValue_t result = SerializeAdapter::serialize(&this->_size,
buffer, size, max_size, bigEndian); buffer, size, max_size, bigEndian);
uint32_t i = 0; uint32_t i = 0;
while ((result == HasReturnvaluesIF::RETURN_OK) && (i < this->_size)) { while ((result == HasReturnvaluesIF::RETURN_OK) && (i < this->_size)) {
result = SerializeAdapter<key_t>::serialize(&theMap[i].first, buffer, result = SerializeAdapter::serialize(&theMap[i].first, buffer,
size, max_size, bigEndian); size, max_size, bigEndian);
result = SerializeAdapter<T>::serialize(&theMap[i].second, buffer, size, result = SerializeAdapter::serialize(&theMap[i].second, buffer, size,
max_size, bigEndian); max_size, bigEndian);
++i; ++i;
} }
@ -168,9 +168,9 @@ public:
uint32_t i = 0; uint32_t i = 0;
for (i = 0; i < _size; ++i) { for (i = 0; i < _size; ++i) {
printSize += SerializeAdapter<key_t>::getSerializedSize( printSize += SerializeAdapter::getSerializedSize(
&theMap[i].first); &theMap[i].first);
printSize += SerializeAdapter<T>::getSerializedSize(&theMap[i].second); printSize += SerializeAdapter::getSerializedSize(&theMap[i].second);
} }
return printSize; return printSize;
@ -178,16 +178,16 @@ public:
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size, virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
bool bigEndian) { bool bigEndian) {
ReturnValue_t result = SerializeAdapter<uint32_t>::deSerialize(&this->_size, ReturnValue_t result = SerializeAdapter::deSerialize(&this->_size,
buffer, size, bigEndian); buffer, size, bigEndian);
if (this->_size > theMap.maxSize()) { if (this->_size > theMap.maxSize()) {
return SerializeIF::TOO_MANY_ELEMENTS; return SerializeIF::TOO_MANY_ELEMENTS;
} }
uint32_t i = 0; uint32_t i = 0;
while ((result == HasReturnvaluesIF::RETURN_OK) && (i < this->_size)) { while ((result == HasReturnvaluesIF::RETURN_OK) && (i < this->_size)) {
result = SerializeAdapter<key_t>::deSerialize(&theMap[i].first, buffer, result = SerializeAdapter::deSerialize(&theMap[i].first, buffer,
size, bigEndian); size, bigEndian);
result = SerializeAdapter<T>::deSerialize(&theMap[i].second, buffer, size, result = SerializeAdapter::deSerialize(&theMap[i].second, buffer, size,
bigEndian); bigEndian);
++i; ++i;
} }

View File

@ -70,7 +70,7 @@ public:
ReturnValue_t serialize(uint8_t** buffer, uint32_t* size, ReturnValue_t serialize(uint8_t** buffer, uint32_t* size,
const uint32_t max_size, bool bigEndian) const { const uint32_t max_size, bool bigEndian) const {
ReturnValue_t result = AutoSerializeAdapter::serialize(&blockStartAddress,buffer,size,max_size,bigEndian); ReturnValue_t result = SerializeAdapter::serialize(&blockStartAddress,buffer,size,max_size,bigEndian);
if(result != HasReturnvaluesIF::RETURN_OK){ if(result != HasReturnvaluesIF::RETURN_OK){
return result; return result;
} }
@ -78,17 +78,17 @@ public:
if(result != HasReturnvaluesIF::RETURN_OK){ if(result != HasReturnvaluesIF::RETURN_OK){
return result; return result;
} }
result = AutoSerializeAdapter::serialize(&this->size,buffer,size,max_size,bigEndian); result = SerializeAdapter::serialize(&this->size,buffer,size,max_size,bigEndian);
if(result != HasReturnvaluesIF::RETURN_OK){ if(result != HasReturnvaluesIF::RETURN_OK){
return result; return result;
} }
result = AutoSerializeAdapter::serialize(&this->storedPackets,buffer,size,max_size,bigEndian); result = SerializeAdapter::serialize(&this->storedPackets,buffer,size,max_size,bigEndian);
return result; return result;
} }
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size, ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
bool bigEndian){ bool bigEndian){
ReturnValue_t result = AutoSerializeAdapter::deSerialize(&blockStartAddress,buffer,size,bigEndian); ReturnValue_t result = SerializeAdapter::deSerialize(&blockStartAddress,buffer,size,bigEndian);
if(result != HasReturnvaluesIF::RETURN_OK){ if(result != HasReturnvaluesIF::RETURN_OK){
return result; return result;
} }
@ -96,11 +96,11 @@ public:
if(result != HasReturnvaluesIF::RETURN_OK){ if(result != HasReturnvaluesIF::RETURN_OK){
return result; return result;
} }
result = AutoSerializeAdapter::deSerialize(&this->size,buffer,size,bigEndian); result = SerializeAdapter::deSerialize(&this->size,buffer,size,bigEndian);
if(result != HasReturnvaluesIF::RETURN_OK){ if(result != HasReturnvaluesIF::RETURN_OK){
return result; return result;
} }
result = AutoSerializeAdapter::deSerialize(&this->storedPackets,buffer,size,bigEndian); result = SerializeAdapter::deSerialize(&this->storedPackets,buffer,size,bigEndian);
if(result != HasReturnvaluesIF::RETURN_OK){ if(result != HasReturnvaluesIF::RETURN_OK){
return result; return result;
} }
@ -108,10 +108,10 @@ public:
} }
uint32_t getSerializedSize() const { uint32_t getSerializedSize() const {
uint32_t size = AutoSerializeAdapter::getSerializedSize(&blockStartAddress); uint32_t size = SerializeAdapter::getSerializedSize(&blockStartAddress);
size += indexType.getSerializedSize(); size += indexType.getSerializedSize();
size += AutoSerializeAdapter::getSerializedSize(&this->size); size += SerializeAdapter::getSerializedSize(&this->size);
size += AutoSerializeAdapter::getSerializedSize(&this->storedPackets); size += SerializeAdapter::getSerializedSize(&this->storedPackets);
return size; return size;
} }
@ -500,14 +500,14 @@ public:
if(result != HasReturnvaluesIF::RETURN_OK){ if(result != HasReturnvaluesIF::RETURN_OK){
return result; return result;
} }
result = AutoSerializeAdapter::serialize(&this->size,buffer,size,max_size,bigEndian); result = SerializeAdapter::serialize(&this->size,buffer,size,max_size,bigEndian);
if(result != HasReturnvaluesIF::RETURN_OK){ if(result != HasReturnvaluesIF::RETURN_OK){
return result; return result;
} }
uint32_t i = 0; uint32_t i = 0;
while ((result == HasReturnvaluesIF::RETURN_OK) && (i < this->size)) { while ((result == HasReturnvaluesIF::RETURN_OK) && (i < this->size)) {
result = SerializeAdapter<Index<T> >::serialize(&this->entries[i], buffer, size, result = SerializeAdapter::serialize(&this->entries[i], buffer, size,
max_size, bigEndian); max_size, bigEndian);
++i; ++i;
} }
@ -515,7 +515,7 @@ public:
return result; return result;
} }
uint16_t crc = Calculate_CRC(crcBuffer,(*size-oldSize)); uint16_t crc = Calculate_CRC(crcBuffer,(*size-oldSize));
result = AutoSerializeAdapter::serialize(&crc,buffer,size,max_size,bigEndian); result = SerializeAdapter::serialize(&crc,buffer,size,max_size,bigEndian);
return result; return result;
} }
@ -531,10 +531,10 @@ public:
size += additionalInfo->getSerializedSize(); size += additionalInfo->getSerializedSize();
} }
size += currentWriteBlock->getSerializedSize(); size += currentWriteBlock->getSerializedSize();
size += AutoSerializeAdapter::getSerializedSize(&this->size); size += SerializeAdapter::getSerializedSize(&this->size);
size += (this->entries[0].getSerializedSize()) * this->size; size += (this->entries[0].getSerializedSize()) * this->size;
uint16_t crc = 0; uint16_t crc = 0;
size += AutoSerializeAdapter::getSerializedSize(&crc); size += SerializeAdapter::getSerializedSize(&crc);
return size; return size;
} }
/** /**
@ -563,7 +563,7 @@ public:
return result; return result;
} }
uint32_t tempSize = 0; uint32_t tempSize = 0;
result = AutoSerializeAdapter::deSerialize(&tempSize,buffer,size,bigEndian); result = SerializeAdapter::deSerialize(&tempSize,buffer,size,bigEndian);
if(result != HasReturnvaluesIF::RETURN_OK){ if(result != HasReturnvaluesIF::RETURN_OK){
return result; return result;
} }
@ -572,7 +572,7 @@ public:
} }
uint32_t i = 0; uint32_t i = 0;
while ((result == HasReturnvaluesIF::RETURN_OK) && (i < this->size)) { while ((result == HasReturnvaluesIF::RETURN_OK) && (i < this->size)) {
result = SerializeAdapter<Index<T> >::deSerialize( result = SerializeAdapter::deSerialize(
&this->entries[i], buffer, size, &this->entries[i], buffer, size,
bigEndian); bigEndian);
++i; ++i;

View File

@ -39,18 +39,18 @@ ReturnValue_t DataPoolParameterWrapper::serialize(uint8_t** buffer,
uint32_t* size, const uint32_t max_size, bool bigEndian) const { uint32_t* size, const uint32_t max_size, bool bigEndian) const {
ReturnValue_t result; ReturnValue_t result;
result = SerializeAdapter<Type>::serialize(&type, buffer, size, max_size, result = SerializeAdapter::serialize(&type, buffer, size, max_size,
bigEndian); bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
result = SerializeAdapter<uint8_t>::serialize(&columns, buffer, size, result = SerializeAdapter::serialize(&columns, buffer, size,
max_size, bigEndian); max_size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
result = SerializeAdapter<uint8_t>::serialize(&rows, buffer, size, max_size, result = SerializeAdapter::serialize(&rows, buffer, size, max_size,
bigEndian); bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;

View File

@ -17,7 +17,7 @@ protected:
uint8_t valid; uint8_t valid;
ReturnValue_t read() { ReturnValue_t read() {
uint8_t arrayIndex = DataPool::PIDToArrayIndex(parameterId); uint8_t arrayIndex = DataPool::PIDToArrayIndex(parameterId);
PoolEntry<T>* read_out = ::dataPool.getData<T>( PoolEntry<T> *read_out = ::dataPool.getData<T>(
DataPool::PIDToDataPoolId(parameterId), arrayIndex); DataPool::PIDToDataPoolId(parameterId), arrayIndex);
if (read_out != NULL) { if (read_out != NULL) {
valid = read_out->valid; valid = read_out->valid;
@ -43,7 +43,8 @@ protected:
* Empty ctor for List initialization * Empty ctor for List initialization
*/ */
PIDReader() : PIDReader() :
parameterId(PoolVariableIF::NO_PARAMETER), valid(PoolVariableIF::INVALID), value(0) { parameterId(PoolVariableIF::NO_PARAMETER), valid(
PoolVariableIF::INVALID), value(0) {
} }
public: public:
@ -63,9 +64,9 @@ public:
* \param setWritable If this flag is set to true, changes in the value attribute can be * \param setWritable If this flag is set to true, changes in the value attribute can be
* written back to the data pool, otherwise not. * written back to the data pool, otherwise not.
*/ */
PIDReader(uint32_t setParameterId, DataSetIF* dataSet) : PIDReader(uint32_t setParameterId, DataSetIF *dataSet) :
parameterId(setParameterId), valid( parameterId(setParameterId), valid(PoolVariableIF::INVALID), value(
PoolVariableIF::INVALID), value(0) { 0) {
if (dataSet != NULL) { if (dataSet != NULL) {
dataSet->registerVariable(this); dataSet->registerVariable(this);
} }
@ -74,7 +75,7 @@ public:
/** /**
* Copy ctor to copy classes containing Pool Variables. * Copy ctor to copy classes containing Pool Variables.
*/ */
PIDReader(const PIDReader& rhs) : PIDReader(const PIDReader &rhs) :
parameterId(rhs.parameterId), valid(rhs.valid), value(rhs.value) { parameterId(rhs.parameterId), valid(rhs.valid), value(rhs.value) {
} }
@ -121,24 +122,25 @@ public:
return value; return value;
} }
PIDReader<T> &operator=(T newValue) { PIDReader<T>& operator=(T newValue) {
value = newValue; value = newValue;
return *this; return *this;
} }
virtual ReturnValue_t serialize(uint8_t** buffer, uint32_t* size, virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size,
const uint32_t max_size, bool bigEndian) const { size_t maxSize, Endianness streamEndianness) const override {
return SerializeAdapter<T>::serialize(&value, buffer, size, max_size, return SerializeAdapter::serialize(&value, buffer, size, maxSize,
bigEndian); streamEndianness);
} }
virtual uint32_t getSerializedSize() const { virtual size_t getSerializedSize() const override {
return SerializeAdapter<T>::getSerializedSize(&value); return SerializeAdapter::getSerializedSize(&value);
} }
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size, virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
bool bigEndian) { Endianness streamEndianness) override {
return SerializeAdapter<T>::deSerialize(&value, buffer, size, bigEndian); return SerializeAdapter::deSerialize(&value, buffer, size,
streamEndianness);
} }
}; };

View File

@ -145,10 +145,12 @@ uint16_t PoolRawAccess::getSizeTillEnd() const {
return sizeTillEnd; return sizeTillEnd;
} }
ReturnValue_t PoolRawAccess::serialize(uint8_t** buffer, uint32_t* size, ReturnValue_t PoolRawAccess::serialize(uint8_t** buffer, size_t* size,
const uint32_t max_size, bool bigEndian) const { size_t maxSize, Endianness streamEndianness) const {
if (typeSize + *size <= max_size) { //TODO integer overflow
if (bigEndian) { if (typeSize + *size <= maxSize) {
#error use endian swapper
if (1) {
#ifndef BYTE_ORDER_SYSTEM #ifndef BYTE_ORDER_SYSTEM
#error BYTE_ORDER_SYSTEM not defined #error BYTE_ORDER_SYSTEM not defined
#elif BYTE_ORDER_SYSTEM == LITTLE_ENDIAN #elif BYTE_ORDER_SYSTEM == LITTLE_ENDIAN
@ -169,16 +171,16 @@ ReturnValue_t PoolRawAccess::serialize(uint8_t** buffer, uint32_t* size,
} }
} }
uint32_t PoolRawAccess::getSerializedSize() const { size_t PoolRawAccess::getSerializedSize() const {
return typeSize; return typeSize;
} }
ReturnValue_t PoolRawAccess::deSerialize(const uint8_t** buffer, int32_t* size, ReturnValue_t PoolRawAccess::deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian) { Endianness streamEndianness) {
*size -= typeSize;
if (*size >= 0) {
if (bigEndian) { if (*size >= typeSize) {
*size -= typeSize;
if (1) {
#ifndef BYTE_ORDER_SYSTEM #ifndef BYTE_ORDER_SYSTEM
#error BYTE_ORDER_SYSTEM not defined #error BYTE_ORDER_SYSTEM not defined
#elif BYTE_ORDER_SYSTEM == LITTLE_ENDIAN #elif BYTE_ORDER_SYSTEM == LITTLE_ENDIAN

View File

@ -70,7 +70,7 @@ public:
static const ReturnValue_t DATA_POOL_ACCESS_FAILED = MAKE_RETURN_CODE(0x02); static const ReturnValue_t DATA_POOL_ACCESS_FAILED = MAKE_RETURN_CODE(0x02);
uint8_t value[RAW_MAX_SIZE]; uint8_t value[RAW_MAX_SIZE];
PoolRawAccess(uint32_t data_pool_id, uint8_t arrayEntry, PoolRawAccess(uint32_t data_pool_id, uint8_t arrayEntry,
DataSetIF* data_set, ReadWriteMode_t setReadWriteMode = DataSetIF *data_set, ReadWriteMode_t setReadWriteMode =
PoolVariableIF::VAR_READ); PoolVariableIF::VAR_READ);
/** /**
* \brief The classes destructor is empty. If commit() was not called, the local value is * \brief The classes destructor is empty. If commit() was not called, the local value is
@ -97,7 +97,7 @@ public:
* \return - \c RETURN_OK if entry could be acquired * \return - \c RETURN_OK if entry could be acquired
* - \c RETURN_FAILED else. * - \c RETURN_FAILED else.
*/ */
ReturnValue_t getEntryEndianSafe(uint8_t* buffer, uint32_t* size, ReturnValue_t getEntryEndianSafe(uint8_t *buffer, uint32_t *size,
uint32_t max_size); uint32_t max_size);
/** /**
* With this method, the content can be set from a big endian buffer safely. * With this method, the content can be set from a big endian buffer safely.
@ -106,7 +106,7 @@ public:
* @return - \c RETURN_OK on success * @return - \c RETURN_OK on success
* - \c RETURN_FAILED on failure * - \c RETURN_FAILED on failure
*/ */
ReturnValue_t setEntryFromBigEndian(const uint8_t* buffer, ReturnValue_t setEntryFromBigEndian(const uint8_t *buffer,
uint32_t setSize); uint32_t setSize);
/** /**
* \brief This operation returns the type of the entry currently stored. * \brief This operation returns the type of the entry currently stored.
@ -140,13 +140,13 @@ public:
*/ */
uint16_t getSizeTillEnd() const; uint16_t getSizeTillEnd() const;
ReturnValue_t serialize(uint8_t** buffer, uint32_t* size, ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
const uint32_t max_size, bool bigEndian) const; Endianness streamEndianness) const override;
uint32_t getSerializedSize() const; size_t getSerializedSize() const override;
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size, ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
bool bigEndian); Endianness streamEndianness) override;
}; };
#endif /* POOLRAWACCESS_H_ */ #endif /* POOLRAWACCESS_H_ */

View File

@ -58,7 +58,7 @@ protected:
* The operation does NOT provide any mutual exclusive protection by itself. * The operation does NOT provide any mutual exclusive protection by itself.
*/ */
ReturnValue_t read() { ReturnValue_t read() {
PoolEntry<T>* read_out = ::dataPool.getData<T>(dataPoolId, 1); PoolEntry<T> *read_out = ::dataPool.getData < T > (dataPoolId, 1);
if (read_out != NULL) { if (read_out != NULL) {
valid = read_out->valid; valid = read_out->valid;
value = *(read_out->address); value = *(read_out->address);
@ -79,7 +79,7 @@ protected:
* *
*/ */
ReturnValue_t commit() { ReturnValue_t commit() {
PoolEntry<T>* write_back = ::dataPool.getData<T>(dataPoolId, 1); PoolEntry<T> *write_back = ::dataPool.getData < T > (dataPoolId, 1);
if ((write_back != NULL) && (readWriteMode != VAR_READ)) { if ((write_back != NULL) && (readWriteMode != VAR_READ)) {
write_back->valid = valid; write_back->valid = valid;
*(write_back->address) = value; *(write_back->address) = value;
@ -115,7 +115,7 @@ public:
* \param setWritable If this flag is set to true, changes in the value attribute can be * \param setWritable If this flag is set to true, changes in the value attribute can be
* written back to the data pool, otherwise not. * written back to the data pool, otherwise not.
*/ */
PoolVariable(uint32_t set_id, DataSetIF* dataSet, PoolVariable(uint32_t set_id, DataSetIF *dataSet,
ReadWriteMode_t setReadWriteMode) : ReadWriteMode_t setReadWriteMode) :
dataPoolId(set_id), valid(PoolVariableIF::INVALID), readWriteMode( dataPoolId(set_id), valid(PoolVariableIF::INVALID), readWriteMode(
setReadWriteMode), value(0) { setReadWriteMode), value(0) {
@ -126,7 +126,7 @@ public:
/** /**
* Copy ctor to copy classes containing Pool Variables. * Copy ctor to copy classes containing Pool Variables.
*/ */
PoolVariable(const PoolVariable& rhs) : PoolVariable(const PoolVariable &rhs) :
dataPoolId(rhs.dataPoolId), valid(rhs.valid), readWriteMode( dataPoolId(rhs.dataPoolId), valid(rhs.valid), readWriteMode(
rhs.readWriteMode), value(rhs.value) { rhs.readWriteMode), value(rhs.value) {
} }
@ -184,29 +184,29 @@ public:
return value; return value;
} }
PoolVariable<T> &operator=(T newValue) { PoolVariable<T>& operator=(T newValue) {
value = newValue; value = newValue;
return *this; return *this;
} }
PoolVariable<T> &operator=(PoolVariable<T> newPoolVariable) { PoolVariable<T>& operator=(PoolVariable<T> newPoolVariable) {
value = newPoolVariable.value; value = newPoolVariable.value;
return *this; return *this;
} }
virtual ReturnValue_t serialize(uint8_t** buffer, uint32_t* size, virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size,
const uint32_t max_size, bool bigEndian) const { size_t max_size, Endianness streamEndianness) const override {
return SerializeAdapter<T>::serialize(&value, buffer, size, max_size, return SerializeAdapter::serialize<T>(&value, buffer, size, max_size,
bigEndian); streamEndianness);
} }
virtual uint32_t getSerializedSize() const { virtual uint32_t getSerializedSize() const override {
return SerializeAdapter<T>::getSerializedSize(&value); return SerializeAdapter::getSerializedSize(&value);
} }
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size, virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
bool bigEndian) { Endianness streamEndianness) override {
return SerializeAdapter<T>::deSerialize(&value, buffer, size, bigEndian); return SerializeAdapter::deSerialize(&value, buffer, size, streamEndianness);
} }
}; };

View File

@ -202,7 +202,7 @@ public:
uint16_t i; uint16_t i;
ReturnValue_t result; ReturnValue_t result;
for (i = 0; i < vector_size; i++) { for (i = 0; i < vector_size; i++) {
result = SerializeAdapter<T>::serialize(&(value[i]), buffer, size, result = SerializeAdapter::serialize(&(value[i]), buffer, size,
max_size, bigEndian); max_size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
@ -212,7 +212,7 @@ public:
} }
virtual uint32_t getSerializedSize() const { virtual uint32_t getSerializedSize() const {
return vector_size * SerializeAdapter<T>::getSerializedSize(value); return vector_size * SerializeAdapter::getSerializedSize(value);
} }
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size, virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
@ -220,7 +220,7 @@ public:
uint16_t i; uint16_t i;
ReturnValue_t result; ReturnValue_t result;
for (i = 0; i < vector_size; i++) { for (i = 0; i < vector_size; i++) {
result = SerializeAdapter<T>::deSerialize(&(value[i]), buffer, size, result = SerializeAdapter::deSerialize(&(value[i]), buffer, size,
bigEndian); bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;

View File

@ -13,12 +13,12 @@ DeviceTmReportingWrapper::~DeviceTmReportingWrapper() {
ReturnValue_t DeviceTmReportingWrapper::serialize(uint8_t** buffer, ReturnValue_t DeviceTmReportingWrapper::serialize(uint8_t** buffer,
uint32_t* size, const uint32_t max_size, bool bigEndian) const { uint32_t* size, const uint32_t max_size, bool bigEndian) const {
ReturnValue_t result = SerializeAdapter<object_id_t>::serialize(&objectId, ReturnValue_t result = SerializeAdapter::serialize(&objectId,
buffer, size, max_size, bigEndian); buffer, size, max_size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
result = SerializeAdapter<ActionId_t>::serialize(&actionId, buffer, result = SerializeAdapter::serialize(&actionId, buffer,
size, max_size, bigEndian); size, max_size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
@ -32,12 +32,12 @@ uint32_t DeviceTmReportingWrapper::getSerializedSize() const {
ReturnValue_t DeviceTmReportingWrapper::deSerialize(const uint8_t** buffer, ReturnValue_t DeviceTmReportingWrapper::deSerialize(const uint8_t** buffer,
int32_t* size, bool bigEndian) { int32_t* size, bool bigEndian) {
ReturnValue_t result = SerializeAdapter<object_id_t>::deSerialize(&objectId, ReturnValue_t result = SerializeAdapter::deSerialize(&objectId,
buffer, size, bigEndian); buffer, size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
result = SerializeAdapter<ActionId_t>::deSerialize(&actionId, buffer, result = SerializeAdapter::deSerialize(&actionId, buffer,
size, bigEndian); size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;

View File

@ -68,13 +68,13 @@ ReturnValue_t Type::serialize(uint8_t** buffer, uint32_t* size,
return result; return result;
} }
result = SerializeAdapter<uint8_t>::serialize(&ptc, buffer, size, max_size, result = SerializeAdapter::serialize(&ptc, buffer, size, max_size,
bigEndian); bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
result = SerializeAdapter<uint8_t>::serialize(&pfc, buffer, size, max_size, result = SerializeAdapter::serialize(&pfc, buffer, size, max_size,
bigEndian); bigEndian);
return result; return result;
@ -83,20 +83,20 @@ ReturnValue_t Type::serialize(uint8_t** buffer, uint32_t* size,
uint32_t Type::getSerializedSize() const { uint32_t Type::getSerializedSize() const {
uint8_t dontcare = 0; uint8_t dontcare = 0;
return 2 * SerializeAdapter<uint8_t>::getSerializedSize(&dontcare); return 2 * SerializeAdapter::getSerializedSize(&dontcare);
} }
ReturnValue_t Type::deSerialize(const uint8_t** buffer, int32_t* size, ReturnValue_t Type::deSerialize(const uint8_t** buffer, int32_t* size,
bool bigEndian) { bool bigEndian) {
uint8_t ptc; uint8_t ptc;
uint8_t pfc; uint8_t pfc;
ReturnValue_t result = SerializeAdapter<uint8_t>::deSerialize(&ptc, buffer, ReturnValue_t result = SerializeAdapter::deSerialize(&ptc, buffer,
size, bigEndian); size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
result = SerializeAdapter<uint8_t>::deSerialize(&pfc, buffer, size, result = SerializeAdapter::deSerialize(&pfc, buffer, size,
bigEndian); bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;

View File

@ -22,7 +22,7 @@ public:
Type(ActualType_t actualType); Type(ActualType_t actualType);
Type(const Type& type); Type(const Type &type);
Type& operator=(Type rhs); Type& operator=(Type rhs);
@ -30,8 +30,8 @@ public:
operator ActualType_t() const; operator ActualType_t() const;
bool operator==(const Type& rhs); bool operator==(const Type &rhs);
bool operator!=(const Type& rhs); bool operator!=(const Type &rhs);
uint8_t getSize() const; uint8_t getSize() const;
@ -39,13 +39,13 @@ public:
static ActualType_t getActualType(uint8_t ptc, uint8_t pfc); static ActualType_t getActualType(uint8_t ptc, uint8_t pfc);
virtual ReturnValue_t serialize(uint8_t** buffer, uint32_t* size, virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size,
const uint32_t max_size, bool bigEndian) const; size_t maxSize, Endianness streamEndianness) const override;
virtual uint32_t getSerializedSize() const; virtual size_t getSerializedSize() const override;
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size, virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
bool bigEndian); Endianness streamEndianness) override;
private: private:
ActualType_t actualType; ActualType_t actualType;

View File

@ -49,7 +49,7 @@ public:
const uint32_t max_size, bool bigEndian) const { const uint32_t max_size, bool bigEndian) const {
iterator iter = this->begin(); iterator iter = this->begin();
uint8_t count = this->countRight(iter); uint8_t count = this->countRight(iter);
ReturnValue_t result = SerializeAdapter<uint8_t>::serialize(&count, ReturnValue_t result = SerializeAdapter::serialize(&count,
buffer, size, max_size, bigEndian); buffer, size, max_size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;

View File

@ -4,7 +4,6 @@
#include <framework/globalfunctions/matching/SerializeableMatcherIF.h> #include <framework/globalfunctions/matching/SerializeableMatcherIF.h>
#include <framework/serialize/SerializeAdapter.h> #include <framework/serialize/SerializeAdapter.h>
template<typename T> template<typename T>
class RangeMatcher: public SerializeableMatcherIF<T> { class RangeMatcher: public SerializeableMatcherIF<T> {
public: public:
@ -27,34 +26,40 @@ public:
} }
} }
ReturnValue_t serialize(uint8_t** buffer, uint32_t* size, ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t max_size,
const uint32_t max_size, bool bigEndian) const { SerializeIF::Endianness streamEndianness) const override {
ReturnValue_t result = SerializeAdapter<T>::serialize(&lowerBound, buffer, size, max_size, bigEndian); ReturnValue_t result = SerializeAdapter::serialize(&lowerBound, buffer,
size, max_size, streamEndianness);
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::serialize(&upperBound, buffer, size,
max_size, streamEndianness);
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::serialize(&inverted, buffer, size, max_size,
streamEndianness);
} }
uint32_t getSerializedSize() const { uint32_t getSerializedSize() const override {
return sizeof(lowerBound) + sizeof(upperBound) + sizeof(bool); return sizeof(lowerBound) + sizeof(upperBound) + sizeof(bool);
} }
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size, ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
bool bigEndian) { SerializeIF::Endianness streamEndianness) override {
ReturnValue_t result = SerializeAdapter<T>::deSerialize(&lowerBound, buffer, size, bigEndian); ReturnValue_t result = SerializeAdapter::deSerialize(&lowerBound,
buffer, size, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
result = SerializeAdapter<T>::deSerialize(&upperBound, buffer, size, bigEndian); result = SerializeAdapter::deSerialize(&upperBound, buffer, size,
streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
return SerializeAdapter<bool>::deSerialize(&inverted, buffer, size, bigEndian); return SerializeAdapter::deSerialize(&inverted, buffer, size,
streamEndianness);
} }
protected: protected:
bool doMatch(T input) { bool doMatch(T input) {

View File

@ -67,16 +67,16 @@ void HealthTable::printAll(uint8_t* pointer, uint32_t maxSize) {
mutex->lockMutex(MutexIF::NO_TIMEOUT); mutex->lockMutex(MutexIF::NO_TIMEOUT);
uint32_t size = 0; uint32_t size = 0;
uint16_t count = healthMap.size(); uint16_t count = healthMap.size();
ReturnValue_t result = SerializeAdapter<uint16_t>::serialize(&count, ReturnValue_t result = SerializeAdapter::serialize(&count,
&pointer, &size, maxSize, true); &pointer, &size, maxSize, true);
HealthMap::iterator iter; HealthMap::iterator iter;
for (iter = healthMap.begin(); for (iter = healthMap.begin();
iter != healthMap.end() && result == HasReturnvaluesIF::RETURN_OK; iter != healthMap.end() && result == HasReturnvaluesIF::RETURN_OK;
++iter) { ++iter) {
result = SerializeAdapter<object_id_t>::serialize(&iter->first, result = SerializeAdapter::serialize(&iter->first,
&pointer, &size, maxSize, true); &pointer, &size, maxSize, true);
uint8_t health = iter->second; uint8_t health = iter->second;
result = SerializeAdapter<uint8_t>::serialize(&health, &pointer, &size, result = SerializeAdapter::serialize(&health, &pointer, &size,
maxSize, true); maxSize, true);
} }
mutex->unlockMutex(); mutex->unlockMutex();

View File

@ -53,7 +53,7 @@ void MemoryHelper::completeLoad(ReturnValue_t errorCode,
memcpy(copyHere, dataToCopy, size); memcpy(copyHere, dataToCopy, size);
break; break;
case HasMemoryIF::POINTS_TO_VARIABLE: case HasMemoryIF::POINTS_TO_VARIABLE:
EndianSwapper::swap(copyHere, dataToCopy, size); EndianConverter::convertBigEndian(copyHere, dataToCopy, size);
break; break;
case HasMemoryIF::ACTIVITY_COMPLETED: case HasMemoryIF::ACTIVITY_COMPLETED:
case RETURN_OK: case RETURN_OK:
@ -86,7 +86,7 @@ void MemoryHelper::completeDump(ReturnValue_t errorCode,
case HasMemoryIF::POINTS_TO_VARIABLE: case HasMemoryIF::POINTS_TO_VARIABLE:
//"data" must be valid pointer! //"data" must be valid pointer!
if (errorCode == HasMemoryIF::POINTS_TO_VARIABLE) { if (errorCode == HasMemoryIF::POINTS_TO_VARIABLE) {
EndianSwapper::swap(reservedSpaceInIPC, dataToCopy, size); EndianConverter::convertBigEndian(reservedSpaceInIPC, dataToCopy, size);
} else { } else {
memcpy(reservedSpaceInIPC, dataToCopy, size); memcpy(reservedSpaceInIPC, dataToCopy, size);
} }
@ -136,7 +136,7 @@ void MemoryHelper::swapMatrixCopy(uint8_t* out, const uint8_t *in,
} }
while (totalSize > 0){ while (totalSize > 0){
EndianSwapper::swap(out,in,datatypeSize); EndianConverter::convertBigEndian(out,in,datatypeSize);
out += datatypeSize; out += datatypeSize;
in += datatypeSize; in += datatypeSize;
totalSize -= datatypeSize; totalSize -= datatypeSize;

View File

@ -91,7 +91,7 @@ void CpuUsage::clear() {
ReturnValue_t CpuUsage::serialize(uint8_t** buffer, uint32_t* size, ReturnValue_t CpuUsage::serialize(uint8_t** buffer, uint32_t* size,
const uint32_t max_size, bool bigEndian) const { const uint32_t max_size, bool bigEndian) const {
ReturnValue_t result = SerializeAdapter<float>::serialize( ReturnValue_t result = SerializeAdapter::serialize(
&timeSinceLastReset, buffer, size, max_size, bigEndian); &timeSinceLastReset, buffer, size, max_size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
@ -111,7 +111,7 @@ uint32_t CpuUsage::getSerializedSize() const {
ReturnValue_t CpuUsage::deSerialize(const uint8_t** buffer, int32_t* size, ReturnValue_t CpuUsage::deSerialize(const uint8_t** buffer, int32_t* size,
bool bigEndian) { bool bigEndian) {
ReturnValue_t result = SerializeAdapter<float>::deSerialize( ReturnValue_t result = SerializeAdapter::deSerialize(
&timeSinceLastReset, buffer, size, bigEndian); &timeSinceLastReset, buffer, size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
@ -122,7 +122,7 @@ ReturnValue_t CpuUsage::deSerialize(const uint8_t** buffer, int32_t* size,
ReturnValue_t CpuUsage::ThreadData::serialize(uint8_t** buffer, uint32_t* size, ReturnValue_t CpuUsage::ThreadData::serialize(uint8_t** buffer, uint32_t* size,
const uint32_t max_size, bool bigEndian) const { const uint32_t max_size, bool bigEndian) const {
ReturnValue_t result = SerializeAdapter<uint32_t>::serialize(&id, buffer, ReturnValue_t result = SerializeAdapter::serialize(&id, buffer,
size, max_size, bigEndian); size, max_size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
@ -133,12 +133,12 @@ ReturnValue_t CpuUsage::ThreadData::serialize(uint8_t** buffer, uint32_t* size,
memcpy(*buffer, name, MAX_LENGTH_OF_THREAD_NAME); memcpy(*buffer, name, MAX_LENGTH_OF_THREAD_NAME);
*size += MAX_LENGTH_OF_THREAD_NAME; *size += MAX_LENGTH_OF_THREAD_NAME;
*buffer += MAX_LENGTH_OF_THREAD_NAME; *buffer += MAX_LENGTH_OF_THREAD_NAME;
result = SerializeAdapter<float>::serialize(&timeRunning, result = SerializeAdapter::serialize(&timeRunning,
buffer, size, max_size, bigEndian); buffer, size, max_size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
result = SerializeAdapter<float>::serialize(&percentUsage, result = SerializeAdapter::serialize(&percentUsage,
buffer, size, max_size, bigEndian); buffer, size, max_size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
@ -159,7 +159,7 @@ uint32_t CpuUsage::ThreadData::getSerializedSize() const {
ReturnValue_t CpuUsage::ThreadData::deSerialize(const uint8_t** buffer, ReturnValue_t CpuUsage::ThreadData::deSerialize(const uint8_t** buffer,
int32_t* size, bool bigEndian) { int32_t* size, bool bigEndian) {
ReturnValue_t result = SerializeAdapter<uint32_t>::deSerialize(&id, buffer, ReturnValue_t result = SerializeAdapter::deSerialize(&id, buffer,
size, bigEndian); size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
@ -169,12 +169,12 @@ ReturnValue_t CpuUsage::ThreadData::deSerialize(const uint8_t** buffer,
} }
memcpy(name, *buffer, MAX_LENGTH_OF_THREAD_NAME); memcpy(name, *buffer, MAX_LENGTH_OF_THREAD_NAME);
*buffer -= MAX_LENGTH_OF_THREAD_NAME; *buffer -= MAX_LENGTH_OF_THREAD_NAME;
result = SerializeAdapter<float>::deSerialize(&timeRunning, result = SerializeAdapter::deSerialize(&timeRunning,
buffer, size, bigEndian); buffer, size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
result = SerializeAdapter<float>::deSerialize(&percentUsage, result = SerializeAdapter::deSerialize(&percentUsage,
buffer, size, bigEndian); buffer, size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;

View File

@ -24,18 +24,18 @@ ReturnValue_t ParameterWrapper::serialize(uint8_t** buffer, uint32_t* size,
const uint32_t max_size, bool bigEndian) const { const uint32_t max_size, bool bigEndian) const {
ReturnValue_t result; ReturnValue_t result;
result = SerializeAdapter<Type>::serialize(&type, buffer, size, max_size, result = SerializeAdapter::serialize(&type, buffer, size, max_size,
bigEndian); bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
result = SerializeAdapter<uint8_t>::serialize(&columns, buffer, size, result = SerializeAdapter::serialize(&columns, buffer, size,
max_size, bigEndian); max_size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
result = SerializeAdapter<uint8_t>::serialize(&rows, buffer, size, max_size, result = SerializeAdapter::serialize(&rows, buffer, size, max_size,
bigEndian); bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
@ -94,7 +94,7 @@ ReturnValue_t ParameterWrapper::serializeData(uint8_t** buffer, uint32_t* size,
ReturnValue_t result; ReturnValue_t result;
uint16_t dataSize = columns * rows; uint16_t dataSize = columns * rows;
while (dataSize != 0) { while (dataSize != 0) {
result = SerializeAdapter<T>::serialize(element, buffer, size, max_size, result = SerializeAdapter::serialize(element, buffer, size, max_size,
bigEndian); bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
@ -123,7 +123,7 @@ ReturnValue_t ParameterWrapper::deSerializeData(uint8_t startingRow,
+ (((startingRow + fromRow) * columns) + startingColumn); + (((startingRow + fromRow) * columns) + startingColumn);
for (uint8_t fromColumn = 0; fromColumn < fromColumns; fromColumn++) { for (uint8_t fromColumn = 0; fromColumn < fromColumns; fromColumn++) {
result = SerializeAdapter<T>::deSerialize( result = SerializeAdapter::deSerialize(
dataWithDataType + fromColumn, &fromAsStream, &streamSize, dataWithDataType + fromColumn, &fromAsStream, &streamSize,
true); true);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
@ -155,18 +155,18 @@ ReturnValue_t ParameterWrapper::deSerialize(const uint8_t** buffer,
ReturnValue_t ParameterWrapper::set(const uint8_t* stream, int32_t streamSize, ReturnValue_t ParameterWrapper::set(const uint8_t* stream, int32_t streamSize,
const uint8_t **remainingStream, int32_t *remainingSize) { const uint8_t **remainingStream, int32_t *remainingSize) {
ReturnValue_t result = SerializeAdapter<Type>::deSerialize(&type, &stream, ReturnValue_t result = SerializeAdapter::deSerialize(&type, &stream,
&streamSize, true); &streamSize, true);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
result = SerializeAdapter<uint8_t>::deSerialize(&columns, &stream, result = SerializeAdapter::deSerialize(&columns, &stream,
&streamSize, true); &streamSize, true);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
result = SerializeAdapter<uint8_t>::deSerialize(&rows, &stream, &streamSize, result = SerializeAdapter::deSerialize(&rows, &stream, &streamSize,
true); true);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;

View File

@ -54,7 +54,7 @@ public:
const uint8_t *streamWithtype = (const uint8_t *) readonlyData; const uint8_t *streamWithtype = (const uint8_t *) readonlyData;
streamWithtype += (row * columns + column) * type.getSize(); streamWithtype += (row * columns + column) * type.getSize();
int32_t size = type.getSize(); int32_t size = type.getSize();
return SerializeAdapter<T>::deSerialize(value, &streamWithtype, return SerializeAdapter::deSerialize(value, &streamWithtype,
&size, true); &size, true);
} else { } else {
const T *dataWithType = (const T *) readonlyData; const T *dataWithType = (const T *) readonlyData;

View File

@ -19,12 +19,12 @@ PowerComponent::PowerComponent(object_id_t setId, uint8_t moduleId, float min, f
ReturnValue_t PowerComponent::serialize(uint8_t** buffer, uint32_t* size, ReturnValue_t PowerComponent::serialize(uint8_t** buffer, uint32_t* size,
const uint32_t max_size, bool bigEndian) const { const uint32_t max_size, bool bigEndian) const {
ReturnValue_t result = SerializeAdapter<float>::serialize(&min, buffer, ReturnValue_t result = SerializeAdapter::serialize(&min, buffer,
size, max_size, bigEndian); size, max_size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
return SerializeAdapter<float>::serialize(&max, buffer, size, max_size, return SerializeAdapter::serialize(&max, buffer, size, max_size,
bigEndian); bigEndian);
} }
@ -58,12 +58,12 @@ float PowerComponent::getMax() {
ReturnValue_t PowerComponent::deSerialize(const uint8_t** buffer, int32_t* size, ReturnValue_t PowerComponent::deSerialize(const uint8_t** buffer, int32_t* size,
bool bigEndian) { bool bigEndian) {
ReturnValue_t result = SerializeAdapter<float>::deSerialize(&min, buffer, ReturnValue_t result = SerializeAdapter::deSerialize(&min, buffer,
size, bigEndian); size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
return SerializeAdapter<float>::deSerialize(&max, buffer, size, bigEndian); return SerializeAdapter::deSerialize(&max, buffer, size, bigEndian);
} }
ReturnValue_t PowerComponent::getParameter(uint8_t domainId, ReturnValue_t PowerComponent::getParameter(uint8_t domainId,

View File

@ -5,20 +5,20 @@
#include <cstring> #include <cstring>
#include <iostream> #include <iostream>
class EndianSwapper { class EndianConverter {
private: private:
EndianSwapper() { EndianConverter() {
} }
; ;
public: public:
template<typename T> template<typename T>
static T swap(T in) { static T convertBigEndian(T in) {
#ifndef BYTE_ORDER_SYSTEM #ifndef BYTE_ORDER_SYSTEM
#error BYTE_ORDER_SYSTEM not defined #error BYTE_ORDER_SYSTEM not defined
#elif BYTE_ORDER_SYSTEM == LITTLE_ENDIAN #elif BYTE_ORDER_SYSTEM == LITTLE_ENDIAN
T tmp; T tmp;
uint8_t *pointerOut = (uint8_t *) &tmp; uint8_t *pointerOut = (uint8_t*) &tmp;
uint8_t *pointerIn = (uint8_t *) &in; uint8_t *pointerIn = (uint8_t*) &in;
for (uint8_t count = 0; count < sizeof(T); count++) { for (uint8_t count = 0; count < sizeof(T); count++) {
pointerOut[sizeof(T) - count - 1] = pointerIn[count]; pointerOut[sizeof(T) - count - 1] = pointerIn[count];
} }
@ -29,7 +29,8 @@ public:
#error Unknown Byte Order #error Unknown Byte Order
#endif #endif
} }
static void swap(uint8_t* out, const uint8_t* in, uint32_t size) { static void convertBigEndian(uint8_t *out, const uint8_t *in,
uint32_t size) {
#ifndef BYTE_ORDER_SYSTEM #ifndef BYTE_ORDER_SYSTEM
#error BYTE_ORDER_SYSTEM not defined #error BYTE_ORDER_SYSTEM not defined
#elif BYTE_ORDER_SYSTEM == LITTLE_ENDIAN #elif BYTE_ORDER_SYSTEM == LITTLE_ENDIAN
@ -40,6 +41,39 @@ public:
#elif BYTE_ORDER_SYSTEM == BIG_ENDIAN #elif BYTE_ORDER_SYSTEM == BIG_ENDIAN
memcpy(out, in, size); memcpy(out, in, size);
return; return;
#endif
}
template<typename T>
static T convertLittleEndian(T in) {
#ifndef BYTE_ORDER_SYSTEM
#error BYTE_ORDER_SYSTEM not defined
#elif BYTE_ORDER_SYSTEM == BIG_ENDIAN
T tmp;
uint8_t *pointerOut = (uint8_t *) &tmp;
uint8_t *pointerIn = (uint8_t *) &in;
for (uint8_t count = 0; count < sizeof(T); count++) {
pointerOut[sizeof(T) - count - 1] = pointerIn[count];
}
return tmp;
#elif BYTE_ORDER_SYSTEM == LITTLE_ENDIAN
return in;
#else
#error Unknown Byte Order
#endif
}
static void convertLittleEndian(uint8_t *out, const uint8_t *in,
uint32_t size) {
#ifndef BYTE_ORDER_SYSTEM
#error BYTE_ORDER_SYSTEM not defined
#elif BYTE_ORDER_SYSTEM == BIG_ENDIAN
for (uint8_t count = 0; count < size; count++) {
out[size - count - 1] = in[count];
}
return;
#elif BYTE_ORDER_SYSTEM == LITTLE_ENDIAN
memcpy(out, in, size);
return;
#endif #endif
} }
}; };

View File

@ -27,11 +27,11 @@ public:
static ReturnValue_t serialize(const ArrayList<T, count_t>* list, uint8_t** buffer, uint32_t* size, static ReturnValue_t serialize(const ArrayList<T, count_t>* list, uint8_t** buffer, uint32_t* size,
const uint32_t max_size, bool bigEndian) { const uint32_t max_size, bool bigEndian) {
ReturnValue_t result = SerializeAdapter<count_t>::serialize(&list->size, ReturnValue_t result = SerializeAdapter::serialize(&list->size,
buffer, size, max_size, bigEndian); buffer, size, max_size, bigEndian);
count_t i = 0; count_t i = 0;
while ((result == HasReturnvaluesIF::RETURN_OK) && (i < list->size)) { while ((result == HasReturnvaluesIF::RETURN_OK) && (i < list->size)) {
result = SerializeAdapter<T>::serialize(&list->entries[i], buffer, size, result = SerializeAdapter::serialize(&list->entries[i], buffer, size,
max_size, bigEndian); max_size, bigEndian);
++i; ++i;
} }
@ -47,7 +47,7 @@ public:
count_t i = 0; count_t i = 0;
for (i = 0; i < list->size; ++i) { for (i = 0; i < list->size; ++i) {
printSize += SerializeAdapter<T>::getSerializedSize(&list->entries[i]); printSize += SerializeAdapter::getSerializedSize(&list->entries[i]);
} }
return printSize; return printSize;
@ -61,7 +61,7 @@ public:
static ReturnValue_t deSerialize(ArrayList<T, count_t>* list, const uint8_t** buffer, int32_t* size, static ReturnValue_t deSerialize(ArrayList<T, count_t>* list, const uint8_t** buffer, int32_t* size,
bool bigEndian) { bool bigEndian) {
count_t tempSize = 0; count_t tempSize = 0;
ReturnValue_t result = SerializeAdapter<count_t>::deSerialize(&tempSize, ReturnValue_t result = SerializeAdapter::deSerialize(&tempSize,
buffer, size, bigEndian); buffer, size, bigEndian);
if (tempSize > list->maxSize()) { if (tempSize > list->maxSize()) {
return SerializeIF::TOO_MANY_ELEMENTS; return SerializeIF::TOO_MANY_ELEMENTS;
@ -69,7 +69,7 @@ public:
list->size = tempSize; list->size = tempSize;
count_t i = 0; count_t i = 0;
while ((result == HasReturnvaluesIF::RETURN_OK) && (i < list->size)) { while ((result == HasReturnvaluesIF::RETURN_OK) && (i < list->size)) {
result = SerializeAdapter<T>::deSerialize( result = SerializeAdapter::deSerialize(
&list->front()[i], buffer, size, &list->front()[i], buffer, size,
bigEndian); bigEndian);
++i; ++i;

View File

@ -26,14 +26,14 @@ ReturnValue_t SerialBufferAdapter<T>::serialize(uint8_t** buffer, uint32_t* size
const uint32_t max_size, bool bigEndian) const { const uint32_t max_size, bool bigEndian) const {
uint32_t serializedLength = bufferLength; uint32_t serializedLength = bufferLength;
if (serializeLength) { if (serializeLength) {
serializedLength += AutoSerializeAdapter::getSerializedSize( serializedLength += SerializeAdapter::getSerializedSize(
&bufferLength); &bufferLength);
} }
if (*size + serializedLength > max_size) { if (*size + serializedLength > max_size) {
return BUFFER_TOO_SHORT; return BUFFER_TOO_SHORT;
} else { } else {
if (serializeLength) { if (serializeLength) {
AutoSerializeAdapter::serialize(&bufferLength, buffer, size, SerializeAdapter::serialize(&bufferLength, buffer, size,
max_size, bigEndian); max_size, bigEndian);
} }
if (this->constBuffer != NULL) { if (this->constBuffer != NULL) {
@ -52,7 +52,7 @@ ReturnValue_t SerialBufferAdapter<T>::serialize(uint8_t** buffer, uint32_t* size
template<typename T> template<typename T>
uint32_t SerialBufferAdapter<T>::getSerializedSize() const { uint32_t SerialBufferAdapter<T>::getSerializedSize() const {
if (serializeLength) { if (serializeLength) {
return bufferLength + AutoSerializeAdapter::getSerializedSize(&bufferLength); return bufferLength + SerializeAdapter::getSerializedSize(&bufferLength);
} else { } else {
return bufferLength; return bufferLength;
} }
@ -63,7 +63,7 @@ ReturnValue_t SerialBufferAdapter<T>::deSerialize(const uint8_t** buffer,
//TODO Ignores Endian flag! //TODO Ignores Endian flag!
if (buffer != NULL) { if (buffer != NULL) {
if(serializeLength){ if(serializeLength){
T serializedSize = AutoSerializeAdapter::getSerializedSize( T serializedSize = SerializeAdapter::getSerializedSize(
&bufferLength); &bufferLength);
if((*size - bufferLength - serializedSize) >= 0){ if((*size - bufferLength - serializedSize) >= 0){
*buffer += serializedSize; *buffer += serializedSize;

View File

@ -31,32 +31,32 @@ public:
SinglyLinkedList<T>(), printCount(printCount) { SinglyLinkedList<T>(), printCount(printCount) {
} }
virtual ReturnValue_t serialize(uint8_t** buffer, uint32_t* size, virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size,
const uint32_t max_size, bool bigEndian) const { size_t maxSize, Endianness streamEndianness) const override {
if (printCount) { if (printCount) {
count_t mySize = SinglyLinkedList<T>::getSize(); count_t mySize = SinglyLinkedList<T>::getSize();
ReturnValue_t result = SerializeAdapter<count_t>::serialize(&mySize, ReturnValue_t result = SerializeAdapter::serialize(&mySize,
buffer, size, max_size, bigEndian); buffer, size, maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
} }
return serialize(SinglyLinkedList<T>::start, buffer, size, max_size, return serialize(SinglyLinkedList<T>::start, buffer, size, maxSize,
bigEndian); streamEndianness);
} }
static ReturnValue_t serialize(const LinkedElement<T>* element, static ReturnValue_t serialize(const LinkedElement<T>* element,
uint8_t** buffer, uint32_t* size, const uint32_t max_size, uint8_t** buffer, size_t* size, size_t maxSize,
bool bigEndian) { Endianness streamEndianness) {
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->serialize(buffer, size, max_size, result = element->value->serialize(buffer, size, maxSize,
bigEndian); streamEndianness);
element = element->getNext(); element = element->getNext();
} }
return result; return result;
} }
virtual uint32_t getSerializedSize() const { virtual size_t getSerializedSize() const override {
if (printCount) { if (printCount) {
return SerialLinkedListAdapter<T>::getSerializedSize() return SerialLinkedListAdapter<T>::getSerializedSize()
+ sizeof(count_t); + sizeof(count_t);
@ -64,8 +64,8 @@ public:
return getSerializedSize(SinglyLinkedList<T>::start); return getSerializedSize(SinglyLinkedList<T>::start);
} }
} }
static uint32_t getSerializedSize(const LinkedElement<T> *element) { static size_t getSerializedSize(const LinkedElement<T> *element) {
uint32_t size = 0; size_t size = 0;
while (element != NULL) { while (element != NULL) {
size += element->value->getSerializedSize(); size += element->value->getSerializedSize();
element = element->getNext(); element = element->getNext();
@ -73,16 +73,16 @@ public:
return size; return size;
} }
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size, virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
bool bigEndian) { Endianness streamEndianness) override {
return deSerialize(SinglyLinkedList<T>::start, buffer, size, bigEndian); return deSerialize(SinglyLinkedList<T>::start, buffer, size, streamEndianness);
} }
static ReturnValue_t deSerialize(LinkedElement<T>* element, static ReturnValue_t deSerialize(LinkedElement<T>* element,
const uint8_t** buffer, int32_t* size, bool bigEndian) { const uint8_t** buffer, size_t* size, Endianness streamEndianness) {
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, streamEndianness);
element = element->getNext(); element = element->getNext();
} }
return result; return result;

View File

@ -10,116 +10,114 @@
/** /**
* \ingroup serialize * \ingroup serialize
*/ */
template<typename T, int>
class SerializeAdapter_ {
public:
static ReturnValue_t serialize(const T* object, uint8_t** buffer,
uint32_t* size, const uint32_t max_size, bool bigEndian) {
uint32_t ignoredSize = 0;
if (size == NULL) {
size = &ignoredSize;
}
if (sizeof(T) + *size <= max_size) {
T tmp;
if (bigEndian) {
tmp = EndianSwapper::swap<T>(*object);
} else {
tmp = *object;
}
memcpy(*buffer, &tmp, sizeof(T));
*size += sizeof(T);
(*buffer) += sizeof(T);
return HasReturnvaluesIF::RETURN_OK;
} else {
return SerializeIF::BUFFER_TOO_SHORT;
}
}
ReturnValue_t deSerialize(T* object, const uint8_t** buffer, int32_t* size,
bool bigEndian) {
T tmp;
*size -= sizeof(T);
if (*size >= 0) {
memcpy(&tmp, *buffer, sizeof(T));
if (bigEndian) {
*object = EndianSwapper::swap<T>(tmp);
} else {
*object = tmp;
}
*buffer += sizeof(T);
return HasReturnvaluesIF::RETURN_OK;
} else {
return SerializeIF::STREAM_TOO_SHORT;
}
}
uint32_t getSerializedSize(const T * object) {
return sizeof(T);
}
};
template<typename T>
class SerializeAdapter_<T, 1> {
public:
ReturnValue_t serialize(const T* object, uint8_t** buffer, uint32_t* size,
const uint32_t max_size, bool bigEndian) const {
uint32_t ignoredSize = 0;
if (size == NULL) {
size = &ignoredSize;
}
return object->serialize(buffer, size, max_size, bigEndian);
}
uint32_t getSerializedSize(const T* object) const {
return object->getSerializedSize();
}
ReturnValue_t deSerialize(T* object, const uint8_t** buffer, int32_t* size,
bool bigEndian) {
return object->deSerialize(buffer, size, bigEndian);
}
};
template<typename T>
class SerializeAdapter { class SerializeAdapter {
public:
static ReturnValue_t serialize(const T* object, uint8_t** buffer,
uint32_t* size, const uint32_t max_size, bool bigEndian) {
SerializeAdapter_<T, IsDerivedFrom<T, SerializeIF>::Is> adapter;
return adapter.serialize(object, buffer, size, max_size, bigEndian);
}
static uint32_t getSerializedSize(const T* object) {
SerializeAdapter_<T, IsDerivedFrom<T, SerializeIF>::Is> adapter;
return adapter.getSerializedSize(object);
}
static ReturnValue_t deSerialize(T* object, const uint8_t** buffer,
int32_t* size, bool bigEndian) {
SerializeAdapter_<T, IsDerivedFrom<T, SerializeIF>::Is> adapter;
return adapter.deSerialize(object, buffer, size, bigEndian);
}
};
class AutoSerializeAdapter {
public: public:
template<typename T> template<typename T>
static ReturnValue_t serialize(const T* object, uint8_t** buffer, static ReturnValue_t serialize(const T *object, uint8_t **buffer,
uint32_t* size, const uint32_t max_size, bool bigEndian) { size_t *size, size_t maxSize, SerializeIF::Endianness streamEndianness) {
SerializeAdapter_<T, IsDerivedFrom<T, SerializeIF>::Is> adapter; InternalSerializeAdapter<T, IsDerivedFrom<T, SerializeIF>::Is> adapter;
return adapter.serialize(object, buffer, size, max_size, bigEndian); return adapter.serialize(object, buffer, size, maxSize,
streamEndianness);
} }
template<typename T> template<typename T>
static uint32_t getSerializedSize(const T* object) { static uint32_t getSerializedSize(const T *object) {
SerializeAdapter_<T, IsDerivedFrom<T, SerializeIF>::Is> adapter; InternalSerializeAdapter<T, IsDerivedFrom<T, SerializeIF>::Is> adapter;
return adapter.getSerializedSize(object); return adapter.getSerializedSize(object);
} }
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,
int32_t* size, bool bigEndian) { size_t *size, SerializeIF::Endianness streamEndianness) {
SerializeAdapter_<T, IsDerivedFrom<T, SerializeIF>::Is> adapter; InternalSerializeAdapter<T, IsDerivedFrom<T, SerializeIF>::Is> adapter;
return adapter.deSerialize(object, buffer, size, bigEndian); return adapter.deSerialize(object, buffer, size, streamEndianness);
} }
private:
template<typename T, int>
class InternalSerializeAdapter {
public:
static ReturnValue_t serialize(const T *object, uint8_t **buffer,
size_t *size, size_t max_size, SerializeIF::Endianness streamEndianness) {
size_t ignoredSize = 0;
if (size == NULL) {
size = &ignoredSize;
}
//TODO check integer overflow of *size
if (sizeof(T) + *size <= max_size) {
T tmp;
switch (streamEndianness) {
case SerializeIF::Endianness::BIG:
tmp = EndianConverter::convertBigEndian<T>(*object);
break;
case SerializeIF::Endianness::LITTLE:
tmp = EndianConverter::convertLittleEndian<T>(*object);
break;
default:
case SerializeIF::Endianness::MACHINE:
tmp = *object;
break;
}
memcpy(*buffer, &tmp, sizeof(T));
*size += sizeof(T);
(*buffer) += sizeof(T);
return HasReturnvaluesIF::RETURN_OK;
} else {
return SerializeIF::BUFFER_TOO_SHORT;
}
}
ReturnValue_t deSerialize(T *object, const uint8_t **buffer,
size_t *size, SerializeIF::Endianness streamEndianness) {
T tmp;
if (*size >= sizeof(T)) {
*size -= sizeof(T);
memcpy(&tmp, *buffer, sizeof(T));
switch (streamEndianness) {
case SerializeIF::Endianness::BIG:
*object = EndianConverter::convertBigEndian<T>(tmp);
break;
case SerializeIF::Endianness::LITTLE:
*object = EndianConverter::convertLittleEndian<T>(tmp);
break;
default:
case SerializeIF::Endianness::MACHINE:
*object = tmp;
break;
}
*buffer += sizeof(T);
return HasReturnvaluesIF::RETURN_OK;
} else {
return SerializeIF::STREAM_TOO_SHORT;
}
}
uint32_t getSerializedSize(const T *object) {
return sizeof(T);
}
};
template<typename T>
class InternalSerializeAdapter<T, 1> {
public:
ReturnValue_t serialize(const T *object, uint8_t **buffer,
size_t *size, size_t max_size,
SerializeIF::Endianness streamEndianness) const {
size_t ignoredSize = 0;
if (size == NULL) {
size = &ignoredSize;
}
return object->serialize(buffer, size, max_size, streamEndianness);
}
uint32_t getSerializedSize(const T *object) const {
return object->getSerializedSize();
}
ReturnValue_t deSerialize(T *object, const uint8_t **buffer,
size_t *size, SerializeIF::Endianness streamEndianness) {
return object->deSerialize(buffer, size, streamEndianness);
}
};
}; };
#endif /* SERIALIZEADAPTER_H_ */ #endif /* SERIALIZEADAPTER_H_ */

View File

@ -9,41 +9,43 @@
* \ingroup serialize * \ingroup serialize
*/ */
template<typename T> template<typename T>
class SerializeElement : public SerializeIF, public LinkedElement<SerializeIF> { class SerializeElement: public SerializeIF, public LinkedElement<SerializeIF> {
public: public:
template<typename... Args> template<typename ... Args>
SerializeElement(Args... args) : LinkedElement<SerializeIF>(this), entry(std::forward<Args>(args)...) { SerializeElement(Args ... args) :
LinkedElement<SerializeIF>(this), entry(std::forward<Args>(args)...) {
} }
SerializeElement() : LinkedElement<SerializeIF>(this) { SerializeElement() :
LinkedElement<SerializeIF>(this) {
} }
T entry; T entry;
ReturnValue_t serialize(uint8_t** buffer, uint32_t* size, ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
const uint32_t max_size, bool bigEndian) const { Endianness streamEndianness) const override {
return SerializeAdapter<T>::serialize(&entry, buffer, size, max_size, bigEndian); return SerializeAdapter::serialize(&entry, buffer, size, maxSize,
streamEndianness);
} }
uint32_t getSerializedSize() const { uint32_t getSerializedSize() const override {
return SerializeAdapter<T>::getSerializedSize(&entry); return SerializeAdapter::getSerializedSize(&entry);
} }
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size, virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
bool bigEndian) { Endianness streamEndianness) override {
return SerializeAdapter<T>::deSerialize(&entry, buffer, size, bigEndian); return SerializeAdapter::deSerialize(&entry, buffer, size,
streamEndianness);
} }
operator T() { operator T() {
return entry; return entry;
} }
SerializeElement<T> &operator=(T newValue) { SerializeElement<T>& operator=(T newValue) {
entry = newValue; entry = newValue;
return *this; return *this;
} }
T *operator->() { T* operator->() {
return &entry; return &entry;
} }
}; };
#endif /* SERIALIZEELEMENT_H_ */ #endif /* SERIALIZEELEMENT_H_ */

View File

@ -2,6 +2,7 @@
#define SERIALIZEIF_H_ #define SERIALIZEIF_H_
#include <framework/returnvalues/HasReturnvaluesIF.h> #include <framework/returnvalues/HasReturnvaluesIF.h>
#include <stddef.h>
/** /**
* \defgroup serialize Serialization * \defgroup serialize Serialization
@ -14,6 +15,10 @@
*/ */
class SerializeIF { class SerializeIF {
public: public:
enum class Endianness : uint8_t {
BIG, LITTLE, MACHINE
};
static const uint8_t INTERFACE_ID = CLASS_ID::SERIALIZE_IF; static const uint8_t INTERFACE_ID = CLASS_ID::SERIALIZE_IF;
static const ReturnValue_t BUFFER_TOO_SHORT = MAKE_RETURN_CODE(1); static const ReturnValue_t BUFFER_TOO_SHORT = MAKE_RETURN_CODE(1);
static const ReturnValue_t STREAM_TOO_SHORT = MAKE_RETURN_CODE(2); static const ReturnValue_t STREAM_TOO_SHORT = MAKE_RETURN_CODE(2);
@ -22,13 +27,13 @@ public:
virtual ~SerializeIF() { virtual ~SerializeIF() {
} }
virtual ReturnValue_t serialize(uint8_t** buffer, uint32_t* size, virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size,
const uint32_t max_size, bool bigEndian) const = 0; size_t max_size, Endianness streamEndianness) const = 0;
virtual uint32_t getSerializedSize() const = 0; virtual size_t getSerializedSize() const = 0;
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size, virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
bool bigEndian) = 0; Endianness streamEndianness) = 0;
}; };

View File

@ -169,7 +169,7 @@ ReturnValue_t Subsystem::handleCommandMessage(CommandMessage* message) {
if (result == RETURN_OK) { if (result == RETURN_OK) {
Mode_t fallbackId; Mode_t fallbackId;
int32_t size = sizeRead; int32_t size = sizeRead;
result = SerializeAdapter<Mode_t>::deSerialize(&fallbackId, result = SerializeAdapter::deSerialize(&fallbackId,
&pointer, &size, true); &pointer, &size, true);
if (result == RETURN_OK) { if (result == RETURN_OK) {
result = SerialArrayListAdapter<ModeListEntry>::deSerialize( result = SerialArrayListAdapter<ModeListEntry>::deSerialize(

View File

@ -23,26 +23,26 @@ public:
ReturnValue_t result; ReturnValue_t result;
result = SerializeAdapter<uint32_t>::serialize(&value1, buffer, size, result = SerializeAdapter::serialize(&value1, buffer, size,
max_size, bigEndian); max_size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
result = SerializeAdapter<uint32_t>::serialize(&value2, buffer, size, result = SerializeAdapter::serialize(&value2, buffer, size,
max_size, bigEndian); max_size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
result = SerializeAdapter<uint8_t>::serialize(&value3, buffer, size, result = SerializeAdapter::serialize(&value3, buffer, size,
max_size, bigEndian); max_size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
result = SerializeAdapter<uint8_t>::serialize(&value4, buffer, size, result = SerializeAdapter::serialize(&value4, buffer, size,
max_size, bigEndian); max_size, bigEndian);
return result; return result;
@ -57,25 +57,25 @@ public:
bool bigEndian) { bool bigEndian) {
ReturnValue_t result; ReturnValue_t result;
result = SerializeAdapter<uint32_t>::deSerialize(&value1, buffer, size, result = SerializeAdapter::deSerialize(&value1, buffer, size,
bigEndian); bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
result = SerializeAdapter<uint32_t>::deSerialize(&value2, buffer, size, result = SerializeAdapter::deSerialize(&value2, buffer, size,
bigEndian); bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
result = SerializeAdapter<uint8_t>::deSerialize(&value3, buffer, size, result = SerializeAdapter::deSerialize(&value3, buffer, size,
bigEndian); bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
result = SerializeAdapter<uint8_t>::deSerialize(&value4, buffer, size, result = SerializeAdapter::deSerialize(&value4, buffer, size,
bigEndian); bigEndian);
return result; return result;

View File

@ -47,13 +47,13 @@ ReturnValue_t ThermalComponent::setLimits(const uint8_t* data, uint32_t size) {
return MonitoringIF::INVALID_SIZE; return MonitoringIF::INVALID_SIZE;
} }
int32_t readSize = size; int32_t readSize = size;
SerializeAdapter<float>::deSerialize(&nopParameters.lowerNopLimit, &data, SerializeAdapter::deSerialize(&nopParameters.lowerNopLimit, &data,
&readSize, true); &readSize, true);
SerializeAdapter<float>::deSerialize(&parameters.lowerOpLimit, &data, SerializeAdapter::deSerialize(&parameters.lowerOpLimit, &data,
&readSize, true); &readSize, true);
SerializeAdapter<float>::deSerialize(&parameters.upperOpLimit, &data, SerializeAdapter::deSerialize(&parameters.upperOpLimit, &data,
&readSize, true); &readSize, true);
SerializeAdapter<float>::deSerialize(&nopParameters.upperNopLimit, &data, SerializeAdapter::deSerialize(&nopParameters.upperNopLimit, &data,
&readSize, true); &readSize, true);
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }

View File

@ -34,12 +34,12 @@ public:
uint16_t ssc; uint16_t ssc;
ReturnValue_t serialize(uint8_t** buffer, uint32_t* size, ReturnValue_t serialize(uint8_t** buffer, uint32_t* size,
const uint32_t max_size, bool bigEndian) const { const uint32_t max_size, bool bigEndian) const {
ReturnValue_t result = SerializeAdapter<uint16_t>::serialize(&apid, ReturnValue_t result = SerializeAdapter::serialize(&apid,
buffer, size, max_size, bigEndian); buffer, size, max_size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
return SerializeAdapter<uint16_t>::serialize(&ssc, buffer, size, return SerializeAdapter::serialize(&ssc, buffer, size,
max_size, bigEndian); max_size, bigEndian);
} }
@ -50,12 +50,12 @@ public:
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size, ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
bool bigEndian) { bool bigEndian) {
ReturnValue_t result = SerializeAdapter<uint16_t>::deSerialize(&apid, ReturnValue_t result = SerializeAdapter::deSerialize(&apid,
buffer, size, bigEndian); buffer, size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
return SerializeAdapter<uint16_t>::deSerialize(&ssc, buffer, size, return SerializeAdapter::deSerialize(&ssc, buffer, size,
bigEndian); bigEndian);
} }
}; };
@ -220,23 +220,23 @@ public:
ReturnValue_t serialize(uint8_t** buffer, uint32_t* size, ReturnValue_t serialize(uint8_t** buffer, uint32_t* size,
const uint32_t max_size, bool bigEndian) const { const uint32_t max_size, bool bigEndian) const {
ReturnValue_t result = AutoSerializeAdapter::serialize(&apid,buffer,size,max_size,bigEndian); ReturnValue_t result = SerializeAdapter::serialize(&apid,buffer,size,max_size,bigEndian);
if(result!=HasReturnvaluesIF::RETURN_OK){ if(result!=HasReturnvaluesIF::RETURN_OK){
return result; return result;
} }
result = AutoSerializeAdapter::serialize(&sourceSequenceCount,buffer,size,max_size,bigEndian); result = SerializeAdapter::serialize(&sourceSequenceCount,buffer,size,max_size,bigEndian);
if(result!=HasReturnvaluesIF::RETURN_OK){ if(result!=HasReturnvaluesIF::RETURN_OK){
return result; return result;
} }
result = AutoSerializeAdapter::serialize(&serviceType,buffer,size,max_size,bigEndian); result = SerializeAdapter::serialize(&serviceType,buffer,size,max_size,bigEndian);
if(result!=HasReturnvaluesIF::RETURN_OK){ if(result!=HasReturnvaluesIF::RETURN_OK){
return result; return result;
} }
result = AutoSerializeAdapter::serialize(&serviceSubtype,buffer,size,max_size,bigEndian); result = SerializeAdapter::serialize(&serviceSubtype,buffer,size,max_size,bigEndian);
if(result!=HasReturnvaluesIF::RETURN_OK){ if(result!=HasReturnvaluesIF::RETURN_OK){
return result; return result;
} }
result = AutoSerializeAdapter::serialize(&subCounter,buffer,size,max_size,bigEndian); result = SerializeAdapter::serialize(&subCounter,buffer,size,max_size,bigEndian);
if(result!=HasReturnvaluesIF::RETURN_OK){ if(result!=HasReturnvaluesIF::RETURN_OK){
return result; return result;
} }
@ -246,11 +246,11 @@ public:
uint32_t getSerializedSize() const { uint32_t getSerializedSize() const {
uint32_t size = 0; uint32_t size = 0;
size += AutoSerializeAdapter::getSerializedSize(&apid); size += SerializeAdapter::getSerializedSize(&apid);
size += AutoSerializeAdapter::getSerializedSize(&sourceSequenceCount); size += SerializeAdapter::getSerializedSize(&sourceSequenceCount);
size += AutoSerializeAdapter::getSerializedSize(&serviceType); size += SerializeAdapter::getSerializedSize(&serviceType);
size += AutoSerializeAdapter::getSerializedSize(&serviceSubtype); size += SerializeAdapter::getSerializedSize(&serviceSubtype);
size += AutoSerializeAdapter::getSerializedSize(&subCounter); size += SerializeAdapter::getSerializedSize(&subCounter);
SerialBufferAdapter<uint8_t> adapter(rawTimestamp,sizeof(rawTimestamp)); SerialBufferAdapter<uint8_t> adapter(rawTimestamp,sizeof(rawTimestamp));
size += adapter.getSerializedSize(); size += adapter.getSerializedSize();
return size; return size;
@ -259,27 +259,27 @@ public:
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size, ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
bool bigEndian) { bool bigEndian) {
ReturnValue_t result = AutoSerializeAdapter::deSerialize(&apid, buffer, ReturnValue_t result = SerializeAdapter::deSerialize(&apid, buffer,
size, bigEndian); size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
result = AutoSerializeAdapter::deSerialize(&sourceSequenceCount, buffer, result = SerializeAdapter::deSerialize(&sourceSequenceCount, buffer,
size, bigEndian); size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
result = AutoSerializeAdapter::deSerialize(&serviceType, buffer, size, result = SerializeAdapter::deSerialize(&serviceType, buffer, size,
bigEndian); bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
result = AutoSerializeAdapter::deSerialize(&serviceSubtype, buffer, result = SerializeAdapter::deSerialize(&serviceSubtype, buffer,
size, bigEndian); size, bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
result = AutoSerializeAdapter::deSerialize(&subCounter, buffer, size, result = SerializeAdapter::deSerialize(&subCounter, buffer, size,
bigEndian); bigEndian);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;

View File

@ -24,14 +24,14 @@ public:
} }
ReturnValue_t serialize(uint8_t** buffer, uint32_t* size, ReturnValue_t serialize(uint8_t** buffer, uint32_t* size,
const uint32_t max_size, bool bigEndian) const { const uint32_t max_size, bool bigEndian) const {
return SerializeAdapter<uint16_t>::serialize(&apid, buffer, size, max_size, bigEndian); return SerializeAdapter::serialize(&apid, buffer, size, max_size, bigEndian);
} }
uint32_t getSerializedSize() const { uint32_t getSerializedSize() const {
return SerializeAdapter<uint16_t>::getSerializedSize(&apid); return SerializeAdapter::getSerializedSize(&apid);
} }
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size, ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
bool bigEndian) { bool bigEndian) {
return SerializeAdapter<uint16_t>::deSerialize(&apid, buffer, size, bigEndian); return SerializeAdapter::deSerialize(&apid, buffer, size, bigEndian);
} }
}; };

View File

@ -24,14 +24,14 @@ public:
} }
ReturnValue_t serialize(uint8_t** buffer, uint32_t* size, ReturnValue_t serialize(uint8_t** buffer, uint32_t* size,
const uint32_t max_size, bool bigEndian) const { const uint32_t max_size, bool bigEndian) const {
return SerializeAdapter<uint8_t>::serialize(&service, buffer, size, max_size, bigEndian); return SerializeAdapter::serialize(&service, buffer, size, max_size, bigEndian);
} }
uint32_t getSerializedSize() const { uint32_t getSerializedSize() const {
return SerializeAdapter<uint8_t>::getSerializedSize(&service); return SerializeAdapter::getSerializedSize(&service);
} }
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size, ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
bool bigEndian) { bool bigEndian) {
return SerializeAdapter<uint8_t>::deSerialize(&service, buffer, size, bigEndian); return SerializeAdapter::deSerialize(&service, buffer, size, bigEndian);
} }
}; };

View File

@ -22,14 +22,14 @@ public:
} }
ReturnValue_t serialize(uint8_t** buffer, uint32_t* size, ReturnValue_t serialize(uint8_t** buffer, uint32_t* size,
const uint32_t max_size, bool bigEndian) const { const uint32_t max_size, bool bigEndian) const {
return SerializeAdapter<uint8_t>::serialize(&subService, buffer, size, max_size, bigEndian); return SerializeAdapter::serialize(&subService, buffer, size, max_size, bigEndian);
} }
uint32_t getSerializedSize() const { uint32_t getSerializedSize() const {
return SerializeAdapter<uint8_t>::getSerializedSize(&subService); return SerializeAdapter::getSerializedSize(&subService);
} }
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size, ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
bool bigEndian) { bool bigEndian) {
return SerializeAdapter<uint8_t>::deSerialize(&subService, buffer, size, bigEndian); return SerializeAdapter::deSerialize(&subService, buffer, size, bigEndian);
} }
private: private:
uint8_t subService; uint8_t subService;

View File

@ -236,7 +236,7 @@ void CommandingServiceBase::sendTmPacket(uint8_t subservice,
uint8_t buffer[sizeof(object_id_t)]; uint8_t buffer[sizeof(object_id_t)];
uint8_t* pBuffer = buffer; uint8_t* pBuffer = buffer;
uint32_t size = 0; uint32_t size = 0;
SerializeAdapter<object_id_t>::serialize(&objectId, &pBuffer, &size, SerializeAdapter::serialize(&objectId, &pBuffer, &size,
sizeof(object_id_t), true); sizeof(object_id_t), true);
TmPacketStored tmPacketStored(this->apid, this->service, subservice, TmPacketStored tmPacketStored(this->apid, this->service, subservice,
this->tmPacketCounter, data, dataLen, buffer, size); this->tmPacketCounter, data, dataLen, buffer, size);

View File

@ -108,12 +108,12 @@ PusSuccessReport::PusSuccessReport(uint16_t setPacketId,
uint16_t setSequenceControl, uint8_t setStep) : uint16_t setSequenceControl, uint8_t setStep) :
reportSize(0), pBuffer(reportBuffer) { reportSize(0), pBuffer(reportBuffer) {
//Serialization won't fail, because we know the necessary max-size of the buffer. //Serialization won't fail, because we know the necessary max-size of the buffer.
SerializeAdapter<uint16_t>::serialize(&setPacketId, &pBuffer, &reportSize, SerializeAdapter::serialize(&setPacketId, &pBuffer, &reportSize,
sizeof(reportBuffer), true); sizeof(reportBuffer), true);
SerializeAdapter<uint16_t>::serialize(&setSequenceControl, &pBuffer, SerializeAdapter::serialize(&setSequenceControl, &pBuffer,
&reportSize, sizeof(reportBuffer), true); &reportSize, sizeof(reportBuffer), true);
if (setStep != 0) { if (setStep != 0) {
SerializeAdapter<uint8_t>::serialize(&setStep, &pBuffer, &reportSize, SerializeAdapter::serialize(&setStep, &pBuffer, &reportSize,
sizeof(reportBuffer), true); sizeof(reportBuffer), true);
} }
} }
@ -135,19 +135,19 @@ PusFailureReport::PusFailureReport(uint16_t setPacketId,
uint8_t setStep, uint32_t parameter1, uint32_t parameter2) : uint8_t setStep, uint32_t parameter1, uint32_t parameter2) :
reportSize(0), pBuffer(reportBuffer) { reportSize(0), pBuffer(reportBuffer) {
//Serialization won't fail, because we know the necessary max-size of the buffer. //Serialization won't fail, because we know the necessary max-size of the buffer.
SerializeAdapter<uint16_t>::serialize(&setPacketId, &pBuffer, &reportSize, SerializeAdapter::serialize(&setPacketId, &pBuffer, &reportSize,
sizeof(reportBuffer), true); sizeof(reportBuffer), true);
SerializeAdapter<uint16_t>::serialize(&setSequenceControl, &pBuffer, SerializeAdapter::serialize(&setSequenceControl, &pBuffer,
&reportSize, sizeof(reportBuffer), true); &reportSize, sizeof(reportBuffer), true);
if (setStep != 0) { if (setStep != 0) {
SerializeAdapter<uint8_t>::serialize(&setStep, &pBuffer, &reportSize, SerializeAdapter::serialize(&setStep, &pBuffer, &reportSize,
sizeof(reportBuffer), true); sizeof(reportBuffer), true);
} }
SerializeAdapter<ReturnValue_t>::serialize(&setErrorCode, &pBuffer, SerializeAdapter::serialize(&setErrorCode, &pBuffer,
&reportSize, sizeof(reportBuffer), true); &reportSize, sizeof(reportBuffer), true);
SerializeAdapter<uint32_t>::serialize(&parameter1, &pBuffer, &reportSize, SerializeAdapter::serialize(&parameter1, &pBuffer, &reportSize,
sizeof(reportBuffer), true); sizeof(reportBuffer), true);
SerializeAdapter<uint32_t>::serialize(&parameter2, &pBuffer, &reportSize, SerializeAdapter::serialize(&parameter2, &pBuffer, &reportSize,
sizeof(reportBuffer), true); sizeof(reportBuffer), true);
} }