libftdi Archives

Subject: Re: ftdi_read_chipid cannot be used from python due to TypeError

From: Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Tue, 13 Jul 2010 17:27:11 +0200
Hello Flynn,

On Saturday, 10. July 2010 17:06:35 Flynn Marquardt wrote:
> I tried to read the chipid in python:
> 
> import ftdi
> ftdic = ftdi.ftdi_context()
> ret = ftdi.ftdi_usb_open(ftdic, 0x0403, 0x6001)
> chipid = 0
> ftdi.ftdi_read_chipid(ftdic, chipid)
> 
> results in a TypeError:
> 
> TypeError: in method 'ftdi_read_chipid', argument 2 of type 'unsigned
> int *'
> 
> Without help from Swig it is not possible to create the correct object.
> 
> Inserting in bindings/ftdi.i the line
> 
> %pointer_functions(unsigned int, uintp);
> 
> after %include "cpointer.i" helps (pointer_class could also be used).
> 
> With a little modification in python:
> 
> import ftdi
> ftdic = ftdi.ftdi_context()
> ret = ftdi.ftdi_usb_open(ftdic, 0x0403, 0x6001)
> chipid = ftdi.new_uintp()
> ftdi.ftdi_read_chipid(ftdic, chipid)
> hex(ftdi.uintp_value(chipid))
> 
> the correct chipid is printed.
> 
> It seems (I'm not an expert in swig), that the *OUTPUT directives are
> not correct for
> ftdi_read_chipid, otherwise this patch woud not be needed.

Thanks for the info. Care to send a proper patch
as I'm not too familiar with swig?

Cheers,
Thomas

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

Current Thread