Daniel,
To do the usb enum at the moment use pyusb.
Example code. including opening ftdi device. (this function polls
continually until device is found).
eg
import usb, ftdi
def connectftdi():
#lets try for usb enum
found=None
dev=None
bus=None
while not found:
print "finding dev"
for bus in usb.busses():
for dev in bus.devices:
if dev.idVendor==0x1b3d and dev.idProduct==0x157:
found=bus, dev
break
if found: break
time.sleep(0.5)
print "dev found"
#now connect via ftdi
context=ftdi.ftdi_context()
ftdi.ftdi_init(context)
ftdi.ftdi_usb_open(context, 0x1b3d, 0x157 )
ftdi.ftdi_set_baudrate(context, 19200)
ftdi.ftdi_set_line_property( context, ftdi.BITS_8, ftdi.EVEN,
ftdi.STOP_BIT_1)
return clcd.cLCD(context, ftdi)
connectftdi()
If you absolutely wish to use the ftdi_usb_find_all() it can be done,
however the swig file for the python-bindings would have to be modified
to deal with the list of pointers as a return.
This situation arises as libftdi does not provide data from its
functions by returns but rather by modifying pointed to data in place.
This makes for exceptions in the swig to python conversion which need to
be handled individually as swig has no way of knowing what is an
argument to the function and what is the return. The swig file shows how
this can be done for the buffer returns but currently this does not
extend to the device_list return.
This should be marked as a TODO.
Regards
Tarek
Daniel Chabrol wrote:
> Hello all!
>
> I stuck with the ftdi_device_list parameter of ftdi_usb_find_all(). I
> was not able to find a way to create an compatible object in python,
> which represents this array of pointers. ftdi_device_list() creates
> only an object of type 'ftdi_device_list *' which does not match. If
> you put this object in a python list the error still occurs
> (TypeError: in method 'ftdi_usb_find_all', argument 2 of type 'struct
> ftdi_device_list **'). I hope someone is already using the new python
> bindings an can give me a hint or a piece of sample code.
>
> Best regards,
> Daniel
>
>
>
> --
> libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
> To unsubscribe send a mail to
> libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx
>
--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx
|