#!/bin/bash # AUX is the extra reciever added to hook into WSJT-X using DIGIU and a VAC etc AUXRECV="51114" # we use these to check if theres already a reciever tuned to our band RECV1FT8="51111" RECV2FT8="51112" RECV3FT8="51113" RECV4FT8="51115" IP="192.168.9.52" function getband() { FREQ=$(cat -) if [[ $FREQ =~ ^1......$ ]] ; then echo 160 elif [[ $FREQ =~ ^3......$ ]] ; then echo 80 elif [[ $FREQ =~ ^7......$ ]] ; then echo 40 elif [[ $FREQ =~ ^10......$ ]] ; then echo 30 elif [[ $FREQ =~ ^14......$ ]] ; then echo 20 elif [[ $FREQ =~ ^18......$ ]] ; then echo 17 elif [[ $FREQ =~ ^21......$ ]] ; then echo 15 elif [[ $FREQ =~ ^24......$ ]] ; then echo 12 elif [[ $FREQ =~ ^28......$ ]] ; then echo 10 else echo "FAILED" return 1 fi } while true ; do AUXBAND=$(echo 'f' | nc -w 1 $IP $AUXRECV | getband) RECV1=$(echo 'f' | nc -w 1 $IP $RECV1FT8 | getband) RECV2=$(echo 'f' | nc -w 1 $IP $RECV2FT8 | getband) RECV3=$(echo 'f' | nc -w 1 $IP $RECV3FT8 | getband) RECV4=$(echo 'f' | nc -w 1 $IP $RECV4FT8 | getband) echo "AUX band $AUXBAND" echo "RECV1 band $RECV1" echo "RECV1 band $RECV2" echo "RECV1 band $RECV3" echo "RECV1 band $RECV4" if [[ $AUXBAND =~ ^-?[0-9]+$ ]] && [[ $AUXBAND -ne $RECV1 && $AUXBAND -ne $RECV2 && $AUXBAND -ne $RECV3 && $AUXBAND -ne $RECV4 ]] ; then if [ "x$AUXBAND" != "x$LASTBAND" ] ; then echo "New band found, running setmode" /home/nathan/tools/setmode.sh else echo "Latest band is same as last, doing nothing" fi LASTBAND="$AUXBAND" else echo "AUX band matches existing" fi sleep 1 done