rk3588 区分两个相同的usb相机

有时候会插入两个一模一样的usb相机,担心每次启动他们所对应的设备节点 /dev/video* 会变化,所以需要绑定usb口,区分两个相机。把两个相机都插入后,查看usb信息

复制代码
root@rk3588:/# udevadm info --attribute-walk --name=/dev/video0

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/platform/fc800000.usb/usb1/1-1/1-1:1.0/video4linux/video0':
    KERNEL=="video0"
    SUBSYSTEM=="video4linux"
    DRIVER==""
    ATTR{dev_debug}=="0"
    ATTR{index}=="0"
    ATTR{name}=="USB Camera: USB Camera"

  looking at parent device '/devices/platform/fc800000.usb/usb1/1-1/1-1:1.0':
    KERNELS=="1-1:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="uvcvideo"
    ATTRS{bAlternateSetting}==" 0"
    ATTRS{authorized}=="1"
    ATTRS{iad_bFunctionClass}=="0e"
    ATTRS{iad_bInterfaceCount}=="02"
    ATTRS{bInterfaceSubClass}=="01"
    ATTRS{iad_bFunctionSubClass}=="03"
    ATTRS{bInterfaceNumber}=="00"
    ATTRS{iad_bFirstInterface}=="00"
    ATTRS{bInterfaceProtocol}=="00"
    ATTRS{iad_bFunctionProtocol}=="00"
    ATTRS{bInterfaceClass}=="0e"
    ATTRS{bNumEndpoints}=="01"
    ATTRS{supports_autosuspend}=="1"
    ATTRS{interface}=="USB Camera"

  looking at parent device '/devices/platform/fc800000.usb/usb1/1-1':
    KERNELS=="1-1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{configuration}==""
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{bDeviceClass}=="ef"
    ATTRS{bcdDevice}=="1001"
    ATTRS{bNumInterfaces}==" 2"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{manufacturer}=="VNV"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{authorized}=="1"
    ATTRS{speed}=="480"
    ATTRS{idProduct}=="c001"
    ATTRS{urbnum}=="32"
    ATTRS{devnum}=="2"
    ATTRS{product}=="USB Camera"
    ATTRS{maxchild}=="0"
    ATTRS{bmAttributes}=="80"
    ATTRS{bDeviceSubClass}=="02"
    ATTRS{bMaxPower}=="500mA"
    ATTRS{rx_lanes}=="1"
    ATTRS{removable}=="unknown"
    ATTRS{idVendor}=="1bcf"
    ATTRS{version}==" 2.00"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{bDeviceProtocol}=="01"
    ATTRS{tx_lanes}=="1"
    ATTRS{devspec}=="(null)"
    ATTRS{ltm_capable}=="no"
    ATTRS{devpath}=="1"
    ATTRS{busnum}=="1"
    ATTRS{quirks}=="0x0"

  looking at parent device '/devices/platform/fc800000.usb/usb1':
    KERNELS=="usb1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{configuration}==""
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{bDeviceClass}=="09"
    ATTRS{bcdDevice}=="0510"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{manufacturer}=="Linux 5.10.110 ehci_hcd"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{authorized}=="1"
    ATTRS{speed}=="480"
    ATTRS{idProduct}=="0002"
    ATTRS{urbnum}=="23"
    ATTRS{devnum}=="1"
    ATTRS{product}=="EHCI Host Controller"
    ATTRS{maxchild}=="1"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bMaxPower}=="0mA"
    ATTRS{rx_lanes}=="1"
    ATTRS{removable}=="unknown"
    ATTRS{idVendor}=="1d6b"
    ATTRS{interface_authorized_default}=="1"
    ATTRS{authorized_default}=="1"
    ATTRS{version}==" 2.00"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{serial}=="fc800000.usb"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{tx_lanes}=="1"
    ATTRS{ltm_capable}=="no"
    ATTRS{devpath}=="0"
    ATTRS{busnum}=="1"
    ATTRS{quirks}=="0x0"

  looking at parent device '/devices/platform/fc800000.usb':
    KERNELS=="fc800000.usb"
    SUBSYSTEMS=="platform"
    DRIVERS=="ehci-platform"
    ATTRS{companion}==""
    ATTRS{driver_override}=="(null)"
    ATTRS{uframe_periodic_max}=="100"

  looking at parent device '/devices/platform':
    KERNELS=="platform"
    SUBSYSTEMS==""
    DRIVERS==""

通过 KERNELS=="1-1" (应该可以加更多信息来区分,没深入研究)可以区分usb相机对应的usb口,udev可以绑定usb相机到对应的usb

复制代码
root@rk3588:/# cat /etc/udev/rules.d/50-video.rules 
KERNEL =="video*",ATTR{index}=="0",KERNELS=="1-1",MODE:="0777",SYMLINK+="my_video0"
KERNEL =="video*",ATTR{index}=="0",KERNELS=="2-1",MODE:="0777",SYMLINK+="my_video1"

这样不管usb 0口插入的是哪个usb相机,它都对应 /dev/my_video0 节点,应用层访问该节点即可获取数据。

相关推荐
石像鬼₧魂石9 小时前
内网渗透靶场实操清单(基于 Vulhub+Metasploitable 2)
linux·windows·学习·ubuntu
橘子真甜~10 小时前
C/C++ Linux网络编程15 - 网络层IP协议
linux·网络·c++·网络协议·tcp/ip·计算机网络·网络层
拾贰_C11 小时前
【Linux | Windows | Terminal Command】 Linux---grep | Windows--- findstr
linux·运维·服务器
阿华hhh12 小时前
Linux系统编程(标准io)
linux·开发语言·c++
石像鬼₧魂石13 小时前
Kali Linux 网络端口深度扫描
linux·运维·网络
alengan13 小时前
linux上面写python3日志服务器
linux·运维·服务器
Rose sait13 小时前
【环境配置】Linux配置虚拟环境pytorch
linux·人工智能·python
叶之香14 小时前
CentOS/RHEL 7、8安装exfat和ntfs文件系统
linux·运维·centos
一世琉璃白_Y14 小时前
pg配置国内数据源安装
linux·python·postgresql·centos