From cdfb979bc87b5b3e2ad727fe8930c1f5638b23c8 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 29 Feb 2024 09:49:08 -0500 Subject: [PATCH 01/61] Update config only unknown if wrong option entered --- config | 61 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/config b/config index 7f603977..cea2d70e 100755 --- a/config +++ b/config @@ -86,10 +86,10 @@ if [ "$1" = "" ]; then echo "To see options, type config -h" # echo # set -- "-h" -fi +# fi -if [ "$1" = "-i" ]; then +elif [ "$1" = "-i" ]; then echo "Rebooting CubeSatSim" sudo reboot now # sudo systemctl restart cubesatsim @@ -165,34 +165,6 @@ elif [ "$1" = "-s" ]; then sudo reboot now # sudo systemctl restart cubesatsim exit -elif [ "$1" = "-h" ]; then - echo "config OPTION" - echo - echo "Changes CubeSatSim mode, resets, or modifies configuration file" - echo - echo " -h This help info" - echo " -a Change to AFSK/APRS mode" - echo " -m Change to CW mode" - echo " -f Change to FSK/DUV mode" - echo " -b Change to BPSK mode" - echo " -s Change to SSTV mode" - echo " -i Reboots CubeSatsim software" - echo " -c Change the CALLSIGN in the configuration file sim.cfg" - echo " -t Change the Simulated Telemetry setting in sim.cfg" - echo " -r Change the Resets Count in the configuration file sim.cfg" - echo " -l Change the Latitude and Longitude in the configuration file sim.cfg" - echo " -S Scan both I2C buses on the Raspberry Pi" - echo " -C Clear logs" - echo " -T Change command and control state" - echo " -R Change the Commands Count in the file command_count.txt" - echo " -B Change battery saver mode manually" - echo " -q Change the Squelch setting for command receiver" - echo " -F Change the rx and tx frequency" - echo " -H Chnage the Balloon mode" - echo " -p Display payload sensor data" - echo " -v Display voltage and current data" - echo - exit elif [ "$1" = "-t" ]; then @@ -712,6 +684,35 @@ elif [ "$1" = "-v" ]; then echo /home/pi/CubeSatSim/telem +elif [ "$1" = "-h" ]; then + echo "config OPTION" + echo + echo "Changes CubeSatSim mode, resets, or modifies configuration file" + echo + echo " -h This help info" + echo " -a Change to AFSK/APRS mode" + echo " -m Change to CW mode" + echo " -f Change to FSK/DUV mode" + echo " -b Change to BPSK mode" + echo " -s Change to SSTV mode" + echo " -i Reboots CubeSatsim software" + echo " -c Change the CALLSIGN in the configuration file sim.cfg" + echo " -t Change the Simulated Telemetry setting in sim.cfg" + echo " -r Change the Resets Count in the configuration file sim.cfg" + echo " -l Change the Latitude and Longitude in the configuration file sim.cfg" + echo " -S Scan both I2C buses on the Raspberry Pi" + echo " -C Clear logs" + echo " -T Change command and control state" + echo " -R Change the Commands Count in the file command_count.txt" + echo " -B Change battery saver mode manually" + echo " -q Change the Squelch setting for command receiver" + echo " -F Change the rx and tx frequency" + echo " -H Chnage the Balloon mode" + echo " -p Display payload sensor data" + echo " -v Display voltage and current data" + echo + exit + else echo echo "Unknown option. Try config -h for a list of supported options." From 39471a2ff584fdfecc436c5bf2ea4df3bba70033 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 29 Feb 2024 09:50:21 -0500 Subject: [PATCH 02/61] Update config no extra line --- config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config b/config index cea2d70e..9d3a6feb 100755 --- a/config +++ b/config @@ -714,7 +714,7 @@ elif [ "$1" = "-h" ]; then exit else - echo +# echo echo "Unknown option. Try config -h for a list of supported options." echo From 98b6136155e6aa253529faaf83bbffb5842d6dff Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 29 Feb 2024 10:07:18 -0500 Subject: [PATCH 03/61] Update main.c start changes for CW --- main.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index 3a39deed..2846dc73 100644 --- a/main.c +++ b/main.c @@ -1117,7 +1117,7 @@ void get_tlm(void) { char header_str2b[30]; // for APRS coordinates char header_lat[10]; char header_long[10]; - char header_str4[] = "hi hi "; + char header_str4[] = "hi hi de "; // char footer_str1[] = "\' > t.txt && echo \'"; char footer_str1[] = "\' > t.txt"; // char footer_str[] = "-11>APCSS:010101/hi hi ' >> t.txt && touch /home/pi/CubeSatSim/ready"; // transmit is done by rpitx.py @@ -1159,8 +1159,10 @@ void get_tlm(void) { printf("\n\nString is %s \n\n", header_str2b); strcat(str, header_str2b); - } else { + } else { // CW mode strcat(str, header_str4); + strcat(str, call); + } // } printf("Str: %s \n", str); @@ -1247,9 +1249,9 @@ void get_tlm(void) { } if (mode == CW) { - char cw_str2[1000]; - char cw_header2[] = "echo '"; - char cw_footer2[] = "' > id.txt && gen_packets -M 20 id.txt -o morse.wav -r 48000 > /dev/null 2>&1 && cat morse.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.897e3"; +// char cw_str2[1000]; +// char cw_header2[] = "echo '"; +// char cw_footer2[] = "' > id.txt && gen_packets -M 20 id.txt -o morse.wav -r 48000 > /dev/null 2>&1 && cat morse.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.897e3"; char cw_footer3[] = "' > cw.txt && touch /home/pi/CubeSatSim/cwready"; // transmit is done by rpitx.py // printf("Str str: %s \n", str); From f9f142dad36ce4083cb636478138ea04e1444521 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 10:19:54 -0500 Subject: [PATCH 04/61] Update main.c add cw0.txt to cw6.txt --- main.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index 2846dc73..4c165c51 100644 --- a/main.c +++ b/main.c @@ -1122,7 +1122,7 @@ void get_tlm(void) { char footer_str1[] = "\' > t.txt"; // char footer_str[] = "-11>APCSS:010101/hi hi ' >> t.txt && touch /home/pi/CubeSatSim/ready"; // transmit is done by rpitx.py char footer_str[] = " && echo 'AMSAT-11>APCSS:010101/hi hi ' >> t.txt && touch /home/pi/CubeSatSim/ready"; // transmit is done by rpitx.py - char footer_str2[] = " && touch /home/pi/CubeSatSim/ready"; + char footer_str2[] = " && touch /home/pi/CubeSatSim/ready"; if (ax5043) { strcpy(str, header_str); @@ -1161,7 +1161,11 @@ void get_tlm(void) { strcat(str, header_str2b); } else { // CW mode strcat(str, header_str4); - strcat(str, call); + strcat(str, call); + + sprintf(tlm_str, "%s' > cw0.txt", &str); + FILE * cw_file = popen(tlm_str, "r"); + pclose(cw_file); } // } @@ -1169,11 +1173,11 @@ void get_tlm(void) { if (mode == CW) { int channel; for (channel = 1; channel < 7; channel++) { - sprintf(tlm_str, "%d%d%d %d%d%d %d%d%d %d%d%d ", + sprintf(tlm_str, "echo '%d%d%d %d%d%d %d%d%d %d%d%d' > cw%1d.txt", channel, upper_digit(tlm[channel][1]), lower_digit(tlm[channel][1]), channel, upper_digit(tlm[channel][2]), lower_digit(tlm[channel][2]), channel, upper_digit(tlm[channel][3]), lower_digit(tlm[channel][3]), - channel, upper_digit(tlm[channel][4]), lower_digit(tlm[channel][4])); + channel, upper_digit(tlm[channel][4]), lower_digit(tlm[channel][4]), channel); // printf("%s",tlm_str); //#ifdef HAB @@ -1182,6 +1186,9 @@ void get_tlm(void) { // if ((!hab_mode) || ((hab_mode) && (mode != AFSK))) strcat(str, tlm_str); + FILE * cw_file = popen(tlm_str, "r"); + pclose(cw_file); + } } else { // APRS //#ifdef HAB From 0f8293f236f027c1eeb38c9b5220d3d6ec675760 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 10:32:55 -0500 Subject: [PATCH 05/61] Update main.c change to just touch cwready --- main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 4c165c51..01f4cd2d 100644 --- a/main.c +++ b/main.c @@ -1260,16 +1260,17 @@ void get_tlm(void) { // char cw_header2[] = "echo '"; // char cw_footer2[] = "' > id.txt && gen_packets -M 20 id.txt -o morse.wav -r 48000 > /dev/null 2>&1 && cat morse.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.897e3"; char cw_footer3[] = "' > cw.txt && touch /home/pi/CubeSatSim/cwready"; // transmit is done by rpitx.py + char cwready[] = "touch /home/pi/CubeSatSim/cwready"; // cw frame is complete. transmit is done by rpitx.py // printf("Str str: %s \n", str); // fflush(stdout); strcat(str, cw_footer3); // printf("Str: %s \n", str); // fflush(stdout); - printf("CW string to execute: %s\n", str); + printf("CW string to execute: %s\n", cwready); fflush(stdout); - FILE * cw_file = popen(str, "r"); + FILE * cw_file = popen(cwready, "r"); pclose(cw_file); while ((cw_file = fopen("/home/pi/CubeSatSim/cwready", "r")) != NULL) { // wait for rpitx to be done From f15703d9acccce2339c2eda4aab450b9d145dc2d Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 10:35:11 -0500 Subject: [PATCH 06/61] Update rpitx.py send cw0.txt --- rpitx.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rpitx.py b/rpitx.py index 7bd6ba95..598dd3c9 100644 --- a/rpitx.py +++ b/rpitx.py @@ -515,7 +515,7 @@ if __name__ == "__main__": try: f = open("/home/pi/CubeSatSim/cwready") f.close() - system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw.txt -r 48000 > /dev/null 2>&1") + system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw0.txt -r 48000 > /dev/null 2>&1") system("sudo rm /home/pi/CubeSatSim/cwready") if (command_tx == True): @@ -528,9 +528,9 @@ if __name__ == "__main__": system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/morse.wav") else: if (debug_mode == 1): - system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw.txt -r 48000 > /dev/null 2>&1 && 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") + 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") else: - system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw.txt -r 48000 > /dev/null 2>&1 && 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") + 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") sleep(0.1) output(txLed, txLedOff) From 881e83c70d3a69558a60b8f1684f5a7232522b9f Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 10:41:29 -0500 Subject: [PATCH 07/61] Update rpitx.py remove extra cw transmits --- rpitx.py | 57 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/rpitx.py b/rpitx.py index 598dd3c9..1fccdc9e 100644 --- a/rpitx.py +++ b/rpitx.py @@ -480,35 +480,35 @@ if __name__ == "__main__": elif (mode == 'm'): print("CW") # sleep(4) - try: - file = open("/home/pi/CubeSatSim/cw.txt") - file.close() - except: - system("echo 'hi hi 100 199 199 199 298 299 299 278 380 350 300 300 439 400 400 400 500 500 500 500 600 600 600 650' > /home/pi/CubeSatSim/cw.txt") - output(pd, 1) - - if (command_tx == True): - output(txLed, txLedOn) +# try: +# file = open("/home/pi/CubeSatSim/cw.txt") +# file.close() +# except: +# system("echo 'hi hi 100 199 199 199 298 299 299 278 380 350 300 300 439 400 400 400 500 500 500 500 600 600 600 650' > /home/pi/CubeSatSim/cw.txt") +# output(pd, 1) +# +# if (command_tx == True): +# output(txLed, txLedOn) # battery_saver_check() - - if (txc): - output (pd, 1) - output (ptt, 0) - sleep(0.1) - - system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw.txt -r 48000 > /dev/null 2>&1 && aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/morse.wav") - sleep(0.1) - output (ptt, 1) - output (pd, 0) - else: - if (debug_mode == 1): - system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw.txt -r 48000 > /dev/null 2>&1 && 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") - else: - system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw.txt -r 48000 > /dev/null 2>&1 && 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) +# +# if (txc): +# output (pd, 1) +# output (ptt, 0) +# sleep(0.1) +# +# system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw.txt -r 48000 > /dev/null 2>&1 && aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/morse.wav") +# sleep(0.1) +# output (ptt, 1) +# output (pd, 0) +# else: +# if (debug_mode == 1): +# system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw.txt -r 48000 > /dev/null 2>&1 && 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") +# else: +# system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw.txt -r 48000 > /dev/null 2>&1 && 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) # output (ptt, 1) - sleep(5) +# sleep(5) while True: command_control_check() @@ -539,7 +539,8 @@ if __name__ == "__main__": f.close() # system("sudo rm /home/pi/CubeSatSim/cwready") sleep(5) - except: + except: + command_control_check() sleep(1) elif (mode == 's'): print("SSTV") From d6fa37cfd137ca91184620378186011158e6cd52 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 10:50:08 -0500 Subject: [PATCH 08/61] Update rpitx.py prints --- rpitx.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rpitx.py b/rpitx.py index 1fccdc9e..86355bad 100644 --- a/rpitx.py +++ b/rpitx.py @@ -517,6 +517,8 @@ if __name__ == "__main__": f.close() system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw0.txt -r 48000 > /dev/null 2>&1") system("sudo rm /home/pi/CubeSatSim/cwready") + print("Sending cw0.txt") + system("cat /home/pi/CubeSatSim/cw0.txt") if (command_tx == True): output(txLed, txLedOn) From 4f886e2bab9886f612ba125cc042c5996a391e64 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 10:55:34 -0500 Subject: [PATCH 09/61] Update rpitx.py don't remove cwready --- rpitx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index 86355bad..ed98f400 100644 --- a/rpitx.py +++ b/rpitx.py @@ -516,7 +516,7 @@ if __name__ == "__main__": f = open("/home/pi/CubeSatSim/cwready") f.close() system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw0.txt -r 48000 > /dev/null 2>&1") - system("sudo rm /home/pi/CubeSatSim/cwready") +### system("sudo rm /home/pi/CubeSatSim/cwready") print("Sending cw0.txt") system("cat /home/pi/CubeSatSim/cw0.txt") From 70f7fa333477e3baf36d3d76a58e60f5010595c2 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 10:59:13 -0500 Subject: [PATCH 10/61] Update rpitx.py cw1 debug --- rpitx.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rpitx.py b/rpitx.py index ed98f400..ecf5acfb 100644 --- a/rpitx.py +++ b/rpitx.py @@ -515,10 +515,10 @@ if __name__ == "__main__": try: f = open("/home/pi/CubeSatSim/cwready") f.close() - system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw0.txt -r 48000 > /dev/null 2>&1") + system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw1.txt -r 48000") # > /dev/null 2>&1") ### system("sudo rm /home/pi/CubeSatSim/cwready") - print("Sending cw0.txt") - system("cat /home/pi/CubeSatSim/cw0.txt") + print("Sending cw1.txt") + system("cat /home/pi/CubeSatSim/cw1.txt") if (command_tx == True): output(txLed, txLedOn) From f59813a97561835199daee72307d861baced6d65 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 11:03:57 -0500 Subject: [PATCH 11/61] Update rpitx.py add pd 1 to cw transmit --- rpitx.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rpitx.py b/rpitx.py index ecf5acfb..6e8b5a25 100644 --- a/rpitx.py +++ b/rpitx.py @@ -515,15 +515,16 @@ if __name__ == "__main__": try: f = open("/home/pi/CubeSatSim/cwready") f.close() - system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw1.txt -r 48000") # > /dev/null 2>&1") -### system("sudo rm /home/pi/CubeSatSim/cwready") + system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw1.txt -r 48000 > /dev/null 2>&1") + system("sudo rm /home/pi/CubeSatSim/cwready") print("Sending cw1.txt") system("cat /home/pi/CubeSatSim/cw1.txt") if (command_tx == True): output(txLed, txLedOn) - output (ptt, 0) + output (pd, 1) sleep(0.1) + output (ptt, 0) # battery_saver_check() if (txc): From 082d8d496f4ddb5d0b716dbcd995fa84ebc13f25 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 11:11:30 -0500 Subject: [PATCH 12/61] Update rpitx.py cycle through channels 0 - 6 --- rpitx.py | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/rpitx.py b/rpitx.py index 6e8b5a25..3cf82d57 100644 --- a/rpitx.py +++ b/rpitx.py @@ -515,30 +515,34 @@ if __name__ == "__main__": try: f = open("/home/pi/CubeSatSim/cwready") f.close() - system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw1.txt -r 48000 > /dev/null 2>&1") system("sudo rm /home/pi/CubeSatSim/cwready") - print("Sending cw1.txt") - system("cat /home/pi/CubeSatSim/cw1.txt") - - if (command_tx == True): - output(txLed, txLedOn) - output (pd, 1) - sleep(0.1) - output (ptt, 0) -# battery_saver_check() - - if (txc): - system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/morse.wav") - else: - if (debug_mode == 1): - 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") + channel = 0 + while (channel < 7): + system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw" + channel + ".txt -r 48000 > /dev/null 2>&1") + channel += 1 +# print("Sending cw1.txt") +# system("cat /home/pi/CubeSatSim/cw1.txt") + + if (command_tx == True): + output(txLed, txLedOn) + output (pd, 1) + sleep(0.1) + output (ptt, 0) + # battery_saver_check() + + if (txc): + system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/morse.wav") else: - 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") - - sleep(0.1) - output(txLed, txLedOff) - output (ptt, 1) + if (debug_mode == 1): + 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") + else: + 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") + sleep(0.1) + output(txLed, txLedOff) + output (ptt, 1) + + command_control_check() f.close() # system("sudo rm /home/pi/CubeSatSim/cwready") sleep(5) From f0b27917edb9fb62cca16e758162e61edd2dfcae Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 11:19:00 -0500 Subject: [PATCH 13/61] Update rpitx.py print channel --- rpitx.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index 3cf82d57..a30e9cc3 100644 --- a/rpitx.py +++ b/rpitx.py @@ -517,7 +517,9 @@ if __name__ == "__main__": f.close() system("sudo rm /home/pi/CubeSatSim/cwready") channel = 0 - while (channel < 7): + print(channel) + while channel < 7: + print(channel) system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw" + channel + ".txt -r 48000 > /dev/null 2>&1") channel += 1 # print("Sending cw1.txt") From b415dc10321e14cdad9ae74e0b160c5fea07e3b8 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 11:22:05 -0500 Subject: [PATCH 14/61] Update rpitx.py try for --- rpitx.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rpitx.py b/rpitx.py index a30e9cc3..6592772f 100644 --- a/rpitx.py +++ b/rpitx.py @@ -518,10 +518,10 @@ if __name__ == "__main__": system("sudo rm /home/pi/CubeSatSim/cwready") channel = 0 print(channel) - while channel < 7: + for channel in range(7): print(channel) system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw" + channel + ".txt -r 48000 > /dev/null 2>&1") - channel += 1 +# channel += 1 # print("Sending cw1.txt") # system("cat /home/pi/CubeSatSim/cw1.txt") From b3a08e35ae2d2325ef32514ee9f38f40a3ce0b67 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 11:29:18 -0500 Subject: [PATCH 15/61] Update rpitx.py more prints --- rpitx.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index 6592772f..d3ff8328 100644 --- a/rpitx.py +++ b/rpitx.py @@ -543,8 +543,9 @@ if __name__ == "__main__": sleep(0.1) output(txLed, txLedOff) output (ptt, 1) - + print(channel) command_control_check() + print(channel) f.close() # system("sudo rm /home/pi/CubeSatSim/cwready") sleep(5) From 393792fe690104b32b3da76974a51913d906cbe5 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 11:31:25 -0500 Subject: [PATCH 16/61] Update rpitx.py try channel 1 --- rpitx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index d3ff8328..9df8110d 100644 --- a/rpitx.py +++ b/rpitx.py @@ -516,7 +516,7 @@ if __name__ == "__main__": f = open("/home/pi/CubeSatSim/cwready") f.close() system("sudo rm /home/pi/CubeSatSim/cwready") - channel = 0 + channel = 1 print(channel) for channel in range(7): print(channel) From b42317908973789bc018dfd6e2b1470ef38e070b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 11:34:41 -0500 Subject: [PATCH 17/61] Update rpitx.py try chan --- rpitx.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rpitx.py b/rpitx.py index 9df8110d..3d0a1fc6 100644 --- a/rpitx.py +++ b/rpitx.py @@ -518,8 +518,8 @@ if __name__ == "__main__": system("sudo rm /home/pi/CubeSatSim/cwready") channel = 1 print(channel) - for channel in range(7): - print(channel) + for chan in range(7): + print(chan) system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw" + channel + ".txt -r 48000 > /dev/null 2>&1") # channel += 1 # print("Sending cw1.txt") @@ -543,9 +543,9 @@ if __name__ == "__main__": sleep(0.1) output(txLed, txLedOff) output (ptt, 1) - print(channel) + print(chan) command_control_check() - print(channel) + print(chan) f.close() # system("sudo rm /home/pi/CubeSatSim/cwready") sleep(5) From bb700f0f8649ec29cdf6483dd9791584268d2127 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 11:38:05 -0500 Subject: [PATCH 18/61] Update rpitx.py chan and channel --- rpitx.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index 3d0a1fc6..764b3c8b 100644 --- a/rpitx.py +++ b/rpitx.py @@ -519,9 +519,10 @@ if __name__ == "__main__": channel = 1 print(channel) for chan in range(7): + print(channel) print(chan) system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw" + channel + ".txt -r 48000 > /dev/null 2>&1") -# channel += 1 + channel = channel + 1 # print("Sending cw1.txt") # system("cat /home/pi/CubeSatSim/cw1.txt") From 2b9ed7cd079ba75471f3b81a6cc41476a3a209b3 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 11:58:00 -0500 Subject: [PATCH 19/61] Update rpitx.py prints --- rpitx.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rpitx.py b/rpitx.py index 764b3c8b..04b8587a 100644 --- a/rpitx.py +++ b/rpitx.py @@ -378,6 +378,7 @@ if __name__ == "__main__": print(ser.portstr) uhf_string = "AT+DMOSETGROUP=0," + rx +"," + tx + ",0,3,0,0\r\n" for i in range(6): + print(i) # ser.write(b"AT+DMOSETGROUP=0,435.0000,434.9000,0,3,0,0\r\n") ser.write(uhf_string.encode()) sleep(0.1) @@ -521,6 +522,8 @@ if __name__ == "__main__": for chan in range(7): print(channel) print(chan) + print("done for") + for chan in range(7): system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw" + channel + ".txt -r 48000 > /dev/null 2>&1") channel = channel + 1 # print("Sending cw1.txt") @@ -547,6 +550,7 @@ if __name__ == "__main__": print(chan) command_control_check() print(chan) + print("done 2nd for") f.close() # system("sudo rm /home/pi/CubeSatSim/cwready") sleep(5) From cd031e9560614d244d8f516f39e67b29a464380b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 12:02:43 -0500 Subject: [PATCH 20/61] Update rpitx.py lots of prints --- rpitx.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index 04b8587a..7c13699d 100644 --- a/rpitx.py +++ b/rpitx.py @@ -523,13 +523,18 @@ if __name__ == "__main__": print(channel) print(chan) print("done for") - for chan in range(7): + for chan in range(7): + print("for loop") system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw" + channel + ".txt -r 48000 > /dev/null 2>&1") + print("for loop1") channel = channel + 1 + print("for loop2") + # print("Sending cw1.txt") # system("cat /home/pi/CubeSatSim/cw1.txt") if (command_tx == True): + print("for loop3") output(txLed, txLedOn) output (pd, 1) sleep(0.1) @@ -547,8 +552,11 @@ if __name__ == "__main__": sleep(0.1) output(txLed, txLedOff) output (ptt, 1) + print("for loop4") + print("for loop5") print(chan) command_control_check() + print("for loop6") print(chan) print("done 2nd for") f.close() From 57b31f3e48e16a0730aea6896557f9e3612b937f Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 12:04:23 -0500 Subject: [PATCH 21/61] Update rpitx.py try ch --- rpitx.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rpitx.py b/rpitx.py index 7c13699d..ceb78c37 100644 --- a/rpitx.py +++ b/rpitx.py @@ -517,7 +517,7 @@ if __name__ == "__main__": f = open("/home/pi/CubeSatSim/cwready") f.close() system("sudo rm /home/pi/CubeSatSim/cwready") - channel = 1 + ch = 1 print(channel) for chan in range(7): print(channel) @@ -525,9 +525,9 @@ if __name__ == "__main__": print("done for") for chan in range(7): print("for loop") - system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw" + channel + ".txt -r 48000 > /dev/null 2>&1") + system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw" + ch + ".txt -r 48000 > /dev/null 2>&1") print("for loop1") - channel = channel + 1 + ch = ch + 1 print("for loop2") # print("Sending cw1.txt") From fe0b7a8440cc5c7802dc6e2ae8b57e0c6e06d705 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 12:06:57 -0500 Subject: [PATCH 22/61] Update rpitx.py don't command control check --- rpitx.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rpitx.py b/rpitx.py index ceb78c37..dd4de9f2 100644 --- a/rpitx.py +++ b/rpitx.py @@ -555,7 +555,8 @@ if __name__ == "__main__": print("for loop4") print("for loop5") print(chan) - command_control_check() +# command_control_check() + print("dont command control check") print("for loop6") print(chan) print("done 2nd for") @@ -563,7 +564,8 @@ if __name__ == "__main__": # system("sudo rm /home/pi/CubeSatSim/cwready") sleep(5) except: - command_control_check() +# command_control_check() + print("dont command control check") sleep(1) elif (mode == 's'): print("SSTV") From 5b1170b66040c63c490ddf566a6710d3b792b05d Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 12:08:28 -0500 Subject: [PATCH 23/61] Update rpitx.py more prints --- rpitx.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index dd4de9f2..4cd66baf 100644 --- a/rpitx.py +++ b/rpitx.py @@ -511,7 +511,8 @@ if __name__ == "__main__": # output (ptt, 1) # sleep(5) while True: - command_control_check() +# command_control_check() + print("don't command control check 0") try: f = open("/home/pi/CubeSatSim/cwready") From f2c3ac1233ae676cee108faa4ac575526a0e0305 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 12:11:20 -0500 Subject: [PATCH 24/61] Update rpitx.py after rm print --- rpitx.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index 4cd66baf..59317e79 100644 --- a/rpitx.py +++ b/rpitx.py @@ -518,6 +518,7 @@ if __name__ == "__main__": f = open("/home/pi/CubeSatSim/cwready") f.close() system("sudo rm /home/pi/CubeSatSim/cwready") + print("after rm") ch = 1 print(channel) for chan in range(7): @@ -566,7 +567,7 @@ if __name__ == "__main__": sleep(5) except: # command_control_check() - print("dont command control check") + print("dont command control check 1") sleep(1) elif (mode == 's'): print("SSTV") From f13d26dd345558442b2d8585b04cb3dad71eb784 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 12:12:40 -0500 Subject: [PATCH 25/61] Update rpitx.py more prints --- rpitx.py | 1 + 1 file changed, 1 insertion(+) diff --git a/rpitx.py b/rpitx.py index 59317e79..1b9a414b 100644 --- a/rpitx.py +++ b/rpitx.py @@ -520,6 +520,7 @@ if __name__ == "__main__": system("sudo rm /home/pi/CubeSatSim/cwready") print("after rm") ch = 1 + print("after ch") print(channel) for chan in range(7): print(channel) From 3c6df815181062d52fafc6fc59a549d3994901f9 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 12:14:05 -0500 Subject: [PATCH 26/61] Update rpitx.py remove a print --- rpitx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index 1b9a414b..ac6d0b1c 100644 --- a/rpitx.py +++ b/rpitx.py @@ -521,7 +521,7 @@ if __name__ == "__main__": print("after rm") ch = 1 print("after ch") - print(channel) +# print(channel) for chan in range(7): print(channel) print(chan) From 8b2d941e193bc01d7211ff35c8e6561958447403 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 12:15:32 -0500 Subject: [PATCH 27/61] Update rpitx.py remove another print --- rpitx.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index ac6d0b1c..b887d2bb 100644 --- a/rpitx.py +++ b/rpitx.py @@ -523,8 +523,9 @@ if __name__ == "__main__": print("after ch") # print(channel) for chan in range(7): - print(channel) +# print(channel) print(chan) + print("after for chan") print("done for") for chan in range(7): print("for loop") From 2a38e8665e03954a39fa996c463f5e512de7b185 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 12:18:36 -0500 Subject: [PATCH 28/61] Update rpitx.py string only in system call --- rpitx.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index b887d2bb..68f49bd4 100644 --- a/rpitx.py +++ b/rpitx.py @@ -529,7 +529,8 @@ if __name__ == "__main__": print("done for") for chan in range(7): print("for loop") - system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw" + ch + ".txt -r 48000 > /dev/null 2>&1") + command = "gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw" + ch + ".txt -r 48000 > /dev/null 2>&1" + system(command) print("for loop1") ch = ch + 1 print("for loop2") From d140fc9fc404377be46155bf01fb175f4685ca96 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 12:20:50 -0500 Subject: [PATCH 29/61] Update rpitx.py more prints --- rpitx.py | 1 + 1 file changed, 1 insertion(+) diff --git a/rpitx.py b/rpitx.py index 68f49bd4..389d61cb 100644 --- a/rpitx.py +++ b/rpitx.py @@ -530,6 +530,7 @@ if __name__ == "__main__": for chan in range(7): print("for loop") command = "gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw" + ch + ".txt -r 48000 > /dev/null 2>&1" + print("after command assignment") system(command) print("for loop1") ch = ch + 1 From 82cdf640beef4e77c241e17a6d28c324cb4ad2ed Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 12:22:28 -0500 Subject: [PATCH 30/61] Update rpitx.py use str --- rpitx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index 389d61cb..464d15ab 100644 --- a/rpitx.py +++ b/rpitx.py @@ -529,7 +529,7 @@ if __name__ == "__main__": print("done for") for chan in range(7): print("for loop") - command = "gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw" + ch + ".txt -r 48000 > /dev/null 2>&1" + command = "gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw" + str(ch) + ".txt -r 48000 > /dev/null 2>&1" print("after command assignment") system(command) print("for loop1") From a55e459b3dcb5cb33734a6f88b0d15c73f4b5e5c Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 12:24:14 -0500 Subject: [PATCH 31/61] Update rpitx.py do c&c checks --- rpitx.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rpitx.py b/rpitx.py index 464d15ab..dc039370 100644 --- a/rpitx.py +++ b/rpitx.py @@ -511,8 +511,8 @@ if __name__ == "__main__": # output (ptt, 1) # sleep(5) while True: -# command_control_check() - print("don't command control check 0") + command_control_check() +# print("don't command control check 0") try: f = open("/home/pi/CubeSatSim/cwready") @@ -561,8 +561,8 @@ if __name__ == "__main__": print("for loop4") print("for loop5") print(chan) -# command_control_check() - print("dont command control check") + command_control_check() +# print("dont command control check") print("for loop6") print(chan) print("done 2nd for") @@ -570,8 +570,8 @@ if __name__ == "__main__": # system("sudo rm /home/pi/CubeSatSim/cwready") sleep(5) except: -# command_control_check() - print("dont command control check 1") + command_control_check() +# print("dont command control check 1") sleep(1) elif (mode == 's'): print("SSTV") From 027afa409ae3706fd76d8397cbca01c5d7bd1708 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 13:00:19 -0500 Subject: [PATCH 32/61] Update rpitx.py extra command and control checks --- rpitx.py | 81 ++++++++------------------------------------------------ 1 file changed, 11 insertions(+), 70 deletions(-) diff --git a/rpitx.py b/rpitx.py index dc039370..c1e3ee06 100644 --- a/rpitx.py +++ b/rpitx.py @@ -372,7 +372,6 @@ if __name__ == "__main__": print("Programming FM module!\n"); output(pd, 1) output (ptt, 1) - try: ser = serial.Serial("/dev/ttyAMA0", 9600) print(ser.portstr) @@ -385,12 +384,13 @@ if __name__ == "__main__": except: print("Error in serial write") ser.close() - output(pd, 0) 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") + + command_control_check() # if (mode != 'a') and (command_tx == True): if (command_tx == True): @@ -426,14 +426,9 @@ if __name__ == "__main__": # if (len(sys.argv)) > 1: # print("There are arguments!") if (mode == 'a'): + command_control_check() # output(pd, 1) print("AFSK") -# sleep(5) -## try: -## file = open("/home/pi/CubeSatSim/t.txt") -## file.close() -## except: -## system("echo '" + callsign + "-11>APCSS:hi hi 100 199 199 199 298 299 299 278 380 350 300 300 439 400 400 400 500 500 500 500 600 600 600 650' > /home/pi/CubeSatSim/t.txt && echo 'AMSAT>APCSS:010101/hi hi ' >> /home/pi/CubeSatSim/t.txt") while True: try: f = open("/home/pi/CubeSatSim/ready") @@ -480,72 +475,23 @@ if __name__ == "__main__": sleep(1) elif (mode == 'm'): print("CW") -# sleep(4) -# try: -# file = open("/home/pi/CubeSatSim/cw.txt") -# file.close() -# except: -# system("echo 'hi hi 100 199 199 199 298 299 299 278 380 350 300 300 439 400 400 400 500 500 500 500 600 600 600 650' > /home/pi/CubeSatSim/cw.txt") -# output(pd, 1) -# -# if (command_tx == True): -# output(txLed, txLedOn) -# battery_saver_check() -# -# if (txc): -# output (pd, 1) -# output (ptt, 0) -# sleep(0.1) -# -# system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw.txt -r 48000 > /dev/null 2>&1 && aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/morse.wav") -# sleep(0.1) -# output (ptt, 1) -# output (pd, 0) -# else: -# if (debug_mode == 1): -# system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw.txt -r 48000 > /dev/null 2>&1 && 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") -# else: -# system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw.txt -r 48000 > /dev/null 2>&1 && 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) -# output (ptt, 1) -# sleep(5) while True: command_control_check() -# print("don't command control check 0") try: f = open("/home/pi/CubeSatSim/cwready") f.close() system("sudo rm /home/pi/CubeSatSim/cwready") - print("after rm") ch = 1 - print("after ch") -# print(channel) for chan in range(7): -# print(channel) - print(chan) - print("after for chan") - print("done for") - for chan in range(7): - print("for loop") - command = "gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw" + str(ch) + ".txt -r 48000 > /dev/null 2>&1" - print("after command assignment") + command = "gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw" + str(chan) + ".txt -r 48000 > /dev/null 2>&1" system(command) - print("for loop1") - ch = ch + 1 - print("for loop2") - -# print("Sending cw1.txt") -# system("cat /home/pi/CubeSatSim/cw1.txt") - + chan = chan + 1 if (command_tx == True): - print("for loop3") output(txLed, txLedOn) output (pd, 1) sleep(0.1) output (ptt, 0) - # battery_saver_check() if (txc): system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/morse.wav") @@ -558,23 +504,15 @@ if __name__ == "__main__": sleep(0.1) output(txLed, txLedOff) output (ptt, 1) - print("for loop4") - print("for loop5") - print(chan) command_control_check() -# print("dont command control check") - print("for loop6") - print(chan) - print("done 2nd for") f.close() -# system("sudo rm /home/pi/CubeSatSim/cwready") sleep(5) except: command_control_check() -# print("dont command control check 1") sleep(1) elif (mode == 's'): print("SSTV") + command_control_check() try: # from picamera import PiCamera # from pysstv.sstv import SSTV @@ -600,6 +538,7 @@ 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() if (command_tx == True): print ("Sending SSTV image") @@ -756,7 +695,7 @@ if __name__ == "__main__": system("(while true; do (sleep 5 && 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() output(txLed, txLedOn) # battery_saver_check() @@ -773,7 +712,9 @@ if __name__ == "__main__": # output (ptt, 1) # output(pd, 0) sleep(1) + elif (mode == 'b'): + command_control_check() print("BPSK") print("turn on FM rx") output(pd, 1) From 82140095c2813ab4a424d18a15e6dc9488984c6a Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 13:03:37 -0500 Subject: [PATCH 33/61] Update main.c add pause before and after each channel --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 01f4cd2d..34653fb8 100644 --- a/main.c +++ b/main.c @@ -1173,7 +1173,7 @@ void get_tlm(void) { if (mode == CW) { int channel; for (channel = 1; channel < 7; channel++) { - sprintf(tlm_str, "echo '%d%d%d %d%d%d %d%d%d %d%d%d' > cw%1d.txt", + sprintf(tlm_str, "echo ' %d%d%d %d%d%d %d%d%d %d%d%d ' > cw%1d.txt", channel, upper_digit(tlm[channel][1]), lower_digit(tlm[channel][1]), channel, upper_digit(tlm[channel][2]), lower_digit(tlm[channel][2]), channel, upper_digit(tlm[channel][3]), lower_digit(tlm[channel][3]), From c0f0380630c996938e249039144e8aa43fd89477 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 13:04:18 -0500 Subject: [PATCH 34/61] Update rpitx.py remove print --- rpitx.py | 1 - 1 file changed, 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index c1e3ee06..a451afb8 100644 --- a/rpitx.py +++ b/rpitx.py @@ -377,7 +377,6 @@ if __name__ == "__main__": print(ser.portstr) uhf_string = "AT+DMOSETGROUP=0," + rx +"," + tx + ",0,3,0,0\r\n" for i in range(6): - print(i) # ser.write(b"AT+DMOSETGROUP=0,435.0000,434.9000,0,3,0,0\r\n") ser.write(uhf_string.encode()) sleep(0.1) From c5baa06a540c13e51d09ea1231e04ae711c78bc0 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 13:13:40 -0500 Subject: [PATCH 35/61] Update rpitx.py longer carrier before CW --- rpitx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index a451afb8..657915ae 100644 --- a/rpitx.py +++ b/rpitx.py @@ -489,7 +489,7 @@ if __name__ == "__main__": if (command_tx == True): output(txLed, txLedOn) output (pd, 1) - sleep(0.1) + sleep(0.3) output (ptt, 0) if (txc): From d3aff374539559aa2a01e83a3369395e465eaeea Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 13:31:34 -0500 Subject: [PATCH 36/61] Update main.c --- main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 34653fb8..a6536dec 100644 --- a/main.c +++ b/main.c @@ -1163,7 +1163,8 @@ void get_tlm(void) { strcat(str, header_str4); strcat(str, call); - sprintf(tlm_str, "%s' > cw0.txt", &str); + sprintf(tlm_str, "%s' > cw0.txt", &str); + printf("CW string to execute: %s\n", &tlm_str); FILE * cw_file = popen(tlm_str, "r"); pclose(cw_file); @@ -1184,8 +1185,10 @@ void get_tlm(void) { // if (mode != AFSK) //#endif // if ((!hab_mode) || ((hab_mode) && (mode != AFSK))) - strcat(str, tlm_str); - + strcat(str, tlm_str); + + printf("CW string to execute: %s\n", &tlm_str); + FILE * cw_file = popen(tlm_str, "r"); pclose(cw_file); From 34007d411a56f7501b285a4e9e8e5555c2e050ad Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 13:38:13 -0500 Subject: [PATCH 37/61] Update rpitx.py print cw command --- rpitx.py | 1 + 1 file changed, 1 insertion(+) diff --git a/rpitx.py b/rpitx.py index 657915ae..53afca53 100644 --- a/rpitx.py +++ b/rpitx.py @@ -484,6 +484,7 @@ if __name__ == "__main__": ch = 1 for chan in range(7): command = "gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw" + str(chan) + ".txt -r 48000 > /dev/null 2>&1" + print(command) system(command) chan = chan + 1 if (command_tx == True): From 745fe341b5e8480be41c07e472e900f80c50b0bf Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Mar 2024 15:50:39 -0500 Subject: [PATCH 38/61] Update main.c do full cw --- main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index a6536dec..9958c06f 100644 --- a/main.c +++ b/main.c @@ -1270,11 +1270,14 @@ void get_tlm(void) { strcat(str, cw_footer3); // printf("Str: %s \n", str); // fflush(stdout); - printf("CW string to execute: %s\n", cwready); + printf("CW string to execute: %s\n", str); fflush(stdout); - FILE * cw_file = popen(cwready, "r"); - pclose(cw_file); + FILE * cw_file = popen(str, "r"); + pclose(cw_file); + +// FILE * cw_file = popen(cwready, "r"); +// pclose(cw_file); while ((cw_file = fopen("/home/pi/CubeSatSim/cwready", "r")) != NULL) { // wait for rpitx to be done fclose(cw_file); From e887647b6136bf8bb4b53b2538c8c530ac3d6650 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 3 Mar 2024 10:40:38 -0500 Subject: [PATCH 39/61] Update rpitx.py don't change mode for testing! --- rpitx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index 53afca53..50ac5326 100644 --- a/rpitx.py +++ b/rpitx.py @@ -173,7 +173,7 @@ def increment_mode(): print("Changing mode now") # system("/home/pi/CubeSatSim/config -" + mode) - system("reboot -h now") +### system("reboot -h now") sleep(10); except: From 47b63aa32de4711ebfc8827de5a91360dd7993af Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 3 Mar 2024 10:42:11 -0500 Subject: [PATCH 40/61] Update rpitx.py don't do initial CW ID if CW mode --- rpitx.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index 50ac5326..ffb8e981 100644 --- a/rpitx.py +++ b/rpitx.py @@ -392,7 +392,8 @@ if __name__ == "__main__": command_control_check() # if (mode != 'a') and (command_tx == True): - if (command_tx == True): +# if (command_tx == True): + if (mode != CW): # battery_saver_mode output(txLed, txLedOn) # if (txc): From 8db86c2aa53c38ad6cae91c95c46c623703df8ef Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 3 Mar 2024 10:50:44 -0500 Subject: [PATCH 41/61] Update rpitx.py don't CW ID if CW --- rpitx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index ffb8e981..24d08aef 100644 --- a/rpitx.py +++ b/rpitx.py @@ -393,7 +393,7 @@ if __name__ == "__main__": # if (mode != 'a') and (command_tx == True): # if (command_tx == True): - if (mode != CW): + if (mode != 'm'): # battery_saver_mode output(txLed, txLedOn) # if (txc): From 1f31f1a0eb6a5017370bfb42ee164614326f9830 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 3 Mar 2024 10:56:40 -0500 Subject: [PATCH 42/61] Update rpitx.py restore reboot in c&c mode change --- rpitx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index 24d08aef..b46c4e46 100644 --- a/rpitx.py +++ b/rpitx.py @@ -173,7 +173,7 @@ def increment_mode(): print("Changing mode now") # system("/home/pi/CubeSatSim/config -" + mode) -### system("reboot -h now") + system("reboot -h now") sleep(10); except: From 76793a7b710f227a219d50c23e3fc9917b0cf551 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 3 Mar 2024 22:27:56 -0500 Subject: [PATCH 43/61] Update rpitx.py remove chan++ and ch --- rpitx.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rpitx.py b/rpitx.py index b46c4e46..3b6d7617 100644 --- a/rpitx.py +++ b/rpitx.py @@ -482,12 +482,12 @@ if __name__ == "__main__": f = open("/home/pi/CubeSatSim/cwready") f.close() system("sudo rm /home/pi/CubeSatSim/cwready") - ch = 1 +## ch = 1 for chan in range(7): command = "gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw" + str(chan) + ".txt -r 48000 > /dev/null 2>&1" print(command) system(command) - chan = chan + 1 +## chan = chan + 1 if (command_tx == True): output(txLed, txLedOn) output (pd, 1) From 1f048206d6096df4d6c9b533668a79f37402f17d Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 4 Mar 2024 09:08:19 -0500 Subject: [PATCH 44/61] Update main.c make battery saver Safe Mode --- main.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index 9958c06f..0ae6eade 100644 --- a/main.c +++ b/main.c @@ -827,13 +827,14 @@ int main(int argc, char * argv[]) { // batteryVoltage = voltage[map[BAT]]; // batteryCurrent = current[map[BAT]]; - + +/* if (batteryVoltage < 3.7) { SafeMode = 1; printf("Safe Mode!\n"); } else SafeMode = 0; - +*/ FILE * cpuTempSensor = fopen("/sys/class/thermal/thermal_zone0/temp", "r"); if (cpuTempSensor) { // double cpuTemp; @@ -930,13 +931,20 @@ int main(int argc, char * argv[]) { if ((batteryCurrent > currentThreshold) && (batteryVoltage < (voltageThreshold + 0.15)) && !sim_mode && !hab_mode) { fprintf(stderr,"Battery voltage low - switch to battery saver\n"); - if (battery_saver_mode == OFF) + if (battery_saver_mode == OFF) { battery_saver(ON); + printf("Safe Mode!\n"); + SafeMode = 1; + + } } else if ((battery_saver_mode == ON) && (batteryCurrent < 0) && !sim_mode && !hab_mode) { fprintf(stderr,"Battery is being charged - switch battery saver off\n"); - if (battery_saver_mode == ON) - battery_saver(OFF); + if (battery_saver_mode == ON) { + battery_saver(OFF); + printf("Safe Mode off!\n"); + SafeMode = 0; + } } if ((batteryCurrent > currentThreshold) && (batteryVoltage < voltageThreshold) && !sim_mode && !hab_mode) // currentThreshold ensures that this won't happen when running on DC power. { From 56d977746931ec3d7af26eb0d2744169d7818692 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 4 Mar 2024 09:19:28 -0500 Subject: [PATCH 45/61] Update rpitx.py add Safe Mode print --- rpitx.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index 3b6d7617..dbb7d758 100644 --- a/rpitx.py +++ b/rpitx.py @@ -62,9 +62,10 @@ def battery_saver_check(): f = open("/home/pi/CubeSatSim/battery_saver", "r") f.close() txc = False + print("Safe Mode!") print("battery saver activated") except: - print("not activated") + print("battery saver not activated") # txc = True def increment_mode(): From 2fdca3524a3e4617a80489457e3c9bb95bbb681c Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 4 Mar 2024 09:25:09 -0500 Subject: [PATCH 46/61] Update config change from battery saver to safe mode --- config | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/config b/config index 9d3a6feb..42076c06 100755 --- a/config +++ b/config @@ -70,6 +70,7 @@ if [ "$1" = "" ]; then FILE=/home/pi/CubeSatSim/battery_saver if [ -f "$FILE" ]; then + echo "Safe Mode!" echo "Battery saver mode is ON" else echo "Battery saver mode is OFF" @@ -100,6 +101,7 @@ elif [ "$1" = "-a" ]; then FILE=/home/pi/CubeSatSim/battery_saver if [ -f "$FILE" ]; then + echo "Safe Mode!" echo "Battery saver mode is ON." # if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi else @@ -119,6 +121,7 @@ elif [ "$1" = "-m" ]; then FILE=/home/pi/CubeSatSim/battery_saver if [ -f "$FILE" ]; then + echo "Safe Mode!" echo "Battery saver mode is ON." # if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi else @@ -154,6 +157,7 @@ elif [ "$1" = "-s" ]; then FILE=/home/pi/CubeSatSim/battery_saver if [ -f "$FILE" ]; then + echo "Safe Mode!" echo "Battery saver mode ON." # if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi else @@ -482,30 +486,32 @@ elif [ "$1" = "-R" ]; then elif [ "$1" = "-B" ]; then echo - echo "Manually setting battery saver mode" + echo "Manually setting Safe Mode (battery saver mode)" echo FILE=/home/pi/CubeSatSim/battery_saver if [ -f "$FILE" ]; then + echo "Safe Mode!" echo "Battery saver mode is ON." mode=1 else + echo "Safe Mode is OFF." echo "Battery saver mode is OFF." mode=0 fi echo - echo "Do you want Battery saver mode ON (y/n) " + echo "Do you want Safe Mode (battery saver mode) ON (y/n) " read saver echo if [ "$saver" = "y" ] || [ "$saver" = "yes" ] ; then - echo "Battery saver mode is now ON" + echo "Safe Mode! Battery saver mode is now ON" touch /home/pi/CubeSatSim/battery_saver # if ["$mode" = "0"] ; then sudo systemctl restart rpitx else - echo "Battery saver mode is now OFF" + echo "Safe Mode is OFF. Battery saver mode is now OFF" sudo rm /home/pi/CubeSatSim/battery_saver # if ["$mode" = "1"] ; then sudo systemctl restart rpitx fi @@ -704,7 +710,7 @@ elif [ "$1" = "-h" ]; then echo " -C Clear logs" echo " -T Change command and control state" echo " -R Change the Commands Count in the file command_count.txt" - echo " -B Change battery saver mode manually" + echo " -B Change Safe Mode (battery saver mode) manually" echo " -q Change the Squelch setting for command receiver" echo " -F Change the rx and tx frequency" echo " -H Chnage the Balloon mode" From 96fe99bb429c3adcd5c9e1029c270dd06cf1bafe Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 4 Mar 2024 09:35:05 -0500 Subject: [PATCH 47/61] Update config only rm battery saver if changed --- config | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config b/config index 42076c06..4662e932 100755 --- a/config +++ b/config @@ -512,8 +512,7 @@ elif [ "$1" = "-B" ]; then # if ["$mode" = "0"] ; then sudo systemctl restart rpitx else echo "Safe Mode is OFF. Battery saver mode is now OFF" - sudo rm /home/pi/CubeSatSim/battery_saver -# if ["$mode" = "1"] ; then sudo systemctl restart rpitx + if ["$mode" = "1"] ; then sudo rm /home/pi/CubeSatSim/battery_saver fi value=`cat /home/pi/CubeSatSim/.mode` From bdef1208d44c485752b55dad5cbe92818cedf642 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 4 Mar 2024 09:36:50 -0500 Subject: [PATCH 48/61] Update config -B fix --- config | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config b/config index 4662e932..74e8d91c 100755 --- a/config +++ b/config @@ -512,7 +512,9 @@ elif [ "$1" = "-B" ]; then # if ["$mode" = "0"] ; then sudo systemctl restart rpitx else echo "Safe Mode is OFF. Battery saver mode is now OFF" - if ["$mode" = "1"] ; then sudo rm /home/pi/CubeSatSim/battery_saver + if ["$mode" = "1"] ; then + sudo rm /home/pi/CubeSatSim/battery_saver + fi fi value=`cat /home/pi/CubeSatSim/.mode` From 740a82b71c0b745b3b67e7f47df4042841f03e3f Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 4 Mar 2024 09:38:00 -0500 Subject: [PATCH 49/61] Update config typo --- config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config b/config index 74e8d91c..fd50b092 100755 --- a/config +++ b/config @@ -509,10 +509,10 @@ elif [ "$1" = "-B" ]; then if [ "$saver" = "y" ] || [ "$saver" = "yes" ] ; then echo "Safe Mode! Battery saver mode is now ON" touch /home/pi/CubeSatSim/battery_saver -# if ["$mode" = "0"] ; then sudo systemctl restart rpitx +# if [ "$mode" = "0" ] ; then sudo systemctl restart rpitx else echo "Safe Mode is OFF. Battery saver mode is now OFF" - if ["$mode" = "1"] ; then + if [ "$mode" = "1" ] ; then sudo rm /home/pi/CubeSatSim/battery_saver fi fi From 8d03cbec58e8cba2fd4ba4d2c58ea1c527348e53 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 4 Mar 2024 09:54:42 -0500 Subject: [PATCH 50/61] Update main.c more safe mode things --- main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 0ae6eade..af9111c6 100644 --- a/main.c +++ b/main.c @@ -933,7 +933,7 @@ int main(int argc, char * argv[]) { fprintf(stderr,"Battery voltage low - switch to battery saver\n"); if (battery_saver_mode == OFF) { battery_saver(ON); - printf("Safe Mode!\n"); + fprintf(stderr, "Battery voltage too low: %f V - shutting down!\n", batteryVoltage);"Safe Mode!\n"); SafeMode = 1; } @@ -942,7 +942,7 @@ int main(int argc, char * argv[]) { fprintf(stderr,"Battery is being charged - switch battery saver off\n"); if (battery_saver_mode == ON) { battery_saver(OFF); - printf("Safe Mode off!\n"); + fprintf(stderr, "Battery voltage too low: %f V - shutting down!\n", batteryVoltage);"Safe Mode off!\n"); SafeMode = 0; } } @@ -2428,6 +2428,7 @@ int battery_saver_check() { return(OFF); } fclose(file); + fprintf(stderr, "Safe Mode!"); fprintf(stderr,"Battery saver mode is ON!\n"); return(ON); } @@ -2438,6 +2439,7 @@ if (setting == ON) { if (battery_saver_check() == OFF) { FILE *command = popen("touch /home/pi/CubeSatSim/battery_saver", "r"); pclose(command); + fprintf(stderr,"Turning Safe Mode ON\n"); fprintf(stderr,"Turning Battery saver mode ON\n"); // command = popen("if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo force_turbo=1 >> /boot/config.txt'; fi", "r"); // pclose(command); From 82cb05e3d99bd31d9034416c1f861248e5fec0f0 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 4 Mar 2024 09:55:54 -0500 Subject: [PATCH 51/61] Update main.c fix safe mode tyops --- main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index af9111c6..167ab2db 100644 --- a/main.c +++ b/main.c @@ -933,7 +933,7 @@ int main(int argc, char * argv[]) { fprintf(stderr,"Battery voltage low - switch to battery saver\n"); if (battery_saver_mode == OFF) { battery_saver(ON); - fprintf(stderr, "Battery voltage too low: %f V - shutting down!\n", batteryVoltage);"Safe Mode!\n"); + fprintf(stderr, "Safe Mode!\n"); SafeMode = 1; } @@ -942,7 +942,7 @@ int main(int argc, char * argv[]) { fprintf(stderr,"Battery is being charged - switch battery saver off\n"); if (battery_saver_mode == ON) { battery_saver(OFF); - fprintf(stderr, "Battery voltage too low: %f V - shutting down!\n", batteryVoltage);"Safe Mode off!\n"); + fprintf(stderr, "Safe Mode off!\n"); SafeMode = 0; } } From ea4edac08654daffef3e7cc5ab4100b30861a441 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 4 Mar 2024 10:07:52 -0500 Subject: [PATCH 52/61] Update main.c cleanup --- main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 167ab2db..b99eb362 100644 --- a/main.c +++ b/main.c @@ -1278,7 +1278,7 @@ void get_tlm(void) { strcat(str, cw_footer3); // printf("Str: %s \n", str); // fflush(stdout); - printf("CW string to execute: %s\n", str); + printf("CW string to execute:: %s\n", str); fflush(stdout); FILE * cw_file = popen(str, "r"); @@ -2428,7 +2428,7 @@ int battery_saver_check() { return(OFF); } fclose(file); - fprintf(stderr, "Safe Mode!"); + fprintf(stderr, "Safe Mode!\n"); fprintf(stderr,"Battery saver mode is ON!\n"); return(ON); } From acdc3897ff9e0305553561eed3bd4157bc8dd5f7 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 4 Mar 2024 10:22:03 -0500 Subject: [PATCH 53/61] Update main.c don't print in battery saver check --- main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/main.c b/main.c index b99eb362..5422f54c 100644 --- a/main.c +++ b/main.c @@ -190,12 +190,12 @@ int main(int argc, char * argv[]) { battery_saver_mode = battery_saver_check(); -/* +/**/ if (battery_saver_mode == ON) - fprintf(stderr, "\nBattery_saver_mode is ON\n\n"); + fprintf(stderr, "Safe Mode! Battery_saver_mode is ON\n\n"); else fprintf(stderr, "\nBattery_saver_mode is OFF\n\n"); -*/ +/**/ fflush(stderr); if (mode == AFSK) @@ -1336,7 +1336,7 @@ void get_tlm(void) { */ strcat(str, footer_str1); // strcat(str, call); - if (battery_saver_mode == ON) + if ( == ON) strcat(str, footer_str); // add extra packet for rpitx transmission else strcat(str, footer_str2); @@ -2424,12 +2424,12 @@ if ((uart_fd = serialOpen("/dev/ttyAMA0", 9600)) >= 0) { // was 9600 int battery_saver_check() { FILE *file = fopen("/home/pi/CubeSatSim/battery_saver", "r"); if (file == NULL) { - fprintf(stderr,"Battery saver mode is OFF!\n"); +// fprintf(stderr,"Battery saver mode is OFF!\n"); return(OFF); } fclose(file); - fprintf(stderr, "Safe Mode!\n"); - fprintf(stderr,"Battery saver mode is ON!\n"); +// fprintf(stderr, "Safe Mode!\n"); +// fprintf(stderr,"Battery saver mode is ON!\n"); return(ON); } From 1991a9144e6ff28197d28301be9f2f4464c85f51 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 4 Mar 2024 10:23:59 -0500 Subject: [PATCH 54/61] Update config print safe mode and saver on same line --- config | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/config b/config index fd50b092..eb8ed230 100755 --- a/config +++ b/config @@ -70,8 +70,7 @@ if [ "$1" = "" ]; then FILE=/home/pi/CubeSatSim/battery_saver if [ -f "$FILE" ]; then - echo "Safe Mode!" - echo "Battery saver mode is ON" + echo "Safe Mode! Battery saver mode is ON" else echo "Battery saver mode is OFF" fi @@ -101,8 +100,7 @@ elif [ "$1" = "-a" ]; then FILE=/home/pi/CubeSatSim/battery_saver if [ -f "$FILE" ]; then - echo "Safe Mode!" - echo "Battery saver mode is ON." + echo "Safe Mode! Battery saver mode is ON." # if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi else echo "Battery saver mode is OFF." @@ -121,8 +119,7 @@ elif [ "$1" = "-m" ]; then FILE=/home/pi/CubeSatSim/battery_saver if [ -f "$FILE" ]; then - echo "Safe Mode!" - echo "Battery saver mode is ON." + echo "Safe Mode! Battery saver mode is ON." # if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi else echo "Battery saver mode is OFF." @@ -157,8 +154,7 @@ elif [ "$1" = "-s" ]; then FILE=/home/pi/CubeSatSim/battery_saver if [ -f "$FILE" ]; then - echo "Safe Mode!" - echo "Battery saver mode ON." + echo "Safe Mode! Battery saver mode ON." # if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi else echo "Battery saver mode is OFF." @@ -491,8 +487,7 @@ elif [ "$1" = "-B" ]; then FILE=/home/pi/CubeSatSim/battery_saver if [ -f "$FILE" ]; then - echo "Safe Mode!" - echo "Battery saver mode is ON." + echo "Safe Mode! Battery saver mode is ON." mode=1 else echo "Safe Mode is OFF." From 6c1a55b8517998ea2171ed11fac8da20e5b5fd8a Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 4 Mar 2024 10:27:25 -0500 Subject: [PATCH 55/61] Update main.c added missing variable --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 5422f54c..53cd1aab 100644 --- a/main.c +++ b/main.c @@ -1336,7 +1336,7 @@ void get_tlm(void) { */ strcat(str, footer_str1); // strcat(str, call); - if ( == ON) + if (battery_saver_mode == ON) strcat(str, footer_str); // add extra packet for rpitx transmission else strcat(str, footer_str2); From 018d50ff10363e0c36749671a5d99a0e1e699723 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 4 Mar 2024 10:31:41 -0500 Subject: [PATCH 56/61] Update main.c fix cwready --- main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/main.c b/main.c index 53cd1aab..b4f85351 100644 --- a/main.c +++ b/main.c @@ -1275,17 +1275,17 @@ void get_tlm(void) { // printf("Str str: %s \n", str); // fflush(stdout); - strcat(str, cw_footer3); +// strcat(str, cw_footer3); // printf("Str: %s \n", str); // fflush(stdout); - printf("CW string to execute:: %s\n", str); - fflush(stdout); +// printf("CW string to execute:: %s\n", str); +// fflush(stdout); - FILE * cw_file = popen(str, "r"); - pclose(cw_file); +// FILE * cw_file = popen(str, "r"); +// pclose(cw_file); -// FILE * cw_file = popen(cwready, "r"); -// pclose(cw_file); + FILE * cw_file = popen(cwready, "r"); + pclose(cw_file); while ((cw_file = fopen("/home/pi/CubeSatSim/cwready", "r")) != NULL) { // wait for rpitx to be done fclose(cw_file); From 04b5b9ca786c17b4b386e5a49e61de58dd31e9ae Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 4 Mar 2024 10:34:48 -0500 Subject: [PATCH 57/61] Update main.c don't say switch unless switching --- main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index b4f85351..81b4607e 100644 --- a/main.c +++ b/main.c @@ -930,8 +930,9 @@ int main(int argc, char * argv[]) { if ((batteryCurrent > currentThreshold) && (batteryVoltage < (voltageThreshold + 0.15)) && !sim_mode && !hab_mode) { - fprintf(stderr,"Battery voltage low - switch to battery saver\n"); + fprintf(stderr,"Battery voltage low\n"); if (battery_saver_mode == OFF) { + fprintf(stderr,"Switch to battery saver\n"); battery_saver(ON); fprintf(stderr, "Safe Mode!\n"); SafeMode = 1; From f311f1f076857763f2d7b0d74215c13a879da77a Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 4 Mar 2024 10:52:05 -0500 Subject: [PATCH 58/61] Update rpitx.py move cw pd and put --- rpitx.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/rpitx.py b/rpitx.py index dbb7d758..15782c3d 100644 --- a/rpitx.py +++ b/rpitx.py @@ -490,22 +490,23 @@ if __name__ == "__main__": system(command) ## chan = chan + 1 if (command_tx == True): - output(txLed, txLedOn) - output (pd, 1) - sleep(0.3) - output (ptt, 0) + output(txLed, txLedOn) if (txc): + output (pd, 1) + sleep(0.3) + output (ptt, 0) system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/morse.wav") + sleep(0.1) + output (ptt, 1) +# output (pd, 0) else: if (debug_mode == 1): 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") else: - 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") - - sleep(0.1) + 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) - output (ptt, 1) + command_control_check() f.close() sleep(5) From 3c090c52854bed841ec4f21222a439270c243c7b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 4 Mar 2024 11:16:23 -0500 Subject: [PATCH 59/61] Update config only reboot in -B if changes --- config | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/config b/config index eb8ed230..62fb1e12 100755 --- a/config +++ b/config @@ -500,26 +500,33 @@ elif [ "$1" = "-B" ]; then echo "Do you want Safe Mode (battery saver mode) ON (y/n) " read saver echo - + + reboot = 0 + if [ "$saver" = "y" ] || [ "$saver" = "yes" ] ; then echo "Safe Mode! Battery saver mode is now ON" touch /home/pi/CubeSatSim/battery_saver -# if [ "$mode" = "0" ] ; then sudo systemctl restart rpitx + if [ "$mode" = "0" ] ; then + reboot = 1 + fi else echo "Safe Mode is OFF. Battery saver mode is now OFF" if [ "$mode" = "1" ] ; then sudo rm /home/pi/CubeSatSim/battery_saver + reboot = 1 fi fi - value=`cat /home/pi/CubeSatSim/.mode` - echo "$value" > /dev/null - set -- $value - - if [ "$1" = "a" ] || [ "$1" = "s" ] || [ "$1" = "m" ] ; then - echo "rebooting" -# sudo systemctl restart cubesatsim - sudo reboot now + if [ "$reboot" = "1" ] ; then + value=`cat /home/pi/CubeSatSim/.mode` + echo "$value" > /dev/null + set -- $value + + if [ "$1" = "a" ] || [ "$1" = "s" ] || [ "$1" = "m" ] ; then + echo "rebooting" + # sudo systemctl restart cubesatsim + sudo reboot now + fi fi elif [ "$1" = "-q" ]; then From 8e9c32cf7da4c5f35099362b03a1d991c7b7d632 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 4 Mar 2024 11:17:52 -0500 Subject: [PATCH 60/61] Update config remove spaces --- config | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config b/config index 62fb1e12..48725b77 100755 --- a/config +++ b/config @@ -501,19 +501,19 @@ elif [ "$1" = "-B" ]; then read saver echo - reboot = 0 + reboot=0 if [ "$saver" = "y" ] || [ "$saver" = "yes" ] ; then echo "Safe Mode! Battery saver mode is now ON" touch /home/pi/CubeSatSim/battery_saver if [ "$mode" = "0" ] ; then - reboot = 1 + reboot=1 fi else echo "Safe Mode is OFF. Battery saver mode is now OFF" if [ "$mode" = "1" ] ; then sudo rm /home/pi/CubeSatSim/battery_saver - reboot = 1 + reboot=1 fi fi From 3275441e5a6ecec220935170ab16e1b4709adc58 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 4 Mar 2024 11:21:01 -0500 Subject: [PATCH 61/61] Update config say will be turned on/off --- config | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/config b/config index 48725b77..33da8587 100755 --- a/config +++ b/config @@ -504,14 +504,15 @@ elif [ "$1" = "-B" ]; then reboot=0 if [ "$saver" = "y" ] || [ "$saver" = "yes" ] ; then - echo "Safe Mode! Battery saver mode is now ON" - touch /home/pi/CubeSatSim/battery_saver if [ "$mode" = "0" ] ; then + echo "Safe Mode will be turned on! Battery saver will be turned ON" + sudo touch /home/pi/CubeSatSim/battery_saver reboot=1 fi else - echo "Safe Mode is OFF. Battery saver mode is now OFF" + if [ "$mode" = "1" ] ; then + echo "Safe Mode will be turned OFF. Battery saver mode will be turned OFF" sudo rm /home/pi/CubeSatSim/battery_saver reboot=1 fi