Hello,<br><br>I have a USB barcode scanner that acts like a keyboard: whenever a barcode is read it sends the code where the keyboard would normally write. I am writing some code in C to read from the scanner.<br><br>I initialliy tried with libusb (and failed) but since the scanner acts like a keyboard I figured I would be more successful with libhid. Can someone tell me how to read from that scanner/keyboard using libhid?
<br><br>Below is the output of usbview, test_libhid and lsusb<br><br>Thanks,<br>Brice<br><br><br>$ usbview<br>
Symbol Bar Code Scanner<br>
...<br>
Speed: 12Mb/s (full)<br>
USB Version: 1.10<br>
Device Class: 00(>ifc )<br>
Device Subclass: 00<br>
Device Protocol: 00<br>
Maximum Default Endpoint Size: 8<br>
Number of Configurations: 1<br>
...<br>
Config Number: 1<br>
Number of Interfaces: 1<br>
Attributes: 80<br>
Max Power Needed: 400mA<br>
<br>
Interface Number: 0<br>
Name: (none)<br>
Alternate Number: 0<br>
Class: 03(HID )<br>
Sub Class: 1<br>
Protocol: 1<br>
Number of Endpoints: 1<br>
<br>
Endpoint Address: 81<br>
Direction: in<br>
Attribute: Int.<br>
Max Packet Size: 8<br>
Interval: 10ms<br><br><br>$ test_libhid<br>parse tree of HIDInterface 002/004[0]:<br> path: 0x00010006.0x00000000; type: 0x80<br> path: 0x00010006.0x00000000
; type: 0x80<br> path: 0x00010006.0x00000000; type: 0x80<br> path: 0x00010006.0x00000000; type: 0x80<br> path: 0x00010006.0x00000000; type: 0x80<br> path: 0x00010006.0x00000000; type: 0x80<br> path: 0x00010006.0x00000000
; type: 0x80<br> path: 0x00010006.0x00000000; type: 0x80<br> path: 0x00010006.0x00000000; type: 0x80<br> path: 0x00010006.0x00000000; type: 0x90<br> path: 0x00010006.0x00000000; type: 0x90<br> path: 0x00010006.0x00000000
; type: 0x90<br> path: 0x00010006.0x00000000; type: 0x90<br> path: 0x00010006.0x00000000; type: 0x90<br> path: 0x00010006.0x00000000; type: 0x90<br> path: 0x00010006.0x00000000; type: 0x80<br> path: 0x00010006.0x00000000
; type: 0x80<br> path: 0x00010006.0x00000000; type: 0x80<br> path: 0x00010006.0x00000000; type: 0x80<br> path: 0x00010006.0x00000000; type: 0x80<br> path: 0x00010006.0x00000000; type: 0x80<br><br><br><br>$ lsusb -s 2:4 -vvv
<br>Bus 002 Device 004: ID 05e0:0200 Symbol Technologies<br>Device Descriptor:<br> bLength 18<br> bDescriptorType 1<br> bcdUSB
1.10<br> bDeviceClass 0 (Defined at Interface level)<br> bDeviceSubClass 0<br> bDeviceProtocol 0<br> bMaxPacketSize0 8<br> idVendor 0x05e0 Symbol Technologies<br> idProduct 0x0200
<br> bcdDevice 2.04<br> iManufacturer 1 (c) Symbol Technologies, Inc, 2000<br> iProduct 2 Symbol Bar Code Scanner<br> iSerial 3 S/N:2925e1000000 Rev:NBRXUAAM3<br> bNumConfigurations 1
<br> Configuration Descriptor:<br> bLength 9<br> bDescriptorType 2<br> wTotalLength 34<br> bNumInterfaces 1<br> bConfigurationValue 1<br> iConfiguration 0
<br> bmAttributes 0x80<br> (Bus Powered)<br> MaxPower 400mA<br> Interface Descriptor:<br> bLength 9<br> bDescriptorType 4<br> bInterfaceNumber 0
<br> bAlternateSetting 0<br> bNumEndpoints 1<br> bInterfaceClass 3 Human Interface Devices<br> bInterfaceSubClass 1 Boot Interface Subclass<br> bInterfaceProtocol 1 Keyboard
<br> iInterface 0<br> HID Device Descriptor:<br> bLength 9<br> bDescriptorType 33<br> bcdHID 1.10<br> bCountryCode 33 US
<br> bNumDescriptors 1<br> bDescriptorType 34 Report<br> wDescriptorLength 65<br> Report Descriptor: (length is 65)<br> Item(Global): Usage Page, data= [ 0x01 ] 1
<br> Generic Desktop Controls<br> Item(Local ): Usage, data= [ 0x06 ] 6<br> Keyboard<br> Item(Main ): Collection, data= [ 0x01 ] 1<br> Application
<br> Item(Global): Usage Page, data= [ 0x07 ] 7<br> Keyboard<br> Item(Local ): Usage Minimum, data= [ 0xe0 ] 224<br> Control Left<br> Item(Local ): Usage Maximum, data= [ 0xe7 ] 231
<br> GUI Right<br> Item(Global): Logical Minimum, data= [ 0x00 ] 0<br> Item(Global): Logical Maximum, data= [ 0x01 ] 1<br> Item(Global): Report Size, data= [ 0x01 ] 1
<br> Item(Global): Report Count, data= [ 0x08 ] 8<br> Item(Main ): Input, data= [ 0x02 ] 2<br> Data Variable Absolute No_Wrap Linear<br> Preferred_State No_Null_Position
<br>Non_Volatile Bitfield<br> Item(Global): Report Count, data= [ 0x01 ] 1<br> Item(Global): Report Size, data= [ 0x08 ] 8<br> Item(Main ): Input, data= [ 0x01 ] 1<br> Constant Array Absolute No_Wrap Linear
<br> Preferred_State No_Null_Position<br>Non_Volatile Bitfield<br> Item(Global): Report Count, data= [ 0x05 ] 5<br> Item(Global): Report Size, data= [ 0x01 ] 1<br> Item(Global): Usage Page, data= [ 0x08 ] 8
<br> LEDs<br> Item(Local ): Usage Minimum, data= [ 0x01 ] 1<br> NumLock<br> Item(Local ): Usage Maximum, data= [ 0x05 ] 5<br> Kana
<br> Item(Main ): Output, data= [ 0x02 ] 2<br> Data Variable Absolute No_Wrap Linear<br> Preferred_State No_Null_Position<br>Non_Volatile Bitfield<br> Item(Global): Report Count, data= [ 0x01 ] 1
<br> Item(Global): Report Size, data= [ 0x03 ] 3<br> Item(Main ): Output, data= [ 0x01 ] 1<br> Constant Array Absolute No_Wrap Linear<br> Preferred_State No_Null_Position
<br>Non_Volatile Bitfield<br> Item(Global): Report Count, data= [ 0x06 ] 6<br> Item(Global): Report Size, data= [ 0x08 ] 8<br> Item(Global): Logical Minimum, data= [ 0x00 ] 0<br> Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
<br> Item(Global): Usage Page, data= [ 0x07 ] 7<br> Keyboard<br> Item(Local ): Usage Minimum, data= [ 0x00 ] 0<br> No Event<br> Item(Local ): Usage Maximum, data= [ 0xff 0x00 ] 255
<br> (null)<br> Item(Main ): Input, data= [ 0x00 ] 0<br> Data Array Absolute No_Wrap Linear<br> Preferred_State No_Null_Position
<br>Non_Volatile Bitfield<br> Item(Main ): End Collection, data=none<br> Endpoint Descriptor:<br> bLength 7<br> bDescriptorType 5<br> bEndpointAddress 0x81 EP 1 IN
<br> bmAttributes 3<br> Transfer Type Interrupt<br> Synch Type None<br> Usage Type Data<br> wMaxPacketSize 0x0008 1x 8 bytes
<br>
bInterval 10<br>Device Status: 0x0000<br> (Bus Powered)<br>