From d2486a87b62879d88d59463b1465273ec2797292 Mon Sep 17 00:00:00 2001 From: Eric Claeys <83164203+EricClaeys@users.noreply.github.com> Date: Sun, 8 Dec 2024 00:09:34 -0600 Subject: [PATCH 1/4] Update install.sh: Warn in no RPi camera command was found --- install.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index 0bcb6ceb4..a1e9592ff 100755 --- a/install.sh +++ b/install.sh @@ -302,10 +302,11 @@ CT=() # Camera Type array - what to display in whiptail get_connected_cameras() { - local CMD CC MSG NUM_RPI=0 NUM_ZWO=0 + local CMD CMD_RET CC MSG NUM_RPI=0 NUM_ZWO=0 # true == ignore errors. ${CMD} will be "" if no command found. CMD="$( determineCommandToUse "false" "" "true" 2> /dev/null )" + CMD_RET=$? # return of 2 means no command was found setup_rpi_supported_cameras "${CMD}" # Will create full file is CMD == "" # RPi format: RPi \t camera_number \t camera_sensor [\t optional_other_stuff] @@ -357,7 +358,12 @@ get_connected_cameras() whiptail --title "${TITLE}" --msgbox "${MSG}" 12 "${WT_WIDTH}" 3>&1 1>&2 2>&3 MSG="No connected cameras were detected." - display_msg --log error "${MSG}" + local MSG2="" + if [[ ${CMD_RET} -eq 2 ]]; then + MSG2="No command to take RPi images was found" + MSG2+=" - make sure 'libcamera-apps' is installed if you have an RPi camera." + fi + display_msg --log error "${MSG}" "${MSG2}" exit_installation 1 "${STATUS_NO_CAMERA}" "" fi @@ -540,6 +546,7 @@ do_save_camera_capabilities() MSG="No camera was found; one must be connected and working for the installation to succeed.\n" MSG+="After connecting your camera, re-run the installation." whiptail --title "${TITLE}" --msgbox "${MSG}" 12 "${WT_WIDTH}" 3>&1 1>&2 2>&3 + display_msg --log error "No camera detected - installation aborted." [[ -s ${TMP} ]] && display_msg --log error "$( < "${TMP}" )" exit_with_image 1 "${STATUS_ERROR}" "No camera detected" @@ -3518,8 +3525,8 @@ install_installer_dependencies() { sudo apt-get update && run_aptGet gawk jq dialog } > "${TMP}" 2>&1 - check_success $? "gawk,jq installation failed" "${TMP}" "${DEBUG}" || - exit_with_image 1 "${STATUS_ERROR}" "gawk,jq install failed." + check_success $? "gawk,jq,dialog installation failed" "${TMP}" "${DEBUG}" || + exit_with_image 1 "${STATUS_ERROR}" "gawk,jq,dialog install failed." STATUS_VARIABLES+=( "${FUNCNAME[0]}='true'\n" ) } @@ -3901,4 +3908,4 @@ else fi display_msg progress "\nEnjoy Allsky!\n" -exit_installation 0 "${STATUS_OK}" "" \ No newline at end of file +exit_installation 0 "${STATUS_OK}" "" From 33574ea3c33c58809c237754a6f98709d521feed Mon Sep 17 00:00:00 2001 From: Eric Claeys <83164203+EricClaeys@users.noreply.github.com> Date: Sun, 8 Dec 2024 00:10:47 -0600 Subject: [PATCH 2/4] Update functions.sh: Keep track of RPi command was found --- scripts/functions.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/functions.sh b/scripts/functions.sh index f7bc21e71..4a727e246 100644 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -187,7 +187,7 @@ function determineCommandToUse() local PREFIX="${2}" # Only used if calling doExit(). local IGNORE_ERRORS="${3:-false}" # True if just checking - local CRET RET MSG EXIT_MSG + local CRET RET MSG EXIT_MSG CMD_FOUND="false" # If libcamera is installed and works, use it. # If it's not installed, or IS installed but doesn't work (the user may not have it configured), @@ -203,7 +203,9 @@ function determineCommandToUse() CRET=$? fi if [[ ${CRET} -eq 0 ]]; then - # Found the command - see if it works. + CMD_FOUND="true" # one of the commands were found. + + # Found a command - see if it works. "${CMD_TO_USE_}" --timeout 1 --nopreview > /dev/null 2>&1 RET=$? if [[ ${RET} -eq 137 ]]; then @@ -230,9 +232,15 @@ function determineCommandToUse() fi fi - return 1 + if [[ ${CMD_FOUND} == "true" ]]; then + return 1 + else + return 2 # no command was found + fi fi + CMD_FOUND="true" # some command was found. + # On Buster, raspistill sometimes hangs if no camera is found, # so work around that. if ! timeout 4 "${CMD_TO_USE_}" --timeout 1 --nopreview > /dev/null 2>&1 ; then From 531c3111eec953f861192873b145707ddd33afd1 Mon Sep 17 00:00:00 2001 From: Eric Claeys <83164203+EricClaeys@users.noreply.github.com> Date: Sun, 8 Dec 2024 00:17:54 -0600 Subject: [PATCH 3/4] Update install.sh: Pass results of determineCommandToUse() --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index a1e9592ff..9f46f6528 100755 --- a/install.sh +++ b/install.sh @@ -312,7 +312,7 @@ get_connected_cameras() # RPi format: RPi \t camera_number \t camera_sensor [\t optional_other_stuff] # ZWO format: ZWO \t camera_number \t camera_model # "true" == ignore errors - get_connected_cameras_info "true" > "${CONNECTED_CAMERAS_INFO}" 2>/dev/null + get_connected_cameras_info --cmd "${CMD}" "true" > "${CONNECTED_CAMERAS_INFO}" 2>/dev/null # Get the RPi connected cameras, if any. CC="" From 97e6160b04f26b0756550ef071cb76a0c46ecdc2 Mon Sep 17 00:00:00 2001 From: Eric Claeys <83164203+EricClaeys@users.noreply.github.com> Date: Sun, 8 Dec 2024 00:22:04 -0600 Subject: [PATCH 4/4] Update functions.sh: check if determineCommandToUse() was already run --- scripts/functions.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/functions.sh b/scripts/functions.sh index 4a727e246..c8996ecd8 100644 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -269,6 +269,12 @@ function determineCommandToUse() # Prepend each line with the CAMERA_TYPE. function get_connected_cameras_info() { + local RUN_dCTU="true" # determine Command To Use + if [[ ${1} == "--cmd" ]]; then + RUN_dCTU="false" + CMD_TO_USE_="${2}" + shift 2 + fi local IGNORE_ERRORS="${1:-false}" ####### Check for RPi @@ -276,7 +282,8 @@ function get_connected_cameras_info() # RPi camera_number camera_sensor # for each camera found. # camera_sensor will be one word. - if [[ -z ${CMD_TO_USE_} ]]; then + # Only run determineCommandToUse() if it wasn't already run. + if [[ -z ${CMD_TO_USE_} && ${RUN_dCTU} == "true" ]]; then determineCommandToUse "false" "" "${IGNORE_ERRORS}" > /dev/null fi if [[ -n ${CMD_TO_USE_} ]]; then