Hi all!
I've got an old eeepc 901 set up with Fedora 20, in a captive situation where it operates a USB web cam (not the built-in one, but something a good deal better, though modestly priced) snapping an image once per minute.
Unfortunately, on the rare occasions when the eeepc gets rebooted, the location in /dev of the particular web cam I'm interested in sometimes changes from /dev/video0 to /dev/video1, or sometimes the other way.
I was looking to see if I could grope /proc files to find out which one was the camera I'm interested in, so the script that runs it could adapt.
not finding anything on that, I hit on writing a udev rule for the USB device to make sure it appeared as a predictable /dev/video<x>.
So, I found a bunch of advice on the web, and tried two rather different udev rules, neither of which works in any way I can confirm. Here's one of 'em:
lsusb: Bus 001 Device 002: ID 046d:0825 Logitech, Inc. Webcam C270
so, according to one of the recipes I found, if I make a rule like this it should work:
SUBSYSTEM=="video4linux", SUBSYSTEM=="usb", ATTRS{idVendor}=="0x046d", ATTRS{idProduct}=="0x0825", SYMLINK+="logitechcam"
if I understand it, this should make the camera appear as "/dev/logitechcam".
If I'm off-base here I hope someone will straighten me out.
this rule is stored in a file in /etc/udev/rules.d/25<stuff>.rules.
unplug/replug the camera elicits no change, and no /dev/logitechcam node, either. neither does a reboot.
Advice will be gladly accepted! Thanks in advance.
Fred
On Thu, 6 Nov 2014 18:47:23 -0500 Fred Smith wrote:
not finding anything on that, I hit on writing a udev rule for the USB device to make sure it appeared as a predictable /dev/video<x>.
I did something similar to recognize my 3D printer when I plug it in, and it was quite challenging to make all my code work because systemd runs things in magic "cgroups" that get killed quickly and have limited permissions. I eventually got all the complex stuff I wanted to do working. The full story is here:
http://home.comcast.net/~tomhorsley/hardware/solidoodle/solidoodle-udev.html
On 11/06/2014 06:53 PM, Tom Horsley wrote:
On Thu, 6 Nov 2014 18:47:23 -0500 Fred Smith wrote:
not finding anything on that, I hit on writing a udev rule for the USB device to make sure it appeared as a predictable /dev/video<x>.
Did you try looking in /dev/v4l? My laptop builtin webcam leaves entries in there. The v4l directory has 2 sub-directories: by-id and by-path which contain entries for my webcam.
I did something similar to recognize my 3D printer when I plug it in, and it was quite challenging to make all my code work because systemd runs things in magic "cgroups" that get killed quickly and have limited permissions. I eventually got all the complex stuff I wanted to do working. The full story is here:
http://home.comcast.net/~tomhorsley/hardware/solidoodle/solidoodle-udev.html
On Fri, Nov 07, 2014 at 03:20:20PM -0500, Kevin Cummings wrote:
On 11/06/2014 06:53 PM, Tom Horsley wrote:
On Thu, 6 Nov 2014 18:47:23 -0500 Fred Smith wrote:
not finding anything on that, I hit on writing a udev rule for the USB device to make sure it appeared as a predictable /dev/video<x>.
Did you try looking in /dev/v4l? My laptop builtin webcam leaves entries in there. The v4l directory has 2 sub-directories: by-id and by-path which contain entries for my webcam.
Hi Kev!
Yes, late yesterday I learned enough about udev to find the files there, so I've modified my script to use those files to figure out which /dev entry is the webcam I'm interested in. I suppose I could use those files directly, too, and save a bit of computation.
an excerpt from the script that operates the camera:
# figure out which /dev/video<x> entry is the camera we want. foo=`ls -l --dereference-command-line-symlink-to-dir /dev/v4l/by-id/usb-046d_0825*` devnode=`echo $foo | sed -e "s;^.*> ../../;;"` # then snap it ${progdir}/fswebcam --png 9 -d /dev/${devnode} -r 800x600 -F 2 --save ${day}/img-%Y%m%d-%H%M%S.png