diff --git a/config b/config index 47e1e809..7073de90 100755 --- a/config +++ b/config @@ -1,213 +1,110 @@ #!/bin/bash -function transmit_command_aprs { +function transmit_command { - FILE=/home/pi/CubeSatSim/transmit_dtmf - if [ -f "$FILE" ]; then - - echo "Stopping command and control" - sudo systemctl stop command - - echo "Transmit DTMF start" - gpio write 28 0 # ptt - gpio write 2 1 # tx LED - timeout 3 direwolf -c /home/pi/CubeSatSim/direwolf/direwolf-transmit-dtmf-aprs.conf -t 0l - gpio write 2 0 # tx LED - gpio write 28 1 #ptt - echo "Transmit stop" - - echo "Resuming command and control" - sudo systemctl start command - - else - - STRING="AMSAT-11>APCSS:=3901.40N\07704.39WShi hi MODE=a" - sudo rm /home/pi/CubeSatSim/t.txt > /dev/null 2>&1 - echo $STRING > /home/pi/CubeSatSim/t.txt - echo - echo -n "Sending APRS packet to change mode to APRS " - echo $STRING - sudo touch /home/pi/CubeSatSim/ready - sleep 3 - - fi - - exit -} - -function transmit_command_fsk { - - FILE=/home/pi/CubeSatSim/transmit_dtmf - if [ -f "$FILE" ]; then - - echo "Stopping command and control" - sudo systemctl stop command - - echo "Transmit DTMF start" - gpio write 28 0 # ptt - gpio write 2 1 # tx LED - timeout 3 direwolf -c /home/pi/CubeSatSim/direwolf/direwolf-transmit-dtmf-fsk.conf -t 0l - gpio write 2 0 # tx LED - gpio write 28 1 #ptt - echo "Transmit stop" - - echo "Resuming command and control" - sudo systemctl start command - - else - - STRING="AMSAT-11>APCSS:=3901.40N\07704.39WShi hi MODE=f" - sudo rm /home/pi/CubeSatSim/t.txt > /dev/null 2>&1 - echo $STRING > /home/pi/CubeSatSim/t.txt - echo - echo -n "Sending APRS packet to change mode to FSK" - echo $STRING - sudo touch /home/pi/CubeSatSim/ready - sleep 3 - - fi - - exit -} - -function transmit_command_bpsk { - - FILE=/home/pi/CubeSatSim/transmit_dtmf - if [ -f "$FILE" ]; then - - echo "Stopping command and control" - sudo systemctl stop command - - echo "Transmit DTMF start" - gpio write 28 0 # ptt - gpio write 2 1 # tx LED - timeout 3 direwolf -c /home/pi/CubeSatSim/direwolf/direwolf-transmit-dtmf-bpsk.conf -t 0l - gpio write 2 0 # tx LED - gpio write 28 1 #ptt - echo "Transmit stop" - - echo "Resuming command and control" - sudo systemctl start command - - else - - STRING="AMSAT-11>APCSS:=3901.40N\07704.39WShi hi MODE=b" - sudo rm /home/pi/CubeSatSim/t.txt > /dev/null 2>&1 - echo $STRING > /home/pi/CubeSatSim/t.txt - echo - echo -n "Sending APRS packet to change mode to BPSK" - echo $STRING - sudo touch /home/pi/CubeSatSim/ready - sleep 3 - - fi - - exit -} + MODE=$1 + echo "CubeSatSim is in Transmit Commands mode" + echo -function transmit_command_sstv { + value=`cat /home/pi/CubeSatSim/sim.cfg` + echo "$value" > /dev/null + set -- $value + + echo -n "TX Frequency is: " + echo -n ${7} + echo " MHz" FILE=/home/pi/CubeSatSim/transmit_dtmf if [ -f "$FILE" ]; then - echo "Stopping command and control" - sudo systemctl stop command - - echo "Transmit DTMF start" - gpio write 28 0 # ptt - gpio write 2 1 # tx LED - timeout 3 direwolf -c /home/pi/CubeSatSim/direwolf/direwolf-transmit-dtmf-sstv.conf -t 0l - gpio write 2 0 # tx LED - gpio write 28 1 #ptt - echo "Transmit stop" - - echo "Resuming command and control" - sudo systemctl start command - - else - - STRING="AMSAT-11>APCSS:=3901.40N\07704.39WShi hi MODE=s" - sudo rm /home/pi/CubeSatSim/t.txt > /dev/null 2>&1 - echo $STRING > /home/pi/CubeSatSim/t.txt echo - echo -n "Sending APRS packet to change mode to SSTV" - echo $STRING - sudo touch /home/pi/CubeSatSim/ready - sleep 3 + echo "Sending DTMF tones to change to mode "$MODE - fi - - exit -} + case $MODE in + + a) + number=1 + ;; + f) + number=2 + ;; + b) + number=3 + ;; + s) + number=4 + ;; + m) + number=5 + ;; + e) + number=6 + ;; + j) + number=7 + ;; + o) + number=10 + ;; + *) + number=0 + ;; + esac -function transmit_command_cw { +# echo $number - FILE=/home/pi/CubeSatSim/transmit_dtmf - if [ -f "$FILE" ]; then + cat /home/pi/CubeSatSim/direwolf/direwolf-transmit-dtmf.conf > /home/pi/CubeSatSim/direwolf-tmp.conf && echo 'CBEACON dest="DTMF-3" info="'$number' #" delay=0' >> /home/pi/CubeSatSim/direwolf-tmp.conf - echo "Stopping command and control" - sudo systemctl stop command +# echo "Stopping command and control" +# sudo systemctl stop command - echo "Transmit DTMF start" +# echo "Transmit start" gpio write 28 0 # ptt gpio write 2 1 # tx LED - timeout 3 direwolf -c /home/pi/CubeSatSim/direwolf/direwolf-transmit-dtmf-cw.conf -t 0l + timeout 3 direwolf -c /home/pi/CubeSatSim/direwolf-tmp.conf -t 0l > /dev/null 2>&1 gpio write 2 0 # tx LED gpio write 28 1 #ptt - echo "Transmit stop" +# echo "Transmit stop" - echo "Resuming command and control" - sudo systemctl start command +# echo "Resuming command and control" +# sudo systemctl start command else - STRING="AMSAT-11>APCSS:=3901.40N\07704.39WShi hi MODE=m" + STRING="$1-11>APCSS:=3901.40N\07704.39WShi hi MODE="$MODE sudo rm /home/pi/CubeSatSim/t.txt > /dev/null 2>&1 echo $STRING > /home/pi/CubeSatSim/t.txt echo - echo -n "Sending APRS packet to change mode to CW" + echo -n "Sending APRS packet to change mode to "$MODE" " echo $STRING sudo touch /home/pi/CubeSatSim/ready sleep 3 fi - exit + echo + echo "To change the mode of this CubeSatSim use config -n" } -function transmit_command_beacon { +function check_restart { - FILE=/home/pi/CubeSatSim/transmit_dtmf - if [ -f "$FILE" ]; then - - echo "Stopping command and control" - sudo systemctl stop command - - echo "Transmit DTMF start" - gpio write 28 0 # ptt - gpio write 2 1 # tx LED - timeout 3 direwolf -c /home/pi/CubeSatSim/direwolf/direwolf-transmit-dtmf-beacon.conf -t 0l - gpio write 2 0 # tx LED - gpio write 28 1 #ptt - echo "Transmit stop" - - echo "Resuming command and control" - sudo systemctl start command + value=`cat /home/pi/CubeSatSim/.mode` + echo "$value" > /dev/null + set -- $value + if [ "$1" == "f" ] || [ "$1" == "b" ] || [ "$1" == "e" ] || [ "$1" == "j" ] ; then + FILE=/home/pi/CubeSatSim/battery_saver + if [ -f "$FILE" ]; then + restart=1 +# echo "Need to restart since batt saver" + else + reboot=1 +# echo "Need to reboot" + fi else - - STRING="AMSAT-11>APCSS:=3901.40N\07704.39WShi hi MODE=o" - sudo rm /home/pi/CubeSatSim/t.txt > /dev/null 2>&1 - echo $STRING > /home/pi/CubeSatSim/t.txt - echo - echo -n "Sending APRS packet to toggle Beacon" - echo $STRING - sudo touch /home/pi/CubeSatSim/ready - sleep 3 - - fi - - exit + restart=1 +# echo "Need to restart" + fi } echo "CubeSatSim v2.1 configuration tool" @@ -218,12 +115,12 @@ echo sudo modprobe snd-aloop -# if [ "$2" = "n" ] ; then -if [ -z "$2" ] ; then - noreboot=0 -else + if [ "$2" = "n" ] ; then +#if [ -z "$2" ] ; then # need to swap else if change noreboot=1 echo "Reboot disabled" +else + noreboot=0 fi # echo "No reboot" @@ -276,6 +173,12 @@ if [ "$1" = "" ]; then fi echo + echo -n "TX Frequency is: " + echo -n ${7} + echo -n " MHz, RX Frequency is: " + echo -n ${8} + echo " MHz" + if [ "$9" = "yes" ] || [ "$9" = "y" ]; then echo "Balloon mode is ON" else @@ -362,22 +265,14 @@ elif [ "$1" = "-a" ]; then if [ "$1" == "n" ]; then - transmit_command_aprs + transmit_command "a" else echo "changing CubeSatSim to AFSK mode" + check_restart sudo echo "a" > /home/pi/CubeSatSim/.mode - if [ "$1" == "f" ] || [ "$1" == "b" ] || [ "$1" == "e" ] || [ "$1" == "j" ] ; then - FILE=/home/pi/CubeSatSim/battery_saver - if [ -f "$FILE" ]; then - restart=1 - else - reboot=1 - fi - else - restart=1 - fi + fi elif [ "$1" = "-m" ]; then @@ -388,22 +283,14 @@ elif [ "$1" = "-m" ]; then if [ "$1" == "n" ]; then - transmit_command_cw + transmit_command "m" else echo "changing CubeSatSim to CW mode" + check_restart sudo echo "m" > /home/pi/CubeSatSim/.mode - if [ "$1" == "f" ] || [ "$1" == "b" ] || [ "$1" == "e" ] || [ "$1" == "j" ] ; then - FILE=/home/pi/CubeSatSim/battery_saver - if [ -f "$FILE" ]; then - restart=1 - else - reboot=1 - fi - else - restart=1 - fi + fi elif [ "$1" = "-f" ]; then @@ -414,7 +301,7 @@ elif [ "$1" = "-f" ]; then if [ "$1" == "n" ]; then - transmit_command_fsk + transmit_command "f" else @@ -431,7 +318,7 @@ elif [ "$1" = "-b" ]; then if [ "$1" == "n" ]; then - transmit_command_bpsk + transmit_command "b" else @@ -448,23 +335,14 @@ elif [ "$1" = "-s" ]; then if [ "$1" == "n" ]; then - transmit_command_sstv + transmit_command "s" else echo "changing CubeSatSim to SSTV mode" + check_restart sudo echo "s" > /home/pi/CubeSatSim/.mode - if [ "$1" == "f" ] || [ "$1" == "b" ] || [ "$1" == "e" ] || [ "$1" == "j" ] ; then - FILE=/home/pi/CubeSatSim/battery_saver - if [ -f "$FILE" ]; then - restart=1 - else - reboot=1 - fi - else - restart=1 - fi fi elif [ "$1" = "-t" ]; then @@ -727,7 +605,6 @@ elif [ "$1" = "-C" ]; then elif [ "$1" = "-T" ]; then - echo echo "Change command and control state" echo @@ -740,7 +617,7 @@ elif [ "$1" = "-T" ]; then echo if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then - echo "Command and control set to OFF" + echo "Turning command and control OFF" sudo rm /home/pi/CubeSatSim/command_control > /dev/null 2>&1 # reboot=1 echo "restarting command and control" @@ -751,21 +628,40 @@ elif [ "$1" = "-T" ]; then fi else - echo "Radio command and control is OFF" + echo "Radio command and control is OFF" echo echo "Do you want to set command and control to ON (y/n) " read reset echo if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then - echo "Command and control set to ON" - sudo touch /home/pi/CubeSatSim/command_control - echo "restarting command and control" -# reboot=1 - sudo systemctl restart command - echo "restarting transmit" - sudo systemctl restart transmit -## sudo reboot now + + value=`cat /home/pi/CubeSatSim/.mode` + echo "$value" > /dev/null + set -- $value + + if [ "$1" != "n" ] ; then + echo "Turning command and control ON" + + value=`cat /home/pi/CubeSatSim/sim.cfg` + echo "$value" > /dev/null + set -- $value + + echo -n "RX Frequency is: " + echo -n ${8} + echo " MHz" + echo + + sudo touch /home/pi/CubeSatSim/command_control + echo "restarting command and control" +# reboot=1 + sudo systemctl restart command + echo "restarting transmit" + sudo systemctl restart transmit +## sudo reboot now + else + echo "Can't turn on Command and control in Transmit Commands mode." + fi fi fi @@ -1148,7 +1044,7 @@ elif [ "$1" = "-o" ]; then if [ "$1" == "n" ]; then - transmit_command_beacon + transmit_command "o" else echo @@ -1187,6 +1083,7 @@ elif [ "$1" = "-o" ]; then # restart=1 fi fi + sleep 3 fi elif [ "$1" = "-H" ]; then @@ -1252,102 +1149,119 @@ elif [ "$1" = "-v" ]; then elif [ "$1" = "-e" ]; then - echo "changing CubeSatSim to Repeater mode" - sudo echo "e" > /home/pi/CubeSatSim/.mode + value=`cat /home/pi/CubeSatSim/.mode` + echo "$value" > /dev/null + set -- $value + + if [ "$1" == "n" ]; then + + transmit_command "e" - restart=1 + else + + echo "changing CubeSatSim to Repeater mode" + sudo echo "e" > /home/pi/CubeSatSim/.mode + restart=1 + fi elif [ "$1" = "-n" ]; then - echo "changing CubeSatSim to Transmit Commands mode" +# echo "changing CubeSatSim to Transmit Commands mode" + + new=$2 value=`cat /home/pi/CubeSatSim/.mode` echo "$value" > /dev/null set -- $value if [ "$1" = "n" ]; then - echo "Turning Transmit Command and Control mode OFF" - echo "Switching to BPSK mode" - sudo echo "b" > /home/pi/CubeSatSim/.mode - reboot=1 + echo "Turning Transmit Commands mode OFF" + if [ "$new" = "a" ] || [ "$new" = "s" ] || [ "$new" = "m" ] ; then + check_restart + echo "Switching to mode "$new + sudo echo $new > /home/pi/CubeSatSim/.mode + elif [ "$new" = "f" ] || [ "$new" = "b" ] || [ "$new" = "e" ] || [ "$new" = "j" ] ; then + echo "Switching to mode "$new + sudo echo $new > /home/pi/CubeSatSim/.mode + restart=1 + else + echo "Switching to BPSK mode" + sudo echo "b" > /home/pi/CubeSatSim/.mode + reboot=1 + fi + sudo systemctl restart command else - echo "Turning Transmit Command and Control mode ON" + echo "Switching to Transmit Commands mode" + + value=`cat /home/pi/CubeSatSim/sim.cfg` + echo "$value" > /dev/null + set -- $value + + echo -n "TX Frequency is: " + echo -n ${7} + echo " MHz" + echo + + check_restart sudo echo "n" > /home/pi/CubeSatSim/.mode - restart=1 + sudo systemctl stop command fi elif [ "$1" = "-A" ]; then - echo "Transmit APRS control packets to control another CubeSatSim" + echo "Transmit APRS Commands to control another CubeSatSim" + echo + + value=`cat /home/pi/CubeSatSim/sim.cfg` + echo "$value" > /dev/null + set -- $value + + echo -n "TX Frequency is: " + echo -n ${7} + echo " MHz" echo value=`cat /home/pi/CubeSatSim/.mode` echo "$value" > /dev/null set -- $value + if [ "$1" == "f" ] || [ "$1" == "b" ] || [ "$1" == "e" ] || [ "$1" == "j" ] ; then + echo "The CubeSatSim/config -A command can only be run in APRS, SSTV, CW, or Transmit Commands modes." + echo "Switch to one of these modes (a, s, m, or n) then re-run this command." + exit + fi + if [ "$1" != "n" ]; then sudo systemctl stop cubesatsim sudo systemctl stop transmit - # sudo rm /home/pi/CubeSatSim/t.txt > /dev/null 2>&1 sudo python3 -u /home/pi/CubeSatSim/transmit.py x > /dev/null 2>&1 & # Force APRS mode fi + sudo systemctl stop command - sim="y" + MODE="0" - while [ "$sim" = "y" ] + while [ "$MODE" != "x" ]; do - echo "Enter the mode number to change: 1=APRS, 2=FSK, 3=BPSK, 4=SSTV, 5=CW" + echo "Enter the mode to change: a=APRS, f=FSK, b=BPSK, s=SSTV, m=CW, e=Repeater, j=FUNcube, o=Beacon on/off x=Exit this mode" read MODE - - case $MODE in - - 1) - echo "Mode 1 is APRS" - STRING="AMSAT-11>APCSS:=3901.40N\07704.39WShi hi MODE=a" - ;; - 2) - echo "Mode 2 is FSK" - STRING="AMSAT-11>APCSS:=3901.40N\07704.39WShi hi MODE=f" - ;; - 3) - echo "Mode 3 is BPSK" - STRING="AMSAT-11>APCSS:=3901.40N\07704.39WShi hi MODE=b" - ;; - 4) - echo "Mode 4 is SSTV" - STRING="AMSAT-11>APCSS:=3901.40N\07704.39WShi hi MODE=s" - ;; - 5) - echo "Mode 5 is CW" - STRING="AMSAT-11>APCSS:=3901.40N\07704.39WShi hi MODE=m" - ;; - *) - echo "Unknown mode" - STRING="AMSAT-11>APCSS:=3901.40N\07704.39WShi hi MODE=?" - ;; - esac - sudo rm /home/pi/CubeSatSim/t.txt > /dev/null 2>&1 - echo $STRING > /home/pi/CubeSatSim/t.txt - echo - echo -n "Sending APRS packet " - echo $STRING - sudo touch /home/pi/CubeSatSim/ready - sleep 5 - sudo touch /home/pi/CubeSatSim/ready + + if [ "$MODE" != "x" ]; then + transmit_command $MODE + fi echo - echo "Do you want to send another APRS command packet (y/n) " - read sim - echo + done - sudo rm /home/pi/CubeSatSim/t.txt > /dev/null 2>&1 -# sudo systemctl restart cubesatsim - if [ "$1" != "n" ]; then + value=`cat /home/pi/CubeSatSim/.mode` + echo "$value" > /dev/null + set -- $value + if [ "$1" != "n" ] ; then + sudo systemctl restart command reboot=1 fi @@ -1419,16 +1333,16 @@ elif [ "$1" = "-j" ]; then echo "$value" > /dev/null set -- $value -# if [ "$1" == "n" ]; then + if [ "$1" == "n" ]; then -# transmit_command_bpsk + transmit_command "j" -# else + else echo "changing CubeSatSim to FUNcube mode" sudo echo "j" > /home/pi/CubeSatSim/.mode restart=1 -# fi + fi elif [ "$1" = "-h" ]; then diff --git a/direwolf/direwolf-transmit-dtmf-beacon.conf b/direwolf/direwolf-transmit-dtmf-beacon.conf deleted file mode 100644 index 6c022dea..00000000 --- a/direwolf/direwolf-transmit-dtmf-beacon.conf +++ /dev/null @@ -1,5 +0,0 @@ -ADEVICE hw:CARD=Loopback,DEV=0 hw:CARD=Headphones,DEV=0 -MYCALL AMSAT -CHANNEL 0 -MODEM 1200 -CBEACON dest="DTMF-3" info="10 #" delay=0 diff --git a/direwolf/direwolf-transmit-dtmf-bpsk.conf b/direwolf/direwolf-transmit-dtmf-bpsk.conf deleted file mode 100644 index a0ae9b54..00000000 --- a/direwolf/direwolf-transmit-dtmf-bpsk.conf +++ /dev/null @@ -1,5 +0,0 @@ -ADEVICE hw:CARD=Loopback,DEV=0 hw:CARD=Headphones,DEV=0 -MYCALL AMSAT -CHANNEL 0 -MODEM 1200 -CBEACON dest="DTMF-3" info="3 #" delay=0 diff --git a/direwolf/direwolf-transmit-dtmf-cw.conf b/direwolf/direwolf-transmit-dtmf-cw.conf deleted file mode 100644 index 8629754f..00000000 --- a/direwolf/direwolf-transmit-dtmf-cw.conf +++ /dev/null @@ -1,5 +0,0 @@ -ADEVICE hw:CARD=Loopback,DEV=0 hw:CARD=Headphones,DEV=0 -MYCALL AMSAT -CHANNEL 0 -MODEM 1200 -CBEACON dest="DTMF-3" info="5 #" delay=0 diff --git a/direwolf/direwolf-transmit-dtmf-fsk.conf b/direwolf/direwolf-transmit-dtmf-fsk.conf deleted file mode 100644 index f197e583..00000000 --- a/direwolf/direwolf-transmit-dtmf-fsk.conf +++ /dev/null @@ -1,5 +0,0 @@ -ADEVICE hw:CARD=Loopback,DEV=0 hw:CARD=Headphones,DEV=0 -MYCALL AMSAT -CHANNEL 0 -MODEM 1200 -CBEACON dest="DTMF-3" info="2 #" delay=0 diff --git a/direwolf/direwolf-transmit-dtmf-sstv.conf b/direwolf/direwolf-transmit-dtmf-sstv.conf deleted file mode 100644 index c58cb77f..00000000 --- a/direwolf/direwolf-transmit-dtmf-sstv.conf +++ /dev/null @@ -1,5 +0,0 @@ -ADEVICE hw:CARD=Loopback,DEV=0 hw:CARD=Headphones,DEV=0 -MYCALL AMSAT -CHANNEL 0 -MODEM 1200 -CBEACON dest="DTMF-3" info="4 #" delay=0 diff --git a/direwolf/direwolf-transmit-dtmf-aprs.conf b/direwolf/direwolf-transmit-dtmf.conf similarity index 68% rename from direwolf/direwolf-transmit-dtmf-aprs.conf rename to direwolf/direwolf-transmit-dtmf.conf index 786102cd..a2fdd69c 100644 --- a/direwolf/direwolf-transmit-dtmf-aprs.conf +++ b/direwolf/direwolf-transmit-dtmf.conf @@ -2,4 +2,5 @@ ADEVICE hw:CARD=Loopback,DEV=0 hw:CARD=Headphones,DEV=0 MYCALL AMSAT CHANNEL 0 MODEM 1200 -CBEACON dest="DTMF-3" info="1 #" delay=0 +KISSPORT 8003 +AGWPORT 8004 diff --git a/dtmf_aprs_cc.py b/dtmf_aprs_cc.py index ad4ef5cf..cfa58788 100644 --- a/dtmf_aprs_cc.py +++ b/dtmf_aprs_cc.py @@ -30,7 +30,6 @@ if __name__ == "__main__": system("echo '\nAPRS Mode!!\n'") mode = 'a' change_mode = True - counter = (counter + 1) % 2 if ((line.find("DTMF>APDW15:t1#")) > 0): system("echo '\nAPRS Mode!!\n'") mode = 'a' @@ -39,7 +38,6 @@ if __name__ == "__main__": system("echo '\nFSK Mode!!\n'") mode = 'f' change_mode = True - counter = (counter + 1) % 2 if ((line.find("DTMF>APDW15:t2#")) > 0): system("echo '\nFSK Mode!!\n'") mode = 'f' @@ -48,7 +46,6 @@ if __name__ == "__main__": system("echo '\nBPSK Mode!!\n'") mode = 'b' change_mode = True - counter = (counter + 1) % 2 if ((line.find("DTMF>APDW15:t3#")) > 0): system("echo '\nBPSK Mode!!\n'") mode = 'b' @@ -57,7 +54,6 @@ if __name__ == "__main__": system("echo '\nSSTV Mode!!\n'") mode = 's' change_mode = True - counter = (counter + 1) % 2 if ((line.find("DTMF>APDW15:t4#")) > 0): system("echo '\nSSTV Mode!!\n'") mode = 's' @@ -66,17 +62,14 @@ if __name__ == "__main__": system("echo '\nCW Mode!!\n'") mode = 'm' change_mode = True - counter = (counter + 1) % 2 if ((line.find("DTMF>APDW15:t5#")) > 0): system("echo '\nCW Mode!!\n'") mode = 'm' change_mode = True - if ((line.find("MODE=e")) > 0): system("echo '\nRepeater Mode!!\n'") mode = 'e' change_mode = True - counter = (counter + 1) % 2 if ((line.find("DTMF>APDW15:t6#")) > 0): system("echo '\nRepeater Mode!!\n'") mode = 'e' @@ -85,7 +78,6 @@ if __name__ == "__main__": system("echo '\nFUNcube Mode!!\n'") mode = 'j' change_mode = True - counter = (counter + 1) % 2 if ((line.find("DTMF>APDW15:t7#")) > 0): system("echo '\nFUNcube Mode!!\n'") mode = 'j' @@ -94,22 +86,23 @@ if __name__ == "__main__": system("echo '\nTransmit Commands Mode!!\n'") mode = 'n' change_mode = True - counter = (counter + 1) % 2 if ((line.find("DTMF>APDW15:t11#")) > 0): system("echo '\nTransmit Commands Mode!!\n'") mode = 'n' change_mode = True if ((line.find("MODE=o")) > 0): - system("echo '\nBeacon Mode toggle!!\n'") - mode = 'o' - change_mode = True - counter = (counter + 1) % 2 + counter = (counter + 1) % 2 # Direwolf prints it twice, only do once + if (counter == 1): + system("echo '\nBeacon Mode toggle!!\n'") + mode = 'o' + change_mode = True + counter = 1 if ((line.find("DTMF>APDW15:t10#")) > 0): system("echo '\nBeacon Mode toggle!!\n'") mode = 'o' change_mode = True - -# if (debug_mode == False) and (change_mode == True) and (counter == 1): # skip every other APRS command since Direwolf prints them twice + +# if ((debug_mode == False) and (change_mode == True) and (counter == 1): # skip every other APRS command since Direwolf prints them twice if (debug_mode == False) and (change_mode == True): # skip every other APRS command since Direwolf prints them twice GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) @@ -261,7 +254,7 @@ if __name__ == "__main__": GPIO.output(txLed, 0) GPIO.output(powerPin, 0) - system("sudo systemctl stop rpitx") + system("sudo systemctl stop transmit") # system("sudo systemctl stop cubesatsim") print("\n/home/pi/CubeSatSim/config -" + mode) diff --git a/transmit.py b/transmit.py index 10cee57d..b9cbdbfe 100644 --- a/transmit.py +++ b/transmit.py @@ -338,6 +338,7 @@ if __name__ == "__main__": print("Can't read callsign from sim.cfg file, defaulting to AMSAT") file.close() + no_command = True try: f = open("/home/pi/CubeSatSim/command_control", "r") f.close() @@ -346,15 +347,17 @@ if __name__ == "__main__": GPIO.setup(squelch, GPIO.IN, pull_up_down=GPIO.PUD_UP) ## pull up in case pin is not connected if GPIO.input(squelch) == False: print("squelch not set correctly, no command input!") - no_command = True else: - print("command and control is activated") - no_command = False -# system("/home/pi/CubeSatSim/command &") - system("sudo systemctl start command") + if (mode != 'n') and (mode != 'x'): + print("command and control is activated") + no_command = False + system("sudo systemctl start command") + else: + print("Command and control not activated since Transmit Commands mode") + txc = True # Transmit commands only works with FM transceiver, so bypass Battery Saver if activated except: print("command and control not activated") - no_command = True + print(callsign) GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4 @@ -421,8 +424,9 @@ if __name__ == "__main__": if (mode == 'a'): print("AFSK") else: - GPIO.output(powerPin, 0) +# GPIO.output(powerPin, 0) print("Transmit APRS Commands") + system("sudo systemctl stop command") # while True: # sleep(0.1) if (mode != 'n'):