1
0
forked from fsfw/fsfw

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

View File

@ -44,6 +44,27 @@ public:
#elif BYTE_ORDER_SYSTEM == BIG_ENDIAN
memcpy(out, in, size);
return;
#endif
}
template<typename T>
static void swap(T * out, const T * in, uint32_t size) {
#ifndef BYTE_ORDER_SYSTEM
#error BYTE_ORDER_SYSTEM not defined
#elif BYTE_ORDER_SYSTEM == LITTLE_ENDIAN
const uint8_t * in_buffer = reinterpret_cast<const uint8_t *>(in);
uint8_t * out_buffer = reinterpret_cast<uint8_t *>(out);
for (uint8_t count = 0; count < size; count++) {
for(uint8_t i = 0; i < sizeof(T);i++) {
out_buffer[sizeof(T)* (count + 1) - i - 1] = in_buffer[count * sizeof(T) + i];
}
}
return;
#elif BYTE_ORDER_SYSTEM == BIG_ENDIAN
memcpy(out, in, size*sizeof(T));
return;
#endif
}
};