For pyusb documentation, try this site:
http://wiki.erazor-zone.de/wiki:projects:python:pyusb:pydoc
It's pretty sparse; to understand what the methods are and how to use them,
you'll need to be familiar with the USB spec, try downloading documents from
http://www.usb.org/developers/docs/
The following is a little special-purpose script I used to test communication
with Tektronix TDS 2014B oscilloscopes. The English strings embedded in the
RUN, STOP, and ID variables will have to change for any other hardware, and
different devices will differ a bit on the other specifics. Also note the code
has hard-coded the logical location of the scope on the bus, which it shouldn't
do for general use.
Your mileage may vary, but hopefully this'll be a useful signpost for getting
started...
#These are commands to be send to the Bulk-OUT
endpoint
# (OUT <=> Host -> Device, IN <=> Device ->
Host)
#see USBTMC spec. for
details
#Byte 0: \x01 - this is a command, no response
allowed
# \x02 - this is a query, response
required
#Byte 1: bTag - byte tag, msg #, increments with each
transaction
#Byte 2: !bTag - one's complement of
bTag
#Byte 3: \x00
always
#Bytes 4-7: Number of bytes in payload, excl. header & alignment bytes
# LSB first
#Byte 8: For a command:
# \x01 if this is the last transfer for this message,
# \x00 otherwise
# For a query:
# \x02 Response must terminate w/ specified TermChar
# \x00 Response ignores TermChar (see Byte 9)
#Byte 9: For a command: \x00 always
# For a query: TermChar (see Byte 8)
#Bytes 10-11: \x00\x00 always
RUN='\x01\x01\xfe\x00\x0e\x00\x00\x00\x01\x00\x00\x00acq:state run\n\x00\x00'
STOP='\x01\x01\xfe\x00\x0e\x00\x00\x00\x01\x00\x00\x00acq:state stop\x00\x00'
ID='\x01\x01\xfe\x00\x05\x00\x00\x00\x01\x00\x00\x00*idn?\x00\x00\x00'
REQ_IN='\x02\x02\xfd\x00\x00\x01\x00\x00\x00\x00\x00\x00'
import usb
dev=usb.busses()[3].devices[0]#bus & device number may vary
print dev.idVendor #Tektronix = 1689L = x0699
print dev.idProduct #TDS 2014B = 872L = x0368
hand=dev.open()
print hand
conf=dev.configurations[0]
intf=conf.interfaces[0][0]
hand.reset()
print 'reset complete'
#hand.setConfiguration(conf)
hand.claimInterface(intf)
print 'claimed'
#hand.setAltInterface(0)
hand.bulkWrite(6,ID,4000) #write to a bulk-out endpoint
hand.bulkWrite(6,REQ_IN,4000) #write to a bulk-out endpoint
stuff=hand.bulkRead(133,256)#read from a bulk-in endpoint
-Sarah
--- On Wed, 9/1/10, Kaan AKŞİT <kun...@gmail.com> wrote:
From: Kaan AKŞİT <kun...@gmail.com>
Subject: [pyusb-users] Documentation
To: pyusb-users@lists.sourceforge.net
Date: Wednesday, September 1, 2010, 2:51 AM
Dear all,
I am having hard time to find a manual or a documentation that explains each
function in pyusb library. Unfortunately, I could not find anything beside
this: http://pyusb.sourceforge.net/docs/1.0/tutorial.html
Best regards,
Kaan
-----Inline Attachment Follows-----
------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:
Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
-----Inline Attachment Follows-----
_______________________________________________
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users
------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:
Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users