feat: enable detection of csi adaptors
Added func detect_avail_csi. refactored logging.sh accordingly. Signed-off-by: Stephan Wendel <me@stephanwe.de>
This commit is contained in:
parent
62ee73b6da
commit
664d9b539b
@ -122,6 +122,6 @@ function initial_check {
|
||||
fi
|
||||
# in systemd show always config file
|
||||
logger -t webcamd -f "${WEBCAMD_CFG}"
|
||||
log_msg "INFO: Detect available Cameras"
|
||||
log_msg "INFO: Detect available Devices"
|
||||
print_cams
|
||||
}
|
||||
|
@ -19,18 +19,36 @@ set -e
|
||||
### Detect Hardware
|
||||
function detect_avail_cams {
|
||||
local avail realpath
|
||||
avail="$(find /dev/v4l/by-id/ 2> /dev/null | sort -n | sed '1d;1~2d')"
|
||||
if [ -d "/dev/v4l/by-id/" ]; then
|
||||
echo "${avail}" | while read -r i; do
|
||||
realpath=$(readlink -e "${i}")
|
||||
log_msg "${i} -> ${realpath}"
|
||||
avail="$(find /dev/v4l/by-id/ -iname "*index0" 2> /dev/null)"
|
||||
count="$(echo "${avail}" | wc -l)"
|
||||
if [ -d "/dev/v4l/by-id/" ] &&
|
||||
[ -n "${avail}" ]; then
|
||||
log_msg "INFO: Found ${count} available camera(s)"
|
||||
echo "${avail}" | while read -r v4l; do
|
||||
realpath=$(readlink -e "${v4l}")
|
||||
log_msg "${v4l} -> ${realpath}"
|
||||
if [ "$(log_level)" != "quiet" ]; then
|
||||
list_cam_formats "${i}"
|
||||
list_cam_formats "${v4l}"
|
||||
fi
|
||||
done
|
||||
else
|
||||
log_msg "ERROR: No usable Cameras found. Exiting."
|
||||
exit 1
|
||||
log_msg "INFO: No usable Cameras found."
|
||||
fi
|
||||
}
|
||||
|
||||
function detect_avail_csi {
|
||||
local avail count realpath
|
||||
avail="$(find /dev/v4l/by-path/ -iname "*csi*index0" 2> /dev/null)"
|
||||
count="$(echo "${avail}" | wc -l)"
|
||||
if [ -d "/dev/v4l/by-path/" ] &&
|
||||
[ -n "${avail}" ]; then
|
||||
log_msg "INFO: Found ${count} available csi device(s)"
|
||||
echo "${avail}" | while read -r csi; do
|
||||
realpath=$(readlink -e "${csi}")
|
||||
log_msg "${csi} -> ${realpath}"
|
||||
done
|
||||
else
|
||||
log_msg "INFO: No usable CSI Devices found."
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -87,17 +87,15 @@ function print_cfg {
|
||||
}
|
||||
|
||||
function print_cams {
|
||||
local count raspicam total
|
||||
count="$(find /dev/v4l/by-id/ 2> /dev/null | sed '1d;1~2d' | wc -l)"
|
||||
total="$((count+$(detect_raspicam)))"
|
||||
local csi raspicam total v4l
|
||||
v4l="$(find /dev/v4l/by-id/ -iname "*index0" 2> /dev/null | wc -l)"
|
||||
csi="$(find /dev/v4l/by-path/ -iname "*csi*index0" 2> /dev/null | wc -l)"
|
||||
total="$((v4l+$(detect_raspicam)+csi))"
|
||||
if [ "${total}" -eq 0 ]; then
|
||||
log_msg "ERROR: No usable Cameras Found. Stopping $(basename "${0}")."
|
||||
log_msg "ERROR: No usable Devices Found. Stopping $(basename "${0}")."
|
||||
exit 1
|
||||
else
|
||||
log_msg "INFO: Found ${total} available Camera(s)"
|
||||
fi
|
||||
if [ -d "/dev/v4l/by-id/" ]; then
|
||||
detect_avail_cams
|
||||
log_msg "INFO: Found ${total} total available Device(s)"
|
||||
fi
|
||||
if [ "$(detect_raspicam)" -ne 0 ]; then
|
||||
raspicam="$(v4l2-ctl --list-devices | grep -A1 -e 'mmal' | \
|
||||
@ -107,6 +105,12 @@ function print_cams {
|
||||
list_cam_formats "${raspicam}"
|
||||
fi
|
||||
fi
|
||||
if [ -d "/dev/v4l/by-id/" ]; then
|
||||
detect_avail_cams
|
||||
fi
|
||||
if [ -d "/dev/v4l/by-path" ]; then
|
||||
detect_avail_csi
|
||||
fi
|
||||
}
|
||||
|
||||
function debug_msg {
|
||||
|
Loading…
x
Reference in New Issue
Block a user