[libhid-discuss] reading from a barcode scanner that acts like a
keyboard
Brice Rebsamen
brice.brice at gmail.com
Mon Nov 6 03:53:11 CET 2006
Hello,
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.
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?
Below is the output of usbview, test_libhid and lsusb
Thanks,
Brice
$ usbview
Symbol Bar Code Scanner
...
Speed: 12Mb/s (full)
USB Version: 1.10
Device Class: 00(>ifc )
Device Subclass: 00
Device Protocol: 00
Maximum Default Endpoint Size: 8
Number of Configurations: 1
...
Config Number: 1
Number of Interfaces: 1
Attributes: 80
Max Power Needed: 400mA
Interface Number: 0
Name: (none)
Alternate Number: 0
Class: 03(HID )
Sub Class: 1
Protocol: 1
Number of Endpoints: 1
Endpoint Address: 81
Direction: in
Attribute: Int.
Max Packet Size: 8
Interval: 10ms
$ test_libhid
parse tree of HIDInterface 002/004[0]:
path: 0x00010006.0x00000000; type: 0x80
path: 0x00010006.0x00000000 ; type: 0x80
path: 0x00010006.0x00000000; type: 0x80
path: 0x00010006.0x00000000; type: 0x80
path: 0x00010006.0x00000000; type: 0x80
path: 0x00010006.0x00000000; type: 0x80
path: 0x00010006.0x00000000 ; type: 0x80
path: 0x00010006.0x00000000; type: 0x80
path: 0x00010006.0x00000000; type: 0x80
path: 0x00010006.0x00000000; type: 0x90
path: 0x00010006.0x00000000; type: 0x90
path: 0x00010006.0x00000000 ; type: 0x90
path: 0x00010006.0x00000000; type: 0x90
path: 0x00010006.0x00000000; type: 0x90
path: 0x00010006.0x00000000; type: 0x90
path: 0x00010006.0x00000000; type: 0x80
path: 0x00010006.0x00000000 ; type: 0x80
path: 0x00010006.0x00000000; type: 0x80
path: 0x00010006.0x00000000; type: 0x80
path: 0x00010006.0x00000000; type: 0x80
path: 0x00010006.0x00000000; type: 0x80
$ lsusb -s 2:4 -vvv
Bus 002 Device 004: ID 05e0:0200 Symbol Technologies
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 8
idVendor 0x05e0 Symbol Technologies
idProduct 0x0200
bcdDevice 2.04
iManufacturer 1 (c) Symbol Technologies, Inc, 2000
iProduct 2 Symbol Bar Code Scanner
iSerial 3 S/N:2925e1000000 Rev:NBRXUAAM3
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 34
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 400mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 3 Human Interface Devices
bInterfaceSubClass 1 Boot Interface Subclass
bInterfaceProtocol 1 Keyboard
iInterface 0
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.10
bCountryCode 33 US
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 65
Report Descriptor: (length is 65)
Item(Global): Usage Page, data= [ 0x01 ] 1
Generic Desktop Controls
Item(Local ): Usage, data= [ 0x06 ] 6
Keyboard
Item(Main ): Collection, data= [ 0x01 ] 1
Application
Item(Global): Usage Page, data= [ 0x07 ] 7
Keyboard
Item(Local ): Usage Minimum, data= [ 0xe0 ] 224
Control Left
Item(Local ): Usage Maximum, data= [ 0xe7 ] 231
GUI Right
Item(Global): Logical Minimum, data= [ 0x00 ] 0
Item(Global): Logical Maximum, data= [ 0x01 ] 1
Item(Global): Report Size, data= [ 0x01 ] 1
Item(Global): Report Count, data= [ 0x08 ] 8
Item(Main ): Input, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position
Non_Volatile Bitfield
Item(Global): Report Count, data= [ 0x01 ] 1
Item(Global): Report Size, data= [ 0x08 ] 8
Item(Main ): Input, data= [ 0x01 ] 1
Constant Array Absolute No_Wrap Linear
Preferred_State No_Null_Position
Non_Volatile Bitfield
Item(Global): Report Count, data= [ 0x05 ] 5
Item(Global): Report Size, data= [ 0x01 ] 1
Item(Global): Usage Page, data= [ 0x08 ] 8
LEDs
Item(Local ): Usage Minimum, data= [ 0x01 ] 1
NumLock
Item(Local ): Usage Maximum, data= [ 0x05 ] 5
Kana
Item(Main ): Output, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position
Non_Volatile Bitfield
Item(Global): Report Count, data= [ 0x01 ] 1
Item(Global): Report Size, data= [ 0x03 ] 3
Item(Main ): Output, data= [ 0x01 ] 1
Constant Array Absolute No_Wrap Linear
Preferred_State No_Null_Position
Non_Volatile Bitfield
Item(Global): Report Count, data= [ 0x06 ] 6
Item(Global): Report Size, data= [ 0x08 ] 8
Item(Global): Logical Minimum, data= [ 0x00 ] 0
Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
Item(Global): Usage Page, data= [ 0x07 ] 7
Keyboard
Item(Local ): Usage Minimum, data= [ 0x00 ] 0
No Event
Item(Local ): Usage Maximum, data= [ 0xff 0x00 ] 255
(null)
Item(Main ): Input, data= [ 0x00 ] 0
Data Array Absolute No_Wrap Linear
Preferred_State No_Null_Position
Non_Volatile Bitfield
Item(Main ): End Collection, data=none
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 10
Device Status: 0x0000
(Bus Powered)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.alioth.debian.org/pipermail/libhid-discuss/attachments/20061106/03de5da0/attachment.htm
More information about the libhid-discuss
mailing list