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(&gt;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>
&nbsp;&nbsp; Number of Interfaces: 1<br>
&nbsp;&nbsp; Attributes: 80<br>
&nbsp;&nbsp; Max Power Needed: 400mA<br>
<br>
&nbsp;&nbsp; Interface Number: 0<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Name: (none)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Alternate Number: 0<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Class: 03(HID )<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Sub Class: 1<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Protocol: 1<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Number of Endpoints: 1<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Endpoint Address: 81<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Direction: in<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Attribute: Int.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Max Packet Size: 8<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Interval: 10ms<br><br><br>$ test_libhid<br>parse tree of HIDInterface 002/004[0]:<br> &nbsp;path: 0x00010006.0x00000000; type: 0x80<br> &nbsp;path: 0x00010006.0x00000000
; type: 0x80<br> &nbsp;path: 0x00010006.0x00000000; type: 0x80<br> &nbsp;path: 0x00010006.0x00000000; type: 0x80<br> &nbsp;path: 0x00010006.0x00000000; type: 0x80<br> &nbsp;path: 0x00010006.0x00000000; type: 0x80<br> &nbsp;path: 0x00010006.0x00000000

; type: 0x80<br> &nbsp;path: 0x00010006.0x00000000; type: 0x80<br> &nbsp;path: 0x00010006.0x00000000; type: 0x80<br> &nbsp;path: 0x00010006.0x00000000; type: 0x90<br> &nbsp;path: 0x00010006.0x00000000; type: 0x90<br> &nbsp;path: 0x00010006.0x00000000

; type: 0x90<br> &nbsp;path: 0x00010006.0x00000000; type: 0x90<br> &nbsp;path: 0x00010006.0x00000000; type: 0x90<br> &nbsp;path: 0x00010006.0x00000000; type: 0x90<br> &nbsp;path: 0x00010006.0x00000000; type: 0x80<br> &nbsp;path: 0x00010006.0x00000000

; type: 0x80<br> &nbsp;path: 0x00010006.0x00000000; type: 0x80<br> &nbsp;path: 0x00010006.0x00000000; type: 0x80<br> &nbsp;path: 0x00010006.0x00000000; type: 0x80<br> &nbsp;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> &nbsp;bLength &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;18<br> &nbsp;bDescriptorType &nbsp; &nbsp; &nbsp; &nbsp; 1<br> &nbsp;bcdUSB &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
1.10<br> &nbsp;bDeviceClass &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0 (Defined at Interface level)<br> &nbsp;bDeviceSubClass &nbsp; &nbsp; &nbsp; &nbsp; 0<br> &nbsp;bDeviceProtocol &nbsp; &nbsp; &nbsp; &nbsp; 0<br> &nbsp;bMaxPacketSize0 &nbsp; &nbsp; &nbsp; &nbsp; 8<br> &nbsp;idVendor &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0x05e0 Symbol Technologies<br> &nbsp;idProduct &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0x0200
<br> &nbsp;bcdDevice &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2.04<br> &nbsp;iManufacturer &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1 (c) Symbol Technologies, Inc, 2000<br> &nbsp;iProduct &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2 Symbol Bar Code Scanner<br> &nbsp;iSerial &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 3 S/N:2925e1000000 Rev:NBRXUAAM3<br> &nbsp;bNumConfigurations &nbsp; &nbsp; &nbsp;1
<br> &nbsp;Configuration Descriptor:<br> &nbsp; &nbsp;bLength &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 9<br> &nbsp; &nbsp;bDescriptorType &nbsp; &nbsp; &nbsp; &nbsp; 2<br> &nbsp; &nbsp;wTotalLength &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 34<br> &nbsp; &nbsp;bNumInterfaces &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1<br> &nbsp; &nbsp;bConfigurationValue &nbsp; &nbsp; 1<br> &nbsp; &nbsp;iConfiguration &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0
<br> &nbsp; &nbsp;bmAttributes &nbsp; &nbsp; &nbsp; &nbsp; 0x80<br> &nbsp; &nbsp; &nbsp;(Bus Powered)<br> &nbsp; &nbsp;MaxPower &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;400mA<br> &nbsp; &nbsp;Interface Descriptor:<br> &nbsp; &nbsp; &nbsp;bLength &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 9<br> &nbsp; &nbsp; &nbsp;bDescriptorType &nbsp; &nbsp; &nbsp; &nbsp; 4<br> &nbsp; &nbsp; &nbsp;bInterfaceNumber &nbsp; &nbsp; &nbsp; &nbsp;0
<br> &nbsp; &nbsp; &nbsp;bAlternateSetting &nbsp; &nbsp; &nbsp; 0<br> &nbsp; &nbsp; &nbsp;bNumEndpoints &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1<br> &nbsp; &nbsp; &nbsp;bInterfaceClass &nbsp; &nbsp; &nbsp; &nbsp; 3 Human Interface Devices<br> &nbsp; &nbsp; &nbsp;bInterfaceSubClass &nbsp; &nbsp; &nbsp;1 Boot Interface Subclass<br> &nbsp; &nbsp; &nbsp;bInterfaceProtocol &nbsp; &nbsp; &nbsp;1 Keyboard
<br> &nbsp; &nbsp; &nbsp;iInterface &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0<br> &nbsp; &nbsp; &nbsp; &nbsp;HID Device Descriptor:<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bLength &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 9<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bDescriptorType &nbsp; &nbsp; &nbsp; &nbsp;33<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bcdHID &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1.10<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bCountryCode &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 33 US
<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bNumDescriptors &nbsp; &nbsp; &nbsp; &nbsp; 1<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bDescriptorType &nbsp; &nbsp; &nbsp; &nbsp;34 Report<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wDescriptorLength &nbsp; &nbsp; &nbsp;65<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Report Descriptor: (length is 65)<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Item(Global): Usage Page, data= [ 0x01 ] 1
<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Generic Desktop Controls<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Item(Local ): Usage, data= [ 0x06 ] 6<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Keyboard<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Item(Main &nbsp;): Collection, data= [ 0x01 ] 1<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Application
<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Item(Global): Usage Page, data= [ 0x07 ] 7<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Keyboard<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Item(Local ): Usage Minimum, data= [ 0xe0 ] 224<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Control Left<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Item(Local ): Usage Maximum, data= [ 0xe7 ] 231
<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GUI Right<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Item(Global): Logical Minimum, data= [ 0x00 ] 0<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Item(Global): Logical Maximum, data= [ 0x01 ] 1<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Item(Global): Report Size, data= [ 0x01 ] 1
<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Item(Global): Report Count, data= [ 0x08 ] 8<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Item(Main &nbsp;): Input, data= [ 0x02 ] 2<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Data Variable Absolute No_Wrap Linear<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Preferred_State No_Null_Position
<br>Non_Volatile Bitfield<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Item(Global): Report Count, data= [ 0x01 ] 1<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Item(Global): Report Size, data= [ 0x08 ] 8<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Item(Main &nbsp;): Input, data= [ 0x01 ] 1<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Constant Array Absolute No_Wrap Linear
<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Preferred_State No_Null_Position<br>Non_Volatile Bitfield<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Item(Global): Report Count, data= [ 0x05 ] 5<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Item(Global): Report Size, data= [ 0x01 ] 1<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Item(Global): Usage Page, data= [ 0x08 ] 8
<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LEDs<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Item(Local ): Usage Minimum, data= [ 0x01 ] 1<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;NumLock<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Item(Local ): Usage Maximum, data= [ 0x05 ] 5<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Kana
<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Item(Main &nbsp;): Output, data= [ 0x02 ] 2<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Data Variable Absolute No_Wrap Linear<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Preferred_State No_Null_Position<br>Non_Volatile Bitfield<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Item(Global): Report Count, data= [ 0x01 ] 1
<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Item(Global): Report Size, data= [ 0x03 ] 3<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Item(Main &nbsp;): Output, data= [ 0x01 ] 1<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Constant Array Absolute No_Wrap Linear<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Preferred_State No_Null_Position
<br>Non_Volatile Bitfield<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Item(Global): Report Count, data= [ 0x06 ] 6<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Item(Global): Report Size, data= [ 0x08 ] 8<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Item(Global): Logical Minimum, data= [ 0x00 ] 0<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Item(Global): Usage Page, data= [ 0x07 ] 7<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Keyboard<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Item(Local ): Usage Minimum, data= [ 0x00 ] 0<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;No Event<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Item(Local ): Usage Maximum, data= [ 0xff 0x00 ] 255
<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(null)<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Item(Main &nbsp;): Input, data= [ 0x00 ] 0<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Data Array Absolute No_Wrap Linear<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Preferred_State No_Null_Position
<br>Non_Volatile Bitfield<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Item(Main &nbsp;): End Collection, data=none<br> &nbsp; &nbsp; &nbsp;Endpoint Descriptor:<br> &nbsp; &nbsp; &nbsp; &nbsp;bLength &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 7<br> &nbsp; &nbsp; &nbsp; &nbsp;bDescriptorType &nbsp; &nbsp; &nbsp; &nbsp; 5<br> &nbsp; &nbsp; &nbsp; &nbsp;bEndpointAddress &nbsp; &nbsp; 0x81 &nbsp;EP 1 IN
<br> &nbsp; &nbsp; &nbsp; &nbsp;bmAttributes &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;3<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Transfer Type &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Interrupt<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Synch Type &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; None<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Usage Type &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Data<br> &nbsp; &nbsp; &nbsp; &nbsp;wMaxPacketSize &nbsp; &nbsp; 0x0008 &nbsp;1x 8 bytes
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;bInterval &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;10<br>Device Status: &nbsp; &nbsp; 0x0000<br> &nbsp;(Bus Powered)<br>