ioctl, pass buffer address, howto?
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Fri Apr 25 21:46:39 EDT 2008
En Fri, 25 Apr 2008 09:30:56 -0300, Neal Becker <ndbecker2 at gmail.com>
escribió:
> I need an ioctl call equivalent to this C code:
>
> my_struct s;
> s.p = p; << a pointer to an array of char
> s.image_size = image_size;
> return (ioctl(fd, xxx, &s));
>
> I'm thinking to use python array for the array of char, but I don't see
> how
> to put it's address into the structure.
Use the array's buffer_info() method:
"""buffer_info(): Return a tuple (address, length) giving the current
memory address and the length in elements of the buffer used to hold
array's contents."""
<http://docs.python.org/lib/module-array.html>
and you can use the struct module to build my_struct.
> Maybe ctypes is the answer?
It could be used too, but I think that in this case it's harder to use
ctypes.
--
Gabriel Genellina
More information about the Python-list
mailing list