From 46f3586fba8da7707873ecca83ccd6247d776573 Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Thu, 21 Mar 2024 17:26:07 +0100 Subject: [PATCH 1/3] feat: log libamera device resolutions and controls (#240) Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 57 ++++++++++++++++++++++++++++++++++++++--------- libs/logging.sh | 6 ++++- 2 files changed, 52 insertions(+), 11 deletions(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index ceb5bd72..515b2b6b 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -21,8 +21,7 @@ detect_avail_cams() { local avail 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 + if [[ -d "/dev/v4l/by-id/" ]] && [[ -n "${avail}" ]]; then log_msg "INFO: Found ${count} available v4l2 (UVC) camera(s)" echo "${avail}" | while read -r v4l; do realpath=$(readlink -e "${v4l}") @@ -63,8 +62,8 @@ detect_libcamera() { local avail if [[ "$(is_raspberry_pi)" = "1" ]] && [[ -x "$(command -v libcamera-hello)" ]]; then - avail="$(libcamera-hello --list-cameras | sed '/^\[.*\].*/d' | awk 'NR==1 {print $1}')" - if [[ "${avail}" = "Available" ]]; then + avail="$(libcamera-hello --list-cameras | grep -c "Available")" + if [[ "${avail}" = "1" ]]; then get_libcamera_path | wc -l else echo "0" @@ -83,23 +82,61 @@ get_libcamera_path() { fi } +# print libcamera resolutions +list_picam_resolution() { + local prefix + prefix="$(date +'[%D %T]') crowsnest:" + log_msg "'libcamera' device(s) resolution(s) :" + while read -r i; do + printf "%s\t\t%s\n" "${prefix}" "${i}" >> "${CROWSNEST_LOG_PATH}" + done < <(libcamera-hello --list-cameras | sed '1,2d;s/Modes:/Colorspace:/') +} + +get_libcamera_controls() { + local ust_bin flags + flags=( --camera-type=libcamera --camera-list_options ) + ust_bin="${BASE_CN_PATH}/bin/camera-streamer/camera-streamer" + if [[ -x "${ust_bin}" ]]; then + "${ust_bin}" "${flags[@]}" --camera-path="$(get_libcamera_path)" 2> /dev/null | \ + sed 's/device//g;/^SNAPSHOT/q' | sed '/^SNAPSHOT/d' | \ + sed '/^CAMERA/d;/- property/d' | sed '/camera-streamer Version:/d' | \ + sed 's/- available option: //g' | sed '/^$/d;' | \ + sed 's/([0-9]*[a-z,0-9]\,//g' | sed '/type=7/d;/type=4/d' | \ + sed 's/type=1/ (bool/g;s/type=3/ (int/g;s/type=5/ (float/g' | \ + sed 's/\[/min=/g;s/\.\./ max=/g;s/\]$//g' + else + log_msg "WARN: 'libcamera' device option can not be displayed, because" + log_msg "WARN: camera-streamer is not installed" + fi +} + +list_picam_controls() { + local prefix + prefix="$(date +'[%D %T]') crowsnest:" + log_msg "'libcamera' device controls :" + while read -r i; do + if [[ ! "${i}" =~ "INFO" ]]; then + printf "%s\t\t%s\n" "${prefix}" "${i}" >>"${CROWSNEST_LOG_PATH}" + fi + done < <(get_libcamera_controls) + # blank line workaround + log_msg "" +} + # Determine connected "legacy" device function detect_legacy { local avail 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 \ - )" + if vcgencmd get_camera &> /dev/null; then + avail="$( vcgencmd get_camera | awk -F '=' '{ print $3 }' | cut -d',' -f1)" fi fi echo "${avail:-0}" } function dev_is_legacy { - v4l2-ctl --list-devices | grep -A1 -e 'mmal' | \ + v4l2-ctl --list-devices | grep -A1 -e 'mmal' | \ awk 'NR==2 {print $1}' } diff --git a/libs/logging.sh b/libs/logging.sh index aef72e09..bb40a8e8 100755 --- a/libs/logging.sh +++ b/libs/logging.sh @@ -108,9 +108,13 @@ function print_cams { for device in $(get_libcamera_path); do log_msg "Detected 'libcamera' device -> ${device}" done + if [[ "$(is_pi5)" = "0" ]]; then + list_picam_resolution + list_picam_controls + fi fi if [[ "${legacy}" -ne 0 ]]; then - raspicam="$(v4l2-ctl --list-devices | grep -A1 -e 'mmal' | \ + raspicam="$(v4l2-ctl --list-devices | grep -A1 -e 'mmal' | \ awk 'NR==2 {print $1}')" log_msg "Detected 'Raspicam' Device -> ${raspicam}" if [[ ! "${CROWSNEST_LOG_LEVEL}" = "quiet" ]]; then From a9db8f9ebea95122963ffb0274406dce2506840e Mon Sep 17 00:00:00 2001 From: Patrick Gehrsitz Date: Tue, 2 Apr 2024 19:18:49 +0200 Subject: [PATCH 2/3] chore: revert #249 and update ustreamer version to v6.9 (#254) Signed-off-by: Patrick Gehrsitz --- bin/build.sh | 4 ++-- tools/configure.sh | 4 ++-- tools/libs/config.sh | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/build.sh b/bin/build.sh index 5e8ed519..992d2f21 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -32,10 +32,10 @@ CLONE_FLAGS=(--depth=1 --single-branch) # Ustreamer repo USTREAMER_PATH="ustreamer" if [[ -z "${CROWSNEST_USTREAMER_REPO_SHIP}" ]]; then - CROWSNEST_USTREAMER_REPO_SHIP="https://github.com/mryel00/ustreamer.git" + CROWSNEST_USTREAMER_REPO_SHIP="https://github.com/pikvm/ustreamer.git" fi if [[ -z "${CROWSNEST_USTREAMER_REPO_BRANCH}" ]]; then - CROWSNEST_USTREAMER_REPO_BRANCH="master" + CROWSNEST_USTREAMER_REPO_BRANCH="v6.10" fi # Camera-streamer repo diff --git a/tools/configure.sh b/tools/configure.sh index 8c3d9579..11c82467 100755 --- a/tools/configure.sh +++ b/tools/configure.sh @@ -26,8 +26,8 @@ CN_CONFIG_CONFIGPATH="${CN_CONFIG_ROOTPATH}/config" CN_CONFIG_LOGPATH="${CN_CONFIG_ROOTPATH}/logs" CN_CONFIG_ENVPATH="${CN_CONFIG_ROOTPATH}/systemd" CN_MOONRAKER_CONFIG_PATH="${CN_CONFIG_CONFIGPATH}/moonraker.conf" -CN_USTREAMER_REPO="https://github.com/mryel00/ustreamer.git" -CN_USTREAMER_BRANCH="master" +CN_USTREAMER_REPO="https://github.com/pikvm/ustreamer.git" +CN_USTREAMER_BRANCH="v6.10" CN_CAMERA_STREAMER_REPO="https://github.com/ayufan/camera-streamer.git" CN_CAMERA_STREAMER_BRANCH="master" diff --git a/tools/libs/config.sh b/tools/libs/config.sh index ba0b10b3..6f9419bc 100755 --- a/tools/libs/config.sh +++ b/tools/libs/config.sh @@ -35,8 +35,8 @@ import_config() { [[ -n "${CROWSNEST_CONFIG_PATH}" ]] || CROWSNEST_CONFIG_PATH="/home/${BASE_USER}/printer_data/config" [[ -n "${CROWSNEST_LOG_PATH}" ]] || CROWSNEST_LOG_PATH="/home/${BASE_USER}/printer_data/logs" [[ -n "${CROWSNEST_ENV_PATH}" ]] || CROWSNEST_ENV_PATH="/home/${BASE_USER}/printer_data/systemd" - [[ -n "${CROWSNEST_USTREAMER_REPO_SHIP}" ]] || CROWSNEST_USTREAMER_REPO_SHIP="https://github.com/mryel00/ustreamer.git" - [[ -n "${CROWSNEST_USTREAMER_REPO_BRANCH}" ]] || CROWSNEST_USTREAMER_REPO_BRANCH="master" + [[ -n "${CROWSNEST_USTREAMER_REPO_SHIP}" ]] || CROWSNEST_USTREAMER_REPO_SHIP="https://github.com/pikvm/ustreamer.git" + [[ -n "${CROWSNEST_USTREAMER_REPO_BRANCH}" ]] || CROWSNEST_USTREAMER_REPO_BRANCH="v6.10" [[ -n "${CROWSNEST_CAMERA_STREAMER_REPO_SHIP}" ]] || CROWSNEST_CAMERA_STREAMER_REPO_SHIP="https://github.com/ayufan/camera-streamer.git" [[ -n "${CROWSNEST_CAMERA_STREAMER_REPO_BRANCH}" ]] || CROWSNEST_CAMERA_STREAMER_REPO_BRANCH="master" status_msg "Using default configuration ..." "0" From 7f8536696f1868de47519cbd1d8d17f6725d82b6 Mon Sep 17 00:00:00 2001 From: Patrick Gehrsitz Date: Tue, 2 Apr 2024 19:25:49 +0200 Subject: [PATCH 3/3] fix: fix empty string if ustreamer not found (#253) Signed-off-by: Patrick Gehrsitz --- libs/core.sh | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/libs/core.sh b/libs/core.sh index d37e2b73..59581de7 100755 --- a/libs/core.sh +++ b/libs/core.sh @@ -82,18 +82,15 @@ function check_dep { function check_apps { local cstreamer ustreamer - ustreamer_base="bin/ustreamer" - ustreamer="$(find "${BASE_CN_PATH}"/"${ustreamer_base}" \ - -iname 'ustreamer.bin' 2> /dev/null | sed '1q')" + ustreamer="bin/ustreamer/src/ustreamer.bin" cstreamer="bin/camera-streamer/camera-streamer" - - if [[ -x "${ustreamer}" ]]; then - log_msg "Dependency: '${ustreamer##*/}' found in ${ustreamer_base}/${ustreamer##*/}." - UST_BIN="${ustreamer}" + if [[ -x "${BASE_CN_PATH}/${ustreamer}" ]]; then + log_msg "Dependency: 'ustreamer' found in ${ustreamer}." + UST_BIN="${BASE_CN_PATH}/${ustreamer}" # shellcheck disable=SC2034 declare -r UST_BIN else - log_msg "Dependency: '${ustreamer##*/}' not found. Exiting!" + log_msg "Dependency: 'ustreamer' not found. Exiting!" exit 1 fi