USB hub 多usb接口重映射:udev 规则
2016-08-24 15:44
375 查看
USB
hub 多usb接口重映射:udev 规则
你在开发的过程中是否会出现 USB端口号会发生变化。 例如: 机器人底盘与雷达都是 ttyUSB* .其序号与接入的先后有关。 对于写好的launch每次修改对应接口是不是
很麻法,或者每次得先插入一个再插另外一个。才能保证ttyUSB0 ttyUSB1. 但是如果你重启系统,说不定还是有问题出现。。
==》 不如将端口重映射到新的固定的名字,并且设置其权限为可读。 这样不管你的先后插入,符合对应id的硬件端口自动的映射到新定义的名字。
一. 单一的USB映射说明
参见:http://blog.csdn.net/zyh821351004/article/details/41577105
lsusb 命令查看所有usb端口信息。
[cpp] view
plain copy
print?
yhzhao@yhzhao:~$ lsusb
Bus 002 Device 002: ID 0bda:0411 Realtek Semiconductor Corp.
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 04f2:b48c Chicony Electronics Co., Ltd
Bus 001 Device 009: ID 046d:c31c Logitech, Inc. Keyboard K120
Bus 001 Device 010: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x UART Bridge / myAVR mySmartUSB light
Bus 001 Device 005: ID 0bda:5411 Realtek Semiconductor Corp.
Bus 001 Device 008: ID 24ae:1100
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
[cpp] view
plain copy
print?
yhzhao@yhzhao:~$ lsusb
Bus 002 Device 002: ID 0bda:0411 Realtek Semiconductor Corp.
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 04f2:b48c Chicony Electronics Co., Ltd
Bus 001 Device 009: ID 046d:c31c Logitech, Inc. Keyboard K120
Bus 001 Device 010: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x UART Bridge / myAVR mySmartUSB light
Bus 001 Device 005: ID 0bda:5411 Realtek Semiconductor Corp.
Bus 001 Device 008: ID 24ae:1100
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
udev的规则说明,可以参考博客说明:http://blog.csdn.net/cokewei/article/details/8281239
简单说明:
$kernel, %k:设备的内核设备名称,例如:sda、cdrom。
ID 10c4:ea60 表示usb设备的ID(这个ID由芯片制造商设置,可以唯一表示该设备)
10c4 usb_device_descriptor.idVendor
ea60 usb_device_descriptor.idProduct
依据这些信息,就可以简单的写udev规则了:rplidar.rules
sudo gedit /etc/udev/rules.d/rplidar.rules
[cpp] view
plain copy
print?
# set the udev rule , make the device_port be fixed by rplidar
#
KERNEL=="ttyUSB*", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", MODE:="0777", SYMLINK+="rplidar"
[cpp] view
plain copy
print?
# set the udev rule , make the device_port be fixed by rplidar
#
KERNEL=="ttyUSB*", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", MODE:="0777", SYMLINK+="rplidar"
创建生效后重新插拔USB。
用下面的命令就可以查看对应的映射结果了。
[cpp] view
plain copy
print?
yhzhao@yhzhao:~$ ls -l /dev |grep ttyUSB
lrwxrwxrwx 1 root root 7 Apr 14 13:18 rplidar -> ttyUSB0
crwxrwxrwx 1 root uucp 188, 0 Apr 14 13:18 ttyUSB0
yhzhao@yhzhao:~$
[cpp] view
plain copy
print?
yhzhao@yhzhao:~$ ls -l /dev |grep ttyUSB
lrwxrwxrwx 1 root root 7 Apr 14 13:18 rplidar -> ttyUSB0
crwxrwxrwx 1 root uucp 188, 0 Apr 14 13:18 ttyUSB0
yhzhao@yhzhao:~$
二. USB hub的多端口映射:
同一个hub连接设备base和laser, 将其重映射换名称到 slamtec_base_ 和 slamtec_laser_
[cpp] view
plain copy
print?
yhzhao@yhzhao:~$ lsusb
Bus 002 Device 002: ID 0bda:0411 Realtek Semiconductor Corp.
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 04f2:b48c Chicony Electronics Co., Ltd
Bus 001 Device 009: ID 046d:c31c Logitech, Inc. Keyboard K120
Bus 001 Device 011: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x UART Bridge / myAVR mySmartUSB light
Bus 001 Device 012: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x UART Bridge / myAVR mySmartUSB light
Bus 001 Device 005: ID 0bda:5411 Realtek Semiconductor Corp.
Bus 001 Device 008: ID 24ae:1100
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
[cpp] view
plain copy
print?
yhzhao@yhzhao:~$ lsusb
Bus 002 Device 002: ID 0bda:0411 Realtek Semiconductor Corp.
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 04f2:b48c Chicony Electronics Co., Ltd
Bus 001 Device 009: ID 046d:c31c Logitech, Inc. Keyboard K120
Bus 001 Device 011: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x UART Bridge / myAVR mySmartUSB light
Bus 001 Device 012: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x UART Bridge / myAVR mySmartUSB light
Bus 001 Device 005: ID 0bda:5411 Realtek Semiconductor Corp.
Bus 001 Device 008: ID 24ae:1100
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
可以看到hub的信息,同时hub上连接了两个串口转USB的设备,并且两者硬件使用的是一样的, 一种是依据设备的device配合一起分别定义udev规则,同上。
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
现提供固定hub的每个端口的映射。
udevadm info --attribute-walk --path=/sys/bus/usb-serial/devices/ttyUSB0
说明参见: http://askubuntu.com/questions/49910/how-to-distinguish-between-identical-usb-to-serial-adapters
可以找到hub端口的不同:
[cpp] view
plain copy
print?
yhzhao@yhzhao:~$ udevadm info --attribute-walk --path=/sys/bus/usb-serial/devices/ttyUSB1
Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.
looking at device '/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2.2/1-2.2:1.0/ttyUSB1':
KERNEL=="ttyUSB1"
SUBSYSTEM=="usb-serial"
DRIVER=="cp210x"
ATTR{port_number}=="0"
looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2.2/1-2.2:1.0':
KERNELS=="1-2.2:1.0"
SUBSYSTEMS=="usb"
DRIVERS=="cp210x"
ATTRS{bInterfaceClass}=="ff"
[cpp] view
plain copy
print?
yhzhao@yhzhao:~$ udevadm info --attribute-walk --path=/sys/bus/usb-serial/devices/ttyUSB1
Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.
looking at device '/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2.2/1-2.2:1.0/ttyUSB1':
KERNEL=="ttyUSB1"
SUBSYSTEM=="usb-serial"
DRIVER=="cp210x"
ATTR{port_number}=="0"
looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2.2/1-2.2:1.0':
KERNELS=="1-2.2:1.0"
SUBSYSTEMS=="usb"
DRIVERS=="cp210x"
ATTRS{bInterfaceClass}=="ff"
[cpp] view
plain copy
print?
yhzhao@yhzhao:~$ udevadm info --attribute-walk --path=/sys/bus/usb-serial/devices/ttyUSB0
Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.
looking at device '/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2.1/1-2.1:1.0/ttyUSB0':
KERNEL=="ttyUSB0"
SUBSYSTEM=="usb-serial"
DRIVER=="cp210x"
ATTR{port_number}=="0"
looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2.1/1-2.1:1.0':
KERNELS=="1-2.1:1.0"
SUBSYSTEMS=="usb"
DRIVERS=="cp210x"
ATTRS{bInterfaceClass}=="ff"
[cpp] view
plain copy
print?
yhzhao@yhzhao:~$ udevadm info --attribute-walk --path=/sys/bus/usb-serial/devices/ttyUSB0
Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.
looking at device '/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2.1/1-2.1:1.0/ttyUSB0':
KERNEL=="ttyUSB0"
SUBSYSTEM=="usb-serial"
DRIVER=="cp210x"
ATTR{port_number}=="0"
looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2.1/1-2.1:1.0':
KERNELS=="1-2.1:1.0"
SUBSYSTEMS=="usb"
DRIVERS=="cp210x"
ATTRS{bInterfaceClass}=="ff"
#参考 http://askubuntu.com/questions/49910/how-to-distinguish-between-identical-usb-to-serial-adapters #lsusb
#udevadm info --attribute-walk --path=/sys/bus/usb-serial/devices/ttyUSB0
[html] view
plain copy
print?
SUBSYSTEMS=="usb"
DRIVERS=="cp210x"
ATTRS{bInterfaceClass}=="ff"
ATTRS{bInterfaceSubClass}=="00"
ATTRS{bInterfaceProtocol}=="00"
ATTRS{bNumEndpoints}=="02"
ATTRS{supports_autosuspend}=="1"
ATTRS{bAlternateSetting}==" 0"
ATTRS{bInterfaceNumber}=="00"
ATTRS{interface}=="CP2102 USB to UART Bridge Controller"
KERNEL=="ttyUSB*", KERNELS=="1-2.1", MODE:="0777",SYMLINK+="slamtec_base_"
KERNEL=="ttyUSB*", KERNELS=="1-2.2", MODE:="0777",SYMLINK+="slamtec_laser_"
[html] view
plain copy
print?
SUBSYSTEMS=="usb"
DRIVERS=="cp210x"
ATTRS{bInterfaceClass}=="ff"
ATTRS{bInterfaceSubClass}=="00"
ATTRS{bInterfaceProtocol}=="00"
ATTRS{bNumEndpoints}=="02"
ATTRS{supports_autosuspend}=="1"
ATTRS{bAlternateSetting}==" 0"
ATTRS{bInterfaceNumber}=="00"
ATTRS{interface}=="CP2102 USB to UART Bridge Controller"
KERNEL=="ttyUSB*", KERNELS=="1-2.1", MODE:="0777",SYMLINK+="slamtec_base_"
KERNEL=="ttyUSB*", KERNELS=="1-2.2", MODE:="0777",SYMLINK+="slamtec_laser_"
重新拔插。可以看到:
ls -l /dev
[cpp] view
plain copy
print?
yhzhao@yhzhao:~$ ls -l /dev|grep ttyUSB
lrwxrwxrwx 1 root root 7 Apr 14 13:45 rplidar -> ttyUSB1
lrwxrwxrwx 1 root root 7 Apr 14 13:45 slamtec_base_ -> ttyUSB0
lrwxrwxrwx 1 root root 7 Apr 14 13:45 slamtec_laser_ -> ttyUSB1
crwxrwxrwx 1 root uucp 188, 0 Apr 14 13:45 ttyUSB0
crwxrwxrwx 1 root dialout 188, 1 Apr 14 13:45 ttyUSB1
[cpp] view
plain copy
print?
yhzhao@yhzhao:~$ ls -l /dev|grep ttyUSB
lrwxrwxrwx 1 root root 7 Apr 14 13:45 rplidar -> ttyUSB1
lrwxrwxrwx 1 root root 7 Apr 14 13:45 slamtec_base_ -> ttyUSB0
lrwxrwxrwx 1 root root 7 Apr 14 13:45 slamtec_laser_ -> ttyUSB1
crwxrwxrwx 1 root uucp 188, 0 Apr 14 13:45 ttyUSB0
crwxrwxrwx 1 root dialout 188, 1 Apr 14 13:45 ttyUSB1
参考:http://blog.csdn.net/zyh821351004/article/details/41577105
hub 多usb接口重映射:udev 规则
你在开发的过程中是否会出现 USB端口号会发生变化。 例如: 机器人底盘与雷达都是 ttyUSB* .其序号与接入的先后有关。 对于写好的launch每次修改对应接口是不是
很麻法,或者每次得先插入一个再插另外一个。才能保证ttyUSB0 ttyUSB1. 但是如果你重启系统,说不定还是有问题出现。。
==》 不如将端口重映射到新的固定的名字,并且设置其权限为可读。 这样不管你的先后插入,符合对应id的硬件端口自动的映射到新定义的名字。
一. 单一的USB映射说明
参见:http://blog.csdn.net/zyh821351004/article/details/41577105
lsusb 命令查看所有usb端口信息。
[cpp] view
plain copy
print?
yhzhao@yhzhao:~$ lsusb
Bus 002 Device 002: ID 0bda:0411 Realtek Semiconductor Corp.
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 04f2:b48c Chicony Electronics Co., Ltd
Bus 001 Device 009: ID 046d:c31c Logitech, Inc. Keyboard K120
Bus 001 Device 010: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x UART Bridge / myAVR mySmartUSB light
Bus 001 Device 005: ID 0bda:5411 Realtek Semiconductor Corp.
Bus 001 Device 008: ID 24ae:1100
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
[cpp] view
plain copy
print?
yhzhao@yhzhao:~$ lsusb
Bus 002 Device 002: ID 0bda:0411 Realtek Semiconductor Corp.
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 04f2:b48c Chicony Electronics Co., Ltd
Bus 001 Device 009: ID 046d:c31c Logitech, Inc. Keyboard K120
Bus 001 Device 010: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x UART Bridge / myAVR mySmartUSB light
Bus 001 Device 005: ID 0bda:5411 Realtek Semiconductor Corp.
Bus 001 Device 008: ID 24ae:1100
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
udev的规则说明,可以参考博客说明:http://blog.csdn.net/cokewei/article/details/8281239
简单说明:
$kernel, %k:设备的内核设备名称,例如:sda、cdrom。
ID 10c4:ea60 表示usb设备的ID(这个ID由芯片制造商设置,可以唯一表示该设备)
10c4 usb_device_descriptor.idVendor
ea60 usb_device_descriptor.idProduct
依据这些信息,就可以简单的写udev规则了:rplidar.rules
sudo gedit /etc/udev/rules.d/rplidar.rules
[cpp] view
plain copy
print?
# set the udev rule , make the device_port be fixed by rplidar
#
KERNEL=="ttyUSB*", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", MODE:="0777", SYMLINK+="rplidar"
[cpp] view
plain copy
print?
# set the udev rule , make the device_port be fixed by rplidar
#
KERNEL=="ttyUSB*", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", MODE:="0777", SYMLINK+="rplidar"
创建生效后重新插拔USB。
用下面的命令就可以查看对应的映射结果了。
[cpp] view
plain copy
print?
yhzhao@yhzhao:~$ ls -l /dev |grep ttyUSB
lrwxrwxrwx 1 root root 7 Apr 14 13:18 rplidar -> ttyUSB0
crwxrwxrwx 1 root uucp 188, 0 Apr 14 13:18 ttyUSB0
yhzhao@yhzhao:~$
[cpp] view
plain copy
print?
yhzhao@yhzhao:~$ ls -l /dev |grep ttyUSB
lrwxrwxrwx 1 root root 7 Apr 14 13:18 rplidar -> ttyUSB0
crwxrwxrwx 1 root uucp 188, 0 Apr 14 13:18 ttyUSB0
yhzhao@yhzhao:~$
二. USB hub的多端口映射:
同一个hub连接设备base和laser, 将其重映射换名称到 slamtec_base_ 和 slamtec_laser_
[cpp] view
plain copy
print?
yhzhao@yhzhao:~$ lsusb
Bus 002 Device 002: ID 0bda:0411 Realtek Semiconductor Corp.
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 04f2:b48c Chicony Electronics Co., Ltd
Bus 001 Device 009: ID 046d:c31c Logitech, Inc. Keyboard K120
Bus 001 Device 011: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x UART Bridge / myAVR mySmartUSB light
Bus 001 Device 012: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x UART Bridge / myAVR mySmartUSB light
Bus 001 Device 005: ID 0bda:5411 Realtek Semiconductor Corp.
Bus 001 Device 008: ID 24ae:1100
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
[cpp] view
plain copy
print?
yhzhao@yhzhao:~$ lsusb
Bus 002 Device 002: ID 0bda:0411 Realtek Semiconductor Corp.
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 04f2:b48c Chicony Electronics Co., Ltd
Bus 001 Device 009: ID 046d:c31c Logitech, Inc. Keyboard K120
Bus 001 Device 011: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x UART Bridge / myAVR mySmartUSB light
Bus 001 Device 012: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x UART Bridge / myAVR mySmartUSB light
Bus 001 Device 005: ID 0bda:5411 Realtek Semiconductor Corp.
Bus 001 Device 008: ID 24ae:1100
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
可以看到hub的信息,同时hub上连接了两个串口转USB的设备,并且两者硬件使用的是一样的, 一种是依据设备的device配合一起分别定义udev规则,同上。
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
现提供固定hub的每个端口的映射。
udevadm info --attribute-walk --path=/sys/bus/usb-serial/devices/ttyUSB0
说明参见: http://askubuntu.com/questions/49910/how-to-distinguish-between-identical-usb-to-serial-adapters
可以找到hub端口的不同:
[cpp] view
plain copy
print?
yhzhao@yhzhao:~$ udevadm info --attribute-walk --path=/sys/bus/usb-serial/devices/ttyUSB1
Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.
looking at device '/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2.2/1-2.2:1.0/ttyUSB1':
KERNEL=="ttyUSB1"
SUBSYSTEM=="usb-serial"
DRIVER=="cp210x"
ATTR{port_number}=="0"
looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2.2/1-2.2:1.0':
KERNELS=="1-2.2:1.0"
SUBSYSTEMS=="usb"
DRIVERS=="cp210x"
ATTRS{bInterfaceClass}=="ff"
[cpp] view
plain copy
print?
yhzhao@yhzhao:~$ udevadm info --attribute-walk --path=/sys/bus/usb-serial/devices/ttyUSB1
Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.
looking at device '/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2.2/1-2.2:1.0/ttyUSB1':
KERNEL=="ttyUSB1"
SUBSYSTEM=="usb-serial"
DRIVER=="cp210x"
ATTR{port_number}=="0"
looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2.2/1-2.2:1.0':
KERNELS=="1-2.2:1.0"
SUBSYSTEMS=="usb"
DRIVERS=="cp210x"
ATTRS{bInterfaceClass}=="ff"
[cpp] view
plain copy
print?
yhzhao@yhzhao:~$ udevadm info --attribute-walk --path=/sys/bus/usb-serial/devices/ttyUSB0
Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.
looking at device '/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2.1/1-2.1:1.0/ttyUSB0':
KERNEL=="ttyUSB0"
SUBSYSTEM=="usb-serial"
DRIVER=="cp210x"
ATTR{port_number}=="0"
looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2.1/1-2.1:1.0':
KERNELS=="1-2.1:1.0"
SUBSYSTEMS=="usb"
DRIVERS=="cp210x"
ATTRS{bInterfaceClass}=="ff"
[cpp] view
plain copy
print?
yhzhao@yhzhao:~$ udevadm info --attribute-walk --path=/sys/bus/usb-serial/devices/ttyUSB0
Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.
looking at device '/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2.1/1-2.1:1.0/ttyUSB0':
KERNEL=="ttyUSB0"
SUBSYSTEM=="usb-serial"
DRIVER=="cp210x"
ATTR{port_number}=="0"
looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2.1/1-2.1:1.0':
KERNELS=="1-2.1:1.0"
SUBSYSTEMS=="usb"
DRIVERS=="cp210x"
ATTRS{bInterfaceClass}=="ff"
#参考 http://askubuntu.com/questions/49910/how-to-distinguish-between-identical-usb-to-serial-adapters #lsusb
#udevadm info --attribute-walk --path=/sys/bus/usb-serial/devices/ttyUSB0
[html] view
plain copy
print?
SUBSYSTEMS=="usb"
DRIVERS=="cp210x"
ATTRS{bInterfaceClass}=="ff"
ATTRS{bInterfaceSubClass}=="00"
ATTRS{bInterfaceProtocol}=="00"
ATTRS{bNumEndpoints}=="02"
ATTRS{supports_autosuspend}=="1"
ATTRS{bAlternateSetting}==" 0"
ATTRS{bInterfaceNumber}=="00"
ATTRS{interface}=="CP2102 USB to UART Bridge Controller"
KERNEL=="ttyUSB*", KERNELS=="1-2.1", MODE:="0777",SYMLINK+="slamtec_base_"
KERNEL=="ttyUSB*", KERNELS=="1-2.2", MODE:="0777",SYMLINK+="slamtec_laser_"
[html] view
plain copy
print?
SUBSYSTEMS=="usb"
DRIVERS=="cp210x"
ATTRS{bInterfaceClass}=="ff"
ATTRS{bInterfaceSubClass}=="00"
ATTRS{bInterfaceProtocol}=="00"
ATTRS{bNumEndpoints}=="02"
ATTRS{supports_autosuspend}=="1"
ATTRS{bAlternateSetting}==" 0"
ATTRS{bInterfaceNumber}=="00"
ATTRS{interface}=="CP2102 USB to UART Bridge Controller"
KERNEL=="ttyUSB*", KERNELS=="1-2.1", MODE:="0777",SYMLINK+="slamtec_base_"
KERNEL=="ttyUSB*", KERNELS=="1-2.2", MODE:="0777",SYMLINK+="slamtec_laser_"
重新拔插。可以看到:
ls -l /dev
[cpp] view
plain copy
print?
yhzhao@yhzhao:~$ ls -l /dev|grep ttyUSB
lrwxrwxrwx 1 root root 7 Apr 14 13:45 rplidar -> ttyUSB1
lrwxrwxrwx 1 root root 7 Apr 14 13:45 slamtec_base_ -> ttyUSB0
lrwxrwxrwx 1 root root 7 Apr 14 13:45 slamtec_laser_ -> ttyUSB1
crwxrwxrwx 1 root uucp 188, 0 Apr 14 13:45 ttyUSB0
crwxrwxrwx 1 root dialout 188, 1 Apr 14 13:45 ttyUSB1
[cpp] view
plain copy
print?
yhzhao@yhzhao:~$ ls -l /dev|grep ttyUSB
lrwxrwxrwx 1 root root 7 Apr 14 13:45 rplidar -> ttyUSB1
lrwxrwxrwx 1 root root 7 Apr 14 13:45 slamtec_base_ -> ttyUSB0
lrwxrwxrwx 1 root root 7 Apr 14 13:45 slamtec_laser_ -> ttyUSB1
crwxrwxrwx 1 root uucp 188, 0 Apr 14 13:45 ttyUSB0
crwxrwxrwx 1 root dialout 188, 1 Apr 14 13:45 ttyUSB1
参考:http://blog.csdn.net/zyh821351004/article/details/41577105
相关文章推荐
- USB hub 多usb接口重映射:udev 规则
- USB hub 多usb接口重映射:udev 规则
- USB hub 多usb接口重映射:udev 规则
- java--web.xml中url-pattern的映射规则
- web.xml中的url-pattern映射规则
- web应用程序servlet的映射名称的规则及请求过程
- URL请求到Action的映射规则
- SpringMVC(3)URL请求到Action的映射规则
- linux外设权限:hokuyo权限设置(udev文件) ubuntu USB外设重映射思路
- SpringMVC3强大的请求映射规则详解 第六章 注解式控制器详解——跟着开涛学SpringMVC
- hosts文件以及映射条目的使用规则
- 写udev 规则
- 在 Linux 中如何编写基本的 udev 规则
- udev规则
- 数据库字段 java bean 映射 规则
- Spring MVC 基于Method的映射规则(注解版)
- SpringMVC学习系列(3) 之 URL请求到Action的映射规则
- JavaWeb开发中,servlet的url-pattern的映射规则
- udev 规则与硬盘操作
- Hibernate联合主键映射规则和数据查询原理