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:
2019-12-09 12:27:14 +01:00
parent 8168885dd9
commit e765f8c99b
6 changed files with 62 additions and 11 deletions
+13 -7
View File
@@ -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;