SlideShare a Scribd company logo
1 of 16
Download to read offline
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
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
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
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
Evidence is clear…
  It’s a plot by Microsoft
                         ®




                             5
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
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
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
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
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
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
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
cat /proc/bus/usb/devices

T: Bus=01 Lev=01 Prnt=01 Port=02 Cnt=01 Dev#= 3 Spd=1.5
MxCh= 0
D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
P: Vendor=09db ProdID=007a Rev= 1.00
S: Manufacturer=MCC
S: Product=PMD-1208LS
S: SerialNumber=00013237
C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=100mA
I: If#= 0 Alt= 0 #EPs= 2 Cls=03(HID ) Sub=00 Prot=00 Driver=hid
E: Ad=81(I) Atr=03(Int.) MxPS= 8 Ivl=10ms
E: Ad=01(O) Atr=03(Int.) MxPS= 8 Ivl=10ms




                                                         13
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
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
Questions …




              16

More Related Content

Similar to 2005 07-hidusb

Creating IoT application using ARM mbed and NanoService solution
Creating IoT application using ARM mbed and NanoService solutionCreating IoT application using ARM mbed and NanoService solution
Creating IoT application using ARM mbed and NanoService solutionPratul Sharma
 
Tac Presentation October 72014- Raspberry PI
Tac Presentation October 72014- Raspberry PITac Presentation October 72014- Raspberry PI
Tac Presentation October 72014- Raspberry PICliff Samuels Jr.
 
The eID on Linux in 2015
The eID on Linux in 2015The eID on Linux in 2015
The eID on Linux in 2015Wouter Verhelst
 
Node-RED and getting started on the Internet of Things
Node-RED and getting started on the Internet of ThingsNode-RED and getting started on the Internet of Things
Node-RED and getting started on the Internet of ThingsBoris Adryan
 
Hardwear.io 2018 BLE Security Essentials workshop
Hardwear.io 2018 BLE Security Essentials workshopHardwear.io 2018 BLE Security Essentials workshop
Hardwear.io 2018 BLE Security Essentials workshopSlawomir Jasek
 
2nd ARM Developer Day - mbed Workshop - ARM
2nd ARM Developer Day - mbed Workshop - ARM2nd ARM Developer Day - mbed Workshop - ARM
2nd ARM Developer Day - mbed Workshop - ARMAntonio Mondragon
 
Project ACRN USB mediator introduction
Project ACRN USB mediator introductionProject ACRN USB mediator introduction
Project ACRN USB mediator introductionProject ACRN
 
Curso de Desenvolvimento Mobile - Android - Stack
Curso de Desenvolvimento Mobile - Android - StackCurso de Desenvolvimento Mobile - Android - Stack
Curso de Desenvolvimento Mobile - Android - StackJackson F. de A. Mafra
 
Android Variants, Hacks, Tricks and Resources presented at AnDevConII
Android Variants, Hacks, Tricks and Resources presented at AnDevConIIAndroid Variants, Hacks, Tricks and Resources presented at AnDevConII
Android Variants, Hacks, Tricks and Resources presented at AnDevConIIOpersys inc.
 
[CONFidence 2016] Sławomir Kosowski - Introduction to iOS Application Securit...
[CONFidence 2016] Sławomir Kosowski - Introduction to iOS Application Securit...[CONFidence 2016] Sławomir Kosowski - Introduction to iOS Application Securit...
[CONFidence 2016] Sławomir Kosowski - Introduction to iOS Application Securit...PROIDEA
 
Informix Expedition Through Connectivity
Informix Expedition Through ConnectivityInformix Expedition Through Connectivity
Informix Expedition Through ConnectivityKevin Smith
 
IoT Getting Started with Intel® IoT Devkit
IoT Getting Started with Intel® IoT DevkitIoT Getting Started with Intel® IoT Devkit
IoT Getting Started with Intel® IoT DevkitVasily Ryzhonkov
 
Андрей Володин — Как подружиться с роботом
Андрей Володин — Как подружиться с роботомАндрей Володин — Как подружиться с роботом
Андрей Володин — Как подружиться с роботомCocoaHeads
 
Research Poster
Research PosterResearch Poster
Research Posterxiang wang
 
Android As a Server- Building Android for the Cloud (AnDevCon SF 2013)
Android As a Server- Building Android for the Cloud (AnDevCon SF 2013)Android As a Server- Building Android for the Cloud (AnDevCon SF 2013)
Android As a Server- Building Android for the Cloud (AnDevCon SF 2013)Ron Munitz
 

Similar to 2005 07-hidusb (20)

Beagle board101 esc-boston-2009b
Beagle board101 esc-boston-2009bBeagle board101 esc-boston-2009b
Beagle board101 esc-boston-2009b
 
Discover System Facilities inside Your Android Phone
Discover System Facilities inside Your Android Phone Discover System Facilities inside Your Android Phone
Discover System Facilities inside Your Android Phone
 
Creating IoT application using ARM mbed and NanoService solution
Creating IoT application using ARM mbed and NanoService solutionCreating IoT application using ARM mbed and NanoService solution
Creating IoT application using ARM mbed and NanoService solution
 
Tac Presentation October 72014- Raspberry PI
Tac Presentation October 72014- Raspberry PITac Presentation October 72014- Raspberry PI
Tac Presentation October 72014- Raspberry PI
 
Touch your NetBSD
Touch your NetBSDTouch your NetBSD
Touch your NetBSD
 
The eID on Linux in 2015
The eID on Linux in 2015The eID on Linux in 2015
The eID on Linux in 2015
 
Node-RED and getting started on the Internet of Things
Node-RED and getting started on the Internet of ThingsNode-RED and getting started on the Internet of Things
Node-RED and getting started on the Internet of Things
 
Hardwear.io 2018 BLE Security Essentials workshop
Hardwear.io 2018 BLE Security Essentials workshopHardwear.io 2018 BLE Security Essentials workshop
Hardwear.io 2018 BLE Security Essentials workshop
 
2nd ARM Developer Day - mbed Workshop - ARM
2nd ARM Developer Day - mbed Workshop - ARM2nd ARM Developer Day - mbed Workshop - ARM
2nd ARM Developer Day - mbed Workshop - ARM
 
Project ACRN USB mediator introduction
Project ACRN USB mediator introductionProject ACRN USB mediator introduction
Project ACRN USB mediator introduction
 
Curso de Desenvolvimento Mobile - Android - Stack
Curso de Desenvolvimento Mobile - Android - StackCurso de Desenvolvimento Mobile - Android - Stack
Curso de Desenvolvimento Mobile - Android - Stack
 
Android Variants, Hacks, Tricks and Resources presented at AnDevConII
Android Variants, Hacks, Tricks and Resources presented at AnDevConIIAndroid Variants, Hacks, Tricks and Resources presented at AnDevConII
Android Variants, Hacks, Tricks and Resources presented at AnDevConII
 
Android in ubuntu
Android in ubuntuAndroid in ubuntu
Android in ubuntu
 
[CONFidence 2016] Sławomir Kosowski - Introduction to iOS Application Securit...
[CONFidence 2016] Sławomir Kosowski - Introduction to iOS Application Securit...[CONFidence 2016] Sławomir Kosowski - Introduction to iOS Application Securit...
[CONFidence 2016] Sławomir Kosowski - Introduction to iOS Application Securit...
 
Informix Expedition Through Connectivity
Informix Expedition Through ConnectivityInformix Expedition Through Connectivity
Informix Expedition Through Connectivity
 
IoT Getting Started with Intel® IoT Devkit
IoT Getting Started with Intel® IoT DevkitIoT Getting Started with Intel® IoT Devkit
IoT Getting Started with Intel® IoT Devkit
 
Андрей Володин — Как подружиться с роботом
Андрей Володин — Как подружиться с роботомАндрей Володин — Как подружиться с роботом
Андрей Володин — Как подружиться с роботом
 
Research Poster
Research PosterResearch Poster
Research Poster
 
Android As a Server- Building Android for the Cloud (AnDevCon SF 2013)
Android As a Server- Building Android for the Cloud (AnDevCon SF 2013)Android As a Server- Building Android for the Cloud (AnDevCon SF 2013)
Android As a Server- Building Android for the Cloud (AnDevCon SF 2013)
 
Начало работы с Intel IoT Dev Kit
Начало работы с Intel IoT Dev KitНачало работы с Intel IoT Dev Kit
Начало работы с Intel IoT Dev Kit
 

Recently uploaded

The Selfspace Journal Preview by Mindbrush
The Selfspace Journal Preview by MindbrushThe Selfspace Journal Preview by Mindbrush
The Selfspace Journal Preview by MindbrushShivain97
 
9892124323, Call Girls in mumbai, Vashi Call Girls , Kurla Call girls
9892124323, Call Girls in mumbai, Vashi Call Girls , Kurla Call girls9892124323, Call Girls in mumbai, Vashi Call Girls , Kurla Call girls
9892124323, Call Girls in mumbai, Vashi Call Girls , Kurla Call girlsPooja Nehwal
 
2k Shots ≽ 9205541914 ≼ Call Girls In Palam (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Palam (Delhi)2k Shots ≽ 9205541914 ≼ Call Girls In Palam (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Palam (Delhi)Delhi Call girls
 
Lilac Illustrated Social Psychology Presentation.pptx
Lilac Illustrated Social Psychology Presentation.pptxLilac Illustrated Social Psychology Presentation.pptx
Lilac Illustrated Social Psychology Presentation.pptxABMWeaklings
 
Top Rated Pune Call Girls Tingre Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Tingre Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Tingre Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Tingre Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
Introducing to billionaire brain wave.pdf
Introducing to billionaire brain wave.pdfIntroducing to billionaire brain wave.pdf
Introducing to billionaire brain wave.pdfnoumannajam04
 
call Now 9811711561 Cash Payment乂 Call Girls in Dwarka Mor
call Now 9811711561 Cash Payment乂 Call Girls in Dwarka Morcall Now 9811711561 Cash Payment乂 Call Girls in Dwarka Mor
call Now 9811711561 Cash Payment乂 Call Girls in Dwarka Morvikas rana
 
Lucknow 💋 High Class Call Girls Lucknow 10k @ I'm VIP Independent Escorts Gir...
Lucknow 💋 High Class Call Girls Lucknow 10k @ I'm VIP Independent Escorts Gir...Lucknow 💋 High Class Call Girls Lucknow 10k @ I'm VIP Independent Escorts Gir...
Lucknow 💋 High Class Call Girls Lucknow 10k @ I'm VIP Independent Escorts Gir...anilsa9823
 
2k Shots ≽ 9205541914 ≼ Call Girls In Mukherjee Nagar (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Mukherjee Nagar (Delhi)2k Shots ≽ 9205541914 ≼ Call Girls In Mukherjee Nagar (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Mukherjee Nagar (Delhi)Delhi Call girls
 
CALL ON ➥8923113531 🔝Call Girls Aliganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Aliganj Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Aliganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Aliganj Lucknow best sexual serviceanilsa9823
 
2k Shots ≽ 9205541914 ≼ Call Girls In Dashrath Puri (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Dashrath Puri (Delhi)2k Shots ≽ 9205541914 ≼ Call Girls In Dashrath Puri (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Dashrath Puri (Delhi)Delhi Call girls
 
CALL ON ➥8923113531 🔝Call Girls Jankipuram Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Jankipuram Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Jankipuram Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Jankipuram Lucknow best sexual serviceanilsa9823
 
Pokemon Go... Unraveling the Conspiracy Theory
Pokemon Go... Unraveling the Conspiracy TheoryPokemon Go... Unraveling the Conspiracy Theory
Pokemon Go... Unraveling the Conspiracy Theorydrae5
 
call girls in candolim beach 9870370636] NORTH GOA ..
call girls in candolim beach 9870370636] NORTH GOA ..call girls in candolim beach 9870370636] NORTH GOA ..
call girls in candolim beach 9870370636] NORTH GOA ..nishakur201
 
CALL ON ➥8923113531 🔝Call Girls Mahanagar Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Mahanagar Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Mahanagar Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Mahanagar Lucknow best sexual serviceanilsa9823
 
LC_YouSaidYes_NewBelieverBookletDone.pdf
LC_YouSaidYes_NewBelieverBookletDone.pdfLC_YouSaidYes_NewBelieverBookletDone.pdf
LC_YouSaidYes_NewBelieverBookletDone.pdfpastor83
 
8377087607 Full Enjoy @24/7-CLEAN-Call Girls In Chhatarpur,
8377087607 Full Enjoy @24/7-CLEAN-Call Girls In Chhatarpur,8377087607 Full Enjoy @24/7-CLEAN-Call Girls In Chhatarpur,
8377087607 Full Enjoy @24/7-CLEAN-Call Girls In Chhatarpur,dollysharma2066
 
CALL ON ➥8923113531 🔝Call Girls Rajajipuram Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Rajajipuram Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Rajajipuram Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Rajajipuram Lucknow best sexual serviceanilsa9823
 

Recently uploaded (20)

The Selfspace Journal Preview by Mindbrush
The Selfspace Journal Preview by MindbrushThe Selfspace Journal Preview by Mindbrush
The Selfspace Journal Preview by Mindbrush
 
9892124323, Call Girls in mumbai, Vashi Call Girls , Kurla Call girls
9892124323, Call Girls in mumbai, Vashi Call Girls , Kurla Call girls9892124323, Call Girls in mumbai, Vashi Call Girls , Kurla Call girls
9892124323, Call Girls in mumbai, Vashi Call Girls , Kurla Call girls
 
(Aarini) Russian Call Girls Surat Call Now 8250077686 Surat Escorts 24x7
(Aarini) Russian Call Girls Surat Call Now 8250077686 Surat Escorts 24x7(Aarini) Russian Call Girls Surat Call Now 8250077686 Surat Escorts 24x7
(Aarini) Russian Call Girls Surat Call Now 8250077686 Surat Escorts 24x7
 
2k Shots ≽ 9205541914 ≼ Call Girls In Palam (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Palam (Delhi)2k Shots ≽ 9205541914 ≼ Call Girls In Palam (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Palam (Delhi)
 
Lilac Illustrated Social Psychology Presentation.pptx
Lilac Illustrated Social Psychology Presentation.pptxLilac Illustrated Social Psychology Presentation.pptx
Lilac Illustrated Social Psychology Presentation.pptx
 
Top Rated Pune Call Girls Tingre Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Tingre Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Tingre Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Tingre Nagar ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Introducing to billionaire brain wave.pdf
Introducing to billionaire brain wave.pdfIntroducing to billionaire brain wave.pdf
Introducing to billionaire brain wave.pdf
 
(Anamika) VIP Call Girls Navi Mumbai Call Now 8250077686 Navi Mumbai Escorts ...
(Anamika) VIP Call Girls Navi Mumbai Call Now 8250077686 Navi Mumbai Escorts ...(Anamika) VIP Call Girls Navi Mumbai Call Now 8250077686 Navi Mumbai Escorts ...
(Anamika) VIP Call Girls Navi Mumbai Call Now 8250077686 Navi Mumbai Escorts ...
 
call Now 9811711561 Cash Payment乂 Call Girls in Dwarka Mor
call Now 9811711561 Cash Payment乂 Call Girls in Dwarka Morcall Now 9811711561 Cash Payment乂 Call Girls in Dwarka Mor
call Now 9811711561 Cash Payment乂 Call Girls in Dwarka Mor
 
Lucknow 💋 High Class Call Girls Lucknow 10k @ I'm VIP Independent Escorts Gir...
Lucknow 💋 High Class Call Girls Lucknow 10k @ I'm VIP Independent Escorts Gir...Lucknow 💋 High Class Call Girls Lucknow 10k @ I'm VIP Independent Escorts Gir...
Lucknow 💋 High Class Call Girls Lucknow 10k @ I'm VIP Independent Escorts Gir...
 
2k Shots ≽ 9205541914 ≼ Call Girls In Mukherjee Nagar (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Mukherjee Nagar (Delhi)2k Shots ≽ 9205541914 ≼ Call Girls In Mukherjee Nagar (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Mukherjee Nagar (Delhi)
 
CALL ON ➥8923113531 🔝Call Girls Aliganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Aliganj Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Aliganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Aliganj Lucknow best sexual service
 
2k Shots ≽ 9205541914 ≼ Call Girls In Dashrath Puri (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Dashrath Puri (Delhi)2k Shots ≽ 9205541914 ≼ Call Girls In Dashrath Puri (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Dashrath Puri (Delhi)
 
CALL ON ➥8923113531 🔝Call Girls Jankipuram Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Jankipuram Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Jankipuram Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Jankipuram Lucknow best sexual service
 
Pokemon Go... Unraveling the Conspiracy Theory
Pokemon Go... Unraveling the Conspiracy TheoryPokemon Go... Unraveling the Conspiracy Theory
Pokemon Go... Unraveling the Conspiracy Theory
 
call girls in candolim beach 9870370636] NORTH GOA ..
call girls in candolim beach 9870370636] NORTH GOA ..call girls in candolim beach 9870370636] NORTH GOA ..
call girls in candolim beach 9870370636] NORTH GOA ..
 
CALL ON ➥8923113531 🔝Call Girls Mahanagar Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Mahanagar Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Mahanagar Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Mahanagar Lucknow best sexual service
 
LC_YouSaidYes_NewBelieverBookletDone.pdf
LC_YouSaidYes_NewBelieverBookletDone.pdfLC_YouSaidYes_NewBelieverBookletDone.pdf
LC_YouSaidYes_NewBelieverBookletDone.pdf
 
8377087607 Full Enjoy @24/7-CLEAN-Call Girls In Chhatarpur,
8377087607 Full Enjoy @24/7-CLEAN-Call Girls In Chhatarpur,8377087607 Full Enjoy @24/7-CLEAN-Call Girls In Chhatarpur,
8377087607 Full Enjoy @24/7-CLEAN-Call Girls In Chhatarpur,
 
CALL ON ➥8923113531 🔝Call Girls Rajajipuram Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Rajajipuram Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Rajajipuram Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Rajajipuram Lucknow best sexual service
 

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
  • 5. Evidence is clear… It’s a plot by Microsoft ® 5
  • 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
  • 13. cat /proc/bus/usb/devices T: Bus=01 Lev=01 Prnt=01 Port=02 Cnt=01 Dev#= 3 Spd=1.5 MxCh= 0 D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1 P: Vendor=09db ProdID=007a Rev= 1.00 S: Manufacturer=MCC S: Product=PMD-1208LS S: SerialNumber=00013237 C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=100mA I: If#= 0 Alt= 0 #EPs= 2 Cls=03(HID ) Sub=00 Prot=00 Driver=hid E: Ad=81(I) Atr=03(Int.) MxPS= 8 Ivl=10ms E: Ad=01(O) Atr=03(Int.) MxPS= 8 Ivl=10ms 13
  • 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