HID devices are problematic with libusb, and since PyUSB depends on libusb, pyusb can't handle HID devices either. A better way should to use hidapi [1].
[1] http://www.signal11.us/oss/hidapi/ 2014-05-09 0:47 GMT-03:00 Dm M <demoman....@gmail.com>: > Hi, > > I am having problems reading from a usb nfc device that acts like a > keyboard. If I plug the device into my linux computer and scan a nfc tag, it > outputs it out as if a keyboard was typing the keys: > >> $: 2352481416 > > > However when I try to isolate the device to capture output with pyusb I am > unable to read anything from the device. In the code I posted below it just > continually prints "[]", never reading any data. When I use ipython to read > with a specified timeout (endpoing.read(129, 5000)), it always times out > despite triggering a tag in the mean time. > > One thing I noticed is the iInterface number is 4, instead of 0, but I am > not sure how to use that info. > > > Device info lsusb -v: > >>> Bus 002 Device 009: ID 08ff:0009 AuthenTec, Inc. >>> >>> Device Descriptor: >>> >>> bLength 18 >>> >>> bDescriptorType 1 >>> >>> bcdUSB 1.10 >>> >>> bDeviceClass 0 (Defined at Interface level) >>> >>> bDeviceSubClass 0 >>> >>> bDeviceProtocol 0 >>> >>> bMaxPacketSize0 8 >>> >>> idVendor 0x08ff AuthenTec, Inc. >>> >>> idProduct 0x0009 >>> >>> bcdDevice 0.08 >>> >>> iManufacturer 1 深圳市思远创智能设备有限公司 >>> >>> http://www.sycreader.com >>> >>> iProduct 2 (error) >>> >>> iSerial 3 REV_0008 >>> >>> bNumConfigurations 1 >>> >>> Configuration Descriptor: >>> >>> bLength 9 >>> >>> bDescriptorType 2 >>> >>> wTotalLength 34 >>> >>> bNumInterfaces 1 >>> >>> bConfigurationValue 1 >>> >>> iConfiguration 0 >>> >>> bmAttributes 0xa0 >>> >>> (Bus Powered) >>> >>> Remote Wakeup >>> >>> MaxPower 100mA >>> >>> Interface Descriptor: >>> >>> bLength 9 >>> >>> bDescriptorType 4 >>> >>> bInterfaceNumber 0 >>> >>> bAlternateSetting 0 >>> >>> bNumEndpoints 1 >>> >>> bInterfaceClass 3 Human Interface Device >>> >>> bInterfaceSubClass 1 Boot Interface Subclass >>> >>> bInterfaceProtocol 1 Keyboard >>> >>> iInterface 4 RFID Reader With Keyboard >>> >>> HID Device Descriptor: >>> >>> bLength 9 >>> >>> bDescriptorType 33 >>> >>> bcdHID 1.10 >>> >>> bCountryCode 33 US >>> >>> bNumDescriptors 1 >>> >>> bDescriptorType 34 Report >>> >>> wDescriptorLength 63 >>> >>> Report Descriptors: >>> >>> ** UNAVAILABLE ** >>> >>> Endpoint Descriptor: >>> >>> bLength 7 >>> >>> bDescriptorType 5 >>> >>> bEndpointAddress 0x81 EP 1 IN >>> >>> bmAttributes 3 >>> >>> Transfer Type Interrupt >>> >>> Synch Type None >>> >>> Usage Type Data >>> >>> wMaxPacketSize 0x0008 1x 8 bytes >>> >>> bInterval 8 >>> >>> Device Status: 0x0000 >>> >>> (Bus Powered) >> >> > > > Python code: > >>> import sys >>> >>> import usb.core >>> >>> import usb.util >>> >>> >>> VENDOR_ID = 0x08ff >>> >>> PRODUCT_ID = 0x0009 >>> >>> >>> device = usb.core.find(idVendor=VENDOR_ID, idProduct=PRODUCT_ID) >>> >>> >>> if device.is_kernel_driver_active(0): >>> >>> try: >>> >>> device.detach_kernel_driver(0) >>> >>> except usb.core.USBError as e: >>> >>> sys.exit("Could not detatch kernel driver: %s" % str(e)) >>> >>> >>> try: >>> >>> device.set_configuration() >>> >>> device.reset() >>> >>> except usb.core.USBError as e: >>> >>> sys.exit("Could not set configuration: %s" % str(e)) >>> >>> >>> endpoint = device[0][(0, 0)][0] >>> >>> >>> data = [] >>> >>> >>> while 1: >>> >>> try: >>> >>> print data >>> >>> data += endpoint.read(endpoint.wMaxPacketSize) >>> >>> print "NEVER PRINTS" >>> >>> except usb.core.USBError as e: >>> >>> print e >>> >>> > > ------------------------------------------------------------------------------ > Is your legacy SCM system holding you back? Join Perforce May 7 to find out: > • 3 signs your SCM is hindering your productivity > • Requirements for releasing software faster > • Expert tips and advice for migrating your SCM now > http://p.sf.net/sfu/perforce > _______________________________________________ > pyusb-users mailing list > pyusb-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/pyusb-users > -- Best Regards, Wander Lairson Costa ------------------------------------------------------------------------------ Is your legacy SCM system holding you back? Join Perforce May 7 to find out: • 3 signs your SCM is hindering your productivity • Requirements for releasing software faster • Expert tips and advice for migrating your SCM now http://p.sf.net/sfu/perforce _______________________________________________ pyusb-users mailing list pyusb-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pyusb-users