From bc6a7fa2e4ec959475377740b5dab39db50054e0 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 23 Jul 2024 14:17:30 -0400 Subject: [PATCH 01/12] Update main.c no LED control --- main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/main.c b/main.c index 9e6f1cb9..a985195d 100644 --- a/main.c +++ b/main.c @@ -340,15 +340,15 @@ int main(int argc, char * argv[]) { } } } - pinMode(txLed, OUTPUT); - digitalWrite(txLed, txLedOff); +// pinMode(txLed, OUTPUT); +// digitalWrite(txLed, txLedOff); #ifdef DEBUG_LOGGING - printf("Tx LED Off\n"); +// printf("Tx LED Off\n"); #endif - pinMode(onLed, OUTPUT); - digitalWrite(onLed, onLedOn); +// pinMode(onLed, OUTPUT); +// digitalWrite(onLed, onLedOn); #ifdef DEBUG_LOGGING - printf("Power LED On\n"); +// printf("Power LED On\n"); #endif /* if (mode == SSTV) { From 15ce3cf700ebbf7ec98a2e718c7744e5bfc60971 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 23 Jul 2024 14:25:56 -0400 Subject: [PATCH 02/12] Update update add disable rpitx --- update | 2 ++ 1 file changed, 2 insertions(+) diff --git a/update b/update index 304bd83a..cc357886 100755 --- a/update +++ b/update @@ -66,6 +66,8 @@ else echo "no changes to cubesatsim.service." fi +sudo systemctl disable rpitx + if [[ $(diff systemd/rpitx.service /etc/systemd/system/rpitx.service) ]]; then echo "changed rpitx.service." sudo cp /home/pi/CubeSatSim/systemd/rpitx.service /etc/systemd/system/rpitx.service From 5cbfbfc5fd26565090c4f955d4ca9179f8f86524 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 23 Jul 2024 14:29:55 -0400 Subject: [PATCH 03/12] Update config restart CubeSatSim then rpitx --- config | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config b/config index b90679c2..c069e397 100755 --- a/config +++ b/config @@ -1431,8 +1431,9 @@ fi if [ "$restart" = "1" ] ; then if [ "$reboot" = "0" ] ; then echo "Restarting" - sudo systemctl stop rpitx +# sudo systemctl stop rpitx sudo systemctl restart cubesatsim + sudo systemctl restart rpitx else echo "Restart needed for changes to take effect" fi From 6507729e2a7158fc89513f22c8e4b91fdb2953f4 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 23 Jul 2024 14:33:49 -0400 Subject: [PATCH 04/12] Update config back to stop rpitx restart cubesatsim --- config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config b/config index c069e397..e8124b5f 100755 --- a/config +++ b/config @@ -1431,9 +1431,9 @@ fi if [ "$restart" = "1" ] ; then if [ "$reboot" = "0" ] ; then echo "Restarting" -# sudo systemctl stop rpitx + sudo systemctl stop rpitx sudo systemctl restart cubesatsim - sudo systemctl restart rpitx +# sudo systemctl restart rpitx else echo "Restart needed for changes to take effect" fi From 345dfd6c05f8b2c351b47c6659ed5525f4e086d0 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 23 Jul 2024 14:34:25 -0400 Subject: [PATCH 05/12] Update main.c start rpitx --- main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index a985195d..5f3c8062 100644 --- a/main.c +++ b/main.c @@ -124,7 +124,8 @@ int main(int argc, char * argv[]) { } // FILE * rpitx_stop = popen("sudo systemctl stop rpitx", "r"); - FILE * rpitx_stop = popen("sudo systemctl restart rpitx", "r"); +// FILE * rpitx_stop = popen("sudo systemctl restart rpitx", "r"); + FILE * rpitx_stop = popen("sudo systemctl start rpitx", "r"); pclose(rpitx_stop); // FILE * cc_start = popen("/home/pi/CubeSatSim/command &", "r"); From f8cd4c4c5c9487ca0c2ade1af42f5c53c0a4c435 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 23 Jul 2024 14:41:01 -0400 Subject: [PATCH 06/12] Update main.c only start rpitx at start --- main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 5f3c8062..8544fb86 100644 --- a/main.c +++ b/main.c @@ -45,6 +45,8 @@ int main(int argc, char * argv[]) { fprintf(stderr, "Pi Zero 2 detected\n"); pi_zero_2_offset = 500; if (uptime_sec < 30.0) { + FILE * rpitx_stop = popen("sudo systemctl start rpitx", "r"); + pclose(rpitx_stop); fprintf(stderr, "Sleep 5 sec"); sleep(5); // try sleep at start to help boot } @@ -63,6 +65,8 @@ int main(int argc, char * argv[]) { } } if (uptime_sec < 30.0) { + FILE * rpitx_stop = popen("sudo systemctl start rpitx", "r"); + pclose(rpitx_stop); fprintf(stderr,"Sleep 10 sec"); sleep(10); } @@ -125,8 +129,7 @@ int main(int argc, char * argv[]) { // FILE * rpitx_stop = popen("sudo systemctl stop rpitx", "r"); // FILE * rpitx_stop = popen("sudo systemctl restart rpitx", "r"); - FILE * rpitx_stop = popen("sudo systemctl start rpitx", "r"); - pclose(rpitx_stop); + // FILE * cc_start = popen("/home/pi/CubeSatSim/command &", "r"); // pclose(cc_start); From 4b0ba7d66421bf2317fd15f6f2cf279c6c63238a Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 23 Jul 2024 14:41:53 -0400 Subject: [PATCH 07/12] Update config restart cubesatsim and rpitx --- config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config b/config index e8124b5f..c069e397 100755 --- a/config +++ b/config @@ -1431,9 +1431,9 @@ fi if [ "$restart" = "1" ] ; then if [ "$reboot" = "0" ] ; then echo "Restarting" - sudo systemctl stop rpitx +# sudo systemctl stop rpitx sudo systemctl restart cubesatsim -# sudo systemctl restart rpitx + sudo systemctl restart rpitx else echo "Restart needed for changes to take effect" fi From e579f76f8c3e9b8e00d6450880a7035d1b2ffce1 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 25 Jul 2024 10:40:52 -0400 Subject: [PATCH 08/12] Update rpitx.py adde extra GPIO for -b and -f --- rpitx.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rpitx.py b/rpitx.py index b20daee6..06ec932d 100644 --- a/rpitx.py +++ b/rpitx.py @@ -800,6 +800,8 @@ if __name__ == "__main__": # command_control_check() if (command_tx == True): + GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4 + GPIO.setup(txLed, GPIO.OUT) output(txLed, txLedOn) print(txLed) print(txLedOn) @@ -849,6 +851,8 @@ if __name__ == "__main__": # output(txLed, txLedOff) # command_control_check() if (command_tx == True): + GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4 + GPIO.setup(txLed, GPIO.OUT) output(txLed, txLedOn) print(txLed) print(txLedOn) From ac84af869e573e41a7a96c9c8ee9c4185a9856b4 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 25 Jul 2024 10:54:22 -0400 Subject: [PATCH 09/12] Update rpitx.py add extra GPIO everywhere, remove command_control_check --- rpitx.py | 103 ++++++++++++++++++++----------------------------------- 1 file changed, 38 insertions(+), 65 deletions(-) diff --git a/rpitx.py b/rpitx.py index 06ec932d..39659d6b 100644 --- a/rpitx.py +++ b/rpitx.py @@ -9,54 +9,7 @@ from time import sleep import sys 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 - - return - - 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) - +import serial def battery_saver_check(): try: @@ -435,12 +388,14 @@ if __name__ == "__main__": 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") - command_control_check() +# command_control_check() # if (mode != ) and (command_tx == True): # if (command_tx == True): if ((mode == 'a') or (mode == 'b') or (mode == 'f') or (mode == 's')) and (command_tx == True) and (skip == False): # battery_saver_mode + GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 + GPIO.setup(txLed, GPIO.OUT) output(txLed, txLedOn) # if (txc): # output(pd, 1) @@ -472,7 +427,7 @@ if __name__ == "__main__": # if (len(sys.argv)) > 1: # print("There are arguments!") if (mode == 'a') or (mode == 'x') or (mode == 'n'): - command_control_check() +# command_control_check() output(pd, 1) output(ptt, 1) if (mode == 'a'): @@ -493,6 +448,8 @@ if __name__ == "__main__": system("gen_packets -o /home/pi/CubeSatSim/telem.wav /home/pi/CubeSatSim/t.txt -r 48000 > /dev/null 2>&1") system("cat /home/pi/CubeSatSim/t.txt") if (command_tx == True): + GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 + GPIO.setup(txLed, GPIO.OUT) output(txLed, txLedOn) # output(pd, 1) # output (ptt, 0) @@ -527,13 +484,13 @@ if __name__ == "__main__": sleep(0.5) except: - command_control_check() +# command_control_check() sleep(1) elif (mode == 'm'): system("touch /home/pi/CubeSatSim/cwready") print("CW") while True: - command_control_check() +# command_control_check() output (pd, 1) output (ptt, 1) try: @@ -547,6 +504,8 @@ if __name__ == "__main__": system(command) ## chan = chan + 1 if (command_tx == True): + GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 + GPIO.setup(txLed, GPIO.OUT) output(txLed, txLedOn) if (txc): @@ -564,7 +523,7 @@ if __name__ == "__main__": system("cat /home/pi/CubeSatSim/morse.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f " + tx + "e3 > /dev/null 2>&1") output(txLed, txLedOff) - command_control_check() +# command_control_check() sleep(2) f.close() sleep(10) @@ -573,7 +532,7 @@ if __name__ == "__main__": sleep(1) elif (mode == 's'): print("SSTV") - command_control_check() +# command_control_check() output (ptt, 1) output(pd, 1) try: @@ -601,10 +560,12 @@ if __name__ == "__main__": file = open("/home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg") print("First SSTV stored image detected") system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg") - command_control_check() +# command_control_check() if (command_tx == True): print ("Sending SSTV image") + GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 + GPIO.setup(txLed, GPIO.OUT) output(txLed, txLedOn) # battery_saver_check() @@ -626,7 +587,7 @@ if __name__ == "__main__": except: print("image 2 did not load - copy from CubeSatSim/sstv directory") while 1: - command_control_check() +# command_control_check() system("raspistill -o /home/pi/CubeSatSim/camera_out.jpg -w 320 -h 256") # > /dev/null 2>&1") print("Photo taken") @@ -654,16 +615,18 @@ if __name__ == "__main__": draw.text((120, 10), telem_string, font=font2, fill='white') img.save(file) - command_control_check() +# command_control_check() system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/CubeSatSim/camera_out.jpg") system("sudo rm /home/pi/CubeSatSim/camera_out.jpg > /dev/null 2>&1") - command_control_check() +# command_control_check() if (command_tx == True): print ("Sending SSTV image") output(txLed, txLedOn) + GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 + GPIO.setup(txLed, GPIO.OUT) # battery_saver_check() if (txc): @@ -686,17 +649,19 @@ if __name__ == "__main__": sleep(10) else: try: - command_control_check() + # command_control_check() file = open("/home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg") print("First SSTV stored image detected") system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg") - command_control_check() +# command_control_check() if (command_tx == True): print ("Sending SSTV image") + GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 + GPIO.setup(txLed, GPIO.OUT) output(txLed, txLedOn) # battery_saver_check() @@ -720,7 +685,7 @@ if __name__ == "__main__": except: print("image 1 did not load - copy from CubeSatSim/sstv directory") try: - command_control_check() +# command_control_check() file = open("/home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg") print("Second SSTV stored image detected") @@ -728,10 +693,12 @@ if __name__ == "__main__": while 1: - command_control_check() +# command_control_check() if (command_tx == True): print ("Sending SSTV image") + GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 + GPIO.setup(txLed, GPIO.OUT) output(txLed, txLedOn) # battery_saver_check() @@ -758,8 +725,12 @@ if __name__ == "__main__": system("(while true; do (sleep 10 && cat /home/pi/CubeSatSim/wav/sstv.wav); done) | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3 &") while 1: if (command_tx == True): - command_control_check() +# command_control_check() + output(txLed, txLedOn) + GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 + GPIO.setup(txLed, GPIO.OUT) + # battery_saver_check() if (txc): @@ -800,7 +771,7 @@ if __name__ == "__main__": # command_control_check() if (command_tx == True): - GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4 + GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 GPIO.setup(txLed, GPIO.OUT) output(txLed, txLedOn) print(txLed) @@ -818,6 +789,8 @@ if __name__ == "__main__": sleep(0.5) if (GPIO.input(squelch) == False): print("Carrier detected, starting repeater") + GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 + GPIO.setup(txLed, GPIO.OUT) output(txLed, txLedOn) # system("arecord -D hw:CARD=Device,DEV=0 | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3 &") system("arecord -D hw:CARD=Device,DEV=0 -f S16_LE -r 48000 -c 1 | csdr convert_s16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3 &") @@ -851,7 +824,7 @@ if __name__ == "__main__": # output(txLed, txLedOff) # command_control_check() if (command_tx == True): - GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4 + GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 GPIO.setup(txLed, GPIO.OUT) output(txLed, txLedOn) print(txLed) From 038cf1abfc6417d6350f6881b8414be6339aa8ce Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 25 Jul 2024 10:59:53 -0400 Subject: [PATCH 10/12] Update config reboot after mode -e --- config | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config b/config index c069e397..062cc0b8 100755 --- a/config +++ b/config @@ -366,7 +366,7 @@ elif [ "$1" = "-a" ]; then echo "changing CubeSatSim to AFSK mode" sudo echo "a" > /home/pi/CubeSatSim/.mode - if [ "$1" == "f" ] || [ "$1" == "b" ] ; then + if [ "$1" == "f" ] || [ "$1" == "b" ] || [ "$1" == "e" ] ; then FILE=/home/pi/CubeSatSim/battery_saver if [ -f "$FILE" ]; then restart=1 @@ -392,7 +392,7 @@ elif [ "$1" = "-m" ]; then echo "changing CubeSatSim to CW mode" sudo echo "m" > /home/pi/CubeSatSim/.mode - if [ "$1" == "f" ] || [ "$1" == "b" ] ; then + if [ "$1" == "f" ] || [ "$1" == "b" ] || [ "$1" == "e" ] ; then FILE=/home/pi/CubeSatSim/battery_saver if [ -f "$FILE" ]; then restart=1 @@ -452,7 +452,7 @@ elif [ "$1" = "-s" ]; then echo "changing CubeSatSim to SSTV mode" sudo echo "s" > /home/pi/CubeSatSim/.mode - if [ "$1" == "f" ] || [ "$1" == "b" ] ; then + if [ "$1" == "f" ] || [ "$1" == "b" ] || [ "$1" == "e" ] ; then FILE=/home/pi/CubeSatSim/battery_saver if [ -f "$FILE" ]; then From cc5ff2541c012f657143448c7a81c12e69920ebc Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 25 Jul 2024 11:17:48 -0400 Subject: [PATCH 11/12] Update rpitx.py fix sstv GPIO --- rpitx.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rpitx.py b/rpitx.py index 39659d6b..27c8e617 100644 --- a/rpitx.py +++ b/rpitx.py @@ -624,9 +624,9 @@ if __name__ == "__main__": if (command_tx == True): print ("Sending SSTV image") - output(txLed, txLedOn) GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 GPIO.setup(txLed, GPIO.OUT) + output(txLed, txLedOn) # battery_saver_check() if (txc): @@ -727,9 +727,9 @@ if __name__ == "__main__": if (command_tx == True): # command_control_check() - output(txLed, txLedOn) GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 GPIO.setup(txLed, GPIO.OUT) + output(txLed, txLedOn) # battery_saver_check() From 704a8e840ab5d76419d157ffcf99e031cebf3c65 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 25 Jul 2024 11:30:50 -0400 Subject: [PATCH 12/12] Update rpitx.py don't immediately transmit APRS in -n --- rpitx.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index 27c8e617..39300e4d 100644 --- a/rpitx.py +++ b/rpitx.py @@ -437,7 +437,8 @@ if __name__ == "__main__": print("Transmit APRS Commands") # while True: # sleep(0.1) - system("touch /home/pi/CubeSatSim/ready") + if (mode != 'n'): + system("touch /home/pi/CubeSatSim/ready") while True: try: