Bit fields in python?

Kwan Lai Cheng laicheng_kwan at innomedia.com.sg
Tue Sep 7 10:39:48 CEST 2010


----- Original Message ----- 
From: Stefan Behnel
To: <python-list at python.org>
Sent: Tuesday, September 07, 2010 2:55 PM
Subject: Re: Bit fields in python?


>
> If you can tell us what these structs are being used for in the original C
> code, we might be able to point you to a suitable way to implement the 
> same
> thing efficiently in Python.
>
> Stefan
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

It's a test program for testing the DSP (Digital Signal Processor). 
Basically what it does is that it sends commands to the DSP via a driver and 
waits for a response from the DSP. The structures represent the data that I 
might receive from the DSP. For example if I send command A, DSP will send 
data in the format of structa to me, so I will cast the data I received to 
structa, and print the struct field values on screen. Each field in the 
structures represent some status or info about the DSP, different bits in an 
unsigned char or unsigned short field might represent different DSP status.

I just found out that there's a ctypes module 
(http://docs.python.org/library/ctypes.html) in python that might solve my 
problem. I understand that it is already included in Python 2.5 & I'm using 
Python 2.6.2. However when I tried "from ctypes import *", I got "No module 
named _ctypes". What am I missing here?





More information about the Python-list mailing list