Parsing Binary Structures; Is there a better way / What is your way?

Bearophile bearophileHUGS at lycos.com
Wed Aug 5 19:17:29 CEST 2009


Martin P. Hellwig:
> On several occasions I have needed (and build) a parser that reads a
> binary piece of data with custom structure. For example (bogus one):
>
> BE
> +---------+---------+-------------+-------------+------+--------+
> | Version | Command | Instruction | Data Length | Data | Filler |
> +---------+---------+-------------+-------------+------+--------+
> Version: 6 bits
> Command: 4 bits
> Instruction: 5 bits
> Data Length: 5 bits
> Data: 0-31 bits
> Filler: filling 0 bits to make the packet dividable by 8

Have you tried Hachoir? (I think its name may be changed to Fusil, I
don't know).

Bye,
bearophile



More information about the Python-list mailing list