I am struggeling with a problem on an embedded system. I have to program in C which is quite the task for me as i usualy work in object based programming languages. In this system two processors share memory and they handle data differntly, i am pretty sure the issue has to do with endian encoding, but after 3 hours of failed attempts to make a single function to fix this i am seeking for help. I struggle immensly with casting and and pointer handeling.
The situation: I store two (or more) floats (or other types) in a buffer lets say for this example its {1.0f , 1.0f}. This ends up with the byte representation of {3F,80,00,00,3F,80,00,00} if the other processor reinterprets the data it gets negative or rediculously high exponential numbers depending on the input.
So what am i trying to achive? A function that fixes this order where the endian encoding is reversed.
void fixEncoding(void *StoredData, uint8_t variableSizeInBytes, uint8_t buffer size)
The parameters would be a pointer to my stored data {3F,80,00,00,3F,80,00,00} the size of the variables encoded within (4 for a float for example or sizeof(float)) and the stored datas size
input {3F,80,00,00,3F,80,00,00} , 4, 8
output{00,00,80,3F,00,00,80,3F}
input {3F,80,00,00,3F,80,00,00} , 2, 8
output{80,3f,00,00,80,3f,00,00}