working on updating SerializeIF, to quote Basti: This is going to be horrible
This commit is contained in:
parent
05c1330b68
commit
a42832ca01
@ -150,13 +150,13 @@ public:
|
||||
|
||||
virtual ReturnValue_t serialize(uint8_t** buffer, uint32_t* size,
|
||||
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);
|
||||
uint32_t i = 0;
|
||||
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);
|
||||
result = SerializeAdapter<T>::serialize(&theMap[i].second, buffer, size,
|
||||
result = SerializeAdapter::serialize(&theMap[i].second, buffer, size,
|
||||
max_size, bigEndian);
|
||||
++i;
|
||||
}
|
||||
@ -168,9 +168,9 @@ public:
|
||||
uint32_t i = 0;
|
||||
|
||||
for (i = 0; i < _size; ++i) {
|
||||
printSize += SerializeAdapter<key_t>::getSerializedSize(
|
||||
printSize += SerializeAdapter::getSerializedSize(
|
||||
&theMap[i].first);
|
||||
printSize += SerializeAdapter<T>::getSerializedSize(&theMap[i].second);
|
||||
printSize += SerializeAdapter::getSerializedSize(&theMap[i].second);
|
||||
}
|
||||
|
||||
return printSize;
|
||||
@ -178,16 +178,16 @@ public:
|
||||
|
||||
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
|
||||
bool bigEndian) {
|
||||
ReturnValue_t result = SerializeAdapter<uint32_t>::deSerialize(&this->_size,
|
||||
ReturnValue_t result = SerializeAdapter::deSerialize(&this->_size,
|
||||
buffer, size, bigEndian);
|
||||
if (this->_size > theMap.maxSize()) {
|
||||
return SerializeIF::TOO_MANY_ELEMENTS;
|
||||
}
|
||||
uint32_t i = 0;
|
||||
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);
|
||||
result = SerializeAdapter<T>::deSerialize(&theMap[i].second, buffer, size,
|
||||
result = SerializeAdapter::deSerialize(&theMap[i].second, buffer, size,
|
||||
bigEndian);
|
||||
++i;
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ public:
|
||||
|
||||
ReturnValue_t serialize(uint8_t** buffer, uint32_t* size,
|
||||
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){
|
||||
return result;
|
||||
}
|
||||
@ -78,17 +78,17 @@ public:
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
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){
|
||||
return result;
|
||||
}
|
||||
result = AutoSerializeAdapter::serialize(&this->storedPackets,buffer,size,max_size,bigEndian);
|
||||
result = SerializeAdapter::serialize(&this->storedPackets,buffer,size,max_size,bigEndian);
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
|
||||
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){
|
||||
return result;
|
||||
}
|
||||
@ -96,11 +96,11 @@ public:
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
return result;
|
||||
}
|
||||
result = AutoSerializeAdapter::deSerialize(&this->size,buffer,size,bigEndian);
|
||||
result = SerializeAdapter::deSerialize(&this->size,buffer,size,bigEndian);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
return result;
|
||||
}
|
||||
result = AutoSerializeAdapter::deSerialize(&this->storedPackets,buffer,size,bigEndian);
|
||||
result = SerializeAdapter::deSerialize(&this->storedPackets,buffer,size,bigEndian);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
return result;
|
||||
}
|
||||
@ -108,10 +108,10 @@ public:
|
||||
}
|
||||
|
||||
uint32_t getSerializedSize() const {
|
||||
uint32_t size = AutoSerializeAdapter::getSerializedSize(&blockStartAddress);
|
||||
uint32_t size = SerializeAdapter::getSerializedSize(&blockStartAddress);
|
||||
size += indexType.getSerializedSize();
|
||||
size += AutoSerializeAdapter::getSerializedSize(&this->size);
|
||||
size += AutoSerializeAdapter::getSerializedSize(&this->storedPackets);
|
||||
size += SerializeAdapter::getSerializedSize(&this->size);
|
||||
size += SerializeAdapter::getSerializedSize(&this->storedPackets);
|
||||
return size;
|
||||
}
|
||||
|
||||
@ -500,14 +500,14 @@ public:
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
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){
|
||||
return result;
|
||||
}
|
||||
|
||||
uint32_t i = 0;
|
||||
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);
|
||||
++i;
|
||||
}
|
||||
@ -515,7 +515,7 @@ public:
|
||||
return result;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
@ -531,10 +531,10 @@ public:
|
||||
size += additionalInfo->getSerializedSize();
|
||||
}
|
||||
size += currentWriteBlock->getSerializedSize();
|
||||
size += AutoSerializeAdapter::getSerializedSize(&this->size);
|
||||
size += SerializeAdapter::getSerializedSize(&this->size);
|
||||
size += (this->entries[0].getSerializedSize()) * this->size;
|
||||
uint16_t crc = 0;
|
||||
size += AutoSerializeAdapter::getSerializedSize(&crc);
|
||||
size += SerializeAdapter::getSerializedSize(&crc);
|
||||
return size;
|
||||
}
|
||||
/**
|
||||
@ -563,7 +563,7 @@ public:
|
||||
return result;
|
||||
}
|
||||
uint32_t tempSize = 0;
|
||||
result = AutoSerializeAdapter::deSerialize(&tempSize,buffer,size,bigEndian);
|
||||
result = SerializeAdapter::deSerialize(&tempSize,buffer,size,bigEndian);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK){
|
||||
return result;
|
||||
}
|
||||
@ -572,7 +572,7 @@ public:
|
||||
}
|
||||
uint32_t i = 0;
|
||||
while ((result == HasReturnvaluesIF::RETURN_OK) && (i < this->size)) {
|
||||
result = SerializeAdapter<Index<T> >::deSerialize(
|
||||
result = SerializeAdapter::deSerialize(
|
||||
&this->entries[i], buffer, size,
|
||||
bigEndian);
|
||||
++i;
|
||||
|
@ -39,18 +39,18 @@ ReturnValue_t DataPoolParameterWrapper::serialize(uint8_t** buffer,
|
||||
uint32_t* size, const uint32_t max_size, bool bigEndian) const {
|
||||
ReturnValue_t result;
|
||||
|
||||
result = SerializeAdapter<Type>::serialize(&type, buffer, size, max_size,
|
||||
result = SerializeAdapter::serialize(&type, buffer, size, max_size,
|
||||
bigEndian);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = SerializeAdapter<uint8_t>::serialize(&columns, buffer, size,
|
||||
result = SerializeAdapter::serialize(&columns, buffer, size,
|
||||
max_size, bigEndian);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = SerializeAdapter<uint8_t>::serialize(&rows, buffer, size, max_size,
|
||||
result = SerializeAdapter::serialize(&rows, buffer, size, max_size,
|
||||
bigEndian);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
|
@ -17,7 +17,7 @@ protected:
|
||||
uint8_t valid;
|
||||
ReturnValue_t read() {
|
||||
uint8_t arrayIndex = DataPool::PIDToArrayIndex(parameterId);
|
||||
PoolEntry<T>* read_out = ::dataPool.getData<T>(
|
||||
PoolEntry<T> *read_out = ::dataPool.getData<T>(
|
||||
DataPool::PIDToDataPoolId(parameterId), arrayIndex);
|
||||
if (read_out != NULL) {
|
||||
valid = read_out->valid;
|
||||
@ -43,7 +43,8 @@ protected:
|
||||
* Empty ctor for List initialization
|
||||
*/
|
||||
PIDReader() :
|
||||
parameterId(PoolVariableIF::NO_PARAMETER), valid(PoolVariableIF::INVALID), value(0) {
|
||||
parameterId(PoolVariableIF::NO_PARAMETER), valid(
|
||||
PoolVariableIF::INVALID), value(0) {
|
||||
|
||||
}
|
||||
public:
|
||||
@ -63,9 +64,9 @@ public:
|
||||
* \param setWritable If this flag is set to true, changes in the value attribute can be
|
||||
* written back to the data pool, otherwise not.
|
||||
*/
|
||||
PIDReader(uint32_t setParameterId, DataSetIF* dataSet) :
|
||||
parameterId(setParameterId), valid(
|
||||
PoolVariableIF::INVALID), value(0) {
|
||||
PIDReader(uint32_t setParameterId, DataSetIF *dataSet) :
|
||||
parameterId(setParameterId), valid(PoolVariableIF::INVALID), value(
|
||||
0) {
|
||||
if (dataSet != NULL) {
|
||||
dataSet->registerVariable(this);
|
||||
}
|
||||
@ -74,7 +75,7 @@ public:
|
||||
/**
|
||||
* 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) {
|
||||
}
|
||||
|
||||
@ -121,24 +122,25 @@ public:
|
||||
return value;
|
||||
}
|
||||
|
||||
PIDReader<T> &operator=(T newValue) {
|
||||
PIDReader<T>& operator=(T newValue) {
|
||||
value = newValue;
|
||||
return *this;
|
||||
}
|
||||
|
||||
virtual ReturnValue_t serialize(uint8_t** buffer, uint32_t* size,
|
||||
const uint32_t max_size, bool bigEndian) const {
|
||||
return SerializeAdapter<T>::serialize(&value, buffer, size, max_size,
|
||||
bigEndian);
|
||||
virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size,
|
||||
size_t maxSize, Endianness streamEndianness) const override {
|
||||
return SerializeAdapter::serialize(&value, buffer, size, maxSize,
|
||||
streamEndianness);
|
||||
}
|
||||
|
||||
virtual uint32_t getSerializedSize() const {
|
||||
return SerializeAdapter<T>::getSerializedSize(&value);
|
||||
virtual size_t getSerializedSize() const override {
|
||||
return SerializeAdapter::getSerializedSize(&value);
|
||||
}
|
||||
|
||||
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
|
||||
bool bigEndian) {
|
||||
return SerializeAdapter<T>::deSerialize(&value, buffer, size, bigEndian);
|
||||
virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
|
||||
Endianness streamEndianness) override {
|
||||
return SerializeAdapter::deSerialize(&value, buffer, size,
|
||||
streamEndianness);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -145,10 +145,12 @@ uint16_t PoolRawAccess::getSizeTillEnd() const {
|
||||
return sizeTillEnd;
|
||||
}
|
||||
|
||||
ReturnValue_t PoolRawAccess::serialize(uint8_t** buffer, uint32_t* size,
|
||||
const uint32_t max_size, bool bigEndian) const {
|
||||
if (typeSize + *size <= max_size) {
|
||||
if (bigEndian) {
|
||||
ReturnValue_t PoolRawAccess::serialize(uint8_t** buffer, size_t* size,
|
||||
size_t maxSize, Endianness streamEndianness) const {
|
||||
//TODO integer overflow
|
||||
if (typeSize + *size <= maxSize) {
|
||||
#error use endian swapper
|
||||
if (1) {
|
||||
#ifndef BYTE_ORDER_SYSTEM
|
||||
#error BYTE_ORDER_SYSTEM not defined
|
||||
#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;
|
||||
}
|
||||
|
||||
ReturnValue_t PoolRawAccess::deSerialize(const uint8_t** buffer, int32_t* size,
|
||||
bool bigEndian) {
|
||||
*size -= typeSize;
|
||||
if (*size >= 0) {
|
||||
ReturnValue_t PoolRawAccess::deSerialize(const uint8_t** buffer, size_t* size,
|
||||
Endianness streamEndianness) {
|
||||
|
||||
if (bigEndian) {
|
||||
if (*size >= typeSize) {
|
||||
*size -= typeSize;
|
||||
if (1) {
|
||||
#ifndef BYTE_ORDER_SYSTEM
|
||||
#error BYTE_ORDER_SYSTEM not defined
|
||||
#elif BYTE_ORDER_SYSTEM == LITTLE_ENDIAN
|
||||
|
@ -70,7 +70,7 @@ public:
|
||||
static const ReturnValue_t DATA_POOL_ACCESS_FAILED = MAKE_RETURN_CODE(0x02);
|
||||
uint8_t value[RAW_MAX_SIZE];
|
||||
PoolRawAccess(uint32_t data_pool_id, uint8_t arrayEntry,
|
||||
DataSetIF* data_set, ReadWriteMode_t setReadWriteMode =
|
||||
DataSetIF *data_set, ReadWriteMode_t setReadWriteMode =
|
||||
PoolVariableIF::VAR_READ);
|
||||
/**
|
||||
* \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
|
||||
* - \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);
|
||||
/**
|
||||
* 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
|
||||
* - \c RETURN_FAILED on failure
|
||||
*/
|
||||
ReturnValue_t setEntryFromBigEndian(const uint8_t* buffer,
|
||||
ReturnValue_t setEntryFromBigEndian(const uint8_t *buffer,
|
||||
uint32_t setSize);
|
||||
/**
|
||||
* \brief This operation returns the type of the entry currently stored.
|
||||
@ -140,13 +140,13 @@ public:
|
||||
*/
|
||||
uint16_t getSizeTillEnd() const;
|
||||
|
||||
ReturnValue_t serialize(uint8_t** buffer, uint32_t* size,
|
||||
const uint32_t max_size, bool bigEndian) const;
|
||||
ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
||||
Endianness streamEndianness) const override;
|
||||
|
||||
uint32_t getSerializedSize() const;
|
||||
size_t getSerializedSize() const override;
|
||||
|
||||
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
|
||||
bool bigEndian);
|
||||
ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
|
||||
Endianness streamEndianness) override;
|
||||
};
|
||||
|
||||
#endif /* POOLRAWACCESS_H_ */
|
||||
|
@ -58,7 +58,7 @@ protected:
|
||||
* The operation does NOT provide any mutual exclusive protection by itself.
|
||||
*/
|
||||
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) {
|
||||
valid = read_out->valid;
|
||||
value = *(read_out->address);
|
||||
@ -79,7 +79,7 @@ protected:
|
||||
*
|
||||
*/
|
||||
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)) {
|
||||
write_back->valid = valid;
|
||||
*(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
|
||||
* 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) :
|
||||
dataPoolId(set_id), valid(PoolVariableIF::INVALID), readWriteMode(
|
||||
setReadWriteMode), value(0) {
|
||||
@ -126,7 +126,7 @@ public:
|
||||
/**
|
||||
* Copy ctor to copy classes containing Pool Variables.
|
||||
*/
|
||||
PoolVariable(const PoolVariable& rhs) :
|
||||
PoolVariable(const PoolVariable &rhs) :
|
||||
dataPoolId(rhs.dataPoolId), valid(rhs.valid), readWriteMode(
|
||||
rhs.readWriteMode), value(rhs.value) {
|
||||
}
|
||||
@ -184,29 +184,29 @@ public:
|
||||
return value;
|
||||
}
|
||||
|
||||
PoolVariable<T> &operator=(T newValue) {
|
||||
PoolVariable<T>& operator=(T newValue) {
|
||||
value = newValue;
|
||||
return *this;
|
||||
}
|
||||
|
||||
PoolVariable<T> &operator=(PoolVariable<T> newPoolVariable) {
|
||||
PoolVariable<T>& operator=(PoolVariable<T> newPoolVariable) {
|
||||
value = newPoolVariable.value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
virtual ReturnValue_t serialize(uint8_t** buffer, uint32_t* size,
|
||||
const uint32_t max_size, bool bigEndian) const {
|
||||
return SerializeAdapter<T>::serialize(&value, buffer, size, max_size,
|
||||
bigEndian);
|
||||
virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size,
|
||||
size_t max_size, Endianness streamEndianness) const override {
|
||||
return SerializeAdapter::serialize<T>(&value, buffer, size, max_size,
|
||||
streamEndianness);
|
||||
}
|
||||
|
||||
virtual uint32_t getSerializedSize() const {
|
||||
return SerializeAdapter<T>::getSerializedSize(&value);
|
||||
virtual uint32_t getSerializedSize() const override {
|
||||
return SerializeAdapter::getSerializedSize(&value);
|
||||
}
|
||||
|
||||
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
|
||||
bool bigEndian) {
|
||||
return SerializeAdapter<T>::deSerialize(&value, buffer, size, bigEndian);
|
||||
virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
|
||||
Endianness streamEndianness) override {
|
||||
return SerializeAdapter::deSerialize(&value, buffer, size, streamEndianness);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -202,7 +202,7 @@ public:
|
||||
uint16_t i;
|
||||
ReturnValue_t result;
|
||||
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);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
@ -212,7 +212,7 @@ public:
|
||||
}
|
||||
|
||||
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,
|
||||
@ -220,7 +220,7 @@ public:
|
||||
uint16_t i;
|
||||
ReturnValue_t result;
|
||||
for (i = 0; i < vector_size; i++) {
|
||||
result = SerializeAdapter<T>::deSerialize(&(value[i]), buffer, size,
|
||||
result = SerializeAdapter::deSerialize(&(value[i]), buffer, size,
|
||||
bigEndian);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
|
@ -13,12 +13,12 @@ DeviceTmReportingWrapper::~DeviceTmReportingWrapper() {
|
||||
|
||||
ReturnValue_t DeviceTmReportingWrapper::serialize(uint8_t** buffer,
|
||||
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);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = SerializeAdapter<ActionId_t>::serialize(&actionId, buffer,
|
||||
result = SerializeAdapter::serialize(&actionId, buffer,
|
||||
size, max_size, bigEndian);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
@ -32,12 +32,12 @@ uint32_t DeviceTmReportingWrapper::getSerializedSize() const {
|
||||
|
||||
ReturnValue_t DeviceTmReportingWrapper::deSerialize(const uint8_t** buffer,
|
||||
int32_t* size, bool bigEndian) {
|
||||
ReturnValue_t result = SerializeAdapter<object_id_t>::deSerialize(&objectId,
|
||||
ReturnValue_t result = SerializeAdapter::deSerialize(&objectId,
|
||||
buffer, size, bigEndian);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = SerializeAdapter<ActionId_t>::deSerialize(&actionId, buffer,
|
||||
result = SerializeAdapter::deSerialize(&actionId, buffer,
|
||||
size, bigEndian);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
|
@ -68,13 +68,13 @@ ReturnValue_t Type::serialize(uint8_t** buffer, uint32_t* size,
|
||||
return result;
|
||||
}
|
||||
|
||||
result = SerializeAdapter<uint8_t>::serialize(&ptc, buffer, size, max_size,
|
||||
result = SerializeAdapter::serialize(&ptc, buffer, size, max_size,
|
||||
bigEndian);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = SerializeAdapter<uint8_t>::serialize(&pfc, buffer, size, max_size,
|
||||
result = SerializeAdapter::serialize(&pfc, buffer, size, max_size,
|
||||
bigEndian);
|
||||
|
||||
return result;
|
||||
@ -83,20 +83,20 @@ ReturnValue_t Type::serialize(uint8_t** buffer, uint32_t* size,
|
||||
|
||||
uint32_t Type::getSerializedSize() const {
|
||||
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,
|
||||
bool bigEndian) {
|
||||
uint8_t ptc;
|
||||
uint8_t pfc;
|
||||
ReturnValue_t result = SerializeAdapter<uint8_t>::deSerialize(&ptc, buffer,
|
||||
ReturnValue_t result = SerializeAdapter::deSerialize(&ptc, buffer,
|
||||
size, bigEndian);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = SerializeAdapter<uint8_t>::deSerialize(&pfc, buffer, size,
|
||||
result = SerializeAdapter::deSerialize(&pfc, buffer, size,
|
||||
bigEndian);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
|
@ -22,7 +22,7 @@ public:
|
||||
|
||||
Type(ActualType_t actualType);
|
||||
|
||||
Type(const Type& type);
|
||||
Type(const Type &type);
|
||||
|
||||
Type& operator=(Type rhs);
|
||||
|
||||
@ -30,8 +30,8 @@ public:
|
||||
|
||||
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;
|
||||
|
||||
@ -39,13 +39,13 @@ public:
|
||||
|
||||
static ActualType_t getActualType(uint8_t ptc, uint8_t pfc);
|
||||
|
||||
virtual ReturnValue_t serialize(uint8_t** buffer, uint32_t* size,
|
||||
const uint32_t max_size, bool bigEndian) const;
|
||||
virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size,
|
||||
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,
|
||||
bool bigEndian);
|
||||
virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
|
||||
Endianness streamEndianness) override;
|
||||
|
||||
private:
|
||||
ActualType_t actualType;
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
const uint32_t max_size, bool bigEndian) const {
|
||||
iterator iter = this->begin();
|
||||
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);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include <framework/globalfunctions/matching/SerializeableMatcherIF.h>
|
||||
#include <framework/serialize/SerializeAdapter.h>
|
||||
|
||||
|
||||
template<typename T>
|
||||
class RangeMatcher: public SerializeableMatcherIF<T> {
|
||||
public:
|
||||
@ -27,34 +26,40 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t serialize(uint8_t** buffer, uint32_t* size,
|
||||
const uint32_t max_size, bool bigEndian) const {
|
||||
ReturnValue_t result = SerializeAdapter<T>::serialize(&lowerBound, buffer, size, max_size, bigEndian);
|
||||
ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t max_size,
|
||||
SerializeIF::Endianness streamEndianness) const override {
|
||||
ReturnValue_t result = SerializeAdapter::serialize(&lowerBound, buffer,
|
||||
size, max_size, streamEndianness);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
|
||||
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
|
||||
bool bigEndian) {
|
||||
ReturnValue_t result = SerializeAdapter<T>::deSerialize(&lowerBound, buffer, size, bigEndian);
|
||||
ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
|
||||
SerializeIF::Endianness streamEndianness) override {
|
||||
ReturnValue_t result = SerializeAdapter::deSerialize(&lowerBound,
|
||||
buffer, size, streamEndianness);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = SerializeAdapter<T>::deSerialize(&upperBound, buffer, size, bigEndian);
|
||||
result = SerializeAdapter::deSerialize(&upperBound, buffer, size,
|
||||
streamEndianness);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
return SerializeAdapter<bool>::deSerialize(&inverted, buffer, size, bigEndian);
|
||||
return SerializeAdapter::deSerialize(&inverted, buffer, size,
|
||||
streamEndianness);
|
||||
}
|
||||
protected:
|
||||
bool doMatch(T input) {
|
||||
|
@ -67,16 +67,16 @@ void HealthTable::printAll(uint8_t* pointer, uint32_t maxSize) {
|
||||
mutex->lockMutex(MutexIF::NO_TIMEOUT);
|
||||
uint32_t size = 0;
|
||||
uint16_t count = healthMap.size();
|
||||
ReturnValue_t result = SerializeAdapter<uint16_t>::serialize(&count,
|
||||
ReturnValue_t result = SerializeAdapter::serialize(&count,
|
||||
&pointer, &size, maxSize, true);
|
||||
HealthMap::iterator iter;
|
||||
for (iter = healthMap.begin();
|
||||
iter != healthMap.end() && result == HasReturnvaluesIF::RETURN_OK;
|
||||
++iter) {
|
||||
result = SerializeAdapter<object_id_t>::serialize(&iter->first,
|
||||
result = SerializeAdapter::serialize(&iter->first,
|
||||
&pointer, &size, maxSize, true);
|
||||
uint8_t health = iter->second;
|
||||
result = SerializeAdapter<uint8_t>::serialize(&health, &pointer, &size,
|
||||
result = SerializeAdapter::serialize(&health, &pointer, &size,
|
||||
maxSize, true);
|
||||
}
|
||||
mutex->unlockMutex();
|
||||
|
@ -53,7 +53,7 @@ void MemoryHelper::completeLoad(ReturnValue_t errorCode,
|
||||
memcpy(copyHere, dataToCopy, size);
|
||||
break;
|
||||
case HasMemoryIF::POINTS_TO_VARIABLE:
|
||||
EndianSwapper::swap(copyHere, dataToCopy, size);
|
||||
EndianConverter::convertBigEndian(copyHere, dataToCopy, size);
|
||||
break;
|
||||
case HasMemoryIF::ACTIVITY_COMPLETED:
|
||||
case RETURN_OK:
|
||||
@ -86,7 +86,7 @@ void MemoryHelper::completeDump(ReturnValue_t errorCode,
|
||||
case HasMemoryIF::POINTS_TO_VARIABLE:
|
||||
//"data" must be valid pointer!
|
||||
if (errorCode == HasMemoryIF::POINTS_TO_VARIABLE) {
|
||||
EndianSwapper::swap(reservedSpaceInIPC, dataToCopy, size);
|
||||
EndianConverter::convertBigEndian(reservedSpaceInIPC, dataToCopy, size);
|
||||
} else {
|
||||
memcpy(reservedSpaceInIPC, dataToCopy, size);
|
||||
}
|
||||
@ -136,7 +136,7 @@ void MemoryHelper::swapMatrixCopy(uint8_t* out, const uint8_t *in,
|
||||
}
|
||||
|
||||
while (totalSize > 0){
|
||||
EndianSwapper::swap(out,in,datatypeSize);
|
||||
EndianConverter::convertBigEndian(out,in,datatypeSize);
|
||||
out += datatypeSize;
|
||||
in += datatypeSize;
|
||||
totalSize -= datatypeSize;
|
||||
|
@ -91,7 +91,7 @@ void CpuUsage::clear() {
|
||||
|
||||
ReturnValue_t CpuUsage::serialize(uint8_t** buffer, uint32_t* size,
|
||||
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);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
@ -111,7 +111,7 @@ uint32_t CpuUsage::getSerializedSize() const {
|
||||
|
||||
ReturnValue_t CpuUsage::deSerialize(const uint8_t** buffer, int32_t* size,
|
||||
bool bigEndian) {
|
||||
ReturnValue_t result = SerializeAdapter<float>::deSerialize(
|
||||
ReturnValue_t result = SerializeAdapter::deSerialize(
|
||||
&timeSinceLastReset, buffer, size, bigEndian);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
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,
|
||||
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);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
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);
|
||||
*size += 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);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = SerializeAdapter<float>::serialize(&percentUsage,
|
||||
result = SerializeAdapter::serialize(&percentUsage,
|
||||
buffer, size, max_size, bigEndian);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
@ -159,7 +159,7 @@ uint32_t CpuUsage::ThreadData::getSerializedSize() const {
|
||||
|
||||
ReturnValue_t CpuUsage::ThreadData::deSerialize(const uint8_t** buffer,
|
||||
int32_t* size, bool bigEndian) {
|
||||
ReturnValue_t result = SerializeAdapter<uint32_t>::deSerialize(&id, buffer,
|
||||
ReturnValue_t result = SerializeAdapter::deSerialize(&id, buffer,
|
||||
size, bigEndian);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
@ -169,12 +169,12 @@ ReturnValue_t CpuUsage::ThreadData::deSerialize(const uint8_t** buffer,
|
||||
}
|
||||
memcpy(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);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = SerializeAdapter<float>::deSerialize(&percentUsage,
|
||||
result = SerializeAdapter::deSerialize(&percentUsage,
|
||||
buffer, size, bigEndian);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
|
@ -24,18 +24,18 @@ ReturnValue_t ParameterWrapper::serialize(uint8_t** buffer, uint32_t* size,
|
||||
const uint32_t max_size, bool bigEndian) const {
|
||||
ReturnValue_t result;
|
||||
|
||||
result = SerializeAdapter<Type>::serialize(&type, buffer, size, max_size,
|
||||
result = SerializeAdapter::serialize(&type, buffer, size, max_size,
|
||||
bigEndian);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = SerializeAdapter<uint8_t>::serialize(&columns, buffer, size,
|
||||
result = SerializeAdapter::serialize(&columns, buffer, size,
|
||||
max_size, bigEndian);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = SerializeAdapter<uint8_t>::serialize(&rows, buffer, size, max_size,
|
||||
result = SerializeAdapter::serialize(&rows, buffer, size, max_size,
|
||||
bigEndian);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
@ -94,7 +94,7 @@ ReturnValue_t ParameterWrapper::serializeData(uint8_t** buffer, uint32_t* size,
|
||||
ReturnValue_t result;
|
||||
uint16_t dataSize = columns * rows;
|
||||
while (dataSize != 0) {
|
||||
result = SerializeAdapter<T>::serialize(element, buffer, size, max_size,
|
||||
result = SerializeAdapter::serialize(element, buffer, size, max_size,
|
||||
bigEndian);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
@ -123,7 +123,7 @@ ReturnValue_t ParameterWrapper::deSerializeData(uint8_t startingRow,
|
||||
+ (((startingRow + fromRow) * columns) + startingColumn);
|
||||
|
||||
for (uint8_t fromColumn = 0; fromColumn < fromColumns; fromColumn++) {
|
||||
result = SerializeAdapter<T>::deSerialize(
|
||||
result = SerializeAdapter::deSerialize(
|
||||
dataWithDataType + fromColumn, &fromAsStream, &streamSize,
|
||||
true);
|
||||
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,
|
||||
const uint8_t **remainingStream, int32_t *remainingSize) {
|
||||
ReturnValue_t result = SerializeAdapter<Type>::deSerialize(&type, &stream,
|
||||
ReturnValue_t result = SerializeAdapter::deSerialize(&type, &stream,
|
||||
&streamSize, true);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = SerializeAdapter<uint8_t>::deSerialize(&columns, &stream,
|
||||
result = SerializeAdapter::deSerialize(&columns, &stream,
|
||||
&streamSize, true);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = SerializeAdapter<uint8_t>::deSerialize(&rows, &stream, &streamSize,
|
||||
result = SerializeAdapter::deSerialize(&rows, &stream, &streamSize,
|
||||
true);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
|
@ -54,7 +54,7 @@ public:
|
||||
const uint8_t *streamWithtype = (const uint8_t *) readonlyData;
|
||||
streamWithtype += (row * columns + column) * type.getSize();
|
||||
int32_t size = type.getSize();
|
||||
return SerializeAdapter<T>::deSerialize(value, &streamWithtype,
|
||||
return SerializeAdapter::deSerialize(value, &streamWithtype,
|
||||
&size, true);
|
||||
} else {
|
||||
const T *dataWithType = (const T *) readonlyData;
|
||||
|
@ -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,
|
||||
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);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
return SerializeAdapter<float>::serialize(&max, buffer, size, max_size,
|
||||
return SerializeAdapter::serialize(&max, buffer, size, max_size,
|
||||
bigEndian);
|
||||
}
|
||||
|
||||
@ -58,12 +58,12 @@ float PowerComponent::getMax() {
|
||||
|
||||
ReturnValue_t PowerComponent::deSerialize(const uint8_t** buffer, int32_t* size,
|
||||
bool bigEndian) {
|
||||
ReturnValue_t result = SerializeAdapter<float>::deSerialize(&min, buffer,
|
||||
ReturnValue_t result = SerializeAdapter::deSerialize(&min, buffer,
|
||||
size, bigEndian);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
return SerializeAdapter<float>::deSerialize(&max, buffer, size, bigEndian);
|
||||
return SerializeAdapter::deSerialize(&max, buffer, size, bigEndian);
|
||||
}
|
||||
|
||||
ReturnValue_t PowerComponent::getParameter(uint8_t domainId,
|
||||
|
@ -5,20 +5,20 @@
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
class EndianSwapper {
|
||||
class EndianConverter {
|
||||
private:
|
||||
EndianSwapper() {
|
||||
EndianConverter() {
|
||||
}
|
||||
;
|
||||
public:
|
||||
template<typename T>
|
||||
static T swap(T in) {
|
||||
static T convertBigEndian(T in) {
|
||||
#ifndef BYTE_ORDER_SYSTEM
|
||||
#error BYTE_ORDER_SYSTEM not defined
|
||||
#elif BYTE_ORDER_SYSTEM == LITTLE_ENDIAN
|
||||
T tmp;
|
||||
uint8_t *pointerOut = (uint8_t *) &tmp;
|
||||
uint8_t *pointerIn = (uint8_t *) ∈
|
||||
uint8_t *pointerOut = (uint8_t*) &tmp;
|
||||
uint8_t *pointerIn = (uint8_t*) ∈
|
||||
for (uint8_t count = 0; count < sizeof(T); count++) {
|
||||
pointerOut[sizeof(T) - count - 1] = pointerIn[count];
|
||||
}
|
||||
@ -29,7 +29,8 @@ public:
|
||||
#error Unknown Byte Order
|
||||
#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
|
||||
#error BYTE_ORDER_SYSTEM not defined
|
||||
#elif BYTE_ORDER_SYSTEM == LITTLE_ENDIAN
|
||||
@ -40,6 +41,39 @@ public:
|
||||
#elif BYTE_ORDER_SYSTEM == BIG_ENDIAN
|
||||
memcpy(out, in, size);
|
||||
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 *) ∈
|
||||
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
|
||||
}
|
||||
};
|
||||
|
@ -27,11 +27,11 @@ public:
|
||||
|
||||
static ReturnValue_t serialize(const ArrayList<T, count_t>* list, uint8_t** buffer, uint32_t* size,
|
||||
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);
|
||||
count_t i = 0;
|
||||
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);
|
||||
++i;
|
||||
}
|
||||
@ -47,7 +47,7 @@ public:
|
||||
count_t i = 0;
|
||||
|
||||
for (i = 0; i < list->size; ++i) {
|
||||
printSize += SerializeAdapter<T>::getSerializedSize(&list->entries[i]);
|
||||
printSize += SerializeAdapter::getSerializedSize(&list->entries[i]);
|
||||
}
|
||||
|
||||
return printSize;
|
||||
@ -61,7 +61,7 @@ public:
|
||||
static ReturnValue_t deSerialize(ArrayList<T, count_t>* list, const uint8_t** buffer, int32_t* size,
|
||||
bool bigEndian) {
|
||||
count_t tempSize = 0;
|
||||
ReturnValue_t result = SerializeAdapter<count_t>::deSerialize(&tempSize,
|
||||
ReturnValue_t result = SerializeAdapter::deSerialize(&tempSize,
|
||||
buffer, size, bigEndian);
|
||||
if (tempSize > list->maxSize()) {
|
||||
return SerializeIF::TOO_MANY_ELEMENTS;
|
||||
@ -69,7 +69,7 @@ public:
|
||||
list->size = tempSize;
|
||||
count_t i = 0;
|
||||
while ((result == HasReturnvaluesIF::RETURN_OK) && (i < list->size)) {
|
||||
result = SerializeAdapter<T>::deSerialize(
|
||||
result = SerializeAdapter::deSerialize(
|
||||
&list->front()[i], buffer, size,
|
||||
bigEndian);
|
||||
++i;
|
||||
|
@ -26,14 +26,14 @@ ReturnValue_t SerialBufferAdapter<T>::serialize(uint8_t** buffer, uint32_t* size
|
||||
const uint32_t max_size, bool bigEndian) const {
|
||||
uint32_t serializedLength = bufferLength;
|
||||
if (serializeLength) {
|
||||
serializedLength += AutoSerializeAdapter::getSerializedSize(
|
||||
serializedLength += SerializeAdapter::getSerializedSize(
|
||||
&bufferLength);
|
||||
}
|
||||
if (*size + serializedLength > max_size) {
|
||||
return BUFFER_TOO_SHORT;
|
||||
} else {
|
||||
if (serializeLength) {
|
||||
AutoSerializeAdapter::serialize(&bufferLength, buffer, size,
|
||||
SerializeAdapter::serialize(&bufferLength, buffer, size,
|
||||
max_size, bigEndian);
|
||||
}
|
||||
if (this->constBuffer != NULL) {
|
||||
@ -52,7 +52,7 @@ ReturnValue_t SerialBufferAdapter<T>::serialize(uint8_t** buffer, uint32_t* size
|
||||
template<typename T>
|
||||
uint32_t SerialBufferAdapter<T>::getSerializedSize() const {
|
||||
if (serializeLength) {
|
||||
return bufferLength + AutoSerializeAdapter::getSerializedSize(&bufferLength);
|
||||
return bufferLength + SerializeAdapter::getSerializedSize(&bufferLength);
|
||||
} else {
|
||||
return bufferLength;
|
||||
}
|
||||
@ -63,7 +63,7 @@ ReturnValue_t SerialBufferAdapter<T>::deSerialize(const uint8_t** buffer,
|
||||
//TODO Ignores Endian flag!
|
||||
if (buffer != NULL) {
|
||||
if(serializeLength){
|
||||
T serializedSize = AutoSerializeAdapter::getSerializedSize(
|
||||
T serializedSize = SerializeAdapter::getSerializedSize(
|
||||
&bufferLength);
|
||||
if((*size - bufferLength - serializedSize) >= 0){
|
||||
*buffer += serializedSize;
|
||||
|
@ -31,32 +31,32 @@ public:
|
||||
SinglyLinkedList<T>(), printCount(printCount) {
|
||||
}
|
||||
|
||||
virtual ReturnValue_t serialize(uint8_t** buffer, uint32_t* size,
|
||||
const uint32_t max_size, bool bigEndian) const {
|
||||
virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size,
|
||||
size_t maxSize, Endianness streamEndianness) const override {
|
||||
if (printCount) {
|
||||
count_t mySize = SinglyLinkedList<T>::getSize();
|
||||
ReturnValue_t result = SerializeAdapter<count_t>::serialize(&mySize,
|
||||
buffer, size, max_size, bigEndian);
|
||||
ReturnValue_t result = SerializeAdapter::serialize(&mySize,
|
||||
buffer, size, maxSize, streamEndianness);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return serialize(SinglyLinkedList<T>::start, buffer, size, max_size,
|
||||
bigEndian);
|
||||
return serialize(SinglyLinkedList<T>::start, buffer, size, maxSize,
|
||||
streamEndianness);
|
||||
}
|
||||
|
||||
static ReturnValue_t serialize(const LinkedElement<T>* element,
|
||||
uint8_t** buffer, uint32_t* size, const uint32_t max_size,
|
||||
bool bigEndian) {
|
||||
uint8_t** buffer, size_t* size, size_t maxSize,
|
||||
Endianness streamEndianness) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
while ((result == HasReturnvaluesIF::RETURN_OK) && (element != NULL)) {
|
||||
result = element->value->serialize(buffer, size, max_size,
|
||||
bigEndian);
|
||||
result = element->value->serialize(buffer, size, maxSize,
|
||||
streamEndianness);
|
||||
element = element->getNext();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
virtual uint32_t getSerializedSize() const {
|
||||
virtual size_t getSerializedSize() const override {
|
||||
if (printCount) {
|
||||
return SerialLinkedListAdapter<T>::getSerializedSize()
|
||||
+ sizeof(count_t);
|
||||
@ -64,8 +64,8 @@ public:
|
||||
return getSerializedSize(SinglyLinkedList<T>::start);
|
||||
}
|
||||
}
|
||||
static uint32_t getSerializedSize(const LinkedElement<T> *element) {
|
||||
uint32_t size = 0;
|
||||
static size_t getSerializedSize(const LinkedElement<T> *element) {
|
||||
size_t size = 0;
|
||||
while (element != NULL) {
|
||||
size += element->value->getSerializedSize();
|
||||
element = element->getNext();
|
||||
@ -73,16 +73,16 @@ public:
|
||||
return size;
|
||||
}
|
||||
|
||||
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
|
||||
bool bigEndian) {
|
||||
return deSerialize(SinglyLinkedList<T>::start, buffer, size, bigEndian);
|
||||
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||
Endianness streamEndianness) override {
|
||||
return deSerialize(SinglyLinkedList<T>::start, buffer, size, streamEndianness);
|
||||
}
|
||||
|
||||
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;
|
||||
while ((result == HasReturnvaluesIF::RETURN_OK) && (element != NULL)) {
|
||||
result = element->value->deSerialize(buffer, size, bigEndian);
|
||||
result = element->value->deSerialize(buffer, size, streamEndianness);
|
||||
element = element->getNext();
|
||||
}
|
||||
return result;
|
||||
|
@ -10,21 +10,51 @@
|
||||
/**
|
||||
* \ingroup serialize
|
||||
*/
|
||||
template<typename T, int>
|
||||
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) {
|
||||
uint32_t ignoredSize = 0;
|
||||
template<typename T>
|
||||
static ReturnValue_t serialize(const T *object, uint8_t **buffer,
|
||||
size_t *size, size_t maxSize, SerializeIF::Endianness streamEndianness) {
|
||||
InternalSerializeAdapter<T, IsDerivedFrom<T, SerializeIF>::Is> adapter;
|
||||
return adapter.serialize(object, buffer, size, maxSize,
|
||||
streamEndianness);
|
||||
}
|
||||
template<typename T>
|
||||
static uint32_t getSerializedSize(const T *object) {
|
||||
InternalSerializeAdapter<T, IsDerivedFrom<T, SerializeIF>::Is> adapter;
|
||||
return adapter.getSerializedSize(object);
|
||||
}
|
||||
template<typename T>
|
||||
static ReturnValue_t deSerialize(T *object, const uint8_t **buffer,
|
||||
size_t *size, SerializeIF::Endianness streamEndianness) {
|
||||
InternalSerializeAdapter<T, IsDerivedFrom<T, SerializeIF>::Is> adapter;
|
||||
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;
|
||||
if (bigEndian) {
|
||||
tmp = EndianSwapper::swap<T>(*object);
|
||||
} else {
|
||||
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);
|
||||
@ -35,17 +65,25 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t deSerialize(T* object, const uint8_t** buffer, int32_t* size,
|
||||
bool bigEndian) {
|
||||
ReturnValue_t deSerialize(T *object, const uint8_t **buffer,
|
||||
size_t *size, SerializeIF::Endianness streamEndianness) {
|
||||
T tmp;
|
||||
if (*size >= sizeof(T)) {
|
||||
*size -= sizeof(T);
|
||||
if (*size >= 0) {
|
||||
memcpy(&tmp, *buffer, sizeof(T));
|
||||
if (bigEndian) {
|
||||
*object = EndianSwapper::swap<T>(tmp);
|
||||
} else {
|
||||
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 {
|
||||
@ -53,73 +91,33 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t getSerializedSize(const T * object) {
|
||||
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;
|
||||
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, bigEndian);
|
||||
return object->serialize(buffer, size, max_size, streamEndianness);
|
||||
}
|
||||
uint32_t getSerializedSize(const T* object) const {
|
||||
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 {
|
||||
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:
|
||||
template<typename T>
|
||||
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);
|
||||
}
|
||||
template<typename T>
|
||||
static uint32_t getSerializedSize(const T* object) {
|
||||
SerializeAdapter_<T, IsDerivedFrom<T, SerializeIF>::Is> adapter;
|
||||
return adapter.getSerializedSize(object);
|
||||
}
|
||||
template<typename T>
|
||||
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);
|
||||
ReturnValue_t deSerialize(T *object, const uint8_t **buffer,
|
||||
size_t *size, SerializeIF::Endianness streamEndianness) {
|
||||
return object->deSerialize(buffer, size, streamEndianness);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
#endif /* SERIALIZEADAPTER_H_ */
|
||||
|
@ -9,41 +9,43 @@
|
||||
* \ingroup serialize
|
||||
*/
|
||||
template<typename T>
|
||||
class SerializeElement : public SerializeIF, public LinkedElement<SerializeIF> {
|
||||
class SerializeElement: public SerializeIF, public LinkedElement<SerializeIF> {
|
||||
public:
|
||||
template<typename... Args>
|
||||
SerializeElement(Args... args) : LinkedElement<SerializeIF>(this), entry(std::forward<Args>(args)...) {
|
||||
template<typename ... Args>
|
||||
SerializeElement(Args ... args) :
|
||||
LinkedElement<SerializeIF>(this), entry(std::forward<Args>(args)...) {
|
||||
|
||||
}
|
||||
SerializeElement() : LinkedElement<SerializeIF>(this) {
|
||||
SerializeElement() :
|
||||
LinkedElement<SerializeIF>(this) {
|
||||
}
|
||||
T entry;
|
||||
ReturnValue_t serialize(uint8_t** buffer, uint32_t* size,
|
||||
const uint32_t max_size, bool bigEndian) const {
|
||||
return SerializeAdapter<T>::serialize(&entry, buffer, size, max_size, bigEndian);
|
||||
ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
||||
Endianness streamEndianness) const override {
|
||||
return SerializeAdapter::serialize(&entry, buffer, size, maxSize,
|
||||
streamEndianness);
|
||||
}
|
||||
|
||||
uint32_t getSerializedSize() const {
|
||||
return SerializeAdapter<T>::getSerializedSize(&entry);
|
||||
uint32_t getSerializedSize() const override {
|
||||
return SerializeAdapter::getSerializedSize(&entry);
|
||||
}
|
||||
|
||||
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
|
||||
bool bigEndian) {
|
||||
return SerializeAdapter<T>::deSerialize(&entry, buffer, size, bigEndian);
|
||||
virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
|
||||
Endianness streamEndianness) override {
|
||||
return SerializeAdapter::deSerialize(&entry, buffer, size,
|
||||
streamEndianness);
|
||||
}
|
||||
operator T() {
|
||||
return entry;
|
||||
}
|
||||
|
||||
SerializeElement<T> &operator=(T newValue) {
|
||||
SerializeElement<T>& operator=(T newValue) {
|
||||
entry = newValue;
|
||||
return *this;
|
||||
}
|
||||
T *operator->() {
|
||||
T* operator->() {
|
||||
return &entry;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* SERIALIZEELEMENT_H_ */
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define SERIALIZEIF_H_
|
||||
|
||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/**
|
||||
* \defgroup serialize Serialization
|
||||
@ -14,6 +15,10 @@
|
||||
*/
|
||||
class SerializeIF {
|
||||
public:
|
||||
enum class Endianness : uint8_t {
|
||||
BIG, LITTLE, MACHINE
|
||||
};
|
||||
|
||||
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 STREAM_TOO_SHORT = MAKE_RETURN_CODE(2);
|
||||
@ -22,13 +27,13 @@ public:
|
||||
virtual ~SerializeIF() {
|
||||
}
|
||||
|
||||
virtual ReturnValue_t serialize(uint8_t** buffer, uint32_t* size,
|
||||
const uint32_t max_size, bool bigEndian) const = 0;
|
||||
virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size,
|
||||
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,
|
||||
bool bigEndian) = 0;
|
||||
virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
|
||||
Endianness streamEndianness) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
@ -169,7 +169,7 @@ ReturnValue_t Subsystem::handleCommandMessage(CommandMessage* message) {
|
||||
if (result == RETURN_OK) {
|
||||
Mode_t fallbackId;
|
||||
int32_t size = sizeRead;
|
||||
result = SerializeAdapter<Mode_t>::deSerialize(&fallbackId,
|
||||
result = SerializeAdapter::deSerialize(&fallbackId,
|
||||
&pointer, &size, true);
|
||||
if (result == RETURN_OK) {
|
||||
result = SerialArrayListAdapter<ModeListEntry>::deSerialize(
|
||||
|
@ -23,26 +23,26 @@ public:
|
||||
|
||||
ReturnValue_t result;
|
||||
|
||||
result = SerializeAdapter<uint32_t>::serialize(&value1, buffer, size,
|
||||
result = SerializeAdapter::serialize(&value1, buffer, size,
|
||||
max_size, bigEndian);
|
||||
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = SerializeAdapter<uint32_t>::serialize(&value2, buffer, size,
|
||||
result = SerializeAdapter::serialize(&value2, buffer, size,
|
||||
max_size, bigEndian);
|
||||
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = SerializeAdapter<uint8_t>::serialize(&value3, buffer, size,
|
||||
result = SerializeAdapter::serialize(&value3, buffer, size,
|
||||
max_size, bigEndian);
|
||||
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = SerializeAdapter<uint8_t>::serialize(&value4, buffer, size,
|
||||
result = SerializeAdapter::serialize(&value4, buffer, size,
|
||||
max_size, bigEndian);
|
||||
|
||||
return result;
|
||||
@ -57,25 +57,25 @@ public:
|
||||
bool bigEndian) {
|
||||
ReturnValue_t result;
|
||||
|
||||
result = SerializeAdapter<uint32_t>::deSerialize(&value1, buffer, size,
|
||||
result = SerializeAdapter::deSerialize(&value1, buffer, size,
|
||||
bigEndian);
|
||||
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = SerializeAdapter<uint32_t>::deSerialize(&value2, buffer, size,
|
||||
result = SerializeAdapter::deSerialize(&value2, buffer, size,
|
||||
bigEndian);
|
||||
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = SerializeAdapter<uint8_t>::deSerialize(&value3, buffer, size,
|
||||
result = SerializeAdapter::deSerialize(&value3, buffer, size,
|
||||
bigEndian);
|
||||
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = SerializeAdapter<uint8_t>::deSerialize(&value4, buffer, size,
|
||||
result = SerializeAdapter::deSerialize(&value4, buffer, size,
|
||||
bigEndian);
|
||||
|
||||
return result;
|
||||
|
@ -47,13 +47,13 @@ ReturnValue_t ThermalComponent::setLimits(const uint8_t* data, uint32_t size) {
|
||||
return MonitoringIF::INVALID_SIZE;
|
||||
}
|
||||
int32_t readSize = size;
|
||||
SerializeAdapter<float>::deSerialize(&nopParameters.lowerNopLimit, &data,
|
||||
SerializeAdapter::deSerialize(&nopParameters.lowerNopLimit, &data,
|
||||
&readSize, true);
|
||||
SerializeAdapter<float>::deSerialize(¶meters.lowerOpLimit, &data,
|
||||
SerializeAdapter::deSerialize(¶meters.lowerOpLimit, &data,
|
||||
&readSize, true);
|
||||
SerializeAdapter<float>::deSerialize(¶meters.upperOpLimit, &data,
|
||||
SerializeAdapter::deSerialize(¶meters.upperOpLimit, &data,
|
||||
&readSize, true);
|
||||
SerializeAdapter<float>::deSerialize(&nopParameters.upperNopLimit, &data,
|
||||
SerializeAdapter::deSerialize(&nopParameters.upperNopLimit, &data,
|
||||
&readSize, true);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
@ -34,12 +34,12 @@ public:
|
||||
uint16_t ssc;
|
||||
ReturnValue_t serialize(uint8_t** buffer, uint32_t* size,
|
||||
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);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
return SerializeAdapter<uint16_t>::serialize(&ssc, buffer, size,
|
||||
return SerializeAdapter::serialize(&ssc, buffer, size,
|
||||
max_size, bigEndian);
|
||||
|
||||
}
|
||||
@ -50,12 +50,12 @@ public:
|
||||
|
||||
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
|
||||
bool bigEndian) {
|
||||
ReturnValue_t result = SerializeAdapter<uint16_t>::deSerialize(&apid,
|
||||
ReturnValue_t result = SerializeAdapter::deSerialize(&apid,
|
||||
buffer, size, bigEndian);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
return SerializeAdapter<uint16_t>::deSerialize(&ssc, buffer, size,
|
||||
return SerializeAdapter::deSerialize(&ssc, buffer, size,
|
||||
bigEndian);
|
||||
}
|
||||
};
|
||||
@ -220,23 +220,23 @@ public:
|
||||
|
||||
ReturnValue_t serialize(uint8_t** buffer, uint32_t* size,
|
||||
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){
|
||||
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){
|
||||
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){
|
||||
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){
|
||||
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){
|
||||
return result;
|
||||
}
|
||||
@ -246,11 +246,11 @@ public:
|
||||
|
||||
uint32_t getSerializedSize() const {
|
||||
uint32_t size = 0;
|
||||
size += AutoSerializeAdapter::getSerializedSize(&apid);
|
||||
size += AutoSerializeAdapter::getSerializedSize(&sourceSequenceCount);
|
||||
size += AutoSerializeAdapter::getSerializedSize(&serviceType);
|
||||
size += AutoSerializeAdapter::getSerializedSize(&serviceSubtype);
|
||||
size += AutoSerializeAdapter::getSerializedSize(&subCounter);
|
||||
size += SerializeAdapter::getSerializedSize(&apid);
|
||||
size += SerializeAdapter::getSerializedSize(&sourceSequenceCount);
|
||||
size += SerializeAdapter::getSerializedSize(&serviceType);
|
||||
size += SerializeAdapter::getSerializedSize(&serviceSubtype);
|
||||
size += SerializeAdapter::getSerializedSize(&subCounter);
|
||||
SerialBufferAdapter<uint8_t> adapter(rawTimestamp,sizeof(rawTimestamp));
|
||||
size += adapter.getSerializedSize();
|
||||
return size;
|
||||
@ -259,27 +259,27 @@ public:
|
||||
|
||||
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
|
||||
bool bigEndian) {
|
||||
ReturnValue_t result = AutoSerializeAdapter::deSerialize(&apid, buffer,
|
||||
ReturnValue_t result = SerializeAdapter::deSerialize(&apid, buffer,
|
||||
size, bigEndian);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = AutoSerializeAdapter::deSerialize(&sourceSequenceCount, buffer,
|
||||
result = SerializeAdapter::deSerialize(&sourceSequenceCount, buffer,
|
||||
size, bigEndian);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = AutoSerializeAdapter::deSerialize(&serviceType, buffer, size,
|
||||
result = SerializeAdapter::deSerialize(&serviceType, buffer, size,
|
||||
bigEndian);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = AutoSerializeAdapter::deSerialize(&serviceSubtype, buffer,
|
||||
result = SerializeAdapter::deSerialize(&serviceSubtype, buffer,
|
||||
size, bigEndian);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
result = AutoSerializeAdapter::deSerialize(&subCounter, buffer, size,
|
||||
result = SerializeAdapter::deSerialize(&subCounter, buffer, size,
|
||||
bigEndian);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
|
@ -24,14 +24,14 @@ public:
|
||||
}
|
||||
ReturnValue_t serialize(uint8_t** buffer, uint32_t* size,
|
||||
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 {
|
||||
return SerializeAdapter<uint16_t>::getSerializedSize(&apid);
|
||||
return SerializeAdapter::getSerializedSize(&apid);
|
||||
}
|
||||
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
|
||||
bool bigEndian) {
|
||||
return SerializeAdapter<uint16_t>::deSerialize(&apid, buffer, size, bigEndian);
|
||||
return SerializeAdapter::deSerialize(&apid, buffer, size, bigEndian);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -24,14 +24,14 @@ public:
|
||||
}
|
||||
ReturnValue_t serialize(uint8_t** buffer, uint32_t* size,
|
||||
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 {
|
||||
return SerializeAdapter<uint8_t>::getSerializedSize(&service);
|
||||
return SerializeAdapter::getSerializedSize(&service);
|
||||
}
|
||||
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
|
||||
bool bigEndian) {
|
||||
return SerializeAdapter<uint8_t>::deSerialize(&service, buffer, size, bigEndian);
|
||||
return SerializeAdapter::deSerialize(&service, buffer, size, bigEndian);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -22,14 +22,14 @@ public:
|
||||
}
|
||||
ReturnValue_t serialize(uint8_t** buffer, uint32_t* size,
|
||||
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 {
|
||||
return SerializeAdapter<uint8_t>::getSerializedSize(&subService);
|
||||
return SerializeAdapter::getSerializedSize(&subService);
|
||||
}
|
||||
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
|
||||
bool bigEndian) {
|
||||
return SerializeAdapter<uint8_t>::deSerialize(&subService, buffer, size, bigEndian);
|
||||
return SerializeAdapter::deSerialize(&subService, buffer, size, bigEndian);
|
||||
}
|
||||
private:
|
||||
uint8_t subService;
|
||||
|
@ -236,7 +236,7 @@ void CommandingServiceBase::sendTmPacket(uint8_t subservice,
|
||||
uint8_t buffer[sizeof(object_id_t)];
|
||||
uint8_t* pBuffer = buffer;
|
||||
uint32_t size = 0;
|
||||
SerializeAdapter<object_id_t>::serialize(&objectId, &pBuffer, &size,
|
||||
SerializeAdapter::serialize(&objectId, &pBuffer, &size,
|
||||
sizeof(object_id_t), true);
|
||||
TmPacketStored tmPacketStored(this->apid, this->service, subservice,
|
||||
this->tmPacketCounter, data, dataLen, buffer, size);
|
||||
|
@ -108,12 +108,12 @@ PusSuccessReport::PusSuccessReport(uint16_t setPacketId,
|
||||
uint16_t setSequenceControl, uint8_t setStep) :
|
||||
reportSize(0), pBuffer(reportBuffer) {
|
||||
//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);
|
||||
SerializeAdapter<uint16_t>::serialize(&setSequenceControl, &pBuffer,
|
||||
SerializeAdapter::serialize(&setSequenceControl, &pBuffer,
|
||||
&reportSize, sizeof(reportBuffer), true);
|
||||
if (setStep != 0) {
|
||||
SerializeAdapter<uint8_t>::serialize(&setStep, &pBuffer, &reportSize,
|
||||
SerializeAdapter::serialize(&setStep, &pBuffer, &reportSize,
|
||||
sizeof(reportBuffer), true);
|
||||
}
|
||||
}
|
||||
@ -135,19 +135,19 @@ PusFailureReport::PusFailureReport(uint16_t setPacketId,
|
||||
uint8_t setStep, uint32_t parameter1, uint32_t parameter2) :
|
||||
reportSize(0), pBuffer(reportBuffer) {
|
||||
//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);
|
||||
SerializeAdapter<uint16_t>::serialize(&setSequenceControl, &pBuffer,
|
||||
SerializeAdapter::serialize(&setSequenceControl, &pBuffer,
|
||||
&reportSize, sizeof(reportBuffer), true);
|
||||
if (setStep != 0) {
|
||||
SerializeAdapter<uint8_t>::serialize(&setStep, &pBuffer, &reportSize,
|
||||
SerializeAdapter::serialize(&setStep, &pBuffer, &reportSize,
|
||||
sizeof(reportBuffer), true);
|
||||
}
|
||||
SerializeAdapter<ReturnValue_t>::serialize(&setErrorCode, &pBuffer,
|
||||
SerializeAdapter::serialize(&setErrorCode, &pBuffer,
|
||||
&reportSize, sizeof(reportBuffer), true);
|
||||
SerializeAdapter<uint32_t>::serialize(¶meter1, &pBuffer, &reportSize,
|
||||
SerializeAdapter::serialize(¶meter1, &pBuffer, &reportSize,
|
||||
sizeof(reportBuffer), true);
|
||||
SerializeAdapter<uint32_t>::serialize(¶meter2, &pBuffer, &reportSize,
|
||||
SerializeAdapter::serialize(¶meter2, &pBuffer, &reportSize,
|
||||
sizeof(reportBuffer), true);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user