63 lines
1.8 KiB
Markdown
63 lines
1.8 KiB
Markdown
# Udevadm 说明
|
|
|
|
## 1. 安装
|
|
|
|
```bash
|
|
# Ubuntu 16.04
|
|
apt install udev
|
|
```
|
|
|
|
## 2. 使用
|
|
|
|
### 2.1. 监控 UEvent
|
|
|
|
```bash
|
|
udevadm monitor
|
|
|
|
# 热插拔设备出现类似 Log
|
|
KERNEL[4907.940589] add /devices/platform/soc/2100000.aips-bus/2184200.usb/ci_hdrc.1/usb2/2-1/2-1:1.9/ttyUSB7/tty/ttyUSB7 (tty)
|
|
UDEV [4908.211629] add /devices/platform/soc/2100000.aips-bus/2184200.usb/ci_hdrc.1/usb2/2-1/2-1:1.9/ttyUSB7/tty/ttyUSB7 (tty)
|
|
```
|
|
|
|
### 2.2. 获取 UDev 信息
|
|
|
|
```bash
|
|
udevadm info <device node>
|
|
# 如
|
|
udevadm info /dev/ttyUSB7
|
|
|
|
P: /devices/platform/soc/2100000.aips-bus/2184200.usb/ci_hdrc.1/usb2/2-1/2-1:1.9/ttyUSB7/tty/ttyUSB7
|
|
N: ttyUSB7
|
|
S: serial/by-id/usb-LONGSUNG_M5700-if09-port0
|
|
S: serial/by-path/platform-ci_hdrc.1-usb-0:1:1.9-port0
|
|
E: DEVLINKS=/dev/serial/by-id/usb-LONGSUNG_M5700-if09-port0 /dev/serial/by-path/platform-ci_hdrc.1-usb-0:1:1.9-port0
|
|
E: DEVNAME=/dev/ttyUSB7
|
|
E: DEVPATH=/devices/platform/soc/2100000.aips-bus/2184200.usb/ci_hdrc.1/usb2/2-1/2-1:1.9/ttyUSB7/tty/ttyUSB7
|
|
E: ID_BUS=usb
|
|
E: ID_MODEL=M5700
|
|
E: ID_MODEL_ENC=M5700
|
|
E: ID_MODEL_ID=4d11
|
|
E: ID_PATH=platform-ci_hdrc.1-usb-0:1:1.9
|
|
E: ID_PATH_TAG=platform-ci_hdrc_1-usb-0_1_1_9
|
|
E: ID_REVISION=0000
|
|
E: ID_SERIAL=LONGSUNG_M5700
|
|
E: ID_TYPE=generic
|
|
E: ID_USB_DRIVER=option
|
|
E: ID_USB_INTERFACES=:020600:0a0000:ff0000:
|
|
E: ID_USB_INTERFACE_NUM=09
|
|
E: ID_VENDOR=LONGSUNG
|
|
E: ID_VENDOR_ENC=LONGSUNG
|
|
E: ID_VENDOR_FROM_DATABASE=Spreadtrum Communications Inc.
|
|
E: ID_VENDOR_ID=1782
|
|
E: MAJOR=188
|
|
E: MINOR=7
|
|
E: SUBSYSTEM=tty
|
|
E: TAGS=:systemd:
|
|
E: USEC_INITIALIZED=4908169711
|
|
```
|
|
|
|
## 外部参考资料
|
|
|
|
1. [How to Use Udev for Device Detection and Management in Linux](https://www.tecmint.com/udev-for-device-detection-management-in-linux/)
|
|
2. [udevadm 命令详解](https://www.cnblogs.com/carriezhangyan/p/9564900.html)
|