diff options
author | Gina Häußge <gina@octoprint.org> | 2021-06-29 15:39:29 +0300 |
---|---|---|
committer | Gina Häußge <gina@octoprint.org> | 2021-06-29 15:39:29 +0300 |
commit | 8d1e000b549ee8aaba2aa4a6af6ef4ed87d56f49 (patch) | |
tree | 69140ee57d67e2250fe5284bf38a07393307d435 | |
parent | 3dc1381937922f59fe46c9ddd75d1a6278841b55 (diff) |
🐛 Fix handling of non-usb v4l2 devices
They don't have a vid and pid, so don't try to format those as hex.
-rwxr-xr-x | src/modules/octopi/filesystem/home/root/bin/webcamd | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/modules/octopi/filesystem/home/root/bin/webcamd b/src/modules/octopi/filesystem/home/root/bin/webcamd index 2af5a79..4aded2e 100755 --- a/src/modules/octopi/filesystem/home/root/bin/webcamd +++ b/src/modules/octopi/filesystem/home/root/bin/webcamd @@ -189,19 +189,22 @@ function startUsb { product=`cat $uevent_file | grep PRODUCT | cut -d"=" -f2` vid=`echo $product | cut -d"/" -f1` pid=`echo $product | cut -d"/" -f2` - vidpid=`printf "%04x:%04x" "0x$vid" "0x$pid"` - - # ... then look if it is in our list of known broken-fps-devices and if so remove - # the -f parameter from the options (if it's in there, else that's just a no-op) - for identifier in ${brokenfps_usb_devices[@]}; - do - if [ "$vidpid" = "$identifier" ]; then - echo - echo "Camera model $vidpid is known to not work with -f parameter, stripping it out" - echo - options=`echo $options | sed -e "s/\(\s\+\|^\)-f\s\+[0-9]\+//g"` - fi - done + + if [[ -n "$vid" && -n "$pid" ]]; then + vidpid=`printf "%04x:%04x" "0x$vid" "0x$pid"` + + # ... then look if it is in our list of known broken-fps-devices and if so remove + # the -f parameter from the options (if it's in there, else that's just a no-op) + for identifier in ${brokenfps_usb_devices[@]}; + do + if [ "$vidpid" = "$identifier" ]; then + echo + echo "Camera model $vidpid is known to not work with -f parameter, stripping it out" + echo + options=`echo $options | sed -e "s/\(\s\+\|^\)-f\s\+[0-9]\+//g"` + fi + done + fi fi logger -s "Starting USB webcam" |