首页 技术 正文
技术 2022年11月16日
0 收藏 796 点赞 4,659 浏览 4894 个字

来源:Linux中国  原文:https://linux.cn/article-2448-1.html

通用串行总线(USB)被设计成为连接计算机外设的标准,如键盘、鼠标、打印机、数码相机、便携式媒体播放器、磁盘和网络适配器等等 – 来源:Wikipedia

它已经成为了一个工业标准,现在很难看到一个没有USB口的计算机了。USB闪存的使用使得它更加流行。在Linux上,我们可以使用lsusb来列出USB设备和它的属性。

什么是lsusb

在它的手册上,lsusb定义成:

显示系统中以及连接到系统的USB总线信息的工具。

如何运行lsusb? 要运行lsusb,你可以直接在控制台输入lsusb。

$ lsusbBus  Device : ID 1d6b: Linux Foundation 2.0 root hub
Bus Device : ID 1d6b: Linux Foundation 2.0 root hub
Bus Device : ID 1d6b: Linux Foundation 1.1 root hub
Bus Device : ID 1d6b: Linux Foundation 1.1 root hub
Bus Device : ID 1d6b: Linux Foundation 1.1 root hub
Bus Device : ID 1d6b: Linux Foundation 1.1 root hub
Bus Device : ID 1d6b: Linux Foundation 1.1 root hub
Bus Device : ID 1d6b: Linux Foundation 1.1 root hub
Bus Device : ID 17ef: Lenovo Integrated Webcam [R5U877]
Bus Device : ID 0a5c:217f Broadcom Corp. Bluetooth Controller

lsusb会显示驱动和内部连接到你系统的设备。

下面介绍如何理解输出。我抓取了上面输出的最后一行:

Bus  Device  : ID 0a5c:217f Broadcom Corp. Bluetooth Controller
  • Bus 008 : 指明设备连接到哪(哪条总线)
  • Device 002 : 表明这是连接到总线上的第二台设备
  • ID : 设备的ID
  • Broadcom Corp. Bluetooth Controller :生产商名字和设备名

我们同样可以看到在我们的系统中同时使用了USB2.0 root hub驱动和USB 1.1 root hub驱动。

dmesg命令同样可以看到。下面是一个例子。

$ dmesg |grep -i usb[ 0.353138] usbcore: registered new interface driver usbfs
[ 0.353150] usbcore: registered new interface driver hub
[ 0.353182] usbcore: registered new device driver usb
[ 0.730026] ehci_hcd: USB 2.0 ‘Enhanced’ Host Controller (EHCI) Driver
[ 0.730116] ehci_hcd ::1a.: new USB bus registered, assigned bus number
[ 0.748019] ehci_hcd ::1a.: USB 2.0 started, EHCI 1.00
[ 0.748169] hub -:1.0: USB hub found
[ 0.748336] ehci_hcd ::1d.: new USB bus registered, assigned bus number
[ 0.768019] ehci_hcd ::1d.: USB 2.0 started, EHCI 1.00
[ 0.768147] hub -:1.0: USB hub found
[ 0.768236] ohci_hcd: USB 1.1 ‘Open’ Host Controller (OHCI) Driver
[ 0.768251] uhci_hcd: USB Universal Host Controller Interface driver

如何列出USB详细信息

使用-v选项来开启。下面是一个例子。

$ lsusb -vInterface Descriptor:
bLength
bDescriptorType
bInterfaceNumber
bAlternateSetting
bNumEndpoints
bInterfaceClass Wireless
bInterfaceSubClass Radio Frequency
bInterfaceProtocol Bluetooth
iInterface
Endpoint Descriptor:
bLength
bDescriptorType
bEndpointAddress × EP IN
bmAttributes
Transfer Type Isochronous
Synch Type None
Usage Type Data
wMaxPacketSize × 1x bytes
bInterval
Endpoint Descriptor:
bLength
bDescriptorType
bEndpointAddress × EP OUT
bmAttributes
Transfer Type Isochronous
Synch Type None
Usage Type Data
wMaxPacketSize × 1x bytes
bInterval

找出连接了多少USB设备

使用下面的命令

$ find /dev/bus

接着你会看到像下面的输出:

/dev/bus
/dev/bus/usb
/dev/bus/usb/
/dev/bus/usb//
/dev/bus/usb//
/dev/bus/usb/
/dev/bus/usb//
/dev/bus/usb/
/dev/bus/usb//
/dev/bus/usb/
/dev/bus/usb//
/dev/bus/usb/
/dev/bus/usb//
/dev/bus/usb/
/dev/bus/usb//
/dev/bus/usb/
/dev/bus/usb//
/dev/bus/usb//
/dev/bus/usb//
/dev/bus/usb/
/dev/bus/usb//
使用lsusb 命令 的-D 选项,你可以打印特定设备的详细信息。下面是一个博通蓝牙设备的示例。$ lsusb -D /dev/bus/usb//Device: ID 0a5c:217f Broadcom Corp. Bluetooth Controller
Couldn’t open device, some information will be missing
Device Descriptor:
bLength
bDescriptorType
bcdUSB 2.00
bDeviceClass Wireless
bDeviceSubClass Radio Frequency
bDeviceProtocol Bluetooth
bMaxPacketSize0
idVendor 0x0a5c Broadcom Corp.
idProduct 0x217f Bluetooth Controller
bcdDevice 3.60
iManufacturer
iProduct
iSerial
bNumConfigurations
Configuration Descriptor:
bLength
bDescriptorType
wTotalLength
bNumInterfaces
bConfigurationValue
iConfiguration
bmAttributes 0xe0
Self Powered
Remote Wakeup
MaxPower 0mA
Interface Descriptor:
bLength
bDescriptorType
bInterfaceNumber
bAlternateSetting
bNumEndpoints
bInterfaceClass Wireless
bInterfaceSubClass Radio Frequency
bInterfaceProtocol Bluetooth
iInterface
Endpoint Descriptor:
bLength
bDescriptorType
bEndpointAddress × EP IN
bmAttributes
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize × 1x bytes
bInterval
Endpoint Descriptor:
bLength
bDescriptorType
bEndpointAddress × EP IN
bmAttributes
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize × 1x bytes
bInterval
Endpoint Descriptor:
bLength
bDescriptorType
bEndpointAddress × EP OUT
bmAttributes
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize × 1x bytes
bInterval

找出大容量存储设备

既然 lsusb -v给我们很详细的信息,那么你或许会错过一些信息。我们可以使用grep命令指定特定的信息。

大容量存储设备会有一个供应商名和ID。我们可以用它作为一个起点。

$ lsusb -v |grep -Ei ‘(idVendor|Mass\ Storage)’idVendor 0×1005 Apacer Technology, Inc.
bInterfaceClass 8 Mass Storage

你可以看到,我们系统上有一个来自Apacer Technology, Inc的USB大容量存储设备。

以树层级结构输出USB设备

使用 -t选项满足这个要求

$ lsusb -t/: Bus .Port : Dev , class="root"\_hub, Driver=uhci_hcd/2p, 12M
/: Bus .Port : Dev , class="root"\_hub, Driver=uhci_hcd/2p, 12M
/: Bus .Port : Dev , class="root"\_hub, Driver=uhci_hcd/2p, 12M
/: Bus .Port : Dev , class="root"\_hub, Driver=uhci_hcd/2p, 12M
/: Bus .Port : Dev , class="root"\_hub, Driver=uhci_hcd/2p, 12M
/: Bus .Port : Dev , class="root"\_hub, Driver=uhci_hcd/2p, 12M
/: Bus .Port : Dev , class="root"\_hub, Driver=ehci_hcd/6p, 480M
|__ Port : Dev , If , class="stor"., Driver=usb-storage, 480M
|__ Port : Dev , If , Class=’bInterfaceClass 0x0e not yet handled’, Driver=uvcvideo, 480M
|__ Port : Dev , If , Class=’bInterfaceClass 0x0e not yet handled’, Driver=uvcvideo, 480M
/: Bus .Port : Dev , class="root"\_hub, Driver=ehci_hcd/6p, 480M

数字12M和480M 是指USB类型的传输速率。

  • 12M 意味着 USB 1.0 / 1.1的速率是 12Mbit/s
  • 480M 意味着 USB 2.0的速率是 480Mbit/s

如果你找到5.0G,那意味这你有USB 3.0类型接口。它有5.0Gbit/s的传输速率。Linux从/var/lib/usbutils/usb.ids识别USB设备的详细信息。或者你可以访问Linux-USB.org获取最新的USB ID列表。

这些就是lsusb命令的基础。你可以用lsusb命令对你的系统上的USB设备做一个诊断。一般来说,你可以通过lsusb的手册探索命令的更多详细细节。只要输入man lsab来打开它的手册。

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,035
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,521
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,369
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,150
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,783
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,864