From 6f3fb62fecd470d4b745a0f6df3f36b9e4407f6b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 13 Aug 2023 08:53:29 -0400 Subject: [PATCH] Update rpitx.py to read and write command_count.txt --- rpitx.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index 4d684d20..f9f3ef4c 100644 --- a/rpitx.py +++ b/rpitx.py @@ -119,6 +119,17 @@ if __name__ == "__main__": print("Command_tx: ") print(command_tx) + try: + file = open("/home/pi/CubeSatSim/command_count.txt") + string = file.read + command_count = int(string) + except: + command_count = 0 + if (debug_mode == 1): + print("Can't open command_count file, setting to 0") + print("Command_count: ") + print(command_count) + try: file = open("/home/pi/CubeSatSim/sim.cfg") callsign = file.readline().split(" ")[0] @@ -563,7 +574,17 @@ if __name__ == "__main__": print("carrier received!") command_tx = not command_tx print(command_tx) - + + try: + command_count += 1 + file = open("/home/pi/CubeSatSim/command_count.txt", "w") + string = file.write(str(command_count)) + except: + if (debug_mode == 1): + print("Can't write command_count file") + print("Command_count: ") + print(command_count) + output(green, txLedOff) sleep(0.03) output(green, txLedOn)