pool raw access modified so vectors are properly serialized now
Endian swapper can swap the entries of a uint16,uint32 buffers now. Some documentation for functions added. setter function for serial buffer adapter written but does not appear to compile, commented out
This commit is contained in:
@ -31,7 +31,10 @@ ReturnValue_t PoolRawAccess::read() {
|
||||
sizeTillEnd = read_out->getByteSize() - arrayPosition;
|
||||
uint8_t* ptr =
|
||||
&((uint8_t*) read_out->getRawData())[arrayPosition];
|
||||
memcpy(value, ptr, typeSize);
|
||||
for(uint8_t arrayCount = 0; arrayCount < arraySize; arrayCount++) {
|
||||
memcpy(value + typeSize * arrayCount, ptr + typeSize * arrayCount, typeSize);
|
||||
}
|
||||
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
} else {
|
||||
//Error value type too large.
|
||||
@ -152,17 +155,20 @@ ReturnValue_t PoolRawAccess::serialize(uint8_t** buffer, uint32_t* size,
|
||||
#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 arrayCount = 0; arrayCount < arraySize; arrayCount++) {
|
||||
for (uint8_t count = 0; count < typeSize; count++) {
|
||||
(*buffer)[typeSize * (arrayCount + 1) - count - 1] =
|
||||
value[typeSize * arrayCount + count];
|
||||
}
|
||||
}
|
||||
#elif BYTE_ORDER_SYSTEM == BIG_ENDIAN
|
||||
memcpy(*buffer, value, typeSize);
|
||||
memcpy(*buffer, value, typeSize * arraySize);
|
||||
#endif
|
||||
} else {
|
||||
memcpy(*buffer, value, typeSize);
|
||||
memcpy(*buffer, value, typeSize * arraySize);
|
||||
}
|
||||
*size += typeSize;
|
||||
(*buffer) += typeSize;
|
||||
*size += typeSize * arraySize;
|
||||
(*buffer) += typeSize * arraySize;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
} else {
|
||||
return SerializeIF::BUFFER_TOO_SHORT;
|
||||
|
@ -48,7 +48,6 @@ private:
|
||||
ReadWriteMode_t readWriteMode;
|
||||
static const uint8_t RAW_MAX_SIZE = sizeof(double);
|
||||
protected:
|
||||
|
||||
/**
|
||||
* \brief The commit call writes back the variable's value to the data pool.
|
||||
* \details It checks type and size, as well as if the variable is writable. If so,
|
||||
@ -80,6 +79,20 @@ public:
|
||||
* The operation does NOT provide any mutual exclusive protection by itself.
|
||||
*/
|
||||
ReturnValue_t read();
|
||||
|
||||
/**
|
||||
* @brief Serialize raw pool entry into provided buffer directly
|
||||
* @details Should be called after read() call. Endianness can be specified too
|
||||
* @param buffer Provided buffer. Raw pool data will be copied here
|
||||
* @param size [out] Increment provided size value by serialized size
|
||||
* @param max_size Maximum allowed serialization size
|
||||
* @param bigEndian Specify endianess
|
||||
* @return - @c RETURN_OK if serialization was successfull
|
||||
* - @c SerializeIF::BUFFER_TOO_SHORT if range check failed
|
||||
*/
|
||||
ReturnValue_t serialize(uint8_t** buffer, uint32_t* size,
|
||||
const uint32_t max_size, bool bigEndian) const;
|
||||
|
||||
/**
|
||||
* \brief This operation returns a pointer to the entry fetched.
|
||||
* \details Return pointer to the buffer containing the raw data
|
||||
@ -142,9 +155,6 @@ public:
|
||||
*/
|
||||
uint16_t getSizeTillEnd() const;
|
||||
|
||||
ReturnValue_t serialize(uint8_t** buffer, uint32_t* size,
|
||||
const uint32_t max_size, bool bigEndian) const;
|
||||
|
||||
uint32_t getSerializedSize() const;
|
||||
|
||||
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
|
||||
|
Reference in New Issue
Block a user