#!/bin/bash echo "Script to decode SSTV using QSSTV with rtl_fm" echo sudo systemctl stop openwebrx sudo modprobe snd-aloop sudo killall -9 qsstv &>/dev/null sudo killall -9 rtl_fm &>/dev/null sudo killall -9 aplay &>/dev/null sudo killall -9 direwolf &>/dev/null sudo systemctl stop rtl_tcp pkill -o chromium &>/dev/null sudo killall -9 rtl_tcp &>/dev/null sudo killall -9 java &>/dev/null sudo killall -9 CubicSDR &>/dev/null sudo killall -9 sdrpp &>/dev/null sudo killall -9 zenity &>/dev/null sudo killall -9 rtl_fm &>/dev/null #echo "s" >> .mode autotune=0 frequency=$(zenity --timeout=10 --list 2>/dev/null --width=410 --height=270 --title="SSTV Decoding using QSSTV" --text="Choose the frequency for SSTV decoding:" --column="kHz" --column="Use" 145800 "ISS" 434900 "CubeSatSim" Auto-tune "CubeSatSim Auto-tune" Other "Choose another frequency" SSTV "Test SSTV decoding with WAV file") echo $frequency if [ -z "$frequency" ]; then echo "No choice made." frequency=434900 #echo "Choose the number for the frequency for SSTV decoding:" #echo "1. ISS (145800Hz)" #echo "2. CubeSatSim (434900 kHz)" #echo "3. Enter a frequency in kiloHertz" #echo "4. Play an SSTV WAV file to test" #echo #read -r choice fi if [ "$choice" = "1" ] || [ "$frequency" = "145800" ]; then frequency=145800000 echo "Frequency is" $frequency echo echo "If the ISS is overhead (check Gpredict) and in SSTV mode (see social media), you can receive images." elif [ "$choice" = "2" ] || [ "$frequency" = "434900" ]; then frequency=434900000 echo "Frequency is" $frequency echo echo "If your CubeSatSim is transmitting in SSTV mode (mode 4) you should get images." echo "Note: if you see and hear an SSTV signal but don't get any images, the CubeSatSim signal might have a frequency offset. Try rebooting the CubeSatSim to fix." elif [ "$frequency" = "Auto-tune" ]; then frequency=434900000 autotune=1 elif [ "$choice" = "3" ] || [ "$frequency" = "Other" ]; then echo echo "Enter the frequency in kiloHertz" echo read -r frequency frequency=$frequency"000" elif [ "$choice" = "4" ] || [ "$frequency" = "SSTV" ]; then echo "A recorded Scottie 2 SSTV WAV file will play and you should see an image decoded." echo value=`aplay -l | grep "Loopback"` echo "$value" > /dev/null set -- $value #aplay -D hw:0,0 /home/pi/CubeSatSim/telem.wav & (while true; do (sleep 5 && aplay -D hw:0,0 /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav); done) & #aplay -D hw:${2:0:1},0,0 /home/pi/CubeSatSim/telem.wav & (while true; do (sleep 5 && aplay -D hw:${2:0:1},0,0 /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav); done) & qsstv fi if [ "$choice" != "4" ] && [ "$frequency" != "SSTV" ]; then #echo $frequency echo echo "Note that the 'Tuned to' frequency will be different from the chosen frequency due to the way SDRs work." echo echo -e "Auto decoding SSTV on $frequency Hz" #sleep 2 setsid qsstv & #sleep 5 if [ "$autotune" = "1" ]; then threshold=1 delay=5 retries=5 echo "Starting Auto-tune scanning" echo "Scan will stop when confidence exceeds threshold value of" $threshold "or after" $retries "retries" tries=0 confidence=0 delay=$((delay-2)) # subtract 2 second built in delay while [ $tries -le $retries ] && [ "$confidence" -le "$threshold" ]; do sleep $delay source /home/pi/venv/bin/activate python3 /home/pi/CubeSatSim/groundstation/auto-tune.py 434900000 n 2> null > /home/pi/CubeSatSim/groundstation/auto-tune.txt # echo "auto-tune.txt" # cat /home/pi/CubeSatSim/groundstation/auto-tune.txt confidence=$(awk '{print $2}' /home/pi/CubeSatSim/groundstation/auto-tune.txt) echo "Auto tune confidence:" $confidence tries=$((tries+1)) done if [ "$confidence" -gt "$threshold" ]; then frequency=$(awk '{print $1}' /home/pi/CubeSatSim/groundstation/auto-tune.txt) echo "Auto tune frequency:" $frequency else echo "Auto tune failed, frequency unchanged" fi echo echo "If your CubeSatSim is transmitting in SSTV mode (mode 4) you should get images." echo fi #sudo systemctl restart cubesatsim value=`aplay -l | grep "Loopback"` echo "$value" > /dev/null set -- $value #rtl_fm -M fm -f 434.9M -s 48k | aplay -D hw:${2:0:1},0,0 -r 48000 -t raw -f S16_LE -c 1 #rtl_fm -M fm -f 434.9M -s 48k | tee >(aplay -D hw:${2:0:1},0,0 -r 48000 -t raw -f S16_LE -c 1) | aplay -D hw:0,0 -r 48000 -t raw -f S16_LE -c 1 rtl_fm -M fm -f $frequency -s 48k | tee >(aplay -D hw:${2:0:1},0,0 -r 48000 -t raw -f S16_LE -c 1) | aplay -r 48000 -t raw -f S16_LE -c 1 rtl_fm -M fm -f $frequency -s 48k | aplay -D hw:${2:0:1},0,0 -r 48000 -t raw -f S16_LE -c 1 sleep 5 fi #$SHELL