From d7bff31a4cfd5e720847a0c9525a4099b97560ac Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Wed, 1 Jul 2020 14:17:55 +0200 Subject: [PATCH] compiling again --- datapool/DataSetBase.cpp | 8 +- datapool/DataSetBase.h | 5 +- datapool/PoolRawAccessHelper.cpp | 20 ++-- datapool/PoolRawAccessHelper.h | 6 +- datapoolglob/GlobalPoolVariable.h | 14 +-- datapoolglob/GlobalPoolVector.h | 4 +- datapoolglob/GlobalPoolVector.tpp | 16 ++-- datapoolglob/PIDReader.h | 6 +- datapoolglob/PoolRawAccess.cpp | 70 +++++++------- datapoolglob/PoolRawAccess.h | 14 +-- datapoollocal/LocalDataPoolManager.cpp | 7 +- datapoollocal/LocalDataSet.cpp | 12 ++- datapoollocal/LocalDataSet.h | 6 +- datapoollocal/LocalPoolVariable.h | 6 +- datapoollocal/LocalPoolVariable.tpp | 12 +-- datapoollocal/LocalPoolVector.h | 5 +- datapoollocal/LocalPoolVector.tpp | 16 ++-- health/HealthTableIF.h | 2 +- power/PowerComponent.h | 9 -- serialize/SerialBufferAdapter.cpp | 8 +- serialize/SerialFixedArrayListAdapter.h | 35 +++---- serialize/SerializeAdapter.h | 3 +- serialize/SerializeAdapterInternal.h | 118 ------------------------ tmtcpacket/pus/TmPacketStored.cpp | 2 +- 24 files changed, 144 insertions(+), 260 deletions(-) delete mode 100644 serialize/SerializeAdapterInternal.h diff --git a/datapool/DataSetBase.cpp b/datapool/DataSetBase.cpp index b788d05d..55801eb1 100644 --- a/datapool/DataSetBase.cpp +++ b/datapool/DataSetBase.cpp @@ -131,11 +131,11 @@ ReturnValue_t DataSetBase::unlockDataPool() { } ReturnValue_t DataSetBase::serialize(uint8_t** buffer, size_t* size, - const size_t maxSize, bool bigEndian) const { + const size_t maxSize, SerializeIF::Endianness streamEndianness) const { ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; for (uint16_t count = 0; count < fillCount; count++) { result = registeredVariables[count]->serialize(buffer, size, maxSize, - bigEndian); + streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } @@ -144,11 +144,11 @@ ReturnValue_t DataSetBase::serialize(uint8_t** buffer, size_t* size, } ReturnValue_t DataSetBase::deSerialize(const uint8_t** buffer, size_t* size, - bool bigEndian) { + SerializeIF::Endianness streamEndianness) { ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; for (uint16_t count = 0; count < fillCount; count++) { result = registeredVariables[count]->deSerialize(buffer, size, - bigEndian); + streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } diff --git a/datapool/DataSetBase.h b/datapool/DataSetBase.h index 8f7d892a..8eae6a09 100644 --- a/datapool/DataSetBase.h +++ b/datapool/DataSetBase.h @@ -105,10 +105,11 @@ public: /* SerializeIF implementations */ virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size, - const size_t maxSize, bool bigEndian) const override; + const size_t maxSize, + SerializeIF::Endianness streamEndianness) const override; virtual size_t getSerializedSize() const override; virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, - bool bigEndian) override; + SerializeIF::Endianness streamEndianness) override; // SHOULDDO we could use a linked list of datapool variables //!< This definition sets the maximum number of variables to diff --git a/datapool/PoolRawAccessHelper.cpp b/datapool/PoolRawAccessHelper.cpp index 6e289303..2324a56c 100644 --- a/datapool/PoolRawAccessHelper.cpp +++ b/datapool/PoolRawAccessHelper.cpp @@ -24,8 +24,9 @@ PoolRawAccessHelper::~PoolRawAccessHelper() { } ReturnValue_t PoolRawAccessHelper::serialize(uint8_t **buffer, size_t *size, - const size_t max_size, bool bigEndian) { - SerializationArgs serializationArgs = {buffer, size, max_size, bigEndian}; + const size_t max_size, SerializeIF::Endianness streamEndianness) { + SerializationArgs serializationArgs = {buffer, size, max_size, + streamEndianness}; ReturnValue_t result = RETURN_OK; size_t remainingParametersSize = numberOfParameters * 4; for(uint8_t count=0; count < numberOfParameters; count++) { @@ -44,9 +45,10 @@ ReturnValue_t PoolRawAccessHelper::serialize(uint8_t **buffer, size_t *size, } ReturnValue_t PoolRawAccessHelper::serializeWithValidityMask(uint8_t ** buffer, - size_t * size, const size_t max_size, bool bigEndian) { + size_t * size, const size_t max_size, + SerializeIF::Endianness streamEndianness) { ReturnValue_t result = RETURN_OK; - SerializationArgs argStruct = {buffer, size, max_size, bigEndian}; + SerializationArgs argStruct = {buffer, size, max_size, streamEndianness}; size_t remainingParametersSize = numberOfParameters * 4; uint8_t validityMaskSize = ceil((float)numberOfParameters/8.0); uint8_t validityMask[validityMaskSize]; @@ -76,8 +78,8 @@ ReturnValue_t PoolRawAccessHelper::serializeCurrentPoolEntryIntoBuffer( bool withValidMask, uint8_t * validityMask) { uint32_t currentPoolId; // Deserialize current pool ID from pool ID buffer - ReturnValue_t result = AutoSerializeAdapter::deSerialize(¤tPoolId, - &poolIdBuffer,remainingParameters, false); + ReturnValue_t result = SerializeAdapter::deSerialize(¤tPoolId, + &poolIdBuffer,remainingParameters, SerializeIF::Endianness::MACHINE); if(result != RETURN_OK) { sif::debug << std::hex << "PoolRawAccessHelper: Error deSeralizing " "pool IDs" << std::dec << std::endl; @@ -109,8 +111,8 @@ ReturnValue_t PoolRawAccessHelper::handlePoolEntrySerialization( GlobDataSet currentDataSet; //debug << "Current array position: " << (int)arrayPosition << std::endl; - PoolRawAccess currentPoolRawAccess(currentPoolId,arrayPosition, - ¤tDataSet,PoolVariableIF::VAR_READ); + PoolRawAccess currentPoolRawAccess(currentPoolId, arrayPosition, + ¤tDataSet, PoolVariableIF::VAR_READ); result = currentDataSet.read(); if (result != RETURN_OK) { @@ -137,7 +139,7 @@ ReturnValue_t PoolRawAccessHelper::handlePoolEntrySerialization( } result = currentDataSet.serialize(argStruct.buffer, argStruct.size, - argStruct.max_size, argStruct.bigEndian); + argStruct.max_size, argStruct.streamEndianness); if (result != RETURN_OK) { sif::debug << "Pool Raw Access Helper: Error serializing pool data with " "ID 0x" << std::hex << currentPoolId << " into send buffer " diff --git a/datapool/PoolRawAccessHelper.h b/datapool/PoolRawAccessHelper.h index 52d9ebe5..0d8f8d6d 100644 --- a/datapool/PoolRawAccessHelper.h +++ b/datapool/PoolRawAccessHelper.h @@ -43,7 +43,7 @@ public: * @c RETURN_FAILED on failure */ ReturnValue_t serialize(uint8_t ** buffer, size_t * size, - const size_t max_size, bool bigEndian); + const size_t max_size, SerializeIF::Endianness streamEndianness); /** * Serializes data pool entries into provided buffer with the validity mask buffer @@ -56,7 +56,7 @@ public: * @c RETURN_FAILED on failure */ ReturnValue_t serializeWithValidityMask(uint8_t ** buffer, size_t * size, - const size_t max_size, bool bigEndian); + const size_t max_size, SerializeIF::Endianness streamEndianness); private: @@ -71,7 +71,7 @@ private: uint8_t ** buffer; size_t * size; const size_t max_size; - bool bigEndian; + SerializeIF::Endianness streamEndianness; }; /** * Helper function to serialize single pool entries diff --git a/datapoolglob/GlobalPoolVariable.h b/datapoolglob/GlobalPoolVariable.h index 9e3eea0c..b4aa6c4c 100644 --- a/datapoolglob/GlobalPoolVariable.h +++ b/datapoolglob/GlobalPoolVariable.h @@ -181,18 +181,20 @@ public: } virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size, - const size_t max_size, bool bigEndian) const override { - return SerializeAdapter::serialize(&value, buffer, size, max_size, - bigEndian); + const size_t max_size, + SerializeIF::Endianness streamEndianness) const override { + return SerializeAdapter::serialize(&value, buffer, size, max_size, + streamEndianness); } virtual size_t getSerializedSize() const { - return SerializeAdapter::getSerializedSize(&value); + return SerializeAdapter::getSerializedSize(&value); } virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, - bool bigEndian) { - return SerializeAdapter::deSerialize(&value, buffer, size, bigEndian); + SerializeIF::Endianness streamEndianness) { + return SerializeAdapter::deSerialize(&value, buffer, size, + streamEndianness); } }; diff --git a/datapoolglob/GlobalPoolVector.h b/datapoolglob/GlobalPoolVector.h index 93092228..0e03f77d 100644 --- a/datapoolglob/GlobalPoolVector.h +++ b/datapoolglob/GlobalPoolVector.h @@ -109,10 +109,10 @@ public: const T &operator [](int i) const {return value[i];} virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size, - const size_t max_size, bool bigEndian) const override; + size_t max_size, Endianness streamEndianness) const override; virtual size_t getSerializedSize() const override; virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, - bool bigEndian) override; + Endianness streamEndianness) override; /** * @brief This is a call to read the array's values diff --git a/datapoolglob/GlobalPoolVector.tpp b/datapoolglob/GlobalPoolVector.tpp index 5710da57..ccf33138 100644 --- a/datapoolglob/GlobalPoolVector.tpp +++ b/datapoolglob/GlobalPoolVector.tpp @@ -79,12 +79,13 @@ inline ReturnValue_t GlobPoolVector::commitWithoutLock() { template inline ReturnValue_t GlobPoolVector::serialize(uint8_t** buffer, - size_t* size, const size_t max_size, bool bigEndian) const { + size_t* size, size_t max_size, + SerializeIF::Endianness streamEndianness) const { uint16_t i; ReturnValue_t result; for (i = 0; i < vectorSize; i++) { - result = SerializeAdapter::serialize(&(value[i]), buffer, size, - max_size, bigEndian); + result = SerializeAdapter::serialize(&(value[i]), buffer, size, + max_size, streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } @@ -94,17 +95,18 @@ inline ReturnValue_t GlobPoolVector::serialize(uint8_t** buffer, template inline size_t GlobPoolVector::getSerializedSize() const { - return vectorSize * SerializeAdapter::getSerializedSize(value); + return vectorSize * SerializeAdapter::getSerializedSize(value); } template inline ReturnValue_t GlobPoolVector::deSerialize( - const uint8_t** buffer, size_t* size, bool bigEndian) { + const uint8_t** buffer, size_t* size, + SerializeIF::Endianness streamEndianness) { uint16_t i; ReturnValue_t result; for (i = 0; i < vectorSize; i++) { - result = SerializeAdapter::deSerialize(&(value[i]), buffer, size, - bigEndian); + result = SerializeAdapter::deSerialize(&(value[i]), buffer, size, + streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } diff --git a/datapoolglob/PIDReader.h b/datapoolglob/PIDReader.h index 1b337f28..a1116040 100644 --- a/datapoolglob/PIDReader.h +++ b/datapoolglob/PIDReader.h @@ -16,9 +16,9 @@ protected: uint32_t parameterId; uint8_t valid; ReturnValue_t readWithoutLock() { - uint8_t arrayIndex = DataPool::PIDToArrayIndex(parameterId); - PoolEntry *read_out = ::dataPool.getData( - DataPool::PIDToDataPoolId(parameterId), arrayIndex); + uint8_t arrayIndex = GlobalDataPool::PIDToArrayIndex(parameterId); + PoolEntry *read_out = glob::dataPool.getData( + GlobalDataPool::PIDToDataPoolId(parameterId), arrayIndex); if (read_out != NULL) { valid = read_out->valid; value = read_out->address[arrayIndex]; diff --git a/datapoolglob/PoolRawAccess.cpp b/datapoolglob/PoolRawAccess.cpp index 39cfd58c..bec54ab3 100644 --- a/datapoolglob/PoolRawAccess.cpp +++ b/datapoolglob/PoolRawAccess.cpp @@ -145,27 +145,29 @@ ReturnValue_t PoolRawAccess::getEntryEndianSafe(uint8_t* buffer, ReturnValue_t PoolRawAccess::serialize(uint8_t** buffer, size_t* size, - const size_t max_size, bool bigEndian) const { - if (typeSize + *size <= max_size) { - if (bigEndian) { + size_t maxSize, Endianness streamEndianness) const { + //TODO integer overflow + if (typeSize + *size <= maxSize) { +#warning use endian swapper + if (1) { #ifndef BYTE_ORDER_SYSTEM #error BYTE_ORDER_SYSTEM not defined #elif BYTE_ORDER_SYSTEM == LITTLE_ENDIAN - for (uint8_t count = 0; count < typeSize; count++) { - (*buffer)[count] = value[typeSize - count - 1]; - } + for (uint8_t count = 0; count < typeSize; count++) { + (*buffer)[count] = value[typeSize - count - 1]; + } #elif BYTE_ORDER_SYSTEM == BIG_ENDIAN - memcpy(*buffer, value, typeSize); + memcpy(*buffer, value, typeSize); #endif - } else { - memcpy(*buffer, value, typeSize); - } - *size += typeSize; - (*buffer) += typeSize; - return HasReturnvaluesIF::RETURN_OK; - } else { - return SerializeIF::BUFFER_TOO_SHORT; - } + } else { + memcpy(*buffer, value, typeSize); + } + *size += typeSize; + (*buffer) += typeSize; + return HasReturnvaluesIF::RETURN_OK; + } else { + return SerializeIF::BUFFER_TOO_SHORT; + } } @@ -231,28 +233,26 @@ size_t PoolRawAccess::getSerializedSize() const { } ReturnValue_t PoolRawAccess::deSerialize(const uint8_t** buffer, size_t* size, - bool bigEndian) { - // TODO: Needs to be tested!!! - if (*size >= typeSize) { - *size -= typeSize; - if (bigEndian) { + Endianness streamEndianness) { + + if (*size >= typeSize) { + *size -= typeSize; + if (1) { #ifndef BYTE_ORDER_SYSTEM #error BYTE_ORDER_SYSTEM not defined #elif BYTE_ORDER_SYSTEM == LITTLE_ENDIAN - for (uint8_t count = 0; count < typeSize; count++) { - value[count] = (*buffer)[typeSize - count - 1]; - } + for (uint8_t count = 0; count < typeSize; count++) { + value[count] = (*buffer)[typeSize - count - 1]; + } #elif BYTE_ORDER_SYSTEM == BIG_ENDIAN - memcpy(value, *buffer, typeSize); + memcpy(value, *buffer, typeSize); #endif - } - else { - memcpy(value, *buffer, typeSize); - } - *buffer += typeSize; - return HasReturnvaluesIF::RETURN_OK; - } - else { - return SerializeIF::STREAM_TOO_SHORT; - } + } else { + memcpy(value, *buffer, typeSize); + } + *buffer += typeSize; + return HasReturnvaluesIF::RETURN_OK; + } else { + return SerializeIF::STREAM_TOO_SHORT; + } } diff --git a/datapoolglob/PoolRawAccess.h b/datapoolglob/PoolRawAccess.h index 60e3c71e..ea07356e 100644 --- a/datapoolglob/PoolRawAccess.h +++ b/datapoolglob/PoolRawAccess.h @@ -69,8 +69,13 @@ public: * @return - @c RETURN_OK if serialization was successfull * - @c SerializeIF::BUFFER_TOO_SHORT if range check failed */ - ReturnValue_t serialize(uint8_t** buffer, size_t* size, - const size_t max_size, bool bigEndian) const; + ReturnValue_t serialize(uint8_t **buffer, size_t *size, + size_t maxSize, Endianness streamEndianness) const override; + + size_t getSerializedSize() const override; + + ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, + Endianness streamEndianness) override; /** * With this method, the content can be set from a big endian buffer safely. @@ -130,11 +135,6 @@ public: */ uint16_t getSizeTillEnd() const; - size_t getSerializedSize() const; - - ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, - bool bigEndian); - /** * @brief This is a call to read the value from the global data pool. * @details diff --git a/datapoollocal/LocalDataPoolManager.cpp b/datapoollocal/LocalDataPoolManager.cpp index bb06206e..78116138 100644 --- a/datapoollocal/LocalDataPoolManager.cpp +++ b/datapoollocal/LocalDataPoolManager.cpp @@ -173,7 +173,7 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid) { } size_t size = 0; result = dataSet->serializeLocalPoolIds(&storePtr, &size, - expectedSize, false); + expectedSize, SerializeIF::Endianness::BIG); if(expectedSize != size) { sif::error << "HousekeepingManager::generateSetStructurePacket: " "Expected size is not equal to serialized size" << std::endl; @@ -198,10 +198,11 @@ ReturnValue_t LocalDataPoolManager::serializeHkPacketIntoStore( if(appendValidityBuffer) { result = dataSet->serializeWithValidityBuffer(&storePtr, - &size, hkSize, false); + &size, hkSize, SerializeIF::Endianness::MACHINE); } else { - result = dataSet->serialize(&storePtr, &size, hkSize, false); + result = dataSet->serialize(&storePtr, &size, hkSize, + SerializeIF::Endianness::MACHINE); } if(result != HasReturnvaluesIF::RETURN_OK) { diff --git a/datapoollocal/LocalDataSet.cpp b/datapoollocal/LocalDataSet.cpp index 3fc8592e..72d79103 100644 --- a/datapoollocal/LocalDataSet.cpp +++ b/datapoollocal/LocalDataSet.cpp @@ -32,7 +32,8 @@ ReturnValue_t LocalDataSet::lockDataPool(uint32_t timeoutMs) { } ReturnValue_t LocalDataSet::serializeWithValidityBuffer(uint8_t **buffer, - size_t *size, const size_t maxSize, bool bigEndian) const { + size_t *size, size_t maxSize, + SerializeIF::Endianness streamEndianness) const { ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; uint8_t validityMaskSize = std::ceil(static_cast(fillCount)/8.0); uint8_t validityMask[validityMaskSize]; @@ -52,7 +53,7 @@ ReturnValue_t LocalDataSet::serializeWithValidityBuffer(uint8_t **buffer, } } result = registeredVariables[count]->serialize(buffer, size, maxSize, - bigEndian); + streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } @@ -69,11 +70,12 @@ ReturnValue_t LocalDataSet::unlockDataPool() { } ReturnValue_t LocalDataSet::serializeLocalPoolIds(uint8_t** buffer, - size_t* size, const size_t maxSize, bool bigEndian) const { + size_t* size, size_t maxSize, + SerializeIF::Endianness streamEndianness) const { for (uint16_t count = 0; count < fillCount; count++) { lp_id_t currentPoolId = registeredVariables[count]->getDataPoolId(); - auto result = AutoSerializeAdapter::serialize(¤tPoolId, buffer, - size, maxSize, bigEndian); + auto result = SerializeAdapter::serialize(¤tPoolId, buffer, + size, maxSize, streamEndianness); if(result != HasReturnvaluesIF::RETURN_OK) { sif::warning << "LocalDataSet::serializeLocalPoolIds: Serialization" " error!" << std::endl; diff --git a/datapoollocal/LocalDataSet.h b/datapoollocal/LocalDataSet.h index aea699d8..e997b729 100644 --- a/datapoollocal/LocalDataSet.h +++ b/datapoollocal/LocalDataSet.h @@ -68,10 +68,12 @@ public: * @return */ ReturnValue_t serializeWithValidityBuffer(uint8_t** buffer, - size_t* size, const size_t maxSize, bool bigEndian) const; + size_t* size, size_t maxSize, + SerializeIF::Endianness streamEndianness) const; ReturnValue_t serializeLocalPoolIds(uint8_t** buffer, - size_t* size, const size_t maxSize, bool bigEndian) const; + size_t* size, size_t maxSize, + SerializeIF::Endianness streamEndianness) const; protected: private: /** diff --git a/datapoollocal/LocalPoolVariable.h b/datapoollocal/LocalPoolVariable.h index 4b6e24aa..98782b8d 100644 --- a/datapoollocal/LocalPoolVariable.h +++ b/datapoollocal/LocalPoolVariable.h @@ -84,11 +84,11 @@ public: void setValid(bool validity) override; uint8_t getValid() const; - ReturnValue_t serialize(uint8_t** buffer, size_t* size, - const size_t max_size, bool bigEndian) const override; + ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, + SerializeIF::Endianness streamEndianness) const override; virtual size_t getSerializedSize() const override; virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, - bool bigEndian) override; + SerializeIF::Endianness streamEndianness) override; /** * @brief This is a call to read the array's values diff --git a/datapoollocal/LocalPoolVariable.tpp b/datapoollocal/LocalPoolVariable.tpp index 9dcd0699..7f9fbf13 100644 --- a/datapoollocal/LocalPoolVariable.tpp +++ b/datapoollocal/LocalPoolVariable.tpp @@ -133,20 +133,20 @@ inline uint8_t LocalPoolVar::getValid() const { template inline ReturnValue_t LocalPoolVar::serialize(uint8_t** buffer, size_t* size, - const size_t max_size, bool bigEndian) const { - return AutoSerializeAdapter::serialize(&value, - buffer, size ,max_size, bigEndian); + const size_t max_size, SerializeIF::Endianness streamEndianness) const { + return SerializeAdapter::serialize(&value, + buffer, size ,max_size, streamEndianness); } template inline size_t LocalPoolVar::getSerializedSize() const { - return AutoSerializeAdapter::getSerializedSize(&value); + return SerializeAdapter::getSerializedSize(&value); } template inline ReturnValue_t LocalPoolVar::deSerialize(const uint8_t** buffer, - size_t* size, bool bigEndian) { - return AutoSerializeAdapter::deSerialize(&value, buffer, size, bigEndian); + size_t* size, SerializeIF::Endianness streamEndianness) { + return SerializeAdapter::deSerialize(&value, buffer, size, streamEndianness); } template diff --git a/datapoollocal/LocalPoolVector.h b/datapoollocal/LocalPoolVector.h index a8d0a7bb..f6532894 100644 --- a/datapoollocal/LocalPoolVector.h +++ b/datapoollocal/LocalPoolVector.h @@ -114,10 +114,11 @@ public: const T &operator [](int i) const; virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size, - const size_t max_size, bool bigEndian) const override; + const size_t maxSize, + SerializeIF::Endianness streamEndiannes) const override; virtual size_t getSerializedSize() const override; virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, - bool bigEndian) override; + SerializeIF::Endianness streamEndianness) override; /** * @brief This is a call to read the array's values diff --git a/datapoollocal/LocalPoolVector.tpp b/datapoollocal/LocalPoolVector.tpp index a18f8327..872c49ec 100644 --- a/datapoollocal/LocalPoolVector.tpp +++ b/datapoollocal/LocalPoolVector.tpp @@ -125,11 +125,12 @@ inline const T& LocalPoolVector::operator [](int i) const { template inline ReturnValue_t LocalPoolVector::serialize(uint8_t** buffer, - size_t* size, const size_t max_size, bool bigEndian) const { + size_t* size, size_t maxSize, + SerializeIF::Endianness streamEndianness) const { ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; for (uint16_t i = 0; i < vectorSize; i++) { - result = SerializeAdapter::serialize(&(value[i]), buffer, size, - max_size, bigEndian); + result = SerializeAdapter::serialize(&(value[i]), buffer, size, + maxSize, streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { break; } @@ -139,16 +140,17 @@ inline ReturnValue_t LocalPoolVector::serialize(uint8_t** buffer, template inline size_t LocalPoolVector::getSerializedSize() const { - return vectorSize * SerializeAdapter::getSerializedSize(value); + return vectorSize * SerializeAdapter::getSerializedSize(value); } template inline ReturnValue_t LocalPoolVector::deSerialize( - const uint8_t** buffer, size_t* size, bool bigEndian) { + const uint8_t** buffer, size_t* size, + SerializeIF::Endianness streamEndianness) { ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; for (uint16_t i = 0; i < vectorSize; i++) { - result = SerializeAdapter::deSerialize(&(value[i]), buffer, size, - bigEndian); + result = SerializeAdapter::deSerialize(&(value[i]), buffer, size, + streamEndianness); if (result != HasReturnvaluesIF::RETURN_OK) { break; } diff --git a/health/HealthTableIF.h b/health/HealthTableIF.h index c8d2c74a..e4606286 100644 --- a/health/HealthTableIF.h +++ b/health/HealthTableIF.h @@ -19,7 +19,7 @@ public: HasHealthIF::HealthState initilialState = HasHealthIF::HEALTHY) = 0; virtual uint32_t getPrintSize() = 0; - virtual void printAll(uint8_t *pointer, uint32_t maxSize) = 0; + virtual void printAll(uint8_t *pointer, size_t maxSize) = 0; protected: virtual ReturnValue_t iterate(std::pair *value, bool reset = false) = 0; diff --git a/power/PowerComponent.h b/power/PowerComponent.h index 1c550776..61ab3674 100644 --- a/power/PowerComponent.h +++ b/power/PowerComponent.h @@ -20,21 +20,12 @@ public: float getMax(); ReturnValue_t serialize(uint8_t** buffer, size_t* size, -<<<<<<< HEAD - const size_t max_size, bool bigEndian) const; - - size_t getSerializedSize() const; - - ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, - bool bigEndian); -======= size_t maxSize, Endianness streamEndianness) const override; size_t getSerializedSize() const override; ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) override; ->>>>>>> upstream/mohr_serialize ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId, ParameterWrapper *parameterWrapper, diff --git a/serialize/SerialBufferAdapter.cpp b/serialize/SerialBufferAdapter.cpp index 69f40a34..1224bba1 100644 --- a/serialize/SerialBufferAdapter.cpp +++ b/serialize/SerialBufferAdapter.cpp @@ -36,18 +36,18 @@ ReturnValue_t SerialBufferAdapter::serialize(uint8_t** buffer, size_t* size, maxSize, streamEndianness); } if (constBuffer != nullptr) { - memcpy(*buffer_, this->constBuffer, bufferLength); + memcpy(*buffer, this->constBuffer, bufferLength); } else if (buffer != nullptr) { // This will propably be never reached, constBuffer should always be // set if non-const buffer is set. - memcpy(*buffer_, this->buffer, bufferLength); + memcpy(*buffer, this->buffer, bufferLength); } else { return HasReturnvaluesIF::RETURN_FAILED; } - *size_ += bufferLength; - (*buffer_) += bufferLength; + *size += bufferLength; + (*buffer) += bufferLength; return HasReturnvaluesIF::RETURN_OK; } } diff --git a/serialize/SerialFixedArrayListAdapter.h b/serialize/SerialFixedArrayListAdapter.h index 6ad154a8..196af67c 100644 --- a/serialize/SerialFixedArrayListAdapter.h +++ b/serialize/SerialFixedArrayListAdapter.h @@ -39,30 +39,25 @@ public: */ template SerialFixedArrayListAdapter(Args... args) : - FixedArrayList(std::forward(args)...) - {} + FixedArrayList( + std::forward(args)...){} - virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size, - const size_t max_size, bool bigEndian) const override { - return SerialArrayListAdapter::serialize(this, - buffer, size, max_size, bigEndian); - } + ReturnValue_t serialize(uint8_t** buffer, size_t* size, + size_t maxSize, Endianness streamEndianness) const { + return SerialArrayListAdapter::serialize(this, + buffer, size, maxSize, streamEndianness); + } - ReturnValue_t serialize(uint8_t** buffer, size_t* size, - size_t maxSize, Endianness streamEndianness) const { - return SerialArrayListAdapter::serialize(this, buffer, size, maxSize, streamEndianness); - } + size_t getSerializedSize() const { + return SerialArrayListAdapter::getSerializedSize(this); + } - size_t getSerializedSize() const { - return SerialArrayListAdapter::getSerializedSize(this); - } + ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, + Endianness streamEndianness) { + return SerialArrayListAdapter::deSerialize(this, + buffer, size, streamEndianness); + } - ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, - Endianness streamEndianness) { - return SerialArrayListAdapter::deSerialize(this, buffer, size, streamEndianness); - } }; - - #endif /* SERIALFIXEDARRAYLISTADAPTER_H_ */ diff --git a/serialize/SerializeAdapter.h b/serialize/SerializeAdapter.h index f8042861..2be39d5c 100644 --- a/serialize/SerializeAdapter.h +++ b/serialize/SerializeAdapter.h @@ -2,8 +2,9 @@ #define SERIALIZEADAPTER_H_ #include +#include +#include #include -#include #include /** diff --git a/serialize/SerializeAdapterInternal.h b/serialize/SerializeAdapterInternal.h deleted file mode 100644 index c57af0c9..00000000 --- a/serialize/SerializeAdapterInternal.h +++ /dev/null @@ -1,118 +0,0 @@ -/** - * @file SerializeAdapterInternal.h - * - * @date 13.04.2020 - * @author R. Mueller - */ - -#ifndef FRAMEWORK_SERIALIZE_SERIALIZEADAPTERINTERNAL_H_ -#define FRAMEWORK_SERIALIZE_SERIALIZEADAPTERINTERNAL_H_ -#include -#include -#include - -/** - * This template specialization will be chosen for fundamental types or - * anything else not implementing SerializeIF, based on partial - * template specialization. - * @tparam T - * @tparam - */ -template -class SerializeAdapter_ { -public: - /** - * - * @param object - * @param buffer - * @param size - * @param max_size - * @param bigEndian - * @return - */ - static ReturnValue_t serialize(const T* object, uint8_t** buffer, - size_t* size, const size_t max_size, bool bigEndian) { - // function eventuelly serializes structs here. - // does this work on every architecture? - // static_assert(std::is_fundamental::value); - size_t ignoredSize = 0; - if (size == nullptr) { - size = &ignoredSize; - } - if (sizeof(T) + *size <= max_size) { - T tmp; - if (bigEndian) { - tmp = EndianSwapper::swap(*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; - } - } - - /** - * Deserialize buffer into object - * @param object [out] Object to be deserialized with buffer data - * @param buffer contains the data. Non-Const pointer to non-const - * pointer to const data. - * @param size Size to deSerialize. wil be decremented by sizeof(T) - * @param bigEndian Specify endianness - * @return - */ - ReturnValue_t deSerialize(T* object, const uint8_t** buffer, size_t* size, - bool bigEndian) { - T tmp; - if (*size >= sizeof(T)) { - *size -= sizeof(T); - memcpy(&tmp, *buffer, sizeof(T)); - if (bigEndian) { - *object = EndianSwapper::swap(tmp); - } else { - *object = tmp; - } - *buffer += sizeof(T); - return HasReturnvaluesIF::RETURN_OK; - } else { - return SerializeIF::STREAM_TOO_SHORT; - } - } - - size_t getSerializedSize(const T * object) { - return sizeof(T); - } -}; - -/** - * This template specialization will be chosen for class derived from - * SerializeIF, based on partial template specialization. - * @tparam T - * @tparam - */ -template -class SerializeAdapter_ { -public: - ReturnValue_t serialize(const T* object, uint8_t** buffer, size_t* size, - const size_t max_size, bool bigEndian) const { - size_t ignoredSize = 0; - if (size == NULL) { - size = &ignoredSize; - } - return object->serialize(buffer, size, max_size, bigEndian); - } - - size_t getSerializedSize(const T* object) const { - return object->getSerializedSize(); - } - - ReturnValue_t deSerialize(T* object, const uint8_t** buffer, size_t* size, - bool bigEndian) { - return object->deSerialize(buffer, size, bigEndian); - } -}; - -#endif /* FRAMEWORK_SERIALIZE_SERIALIZEADAPTERINTERNAL_H_ */ diff --git a/tmtcpacket/pus/TmPacketStored.cpp b/tmtcpacket/pus/TmPacketStored.cpp index 14cf6a03..d6a4a69f 100644 --- a/tmtcpacket/pus/TmPacketStored.cpp +++ b/tmtcpacket/pus/TmPacketStored.cpp @@ -84,7 +84,7 @@ void TmPacketStored::deletePacket() { void TmPacketStored::setStoreAddress(store_address_t setAddress) { storeAddress = setAddress; const uint8_t *temp_data = NULL; - uint32_t temp_size; + size_t temp_size; if (!checkAndSetStore()) { return; }