Hello. I have the following structures:
typedef struct CSH{
ulong H:8;
ulong S:6;
ulong C0:2;
ulong C:8;
}__attribute__((__packed__))CSH;
typedef struct CSH1{
ulong H:8;
ulong C0:2;
ulong S:6;
ulong C:8;
}__attribute__((__packed__))CSH1;
typedef struct partitie{
ulong active:8;
CSH F;
ulong sysID:8;
CSH L;
ulong start;
ulong size;
}__attribute__((__packed__))partitie;
typedef union{
partitie p;
uchar c;
}part;
part p;
I read data into p.c (16 bytes). This data has the following structure: first byte - active, second byte - FH , third byte - ( first to bits - FC0 , next 6 bits FS ), 4th byte - FC , 5 th byte sysID, bytes 6,7,8 similar to bytes 2,3,4 ; at last the next 4 bytes - start, and the last 4 bytes - size... and it works well.
However I don't quite understand why it doesn't work if I use CSH1 instead of CSH ( the logical order is H, C0, S, C not H S C0 C)
Thank you!
typedef struct CSH{
ulong H:8;
ulong S:6;
ulong C0:2;
ulong C:8;
}__attribute__((__packed__))CSH;
typedef struct CSH1{
ulong H:8;
ulong C0:2;
ulong S:6;
ulong C:8;
}__attribute__((__packed__))CSH1;
typedef struct partitie{
ulong active:8;
CSH F;
ulong sysID:8;
CSH L;
ulong start;
ulong size;
}__attribute__((__packed__))partitie;
typedef union{
partitie p;
uchar c;
}part;
part p;
I read data into p.c (16 bytes). This data has the following structure: first byte - active, second byte - FH , third byte - ( first to bits - FC0 , next 6 bits FS ), 4th byte - FC , 5 th byte sysID, bytes 6,7,8 similar to bytes 2,3,4 ; at last the next 4 bytes - start, and the last 4 bytes - size... and it works well.
However I don't quite understand why it doesn't work if I use CSH1 instead of CSH ( the logical order is H, C0, S, C not H S C0 C)
Thank you!