iot-root / garden-of-eden

Truly own that which is yours!
GNU General Public License v3.0
30 stars 8 forks source link

add udev rules for cameras #8

Open iot-root opened 1 year ago

iot-root commented 1 year ago

Related Issue: https://github.com/iot-root/garden-of-eden/issues/40

The system shall assign aliases to the cameras.

User Case For easy identification when running scripts or code.

Note: fswebcam generates the jpg

https://manpages.ubuntu.com/manpages/jammy/man1/fswebcam.1.html#:~:text=fswebcam%20is%20a%20small%20and,using%20the%20filename%20%22%2D%22.

#!/bin/bash
/usr/bin/fswebcam -d /dev/video0 -r 2500x1900 -S 2 -F 10 right-cam.jpg
/usr/bin/fswebcam -d /dev/video1 -r 2500x1900 -S 2 -F 10 left-cam.jpg

lsusb output Gardyn 2.0

Bus 001 Device 004: ID c499:0ac8 Alcorlink Corp. View Camera
Bus 001 Device 003: ID c499:0ac8 Alcorlink Corp. View Camera

lsusb output for Gardyn 3.0

Bus 001 Device 004: ID 0c45:6368 Microdia USB 2.0 Camera
Bus 001 Device 003: ID 0c45:6368 Microdia USB 2.0 Camera

lsusb output for Gardyn 4.0

Bus 001 Device 004: ID 0c45:6368 Microdia
Bus 001 Device 003: ID 0c45:6368 Microdia

Bus=01 Lev=02 Prnt=02 Port=03 Cnt=02 Dev#=  4 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=0c45 ProdID=6368 Rev=01.00
S:  Manufacturer=Sonix Technology Co., Ltd.
S:  Product=USB 2.0 Camera
S:  SerialNumber=SN0001
C:  #Ifs= 4 Cfg#= 1 Atr=80 MxPwr=500mA
I:  If#= 0 Alt= 0 #EPs= 1 Cls=0e(video) Sub=01 Prot=00 Driver=uvcvideo
I:  If#= 1 Alt= 0 #EPs= 0 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo
I:  If#= 2 Alt= 0 #EPs= 0 Cls=01(audio) Sub=01 Prot=00 Driver=snd-usb-audio
I:  If#= 3 Alt= 0 #EPs= 0 Cls=01(audio) Sub=02 Prot=00 Driver=snd-usb-audio
iot-root commented 1 year ago
specter@gardyn-01:~ $ udevadm info -a -n /dev/video1 > v1
specter@gardyn-01:~ $ udevadm info -a -n /dev/video0 > v0
specter@gardyn-01:~ $ diff v0 v1
8,9c8,9
<   looking at device '/devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/video4linux/video0':
<     KERNEL=="video0"
---
>   looking at device '/devices/platform/soc/20980000.usb/usb1/1-1/1-1.4/1-1.4:1.0/video4linux/video1':
>     KERNEL=="video1"
16,17c16,17
<   looking at parent device '/devices/platform/soc/20980000.usb/usb1/1-1/1-1.3/1-1.3:1.0':
<     KERNELS=="1-1.3:1.0"
---
>   looking at parent device '/devices/platform/soc/20980000.usb/usb1/1-1/1-1.4/1-1.4:1.0':
>     KERNELS=="1-1.4:1.0"
35,36c35,36
<   looking at parent device '/devices/platform/soc/20980000.usb/usb1/1-1/1-1.3':
<     KERNELS=="1-1.3"
---
>   looking at parent device '/devices/platform/soc/20980000.usb/usb1/1-1/1-1.4':
>     KERNELS=="1-1.4"
53,54c53,54
<     ATTRS{devnum}=="3"
<     ATTRS{devpath}=="1.3"
---
>     ATTRS{devnum}=="4"
>     ATTRS{devpath}=="1.4"
66c66
<     ATTRS{urbnum}=="159445"
---
>     ATTRS{urbnum}=="157693"
iot-root commented 1 year ago

We could always prompt user on setup, is this the left or right cam?

bzzbzzz commented 6 months ago

We could always prompt user on setup, is this the left or right cam?

Or just name them A and B? Or only an option to switch left/right afterwards? Because the probability that it's already "right" is >=50% and even for the cases where it's not, there are quite some people who probably would'nt care ?