(No.1)↠Young Call Girls in Sikanderpur (Gurgaon) ꧁❤ 9711911712 ❤꧂ Escorts
2005 07-hidusb
1. Linux HID/USB
or
How I got the !@#%! LED to
Blink
By:
Warren Jasper wjasper@tx.ncsu.edu
Mike Erickson mikee@signalscape.com
July 14, 2005
1
2. Overview
What is HID? A quick tutorial on
Interfaces, Endpoints, Reports, and
Usages.
The PMD 1208-LS. An example of a low
cost USB data acquisition device.
hiddev: the Linux HID driver
libusb/libhid: An alternative
Demos:
2
3. HID – Human Interface Device
Originally intended for mice, keyboards, joysticks and
similar devices used by humans to control the
operation of computers.
Control and Interrupt pipes only
n No bulk
n No isochronous
Proliferated possibly because Windows has
®
comprehensive user space support.
Many devices now “shoehorned” into HID protocol to
avoid writing Windows kernel drivers.
3
4. HID – Self Describing
Host can infer from USB descriptors how to talk to device,
especially canonical HID devices.
Descriptors can be very complex.
n Device
n Interface
n Endpoint
n HID
n Physical
n Report
n Field
n Usage
“Shoehorned” devices can be lip-numbingly complex
Evidence is clear…
4
6. Interfacing HID under Linux
There are three choices
that one can use to
interface to a HID device:
1. Write a Linux Device
Driver
2. Use usbhid (/dev/hiddev*)
3. Use libusb/libhid
6
7. Pros: hiddev
Comes by default on most Linux
distributions.
Fairly easy to use (if one knows how)
It works from user space without being
root. (Don’t forget to
chmod /dev/usb/hiddev*)
or set permissions in udev
7
8. Cons: hiddev
hiddev is broken under Linux 2.4
hiddev enforces the usage max/min limits, which
cause problems in the LS series.
hiddev is quite slow. Could not reliable get more
than 200-500 Hz through the driver.
n Usages are sent a byte at a time!!
Lots of delays have to be put into the code for
reliable data transfer.
Documentation and examples are almost non-
existent.
Difficult to disassociate the HID driver from the
interface.
8
9. Pros: libusb/libhid
Works under 2.4 and 2.6 kernel.
Does not enforce usage max/min.
Data transfer done through libusb calls,
thus much faster then hiddev.
n For LS series 3X
n For FS series 50X?
Works under Linux/Windows, MacOS
9
10. Cons: libusb/libhid
Need to be root or have program run suid
unless one configures hotplug.
Interfacing with the device with low level
libusb calls requires a deeper understanding
of the HID interface on the device side.
There is no functionality for sending reports
from libhid.
There are still some timing issues, but more
stable then hiddev.
Lots of configuration dependencies.
10
11. Resources
Linux Device Drivers, Alessandro Rubini,
Corbet and Kroah-Hartman, O’Reilly &
Associates. Third edition.
ftp://lx10.tx.ncsu.edu:/pub/Linux/drivers
http://www.usb.org/developers/hidpage/
http://libhid.alioth.debian.org/
11
12. An Example
Let’s look at an actual
code for the PMD-
1208LS. This menu
driven code
exercises some of
the features of the
device.
12
14. To disassociate the hid driver
1. Remove the hid driver. This is rather drastic, and will cause all other
hid devices (mouse, keyboard, etc.) not to work.
2. In the kernel source /usr/src/linux-XX/drivers/usb/hid-core. There is a
blacklist structure:
struct hid_blacklist {
__u16 idVendor;
__u16 idProduct;
unsigned quirks;
} hid_blacklist[] = {
For example:
#define USB_VENDOR_ID_MEASUREMENT_COMPUTING 0x09db
#define USB_DEVICE_ID_PMD-1208LS 0x007a
Then at the bottom of the hid_blacklist[]
{ USB_VENDOR_ID_MEASUREMENT_COMPUTING,
USB_DEVICE_ID_PMD-1024LS, HID_QUIRK_IGNORE },
{ 0, 0 }
.
14
15. To disassociate the hid driver
3. The third option is the easiest and
most flexible. Along with the libhid
package there is a program called
libhid-detach-device.
Example:
libhid-detach-device 09db:007a
15