Use Python Construct to parse 64b *little* endian bitmap into an array of bytes

287 Views Asked by At

I need to parse a 64 bit little endian memory into an array of 64 bytes. One bit parses to 1 byte. This will allow me later on to use those bytes for further parsing. Example: 3B 94 00 00 00 00 00 00 Should be parsed into: 1001010000111011. The 1011 on the right are the LSBs (bits 0-3). Each bit resides in a byte in an array.

The issue I was facing is that I was only able to parse 64b little endian into 64bit single item. Example: a = Struct(bmp_struct=BitStruct(bmp=BitsInteger(64, swapped=True))) I need to separate the bits as well so I can use them.

On the other hand I was able to parse 64b big endian (I need little endian) into a 64 byte array. Example: a = BitStruct(bmp=Array(64, Byte)

I was never able to do both. How do I combine the two?

I read a big portion of Python Construct help. It sounds like a simple task however I was not able to pull this off. I am probably missing something since I am a newbie with Construct.

Is there some Python Construct Forum where I post this question?

Thx in advance for anyone trying to take this on!!

YL

0

There are 0 best solutions below