Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to ver 0.8 and other changes #423

Merged
merged 29 commits into from
Aug 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
94e425e
Add files via upload
EricClaeys Jul 10, 2021
a08f239
Add files via upload
EricClaeys Jul 10, 2021
82f1d28
Add files via upload
EricClaeys Jul 10, 2021
a6d8abf
Add files via upload
EricClaeys Jul 10, 2021
998950d
Merge branch 'thomasjacquin:master' into master
EricClaeys Aug 2, 2021
3ae07e8
Update copy_notification_image.sh
EricClaeys Aug 4, 2021
1145558
Update darkCapture.sh
EricClaeys Aug 4, 2021
2829369
Update darkSubtract.sh
EricClaeys Aug 4, 2021
8b7f315
Update endOfNight.sh
EricClaeys Aug 4, 2021
12042de
Update endOfNight_additionalSteps.sh
EricClaeys Aug 4, 2021
ca5412b
Update generateForDay.sh
EricClaeys Aug 4, 2021
4983636
Update postData.sh
EricClaeys Aug 4, 2021
c8f8ebc
Update saveImageDay.sh
EricClaeys Aug 4, 2021
d19202a
Update saveImageNight.sh
EricClaeys Aug 4, 2021
cecbf31
Update removeBadImages.sh
EricClaeys Aug 4, 2021
6bd2a68
Update timelapse.sh
EricClaeys Aug 4, 2021
1a707fb
Update uploadForDay.sh
EricClaeys Aug 4, 2021
cbba45c
Update README.md
EricClaeys Aug 4, 2021
a273911
Update allsky.sh
EricClaeys Aug 4, 2021
74f6356
Update config.sh.repo
EricClaeys Aug 4, 2021
149cf7b
Update settings_RPiHQ.json.repo
EricClaeys Aug 4, 2021
e321f5e
Update settings_ZWO.json.repo
EricClaeys Aug 4, 2021
fc044bc
Update capture_RPiHQ.cpp
EricClaeys Aug 4, 2021
f67fa12
Update capture.cpp
EricClaeys Aug 5, 2021
d0e862b
Allow user to specify timelapse bitrate
EricClaeys Aug 9, 2021
fc7ed64
Update capture.cpp
EricClaeys Aug 9, 2021
7657eee
Check both Linefeed and Carriage Return
EricClaeys Aug 9, 2021
b302888
Update version; users can change timelapse bitrate
EricClaeys Aug 9, 2021
9ec0bfb
Updated to ver 0.8 and other changes
EricClaeys Aug 14, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 78 additions & 33 deletions README.md

Large diffs are not rendered by default.

115 changes: 92 additions & 23 deletions allsky.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,51 +6,90 @@ then
fi

# reset auto camera selection, so $ALLSKY_HOME/config.sh do not pick up old camera selection
cd $ALLSKY_HOME
echo "" > "$ALLSKY_HOME/autocam.sh"
source $ALLSKY_HOME/config.sh

# Make it easy to find the beginning of this run in the log file.
echo " ***** Starting AllSky *****"
echo "Making sure allsky.sh is not already running..."
ps -ef | grep allsky.sh | grep -v $$ | xargs "sudo kill -9" 2>/dev/null

mv -f log.txt OLD_log.txt 2> /dev/null # save the prior log file for debugging
> log.txt

# old/regular manual camera selection mode => exit if no requested camera was found
RPiHQIsPresent=$(vcgencmd get_camera)
if [[ $CAMERA == "RPiHQ" && $RPiHQIsPresent != "supported=1 detected=1" ]]; then
echo "RPiHQ Camera not found. Exiting." >&2
if [[ $(vcgencmd get_camera) == "supported=1 detected=1" ]]; then
RPiHQIsPresent=1
else
RPiHQIsPresent=0
fi
if [[ $CAMERA == "RPiHQ" && $RPiHQIsPresent -eq 0 ]]; then
echo "RPiHQ Camera not found. Exiting." >&2
sudo systemctl stop allsky
exit 0
fi

ZWOIsPresent=$(lsusb -D $(lsusb | awk '/ 03c3:/ { bus=$2; dev=$4; gsub(/[^0-9]/,"",dev); print "/dev/bus/usb/"bus"/"dev;}') | grep -c 'iProduct .*ASI[0-9]')
if [[ $CAMERA == "ZWO" && $ZWOIsPresent -eq 0 ]]; then
echo "ZWO Camera not found. Exiting." >&2
sudo systemctl stop allsky
exit 0
if [[ $CAMERA != "RPiHQ" ]]; then
# Use two commands to better aid debugging when camera isn't found.
# xxxxx This doesn't catch cases where CAMERA is "auto" and we should use ZWO.
ZWOdev=$(lsusb | awk '/ 03c3:/ { bus=$2; dev=$4; gsub(/[^0-9]/,"",dev); print "/dev/bus/usb/"bus"/"dev;}')
ZWOIsPresent=$(lsusb -D ${ZWOdev} 2>/dev/null | grep -c 'iProduct .*ASI[0-9]')
if [[ $CAMERA == "ZWO" && $ZWOIsPresent -eq 0 ]]; then
echo "ZWO Camera not found..." >&2
if [[ $ZWOdev == "" ]]; then
echo " and no USB entry found for it." >&2
else
echo " but USB entry '$ZWOdev' found for it." >&2
fi
if [ "$UHUBCTL_PATH" != "" ] ; then
if tty --silent ; then
echo " Resetting USB ports; restart allsky.sh when done." >&2
else
echo " Resetting USB ports and restarting." >&2
# The service will automatically restart this script.
fi
sudo "$UHUBCTL_PATH" -a cycle -l "$UHUBCTL_PORT"
exit 0
else
echo " Exiting." >&2
echo " If you have the 'uhubctl' command installed, add it to config.sh." >&2
echo " In the meantime, try running it to reset the USB bus." >&2
sudo systemctl stop allsky
exit 0
fi
fi
fi

# CAMERA AUTOSELECT
# exit if no camare found at all
if [[ $CAMERA -eq "auto" ]]; then
# exit if no camera found at all
if [[ $CAMERA == "auto" ]]; then
echo "Trying to automatically choose between ZWO and RPI camera"
if [[ $ZWOIsPresent -eq 0 && $RPiHQIsPresent != "supported=1 detected=1" ]]; then
if [[ $ZWOIsPresent -eq 0 && $RPiHQIsPresent -eq 0 ]]; then
echo "None of RPI or ZWO Cameras were found. Exiting." >&2
sudo systemctl stop allsky
exit 0
fi
# prioritize ZWO camera if exists, and use RPI camera otherwise
if [[ $ZWOIsPresent -eq 0 ]]; then
echo "No ZWO camera found. Choosing RPI"
# echo "No ZWO camera found. Choosing RPI" # CAMERA is displayed below; don't need it here too
CAMERA="RPiHQ"
else
echo "ZWO camera found. Choosing ZWO"
# echo "ZWO camera found. Choosing ZWO" # CAMERA is displayed below; don't need it here too
CAMERA="ZWO"
fi

# redefine the settings variable
CAMERA_SETTINGS="$CAMERA_SETTINGS_DIR/settings_$CAMERA.json"
fi

# Optionally display a notification image
USE_NOTIFICATION_IMAGES=$(jq -r '.notificationimages' "$CAMERA_SETTINGS")
if [ "$USE_NOTIFICATION_IMAGES" = "1" ] ; then
$ALLSKY_HOME/scripts/copy_notification_image.sh "StartingUp" 2>&1
fi

echo "Settings check done"
# echo "Settings check done"
echo "CAMERA: ${CAMERA}"
echo "CAMERA_SETTINGS: ${CAMERA_SETTINGS}"
# save auto camera selection for the current session, will be read in "$ALLSKY_HOME/config.sh" file
Expand All @@ -60,27 +99,57 @@ echo "export CAMERA=$CAMERA" > "$ALLSKY_HOME/autocam.sh"
source $ALLSKY_HOME/scripts/filename.sh

echo "Starting allsky camera..."
cd $ALLSKY_HOME

# Building the arguments to pass to the capture binary
ARGUMENTS=""
# Building the arguments to pass to the capture binary.
# Want to allow spaces in arguments so need to put quotes around them,
# but in order for it to work need to make ARGUMENTS an array.
ARGUMENTS=()
KEYS=( $(jq -r 'keys[]' $CAMERA_SETTINGS) )
for KEY in ${KEYS[@]}
do
ARGUMENTS="$ARGUMENTS -$KEY `jq -r '.'$KEY $CAMERA_SETTINGS` "
K="`jq -r '.'$KEY $CAMERA_SETTINGS`"
ARGUMENTS+=(-$KEY "$K")
done

# When using a desktop environment (Remote Desktop, VNC, HDMI output, etc), a preview of the capture can be displayed in a separate window
# The preview mode does not work if allsky.sh is started as a service or if the debian distribution has no desktop environment.
if [[ $1 == "preview" ]] ; then
ARGUMENTS="$ARGUMENTS -preview 1"
ARGUMENTS+=(-preview 1)
fi
ARGUMENTS="$ARGUMENTS -daytime $DAYTIME"
ARGUMENTS+=(-daytime $DAYTIME)

echo "$ARGUMENTS">>log.txt
# Determine if we're called from the service (tty will fail).
tty --silent
if [ $? -eq 0 ] ; then
TTY=1
else
TTY=0
fi
ARGUMENTS+=(-tty $TTY)

Z=""
for A in ${ARGUMENTS[@]}
do
Z="$Z $A"
done
echo "$Z" >> log.txt

RETCODE=0
if [[ $CAMERA == "ZWO" ]]; then
$ALLSKY_HOME/capture $ARGUMENTS
$ALLSKY_HOME/capture "${ARGUMENTS[@]}"
RETCODE=$?
echo "capture exited with retcode=$RETCODE"

elif [[ $CAMERA == "RPiHQ" ]]; then
$ALLSKY_HOME/capture_RPiHQ $ARGUMENTS
$ALLSKY_HOME/capture_RPiHQ "${ARGUMENTS[@]}"
RETCODE=$?
else
exit 1
fi

if [ "$USE_NOTIFICATION_IMAGES" = "1" -a "$RETCODE" -ne 0 ] ; then
# "capture" will do this if it exited with 0.
$ALLSKY_HOME/scripts/copy_notification_image.sh "NotRunning" 2>&1
fi

exit $RETCODE
Loading