On Sat, Jul 30, 2011 at 5:26 PM, Xiaofan Chen <[email protected]> wrote:
> On Sat, Jul 30, 2011 at 2:12 PM, C Duff <[email protected]> wrote:
>> Thanks Xiaofan,
>> I didn't know about the reset - I'll make sure to add that. And everything
>> now works.
>
> The reset call is normally not necessary and I tried Microchip's
> QT3/libusb-0.1
> based application and that works fine without the reset. So there might
> be something different from pyusb side.
>
On the other hand, I tested the simple HID demo under Ubuntu 11.04 32bit
and it does not need the reset. So it might still point to the firmware.
#!/usr/bin/env python
import usb.core
import usb.util
#find our device
dev = usb.core.find(idVendor=0x04D8, idProduct=0x003f)
#was it found?
if dev is None:
raise ValueError('Device not found')
for configuration in dev:
for interface in configuration:
ifnum = interface.bInterfaceNumber
if not dev.is_kernel_driver_active(ifnum):
continue
try:
print "detach kernel driver from device %s: interface %s" %
(dev, ifnum)
dev.detach_kernel_driver(ifnum)
except usb.core.USBError, e:
pass
#set the active configuration. with no args we use first config.
dev.set_configuration()
#turn light on
print "Toggle LED by sending Toggle_LED command"
dev.write(1, [0x080], 0, 1000)
print "Sending read switch command"
dev.write(1,[0x081],0,1000)
s=dev.read(0x81,64,0,5000)
print "Echo read switch command 0x81"
print s[0]
print "Read switch status, 1 means not pressed, 0 means pressed"
print s[1]
#dev.reset()
mcuee@Ubuntu:~/Desktop/build/pyusb/test$ python testmchp_simplehid.py
Toggle LED by sending Toggle_LED command
Sending read switch command
Echo read switch command 0x81
129
Read switch status, 1 means not pressed, 0 means pressed
1
--
Xiaofan
------------------------------------------------------------------------------
Got Input? Slashdot Needs You.
Take our quick survey online. Come on, we don't ask for help often.
Plus, you'll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
_______________________________________________
pyusb-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyusb-users