no reboot on mode change

pull/327/head
Alan Johnston 1 year ago
parent 4f65e60711
commit 0629681b88

@ -365,7 +365,11 @@ elif [ "$1" = "-a" ]; then
echo "changing CubeSatSim to AFSK mode" echo "changing CubeSatSim to AFSK mode"
sudo echo "a" > /home/pi/CubeSatSim/.mode sudo echo "a" > /home/pi/CubeSatSim/.mode
reboot=1 if [ "$1" == "f" ] || [ "$1" == "b" ] ; then
reboot=1
else
restart=1
fi
fi fi
elif [ "$1" = "-m" ]; then elif [ "$1" = "-m" ]; then
@ -382,7 +386,11 @@ elif [ "$1" = "-m" ]; then
echo "changing CubeSatSim to CW mode" echo "changing CubeSatSim to CW mode"
sudo echo "m" > /home/pi/CubeSatSim/.mode sudo echo "m" > /home/pi/CubeSatSim/.mode
reboot=1 if [ "$1" == "f" ] || [ "$1" == "b" ] ; then
reboot=1
else
restart=1
fi
fi fi
elif [ "$1" = "-f" ]; then elif [ "$1" = "-f" ]; then
@ -399,7 +407,7 @@ elif [ "$1" = "-f" ]; then
echo "changing CubeSatSim to FSK mode" echo "changing CubeSatSim to FSK mode"
sudo echo "f" > /home/pi/CubeSatSim/.mode sudo echo "f" > /home/pi/CubeSatSim/.mode
reboot=1 restart=1
fi fi
elif [ "$1" = "-b" ]; then elif [ "$1" = "-b" ]; then
@ -416,7 +424,7 @@ elif [ "$1" = "-b" ]; then
echo "changing CubeSatSim to BPSK mode" echo "changing CubeSatSim to BPSK mode"
sudo echo "b" > /home/pi/CubeSatSim/.mode sudo echo "b" > /home/pi/CubeSatSim/.mode
reboot=1 restart=1
fi fi
elif [ "$1" = "-s" ]; then elif [ "$1" = "-s" ]; then
@ -433,7 +441,11 @@ elif [ "$1" = "-s" ]; then
echo "changing CubeSatSim to SSTV mode" echo "changing CubeSatSim to SSTV mode"
sudo echo "s" > /home/pi/CubeSatSim/.mode sudo echo "s" > /home/pi/CubeSatSim/.mode
reboot=1 if [ "$1" == "f" ] || [ "$1" == "b" ] ; then
reboot=1
else
restart=1
fi
fi fi
elif [ "$1" = "-t" ]; then elif [ "$1" = "-t" ]; then
@ -1130,8 +1142,8 @@ elif [ "$1" = "-o" ]; then
if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then if [ "$reset" = "y" ] || [ "$reset" = "yes" ] ; then
echo "Turn beacon telemetry ON" echo "Turn beacon telemetry ON"
sudo rm /home/pi/CubeSatSim/beacon_off > /dev/null 2>&1 sudo rm /home/pi/CubeSatSim/beacon_off > /dev/null 2>&1
sudo systemctl stop rpitx sudo systemctl restart rpitx
sudo python3 -u /home/pi/CubeSatSim/rpitx.py s & > /dev/null 2>&1 # sudo python3 -u /home/pi/CubeSatSim/rpitx.py s & > /dev/null 2>&1
# restart=1 # restart=1
fi fi
@ -1365,6 +1377,8 @@ fi
# echo $noreboot # echo $noreboot
#reboot=0
#restart=1
if [ "$reboot" = "1" ] ; then if [ "$reboot" = "1" ] ; then
if [ "$noreboot" = "0" ] ; then if [ "$noreboot" = "0" ] ; then
@ -1380,6 +1394,7 @@ fi
if [ "$restart" = "1" ] ; then if [ "$restart" = "1" ] ; then
if [ "$reboot" = "0" ] ; then if [ "$reboot" = "0" ] ; then
echo "Restarting" echo "Restarting"
sudo systemctl stop rpitx
sudo systemctl restart cubesatsim sudo systemctl restart cubesatsim
else else
echo "Restart needed for changes to take effect" echo "Restart needed for changes to take effect"

@ -262,8 +262,9 @@ print(txLed)
debug_mode = 0 #no debugging rpitx debug_mode = 0 #no debugging rpitx
skip = False
if __name__ == "__main__": if __name__ == "__main__":
skip = False
mode = "y" mode = "y"
if (len(sys.argv)) > 1: if (len(sys.argv)) > 1:
# print("There are arguments!") # print("There are arguments!")
@ -277,6 +278,24 @@ if __name__ == "__main__":
print("Skipping delay and CW ID") print("Skipping delay and CW ID")
print(transmit) 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"): if ( mode == "y"):
try: try:
file = open("/home/pi/CubeSatSim/.mode") file = open("/home/pi/CubeSatSim/.mode")
@ -408,8 +427,8 @@ if __name__ == "__main__":
print("Error in serial write") print("Error in serial write")
output(pd, 0) output(pd, 0)
if (mode != 'x') and (skip == False): # if (mode != 'x') and (skip == False):
sleep(10) # delay so cubesatsim code catches up # 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") 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") print("Transmit APRS Commands")
# while True: # while True:
# sleep(0.1) # sleep(0.1)
system("touch /home/pi/CubeSatSim/ready")
while True: while True:
try: try:
f = open("/home/pi/CubeSatSim/ready") f = open("/home/pi/CubeSatSim/ready")
@ -506,6 +527,7 @@ if __name__ == "__main__":
command_control_check() command_control_check()
sleep(1) sleep(1)
elif (mode == 'm'): elif (mode == 'm'):
system("touch /home/pi/CubeSatSim/cwready")
print("CW") print("CW")
while True: while True:
command_control_check() command_control_check()

Loading…
Cancel
Save

Powered by TurnKey Linux.