From 3124280207dd012bb9f26c269f93849c743c5d5b Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 10 Jun 2021 07:19:34 -0400 Subject: [PATCH 01/21] read .mode file --- afsk/main.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/afsk/main.c b/afsk/main.c index 1dde5c8b..85aa0e91 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -191,6 +191,16 @@ int main(int argc, char * argv[]) { printf("No CW id\n"); } } + } else { + + FILE * mode_file = fopen("/home/pi/CubeSatSim/.mode", "r"); + if (mode_file != NULL) { + char mode_string[5]; + mode_string = fgetc(mode_file); + fclose(mode_file); + printf("Mode file /home/pi/CubeSatSim/.mode contains %s\n", mode_string); + + } } // Open configuration file with callsign and reset count From a7c1f8864faff768a273ad9c156f6fa9119cb312 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 10 Jun 2021 07:20:44 -0400 Subject: [PATCH 02/21] typo --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 85aa0e91..5404c0f9 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -195,7 +195,7 @@ int main(int argc, char * argv[]) { FILE * mode_file = fopen("/home/pi/CubeSatSim/.mode", "r"); if (mode_file != NULL) { - char mode_string[5]; + char mode_string; mode_string = fgetc(mode_file); fclose(mode_file); printf("Mode file /home/pi/CubeSatSim/.mode contains %s\n", mode_string); From 8707315884e96d9aaa8e90bcefe39d365abf7a26 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 10 Jun 2021 07:22:35 -0400 Subject: [PATCH 03/21] printf typo --- afsk/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 5404c0f9..c93bff17 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -198,7 +198,7 @@ int main(int argc, char * argv[]) { char mode_string; mode_string = fgetc(mode_file); fclose(mode_file); - printf("Mode file /home/pi/CubeSatSim/.mode contains %s\n", mode_string); + printf("Mode file /home/pi/CubeSatSim/.mode contains %c\n", mode_string); } } From 4054359f6ccb45dbbb025033c1371234eca13d30 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 10 Jun 2021 07:27:08 -0400 Subject: [PATCH 04/21] if no arguments, set mode based on .mode character --- afsk/main.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index c93bff17..73a0d608 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -110,7 +110,8 @@ FILE *sopen(const char *program); #define AFSK 1 #define FSK 2 #define BPSK 3 -#define CW 4 +#define SSTV 4 +#define CW 5 int rpitxStatus = -1; @@ -199,6 +200,22 @@ int main(int argc, char * argv[]) { mode_string = fgetc(mode_file); fclose(mode_file); printf("Mode file /home/pi/CubeSatSim/.mode contains %c\n", mode_string); + + if ( mode_string == 'b') { + mode = BPSK; + printf("Mode is BPSK\n"); + } else if ( mode_string == 'a') { + mode = AFSK; + printf("Mode is AFSK\n"); + } else if ( mode_string == 's') { + mode = SSTV; + printf("Mode is SSTV\n"); + } else if ( mode_string == 'c') { + mode = CW; + printf("Mode is CW\n"); + } else { + printf("Mode is FSK\n"); + } } } From 27875e5bca0b3ebf66af32a7f0f909a06d0ae385 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 10 Jun 2021 07:31:12 -0400 Subject: [PATCH 05/21] added rpitx restart --- afsk/main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/afsk/main.c b/afsk/main.c index 73a0d608..ff063199 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -219,6 +219,9 @@ int main(int argc, char * argv[]) { } } + + FILE * rpitx_restart = popen("sudo systemctl restart rpitx", "r"); + fclose(rpitx_restart); // Open configuration file with callsign and reset count FILE * config_file = fopen("/home/pi/CubeSatSim/sim.cfg", "r"); From c418a21f54dea02d71ea0681a804daa00aa632b8 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 10 Jun 2021 07:38:56 -0400 Subject: [PATCH 06/21] read .mode file --- rpitx.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rpitx.py b/rpitx.py index b45e829b..c9429424 100644 --- a/rpitx.py +++ b/rpitx.py @@ -32,6 +32,14 @@ GPIO.output(27, 0) print(transmit) +try: + file = open("/home/pi/CubeSatSim/.mode") + mode = file.read(1) +except: + mode = "f" +print("Mode char is: ") +print(mode) + try: file = open("/home/pi/CubeSatSim/sim.cfg") callsign = file.readline().split(" ")[0] From 04864dc2aaae010078deb336b721cb073644069f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 10 Jun 2021 07:43:21 -0400 Subject: [PATCH 07/21] set mode based on reading .mode file --- rpitx.py | 134 +++++++++++++++++++++++++++---------------------------- 1 file changed, 67 insertions(+), 67 deletions(-) diff --git a/rpitx.py b/rpitx.py index c9429424..b459d4d7 100644 --- a/rpitx.py +++ b/rpitx.py @@ -37,7 +37,7 @@ try: mode = file.read(1) except: mode = "f" -print("Mode char is: ") +print("Mode is: ") print(mode) try: @@ -61,88 +61,88 @@ if __name__ == "__main__": # print 'Length: ', len(sys.argv) - if (len(sys.argv)) > 1: +# if (len(sys.argv)) > 1: # print("There are arguments!") - if (('a' == sys.argv[1]) or ('afsk' in sys.argv[1])): - print("AFSK") + if (mode == 'a'): + print("AFSK") + time.sleep(4) + for x in range(5): + GPIO.output(txLed, txLedOn); + system("sudo gen_packets -o /home/pi/CubeSatSim/telem.wav /home/pi/CubeSatSim/t.txt -r 48000 > /dev/null 2>&1 && cat /home/pi/CubeSatSim/telem.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.9e3 > /dev/null 2>&1") + GPIO.output(txLed, txLedOff); time.sleep(4) - for x in range(5): - GPIO.output(txLed, txLedOn); + while True: + try: + f = open("/home/pi/CubeSatSim/ready") system("sudo gen_packets -o /home/pi/CubeSatSim/telem.wav /home/pi/CubeSatSim/t.txt -r 48000 > /dev/null 2>&1 && cat /home/pi/CubeSatSim/telem.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.9e3 > /dev/null 2>&1") - GPIO.output(txLed, txLedOff); - time.sleep(4) - while True: - try: - f = open("/home/pi/CubeSatSim/ready") - system("sudo gen_packets -o /home/pi/CubeSatSim/telem.wav /home/pi/CubeSatSim/t.txt -r 48000 > /dev/null 2>&1 && cat /home/pi/CubeSatSim/telem.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.9e3 > /dev/null 2>&1") - f.close() - system("sudo rm ready") - time.sleep(0.5) - except: - time.sleep(0.5) - elif (('s' == sys.argv[1]) or ('sstv' in sys.argv[1])): - print("SSTV") - try: - from picamera import PiCamera + f.close() + system("sudo rm ready") + time.sleep(0.5) + except: + time.sleep(0.5) + elif (mode == 's'): + print("SSTV") + try: + from picamera import PiCamera # from pysstv.sstv import SSTV - camera = PiCamera() - print("Camera present") - camera_present = 1 - camera.close() - except: - print("No camera") - camera_present = 0 - try: - 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") + camera = PiCamera() + print("Camera present") + camera_present = 1 + camera.close() + except: + print("No camera") + camera_present = 0 + try: + 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") + print ("Sending SSTV image") + GPIO.output(txLed, txLedOn); + system("cat /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3") # > /dev/null 2>&1") + GPIO.output(txLed, txLedOff) +# time.sleep(1) + except: + print("No first image") +# while 1: + GPIO.output(txLed, txLedOff) + if (camera_present == 1): + while 1: + system("raspistill -o /home/pi/CubeSatSim/camera_out.jpg -w 320 -h 256") # > /dev/null 2>&1") + print("Photo taken") + system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/CubeSatSim/camera_out.jpg") print ("Sending SSTV image") GPIO.output(txLed, txLedOn); - system("cat /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3") # > /dev/null 2>&1") + system("cat /home/pi/CubeSatSim/camera_out.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3") # > /dev/null 2>&1") GPIO.output(txLed, txLedOff) -# time.sleep(1) - except: - print("No first image") -# while 1: - GPIO.output(txLed, txLedOff) - if (camera_present == 1): + time.sleep(1) + else: + try: + file = open("/home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg") + print("Second SSTV stored image detected") + system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg") while 1: - system("raspistill -o /home/pi/CubeSatSim/camera_out.jpg -w 320 -h 256") # > /dev/null 2>&1") - print("Photo taken") - system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/CubeSatSim/camera_out.jpg") print ("Sending SSTV image") GPIO.output(txLed, txLedOn); - system("cat /home/pi/CubeSatSim/camera_out.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3") # > /dev/null 2>&1") + system("cat /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3") # > /dev/null 2>&1") + GPIO.output(txLed, txLedOff) + time.sleep(5) + except: + 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 434.9e3 &") + while 1: + GPIO.output(txLed, txLedOn) + time.sleep(60) GPIO.output(txLed, txLedOff) time.sleep(1) - else: - try: - file = open("/home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg") - print("Second SSTV stored image detected") - system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg") - while 1: - print ("Sending SSTV image") - GPIO.output(txLed, txLedOn); - system("cat /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3") # > /dev/null 2>&1") - GPIO.output(txLed, txLedOff) - time.sleep(5) - except: - 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 434.9e3 &") - while 1: - GPIO.output(txLed, txLedOn) - time.sleep(60) - GPIO.output(txLed, txLedOff) - time.sleep(1) - elif (('b' == sys.argv[1]) or ('bpsk' in sys.argv[1])): - print("BPSK") - system("sudo nc -l 8080 | csdr convert_i16_f | csdr fir_interpolate_cc 2 | csdr dsb_fc | csdr bandpass_fir_fft_cc 0.002 0.06 0.01 | csdr fastagc_ff | sudo /home/pi/rpitx/sendiq -i /dev/stdin -s 96000 -f 434.9e6 -t float") - else: - print("FSK") - system("sudo nc -l 8080 | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.9e3") + elif (mode == 'b'): + print("BPSK") + system("sudo nc -l 8080 | csdr convert_i16_f | csdr fir_interpolate_cc 2 | csdr dsb_fc | csdr bandpass_fir_fft_cc 0.002 0.06 0.01 | csdr fastagc_ff | sudo /home/pi/rpitx/sendiq -i /dev/stdin -s 96000 -f 434.9e6 -t float") else: print("FSK") system("sudo nc -l 8080 | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.9e3") +# else: +# print("FSK") +# system("sudo nc -l 8080 | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.9e3") else: print("No Band Pass Filter so no telemetry transmit. See http://cubesatsim.org/wiki for instructions on how to build the BPF.") From 2e453a8416e5f6c6470236c5dbba6a021ad41a5a Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 10 Jun 2021 07:51:42 -0400 Subject: [PATCH 08/21] sleeping only for SSTV --- afsk/main.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/afsk/main.c b/afsk/main.c index ff063199..7d3c0f5e 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -247,6 +247,14 @@ int main(int argc, char * argv[]) { } if (strcmp(sim_yes, "yes") == 0) sim_mode = TRUE; + + if (mode == SSTV) { + + fprintf(stderr, "Sleeping"); + while (1) + sleep(10); + } + wiringPiSetup(); // Check for SPI and AX-5043 Digital Transceiver Board From 8d78bdbc4e474cc4796a06148d762f7f597d8c59 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 10 Jun 2021 07:55:11 -0400 Subject: [PATCH 09/21] just run cubesatsim --- systemd/cubesatsim.service | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/systemd/cubesatsim.service b/systemd/cubesatsim.service index e704d5b8..11966c22 100644 --- a/systemd/cubesatsim.service +++ b/systemd/cubesatsim.service @@ -1,10 +1,9 @@ [Unit] -Description=CubeSatSim demo service +Description=CubeSatSim service [Service] TimeoutStopSec=5 -EnvironmentFile=/home/pi/CubeSatSim/.mode -ExecStart=/home/pi/CubeSatSim/demo.sh $ARG1 +ExecStart=/home/pi/CubeSatSim/cubesatsim WorkingDirectory=/home/pi/CubeSatSim StandardOutput=inherit StandardError=inherit From 752b78b1e545f23c8e2fd1cfaf4cabd17cf78328 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 10 Jun 2021 07:56:09 -0400 Subject: [PATCH 10/21] just run python3 -u rpitx.py --- systemd/rpitx.service | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/systemd/rpitx.service b/systemd/rpitx.service index c58b7bd1..2f2feac2 100644 --- a/systemd/rpitx.service +++ b/systemd/rpitx.service @@ -3,8 +3,7 @@ Description=CubeSatSim rpitx service [Service] TimeoutStopSec=5 -EnvironmentFile=/home/pi/CubeSatSim/.mode -ExecStart=/home/pi/CubeSatSim/rpitx.sh $ARG1 +ExecStart=python3 -u /home/pi/CubeSatSim/rpitx.py WorkingDirectory=/home/pi/CubeSatSim StandardOutput=inherit StandardError=inherit From f1dfe1483b6a3d3a1c4a5c8b2143dc33494a4c67 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 10 Jun 2021 07:59:03 -0400 Subject: [PATCH 11/21] changed .mode to just a, b, f, or s --- config | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/config b/config index f2ed02ab..02ddf9f4 100755 --- a/config +++ b/config @@ -13,13 +13,13 @@ if [ "$1" = "" ]; then echo "$value" > /dev/null set -- $value - if [ "$1" = "ARG1=a" ]; then + if [ "$1" = "a" ]; then echo "APRS mode is set" - elif [ "$1" = "ARG1=f" ]; then + elif [ "$1" = "f" ]; then echo "FSK mode is set" - elif [ "$1" = "ARG1=b" ]; then + elif [ "$1" = "b" ]; then echo "BPSK mode is set" - elif [ "$1" = "ARG1=s" ]; then + elif [ "$1" = "s" ]; then echo "SSTV mode is set" else echo @@ -55,22 +55,22 @@ if [ "$1" = "-i" ]; then exit elif [ "$1" = "-a" ]; then echo "changing CubeSatSim to AFSK mode" - sudo echo "ARG1=a" > /home/pi/CubeSatSim/.mode + sudo echo "a" > /home/pi/CubeSatSim/.mode sudo systemctl restart cubesatsim exit elif [ "$1" = "-f" ]; then echo "changing CubeSatSim to FSK mode" - sudo echo "ARG1=f" > /home/pi/CubeSatSim/.mode + sudo echo "f" > /home/pi/CubeSatSim/.mode sudo systemctl restart cubesatsim exit elif [ "$1" = "-b" ]; then echo "changing CubeSatSim to BPSK mode" - sudo echo "ARG1=b" > /home/pi/CubeSatSim/.mode + sudo echo "b" > /home/pi/CubeSatSim/.mode sudo systemctl restart cubesatsim exit elif [ "$1" = "-s" ]; then echo "changing CubeSatSim to SSTV mode" - sudo echo "ARG1=s" > /home/pi/CubeSatSim/.mode + sudo echo "s" > /home/pi/CubeSatSim/.mode sudo systemctl restart cubesatsim exit elif [ "$1" = "-h" ]; then From 936c5e31f19fe83313d55462c4ae0e556a05b1c6 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 10 Jun 2021 08:12:09 -0400 Subject: [PATCH 12/21] no longer needed with simpler cubesatsim --- demo.sh | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100755 demo.sh diff --git a/demo.sh b/demo.sh deleted file mode 100755 index e25a8214..00000000 --- a/demo.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -echo -e "\nDemo of CubeSatSim at 434.9 MHz\n" - -sudo systemctl restart rpitx - -if [ "$1" = "c" ]; then - echo "Mode cycling" - y=$(last reboot | grep ^reboot | wc -l) - echo $y - echo $(($y % 4)) -fi - -if [[ ("$1" = "a" ) || (("$1" = "c") && ("$(($y %4))" = 3)) ]]; then - echo "Mode is continuous AFSK" - /home/pi/CubeSatSim/cubesatsim afsk -elif [[ ("$1" = "b" ) || (("$1" = "c") && ("$(($y %4))" = 1)) ]]; then - echo "Mode is continuous BPSK" - sudo cpulimit -l 2.5 -b -P cubesatsim - /home/pi/CubeSatSim/cubesatsim bpsk -elif [[ ("$1" = "s" ) || (("$1" = "c") && ("$(($y %4))" = 2)) ]]; then - echo "Mode is continuous SSTV" - while true; do sleep 5; done -else - echo "Mode is continuous FSK" - /home/pi/CubeSatSim/cubesatsim fsk -fi - From ccfcb88f3942b3ae85d18bbc2d666dcef240d960 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 10 Jun 2021 08:12:28 -0400 Subject: [PATCH 13/21] no longer needed with simpler cubesatsim --- rpitx.sh | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100755 rpitx.sh diff --git a/rpitx.sh b/rpitx.sh deleted file mode 100755 index afc736a2..00000000 --- a/rpitx.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -echo -e "\nrpitx for CubeSatSim at 434.9 MHz using python\n" - -if [ "$1" = "c" ]; then - echo "Mode cycling" - y=$(last reboot | grep ^reboot | wc -l) - echo $y - if [ $(($y % 4)) = 3 ]; then - echo "Mode is continuous AFSK" - python3 -u /home/pi/CubeSatSim/rpitx.py a - elif [ $(($y % 4)) = 1 ]; then - echo "Mode is continuous BPSK" - python3 -u /home/pi/CubeSatSim/rpitx.py b - elif [ $(($y % 4)) = 2 ]; then - echo "Mode is continuous SSTV" - python3 -u /home/pi/CubeSatSim/rpitx.py s - else - echo "Mode is continuous FSK" - python3 -u /home/pi/CubeSatSim/rpitx.py f - fi -else - python3 -u /home/pi/CubeSatSim/rpitx.py $1 -fi - From 1112b459a7708bdc8787d0688548895a2e746a8e Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 10 Jun 2021 08:14:57 -0400 Subject: [PATCH 14/21] changed to user pi --- systemd/cubesatsim.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/systemd/cubesatsim.service b/systemd/cubesatsim.service index 11966c22..213fdfea 100644 --- a/systemd/cubesatsim.service +++ b/systemd/cubesatsim.service @@ -8,7 +8,7 @@ WorkingDirectory=/home/pi/CubeSatSim StandardOutput=inherit StandardError=inherit Restart=always -User=root +User=pi CPUAccounting=true CPUQuota=5% From 7f4313bc0db301ec2410ff857aa5b1ca9749b508 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 10 Jun 2021 08:39:46 -0400 Subject: [PATCH 15/21] added toAprsFormat to convert decimal to DMS for lat and long --- afsk/main.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 7d3c0f5e..8bb89db7 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -83,6 +83,7 @@ ax5043_conf_t hax5043; ax25_conf_t hax25; int twosToInt(int val, int len); +float toAprsFormat(float input); float rnd_float(double min, double max); void get_tlm(); void get_tlm_fox(); @@ -242,9 +243,15 @@ int main(int argc, char * argv[]) { if ((fabs(lat_file) > 0) && (fabs(lat_file) < 90.0) && (fabs(long_file) > 0) && (fabs(long_file) < 180.0)) { printf("Valid latitude and longitude in config file\n"); - latitude = lat_file; - longitude = long_file; +// convert to APRS DDMM.MM format + latitude = toAprsFormat(lat_file); + longitude = toAprsFormat(long_file); + printf("Lat/Long in APRS DDMM.MM format: %f/%f\n", latitude, longitude); + } else { // set default + latitude = toAprsFormat(latitude); + longitude = toAprsFormat(longitude); } + if (strcmp(sim_yes, "yes") == 0) sim_mode = TRUE; @@ -2290,3 +2297,12 @@ int test_i2c_bus(int bus) } return(output); // return bus number or -1 if there is a problem with the bus } + +float toAprsFormat(float input) { +// converts decimal coordinate (latitude or longitude) to APRS DDMM.MM format + int dd = (int) input; + int mm1 = (int)((input - dd) * 60.0); + int mm2 = (int)((input - dd - (float)mm1/60.0) * 60.0 * 60.0); + float output = dd * 100 + mm1 + (float)mm2 * 0.01; + return(output); +} From 8852ba8647db5cd3d318d6e76bc3839db4164bea Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 10 Jun 2021 08:45:00 -0400 Subject: [PATCH 16/21] got rid of 100 x lat and long --- afsk/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/afsk/main.c b/afsk/main.c index 8bb89db7..94b8721e 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -940,13 +940,13 @@ void get_tlm(void) { strcat(str, header_str2); // sprintf(header_str2b, "=%7.2f%c%c%c%08.2f%cShi hi ",4003.79,'N',0x5c,0x5c,07534.33,'W'); // add APRS lat and long if (latitude > 0) - sprintf(header_lat, "%7.2f%c", latitude * 100.0, 'N'); // lat + sprintf(header_lat, "%7.2f%c", latitude, 'N'); // lat else - sprintf(header_lat, "%7.2f%c", latitude * (-100.0), 'S'); // lat + sprintf(header_lat, "%7.2f%c", latitude * (-1.0), 'S'); // lat if (longitude > 0) - sprintf(header_long, "%08.2f%c", longitude * 100.0, 'E'); // long + sprintf(header_long, "%08.2f%c", longitude , 'E'); // long else - sprintf(header_long, "%08.2f%c", longitude * (-100.0), 'W'); // long + sprintf(header_long, "%08.2f%c", longitude * (-1.0), 'W'); // long sprintf(header_str2b, "=%s%c%c%sShi hi ", header_lat, 0x5c, 0x5c, header_long); // add APRS lat and long printf("\n\nString is %s \n\n", header_str2b); From e2bd31785dbcdf2fa5be5a77d0816682559d5b8f Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 10 Jun 2021 08:49:41 -0400 Subject: [PATCH 17/21] no sudo on gen_packets --- rpitx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index b459d4d7..6c975ded 100644 --- a/rpitx.py +++ b/rpitx.py @@ -49,7 +49,7 @@ print(callsign) #GPIO.output(27, 1); GPIO.output(txLed, txLedOn); -system("echo 'de " + callsign + "' > id.txt && sudo gen_packets -M 20 /home/pi/CubeSatSim/id.txt -o /home/pi/CubeSatSim/morse.wav -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 434.9e3") +system("echo '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 && 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 434.9e3") #GPIO.output(27, 0); GPIO.output(txLed, txLedOff); From e880a5db734b481815695c411ae02d47e4b99c4b Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 10 Jun 2021 14:30:42 -0400 Subject: [PATCH 18/21] changed tlm[3][A] to go negative --- afsk/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index 94b8721e..ca039eba 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -897,7 +897,8 @@ void get_tlm(void) { tlm[2][C] = (int)(99.5 - current[map[MINUS_Z]] / 10.0) % 100; // -Z current (was timestamp) tlm[2][D] = (int)(50.5 + current[map[BAT]] / 10.0) % 100; // NiMH Battery current - tlm[3][A] = abs((int)((voltage[map[BAT]] * 10.0) - 65.5) % 100); +// tlm[3][A] = abs((int)((voltage[map[BAT]] * 10.0) - 65.5) % 100); + tlm[3][A] = (int)((voltage[map[BAT]] * 10.0) - 65.5) % 100; // allow it to go negative for voltages less than 6.5 V tlm[3][B] = (int)(voltage[map[BUS]] * 10.0) % 100; // 5V supply to Pi tlm[4][B] = (int)((95.8 - cpuTemp) / 1.48 + 0.5) % 100; From a92004b265f877552e06a886ada4b879b73f77dc Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 10 Jun 2021 15:01:30 -0400 Subject: [PATCH 19/21] different encoding for tlm[3][A] for 3 cell battery --- afsk/main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/afsk/main.c b/afsk/main.c index ca039eba..3f1612f3 100644 --- a/afsk/main.c +++ b/afsk/main.c @@ -898,7 +898,11 @@ void get_tlm(void) { tlm[2][D] = (int)(50.5 + current[map[BAT]] / 10.0) % 100; // NiMH Battery current // tlm[3][A] = abs((int)((voltage[map[BAT]] * 10.0) - 65.5) % 100); - tlm[3][A] = (int)((voltage[map[BAT]] * 10.0) - 65.5) % 100; // allow it to go negative for voltages less than 6.5 V + if (voltage[map[BAT]] > 4.6) + tlm[3][A] = (int)((voltage[map[BAT]] * 10.0) - 65.5) % 100; // 7.0 - 10.0 V for old 9V battery + else + tlm[3][A] = (int)((voltage[map[BAT]] * 10.0) + 44.5) % 100; // 0 - 4.5 V for new 3 cell battery + tlm[3][B] = (int)(voltage[map[BUS]] * 10.0) % 100; // 5V supply to Pi tlm[4][B] = (int)((95.8 - cpuTemp) / 1.48 + 0.5) % 100; From ed721137a4f4b945658b077c4c643382f04cd1d7 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 10 Jun 2021 16:49:59 -0400 Subject: [PATCH 20/21] added pull and install for pi-power-button --- update | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/update b/update index 4e9e29b9..c96f5bd6 100755 --- a/update +++ b/update @@ -18,6 +18,14 @@ sudo sed -i 's/more information/more\ninformation/g' /etc/motd sudo sed -i 's/update to/update\nto/g' /etc/motd + +cd /home/pi/pi-power-button && git pull + +script/install + +cd + + cd /home/pi/CubeSatSim git pull > .updated From 8cfebaa695da48f7ffeec39ad67adf88b64f9407 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Thu, 10 Jun 2021 17:04:48 -0400 Subject: [PATCH 21/21] added sstv image copies --- install | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/install b/install index 554de89e..4f0c6b8b 100755 --- a/install +++ b/install @@ -77,6 +77,12 @@ cd PiSSTVpp make pisstvpp +echo "Copying SSTV image 1" +cp /home/pi/CubeSatSim/sstv/sstv_image_1_320_x_256.jpg /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg + +echo "Copying SSTV image 2" +cp /home/pi/CubeSatSim/sstv/sstv_image_2_320_x_256.jpg /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg + cd