I have a Pi running a weather station and four identical cameras (look at nzfi.avmet.nz if interested). The cameras are /dev/video0, /dev/video1,/dev/video2,/dev/video3. They are identical right down to each having the same serial number.
If I reboot the system, the allocation of cameras to video numbers can be a bit random. I would like each camera to always have the same /dev/videox because I treat each pic differently. I understand this calls for a bit of udev rule stuff. I have to make rules that are based on which port the camera is plugged in to - there are no other distinguishing features.
I found this .... seems to be just what I am looking for
===========================================
If you are not going to be rearranging where they're plugged in then you can do something like:
BUS="usb", ID=="1-4.2:1.0", SYMLINK+="ttyUSBport2"
BUS="usb", ID=="1-4.3:1.0", SYMLINK+="ttyUSBport3"
BUS="usb", ID=="1-4.4:1.0", SYMLINK+="ttyUSBport4"
etc. This works as no matter what order they're initialized in their place on the physical bus is not going to change (unless you unplug one and plug it in somewhere else). I think the ID means controller 1, position 4 (which is a hub), hub port 2 (or 3 or 4), device 1.
============================================
Here is what lsusb tells me
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 012: ID 19d2:0117 ZTE WCDMA Technologies MSM
Bus 001 Device 009: ID 0bda:58bb Realtek Semiconductor Corp.
Bus 001 Device 011: ID 0bda:58bb Realtek Semiconductor Corp.
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 1a40:0101 Terminus Technology Inc. 4-Port HUB
Bus 001 Device 005: ID 1a40:0101 Terminus Technology Inc. 4-Port HUB
Bus 001 Device 006: ID 1941:8021 Dream Link WH1080 Weather Station / USB Missile Launcher
Bus 001 Device 008: ID 0bda:58bb Realtek Semiconductor Corp.
Bus 001 Device 010: ID 0bda:58bb Realtek Semiconductor Corp.
The cameras are 8,9,10,11
Physically this is a Pi model B with four USB ports. One of them is connected to an 8-port hub, the others are empty. The devices (weather station, modem and cameras) are plugged in to the hub.
lsusb-t tells me
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=dwc_otg/1p, 480M|__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/5p, 480M
|__ Port 1: Dev 3, If 0, Class=vend., Driver=smsc95xx, 480M
|__ Port 3: Dev 4, If 0, Class=hub, Driver=hub/4p, 480M
|__ Port 1: Dev 5, If 0, Class=hub, Driver=hub/4p, 480M
|__ Port 2: Dev 12, If 0, Class=vend., Driver=option, 480M
|__ Port 2: Dev 12, If 1, Class=vend., Driver=option, 480M
|__ Port 2: Dev 12, If 2, Class=vend., Driver=option, 480M
|__ Port 3: Dev 9, If 0, Class='bInterfaceClass 0x0e not yet handled', Driver=uvcvideo, 480M
|__ Port 4: Dev 11, If 0, Class='bInterfaceClass 0x0e not yet handled', Driver=uvcvideo, 480M
|__ Port 2: Dev 6, If 0, Class=HID, Driver=usbfs, 1.5M
|__ Port 3: Dev 8, If 0, Class='bInterfaceClass 0x0e not yet handled', Driver=uvcvideo, 480M
|__ Port 4: Dev 10, If 0, Class='bInterfaceClass 0x0e not yet handled', Driver=uvcvideo, 480M
I can't figure the ID=="a-b.c:d.0" bit of the rule for devices 8,9,10,11 ....
IB
