From bc45f23e44c860e3f8ef4d2ff3b95fdadab44361 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 25 Feb 2024 17:42:18 -0500 Subject: [PATCH] Update rpitx.py define command_control_check --- rpitx.py | 81 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 46 insertions(+), 35 deletions(-) diff --git a/rpitx.py b/rpitx.py index 2850aced..df264df1 100644 --- a/rpitx.py +++ b/rpitx.py @@ -11,6 +11,51 @@ from os import system from PIL import Image, ImageDraw, ImageFont, ImageColor import serial +def command_control_check(): + + global command_control + global no_command + global debug_mode + global command_count + + output(pd, 1) + output(ptt, 1) + sleep(1) + if (no_command == False and GPIO.input(squelch) == False): + print("carrier received!") + # command_tx = not command_tx +# print(command_tx) + + try: + command_count += 1 + filec = open("/home/pi/CubeSatSim/command_count.txt", "w") + command_count_string = str(command_count) + print(command_count_string) + string = filec.write(command_count_string) + filec.close() + except: + if (debug_mode == 1): + print("Can't write command_count file!") + print("Command_count: ") + print(command_count) + + increment_mode() + +# if (command_tx == True): +# print("Turning on transmit") +# system("echo > command_tx True") +# output(txLed, txLedOn) +# sleep(0.5) +# output(txLed, txLedff) +# else: +# print("Turning off transmit") +# system("echo > command_tx False") + else: + print("No carrier received!") + output(pd, 0) +# sleep(1) + + def battery_saver_check(): try: global txc @@ -430,41 +475,7 @@ if __name__ == "__main__": sleep(0.5) except: - output(pd, 1) - output(ptt, 1) - sleep(1) - if (no_command == False and GPIO.input(squelch) == False): - print("carrier received!") - # command_tx = not command_tx - print(command_tx) - - try: - command_count += 1 - filec = open("/home/pi/CubeSatSim/command_count.txt", "w") - command_count_string = str(command_count) - print(command_count_string) - string = filec.write(command_count_string) - filec.close() - except: - if (debug_mode == 1): - print("Can't write command_count file!") - print("Command_count: ") - print(command_count) - - increment_mode() - - if (command_tx == True): - print("Turning on transmit") - system("echo > command_tx True") -# output(txLed, txLedOn) -# sleep(0.5) -# output(txLed, txLedff) - else: - print("Turning off transmit") - system("echo > command_tx False") - else: - print("No carrier received!") - output(pd, 0) + command_control_check() sleep(1) elif (mode == 'm'): print("CW")