Update rpitx.py add argument a to force aprs

beta-pl-cc
Alan Johnston 1 year ago committed by GitHub
parent d6a1dbd63e
commit b089be84a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -36,12 +36,12 @@ def command_control_check():
string = filec.write(command_count_string) string = filec.write(command_count_string)
filec.close() filec.close()
except: except:
if (debug_mode == 1): if (debug_ == 1):
print("Can't write command_count file!") print("Can't write command_count file!")
print("Command_count: ") print("Command_count: ")
print(command_count) print(command_count)
increment_mode() increment_()
# if (command_tx == True): # if (command_tx == True):
# print("Turning on transmit") # print("Turning on transmit")
@ -64,27 +64,27 @@ def battery_saver_check():
f = open("/home/pi/CubeSatSim/battery_saver", "r") f = open("/home/pi/CubeSatSim/battery_saver", "r")
f.close() f.close()
txc = False txc = False
print("Safe Mode!") print("Safe !")
print("battery saver activated") print("battery saver activated")
except: except:
print("battery saver not activated") print("battery saver not activated")
# txc = True # txc = True
def increment_mode(): def increment_():
print("increment mode") print("increment ")
powerPin = 16 powerPin = 16
try: try:
file = open("/home/pi/CubeSatSim/.mode") file = open("/home/pi/CubeSatSim/.")
mode = file.read(1) = file.read(1)
except: except:
# mode = "f" # = "f"
if (debug_mode == 1): if (debug_ == 1):
print("Can't open .mode file") # , defaulting to FSK") print("Can't open . file") # , defaulting to FSK")
file.close() file.close()
print("Mode is: ") print(" is: ")
print(mode) print()
if (mode == 'a'): if ( == 'a'):
mode = 'f' = 'f'
GPIO.output(powerPin, 0) # blink two times GPIO.output(powerPin, 0) # blink two times
sleep(0.1) sleep(0.1)
GPIO.output(powerPin, 1) GPIO.output(powerPin, 1)
@ -94,8 +94,8 @@ def increment_mode():
GPIO.output(powerPin, 1) GPIO.output(powerPin, 1)
sleep(2.5) sleep(2.5)
elif (mode == 'f'): elif ( == 'f'):
mode = 'b' = 'b'
GPIO.output(powerPin, 0) # blink three times GPIO.output(powerPin, 0) # blink three times
sleep(0.1) sleep(0.1)
GPIO.output(powerPin, 1) GPIO.output(powerPin, 1)
@ -109,8 +109,8 @@ def increment_mode():
GPIO.output(powerPin, 1) GPIO.output(powerPin, 1)
sleep(2.5) sleep(2.5)
elif (mode == 'b'): elif ( == 'b'):
mode = 's' = 's'
GPIO.output(powerPin, 0) # blink four times GPIO.output(powerPin, 0) # blink four times
sleep(0.1) sleep(0.1)
GPIO.output(powerPin, 1) GPIO.output(powerPin, 1)
@ -128,8 +128,8 @@ def increment_mode():
GPIO.output(powerPin, 1) GPIO.output(powerPin, 1)
sleep(2.5) sleep(2.5)
elif (mode == 's'): elif ( == 's'):
mode = 'm' = 'm'
GPIO.output(powerPin, 0) # blink five times GPIO.output(powerPin, 0) # blink five times
sleep(0.1) sleep(0.1)
GPIO.output(powerPin, 1) GPIO.output(powerPin, 1)
@ -151,18 +151,18 @@ def increment_mode():
GPIO.output(powerPin, 1) GPIO.output(powerPin, 1)
sleep(2.5) sleep(2.5)
else: else:
mode = 'a' = 'a'
GPIO.output(powerPin, 0) # blink one time GPIO.output(powerPin, 0) # blink one time
sleep(0.1) sleep(0.1)
GPIO.output(powerPin, 1) GPIO.output(powerPin, 1)
sleep(2.5) sleep(2.5)
try: try:
file = open("/home/pi/CubeSatSim/.mode", "w") file = open("/home/pi/CubeSatSim/.", "w")
count_string = str(command_count) count_string = str(command_count)
file.write(mode) file.write()
file.close() file.close()
print(".mode file written") print(". file written")
GPIO.setwarnings(False) GPIO.setwarnings(False)
GPIO.output(txLed, 0) GPIO.output(txLed, 0)
@ -174,13 +174,13 @@ def increment_mode():
# system("reboot -h now") # system("reboot -h now")
# release = True; # release = True;
print("Changing mode now") print("Changing now")
# system("/home/pi/CubeSatSim/config -" + mode) # system("/home/pi/CubeSatSim/config -" + )
system("reboot -h now") system("reboot -h now")
sleep(10); sleep(10);
except: except:
print("can't write to .mode file") print("can't write to . file")
print("CubeSatSim v1.3.2 rpitx.py starting...") print("CubeSatSim v1.3.2 rpitx.py starting...")
@ -193,7 +193,7 @@ green = 16
command_tx = True command_tx = True
GPIO.setmode(GPIO.BCM) GPIO.set(GPIO.BCM)
GPIO.setwarnings(False) GPIO.setwarnings(False)
GPIO.setup(13, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(13, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_UP)
@ -230,7 +230,7 @@ else:
# GPIO.setup(txLed, GPIO.OUT) # GPIO.setup(txLed, GPIO.OUT)
# output(txLed, txLedOff) # output(txLed, txLedOff)
GPIO.setmode(GPIO.BCM) # Repeat to make LED work on Pi 4 GPIO.set(GPIO.BCM) # Repeat to make LED work on Pi 4
GPIO.setwarnings(False) GPIO.setwarnings(False)
GPIO.setup(txLed, GPIO.OUT) GPIO.setup(txLed, GPIO.OUT)
@ -262,21 +262,23 @@ print(txLed)
debug_mode = 0 #no debugging rpitx debug_mode = 0 #no debugging rpitx
if __name__ == "__main__": if __name__ == "__main__":
mode = "x"
if (len(sys.argv)) > 1: if (len(sys.argv)) > 1:
# print("There are arguments!") # print("There are arguments!")
if (('d' == sys.argv[1]) or ('-d' in sys.argv[1])): if (('d' == sys.argv[1]) or ('-d' in sys.argv[1])):
debug_mode = 1 debug_mode = 1
else if (('a' == sys.argv[1]) or ('-a' in sys.argv[1])):
mode = "a"
print(transmit) print(transmit)
try: if ( mode == "x"):
file = open("/home/pi/CubeSatSim/.mode") try:
mode = file.read(1) file = open("/home/pi/CubeSatSim/.mode")
except: mode = file.read(1)
mode = "f" except:
if (debug_mode == 1): mode = "f"
print("Can't open .mode file, defaulting to FSK") if (debug_mode == 1):
print("Can't open .mode file, defaulting to FSK")
print("Mode is: ") print("Mode is: ")
print(mode) print(mode)

Loading…
Cancel
Save

Powered by TurnKey Linux.