I'm looking for a way to unpack binary data. The data is described by a whole tree of structs (up to four layers deep, total struct size is almost 64k) in a C header file.
For this question: Unpacking nested C structs in Python the only answer was to "flatten" the whole data description into one string, but I'm reluctant to do this in my case because it would be unmaintainable.
What I'd love to have is something that reads the header file and then magically creates a function that takes the binary data and returns a (properly nested) dictionary with all the data.
Is there any Python module that can accomplish this, or some parts of it?
Or are there other ways to deal with such data in Python?
This is an old thread, but I had the same issue and did not find any library for python that supports nested structs.
Therefore I wrote the pycstruct library.
It supports structs, unions, bitfields and enums. It also supports all byteorders, alignments and nesting at any level.