检测插入的 USB 设备 [英] Detection of plugged in USB device

查看:39
本文介绍了检测插入的 USB 设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道,系统的哪一部分负责检测USB端口插入的设备

I'd like to know, which part of the system is responsible for detection of plugged-in device in the USB port

它可能是 USB 主机端口,因此插入的设备将被视为 USB 客户端(因此端口所有者是主机),
或者它可能是 USB 客户端端口,因此插入的设备将被视为 USB 主机(因此端口所有者是客户端)

It may be a USB host port, so that a plugged-in device will be considered a USB client (so port owner is host),
or it may be a USB client port, so that a plugged-in device will be considered a USB host (so port owner is client)

我感兴趣的是当系统实际检测到(可能通过电阻变化)某些东西已插入时的时刻,并基于信号来自哪个端口(主机端口或客户端端口),无论是主机已部署端口驱动程序或客户端端口驱动程序
我想知道,系统如何根据插入"事件选择这个或那个驱动程序

What I am interested in is a moment WHEN the system actually detects (by change of resistance maybe) that something has been plugged in, and based on from which port the signal is coming (host port or client port), either host port driver or client port driver is deployed
I want to know, HOW system picks up this or that driver, based on that "plugged-in" event

我应该去哪里找那个?在 USB 核心也许?

Where should I look for that ? In USB core maybe ?

推荐答案

USB 子系统负责检测和探测新添加/热插拔的 USB 设备.查看内核日志中的消息,例如:

The usb subsystem is responsible for detecting and probing newly added/hotplugged USB devices. Look in the kernel logs for messages like:

usb usb4:找到新的 USB 设备,idVendor=1d6b,idProduct=0001
usb usb4:新的 USB 设备字符串:Mfr=3、Product=2、SerialNumber=1
usb usb4:产品:OHCI 主机控制器
usb usb4:制造商:Linux 2.6.32 ohci_hcd
usb usb4:序列号:0000:00:12.1
usb usb4:配置 #1 从 1 个选择中选择

处理这一切的代码位于drivers/usb/core

The code which handles all this is located in drivers/usb/core

usb 子系统位于 scsi 子系统下方,因此您新分配的设备将具有类似 /dev/sdX 的设备名称.udev 的工作是在 /dev 中创建与此 USB 设备相对应的新设备节点.如果您有兴趣捕获此事件并运行执行某些通知的脚本,您可能想了解如何编辑 udevd 规则:http://www.reactivated.net/writing_udev_rules.html#external-run

The usb subsystem sits below the scsi subsystem and hence your newly allocated devices will have device names like /dev/sdX. Its the job of udev to create a new device node corresponding to this USB device in /dev. If you are interested in capturing this event and running a script that does some notifications you may wanna read up on how to edit udevd rules: http://www.reactivated.net/writing_udev_rules.html#external-run

这篇关于检测插入的 USB 设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆