From 07fc9aeb7f667ba17206878716776e1d5d463a60 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 29 Oct 2025 14:14:23 -0400 Subject: [PATCH] Update fctelem.sh add auto-tune --- groundstation/fctelem.sh | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/groundstation/fctelem.sh b/groundstation/fctelem.sh index 4beb88a3..c2682806 100755 --- a/groundstation/fctelem.sh +++ b/groundstation/fctelem.sh @@ -80,8 +80,9 @@ else echo fi +autotune=0 -frequency=$(zenity --timeout=10 --list 2>/dev/null --width=410 --height=180 --title="FUNcube Telem Decoding" --text="Choose the frequency for FUNcube decoding:" --column="kHz" --column="Use" 434900 "CubeSatSim" Other "Choose another frequency") +frequency=$(zenity --timeout=10 --list 2>/dev/null --width=410 --height=220 --title="FUNcube Telem Decoding" --text="Choose the frequency for FUNcube decoding:" --column="kHz" --column="Use" 434900 "CubeSatSim" Auto-tune "CubeSatSim Auto-tune" Other "Choose another frequency") echo $frequency @@ -96,6 +97,11 @@ if [ "$frequency" = "434900" ]; then frequency=434900000 +elif [ "$frequency" = "Auto-tune" ]; then + + frequency=434900000 + autotune=1 + elif [ "$frequency" = "Other" ]; then echo @@ -110,6 +116,38 @@ elif [ "$frequency" = "Other" ]; then fi +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 + +fi + echo "Frequency is" $frequency echo echo "If your CubeSatSim is transmitting in FUNcube mode (mode 7) you should get some frames after 30 seconds"