allocating an unsigned int memory buffer for C (swig) struct

njuk.njuk at gmail.com njuk.njuk at gmail.com
Thu Dec 4 21:54:42 EST 2008


i am using python (via swig) to interface with the comedi (http://
www.comedi.org/) library for some simple data acquisition.  a general
category of problems i am having has to do with basic comedi structs
whose members require being set to a pointer of an allocated memory
buffer.

one specific example is the 'insn' struct that has a 'data' member
that should point to a buffer i have previously allocated.  the comedi
type is 'lsampl_t*' but underneath this is simply an 'unsigned int*'.

for the life of me, i haven't been able to figure out how to
instantiate a memory buffer of the correct underlying type in python.
whatever i try always fails when i set the struct member.

TypeError: in method 'comedi_insn_struct_data_set', argument 2 of type
'lsampl_t *'

[the underlying swig code seems to be (correctly) checking for an
unsigned int pointer].

aside: i am currently running python v2.4.4 but could upgrade to a 2.5
version.

thanks for any help.



More information about the Python-list mailing list