I’m installing BitString right now. It seems like what I need. The first sentence on the BitString Google Code website is: “bitstring is a pure Python module designed to help make the creation, manipulation and analysis of binary data as simple and natural as possible.” Perfect. The first thing I did was download the manual (pdf) and the zipped installation file for my version of Python (2.6).
Unzipping zipped files in Ubuntu is really easy – just right click on the file in the File Browser, and choose to Unzip using Archive Manager. But I wanted to know how to do it using the command line. Here is an example:
I installed the contents of the file into the appropriate Python Module locations on my computer by going to the directory where the unzipped files were, and typing the following into the command line:
sudo python setup.py install
Now I’m ready to dig in! Luckily, a friend of mine at work helped me out with some pointers on how to read in the s7k binary file. He explained the commands he’d used when creating his Matlab scripts, and how the structure was defined. He’s not a Python user, so couldn’t give me any specific Python tips, but it was enough for me to get started. So now I have to figure out the BitString part. The reason I’m not going with
array is because it seems that these are meant to work with whole bytes and are clunky when it comes to parsing out individual bits. BitString is designed with more flexibility.
Fortunately BigString seems pretty straightforward. I had a very quick look through the manual, and if I understand correctly, I will start by converting the s7k file to a BitString object, then just read through it bit by bit (or byte by byte).