I have a packet of data and when i assign that data to variables bit by bit as per the requirement, it is missing some bytes in between. Don't know why? I am working in c++.
For Example, I have structure like:
struct __attribute__((packed))
{
    uint32  varA:9;
    uint32  varB:10;
    uint32  varC:9;
    uint32  varD:4;
    uint16  varE:16;
    uint32  varF:32;
}structA;
And i have data as: a0 1a 0d 00 01 42 00 1c 17 2d
All thing goes well til variable varD. When come to varE, it should assign 01 42 to that but it is missing 01 and taking 42 only. And after that everything goes fine.
And if i do it like this
 struct __attribute__((packed))
{
    uint32  varA:9;
    uint32  varB:10;
    uint32  varC:9;
    uint32  varD:4;
    uint8   varE:8;
    uint8   varF:8;
    uint32  varG:32;
}structA;
The bits assigning works fine. Any idea why is this happening?
 
     
    