fix: fixes error in detect_legacy (#217)

This will fix issue on Raspberry Pi5, which doesnt generate cam list,
because 'vcgencmd get_camera' exits with an error.

If all conditions fail it will always return '0'

Signed-off-by: Stephan Wendel <me@stephanwe.de>
This commit is contained in:
Stephan Wendel 2023-12-14 23:54:46 +01:00 committed by GitHub
parent 43a1ee3bc0
commit 61421f5148
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -86,13 +86,16 @@ get_libcamera_path() {
# Determine connected "legacy" device
function detect_legacy {
local avail
if [[ -f /proc/device-tree/model ]] &&
grep -q "Raspberry" /proc/device-tree/model; then
avail="$(vcgencmd get_camera | awk -F '=' '{ print $3 }' | cut -d',' -f1)"
else
avail="0"
if [[ "$(is_raspberry_pi)" = "1" ]] &&
command -v vcgencmd &> /dev/null; then
if vcgencmd get_camera &> /dev/null ; then
avail="$(vcgencmd get_camera \
| awk -F '=' '{ print $3 }' \
| cut -d',' -f1 \
)"
fi
fi
echo "${avail}"
echo "${avail:-0}"
}
function dev_is_legacy {