From 0629681b88f5469cd35ed1f32791188a5bac640d Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 18 Jul 2024 09:43:42 -0400 Subject: [PATCH] no reboot on mode change --- config | 29 ++++++++++++++++++++++------- rpitx.py | 28 +++++++++++++++++++++++++--- 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/config b/config index 440d28e0..76706eae 100755 --- a/config +++ b/config @@ -365,7 +365,11 @@ elif [ "$1" = "-a" ]; then echo "changing CubeSatSim to AFSK mode" sudo echo "a" > /home/pi/CubeSatSim/.mode - reboot=1 + if [ "$1" == "f" ] || [ "$1" == "b" ] ; then + reboot=1 + else + restart=1 + fi fi elif [ "$1" = "-m" ]; then @@ -382,7 +386,11 @@ elif [ "$1" = "-m" ]; then echo "changing CubeSatSim to CW mode" sudo echo "m" > /home/pi/CubeSatSim/.mode - reboot=1 + if [ "$1" == "f" ] || [ "$1" == "b" ] ; then + reboot=1 + else + restart=1 + fi fi elif [ "$1" = "-f" ]; then @@ -399,7 +407,7 @@ elif [ "$1" = "-f" ]; then echo "changing CubeSatSim to FSK mode" sudo echo "f" > /home/pi/CubeSatSim/.mode - reboot=1 + restart=1 fi elif [ "$1" = "-b" ]; then @@ -416,7 +424,7 @@ elif [ "$1" = "-b" ]; then echo "changing CubeSatSim to BPSK mode" sudo echo "b" > /home/pi/CubeSatSim/.mode - reboot=1 + restart=1 fi elif [ "$1" = "-s" ]; then @@ -433,7 +441,11 @@ elif [ "$1" = "-s" ]; then echo "changing CubeSatSim to SSTV mode" sudo echo "s" > /home/pi/CubeSatSim/.mode - reboot=1 + if [ "$1" == "f" ] || [ "$1" == "b" ] ; then + reboot=1 + else + restart=1 + fi fi elif [ "$1" = "-t" ]; then @@ -1130,8 +1142,8 @@ elif [ "$1" = "-o" ]; then if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then echo "Turn beacon telemetry ON" sudo rm /home/pi/CubeSatSim/beacon_off > /dev/null 2>&1 - sudo systemctl stop rpitx - sudo python3 -u /home/pi/CubeSatSim/rpitx.py s & > /dev/null 2>&1 + sudo systemctl restart rpitx + # sudo python3 -u /home/pi/CubeSatSim/rpitx.py s & > /dev/null 2>&1 # restart=1 fi @@ -1365,6 +1377,8 @@ fi # echo $noreboot +#reboot=0 +#restart=1 if [ "$reboot" = "1" ] ; then if [ "$noreboot" = "0" ] ; then @@ -1380,6 +1394,7 @@ fi if [ "$restart" = "1" ] ; then if [ "$reboot" = "0" ] ; then echo "Restarting" + sudo systemctl stop rpitx sudo systemctl restart cubesatsim else echo "Restart needed for changes to take effect" diff --git a/rpitx.py b/rpitx.py index 80a3243a..a85f92bc 100644 --- a/rpitx.py +++ b/rpitx.py @@ -262,8 +262,9 @@ print(txLed) debug_mode = 0 #no debugging rpitx +skip = False + if __name__ == "__main__": - skip = False mode = "y" if (len(sys.argv)) > 1: # print("There are arguments!") @@ -277,6 +278,24 @@ if __name__ == "__main__": print("Skipping delay and CW ID") print(transmit) + + + try: + system("cat /proc/uptime > /home/pi/CubeSatSim/uptime") + file = open("/home/pi/CubeSatSim/uptime") + up = file.read().split(" ")[0] +# print(up) + uptime = float(up) +# print(uptime) + if (uptime < 30): + print("Uptime < 30 seconds") + else: + print("Uptime > 30 seconds") + skip = True + file.close() + except: + print("Can't open /proc/uptime") + if ( mode == "y"): try: file = open("/home/pi/CubeSatSim/.mode") @@ -408,8 +427,8 @@ if __name__ == "__main__": print("Error in serial write") output(pd, 0) - if (mode != 'x') and (skip == False): - sleep(10) # delay so cubesatsim code catches up +# if (mode != 'x') and (skip == False): +# sleep(10) # delay so cubesatsim code catches up system("echo 'hi hi de " + callsign + "' > id.txt && gen_packets -M 20 /home/pi/CubeSatSim/id.txt -o /home/pi/CubeSatSim/morse.wav -r 48000 > /dev/null 2>&1") @@ -460,6 +479,8 @@ if __name__ == "__main__": print("Transmit APRS Commands") # while True: # sleep(0.1) + system("touch /home/pi/CubeSatSim/ready") + while True: try: f = open("/home/pi/CubeSatSim/ready") @@ -506,6 +527,7 @@ if __name__ == "__main__": command_control_check() sleep(1) elif (mode == 'm'): + system("touch /home/pi/CubeSatSim/cwready") print("CW") while True: command_control_check()