From d8332a6a7627ca8242a3b349ec01da338b62fb25 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Sat, 20 Jan 2024 09:43:57 +0100 Subject: [PATCH 01/40] refactor: refactor detect_libcamera func Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index ceb5bd72..58675b01 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -63,8 +63,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" From 94f2ec77e444906951ef454bb8e42c72f8aa4e2b Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Wed, 31 Jan 2024 19:32:49 +0100 Subject: [PATCH 02/40] feat: print picamera resolutions Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 50 +++++++++++++++++++++++++++++------------------ libs/logging.sh | 31 +++++++++++++++-------------- 2 files changed, 47 insertions(+), 34 deletions(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index 58675b01..43cb7de9 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -19,10 +19,10 @@ set -Ee ### Detect Hardware detect_avail_cams() { local avail realpath - avail="$(find /dev/v4l/by-id/ -iname "*index0" 2> /dev/null)" + 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 + [[ -n "${avail}" ]]; then log_msg "INFO: Found ${count} available v4l2 (UVC) camera(s)" echo "${avail}" | while read -r v4l; do realpath=$(readlink -e "${v4l}") @@ -44,7 +44,7 @@ list_cam_formats() { prefix="$(date +'[%D %T]') crowsnest:" log_msg "Supported Formats:" while read -r i; do - printf "%s\t\t%s\n" "${prefix}" "${i}" >> "${CROWSNEST_LOG_PATH}" + printf "%s\t\t%s\n" "${prefix}" "${i}" >>"${CROWSNEST_LOG_PATH}" done < <(v4l2-ctl -d "${device}" --list-formats-ext | sed '1,3d') } @@ -54,7 +54,7 @@ list_cam_v4l2ctrls() { prefix="$(date +'[%D %T]') crowsnest:" log_msg "Supported Controls:" while read -r i; do - printf "%s\t\t%s\n" "${prefix}" "${i}" >> "${CROWSNEST_LOG_PATH}" + printf "%s\t\t%s\n" "${prefix}" "${i}" >>"${CROWSNEST_LOG_PATH}" done < <(v4l2-ctl -d "${device}" --list-ctrls-menus) } @@ -62,7 +62,7 @@ list_cam_v4l2ctrls() { detect_libcamera() { local avail if [[ "$(is_raspberry_pi)" = "1" ]] && - [[ -x "$(command -v libcamera-hello)" ]]; then + [[ -x "$(command -v libcamera-hello)" ]]; then avail="$(libcamera-hello --list-cameras | grep -c "Available")" if [[ "${avail}" = "1" ]]; then get_libcamera_path | wc -l @@ -77,30 +77,42 @@ detect_libcamera() { ## Spit /base/soc path for libcamera device get_libcamera_path() { if [[ "$(is_raspberry_pi)" = "1" ]] && - [[ -x "$(command -v libcamera-hello)" ]]; then - libcamera-hello --list-cameras | sed '1,2d' \ - | grep "\(/base/*\)" | cut -d"(" -f2 | tr -d '$)' + [[ -x "$(command -v libcamera-hello)" ]]; then + libcamera-hello --list-cameras | sed '1,2d' | + grep "\(/base/*\)" | cut -d"(" -f2 | tr -d '$)' fi } +# print libcamera resolutions +list_picam_resolution() { + local device prefix + device="${1}" + 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') +} + # 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 \ - )" + 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:-0}" } function dev_is_legacy { - v4l2-ctl --list-devices | grep -A1 -e 'mmal' | \ - awk 'NR==2 {print $1}' + v4l2-ctl --list-devices | grep -A1 -e 'mmal' | + awk 'NR==2 {print $1}' } ## Determine if cam has H.264 Hardware encoder @@ -124,7 +136,7 @@ detect_mjpeg() { ## Check if device is raspberry sbc is_raspberry_pi() { if [[ -f /proc/device-tree/model ]] && - grep -q "Raspberry" /proc/device-tree/model; then + grep -q "Raspberry" /proc/device-tree/model; then echo "1" else echo "0" @@ -133,7 +145,7 @@ is_raspberry_pi() { is_pi5() { if [[ -f /proc/device-tree/model ]] && - grep -q "Raspberry Pi 5" /proc/device-tree/model; then + grep -q "Raspberry Pi 5" /proc/device-tree/model; then echo "1" else echo "0" @@ -142,7 +154,7 @@ is_pi5() { is_ubuntu_arm() { if [[ "$(is_raspberry_pi)" = "1" ]] && - grep -q "ubuntu" /etc/os-release; then + grep -q "ubuntu" /etc/os-release; then echo "1" else echo "0" diff --git a/libs/logging.sh b/libs/logging.sh index aef72e09..c66a3998 100755 --- a/libs/logging.sh +++ b/libs/logging.sh @@ -39,7 +39,7 @@ function init_logging { function set_log_level { local loglevel - loglevel="$(get_param crowsnest log_level 2> /dev/null)" + loglevel="$(get_param crowsnest log_level 2>/dev/null)" # Set default log_level to quiet if [ -z "${loglevel}" ] || [[ "${loglevel}" != @(quiet|verbose|debug) ]]; then CROWSNEST_LOG_LEVEL="quiet" @@ -51,7 +51,7 @@ function set_log_level { function delete_log { local del_log - del_log="$(get_param "crowsnest" delete_log 2> /dev/null)" + del_log="$(get_param "crowsnest" delete_log 2>/dev/null)" if [ "${del_log}" = "true" ]; then rm -rf "${CROWSNEST_LOG_PATH}" fi @@ -61,7 +61,7 @@ function log_msg { local msg prefix msg="${1}" prefix="$(date +'[%D %T]') crowsnest:" - printf "%s %s\n" "${prefix}" "${msg}" >> "${CROWSNEST_LOG_PATH}" + printf "%s %s\n" "${prefix}" "${msg}" >>"${CROWSNEST_LOG_PATH}" printf "%s\n" "${msg}" } @@ -80,19 +80,19 @@ function print_cfg { local prefix prefix="$(date +'[%D %T]') crowsnest:" log_msg "INFO: Print Configfile: '${CROWSNEST_CFG}'" - (sed '/^#.*/d;/./,$!d' | cut -d'#' -f1) < "${CROWSNEST_CFG}" | \ - while read -r line; do - printf "%s\t\t%s\n" "${prefix}" "${line}" >> "${CROWSNEST_LOG_PATH}" - printf "\t\t%s\n" "${line}" - done + (sed '/^#.*/d;/./,$!d' | cut -d'#' -f1) <"${CROWSNEST_CFG}" | + while read -r line; do + printf "%s\t\t%s\n" "${prefix}" "${line}" >>"${CROWSNEST_LOG_PATH}" + printf "\t\t%s\n" "${line}" + done } function print_cams { local device total v4l - v4l="$(find /dev/v4l/by-id/ -iname "*index0" 2> /dev/null | wc -l)" + v4l="$(find /dev/v4l/by-id/ -iname "*index0" 2>/dev/null | wc -l)" libcamera="$(detect_libcamera)" legacy="$(detect_legacy)" - total="$((v4l+libcamera+legacy))" + total="$((v4l + libcamera + legacy))" if [ "${total}" -eq 0 ]; then log_msg "ERROR: No usable Devices Found. Stopping $(basename "${0}")." exit 1 @@ -108,10 +108,11 @@ function print_cams { for device in $(get_libcamera_path); do log_msg "Detected 'libcamera' device -> ${device}" done + list_picam_resolution fi if [[ "${legacy}" -ne 0 ]]; then - raspicam="$(v4l2-ctl --list-devices | grep -A1 -e 'mmal' | \ - awk 'NR==2 {print $1}')" + 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 list_cam_formats "${raspicam}" @@ -135,8 +136,8 @@ function print_host { ## OS Infos ## OS Version if [[ -f /etc/os-release ]]; then - log_msg "Host Info: Distribution: $(grep "PRETTY" /etc/os-release | \ - cut -d '=' -f2 | sed 's/^"//;s/"$//')" + log_msg "Host Info: Distribution: $(grep "PRETTY" /etc/os-release | + cut -d '=' -f2 | sed 's/^"//;s/"$//')" fi ## Release Version of MainsailOS (if file present) if [[ -f /etc/mainsailos-release ]]; then @@ -150,7 +151,7 @@ function print_host { log_msg "Host Info: Model: ${sbc_model}" fi if [[ -n "${generic_model}" ]] && - [[ -z "${sbc_model}" ]]; then + [[ -z "${sbc_model}" ]]; then log_msg "Host Info: Model: ${generic_model}" fi ## CPU count From 5410a9e4ffecbca0fbbc0520b721e47ecd4b01f7 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Wed, 31 Jan 2024 19:53:55 +0100 Subject: [PATCH 03/40] chore: wip Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index 43cb7de9..ded9724a 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -85,13 +85,15 @@ get_libcamera_path() { # print libcamera resolutions list_picam_resolution() { - local device prefix - device="${1}" - 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') + + log_msg "HEYYY" + # local device prefix + # device="${1}" + # 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') } # Determine connected "legacy" device From 64000be1f041791489a25c2c9dbc0ebbd637b7cb Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Wed, 31 Jan 2024 19:57:12 +0100 Subject: [PATCH 04/40] chore: wip Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index ded9724a..bf6bf9d3 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -85,15 +85,12 @@ get_libcamera_path() { # print libcamera resolutions list_picam_resolution() { - - log_msg "HEYYY" - # local device prefix - # device="${1}" - # 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') + 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') } # Determine connected "legacy" device From f7bc73f4aa06fb0aa7276175e3d213f30c092a49 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Wed, 31 Jan 2024 20:14:13 +0100 Subject: [PATCH 05/40] chore: wip Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index bf6bf9d3..f1e5ecd1 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -90,7 +90,7 @@ list_picam_resolution() { 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') + done < <(libcamera-hello --list-cameras | sed '1,2d;s/Modes://') } # Determine connected "legacy" device From b32a18cc8ab3710af82edd4ab3a2467b3857dca9 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Wed, 31 Jan 2024 20:42:44 +0100 Subject: [PATCH 06/40] chore: wip Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index f1e5ecd1..72167749 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -90,7 +90,7 @@ list_picam_resolution() { 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://') + done < <(libcamera-hello --list-cameras | sed '1,2d;s/Modes:/Colorspace:/') } # Determine connected "legacy" device From e9e4011d6697d97e134da2cbe2ded26706249320 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Wed, 31 Jan 2024 21:05:29 +0100 Subject: [PATCH 07/40] chore: wip Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 35 +++++++++++++++++++++++++++++++++++ libs/logging.sh | 1 + 2 files changed, 36 insertions(+) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index 72167749..efb55d9c 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -93,6 +93,41 @@ list_picam_resolution() { done < <(libcamera-hello --list-cameras | sed '1,2d;s/Modes:/Colorspace:/') } +get_libcamera_controls() { + python - <>"${CROWSNEST_LOG_PATH}" + fi + done < <(get_libcamera_controls) +} + # Determine connected "legacy" device function detect_legacy { local avail diff --git a/libs/logging.sh b/libs/logging.sh index c66a3998..a461a280 100755 --- a/libs/logging.sh +++ b/libs/logging.sh @@ -109,6 +109,7 @@ function print_cams { log_msg "Detected 'libcamera' device -> ${device}" done list_picam_resolution + list_picam_controls fi if [[ "${legacy}" -ne 0 ]]; then raspicam="$(v4l2-ctl --list-devices | grep -A1 -e 'mmal' | From 63a5529233b7d87b9341cd26fd53b3f5bfb8903f Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Wed, 31 Jan 2024 21:07:13 +0100 Subject: [PATCH 08/40] chore: wip Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index efb55d9c..fb9fea9e 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -112,7 +112,7 @@ for key, value in ctrls.items(): else: ctrl_type=type(min) - print(f"{key} ({ctrl_type}) :\t\tmin={min} max={max} default={default}\n") + print(f"{key} ({ctrl_type}) :\t\tmin={min} max={max} default={default}") EOL } From 947cb07ebdc790644911fed6b24ad83db5d821de Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Wed, 31 Jan 2024 21:08:40 +0100 Subject: [PATCH 09/40] chore: wip Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index fb9fea9e..a5d1e37b 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -126,6 +126,8 @@ list_picam_controls() { 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 From a1429f10516bf9c88617053d28507e6af351ca2e Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Wed, 31 Jan 2024 21:16:30 +0100 Subject: [PATCH 10/40] chore: dont display controls on pi5 Signed-off-by: Stephan Wendel --- libs/logging.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/logging.sh b/libs/logging.sh index a461a280..5e9ec5b7 100755 --- a/libs/logging.sh +++ b/libs/logging.sh @@ -109,7 +109,9 @@ function print_cams { log_msg "Detected 'libcamera' device -> ${device}" done list_picam_resolution - list_picam_controls + if [[ "$(is_pi5)" = "0" ]]; then + list_picam_controls + fi fi if [[ "${legacy}" -ne 0 ]]; then raspicam="$(v4l2-ctl --list-devices | grep -A1 -e 'mmal' | From 63bbbea908f1f108c739187009c140bbbc3e59e3 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Wed, 31 Jan 2024 21:20:25 +0100 Subject: [PATCH 11/40] chore: dont display resolutions on pi5 Signed-off-by: Stephan Wendel --- libs/logging.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/logging.sh b/libs/logging.sh index 5e9ec5b7..9fdb228f 100755 --- a/libs/logging.sh +++ b/libs/logging.sh @@ -108,8 +108,8 @@ function print_cams { for device in $(get_libcamera_path); do log_msg "Detected 'libcamera' device -> ${device}" done - list_picam_resolution if [[ "$(is_pi5)" = "0" ]]; then + list_picam_resolution list_picam_controls fi fi From 09b19c9b9cfe5eab733f1765dc83bc618cec29b8 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Wed, 31 Jan 2024 21:35:10 +0100 Subject: [PATCH 12/40] fix: revert code style changes Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 30 +++++++++++++++--------------- libs/logging.sh | 26 +++++++++++++------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index a5d1e37b..065dc46f 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -44,7 +44,7 @@ list_cam_formats() { prefix="$(date +'[%D %T]') crowsnest:" log_msg "Supported Formats:" while read -r i; do - printf "%s\t\t%s\n" "${prefix}" "${i}" >>"${CROWSNEST_LOG_PATH}" + printf "%s\t\t%s\n" "${prefix}" "${i}" >> "${CROWSNEST_LOG_PATH}" done < <(v4l2-ctl -d "${device}" --list-formats-ext | sed '1,3d') } @@ -54,7 +54,7 @@ list_cam_v4l2ctrls() { prefix="$(date +'[%D %T]') crowsnest:" log_msg "Supported Controls:" while read -r i; do - printf "%s\t\t%s\n" "${prefix}" "${i}" >>"${CROWSNEST_LOG_PATH}" + printf "%s\t\t%s\n" "${prefix}" "${i}" >> "${CROWSNEST_LOG_PATH}" done < <(v4l2-ctl -d "${device}" --list-ctrls-menus) } @@ -62,7 +62,7 @@ list_cam_v4l2ctrls() { detect_libcamera() { local avail if [[ "$(is_raspberry_pi)" = "1" ]] && - [[ -x "$(command -v libcamera-hello)" ]]; then + [[ -x "$(command -v libcamera-hello)" ]]; then avail="$(libcamera-hello --list-cameras | grep -c "Available")" if [[ "${avail}" = "1" ]]; then get_libcamera_path | wc -l @@ -78,8 +78,8 @@ detect_libcamera() { get_libcamera_path() { if [[ "$(is_raspberry_pi)" = "1" ]] && [[ -x "$(command -v libcamera-hello)" ]]; then - libcamera-hello --list-cameras | sed '1,2d' | - grep "\(/base/*\)" | cut -d"(" -f2 | tr -d '$)' + libcamera-hello --list-cameras | sed '1,2d' \ + | grep "\(/base/*\)" | cut -d"(" -f2 | tr -d '$)' fi } @@ -89,7 +89,7 @@ list_picam_resolution() { 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}" + printf "%s\t\t%s\n" "${prefix}" "${i}" >> "${CROWSNEST_LOG_PATH}" done < <(libcamera-hello --list-cameras | sed '1,2d;s/Modes:/Colorspace:/') } @@ -137,18 +137,18 @@ function detect_legacy { command -v vcgencmd &>/dev/null; then if vcgencmd get_camera &>/dev/null; then avail="$( - vcgencmd get_camera | - awk -F '=' '{ print $3 }' | - cut -d',' -f1 - )" + 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' | - awk 'NR==2 {print $1}' + v4l2-ctl --list-devices | grep -A1 -e 'mmal' \ + | awk 'NR==2 {print $1}' } ## Determine if cam has H.264 Hardware encoder @@ -172,7 +172,7 @@ detect_mjpeg() { ## Check if device is raspberry sbc is_raspberry_pi() { if [[ -f /proc/device-tree/model ]] && - grep -q "Raspberry" /proc/device-tree/model; then + grep -q "Raspberry" /proc/device-tree/model; then echo "1" else echo "0" @@ -181,7 +181,7 @@ is_raspberry_pi() { is_pi5() { if [[ -f /proc/device-tree/model ]] && - grep -q "Raspberry Pi 5" /proc/device-tree/model; then + grep -q "Raspberry Pi 5" /proc/device-tree/model; then echo "1" else echo "0" @@ -190,7 +190,7 @@ is_pi5() { is_ubuntu_arm() { if [[ "$(is_raspberry_pi)" = "1" ]] && - grep -q "ubuntu" /etc/os-release; then + grep -q "ubuntu" /etc/os-release; then echo "1" else echo "0" diff --git a/libs/logging.sh b/libs/logging.sh index 9fdb228f..0bc48caa 100755 --- a/libs/logging.sh +++ b/libs/logging.sh @@ -39,7 +39,7 @@ function init_logging { function set_log_level { local loglevel - loglevel="$(get_param crowsnest log_level 2>/dev/null)" + loglevel="$(get_param crowsnest log_level 2> /dev/null)" # Set default log_level to quiet if [ -z "${loglevel}" ] || [[ "${loglevel}" != @(quiet|verbose|debug) ]]; then CROWSNEST_LOG_LEVEL="quiet" @@ -51,7 +51,7 @@ function set_log_level { function delete_log { local del_log - del_log="$(get_param "crowsnest" delete_log 2>/dev/null)" + del_log="$(get_param "crowsnest" delete_log 2> /dev/null)" if [ "${del_log}" = "true" ]; then rm -rf "${CROWSNEST_LOG_PATH}" fi @@ -61,7 +61,7 @@ function log_msg { local msg prefix msg="${1}" prefix="$(date +'[%D %T]') crowsnest:" - printf "%s %s\n" "${prefix}" "${msg}" >>"${CROWSNEST_LOG_PATH}" + printf "%s %s\n" "${prefix}" "${msg}" >> "${CROWSNEST_LOG_PATH}" printf "%s\n" "${msg}" } @@ -81,10 +81,10 @@ function print_cfg { prefix="$(date +'[%D %T]') crowsnest:" log_msg "INFO: Print Configfile: '${CROWSNEST_CFG}'" (sed '/^#.*/d;/./,$!d' | cut -d'#' -f1) <"${CROWSNEST_CFG}" | - while read -r line; do - printf "%s\t\t%s\n" "${prefix}" "${line}" >>"${CROWSNEST_LOG_PATH}" - printf "\t\t%s\n" "${line}" - done + while read -r line; do + printf "%s\t\t%s\n" "${prefix}" "${line}" >>"${CROWSNEST_LOG_PATH}" + printf "\t\t%s\n" "${line}" + done } function print_cams { @@ -92,7 +92,7 @@ function print_cams { v4l="$(find /dev/v4l/by-id/ -iname "*index0" 2>/dev/null | wc -l)" libcamera="$(detect_libcamera)" legacy="$(detect_legacy)" - total="$((v4l + libcamera + legacy))" + total="$((v4l+libcamera+legacy))" if [ "${total}" -eq 0 ]; then log_msg "ERROR: No usable Devices Found. Stopping $(basename "${0}")." exit 1 @@ -114,8 +114,8 @@ function print_cams { fi fi if [[ "${legacy}" -ne 0 ]]; then - raspicam="$(v4l2-ctl --list-devices | grep -A1 -e 'mmal' | - awk 'NR==2 {print $1}')" + 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 list_cam_formats "${raspicam}" @@ -139,8 +139,8 @@ function print_host { ## OS Infos ## OS Version if [[ -f /etc/os-release ]]; then - log_msg "Host Info: Distribution: $(grep "PRETTY" /etc/os-release | - cut -d '=' -f2 | sed 's/^"//;s/"$//')" + log_msg "Host Info: Distribution: $(grep "PRETTY" /etc/os-release \ + | cut -d '=' -f2 | sed 's/^"//;s/"$//')" fi ## Release Version of MainsailOS (if file present) if [[ -f /etc/mainsailos-release ]]; then @@ -154,7 +154,7 @@ function print_host { log_msg "Host Info: Model: ${sbc_model}" fi if [[ -n "${generic_model}" ]] && - [[ -z "${sbc_model}" ]]; then + [[ -z "${sbc_model}" ]]; then log_msg "Host Info: Model: ${generic_model}" fi ## CPU count From b9011815e916c09f2c7ca716d919526eca2b024e Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 19 Mar 2024 19:55:38 +0100 Subject: [PATCH 13/40] chore: switch to bash Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index 065dc46f..7767bb49 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -94,27 +94,17 @@ list_picam_resolution() { } get_libcamera_controls() { - python - < /dev/null | \ + sed 's/device//g;^SNAPSHOT/q' | sed '/^SNAPSHOT/d' | \ + sed '/^CAMERA/d;/- property/d' | sed '/\.\/camera/d' + else + log_msg "WARN: 'libcamera' device option can not be displayed, because" + log_msg "WARN: camera-streamer is not installed" + fi } list_picam_controls() { From 7b325090ca57ce1dcc0d3d5cb9db9b5aee85ec80 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 19 Mar 2024 20:00:42 +0100 Subject: [PATCH 14/40] fix: fix typo Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index 7767bb49..eb7fb1ed 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -99,7 +99,7 @@ get_libcamera_controls() { ust_bin="${BASE_CN_PATH}/bin/camera-streamer/camera-streamer" if [[ -x "${ust_bin}" ]]; then "${ust_bin}" "${flags[@]}" 2> /dev/null | \ - sed 's/device//g;^SNAPSHOT/q' | sed '/^SNAPSHOT/d' | \ + sed 's/device//g;/^SNAPSHOT/q' | sed '/^SNAPSHOT/d' | \ sed '/^CAMERA/d;/- property/d' | sed '/\.\/camera/d' else log_msg "WARN: 'libcamera' device option can not be displayed, because" From 30b2aeb83b99fffbd23b7b928caa81f1b4b3ab46 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 19 Mar 2024 20:02:51 +0100 Subject: [PATCH 15/40] fix: fix output Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index eb7fb1ed..8edbfc39 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -100,7 +100,7 @@ get_libcamera_controls() { if [[ -x "${ust_bin}" ]]; then "${ust_bin}" "${flags[@]}" 2> /dev/null | \ sed 's/device//g;/^SNAPSHOT/q' | sed '/^SNAPSHOT/d' | \ - sed '/^CAMERA/d;/- property/d' | sed '/\.\/camera/d' + sed '/^CAMERA/d;/- property/d' | sed '/camera-streamer Version:/d' else log_msg "WARN: 'libcamera' device option can not be displayed, because" log_msg "WARN: camera-streamer is not installed" From 8b3977143ebb4f83dc6b6056f9e0cbb3baf23671 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 19 Mar 2024 20:05:22 +0100 Subject: [PATCH 16/40] chore: wip Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index 8edbfc39..f6e6649b 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -100,7 +100,8 @@ get_libcamera_controls() { if [[ -x "${ust_bin}" ]]; then "${ust_bin}" "${flags[@]}" 2> /dev/null | \ sed 's/device//g;/^SNAPSHOT/q' | sed '/^SNAPSHOT/d' | \ - sed '/^CAMERA/d;/- property/d' | sed '/camera-streamer Version:/d' + sed '/^CAMERA/d;/- property/d' | sed '/camera-streamer Version:/d' | \ + sed 's/- available option: //g' else log_msg "WARN: 'libcamera' device option can not be displayed, because" log_msg "WARN: camera-streamer is not installed" From 1853129c38e79d69a171cfb27b77504b6cc75f63 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 19 Mar 2024 20:08:41 +0100 Subject: [PATCH 17/40] chore: wip Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index f6e6649b..446b20c3 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -101,7 +101,7 @@ get_libcamera_controls() { "${ust_bin}" "${flags[@]}" 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 's/- available option: //g' | sed '/^$/d' else log_msg "WARN: 'libcamera' device option can not be displayed, because" log_msg "WARN: camera-streamer is not installed" From 78d644eacc803824b8686d1802c2ddec3c2a99f1 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 19 Mar 2024 20:19:51 +0100 Subject: [PATCH 18/40] chore: wip Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index 446b20c3..55079aba 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -101,7 +101,8 @@ get_libcamera_controls() { "${ust_bin}" "${flags[@]}" 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/- available option: //g' | sed '/^$/d;' | \ + sed 's/([0-9]*[a-z,0-9]\,//g' else log_msg "WARN: 'libcamera' device option can not be displayed, because" log_msg "WARN: camera-streamer is not installed" From 84267b93788fbc88e45d83873743a32fa84df2c0 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 19 Mar 2024 20:28:30 +0100 Subject: [PATCH 19/40] chore: wip Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index 55079aba..fd8986e9 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -93,6 +93,7 @@ list_picam_resolution() { done < <(libcamera-hello --list-cameras | sed '1,2d;s/Modes:/Colorspace:/') } +#type=3): get_libcamera_controls() { local ust_bin flags flags=( --camera-type=libcamera --camera-list_options ) @@ -102,7 +103,8 @@ get_libcamera_controls() { 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 's/([0-9]*[a-z,0-9]\,//g' | \ + sed '/type=7/d;s/type=1\)\:/\(/\(bool\)/g' else log_msg "WARN: 'libcamera' device option can not be displayed, because" log_msg "WARN: camera-streamer is not installed" From 38e63a2979ab92e1985a45e5bca969f11f309a18 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 19 Mar 2024 20:31:57 +0100 Subject: [PATCH 20/40] chore: wip Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index fd8986e9..972163fe 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -104,7 +104,7 @@ get_libcamera_controls() { 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;s/type=1\)\:/\(/\(bool\)/g' + sed '/type=7/d;s#type=1\)\:\(#(bool)#g' else log_msg "WARN: 'libcamera' device option can not be displayed, because" log_msg "WARN: camera-streamer is not installed" From 127b0fcd6f271e8c0daf3ae566271b4fcff6b3c4 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 19 Mar 2024 20:32:56 +0100 Subject: [PATCH 21/40] chore: wip Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index 972163fe..82626118 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -103,8 +103,7 @@ get_libcamera_controls() { 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;s#type=1\)\:\(#(bool)#g' + sed 's/([0-9]*[a-z,0-9]\,//g' else log_msg "WARN: 'libcamera' device option can not be displayed, because" log_msg "WARN: camera-streamer is not installed" From 8dcb9cbcfb737d79a8c544cf697466c8631a0552 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 19 Mar 2024 20:38:37 +0100 Subject: [PATCH 22/40] chore: wip Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index 82626118..d8419c34 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -103,7 +103,8 @@ get_libcamera_controls() { 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 's/([0-9]*[a-z,0-9]\,//g' | \ + sed '/type=7)/d;s/type=1)/(bool)/g;s/type=3)/(int)/g;s/type=5)/(float)/g' else log_msg "WARN: 'libcamera' device option can not be displayed, because" log_msg "WARN: camera-streamer is not installed" From 3ff0296a1ea5360b352b2878d4b9e6879cc7e9e9 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 19 Mar 2024 20:40:47 +0100 Subject: [PATCH 23/40] chore: wip Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index d8419c34..ab035a70 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -103,8 +103,8 @@ get_libcamera_controls() { 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;s/type=1)/(bool)/g;s/type=3)/(int)/g;s/type=5)/(float)/g' + sed 's/([0-9]*[a-z,0-9]\,//g' | sed '/type=7)/d' | \ + sed 's/type=1)/(bool)/g;s/type=3)/(int)/g;s/type=5)/(float)/g' else log_msg "WARN: 'libcamera' device option can not be displayed, because" log_msg "WARN: camera-streamer is not installed" From 32bb8c204461c4a9a3ee5c9a6d736b6662d3605e Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 19 Mar 2024 20:42:34 +0100 Subject: [PATCH 24/40] chore: wip Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index ab035a70..36617c1b 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -104,7 +104,7 @@ get_libcamera_controls() { 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' | \ - sed 's/type=1)/(bool)/g;s/type=3)/(int)/g;s/type=5)/(float)/g' + sed 's/type=1)/\t(bool)/g;s/type=3)/\t(int)/g;s/type=5)/\t(float)/g' else log_msg "WARN: 'libcamera' device option can not be displayed, because" log_msg "WARN: camera-streamer is not installed" From 9c4266b63755b596db6cbcc0f51db0d8f9955ccd Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 19 Mar 2024 20:43:38 +0100 Subject: [PATCH 25/40] chore: wip Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index 36617c1b..9f205239 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -104,7 +104,7 @@ get_libcamera_controls() { 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' | \ - sed 's/type=1)/\t(bool)/g;s/type=3)/\t(int)/g;s/type=5)/\t(float)/g' + sed 's/type=1)/\t\t(bool)/g;s/type=3)/\t\t(int)/g;s/type=5)/\t\t(float)/g' else log_msg "WARN: 'libcamera' device option can not be displayed, because" log_msg "WARN: camera-streamer is not installed" From 9ce04f56b44df656e952782d0fae7fbde40eeea8 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 19 Mar 2024 20:46:56 +0100 Subject: [PATCH 26/40] chore: wip Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index 9f205239..d9dec862 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -104,7 +104,8 @@ get_libcamera_controls() { 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' | \ - sed 's/type=1)/\t\t(bool)/g;s/type=3)/\t\t(int)/g;s/type=5)/\t\t(float)/g' + sed 's/type=1)/\t(bool)/g;s/type=3)/\t(int)/g;s/type=5)/\t(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" From 1c2ce25661e793076211f29ea2e4d999cbf98b6a Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 19 Mar 2024 20:48:07 +0100 Subject: [PATCH 27/40] chore: wip Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index d9dec862..c5738554 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -105,7 +105,7 @@ get_libcamera_controls() { sed 's/- available option: //g' | sed '/^$/d;' | \ sed 's/([0-9]*[a-z,0-9]\,//g' | sed '/type=7)/d' | \ sed 's/type=1)/\t(bool)/g;s/type=3)/\t(int)/g;s/type=5)/\t(float)/g' | \ - sed 's/\[/min=/g;s/\.\./max=/g;s/\]$//g' + sed 's/\[/min=/g;s/\.\./\tmax=/g;s/\]$//g' else log_msg "WARN: 'libcamera' device option can not be displayed, because" log_msg "WARN: camera-streamer is not installed" From 094b15d27ead706b19a04b2fd8fc42c158e6a05c Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 19 Mar 2024 21:21:57 +0100 Subject: [PATCH 28/40] chore: wip Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index c5738554..e86bd676 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -104,7 +104,7 @@ get_libcamera_controls() { 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' | \ - sed 's/type=1)/\t(bool)/g;s/type=3)/\t(int)/g;s/type=5)/\t(float)/g' | \ + sed 's/type=1)/\t\t\t(bool)/g;s/type=3)/\t\t\t(int)/g;s/type=5)/\t\t\t(float)/g' | \ sed 's/\[/min=/g;s/\.\./\tmax=/g;s/\]$//g' else log_msg "WARN: 'libcamera' device option can not be displayed, because" From d0e743b68e1c7c0a6e9ac59224878db2c45fff60 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 19 Mar 2024 21:26:24 +0100 Subject: [PATCH 29/40] chore: wip Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index e86bd676..a13e1f05 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -103,8 +103,8 @@ get_libcamera_controls() { 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' | \ - sed 's/type=1)/\t\t\t(bool)/g;s/type=3)/\t\t\t(int)/g;s/type=5)/\t\t\t(float)/g' | \ + sed 's/([0-9]*[a-z,0-9]\,//g' | sed '/type=7/d;/type=4/d' | \ + sed 's/type=1/\t(bool/g;s/type=3/\t(int/g;s/type=5/\t(float/g' | \ sed 's/\[/min=/g;s/\.\./\tmax=/g;s/\]$//g' else log_msg "WARN: 'libcamera' device option can not be displayed, because" From 1df93b1ecc9aeb32e834886d1dba9bbb4dcee5a2 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 19 Mar 2024 21:31:22 +0100 Subject: [PATCH 30/40] chore: wip Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index a13e1f05..3f5f3b51 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -105,7 +105,7 @@ get_libcamera_controls() { 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/\t(bool/g;s/type=3/\t(int/g;s/type=5/\t(float/g' | \ - sed 's/\[/min=/g;s/\.\./\tmax=/g;s/\]$//g' + sed 's/\[/\tmin=/g;s/\.\./\tmax=/g;s/\]$//g' else log_msg "WARN: 'libcamera' device option can not be displayed, because" log_msg "WARN: camera-streamer is not installed" From 058df55d928ab920565340c7ffa17d8d0aa62173 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 19 Mar 2024 21:46:18 +0100 Subject: [PATCH 31/40] chore: revert code style changes Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 15 +++++---------- libs/logging.sh | 14 +++++++------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index 3f5f3b51..971afe5d 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}") @@ -77,7 +76,7 @@ detect_libcamera() { ## Spit /base/soc path for libcamera device get_libcamera_path() { if [[ "$(is_raspberry_pi)" = "1" ]] && - [[ -x "$(command -v libcamera-hello)" ]]; then + [[ -x "$(command -v libcamera-hello)" ]]; then libcamera-hello --list-cameras | sed '1,2d' \ | grep "\(/base/*\)" | cut -d"(" -f2 | tr -d '$)' fi @@ -131,19 +130,15 @@ function detect_legacy { 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 - )" + 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' \ - | awk 'NR==2 {print $1}' + v4l2-ctl --list-devices | grep -A1 -e 'mmal' | \ + awk 'NR==2 {print $1}' } ## Determine if cam has H.264 Hardware encoder diff --git a/libs/logging.sh b/libs/logging.sh index 0bc48caa..bb40a8e8 100755 --- a/libs/logging.sh +++ b/libs/logging.sh @@ -80,16 +80,16 @@ function print_cfg { local prefix prefix="$(date +'[%D %T]') crowsnest:" log_msg "INFO: Print Configfile: '${CROWSNEST_CFG}'" - (sed '/^#.*/d;/./,$!d' | cut -d'#' -f1) <"${CROWSNEST_CFG}" | + (sed '/^#.*/d;/./,$!d' | cut -d'#' -f1) < "${CROWSNEST_CFG}" | \ while read -r line; do - printf "%s\t\t%s\n" "${prefix}" "${line}" >>"${CROWSNEST_LOG_PATH}" + printf "%s\t\t%s\n" "${prefix}" "${line}" >> "${CROWSNEST_LOG_PATH}" printf "\t\t%s\n" "${line}" done } function print_cams { local device total v4l - v4l="$(find /dev/v4l/by-id/ -iname "*index0" 2>/dev/null | wc -l)" + v4l="$(find /dev/v4l/by-id/ -iname "*index0" 2> /dev/null | wc -l)" libcamera="$(detect_libcamera)" legacy="$(detect_legacy)" total="$((v4l+libcamera+legacy))" @@ -114,8 +114,8 @@ function print_cams { fi fi if [[ "${legacy}" -ne 0 ]]; then - raspicam="$(v4l2-ctl --list-devices | grep -A1 -e 'mmal' \ - | awk 'NR==2 {print $1}')" + 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 list_cam_formats "${raspicam}" @@ -139,8 +139,8 @@ function print_host { ## OS Infos ## OS Version if [[ -f /etc/os-release ]]; then - log_msg "Host Info: Distribution: $(grep "PRETTY" /etc/os-release \ - | cut -d '=' -f2 | sed 's/^"//;s/"$//')" + log_msg "Host Info: Distribution: $(grep "PRETTY" /etc/os-release | \ + cut -d '=' -f2 | sed 's/^"//;s/"$//')" fi ## Release Version of MainsailOS (if file present) if [[ -f /etc/mainsailos-release ]]; then From dd8e1d2c3630e555727276b3df32e7a351a6c6c6 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Tue, 19 Mar 2024 21:50:13 +0100 Subject: [PATCH 32/40] chore: revert code style change Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index 971afe5d..ef69a4c1 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -19,7 +19,7 @@ set -Ee ### Detect Hardware detect_avail_cams() { local avail realpath - avail="$(find /dev/v4l/by-id/ -iname "*index0" 2>/dev/null)" + 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 v4l2 (UVC) camera(s)" From 10ec828aff3c3a54548769a480a313388b8c8472 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Wed, 20 Mar 2024 17:00:21 +0100 Subject: [PATCH 33/40] chore: revert code style changes Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index ef69a4c1..bcd5e6af 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -128,7 +128,7 @@ list_picam_controls() { function detect_legacy { local avail if [[ "$(is_raspberry_pi)" = "1" ]] && - command -v vcgencmd &>/dev/null; then + 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 From ae02f466804cc58947f79dbc585f34841048752c Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Wed, 20 Mar 2024 17:01:10 +0100 Subject: [PATCH 34/40] chore: revert code style changes Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index bcd5e6af..d4b51a3e 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -129,7 +129,7 @@ function detect_legacy { local avail if [[ "$(is_raspberry_pi)" = "1" ]] && command -v vcgencmd &> /dev/null; then - if vcgencmd get_camera &>/dev/null; then + if vcgencmd get_camera &> /dev/null; then avail="$( vcgencmd get_camera | awk -F '=' '{ print $3 }' | cut -d',' -f1)" fi fi From 55e2f06dce43be287498802c58dea5ba3a42169f Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Thu, 21 Mar 2024 16:05:14 +0100 Subject: [PATCH 35/40] chore: remove useless comment Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index d4b51a3e..93619db8 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -92,7 +92,6 @@ list_picam_resolution() { done < <(libcamera-hello --list-cameras | sed '1,2d;s/Modes:/Colorspace:/') } -#type=3): get_libcamera_controls() { local ust_bin flags flags=( --camera-type=libcamera --camera-list_options ) From 6bf8fd813f9c9718bee91cecdf2e66da3bfb9420 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Thu, 21 Mar 2024 16:08:08 +0100 Subject: [PATCH 36/40] chore: wip Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index 93619db8..bfefd7ea 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -97,7 +97,7 @@ get_libcamera_controls() { 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[@]}" 2> /dev/null | \ + "${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;' | \ From 9239cd8da21e5b2583107e0ecaaa1274e4d280fe Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Thu, 21 Mar 2024 16:27:29 +0100 Subject: [PATCH 37/40] chore: wip Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index bfefd7ea..3d2949a1 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -103,7 +103,7 @@ get_libcamera_controls() { 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/\t(bool/g;s/type=3/\t(int/g;s/type=5/\t(float/g' | \ - sed 's/\[/\tmin=/g;s/\.\./\tmax=/g;s/\]$//g' + sed 's/\[/\tmin=/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" From b26f5edb8f393203d8191a5d5a28d6ea7cf494af Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Thu, 21 Mar 2024 16:29:34 +0100 Subject: [PATCH 38/40] chore: wip Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index 3d2949a1..afcb14dd 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -102,7 +102,7 @@ get_libcamera_controls() { 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/\t(bool/g;s/type=3/\t(int/g;s/type=5/\t(float/g' | \ + sed 's/type=1/ (bool/g;s/type=3/ (int/g;s/type=5/ (float/g' | \ sed 's/\[/\tmin=/g;s/\.\./ max=/g;s/\]$//g' else log_msg "WARN: 'libcamera' device option can not be displayed, because" From 2cd11c4b08c211a076f12e631ca84ec355f0ec03 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Thu, 21 Mar 2024 16:31:07 +0100 Subject: [PATCH 39/40] chore: wip Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index afcb14dd..66ae338c 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -102,7 +102,7 @@ get_libcamera_controls() { 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/type=1/ (bool/g;s/type=3/ (int/g;s/type=5/ (float/g' | \ sed 's/\[/\tmin=/g;s/\.\./ max=/g;s/\]$//g' else log_msg "WARN: 'libcamera' device option can not be displayed, because" From 4ba3942d20906de58c58f1d68c9935b497f4b5e3 Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Thu, 21 Mar 2024 16:34:55 +0100 Subject: [PATCH 40/40] chore: wip Signed-off-by: Stephan Wendel --- libs/hwhandler.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/hwhandler.sh b/libs/hwhandler.sh index 66ae338c..515b2b6b 100755 --- a/libs/hwhandler.sh +++ b/libs/hwhandler.sh @@ -103,7 +103,7 @@ get_libcamera_controls() { 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/\[/\tmin=/g;s/\.\./ max=/g;s/\]$//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"