However the XMOS is using SYSV byte alignment and this causes my data to be off.
For example here is a first part of a struct that I’ve declared.
Code: Select all
typedef struct _module_descriptor_
{
uint8_t macAddress0;
uint8_t macAddress1;
uint8_t macAddress2;
uint8_t macAddress3;
uint8_t macAddress4;
uint8_t macAddress5;
uint32_t vendorID;
uint32_t moduleID;
[…]
}
Code: Select all
My_module_descriptor_getter (&Descriptor);
unsigned l; unsigned char XXX[200];
memcpy(&XXX, & Descriptor, sizeof(Descriptor));
for(i=0; i< sizeof(Descriptor); i++);
{
printf("0x%02X\n", XXX[i]);
}
l=0;
printf("\n0x%08X\n", Descriptor.vendorID);
printf("0x%08X\n", Descriptor.moduleID);
c_lcd <: Descriptor;
0x02 //<- macAddress0
0xEA //<- macAddress1
0x36 //<- macAddress2
0x00 //<- macAddress3
0xB7 //<- macAddress4
0xA6 //<- macAddress5
0x03 //<- Descriptor.vendorID should be 0x0000E003
0xE0
0x00
0x00
0x06 //<- Descriptor. moduleID should be 0x00000006
0x00
0x00
0x00
0x00
0x74
0x25
0x00
0x00
[…]
0x00060000 // output from printf("\n0x%08X\n", Descriptor.vendorID);
0x74000000 // output from printf("0x%08X\n", Descriptor.moduleID);
I’ve also had a similar problem with a header to a binary file (TGA graphic) that I read from an SDcard. Is there a trick that I can use to get the byte alignment correct when referencing the struct or do I need to roll-my-own functions for each structure that I need to read?
Thanks,
-Steve