Linux USB Device Fundamentals

Original link: https://blog.frytea.com/archives/633/

Get all the USB devices of the physical node by scanning the following directories:

 /sys/bus/usb/devices/usb* /sys/bus/usb/devices/usb*/$busnum-*

The main information collected for a device from this file system is as follows:

 { "busnum": 1, "class": 0, "devnum": 2, "level": 1, "manufacturer": "QEMU", "port": 0, "prodid": "0001", "product": "QEMU USB Tablet", "speed": "12", "usbpath": "1", "vendid": "0627" }

File meaning

Some files in the directory have the following meanings:

  • busnum : bus number
  • devnum : device number (the first device on the bus)
  • speed : speed
  • bDeviceClass : device type
  • idVendor : The manufacturer ID of the device, which is managed and applied by the USB device manufacturer to the USB-IF official
  • idProduct : The product number produced by the manufacturer, different idProducts under the same manufacturer represent different product series of the company
  • product : manufacturer
  • manufacturer : product
  • serial : USB hardware device serial number, for example 0000:00:01.2

positioning method

There are two ways to locate a USB device:

  • busnum + devnum
  • idVendor + idProduct

Device type bDeviceClass

class code usage describe
00h device descriptor Use class information in the interface Descriptors
01h interface descriptor audio
02h device descriptor, interface descriptor Communication equipment, such as telephones, modems, etc.
03h interface descriptor HID equipment
05h interface descriptor Physical
06h interface descriptor Image
07h interface descriptor printer
08h interface descriptor mass storage
09h device descriptor Hub USB hub
0Ah interface descriptor CDC-Data
0Bh interface descriptor Smart Card
0Dh interface descriptor Content Security
0Eh interface descriptor UVC Video/CAMERA
0Fh interface descriptor Personal Healthcare
10h interface descriptor Audio and video equipment
11h device descriptor Billboard Device Class
12h interface descriptor USB Type-C Bridge Class
DCh device descriptor, interface descriptor Diagnostic Device
E0h interface descriptor Wireless Controller
EFh device descriptor, interface descriptor Miscellaneous
FEh interface descriptor Application Specific
FFh device descriptor, interface descriptor Manufacturer’s custom

references

This article is reproduced from: https://blog.frytea.com/archives/633/
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment