I\'m trying to wrap pre-existing c code for use in Python in Linux. I have little experience with c, and I\'m currently approaching this problem using ctypes. My C function requ
The line:
_fields_ = [("array", (Calibration_AIN() * NCHAN_1808) * NGAINS_1808)]
should raise a TypeError, since you instantiate Calibration_AIN. I believe that what you meant was:
_fields_ = [("array", (Calibration_AIN * NCHAN_1808) * NGAINS_1808)]
But even so, you don't need the AINarray wrapper. According to [Python]: Arrays, you could do something like:
Calibration_AIN_Table = (Calibration_AIN * NCHAN_1808) * NGAINS_1808
and then, in order to initialize an instance do smth like:
>>> cat = Calibration_AIN_Table() >>> for i in range(NGAINS_1808): ... for j in range(NCHAN_1808): ... cat[i][j].slope = i * j ... cat[i][j].offset = i * i * j ... >>> cat[2][3].slope 6.0