QuickCam Team Forums

Full Version: error in /lib/udev/uvcdynctrl
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I have problem with /lib/udev/uvcdynctrl.
The logitech.xml is not imported automatically as it should
when plugging in the camera.
/tmp/uvcdynctrl-udev.log looks like this, showing the error message
in the last line:

Code:
Triggered at Sun Jul 27 17:49:10 CEST 2008

ACTION=add
BASH=/bin/sh
BASH_ARGC=()
BASH_ARGV=()
BASH_LINENO=([0]="0")
BASH_SOURCE=([0]="/lib/udev/uvcdynctrl")
BASH_VERSINFO=([0]="3" [1]="2" [2]="39" [3]="1" [4]="release" [5]="x86_64-suse-linux-gnu")
BASH_VERSION='3.2.39(1)-release'
DEVLINKS=/dev/video
DEVNAME=/dev/video0
DEVPATH=/devices/pci0000:00/0000:00:0b.1/usb1/1-6/1-6:1.0/video4linux/video0
DIRSTACK=()
EUID=0
GROUPS=()
HOSTNAME=camel
HOSTTYPE=x86_64
IFS='
'
MACHTYPE=x86_64-suse-linux-gnu
MAJOR=81
MINOR=0
OPTERR=1
OPTIND=1
OSTYPE=linux-gnu
PATH=/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:.
PIPESTATUS=([0]="0")
POSIXLY_CORRECT=y
PPID=7925
PS4='+ '
PWD=/
SEQNUM=1945
SHELL=/bin/bash
SHELLOPTS=braceexpand:hashall:interactive-comments:posix
SHLVL=1
SUBSYSTEM=video4linux
TERM=dumb
UDEVD_EVENT=1
UDEV_LOG=3
UID=0
_='Triggered at Sun Jul 27 17:49:10 CEST 2008\n'
logfile=/tmp/uvcdynctrl-udev.log
uvcdynctrlpath=uvcdynctrl
xmlpath=/etc/udev/data

VID of new device: ''
PID of new device: ''
ERROR: Unable to extract USB VID from '/sys/../idVendor'.

Apparently the reason for this is, that $PHYSDEVPATH is missing.
Any idea, why this is the case? How can I fix this?
My system is OpenSuSE 11.0 X86-64, Kernel 2.6.25.5-1.1-default.
uvcdnyctrl and libwebcam were pulled from svc yesterday.

Cheerio
Peter

Unfortunately the udev support is experimental and largely untested. It seems every distribution is slightly different, so I've found it hard to come up with a version that works everywhere. I will try to look into it when I get a chance but in the meantime any help from udev experts would be appreciated. :-)
The following works for me on Ubuntu 8.04, kernel 2.6.24, with a Quickcam Sphere AF.

(Sorry if spacing/newlines are messed up, forum won't take these as attachments for some reason.)

In /etc/udev/rules.d/80-uvcdynctrl.rules:

###############################################################################
# Rules for adding dynamic UVC extension unit controls to UVC devices
###############################################################################
ACTION=="add", SUBSYSTEM=="video4linux", DRIVERS=="uvcvideo", ENV{idVendor}="$attr{idVendor}", ENV{idProduct}="$attr{idProduct}", RUN+="/lib/udev/uvcdynctrl"

In /lib/udev/uvcdynctrl:

#!/bin/sh
###############################################################################
# udev helper script for UVC devices to support dynamic controls.
#
# Version: 0.1
###############################################################################

xmlpath=/etc/udev/data
logfile=/tmp/uvcdynctrl-udev.log
#logfile=/dev/null
uvcdynctrlpath=uvcdynctrl

echo -e "\n============================================================================== " >> $logfile
echo -e "Triggered at `date`\n" >> $logfile
set >> $logfile
echo >> $logfile

# Extract the VID and PID
vid=`echo "$idVendor" | tr "[:upper:]" "[:lower:]"`
pid=`echo "$idProduct" | tr "[:upper:]" "[:lower:]"`
echo "VID of new device: '$vid'" >> $logfile
echo "PID of new device: '$pid'" >> $logfile
if [ -z $vid ]; then
echo "ERROR: Unable to extract USB VID from '$DEVPATH'" >> $logfile
exit 2
fi

# Make sure the vendor directory ($xmlpath/VID) exists
vendordir="$xmlpath/$vid"
if [ ! -d "$vendordir" ]; then
echo "ERROR: Vendor directory '$vendordir' not found." >> $logfile
exit 5
fi

# Look for device specific XML files ($xmlpath/VID/PID/*.xml)
if [ ! -z $pid ]; then
productdir="$xmlpath/$vid/$pid"
if [ -d "$productdir" ]; then
for file in $productdir/*.xml; do
if [ -f "$file" ]; then
echo "Found product XML file: $file" >> $logfile
cmd="$uvcdynctrlpath -d $DEVNAME -i $file"
echo "Executing command: '$cmd'" >> $logfile
$cmd >> $logfile 2>&1
fi
done
fi
fi

# Look for vendor specific XML files ($xmlpath/VID/*.xml)
for file in $vendordir/*.xml; do
if [ -f "$file" ]; then
echo "Found vendor XML file: $file" >> $logfile
cmd="$uvcdynctrlpath -d $DEVNAME -i $file"
echo "Executing command: '$cmd'" >> $logfile
$cmd >> $logfile 2>&1
fi
done



echo -e "==============================================================================\n " >> $logfile



Finally, I note that echo is a shell built-in in my /bin/sh, and it does not accept a -e argument, so the logfile has a bunch of extraneous -e's in it, a bit confusing but I've left it as in the original script.
Same here for Ubuntu 8.10 beta (Intrepid), /lib/udev/uvcdynctrl failes just like pit007 described.

Here is why: udev doesn't provide PHYSDEVPATH anymore, because all PHYS* keys were deprecated for a while and have finally been removed.

http://git.kernel.org/?p=linux/hotplug/u...=NEWS#l390

Different distros running different versions of udev would explain why it worked on one and failed on the other. libwebcam shouldn't rely on PHYS* variables any longer because all distros will sooner or later drop them.

I can confirm that Trevors solution (thank you!) works for Ubuntu Intrepid Beta and it even looks to be more robust than the previous one. Since he relies on udev to provide vendor and product id it should be unproblematic to use with other distributions.

So, please update SVN with Trevors fix.
Reference URL's