#!/bin/bash # Author: Kristopher Setnes # Date: 2020-09-13 # This script watches the CCD Simulator driver and controls the snap port # found on many SkyWatcher mounts. If you have a different way to control # your shutter from the command line, you can easily modify this script by # changing exposeSensor and closeShutter. # Used in indi_setprop commands. Change if you have and use snap port 2. OPEN_SHUTTER="EQMod Mount.SNAPPORT1.SNAPPORT1_ON=On" CLOSE_SHUTTER="EQMod Mount.SNAPPORT1.SNAPPORT1_OFF=On" exposeSensor() { indi_setprop "$OPEN_SHUTTER" sleep $1 indi_setprop "$CLOSE_SHUTTER" } closeShutter() { indi_setprop "$CLOSE_SHUTTER" # We call closeShutter first in the script below. # It can double as a test to make sure the parameter exists. if [ $? -ne 0 ] then echo echo "Could not access the snap port!" echo exit 1 fi } # Print output prefixed with time. function log_this() { echo "$(date "+%T.%3N") -- $@" } # Print hours, minutes, seconds.... convertSeconds() { h=$(bc <<< "${1}/3600") m=$(bc <<< "(${1}%3600)/60") s=$(bc <<< "${1}%60") printf "%02d:%02d:%04.1f" $h $m $s } # Ctrl-C handler for clean shutdown exitScript() { echo log_this "Done" closeShutter exit 0 } trap exitScript SIGINT # Make sure the shutter is closed at the start. closeShutter # Main Loop COUNT=0 TOTAL=0 while true do echo log_this "Waiting for next capture..." EXPOSURE=$(indi_eval -t 0 -w -o '"CCD Simulator.CCD_EXPOSURE.CCD_EXPOSURE_VALUE" > 0.001' 2>&1|tail -n 1|cut -f2 -d"=") log_this "Image $((++COUNT)) -- ${EXPOSURE} seconds" exposeSensor $EXPOSURE TOTAL=$( echo "$TOTAL + $EXPOSURE" | bc -l ) log_this "Cumulative exposure = $(convertSeconds $TOTAL)" done # We won't hit this when using the infinite loop above. exitScript