QuickCam Team Forums

Full Version: Ubuntu udev
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
I was never able to get the udev script working in ubuntu,
finally today I had some spare time and was able to check the problem.

There is no idVendor or idProduct files, so the udev scripte cannot set VID and PID variables.
I was able to get this values from modalias file.
The attached script works well in Ubuntu intrepid if hotpluging, but for some reason udev isn't triggered on startup, couldn't figure the problem yet.

Running /etc/init.d/udev restart also works, I've tried setting udev on rc.5 but this didn't work, I've just run out of ideas some help is welcomed.

Thank you,
Paulo
------------------//----------------

#!/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 interface and device paths
ifacepath="/sys$DEVPATH"
if [ -e "$ifacepath/device" ]; then
devpath="$ifacepath/device"
unset ifacepath
driverpath="$devpath/driver/module/drivers/usb:uvcvideo"
else
devpath="$ifacepath/device"
driverpath="$devpath/driver/module/drivers/usb:uvcvideo"
fi

# Extract the VID and PID
#vid=`cat "$devpath/dev" | tr "[:upper:]" "[:lower:]"`
vid=`sed -e "s/.*v\(....\)p\(....\).*/\1/" "$devpath/modalias" | tr "[:upper:]"
"[:lower:]"`
#pid=`cat "$devpath/name" | tr "[:upper:]" "[:lower:]"`
pid=`sed -e "s/.*v\(....\)p\(....\).*/\2/" "$devpath/modalias" | 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/idVendor'." >> $lo
gfile
exit 2
fi

# Check whether the device is managed by the UVC driver
drivername=`readlink $driverpath`
drivername=`basename $drivername`
if [ "$drivername" != "uvcvideo" ]; then
echo "ERROR: Device is not handled by uvcvideo but by '$drivername'." >>
$logfile
if [ "$drivername" = "usb" ]; then
echo "Note: There is a known problem for older versions of the U
VC driver where the physical device path reported by udev ('/sys$PHYSDEVPATH' in
this case) points to the USB device instead of the USB interface. For these ver
sions of the UVC driver dynamic controls are not supported anyway. Please update
your uvcvideo driver to the latest version if you know that this device is a UV
C device." >> $logfile
fi
exit 3
fi
#if [ -z $ifacepath ]; then
# echo "ERROR: Interface path not available." >> $logfile
# exit 4
#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
Sorry, I missed the previous thread on the subject.
I've tried Trevor solution, but the result is the same, it works great when I hotplug the camera, or run /etc/init.d/udev restart, but the script is not triggered when booting with the camera already connected.
This is no doubt a udev issue but I can't understand the cause, as I remember this was not a problem in debian, so it must be something specific to Intrepid.

Best regards,
Paulo
Reference URL's