Ok, I have a 'expandIO', which is basically a PIC18F 2455 Microcontroller,
which uses a HID USB interface to send commands from a PC to the
microcontroller. Using the following script, I am able send a couple of
commands to the device (turns on and off an LED), but I get a timeout error
after that and am unable to send more commands. I am also unable to receive
anything from the device. Does anyone know what I am doing wrong? Sorry about
posting all of my problems on here, I am just a beginner with USB communication
stuff.
Here is my current script:
import usb.core
import usb.util
import time
# find our device
dev = usb.core.find(idVendor=0x0B40, idProduct=0x0133)
print dev
# 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()
address = dev.address
endpoint = usb.util.endpoint_address(address)
led_on = '\x9F\x01\x05\x00' #write a 0 to port A5
led_off = '\x9F\x01\x05\x01' #write a 1 to port A5
dev.write(endpoint,led_on,0) #turn the DS1 LED on
time.sleep(0.5) #wait for 1/2 second
dev.write(endpoint,led_off,0) #turn the DS1 LED off
time.sleep(0.5) #wait for 1/2 second
dev.write(endpoint,led_on,0) #turn the DS1 LED on
time.sleep(0.5) #wait for 1/2 second
dev.write(endpoint,led_off,0) #turn the DS1 LED off
Here is the error that I am getting:
Traceback (most recent call last):
File "usb_test.py", line 25, in <module>
dev.write(endpoint, led_on,0) #turn the DS1 LED on
File "C:\Python27\usb\core.py", line 619, in write
self.__get_timeout(timeout)
File "C:\Python27\usb\backend\libusb01.py", line 492, in intr_write
timeout)
File "C:\Python27\usb\backend\libusb01.py", line 556, in __write
timeout
File "C:\Python27\usb\backend\libusb01.py", line 384, in _check
raise USBError(errmsg, ret)
usb.core.USBError: [Errno None] libusb0-dll:err [_usb_reap_async] timeout error
Any ideas?
Thanks,
Bryson
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users