libftdi Archives

Subject: libftdi - Python SWIG & unsigned char *

From: Chris Zeh <chris.w.zeh@xxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Mon, 7 Mar 2011 11:36:57 -0700
Good morning,

I've been working with the libftdi driver in Python recently and I've
run into a problem calling some of the functions from Python.

I stumbled across a mailing list thread between Flynn Marquardt and
Thomas 
(http://www.mail-archive.com/libftdi@xxxxxxxxxxxxxxxxxxxxxxx/msg00731.html)
which describes adding the following code to the ftdi.i swig file:

pointer_functions(unsigned int, uintp);

...to give us the ability to work with "unsigned int *" types.

Now, I wanted to use the ftdi_read_pins() function which requires us
to pass an "unsigned char *" type:
int ftdi_read_pins  ( struct ftdi_context *  ftdi,
  unsigned char *  pins
 )

Do we need to do something similar to support this uchar * type in Python?

I tried adding the following and recompiling:
pointer_functions(unsigned char *, ucharp);

However, Python still gave me a Type error. I was only able to get the
ftdi_read_pin function working when I added and used the following:
pointer_functions(char *, charp);

Perhaps the following line in the ftdi.i file "%typemap(in) unsigned
char* = char*;" is what requires the use of char* instead of uchar* of
this?

I appreciate any advice on the best course of action on this matter.

Best regards,
Chris Zeh

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread