Below is example where I have a BitStruct embedded in a Struct:
bits = BitStruct(
'bits',
Flag('a'),
Flag('b'),
Enum(BitField('c', 2),
A = 0b00,
B = 0b01,
C = 0b10,
D = 0b11,
),
BitField('d', 12),
)
packet = Struct(
'packet',
ULInt16('foo'),
EmbeddedBitStruct(bits),
ULInt16('bar'),
)
In the example above I'd like to make 'bits' an unsigned, little-endian, 16-bit integer, within the packet. Is there an easy way to cast it to a ULInt16 within 'packet'? Or do I have to reorder the 'bits' BitStruct by hand?
Thanks,
-kap