/sys/bus/usb/devices下的文件命名
来源:互联网 发布:苹果版软件商店 编辑:程序博客网 时间:2024/05/21 08:56
/sys/bus/usb/devices下的文件命名:
root@Four-Faith:/sys/bus/usb/devices# ls -l
lrwxrwxrwx 1 root root 0 Jan 1 1970 1-0:1.0 -> ../../../devices/platform/xhc_mtk/usb1/1-0:1.0
lrwxrwxrwx 1 root root 0 Jan 8 23:27 1-2 -> ../../../devices/platform/xhc_mtk/usb1/1-2
lrwxrwxrwx 1 root root 0 Jan 8 23:28 1-2:1.0 -> ../../../devices/platform/xhc_mtk/usb1/1-2/1-2:1.0
lrwxrwxrwx 1 root root 0 Jan 8 23:28 1-2:1.1 -> ../../../devices/platform/xhc_mtk/usb1/1-2/1-2:1.1
lrwxrwxrwx 1 root root 0 Jan 8 23:27 1-2:1.2 -> ../../../devices/platform/xhc_mtk/usb1/1-2/1-2:1.2
lrwxrwxrwx 1 root root 0 Jan 8 23:28 1-2:1.3 -> ../../../devices/platform/xhc_mtk/usb1/1-2/1-2:1.3
lrwxrwxrwx 1 root root 0 Jan 8 23:28 1-2:1.4 -> ../../../devices/platform/xhc_mtk/usb1/1-2/1-2:1.4
lrwxrwxrwx 1 root root 0 Jan 8 23:28 1-2:1.5 -> ../../../devices/platform/xhc_mtk/usb1/1-2/1-2:1.5
lrwxrwxrwx 1 root root 0 Jan 1 1970 2-0:1.0 -> ../../../devices/platform/xhc_mtk/usb2/2-0:1.0
lrwxrwxrwx 1 root root 0 Jan 1 1970 usb1 -> ../../../devices/platform/xhc_mtk/usb1
lrwxrwxrwx 1 root root 0 Jan 1 1970 usb2 -> ../../../devices/platform/xhc_mtk/usb2
如上可知:/sys/bus/usb/devices都是实际指向/sys/devices/platform/下的文件,文件的命名是根据USB命名的规则,比如:
/sys/bus/usb/devices/usb1,usb2表示表示两个usb hub,是root bug,usb1/内有属于usb bug device的一些属性,可以看一下:
root@Four-Faith:/sys/devices/platform/xhc_mtk/usb1# ls
1-0:1.0 bcdDevice maxchild
1-2 bmAttributes product
authorized busnum quirks
authorized_default configuration remove
avoid_reset_quirk descriptors serial
bConfigurationValue dev speed
bDeviceClass devnum subsystem
bDeviceProtocol devpath uevent
bDeviceSubClass driver urbnum
bMaxPacketSize0 ep_00 usb_device
bMaxPower idProduct version
bNumConfigurations idVendor
bNumInterfaces manufacturer
一个hub也是一个usb decice,因此一个usb device ,直接引用include/linux/usb/ch9.h中的定义是:(+表示在该目录下存在)
216 /* USB_DT_DEVICE: Device descriptor */
217 struct usb_device_descriptor {
218 __u8 bLength;
219 __u8 bDescriptorType; //+descriptors
220
221 __le16 bcdUSB; //+version
222 __u8 bDeviceClass; //+
223 __u8 bDeviceSubClass; //+
224 __u8 bDeviceProtocol; //+
225 __u8 bMaxPacketSize0; //+
226 __le16 idVendor; //+
227 __le16 idProduct; //+
228 __le16 bcdDevice; //+
229 __u8 iManufacturer; //+manufacturer
230 __u8 iProduct; //+product
231 __u8 iSerialNumber; //+serial
232 __u8 bNumConfigurations; //+
233 } __attribute__ ((packed));
cat bDeviceClass显示9,在ch9.h中定义:
#define USB_CLASS_HUB 9
lzj@lzj-laptop:/sys/bus/usb/devices/usb1$ cat bDeviceClass
09
hub当然还是一个hub device,它具有普通usb device没有的一些性质, struct usb_hub_descriptor,但这些信息没有在sysfs中显示,可能是一个普通用户不需要知道hub的信息吧,所以内核开发者没有在sysfs中显示
**************以上是device(或者是USB hub)级别的信息,一个usb device有1个或多个interface.下面开始讲interface
1-0:1.0就是interface的目录,表示root hub1-port0上的configuration1的interface0,
命名规则是:roothub-port:configuration.interface.
看看1-0:1.0目录下的内容:
root@Four-Faith:/sys/devices/platform/xhc_mtk/usb1/1-0:1.0# ls
bAlternateSetting bInterfaceSubClass modalias
bInterfaceClass bNumEndpoints subsystem
bInterfaceNumber driver supports_autosuspend
bInterfaceProtocol ep_81 uevent
其实1-0:1.0是usb hub1自己占有的,在没有接入任何usb设备的时候,1-0:1.0都存在并且可以在usb1中找到,在用户接入USB设备之后并且该设备挂载在ubs hug1下,那么就会在usb1下多出1-2/目录,打开看:
drwxr-xr-x 5 root root 0 Jan 9 13:46 1-2:1.0
drwxr-xr-x 6 root root 0 Jan 9 13:46 1-2:1.1
drwxr-xr-x 6 root root 0 Jan 9 13:45 1-2:1.2
drwxr-xr-x 6 root root 0 Jan 9 13:46 1-2:1.3
drwxr-xr-x 6 root root 0 Jan 9 13:46 1-2:1.4
drwxr-xr-x 5 root root 0 Jan 9 13:46 1-2:1.5
-rw-r--r-- 1 root root 4096 Jan 9 13:46 authorized
-rw-r--r-- 1 root root 4096 Jan 9 13:46 avoid_reset_quirk
-rw-r--r-- 1 root root 4096 Jan 9 13:46 bConfigurationValue
-r--r--r-- 1 root root 4096 Jan 9 13:46 bDeviceClass
-r--r--r-- 1 root root 4096 Jan 9 13:46 bDeviceProtocol
-r--r--r-- 1 root root 4096 Jan 9 13:46 bDeviceSubClass
-r--r--r-- 1 root root 4096 Jan 9 13:46 bMaxPacketSize0
-r--r--r-- 1 root root 4096 Jan 9 13:46 bMaxPower
-r--r--r-- 1 root root 4096 Jan 9 13:46 bNumConfigurations
-r--r--r-- 1 root root 4096 Jan 9 13:46 bNumInterfaces
-r--r--r-- 1 root root 4096 Jan 9 13:46 bcdDevice
-r--r--r-- 1 root root 4096 Jan 9 13:46 bmAttributes
-r--r--r-- 1 root root 4096 Jan 9 13:46 busnum
-r--r--r-- 1 root root 4096 Jan 9 13:46 configuration
-r--r--r-- 1 root root 65553 Jan 9 13:46 descriptors
-r--r--r-- 1 root root 4096 Jan 9 13:46 dev
-r--r--r-- 1 root root 4096 Jan 9 13:46 devnum
-r--r--r-- 1 root root 4096 Jan 9 13:46 devpath
lrwxrwxrwx 1 root root 0 Jan 9 13:46 driver -> ../../../../../bus/usb/drivers/usb
drwxr-xr-x 2 root root 0 Jan 9 13:46 ep_00
-r--r--r-- 1 root root 4096 Jan 9 13:45 idProduct
-r--r--r-- 1 root root 4096 Jan 9 13:45 idVendor
-r--r--r-- 1 root root 4096 Jan 9 13:46 manufacturer
-r--r--r-- 1 root root 4096 Jan 9 13:46 maxchild
-r--r--r-- 1 root root 4096 Jan 9 13:46 product
-r--r--r-- 1 root root 4096 Jan 9 13:46 quirks
--w------- 1 root root 4096 Jan 9 13:46 remove
-r--r--r-- 1 root root 4096 Jan 9 13:46 serial
-r--r--r-- 1 root root 4096 Jan 9 13:46 speed
lrwxrwxrwx 1 root root 0 Jan 9 13:46 subsystem -> ../../../../../bus/usb
-rw-r--r-- 1 root root 4096 Jan 9 13:46 uevent
-r--r--r-- 1 root root 4096 Jan 9 13:46 urbnum
drwxr-xr-x 3 root root 0 Jan 9 13:46 usb_device
-r--r--r-- 1 root root 4096 Jan 9 13:46 version
会多出如下:
drwxr-xr-x 5 root root 0 Jan 9 13:46 1-2:1.0
drwxr-xr-x 6 root root 0 Jan 9 13:46 1-2:1.1
drwxr-xr-x 6 root root 0 Jan 9 13:45 1-2:1.2
drwxr-xr-x 6 root root 0 Jan 9 13:46 1-2:1.3
drwxr-xr-x 6 root root 0 Jan 9 13:46 1-2:1.4
drwxr-xr-x 5 root root 0 Jan 9 13:46 1-2:1.5
这些就是用户刚刚挂载在ubs1 这个bug下的设备,他们占用usb bub1中port1,configuration都为1,而interface0 - 6都被用户占用,在1-2:1.0可以找到ttyUSB0/,ttyUSB0就是/dev/ttyUSB0相关。我现在挂载在usb hub1上的设备是usb转串口的lte模块,所以名字是ttyUSB*
- /sys/bus/usb/devices下的文件命名
- /sys/bus/i2c/devices下的内容与i2c_board_info结构
- 解决/proc/bus/usb/目录下没有devices文件问题
- 解决/proc/bus/usb/目录下没有devices文件问题
- /sys/bus/i2c/devices下的内容与i2c_board_info结构体
- /sys/bus/i2c/devices下的内容与i2c_board_info结构体
- /sys/bus/i2c/devices下的内容与i2c_board_info结构体
- /sys/bus/i2c/devices下的内容与i2c_board_info结构体
- /sys/bus/i2c/devices下的内容与i2c_board_info结构体
- linux下bus、devices和platform的基础模型
- linux下bus、devices和platform的基础模型
- linux下bus、devices和platform的基础模型
- linux下bus、devices和platform的基础模型
- 嵌入式 linux下bus、devices和platform的基础模型
- linux下bus、devices和platform的基础模型
- linux下bus、devices和platform的基础模型
- Documentation/ABI/obsolute/sys-bus-usb.txt
- 设备初始化及/sys下devices等目录的建立
- MNIST数据集格式转化
- Spring 学习笔记 整合 structs2
- dogse入门指南
- 读《失业的程序员》笔记-----中
- oracle11g 手工建库
- /sys/bus/usb/devices下的文件命名
- Springmvc json加载数据 前端拼接技术
- android在 Activity 之间传递参数
- libevent7
- html与htm的区别
- 基于Windows Socket的安全通信(C++实现,附源码)
- 浏览器缓存机制
- C#实现MD5加密
- LeetCode_OJ【39】Combination Sum