On 3 January 2011 22:56, wander.lairson <wander.lair...@gmail.com> wrote:

> 2011/1/3 mike s <mikescal...@hotmail.com>:
> >
> > Hi,
> > I'm trying to start interfacing with USB devices with Python which led me
> to
> > PyUSB. I have installed the following software already:
> > Mac OSX 10.6.5
> > Xcode
> > Python 2.6.6 and 3.2
> > pkg-config-0.18.1
> > libusb-1.0.8
> > pyusb-1.0.0-a1
> >
> > In Python (2.6) I can have it import the usb.core and usb.util but when I
> go
> > to run a sample test program (below)
> > import usb.core
> > import usb.util
> > # find our device
> > dev = usb.core.find(idVendor=0xfffe, idProduct=0x0001)
> > # was it found?
> > if dev is None:
> >     raise ValueError('Device not found')
> > # set the active configuration. With no arguments, the first
> > # configuration will be the active one
> > dev.set_configuration()
> > # get an endpoint instance
> > ep = usb.util.find_descriptor(
> >         dev.get_interface_altsetting(),   # first interface
> >         # match the first OUT endpoint
> >         custom_match = \
> >             lambda e: \
> >                 usb.util.endpoint_direction(e.bEndpointAddress) == \
> >                 usb.util.ENDPOINT_OUT
> >     )
> > assert ep is not None
> > # write the data
> > ep.write('test')
> > I get this error and not the proper one
> > Traceback (most recent call last):
> >   File "/Users/admin/Desktop/python test/test", line 5, in <module>
> >     dev = usb.core.find(idVendor=0xfffe, idProduct=0x0001)
> >   File
> >
> "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/usb/core.py",
> > line 829, in find
> >     raise ValueError('No backend available')
> > ValueError: No backend available
> >
> > I've looked around and found a few forums addressing the issue but didn't
> > really get a clear answer. I found one that talked about making some
> changes
> > to a file but wasn't real clear on what exactly the changes were. Any
> help
> > would be greatly appreciated.
> > Thanks,
> > mike scalisi
> >
> These kind of problems usually happens when people insall libusb from
> sources and the default lib directory is not configured as a library
> search path. If you still have problems, please activate logging
> (check section 'What's wrong' in the PyUSB tutorial*) and report the
> results to the mailing list (not me, please).
>
> * http://pyusb.sourceforge.net/docs/1.0/tutorial.html
>
>
> --
> Best Regards,
> Wander Lairson Costa
> LCoN - Laboratório de Computação Natural - Natural Computing Laboratory
> (http://www.mackenzie.com.br/lcon.html)
> Programa de Pós-Graduação em Engenharia Elétrica (PPGEE)
> Faculdade de Computação e Informática (FCI)
> Universidade Presbiteriana Mackenzie - SP - Brazil
>
>
> ------------------------------------------------------------------------------
> Learn how Oracle Real Application Clusters (RAC) One Node allows customers
> to consolidate database storage, standardize their database environment,
> and,
> should the need arise, upgrade to a full multi-node Oracle RAC database
> without downtime or disruption
> http://p.sf.net/sfu/oracle-sfdevnl
> _______________________________________________
> pyusb-users mailing list
> pyusb-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pyusb-users
>

Hello everyone,

I am a total newbie to pythonUSB.

I am using the PyUSB interface for one of the devices which has a FTDI chip.

I could read the device ID and get the serial number of it.

I need to read and write data to the device.

The example provided on the website is not sufficient to read or write data.

Could you provide some examples which i could try out so that i can talk
with the device?

I have refered the programmers guide for D2XX programming but it seems to be
written for C programming.
I tried to modify to suit to a python environment.

For eg,  in the code below:

# ----------
# import the PyUSB module
import d2xx
global EventDword,TxBytes,RxBytes,BytesReceived
EventDword =TxBytes=RxBytes=
BytesReceived=0
# list devices by description, returns tuple of attached devices description
strings
d = d2xx.listDevices(d2xx.OPEN_BY_DESCRIPTION)
print d

# list devices by serial, returns tuple of attached devices serial strings
d = d2xx.listDevices() # implicit d2xx.OPEN_BY_SERIAL_NUMBER
print d

h = d2xx.open(0)
print h

# get queue status
print h.getQueueStatus()

# set RX/TX timeouts
h.setTimeouts(1000,1000)

print h.read(5)


# ----------
The python interpreter exits once it reaches print h.read(5).

I need read data from the device and write to it as well.

The device is  data acquisition system which is connected to the PC via a
USB cable.

The output received for execution of the code till it reaches the Read is as
below:

>> ('USB Interface IF-U1',)
>>> ('EAT2QBD0',)
>>> <FtobjType object at 0x00A17300>
>>> 0
[Dbg]>>>

This tells me that i am connected to the device and get the object of it.
But i need to use it and read and write data from the device as well.

Any help in this regard is highly appreciated.


-- 
Thanks and Regards,

Karthikeyan.V
Transmission Controls HIL LAB
Tel: +44 (0)2476 206717
kvenk...@jaguarlandrover.com <g...@jaguarlandrover.com>

Land Rover, Banbury Road, Gaydon, Warwick, CV35 ORR, UK. Registered in
England and Wales Number: 4019301.
Jaguar Cars Limited, Abbey Road, Whitley, Coventry, CV3 4LF, UK. Registered
in England Number: 1672070.
------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users

Reply via email to