Skip to content

Commit

Permalink
Merge pull request #4026 from AllskyTeam/Say-when-no-RPi-command-was-…
Browse files Browse the repository at this point in the history
…found

Say when no RPi command was found
  • Loading branch information
Alex-developer authored Dec 8, 2024
2 parents 84a164d + 33574ea commit d338256
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
17 changes: 12 additions & 5 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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" )
}
Expand Down Expand Up @@ -3901,4 +3908,4 @@ else
fi

display_msg progress "\nEnjoy Allsky!\n"
exit_installation 0 "${STATUS_OK}" ""
exit_installation 0 "${STATUS_OK}" ""
14 changes: 11 additions & 3 deletions scripts/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit d338256

Please sign in to comment.