I have the problem of casting a byte array to a struct, some bytes are ignored or skipped.
Given the following struct,
typedef struct
{
uint32_t id;
uint16_t test;
uint8_t group;
uint32_t time;
uint16_t duration;
uint8_t a;
uint8_t b;
uint8_t c;
uint16_t d;
uint16_t e;
uint8_t status;
uint8_t x;
uint8_t y;
} testStruct_t, *PtestStruct_t;
I have an array with the following test data:
uint8_t pBuff = { 0x11 , 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19 };
The casting is done as follows:
PtestStruct_t pStruct = (PtestStruct_t)pBuff;
Somewhere in the structure some bytes are skipped or ignored. I do not know why. This has been tested in Visual Studio 2012 and on a ARM processor on which this testing and debugging was made required.
What am I missing here? I do not believe it is Endian related. It could be the compiler in both test cases, I do not know what to do in this last case.
The bytes which are being skipped/ignored are 0x88
and 0x14