From a586edb110a66441926093c805cc94c622bca5f5 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 13 Oct 2023 20:28:34 -0400 Subject: [PATCH 001/174] Update rpitx.py add battery_saver_check each transmit --- rpitx.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index ca21fe4f..2986b35d 100644 --- a/rpitx.py +++ b/rpitx.py @@ -10,6 +10,12 @@ import sys from os import system from PIL import Image, ImageDraw, ImageFont, ImageColor +def battery_saver_check(): + try: + f = open("/home/pi/CubeSatSim/battery_saver") + close(f) + txc = False + def increment_mode(): print("increment mode") powerPin = 16 @@ -191,6 +197,7 @@ else: output(txLed, txLedOn) sleep(1) output(txLed, txLedOff) +battery_saver_check() # print(txLedOn) print(txLed) @@ -269,6 +276,7 @@ if __name__ == "__main__": output(txLed, txLedOn) sleep(0.1) + battery_saver_check() if (txc): system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/morse.wav") else: @@ -312,7 +320,8 @@ if __name__ == "__main__": # output(pd, 1) output (ptt, 0) sleep(.1) - + + battery_saver_check() if (txc): system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/telem.wav") else: @@ -381,6 +390,7 @@ if __name__ == "__main__": output(txLed, txLedOn) output (ptt, 0) sleep(0.1) + battery_saver_check() if (txc): 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") @@ -433,6 +443,7 @@ if __name__ == "__main__": output(txLed, txLedOn) output (ptt, 0) sleep(0.1) + battery_saver_check() if (txc): system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/morse.wav") @@ -483,6 +494,7 @@ if __name__ == "__main__": output(txLed, txLedOn) output(pd, 1) output (ptt, 0) + battery_saver_check() if (txc): system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg.wav") @@ -566,6 +578,7 @@ if __name__ == "__main__": output(txLed, txLedOn) output(pd, 1) output (ptt, 0) + battery_saver_check() if (txc): system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/camera_out.jpg.wav") @@ -592,6 +605,7 @@ if __name__ == "__main__": output(txLed, txLedOn) output(pd, 1) output (ptt, 0) + battery_saver_check() if (txc): system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav") @@ -650,6 +664,7 @@ if __name__ == "__main__": output(txLed, txLedOn) output(pd, 1) output (ptt, 0) + battery_saver_check() if (txc): system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav") @@ -674,6 +689,7 @@ if __name__ == "__main__": output(txLed, txLedOn) output(pd, 1) output (ptt, 0) + battery_saver_check() if (txc): system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/sstv.wav") From c3413618580a6dac797b2a8e50279b3644ef9287 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 13 Oct 2023 20:36:38 -0400 Subject: [PATCH 002/174] Update rpitx.py typo --- rpitx.py | 1 + 1 file changed, 1 insertion(+) diff --git a/rpitx.py b/rpitx.py index 2986b35d..1fa19acf 100644 --- a/rpitx.py +++ b/rpitx.py @@ -15,6 +15,7 @@ def battery_saver_check(): f = open("/home/pi/CubeSatSim/battery_saver") close(f) txc = False + except: def increment_mode(): print("increment mode") From eda4fac4499e6ee683f95391a83a45a2c1557e7b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 13 Oct 2023 20:39:13 -0400 Subject: [PATCH 003/174] Update rpitx.py added pass --- rpitx.py | 1 + 1 file changed, 1 insertion(+) diff --git a/rpitx.py b/rpitx.py index 1fa19acf..e624b772 100644 --- a/rpitx.py +++ b/rpitx.py @@ -16,6 +16,7 @@ def battery_saver_check(): close(f) txc = False except: + pass def increment_mode(): print("increment mode") From 1691bee15c1e8f6ca1e1b0b19c5a04ce48bf39fe Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 13 Oct 2023 20:47:44 -0400 Subject: [PATCH 004/174] Update rpitx.py with prints --- rpitx.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rpitx.py b/rpitx.py index e624b772..887cd7ed 100644 --- a/rpitx.py +++ b/rpitx.py @@ -15,7 +15,9 @@ def battery_saver_check(): f = open("/home/pi/CubeSatSim/battery_saver") close(f) txc = False + print("battery saver activated") except: + print("not activated") pass def increment_mode(): From fec17d51c0127ef24d81b5144e58c5a16b22be7d Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Fri, 13 Oct 2023 20:53:51 -0400 Subject: [PATCH 005/174] Update rpitx.py remove close --- rpitx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index 887cd7ed..57466e96 100644 --- a/rpitx.py +++ b/rpitx.py @@ -13,7 +13,7 @@ from PIL import Image, ImageDraw, ImageFont, ImageColor def battery_saver_check(): try: f = open("/home/pi/CubeSatSim/battery_saver") - close(f) +# close(f) txc = False print("battery saver activated") except: From c41932c9b41a22de2bf483379f21f084d1d5666e Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 14 Oct 2023 09:18:03 -0400 Subject: [PATCH 006/174] Update rpitx.py changed to .close --- rpitx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index 57466e96..8754e9cb 100644 --- a/rpitx.py +++ b/rpitx.py @@ -13,7 +13,7 @@ from PIL import Image, ImageDraw, ImageFont, ImageColor def battery_saver_check(): try: f = open("/home/pi/CubeSatSim/battery_saver") -# close(f) + f.close() txc = False print("battery saver activated") except: From 4181561d651693c03b04df3127cfd6c52d08122f Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 14 Oct 2023 09:20:57 -0400 Subject: [PATCH 007/174] Update rpitx.py added global --- rpitx.py | 1 + 1 file changed, 1 insertion(+) diff --git a/rpitx.py b/rpitx.py index 8754e9cb..96adeddc 100644 --- a/rpitx.py +++ b/rpitx.py @@ -12,6 +12,7 @@ from PIL import Image, ImageDraw, ImageFont, ImageColor def battery_saver_check(): try: + global txc f = open("/home/pi/CubeSatSim/battery_saver") f.close() txc = False From f54751d2eeebe50606a49cbf75c5768e18e61ac0 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 14 Oct 2023 09:32:09 -0400 Subject: [PATCH 008/174] Update rpitx.py txc true when off --- rpitx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index 96adeddc..954956b6 100644 --- a/rpitx.py +++ b/rpitx.py @@ -19,7 +19,7 @@ def battery_saver_check(): print("battery saver activated") except: print("not activated") - pass + txc = True def increment_mode(): print("increment mode") From 322f527e640e3966b3d1470890e24c2e9dbebf99 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 14 Oct 2023 09:36:40 -0400 Subject: [PATCH 009/174] Update rpitx.py added rest of f.close --- rpitx.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index 954956b6..6610b963 100644 --- a/rpitx.py +++ b/rpitx.py @@ -316,6 +316,7 @@ if __name__ == "__main__": while True: try: f = open("/home/pi/CubeSatSim/ready") + f.close() if (debug_mode == 1): print("Packet ready!") system("gen_packets -o /home/pi/CubeSatSim/telem.wav /home/pi/CubeSatSim/t.txt -r 48000 > /dev/null 2>&1") @@ -441,6 +442,7 @@ if __name__ == "__main__": sleep(5) 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("sudo rm /home/pi/CubeSatSim/cwready") @@ -475,7 +477,8 @@ if __name__ == "__main__": # camera = PiCamera() print("Testing for camera") system("raspistill -o /home/pi/CubeSatSim/camera_out.jpg -w 320 -h 256") - f = open("/home/pi/CubeSatSim/camera_out.jpg") + f = open("/home/pi/CubeSatSim/camera_out.jpg") + f.close() print("Camera present") camera_present = 1 # camera.close() From fdaf62ee3c647232be8f7e4faf19654e967dceaa Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 14 Oct 2023 15:10:08 -0400 Subject: [PATCH 010/174] Update rpitx.py not debugging rpitx --- rpitx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index 6610b963..1c20ffc8 100644 --- a/rpitx.py +++ b/rpitx.py @@ -209,7 +209,7 @@ print(txLed) # GPIO.setup(27, GPIO.OUT) # GPIO.output(27, 0) -debug_mode = 1 +debug_mode = 0 #no debugging rpitx if __name__ == "__main__": From d2d1658b04cbdfa54e3f41bc5e9a2028630b9961 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 14 Oct 2023 15:21:08 -0400 Subject: [PATCH 011/174] Update rpitx.py force txc off --- rpitx.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/rpitx.py b/rpitx.py index 1c20ffc8..a6959980 100644 --- a/rpitx.py +++ b/rpitx.py @@ -132,7 +132,7 @@ print("CubeSatSim v1.3b rpitx.py starting...") pd = 21 ptt = 20 -txc = 7 +txc_pin = 7 squelch = 6 green = 16 @@ -143,7 +143,7 @@ GPIO.setwarnings(False) GPIO.setup(13, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(27, GPIO.IN, pull_up_down=GPIO.PUD_UP) -GPIO.setup(7, GPIO.IN, pull_up_down=GPIO.PUD_UP) +GPIO.setup(txc_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(green, GPIO.OUT) GPIO.setup(squelch, GPIO.IN, pull_up_down=GPIO.PUD_UP) ## pull up in case pin is not connected @@ -194,11 +194,13 @@ GPIO.setup(ptt, GPIO.OUT) output (ptt, 1) txc = False -if GPIO.input(7) == False: +if GPIO.input(txc_pin) == False: print("TXC is present") txc = True; else: print("TXC not present") + +txc = False # forcing it off output(txLed, txLedOn) sleep(1) output(txLed, txLedOff) From d65bdf7d28dccb82d0e3642bd3e90a3d3f5f60d4 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 14 Oct 2023 16:51:39 -0400 Subject: [PATCH 012/174] Update rpitx.py use config to change modes --- rpitx.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/rpitx.py b/rpitx.py index a6959980..9a3907b0 100644 --- a/rpitx.py +++ b/rpitx.py @@ -108,21 +108,25 @@ def increment_mode(): sleep(2.5) try: - file = open("/home/pi/CubeSatSim/.mode", "w") +# file = open("/home/pi/CubeSatSim/.mode", "w") # count_string = str(command_count) - file.write(mode) - file.close() - print(".mode file written") +# file.write(mode) +# file.close() +# print(".mode file written") GPIO.setwarnings(False) GPIO.output(txLed, 0) GPIO.output(powerPin, 0) - print("sudo reboot -h now") +# print("sudo reboot -h now") GPIO.setwarnings(False) GPIO.setup(powerPin, GPIO.OUT) - GPIO.output(powerPin, 0); - system("reboot -h now") + GPIO.output(powerPin, 0); +# system("reboot -h now") # release = True; + + print("Changing mode now") + system("/home/pi/CubeSatSim/config -" + mode) + sleep(10); except: print("can't write to .mode file") From 650c46741395abb7b01f0563e45f8dac469aa5ef Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 14 Oct 2023 17:06:55 -0400 Subject: [PATCH 013/174] Update config APRS setting based on battery saver mode --- config | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/config b/config index 6dbc3742..ca0441de 100755 --- a/config +++ b/config @@ -68,7 +68,16 @@ if [ "$1" = "-i" ]; then elif [ "$1" = "-a" ]; then echo "changing CubeSatSim to AFSK mode" sudo echo "a" > /home/pi/CubeSatSim/.mode - sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt + + FILE=/home/pi/CubeSatSim/battery_saver + if [ -f "$FILE" ]; then + echo "Battery saver mode activated." + if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi + else + echo "Not battery saver mode" + sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt + fi + echo "rebooting" sudo reboot now # sudo systemctl restart cubesatsim From dcc3de2616a2af821db5c8e1d721848c0450b085 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 14 Oct 2023 18:55:28 -0400 Subject: [PATCH 014/174] Update rpitx.py turn of txc off forcing --- rpitx.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rpitx.py b/rpitx.py index 9a3907b0..a77d854c 100644 --- a/rpitx.py +++ b/rpitx.py @@ -19,7 +19,7 @@ def battery_saver_check(): print("battery saver activated") except: print("not activated") - txc = True +# txc = True def increment_mode(): print("increment mode") @@ -204,7 +204,7 @@ if GPIO.input(txc_pin) == False: else: print("TXC not present") -txc = False # forcing it off +# txc = False # forcing it off output(txLed, txLedOn) sleep(1) output(txLed, txLedOff) From 576ff98113268d4cf62dbb494c2fe2ff81992861 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 15 Oct 2023 09:00:05 -0400 Subject: [PATCH 015/174] Update rpitx.py debug mode back on --- rpitx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index a77d854c..693b201c 100644 --- a/rpitx.py +++ b/rpitx.py @@ -215,7 +215,7 @@ print(txLed) # GPIO.setup(27, GPIO.OUT) # GPIO.output(27, 0) -debug_mode = 0 #no debugging rpitx +debug_mode = 1 #no debugging rpitx if __name__ == "__main__": From 0dbcc9175e859bc3fafe7c329c24f99952d4f539 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 16 Oct 2023 22:37:41 -0400 Subject: [PATCH 016/174] Update main.c fix typo for HAB mode --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 41dc7d9f..c6795cde 100644 --- a/main.c +++ b/main.c @@ -68,7 +68,7 @@ int main(int argc, char * argv[]) { // sleep(2); #ifdef HAB - Serial.println("HAB mode enabled - balloon icon and BAT only telem and no low voltage shutdown"); + printf("HAB mode enabled - balloon icon and BAT only telem and no low voltage shutdown\n"); #endif // FILE * rpitx_restart = popen("sudo systemctl restart rpitx", "r"); From 2551c3b0cd710980db61bf634849191f50502955 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 7 Nov 2023 15:23:49 -0500 Subject: [PATCH 017/174] Update ina219.py to avoid BrokenPipeError --- ina219.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ina219.py b/ina219.py index 3fb5713e..6f1b44bd 100644 --- a/ina219.py +++ b/ina219.py @@ -7,6 +7,12 @@ import busio from adafruit_extended_bus import ExtendedI2C as I2C from adafruit_ina219 import INA219 from adafruit_ina219 import ADCResolution, BusVoltageRange +import signal + +# Don't turn these signal into exceptions, just die. +# https://stackoverflow.com/questions/26692284/how-to-prevent-brokenpipeerror-when-doing-a-flush-in-python +signal.signal(signal.SIGINT, signal.SIG_DFL) +signal.signal(signal.SIGPIPE, signal.SIG_DFL) if __name__ == "__main__": # print 'Length: ', len(sys.argv) From 2783e455b4720da415b8a6250885982d89eecca9 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 11 Nov 2023 11:48:59 -0500 Subject: [PATCH 018/174] Update rpitx.py added file.close --- rpitx.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index ca21fe4f..ee501fe0 100644 --- a/rpitx.py +++ b/rpitx.py @@ -20,6 +20,7 @@ def increment_mode(): # mode = "f" if (debug_mode == 1): print("Can't open .mode file") # , defaulting to FSK") + file.close() print("Mode is: ") print(mode) if (mode == 'a'): @@ -253,7 +254,8 @@ if __name__ == "__main__": except: callsign = "AMSAT" if (debug_mode == 1): - print("Can't read callsign from sim.cfg file, defaulting to AMSAT") + print("Can't read callsign from sim.cfg file, defaulting to AMSAT") + file.close() print(callsign) GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4 GPIO.setup(txLed, GPIO.OUT) From a52308ab48a0238801b223adced2e862e6d5f740 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 11 Nov 2023 11:54:15 -0500 Subject: [PATCH 019/174] Update main.c added squelch to sim.cfg --- main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index c6795cde..ef8b2213 100644 --- a/main.c +++ b/main.c @@ -152,9 +152,9 @@ int main(int argc, char * argv[]) { // char * cfg_buf[100]; - fscanf(config_file, "%s %d %f %f %s", call, & reset_count, & lat_file, & long_file, sim_yes); + fscanf(config_file, "%s %d %f %f %s %d", call, & reset_count, & lat_file, & long_file, sim_yes, squelch); fclose(config_file); - printf("Config file /home/pi/CubeSatSim/sim.cfg contains %s %d %f %f %s\n", call, reset_count, lat_file, long_file, sim_yes); + printf("Config file /home/pi/CubeSatSim/sim.cfg contains %s %d %f %f %s %d\n", call, reset_count, lat_file, long_file, sim_yes, squelch); reset_count = (reset_count + 1) % 0xffff; if ((fabs(lat_file) > 0) && (fabs(lat_file) < 90.0) && (fabs(long_file) > 0) && (fabs(long_file) < 180.0)) { @@ -298,7 +298,7 @@ int main(int argc, char * argv[]) { } */ config_file = fopen("sim.cfg", "w"); - fprintf(config_file, "%s %d %8.4f %8.4f %s", call, reset_count, lat_file, long_file, sim_yes); + fprintf(config_file, "%s %d %8.4f %8.4f %s %d", call, reset_count, lat_file, long_file, sim_yes,, squelch); // fprintf(config_file, "%s %d", call, reset_count); fclose(config_file); config_file = fopen("sim.cfg", "r"); From 328ef1555cf4d512a9e1c641d17d83c4923bb953 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 11 Nov 2023 11:55:54 -0500 Subject: [PATCH 020/174] Update main.h added squelch = 3 --- main.h | 1 + 1 file changed, 1 insertion(+) diff --git a/main.h b/main.h index 6a9057dc..5b5bdf7d 100644 --- a/main.h +++ b/main.h @@ -123,6 +123,7 @@ float uptime_sec = 0; long int uptime; char call[5]; char sim_yes[10]; +int squelch = 3; // default squelch int bitRate, mode, bufLen, rsFrames, payloads, rsFrameLen, dataLen, headerLen, syncBits, syncWord, parityLen, samples, frameCnt, samplePeriod; float sleepTime; From 10aeddf6b735a121da3909aa05469081f0b5799a Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 11 Nov 2023 12:05:57 -0500 Subject: [PATCH 021/174] Update config added squelch setting --- config | 67 +++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 57 insertions(+), 10 deletions(-) diff --git a/config b/config index 6dbc3742..76ccc3b5 100755 --- a/config +++ b/config @@ -51,7 +51,7 @@ if [ "$1" = "" ]; then echo -e "Current sim.cfg configuration file:" echo - echo $1 $2 $3 $4 $5 + echo $1 $2 $3 $4 $5 $6 echo echo "To change, include an OPTION" @@ -125,6 +125,7 @@ elif [ "$1" = "-h" ]; then echo " -C Clear logs" echo " -T Change command state" echo " -R Change the Commands Count in the file command_count.txt" + echo " -q Change the Squelch setting for command receiver" echo exit @@ -190,7 +191,7 @@ elif [ "$1" = "-c" ]; then echo $1 echo -# echo $1 $2 $3 $4 $5 +# echo $1 $2 $3 $4 $5 $6 echo "Enter callsign in all capitals: " read callsign @@ -204,8 +205,8 @@ elif [ "$1" = "-c" ]; then echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" - echo $callsign $2 $3 $4 $5 - echo $callsign $2 $3 $4 $5 > /home/pi/CubeSatSim/sim.cfg + echo $callsign $2 $3 $4 $5 $6 + echo $callsign $2 $3 $4 $5 $6 > /home/pi/CubeSatSim/sim.cfg fi if [ "$norestart" = "1" ]; then @@ -236,7 +237,7 @@ elif [ "$1" = "-r" ]; then echo $2 echo -# echo $1 $2 $3 $4 $5 +# echo $1 $2 $3 $4 $5 $6 echo -e "Enter Reset Count (integer): " @@ -256,8 +257,8 @@ elif [ "$1" = "-r" ]; then echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" - echo $1 $resets $3 $4 $5 - echo $1 $resets $3 $4 $5 > /home/pi/CubeSatSim/sim.cfg + echo $1 $resets $3 $4 $5 $6 + echo $1 $resets $3 $4 $5 $6 > /home/pi/CubeSatSim/sim.cfg fi if [ "$norestart" = "1" ]; then @@ -289,7 +290,7 @@ elif [ "$1" = "-l" ]; then echo $3 echo -# echo $1 $2 $3 $4 $5 +# echo $1 $2 $3 $4 $5 $6 echo -e "Enter latitude (decimal degrees, positive is north): " @@ -331,8 +332,8 @@ elif [ "$1" = "-l" ]; then fi echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" - echo $1 $2 $lat $long $5 - echo $1 $2 $lat $long $5 > /home/pi/CubeSatSim/sim.cfg + echo $1 $2 $lat $long $5 $6 + echo $1 $2 $lat $long $5 $6 > /home/pi/CubeSatSim/sim.cfg if [ "$norestart" = "1" ]; then echo @@ -420,6 +421,52 @@ elif [ "$1" = "-R" ]; then else echo "Commands count not reset" fi +elif [ "$1" = "-q" ]; then + + echo + echo "Editing the Squelch setting in" + echo "the configuration file for CubeSatSim" + echo + + value=`cat /home/pi/CubeSatSim/sim.cfg` + echo "$value" > /dev/null + set -- $value + + echo + echo "Current value of squelch is" + echo $6 + echo + +# echo $1 $2 $3 $4 $5 $6 + + echo -e "Enter squelch (integer 0 - 8): " + + read sq + + if [ -z $sq ] ; then + + sq="$6" + echo "Keeping value of" $lat + fi + + if ! [[ $sq =~ ^[+-]?[0-9]+([.][0-9]+)?$ ]] ; then + + echo "Error: not a number!" + sq="$6" + echo "Keeping value of" $sq + fi + + echo + echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" + echo + echo $1 $2 $3 $4 $5 $sq + echo $1 $2 $3 $4 $4 $sq > /home/pi/CubeSatSim/sim.cfg + echo + echo "Restarting CubeSatSim with new configuraation file" + echo + + sudo systemctl restart cubesatsim + fi # sudo systemctl restart cubesatsim From 6ba9235c9bdaa30f1182abd6b8144dc33b5e6786 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 11 Nov 2023 12:09:40 -0500 Subject: [PATCH 022/174] Update main.c typo --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index ef8b2213..92c652d6 100644 --- a/main.c +++ b/main.c @@ -298,7 +298,7 @@ int main(int argc, char * argv[]) { } */ config_file = fopen("sim.cfg", "w"); - fprintf(config_file, "%s %d %8.4f %8.4f %s %d", call, reset_count, lat_file, long_file, sim_yes,, squelch); + fprintf(config_file, "%s %d %8.4f %8.4f %s %d", call, reset_count, lat_file, long_file, sim_yes, squelch); // fprintf(config_file, "%s %d", call, reset_count); fclose(config_file); config_file = fopen("sim.cfg", "r"); From d9065d901a1704bcfc5a98bd3e8192a29c6c3114 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 11 Nov 2023 12:16:27 -0500 Subject: [PATCH 023/174] Update config added sq output --- config | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config b/config index 76ccc3b5..40efcb25 100755 --- a/config +++ b/config @@ -48,6 +48,10 @@ if [ "$1" = "" ]; then echo "Current beacon transmit mode is:" cat /home/pi/CubeSatSim/command_tx echo + + echo "Squelch level is:" + echo $6 + echo echo -e "Current sim.cfg configuration file:" echo From 840c1fd8706e79f64acc13897bad9ecd441587b7 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 11 Nov 2023 12:28:09 -0500 Subject: [PATCH 024/174] Update main.c config radio using squelch --- main.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 92c652d6..5e5d5472 100644 --- a/main.c +++ b/main.c @@ -2205,8 +2205,17 @@ if ((uart_fd = serialOpen("/dev/ttyAMA0", 9600)) >= 0) { // was 9600 // mySerial.println("AT+DMOSETGROUP=0,144.3900,144.3900,0,3,0,0\r"); // can change to 144.39 for standard APRS // mySerial.println("AT+DMOSETGROUP=0,145.0000,145.0000,0,3,0,0\r"); // can change to 145 for testing ASPRS //#else - char uhf_string[] = "AT+DMOSETGROUP=0,435.0000,434.9000,0,3,0,0\r\n"; - serialPrintf(uart_fd, uhf_string); + char uhf_string[] = "AT+DMOSETGROUP=0,435.0000,434.9000,0,3,0,0\r\n"; + char uhf_string1[] = "AT+DMOSETGROUP=0,435.0000,434.9100,0,"; // changed frequency to verify + char uhf_string2[] = ",0,0\r\n"; + char sq_string[2]; + sq_string[0] = '0' + squelch; + sq_string[1] = 0; +// serialPrintf(uart_fd, uhf_string); + serialPrintf(uart_fd, uhf_string1); + serialPrintf(uart_fd, sq_string); + serialPrintf(uart_fd, uhf_string2); + // mySerial.println("AT+DMOSETGROUP=0,435.1000,434.9900,0,3,0,0\r"); // squelch set to 3 //#endif sleep(1); From 4b4dcb9edf60f41743c71c5576e7e8bc9c5d1027 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 11 Nov 2023 12:45:32 -0500 Subject: [PATCH 025/174] Update main.c handling telem_string error --- main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 5e5d5472..01842dce 100644 --- a/main.c +++ b/main.c @@ -841,9 +841,12 @@ int main(int argc, char * argv[]) { } #endif FILE * fp = fopen("/home/pi/CubeSatSim/telem_string.txt", "w"); - printf("Writing telem_string.txt\n"); - fprintf(fp, "BAT %4.2fV %5.1fmA\n", batteryVoltage, batteryCurrent); - fclose(fp); + if (fp != NULL) { + printf("Writing telem_string.txt\n"); + fprintf(fp, "BAT %4.2fV %5.1fmA\n", batteryVoltage, batteryCurrent); + fclose(fp); + } else + printf("Error writing to telem_string.txt\n"); /**/ // sleep(1); // Delay 1 second From 25582c8f7f852dbc83421874477f786422f4790a Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 11 Nov 2023 16:02:20 -0500 Subject: [PATCH 026/174] Update main.c added & --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 01842dce..7fd336d1 100644 --- a/main.c +++ b/main.c @@ -152,7 +152,7 @@ int main(int argc, char * argv[]) { // char * cfg_buf[100]; - fscanf(config_file, "%s %d %f %f %s %d", call, & reset_count, & lat_file, & long_file, sim_yes, squelch); + fscanf(config_file, "%s %d %f %f %s %d", call, & reset_count, & lat_file, & long_file, sim_yes, & squelch); fclose(config_file); printf("Config file /home/pi/CubeSatSim/sim.cfg contains %s %d %f %f %s %d\n", call, reset_count, lat_file, long_file, sim_yes, squelch); reset_count = (reset_count + 1) % 0xffff; From 4b8b31d59a62d1daae84d955c322392702928fa0 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 11 Nov 2023 17:09:21 -0500 Subject: [PATCH 027/174] Update rpitx.py get squelch from sim.cfg --- rpitx.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index ee501fe0..0de9c94c 100644 --- a/rpitx.py +++ b/rpitx.py @@ -250,7 +250,15 @@ if __name__ == "__main__": try: file = open("/home/pi/CubeSatSim/sim.cfg") - callsign = file.readline().split(" ")[0] +# callsign = file.readline().split(" ")[0] + config = file.readline().split(" ") + callsign = config[0] + sim = config[4] + squelch = config[5] + print(callsign) + print(sim) + print(squelch) + except: callsign = "AMSAT" if (debug_mode == 1): From 16190e86a3f95177e8958b9ea5cc419fdd06bcdf Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 11 Nov 2023 17:12:24 -0500 Subject: [PATCH 028/174] Update rpitx.py print config --- rpitx.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rpitx.py b/rpitx.py index 0de9c94c..a8a80a25 100644 --- a/rpitx.py +++ b/rpitx.py @@ -255,6 +255,8 @@ if __name__ == "__main__": callsign = config[0] sim = config[4] squelch = config[5] + print(config) + print print(callsign) print(sim) print(squelch) From 583f19f8b71fe4d95c97935307a3980767432ffc Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 11 Nov 2023 17:14:12 -0500 Subject: [PATCH 029/174] Update rpitx.py adjust number --- rpitx.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/rpitx.py b/rpitx.py index a8a80a25..3b02eac8 100644 --- a/rpitx.py +++ b/rpitx.py @@ -253,12 +253,10 @@ if __name__ == "__main__": # callsign = file.readline().split(" ")[0] config = file.readline().split(" ") callsign = config[0] - sim = config[4] - squelch = config[5] + squelch = config[10] print(config) print print(callsign) - print(sim) print(squelch) except: From f5d2302bc8a43060c59c70509be40a1a5f68ce61 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 12 Nov 2023 09:28:02 -0500 Subject: [PATCH 030/174] Update rpitx.py turn off command if squelch is 8 --- rpitx.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rpitx.py b/rpitx.py index 3b02eac8..2fe777a8 100644 --- a/rpitx.py +++ b/rpitx.py @@ -258,6 +258,11 @@ if __name__ == "__main__": print print(callsign) print(squelch) + if squelch == 8: + print("squelch set to 8, no command input!") + no_command = True + else: + no_command = False except: callsign = "AMSAT" From 239f089660ced5ee70ecd69c4cad883419562dbe Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 12 Nov 2023 09:35:28 -0500 Subject: [PATCH 031/174] Update rpitx.py split on whitespace --- rpitx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index 2fe777a8..ad7283d4 100644 --- a/rpitx.py +++ b/rpitx.py @@ -251,7 +251,7 @@ if __name__ == "__main__": try: file = open("/home/pi/CubeSatSim/sim.cfg") # callsign = file.readline().split(" ")[0] - config = file.readline().split(" ") + config = file.readline().split() callsign = config[0] squelch = config[10] print(config) From c0d2fe4c0e2d35c025f119700a68330ff828cf80 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 12 Nov 2023 09:39:58 -0500 Subject: [PATCH 032/174] Update rpitx.py changed to last --- rpitx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index ad7283d4..149dba69 100644 --- a/rpitx.py +++ b/rpitx.py @@ -253,7 +253,7 @@ if __name__ == "__main__": # callsign = file.readline().split(" ")[0] config = file.readline().split() callsign = config[0] - squelch = config[10] + squelch = config[last] print(config) print print(callsign) From 2831d5cd0e6236b2e74463f74b1770ae1f9dce0b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 12 Nov 2023 09:42:59 -0500 Subject: [PATCH 033/174] Update rpitx.py changed to 5 --- rpitx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index 149dba69..95d14741 100644 --- a/rpitx.py +++ b/rpitx.py @@ -253,7 +253,7 @@ if __name__ == "__main__": # callsign = file.readline().split(" ")[0] config = file.readline().split() callsign = config[0] - squelch = config[last] + squelch = config[5] print(config) print print(callsign) From 04263ca23e0040c7487276de54424051cb32a252 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 12 Nov 2023 09:50:08 -0500 Subject: [PATCH 034/174] Update config fixed -t --- config | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config b/config index 40efcb25..5dc1e373 100755 --- a/config +++ b/config @@ -152,7 +152,7 @@ elif [ "$1" = "-t" ]; then echo -# echo $1 $2 $3 $4 +# echo $1 $2 $3 $4 $5 $6 echo "Do you want Simulated Telemetry ON (y/n) " read sim @@ -169,8 +169,8 @@ elif [ "$1" = "-t" ]; then echo echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" echo - echo $1 $2 $3 $4 $sim - echo $1 $2 $3 $4 $sim > /home/pi/CubeSatSim/sim.cfg + echo $1 $2 $3 $4 $sim $6 + echo $1 $2 $3 $4 $sim $6 > /home/pi/CubeSatSim/sim.cfg echo echo "Restarting CubeSatSim with new configuraation file" echo From f75502f8cd68a29a1c8febd463e9f2bbdfc57c8d Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 12 Nov 2023 10:08:26 -0500 Subject: [PATCH 035/174] Update rpitx.py print no_command --- rpitx.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rpitx.py b/rpitx.py index 95d14741..2fb3409d 100644 --- a/rpitx.py +++ b/rpitx.py @@ -256,14 +256,14 @@ if __name__ == "__main__": squelch = config[5] print(config) print - print(callsign) +# print(callsign) print(squelch) if squelch == 8: print("squelch set to 8, no command input!") no_command = True else: no_command = False - + print(no_command) except: callsign = "AMSAT" if (debug_mode == 1): From a43f47172fc5f63157b089ff905bbad1716b3f6c Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 12 Nov 2023 10:13:55 -0500 Subject: [PATCH 036/174] Update rpitx.py changed squelch to sq --- rpitx.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rpitx.py b/rpitx.py index 2fb3409d..23a81467 100644 --- a/rpitx.py +++ b/rpitx.py @@ -253,12 +253,12 @@ if __name__ == "__main__": # callsign = file.readline().split(" ")[0] config = file.readline().split() callsign = config[0] - squelch = config[5] + sq = config[5] print(config) print # print(callsign) - print(squelch) - if squelch == 8: + print(sq) + if sq == 8: print("squelch set to 8, no command input!") no_command = True else: From e4deee809f029b9798f072641ac473a09fd62f1e Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 12 Nov 2023 10:22:10 -0500 Subject: [PATCH 037/174] Update rpitx.py changed 8 to '8' --- rpitx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index 23a81467..5fc26bd7 100644 --- a/rpitx.py +++ b/rpitx.py @@ -258,7 +258,7 @@ if __name__ == "__main__": print # print(callsign) print(sq) - if sq == 8: + if sq == '8': print("squelch set to 8, no command input!") no_command = True else: From 0951067e2905b029dc583fc6eb0d27fe2c9581f5 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 12 Nov 2023 10:37:27 -0500 Subject: [PATCH 038/174] Update main.c change back to 434.9 --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 7fd336d1..11e31118 100644 --- a/main.c +++ b/main.c @@ -2209,7 +2209,7 @@ if ((uart_fd = serialOpen("/dev/ttyAMA0", 9600)) >= 0) { // was 9600 // mySerial.println("AT+DMOSETGROUP=0,145.0000,145.0000,0,3,0,0\r"); // can change to 145 for testing ASPRS //#else char uhf_string[] = "AT+DMOSETGROUP=0,435.0000,434.9000,0,3,0,0\r\n"; - char uhf_string1[] = "AT+DMOSETGROUP=0,435.0000,434.9100,0,"; // changed frequency to verify + char uhf_string1[] = "AT+DMOSETGROUP=0,435.0000,434.9000,0,"; // changed frequency to verify char uhf_string2[] = ",0,0\r\n"; char sq_string[2]; sq_string[0] = '0' + squelch; From 4921e95cba8c7323b8958a02162aeac60b065ef7 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 13 Nov 2023 15:51:29 -0500 Subject: [PATCH 039/174] Update main.c adding tx rx frequencies --- main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 11e31118..ba841b77 100644 --- a/main.c +++ b/main.c @@ -152,9 +152,10 @@ int main(int argc, char * argv[]) { // char * cfg_buf[100]; - fscanf(config_file, "%s %d %f %f %s %d", call, & reset_count, & lat_file, & long_file, sim_yes, & squelch); + fscanf(config_file, "%s %d %f %f %s %d %s %s", call, & reset_count, & lat_file, & long_file, sim_yes, & squelch, tx, rx); fclose(config_file); - printf("Config file /home/pi/CubeSatSim/sim.cfg contains %s %d %f %f %s %d\n", call, reset_count, lat_file, long_file, sim_yes, squelch); + printf("Config file /home/pi/CubeSatSim/sim.cfg contains %s %d %f %f %s %d %s %s\n", + call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx); reset_count = (reset_count + 1) % 0xffff; if ((fabs(lat_file) > 0) && (fabs(lat_file) < 90.0) && (fabs(long_file) > 0) && (fabs(long_file) < 180.0)) { @@ -298,7 +299,7 @@ int main(int argc, char * argv[]) { } */ config_file = fopen("sim.cfg", "w"); - fprintf(config_file, "%s %d %8.4f %8.4f %s %d", call, reset_count, lat_file, long_file, sim_yes, squelch); + fprintf(config_file, "%s %d %8.4f %8.4f %s %d %s %s", call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx); // fprintf(config_file, "%s %d", call, reset_count); fclose(config_file); config_file = fopen("sim.cfg", "r"); From 3cf2791e480af0034310d3f1b0923ad9ab7d0423 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 13 Nov 2023 15:52:21 -0500 Subject: [PATCH 040/174] Update main.h adding tx rx --- main.h | 1 + 1 file changed, 1 insertion(+) diff --git a/main.h b/main.h index 5b5bdf7d..8495cc54 100644 --- a/main.h +++ b/main.h @@ -124,6 +124,7 @@ long int uptime; char call[5]; char sim_yes[10]; int squelch = 3; // default squelch +char rx[12], tx[12]; int bitRate, mode, bufLen, rsFrames, payloads, rsFrameLen, dataLen, headerLen, syncBits, syncWord, parityLen, samples, frameCnt, samplePeriod; float sleepTime; From 263deb3766d195f4f9d9f944dfb301f99f05b551 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 13 Nov 2023 16:03:06 -0500 Subject: [PATCH 041/174] Update config adding -F change rx and tx frequency --- config | 90 +++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 74 insertions(+), 16 deletions(-) diff --git a/config b/config index 5dc1e373..07a29287 100755 --- a/config +++ b/config @@ -55,7 +55,7 @@ if [ "$1" = "" ]; then echo -e "Current sim.cfg configuration file:" echo - echo $1 $2 $3 $4 $5 $6 + echo $1 $2 $3 $4 $5 $6 $7 $8 echo echo "To change, include an OPTION" @@ -130,6 +130,7 @@ elif [ "$1" = "-h" ]; then echo " -T Change command state" echo " -R Change the Commands Count in the file command_count.txt" echo " -q Change the Squelch setting for command receiver" + echo " -F Change the rx and tx frequency" echo exit @@ -152,7 +153,7 @@ elif [ "$1" = "-t" ]; then echo -# echo $1 $2 $3 $4 $5 $6 +# echo $1 $2 $3 $4 $5 $6 $7 $8 echo "Do you want Simulated Telemetry ON (y/n) " read sim @@ -169,8 +170,8 @@ elif [ "$1" = "-t" ]; then echo echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" echo - echo $1 $2 $3 $4 $sim $6 - echo $1 $2 $3 $4 $sim $6 > /home/pi/CubeSatSim/sim.cfg + echo $1 $2 $3 $4 $sim $6 $7 $8 + echo $1 $2 $3 $4 $sim $6 $7 $8 > /home/pi/CubeSatSim/sim.cfg echo echo "Restarting CubeSatSim with new configuraation file" echo @@ -195,7 +196,7 @@ elif [ "$1" = "-c" ]; then echo $1 echo -# echo $1 $2 $3 $4 $5 $6 +# echo $1 $2 $3 $4 $5 $6 $7 $8 echo "Enter callsign in all capitals: " read callsign @@ -209,8 +210,8 @@ elif [ "$1" = "-c" ]; then echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" - echo $callsign $2 $3 $4 $5 $6 - echo $callsign $2 $3 $4 $5 $6 > /home/pi/CubeSatSim/sim.cfg + echo $callsign $2 $3 $4 $5 $6 $7 $8 + echo $callsign $2 $3 $4 $5 $6 $7 $8 > /home/pi/CubeSatSim/sim.cfg fi if [ "$norestart" = "1" ]; then @@ -241,7 +242,7 @@ elif [ "$1" = "-r" ]; then echo $2 echo -# echo $1 $2 $3 $4 $5 $6 +# echo $1 $2 $3 $4 $5 $6 $7 $8 echo -e "Enter Reset Count (integer): " @@ -261,8 +262,8 @@ elif [ "$1" = "-r" ]; then echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" - echo $1 $resets $3 $4 $5 $6 - echo $1 $resets $3 $4 $5 $6 > /home/pi/CubeSatSim/sim.cfg + echo $1 $resets $3 $4 $5 $6 $7 $8 + echo $1 $resets $3 $4 $5 $6 $7 $8 > /home/pi/CubeSatSim/sim.cfg fi if [ "$norestart" = "1" ]; then @@ -294,7 +295,7 @@ elif [ "$1" = "-l" ]; then echo $3 echo -# echo $1 $2 $3 $4 $5 $6 +# echo $1 $2 $3 $4 $5 $6 $7 $8 echo -e "Enter latitude (decimal degrees, positive is north): " @@ -336,8 +337,8 @@ elif [ "$1" = "-l" ]; then fi echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" - echo $1 $2 $lat $long $5 $6 - echo $1 $2 $lat $long $5 $6 > /home/pi/CubeSatSim/sim.cfg + echo $1 $2 $lat $long $5 $6 $7 $8 + echo $1 $2 $lat $long $5 $6 $7 $8 > /home/pi/CubeSatSim/sim.cfg if [ "$norestart" = "1" ]; then echo @@ -441,7 +442,7 @@ elif [ "$1" = "-q" ]; then echo $6 echo -# echo $1 $2 $3 $4 $5 $6 +# echo $1 $2 $3 $4 $5 $6 $7 $8 echo -e "Enter squelch (integer 0 - 8): " @@ -463,14 +464,71 @@ elif [ "$1" = "-q" ]; then echo echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" echo - echo $1 $2 $3 $4 $5 $sq - echo $1 $2 $3 $4 $4 $sq > /home/pi/CubeSatSim/sim.cfg + echo $1 $2 $3 $4 $5 $sq $7 $8 + echo $1 $2 $3 $4 $4 $sq $7 $8 > /home/pi/CubeSatSim/sim.cfg echo echo "Restarting CubeSatSim with new configuraation file" echo sudo systemctl restart cubesatsim + +elif [ "$1" = "-F" ]; then + + echo + echo "Editing the tx and rx frequency in the" + echo "configuration file for CubeSatSim" + echo + echo "Return keeps current value." +# echo -e "Current sim.cfg configuration file:" +# echo + + value=`cat /home/pi/CubeSatSim/sim.cfg` + echo "$value" > /dev/null + set -- $value + + echo "Current value of tx is" + echo $7 + echo + echo "Current value of rx is" + echo $8 + echo + +# echo $1 $2 $3 $4 $5 $6 $7 $8 + + echo "Enter tx frequency as 4XX.XXXX: " + read tx + + if [ -z $tx ] ; then + + tx="$7" + echo "Keeping value of" $tx + fi + + echo "Enter rx frequency as 4XX.XXXX: " + read rx + + if [ -z $rx ] ; then + + rx="$8" + echo "Keeping value of" $rx + +# else + echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" + + echo $callsign $2 $3 $4 $5 $6 $7 $8 + echo $callsign $2 $3 $4 $5 $6 $7 $8 > /home/pi/CubeSatSim/sim.cfg + fi + +# if [ "$norestart" = "1" ]; then +# echo +# else + echo + echo "Restarting CubeSatSim with new configuraation file" + echo + sudo systemctl restart cubesatsim +# fi + fi # sudo systemctl restart cubesatsim From dae91105a1bba33b35cc9441095a54285b8a1b06 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 13 Nov 2023 16:11:39 -0500 Subject: [PATCH 042/174] Update config update config --- config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config b/config index 07a29287..8e0bec00 100755 --- a/config +++ b/config @@ -517,7 +517,7 @@ elif [ "$1" = "-F" ]; then echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" echo $callsign $2 $3 $4 $5 $6 $7 $8 - echo $callsign $2 $3 $4 $5 $6 $7 $8 > /home/pi/CubeSatSim/sim.cfg + echo $callsign $2 $3 $4 $5 $6 $tx $rx > /home/pi/CubeSatSim/sim.cfg fi # if [ "$norestart" = "1" ]; then From 0ce4735487a5240ea22e10e24d0e9fb0bad75370 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 13 Nov 2023 16:13:17 -0500 Subject: [PATCH 043/174] Update config update for real --- config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config b/config index 8e0bec00..aefd8757 100755 --- a/config +++ b/config @@ -511,14 +511,14 @@ elif [ "$1" = "-F" ]; then rx="$8" echo "Keeping value of" $rx - + fi # else echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" echo $callsign $2 $3 $4 $5 $6 $7 $8 echo $callsign $2 $3 $4 $5 $6 $tx $rx > /home/pi/CubeSatSim/sim.cfg - fi +# fi # if [ "$norestart" = "1" ]; then # echo From fe952653073406e6f871c96831ed3e4aae58c936 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 13 Nov 2023 16:17:33 -0500 Subject: [PATCH 044/174] Update config display new rx tx --- config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config b/config index aefd8757..63a4a632 100755 --- a/config +++ b/config @@ -516,7 +516,7 @@ elif [ "$1" = "-F" ]; then echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" - echo $callsign $2 $3 $4 $5 $6 $7 $8 + echo $callsign $2 $3 $4 $5 $6 $tx $rx echo $callsign $2 $3 $4 $5 $6 $tx $rx > /home/pi/CubeSatSim/sim.cfg # fi From 7b333c8f499cdfbae1e4382e50b56bf9e54313ea Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 13 Nov 2023 16:20:21 -0500 Subject: [PATCH 045/174] Update config don't override callsign --- config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config b/config index 63a4a632..26dc1a9d 100755 --- a/config +++ b/config @@ -516,8 +516,8 @@ elif [ "$1" = "-F" ]; then echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" - echo $callsign $2 $3 $4 $5 $6 $tx $rx - echo $callsign $2 $3 $4 $5 $6 $tx $rx > /home/pi/CubeSatSim/sim.cfg + echo $1 $2 $3 $4 $5 $6 $tx $rx + echo $1 $2 $3 $4 $5 $6 $tx $rx > /home/pi/CubeSatSim/sim.cfg # fi # if [ "$norestart" = "1" ]; then From 9ee32cb03a7ddb17a2470803548b2ec422993779 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 13 Nov 2023 16:28:33 -0500 Subject: [PATCH 046/174] Update rpitx.py read tx and rx from sim.cfg --- rpitx.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index 5fc26bd7..8992f1a8 100644 --- a/rpitx.py +++ b/rpitx.py @@ -253,7 +253,20 @@ if __name__ == "__main__": # callsign = file.readline().split(" ")[0] config = file.readline().split() callsign = config[0] - sq = config[5] + if len(config) > 5: + sq = config[5] + else: + sq = '0' + if len(config) > 6: + tx = config[6] + print(tx) + else: + tx = '434.9000' + if len(config) > 7: + rx = config[7] + print(rx) + else: + rx = '435.0000' print(config) print # print(callsign) From 05bde2ada4e177bc3855c03f6a9ad90e95050f06 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 13 Nov 2023 16:33:00 -0500 Subject: [PATCH 047/174] Update rpitx.py force CW ID rpitx using tx --- rpitx.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rpitx.py b/rpitx.py index 8992f1a8..19956033 100644 --- a/rpitx.py +++ b/rpitx.py @@ -187,6 +187,7 @@ txc = False if GPIO.input(7) == False: print("TXC is present") txc = True; + txc = False; else: print("TXC not present") output(txLed, txLedOn) @@ -301,9 +302,11 @@ if __name__ == "__main__": system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/morse.wav") else: if (debug_mode == 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 && 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 '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 && 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 '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 && 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("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 && 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 > /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 && 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 > /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 && 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 ab62d1df72cf6df0a91c6bb246714cc51c25527f Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 13 Nov 2023 16:40:55 -0500 Subject: [PATCH 048/174] Update rpitx.py add tx for BPSK --- rpitx.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index 19956033..418da492 100644 --- a/rpitx.py +++ b/rpitx.py @@ -721,7 +721,8 @@ if __name__ == "__main__": output(pd, 1) output(ptt, 1) if (command_tx == True): - 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 &") +# 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 &") + 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 " + tx + "e6 -t float &") print("Turning LED on/off and listening for carrier") while 1: output(txLed, txLedOff) From e48a5880bec53ba025e1f68953b4ce866d11cecc Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 13 Nov 2023 16:45:37 -0500 Subject: [PATCH 049/174] Update rpitx.py FSK and BPSK use tx, force txc off --- rpitx.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/rpitx.py b/rpitx.py index 418da492..ccd77162 100644 --- a/rpitx.py +++ b/rpitx.py @@ -187,7 +187,6 @@ txc = False if GPIO.input(7) == False: print("TXC is present") txc = True; - txc = False; else: print("TXC not present") output(txLed, txLedOn) @@ -754,7 +753,7 @@ if __name__ == "__main__": if (command_tx == True): print("Turning on transmit") system("echo > command_tx True") - 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 &") + 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 " + tx + "e6 -t float &") else: print("Turning off transmit") # and rebooting") system("echo > command_tx False") @@ -770,7 +769,7 @@ if __name__ == "__main__": output(pd, 1) output(ptt, 1) if (command_tx == True): - 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 &") + 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 " + tx + "e3 &") print("Turning LED on/off and listening for carrier") while 1: output(txLed, txLedOff) @@ -802,7 +801,7 @@ if __name__ == "__main__": if (command_tx == True): print("Turning on transmit") system("echo > command_tx True") - 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 &") + 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 " + tx + "e3 &") else: print("Turning of transmit and rebooting") system("echo > command_tx False") From f40f703f6c126647f7136d861e86767723230f30 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 13 Nov 2023 16:50:16 -0500 Subject: [PATCH 050/174] Update rpitx.py change all 434.9 to tx --- rpitx.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/rpitx.py b/rpitx.py index ccd77162..684311c1 100644 --- a/rpitx.py +++ b/rpitx.py @@ -347,9 +347,9 @@ if __name__ == "__main__": system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/telem.wav") else: if (debug_mode == 1): - system("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") + system("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 " + tx + "e3") else: - system("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") + system("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 " + tx + "e3 > /dev/null 2>&1") sleep(0.1) output (ptt, 1) @@ -416,9 +416,9 @@ if __name__ == "__main__": 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") 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 434.9e3") + 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 434.9e3 > /dev/null 2>&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 > /dev/null 2>&1") output(txLed, txLedOff) output (ptt, 1) @@ -468,9 +468,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 434.9e3") + 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 434.9e3 > /dev/null 2>&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 > /dev/null 2>&1") sleep(0.1) output(txLed, txLedOff) @@ -518,9 +518,9 @@ if __name__ == "__main__": system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg.wav") else: if (debug_mode == 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") + 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 " + tx + "e3") else: - 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/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 " + tx + "e3 > /dev/null 2>&1") output(txLed, txLedOff) output (ptt, 1) @@ -601,9 +601,9 @@ if __name__ == "__main__": system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/camera_out.jpg.wav") else: if (debug_mode == 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") + 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 " + tx + "e3") else: - 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/camera_out.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3 > /dev/null 2>&1") output(txLed, txLedOff) output (ptt, 1) @@ -627,9 +627,9 @@ if __name__ == "__main__": system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav") else: if (debug_mode == 1): - system("cat /home/pi/CubeSatSim/sstv_image_1_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") + system("cat /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3") else: - system("cat /home/pi/CubeSatSim/sstv_image_1_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/sstv_image_1_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3 > /dev/null 2>&1") output(txLed, txLedOff) output (ptt, 1) @@ -685,9 +685,9 @@ if __name__ == "__main__": system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav") else: if (debug_mode == 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") + 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 " + tx + "e3") else: - 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/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 " + tx + "e3 > /dev/null 2>&1") output(txLed, txLedOff) output (ptt, 1) @@ -697,7 +697,7 @@ if __name__ == "__main__": print("image 2 did not load - copy from CubeSatSim/sstv directory") if (txc == False): if (command_tx == True): - 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 &") + 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): From 19a0745b8ab92a2a7ac711e6c3d855d0fc1e26b8 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 13 Nov 2023 16:57:49 -0500 Subject: [PATCH 051/174] Update main.c set FM to tx and rx --- main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index ba841b77..206bbb37 100644 --- a/main.c +++ b/main.c @@ -2210,13 +2210,20 @@ if ((uart_fd = serialOpen("/dev/ttyAMA0", 9600)) >= 0) { // was 9600 // mySerial.println("AT+DMOSETGROUP=0,145.0000,145.0000,0,3,0,0\r"); // can change to 145 for testing ASPRS //#else char uhf_string[] = "AT+DMOSETGROUP=0,435.0000,434.9000,0,3,0,0\r\n"; + char uhf_string1a[] = "AT+DMOSETGROUP=0,"; // changed frequency to verify + char comma[] = ","; + char uhf_string1b[] = ",0,"; // changed frequency to verify char uhf_string1[] = "AT+DMOSETGROUP=0,435.0000,434.9000,0,"; // changed frequency to verify char uhf_string2[] = ",0,0\r\n"; char sq_string[2]; sq_string[0] = '0' + squelch; sq_string[1] = 0; // serialPrintf(uart_fd, uhf_string); - serialPrintf(uart_fd, uhf_string1); + serialPrintf(uart_fd, uhf_string1a); + serialPrintf(uart_fd, tx); + serialPrintf(uart_fd, comma); + serialPrintf(uart_fd, rx); + serialPrintf(uart_fd, uhf_string1b); serialPrintf(uart_fd, sq_string); serialPrintf(uart_fd, uhf_string2); From 625d740308393b051eaa3458c3fefd4ed5d7091d Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 13 Nov 2023 17:03:25 -0500 Subject: [PATCH 052/174] Update main.c print tx and rx --- main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/main.c b/main.c index 206bbb37..2f3ce8a4 100644 --- a/main.c +++ b/main.c @@ -156,6 +156,9 @@ int main(int argc, char * argv[]) { fclose(config_file); printf("Config file /home/pi/CubeSatSim/sim.cfg contains %s %d %f %f %s %d %s %s\n", call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx); + + printf("==%s==%s==\n", tx, rx); + reset_count = (reset_count + 1) % 0xffff; if ((fabs(lat_file) > 0) && (fabs(lat_file) < 90.0) && (fabs(long_file) > 0) && (fabs(long_file) < 180.0)) { From 4fdda4c1c3cd5f6e4c6bd86ad55652695e650cc8 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 13 Nov 2023 17:07:55 -0500 Subject: [PATCH 053/174] Update main.c move program_radio() --- main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 2f3ce8a4..2fad1886 100644 --- a/main.c +++ b/main.c @@ -46,9 +46,7 @@ int main(int argc, char * argv[]) { printf("\n\nCubeSatSim v1.3b starting...\n\n"); wiringPiSetup(); - - program_radio(); - + // FILE * rpitx_stop = popen("sudo systemctl stop rpitx", "r"); FILE * rpitx_stop = popen("sudo systemctl restart rpitx", "r"); pclose(rpitx_stop); @@ -159,6 +157,8 @@ int main(int argc, char * argv[]) { printf("==%s==%s==\n", tx, rx); + program_radio(); + reset_count = (reset_count + 1) % 0xffff; if ((fabs(lat_file) > 0) && (fabs(lat_file) < 90.0) && (fabs(long_file) > 0) && (fabs(long_file) < 180.0)) { From c52d0f9666635e881961daa659aa1e1ece1ad6c7 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 13 Nov 2023 17:20:11 -0500 Subject: [PATCH 054/174] Update main.c basic program_radio --- main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 2fad1886..2ca7190f 100644 --- a/main.c +++ b/main.c @@ -2221,7 +2221,9 @@ if ((uart_fd = serialOpen("/dev/ttyAMA0", 9600)) >= 0) { // was 9600 char sq_string[2]; sq_string[0] = '0' + squelch; sq_string[1] = 0; -// serialPrintf(uart_fd, uhf_string); + + serialPrintf(uart_fd, uhf_string); +/* serialPrintf(uart_fd, uhf_string1a); serialPrintf(uart_fd, tx); serialPrintf(uart_fd, comma); @@ -2229,6 +2231,7 @@ if ((uart_fd = serialOpen("/dev/ttyAMA0", 9600)) >= 0) { // was 9600 serialPrintf(uart_fd, uhf_string1b); serialPrintf(uart_fd, sq_string); serialPrintf(uart_fd, uhf_string2); +*/ // mySerial.println("AT+DMOSETGROUP=0,435.1000,434.9900,0,3,0,0\r"); // squelch set to 3 //#endif From cff2f123eb9531069739e4c534d2bc347dfe98a7 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 13 Nov 2023 17:24:27 -0500 Subject: [PATCH 055/174] Update main.c move program_radio back to start --- main.c | 88 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/main.c b/main.c index 2ca7190f..e3a71d2b 100644 --- a/main.c +++ b/main.c @@ -45,7 +45,50 @@ int main(int argc, char * argv[]) { printf("\n\nCubeSatSim v1.3b starting...\n\n"); - wiringPiSetup(); + // Open configuration file with callsign and reset count + FILE * config_file = fopen("/home/pi/CubeSatSim/sim.cfg", "r"); + if (config_file == NULL) { + printf("Creating config file."); + config_file = fopen("/home/pi/CubeSatSim/sim.cfg", "w"); + fprintf(config_file, "%s %d", " ", 100); + fclose(config_file); + config_file = fopen("/home/pi/CubeSatSim/sim.cfg", "r"); + } + +// char * cfg_buf[100]; + + fscanf(config_file, "%s %d %f %f %s %d %s %s", call, & reset_count, & lat_file, & long_file, sim_yes, & squelch, tx, rx); + fclose(config_file); + printf("Config file /home/pi/CubeSatSim/sim.cfg contains %s %d %f %f %s %d %s %s\n", + call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx); + + printf("==%s==%s==\n", tx, rx); + + program_radio(); + + reset_count = (reset_count + 1) % 0xffff; + + 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"); +// convert to APRS DDMM.MM format +// latitude = toAprsFormat(lat_file); +// longitude = toAprsFormat(long_file); + latitude = lat_file; + longitude = long_file; + printf("Lat/Long %f %f\n", latitude, longitude); + printf("Lat/Long in APRS DDMM.MM format: %07.2f/%08.2f\n", toAprsFormat(latitude), toAprsFormat(longitude)); + newGpsTime = millis(); + + } else { // set default +// latitude = toAprsFormat(latitude); +// longitude = toAprsFormat(longitude); + newGpsTime = millis(); + } + + if (strcmp(sim_yes, "yes") == 0) + sim_mode = TRUE; + + wiringPiSetup(); // FILE * rpitx_stop = popen("sudo systemctl stop rpitx", "r"); FILE * rpitx_stop = popen("sudo systemctl restart rpitx", "r"); @@ -137,49 +180,6 @@ int main(int argc, char * argv[]) { fclose(telem_file); printf("Opened telem file\n"); - - // Open configuration file with callsign and reset count - FILE * config_file = fopen("/home/pi/CubeSatSim/sim.cfg", "r"); - if (config_file == NULL) { - printf("Creating config file."); - config_file = fopen("/home/pi/CubeSatSim/sim.cfg", "w"); - fprintf(config_file, "%s %d", " ", 100); - fclose(config_file); - config_file = fopen("/home/pi/CubeSatSim/sim.cfg", "r"); - } - -// char * cfg_buf[100]; - - fscanf(config_file, "%s %d %f %f %s %d %s %s", call, & reset_count, & lat_file, & long_file, sim_yes, & squelch, tx, rx); - fclose(config_file); - printf("Config file /home/pi/CubeSatSim/sim.cfg contains %s %d %f %f %s %d %s %s\n", - call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx); - - printf("==%s==%s==\n", tx, rx); - - program_radio(); - - reset_count = (reset_count + 1) % 0xffff; - - 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"); -// convert to APRS DDMM.MM format -// latitude = toAprsFormat(lat_file); -// longitude = toAprsFormat(long_file); - latitude = lat_file; - longitude = long_file; - printf("Lat/Long %f %f\n", latitude, longitude); - printf("Lat/Long in APRS DDMM.MM format: %07.2f/%08.2f\n", toAprsFormat(latitude), toAprsFormat(longitude)); - newGpsTime = millis(); - - } else { // set default -// latitude = toAprsFormat(latitude); -// longitude = toAprsFormat(longitude); - newGpsTime = millis(); - } - - if (strcmp(sim_yes, "yes") == 0) - sim_mode = TRUE; if (mode == AFSK) { From b8d4f5ea49a3e0478f68d891e449c0d7522f1a5a Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 13 Nov 2023 17:28:05 -0500 Subject: [PATCH 056/174] Update main.c back to normal programradio --- main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index e3a71d2b..d515a214 100644 --- a/main.c +++ b/main.c @@ -2222,8 +2222,8 @@ if ((uart_fd = serialOpen("/dev/ttyAMA0", 9600)) >= 0) { // was 9600 sq_string[0] = '0' + squelch; sq_string[1] = 0; - serialPrintf(uart_fd, uhf_string); -/* +// serialPrintf(uart_fd, uhf_string); +/**/ serialPrintf(uart_fd, uhf_string1a); serialPrintf(uart_fd, tx); serialPrintf(uart_fd, comma); @@ -2231,7 +2231,7 @@ if ((uart_fd = serialOpen("/dev/ttyAMA0", 9600)) >= 0) { // was 9600 serialPrintf(uart_fd, uhf_string1b); serialPrintf(uart_fd, sq_string); serialPrintf(uart_fd, uhf_string2); -*/ +/**/ // mySerial.println("AT+DMOSETGROUP=0,435.1000,434.9900,0,3,0,0\r"); // squelch set to 3 //#endif From b95b42c7ee932ae16293be5df7b73b9b1b609da4 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 13 Nov 2023 17:29:35 -0500 Subject: [PATCH 057/174] Update main.c move wiring pi setup --- main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index d515a214..8832e6cf 100644 --- a/main.c +++ b/main.c @@ -45,6 +45,8 @@ int main(int argc, char * argv[]) { printf("\n\nCubeSatSim v1.3b starting...\n\n"); + wiringPiSetup(); + // Open configuration file with callsign and reset count FILE * config_file = fopen("/home/pi/CubeSatSim/sim.cfg", "r"); if (config_file == NULL) { @@ -88,8 +90,6 @@ int main(int argc, char * argv[]) { if (strcmp(sim_yes, "yes") == 0) sim_mode = TRUE; - wiringPiSetup(); - // FILE * rpitx_stop = popen("sudo systemctl stop rpitx", "r"); FILE * rpitx_stop = popen("sudo systemctl restart rpitx", "r"); pclose(rpitx_stop); From 7ed88f97750ea88d5cc979c14e9a444400f6f3d4 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 13 Nov 2023 17:32:16 -0500 Subject: [PATCH 058/174] Update main.c swapped rx and tx --- main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 8832e6cf..318c8eaa 100644 --- a/main.c +++ b/main.c @@ -2225,9 +2225,9 @@ if ((uart_fd = serialOpen("/dev/ttyAMA0", 9600)) >= 0) { // was 9600 // serialPrintf(uart_fd, uhf_string); /**/ serialPrintf(uart_fd, uhf_string1a); - serialPrintf(uart_fd, tx); - serialPrintf(uart_fd, comma); serialPrintf(uart_fd, rx); + serialPrintf(uart_fd, comma); + serialPrintf(uart_fd, tx); serialPrintf(uart_fd, uhf_string1b); serialPrintf(uart_fd, sq_string); serialPrintf(uart_fd, uhf_string2); From ecb01928c8e7387fa53e7cf8cd3471423fbad1da Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 14 Nov 2023 08:44:30 -0500 Subject: [PATCH 059/174] Update main.c disable program radio - do in rpitx.py instead --- main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 318c8eaa..4f7878cd 100644 --- a/main.c +++ b/main.c @@ -64,9 +64,9 @@ int main(int argc, char * argv[]) { printf("Config file /home/pi/CubeSatSim/sim.cfg contains %s %d %f %f %s %d %s %s\n", call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx); - printf("==%s==%s==\n", tx, rx); + printf("Transmit on %s Receive on %s\n", tx, rx); - program_radio(); +// program_radio(); // do in rpitx instead reset_count = (reset_count + 1) % 0xffff; From 4a518700c7899ee05f0d08679a7d6abebf95b055 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 14 Nov 2023 08:58:29 -0500 Subject: [PATCH 060/174] Update rpitx.py added program radio --- rpitx.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/rpitx.py b/rpitx.py index 684311c1..200a2533 100644 --- a/rpitx.py +++ b/rpitx.py @@ -9,6 +9,7 @@ from time import sleep import sys from os import system from PIL import Image, ImageDraw, ImageFont, ImageColor +import serial def increment_mode(): print("increment mode") @@ -285,6 +286,19 @@ if __name__ == "__main__": print(callsign) GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4 GPIO.setup(txLed, GPIO.OUT) + + print("Programming FM module!\n"); + output(pd, 1) + output (ptt, 1) + + ser = serial.Serial("/dev/ttyAMA0", 9600) + print(ser.portstr) + for i in range(6): + ser.write("AT+DMOSETGROUP=0,435.0000,434.9100,0,3,0,0\r\n") + sleep(0.1) + ser.close() + + output(pd, 0) sleep(10) # delay so cubesatsim code catches up From 2ff39ec7f7984c2bc8addcdc50ee5dd17f7b8bcf Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 14 Nov 2023 09:05:10 -0500 Subject: [PATCH 061/174] Update rpitx.py change to bytes --- rpitx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index 200a2533..37da585b 100644 --- a/rpitx.py +++ b/rpitx.py @@ -294,7 +294,7 @@ if __name__ == "__main__": ser = serial.Serial("/dev/ttyAMA0", 9600) print(ser.portstr) for i in range(6): - ser.write("AT+DMOSETGROUP=0,435.0000,434.9100,0,3,0,0\r\n") + ser.write(b"AT+DMOSETGROUP=0,435.0000,434.9100,0,3,0,0\r\n") sleep(0.1) ser.close() From ef73a3cebc259079aef90fa4d464a2418eee4762 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 14 Nov 2023 09:07:50 -0500 Subject: [PATCH 062/174] Update rpitx.py add try for serial --- rpitx.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/rpitx.py b/rpitx.py index 37da585b..cd1b7184 100644 --- a/rpitx.py +++ b/rpitx.py @@ -291,11 +291,14 @@ if __name__ == "__main__": output(pd, 1) output (ptt, 1) - ser = serial.Serial("/dev/ttyAMA0", 9600) - print(ser.portstr) - for i in range(6): - ser.write(b"AT+DMOSETGROUP=0,435.0000,434.9100,0,3,0,0\r\n") - sleep(0.1) + try: + ser = serial.Serial("/dev/ttyAMA0", 9600) + print(ser.portstr) + for i in range(6): + ser.write(b"AT+DMOSETGROUP=0,435.0000,434.9200,0,3,0,0\r\n") + sleep(0.1) + except: + print("Error in serial write") ser.close() output(pd, 0) From a0b8119ffdbd4a6ef24d021a12997b34a564b0bc Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 14 Nov 2023 09:10:17 -0500 Subject: [PATCH 063/174] Update rpitx.py with tx and rx --- rpitx.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index cd1b7184..7b912aa5 100644 --- a/rpitx.py +++ b/rpitx.py @@ -295,7 +295,8 @@ if __name__ == "__main__": ser = serial.Serial("/dev/ttyAMA0", 9600) print(ser.portstr) for i in range(6): - ser.write(b"AT+DMOSETGROUP=0,435.0000,434.9200,0,3,0,0\r\n") +# ser.write(b"AT+DMOSETGROUP=0,435.0000,434.9000,0,3,0,0\r\n") + ser.write(b"AT+DMOSETGROUP=0," + rx +"," + tx + ",0,3,0,0\r\n") sleep(0.1) except: print("Error in serial write") From eb291934bdf46b5328206be375d9d411475438f2 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 14 Nov 2023 09:13:58 -0500 Subject: [PATCH 064/174] Update rpitx.py fix string to bytes --- rpitx.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index 7b912aa5..6127ffce 100644 --- a/rpitx.py +++ b/rpitx.py @@ -294,9 +294,10 @@ if __name__ == "__main__": try: ser = serial.Serial("/dev/ttyAMA0", 9600) print(ser.portstr) + uhf_string = "AT+DMOSETGROUP=0," + rx +"," + tx + ",0,3,0,0\r\n" for i in range(6): # ser.write(b"AT+DMOSETGROUP=0,435.0000,434.9000,0,3,0,0\r\n") - ser.write(b"AT+DMOSETGROUP=0," + rx +"," + tx + ",0,3,0,0\r\n") + ser.write(uhf_string.encode()) sleep(0.1) except: print("Error in serial write") From 725d384dbbe542e9576a99fc4f50163a6b498ca3 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 14 Nov 2023 10:22:43 -0500 Subject: [PATCH 065/174] Update config remove pin 18 func 2 for aprs battery saver --- config | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config b/config index ca0441de..1814eabd 100755 --- a/config +++ b/config @@ -73,9 +73,11 @@ elif [ "$1" = "-a" ]; then if [ -f "$FILE" ]; then echo "Battery saver mode activated." if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi + sudo sed -i ':a;N;$!ba;s/\ndtoverlay=pwm,pin=18,func=2//g' /boot/config.txt else echo "Not battery saver mode" sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt + if ! grep -q dtoverlay=pwm,pin=18,func=2 /boot/config.txt ; then sudo sh -c 'echo "\ndtoverlay=pwm,pin=18,func=2" >> /boot/config.txt'; fi fi echo "rebooting" From 74bc31405d782c5112386f3fda86697e7889da09 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 14 Nov 2023 16:12:27 -0500 Subject: [PATCH 066/174] Update config remove more from config.txt --- config | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config b/config index 1814eabd..59021a5c 100755 --- a/config +++ b/config @@ -74,10 +74,12 @@ elif [ "$1" = "-a" ]; then echo "Battery saver mode activated." if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi sudo sed -i ':a;N;$!ba;s/\ndtoverlay=pwm,pin=18,func=2//g' /boot/config.txt + sudo sed -i ':a;N;$!ba;s/\ndtoverlay=audremap,enable_jack=on//g' /boot/config.txt else echo "Not battery saver mode" sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt if ! grep -q dtoverlay=pwm,pin=18,func=2 /boot/config.txt ; then sudo sh -c 'echo "\ndtoverlay=pwm,pin=18,func=2" >> /boot/config.txt'; fi + if ! grep -q dtoverlay=audremap,enable_jack=on /boot/config.txt ; then sudo sh -c 'echo "\ndtoverlay=audremap,enable_jack=on" >> /boot/config.txt'; fi fi echo "rebooting" From 84b81c563b0f603b1a3d6e84819a740f930fe5a4 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 14 Nov 2023 16:32:07 -0500 Subject: [PATCH 067/174] Update rpitx.py don't activate FM module when txc False aprs --- rpitx.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/rpitx.py b/rpitx.py index 693b201c..36227efe 100644 --- a/rpitx.py +++ b/rpitx.py @@ -282,24 +282,24 @@ if __name__ == "__main__": # if (mode != 'a') and (command_tx == True): if (command_tx == True): - output(pd, 1) - output (ptt, 0) - output(txLed, txLedOn) - sleep(0.1) - battery_saver_check() + output(txLed, txLedOn) if (txc): - system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/morse.wav") + output(pd, 1) + output (ptt, 0) + sleep(0.1) + 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("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 && 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") else: 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 && 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 > /dev/null 2>&1") - sleep(0.1) output(txLed, txLedOff) - output (ptt, 1) - output(pd, 0) + sleep(1) else: print("Don't transmit CW ID since command_tx is False or APRS mode") From 3642fda98b0a930dc97066cb6d9c2e99a92371ec Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 14 Nov 2023 16:38:56 -0500 Subject: [PATCH 068/174] Update rpitx.py fix aprs --- rpitx.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/rpitx.py b/rpitx.py index 36227efe..1fd1996c 100644 --- a/rpitx.py +++ b/rpitx.py @@ -330,12 +330,18 @@ if __name__ == "__main__": if (command_tx == True): output(txLed, txLedOn) # output(pd, 1) - output (ptt, 0) - sleep(.1) +# output (ptt, 0) +# sleep(.1) battery_saver_check() if (txc): - system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/telem.wav") + output(pd, 1) + output (ptt, 0) + sleep(0.1) + system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/telem.wav") + sleep(0.1) + output (ptt, 1) + output(pd, 0) else: if (debug_mode == 1): system("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") @@ -343,7 +349,7 @@ if __name__ == "__main__": system("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") sleep(0.1) - output (ptt, 1) +# output (ptt, 1) # output(pd, 0) output(txLed, txLedOff) system("sudo rm /home/pi/CubeSatSim/ready") From d9b03237699cdec8ec7bb3e76f72ed26d4fa97cc Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 14 Nov 2023 16:44:57 -0500 Subject: [PATCH 069/174] Update rpitx.py fix sstv --- rpitx.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/rpitx.py b/rpitx.py index 1fd1996c..a54a479b 100644 --- a/rpitx.py +++ b/rpitx.py @@ -512,12 +512,14 @@ if __name__ == "__main__": if (command_tx == True): print ("Sending SSTV image") output(txLed, txLedOn) - output(pd, 1) - output (ptt, 0) battery_saver_check() if (txc): + output(pd, 1) + output (ptt, 0) system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg.wav") + output (ptt, 1) + output(pd, 0) else: if (debug_mode == 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") @@ -525,8 +527,7 @@ if __name__ == "__main__": 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") output(txLed, txLedOff) - output (ptt, 1) - output(pd, 0) + # sleep(1) except: print("image 2 did not load - copy from CubeSatSim/sstv directory") From 8ddce2131d9a9077ca1247bbe4060046ef7eafa2 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 14 Nov 2023 16:58:46 -0500 Subject: [PATCH 070/174] Update config fixed config aprs change --- config | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config b/config index 59021a5c..74f13c52 100755 --- a/config +++ b/config @@ -73,13 +73,13 @@ elif [ "$1" = "-a" ]; then if [ -f "$FILE" ]; then echo "Battery saver mode activated." if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi - sudo sed -i ':a;N;$!ba;s/\ndtoverlay=pwm,pin=18,func=2//g' /boot/config.txt - sudo sed -i ':a;N;$!ba;s/\ndtoverlay=audremap,enable_jack=on//g' /boot/config.txt +# sudo sed -i ':a;N;$!ba;s/\ndtoverlay=pwm,pin=18,func=2//g' /boot/config.txt +# sudo sed -i ':a;N;$!ba;s/\ndtoverlay=audremap,enable_jack=on//g' /boot/config.txt else echo "Not battery saver mode" sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt - if ! grep -q dtoverlay=pwm,pin=18,func=2 /boot/config.txt ; then sudo sh -c 'echo "\ndtoverlay=pwm,pin=18,func=2" >> /boot/config.txt'; fi - if ! grep -q dtoverlay=audremap,enable_jack=on /boot/config.txt ; then sudo sh -c 'echo "\ndtoverlay=audremap,enable_jack=on" >> /boot/config.txt'; fi +# if ! grep -q dtoverlay=pwm,pin=18,func=2 /boot/config.txt ; then sudo sh -c 'echo "\ndtoverlay=pwm,pin=18,func=2" >> /boot/config.txt'; fi +# if ! grep -q dtoverlay=audremap,enable_jack=on /boot/config.txt ; then sudo sh -c 'echo "\ndtoverlay=audremap,enable_jack=on" >> /boot/config.txt'; fi fi echo "rebooting" From 19812e46c688330d96f3afdd7845de862c813cef Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 14 Nov 2023 17:20:03 -0500 Subject: [PATCH 071/174] Update rpitx.py more txc cleanup --- rpitx.py | 60 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/rpitx.py b/rpitx.py index a54a479b..d301e968 100644 --- a/rpitx.py +++ b/rpitx.py @@ -311,7 +311,7 @@ if __name__ == "__main__": # if (len(sys.argv)) > 1: # print("There are arguments!") if (mode == 'a'): - output(pd, 1) +# output(pd, 1) print("AFSK") # sleep(5) ## try: @@ -406,12 +406,17 @@ if __name__ == "__main__": if (command_tx == True): output(txLed, txLedOn) - output (ptt, 0) - sleep(0.1) 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 434.9e3") @@ -419,7 +424,7 @@ if __name__ == "__main__": 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 434.9e3 > /dev/null 2>&1") output(txLed, txLedOff) - output (ptt, 1) +# output (ptt, 1) sleep(5) while True: if (no_command == False and GPIO.input(squelch) == False): @@ -501,8 +506,8 @@ if __name__ == "__main__": # while 1: output(txLed, txLedOff) - output (ptt, 1) - output(pd, 0) +# output (ptt, 1) +# output(pd, 0) if (camera_present == 1): try: file = open("/home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg") @@ -597,12 +602,14 @@ if __name__ == "__main__": if (command_tx == True): print ("Sending SSTV image") output(txLed, txLedOn) - output(pd, 1) - output (ptt, 0) battery_saver_check() if (txc): + output(pd, 1) + output (ptt, 0) system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/camera_out.jpg.wav") + output(ptt, 1) + output (pd, 0) else: if (debug_mode == 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") @@ -610,9 +617,9 @@ if __name__ == "__main__": 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") output(txLed, txLedOff) - output (ptt, 1) +# output (ptt, 1) - output(pd, 0) +# output(pd, 0) system("sudo rm /home/pi/CubeSatSim/camera_out.jpg.wav > /dev/null 2>&1") sleep(1) else: @@ -624,12 +631,15 @@ if __name__ == "__main__": print ("Sending SSTV image") output(txLed, txLedOn) - output(pd, 1) - output (ptt, 0) + battery_saver_check() if (txc): + output(pd, 1) + output (ptt, 0) system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav") + output(ptt, 1) + output (pd, 0) else: if (debug_mode == 1): system("cat /home/pi/CubeSatSim/sstv_image_1_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") @@ -637,8 +647,8 @@ if __name__ == "__main__": system("cat /home/pi/CubeSatSim/sstv_image_1_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") output(txLed, txLedOff) - output (ptt, 1) - output(pd, 0) +# output (ptt, 1) +# output(pd, 0) sleep(1) except: print("image 1 did not load - copy from CubeSatSim/sstv directory") @@ -678,17 +688,19 @@ if __name__ == "__main__": else: print("Turning off transmit") system("echo > command_tx False") - output(pd, 0) +# output(pd, 0) if (command_tx == True): print ("Sending SSTV image") output(txLed, txLedOn) - output(pd, 1) - output (ptt, 0) battery_saver_check() if (txc): + output(pd, 1) + output (ptt, 0) system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav") + output(ptt, 1) + output (pd, 0) else: if (debug_mode == 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") @@ -696,8 +708,8 @@ if __name__ == "__main__": 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") output(txLed, txLedOff) - output (ptt, 1) - output(pd, 0) +# output (ptt, 1) +# output(pd, 0) sleep(5) except: print("image 2 did not load - copy from CubeSatSim/sstv directory") @@ -708,18 +720,20 @@ if __name__ == "__main__": if (command_tx == True): output(txLed, txLedOn) - output(pd, 1) - output (ptt, 0) battery_saver_check() if (txc): + output(pd, 1) + output (ptt, 0) system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/sstv.wav") + output(ptt, 1) + output (pd, 0) else: sleep(60) output(txLed, txLedOff) - output (ptt, 1) - output(pd, 0) +# output (ptt, 1) +# output(pd, 0) sleep(1) elif (mode == 'b'): print("BPSK") From 0fbbac2e5c88df138c0be5e5d97dc0f5559b8942 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 15 Nov 2023 17:41:03 -0500 Subject: [PATCH 072/174] Update main.c added extra echo --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 41dc7d9f..35088460 100644 --- a/main.c +++ b/main.c @@ -992,7 +992,7 @@ void get_tlm(void) { // 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 - char footer_str[] = " && 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 if (ax5043) { strcpy(str, header_str); From 48314e65f62dde3c59e77d06f7ac2bd554be8db3 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 15 Nov 2023 22:29:11 -0500 Subject: [PATCH 073/174] Update config manual battery saver, change modes a,s,m --- config | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 53 insertions(+), 6 deletions(-) diff --git a/config b/config index 74f13c52..40ea295d 100755 --- a/config +++ b/config @@ -73,13 +73,9 @@ elif [ "$1" = "-a" ]; then if [ -f "$FILE" ]; then echo "Battery saver mode activated." if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi -# sudo sed -i ':a;N;$!ba;s/\ndtoverlay=pwm,pin=18,func=2//g' /boot/config.txt -# sudo sed -i ':a;N;$!ba;s/\ndtoverlay=audremap,enable_jack=on//g' /boot/config.txt else echo "Not battery saver mode" sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt -# if ! grep -q dtoverlay=pwm,pin=18,func=2 /boot/config.txt ; then sudo sh -c 'echo "\ndtoverlay=pwm,pin=18,func=2" >> /boot/config.txt'; fi -# if ! grep -q dtoverlay=audremap,enable_jack=on /boot/config.txt ; then sudo sh -c 'echo "\ndtoverlay=audremap,enable_jack=on" >> /boot/config.txt'; fi fi echo "rebooting" @@ -89,7 +85,15 @@ elif [ "$1" = "-a" ]; then elif [ "$1" = "-m" ]; then echo "changing CubeSatSim to CW mode" sudo echo "m" > /home/pi/CubeSatSim/.mode - sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt + + FILE=/home/pi/CubeSatSim/battery_saver + if [ -f "$FILE" ]; then + echo "Battery saver mode activated." + if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi + else + echo "Not battery saver mode" + sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt + fi echo "rebooting" sudo reboot now # sudo systemctl restart cubesatsim @@ -113,7 +117,15 @@ elif [ "$1" = "-b" ]; then elif [ "$1" = "-s" ]; then echo "changing CubeSatSim to SSTV mode" sudo echo "s" > /home/pi/CubeSatSim/.mode - sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt + + FILE=/home/pi/CubeSatSim/battery_saver + if [ -f "$FILE" ]; then + echo "Battery saver mode activated." + if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi + else + echo "Not battery saver mode" + sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt + fi echo "rebooting" sudo reboot now # sudo systemctl restart cubesatsim @@ -138,6 +150,7 @@ elif [ "$1" = "-h" ]; then echo " -C Clear logs" echo " -T Change command state" echo " -R Change the Commands Count in the file command_count.txt" + echo " -B Change battery saver mode manually" echo exit @@ -433,6 +446,40 @@ elif [ "$1" = "-R" ]; then else echo "Commands count not reset" fi + +elif [ "$1" = "-B" ]; then + + echo + echo "Manually setting battery saver mode" + echo + + FILE=/home/pi/CubeSatSim/battery_saver + if [ -f "$FILE" ]; then + echo "Battery saver mode is activated." + mode=1 + else + echo "Battery saver mode is not activated." + mode=0 + fi + + echo + + echo "Do you want Battery saver mode ON (y/n) " + read saver + echo + + if [ "$saver" = "y" ] || [ "$saver" = "yes" ] ; then + echo "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" + sudo rm /home/pi/CubeSatSim/battery_saver +# if ["$mode" = "1"] ; then sudo systemctl restart rpitx + fi + +# sudo systemctl restart cubesatsim + fi # sudo systemctl restart cubesatsim From a3e849c11d6092d50512e8315d920b537f0ff4f3 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 15 Nov 2023 22:41:38 -0500 Subject: [PATCH 074/174] Update main.h add battery_saver function --- main.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main.h b/main.h index 6a9057dc..bb7bd4ff 100644 --- a/main.h +++ b/main.h @@ -173,3 +173,5 @@ int end_flag_detected = FALSE; int jpeg_start = 0; #define CAMERA_TIMEOUT 10000 // 20000 // Camera timeout in milli seconds +int battery_saver(); + From 63d307423d78d0693414b255dc8794a86d24f45c Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 15 Nov 2023 22:44:41 -0500 Subject: [PATCH 075/174] Update main.h add CHECK --- main.h | 1 + 1 file changed, 1 insertion(+) diff --git a/main.h b/main.h index bb7bd4ff..4735427c 100644 --- a/main.h +++ b/main.h @@ -54,6 +54,7 @@ #define OFF - 1 #define ON 1 +#define CHECK 0 uint32_t tx_freq_hz = 434900000 + FREQUENCY_OFFSET; uint8_t data[1024]; From 76f300541fc90c4364691b5b15b0af3f551b056b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 15 Nov 2023 22:56:05 -0500 Subject: [PATCH 076/174] Update main.c add battery_saver function --- main.c | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 35088460..2140cb91 100644 --- a/main.c +++ b/main.c @@ -816,8 +816,14 @@ int main(int argc, char * argv[]) { // if ((batteryVoltage > 1.0) && (batteryVoltage < batteryThreshold)) // no battery INA219 will give 0V, no battery plugged into INA219 will read < 1V /**/ -#ifndef HAB - if ((batteryCurrent > currentThreshold) && (batteryVoltage < voltageThreshold) && !sim_mode) // currentThreshold ensures that this won't happen when running on DC power. +#ifndef HAB + if ((batteryCurrent > currentThreshold) && (batteryVoltage < (voltageThreshold + 0.15)) && !sim_mode) + { + battery_saver(ON); + } else if ((battery_saver(CHECK)) && (batteryCurrent < 0)) + { + battery_saver(OFF); + } else if ((batteryCurrent > currentThreshold) && (batteryVoltage < voltageThreshold) && !sim_mode) // currentThreshold ensures that this won't happen when running on DC power. { fprintf(stderr, "Battery voltage too low: %f V - shutting down!\n", batteryVoltage); digitalWrite(txLed, txLedOff); @@ -2230,3 +2236,34 @@ if ((uart_fd = serialOpen("/dev/ttyAMA0", 9600)) >= 0) { // was 9600 serialClose(uart_fd); } + +int battery_saver(int setting) { + if (setting == CHECK) { + *FILE file = fopen("/home/pi/CubeSatSim/battery_saver", "r"); + if (file == NULL) { + printf("Battery saver mode is OFF\n"); + fclose(file); + return(0); + } + fclose(file); + printf("Battery saver mode is ON\n"); + return(1); + + } else if (setting == ON) { + FILE *command = popen("touch /home/pi/CubeSatSim/battery_saver", "r"); + pclose(command); + printf("Turning Battery saver mode ON\n"); + return(1); + + } else if (setting == OFF) { + FILE *command = popen("sudo rm /home/pi/CubeSatSim/battery_saver", "r"); + pclose(command); + printf("Turning Battery saver mode OFF\n"); + return(1); + + } else { + printf("battery_saver function error"); + return(0); + } + return(2); +} From 5f39728cb3fbeae0eee9ff06252c0209c361269a Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 16 Nov 2023 08:02:56 -0500 Subject: [PATCH 077/174] Update main.c typo file --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 2140cb91..21453ea4 100644 --- a/main.c +++ b/main.c @@ -2239,7 +2239,7 @@ if ((uart_fd = serialOpen("/dev/ttyAMA0", 9600)) >= 0) { // was 9600 int battery_saver(int setting) { if (setting == CHECK) { - *FILE file = fopen("/home/pi/CubeSatSim/battery_saver", "r"); + FILE *file = fopen("/home/pi/CubeSatSim/battery_saver", "r"); if (file == NULL) { printf("Battery saver mode is OFF\n"); fclose(file); From cb54b365c39726c53cc77a14956917d2e945e51b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 16 Nov 2023 08:13:40 -0500 Subject: [PATCH 078/174] Update main.h --- main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.h b/main.h index 4735427c..7f4d04a0 100644 --- a/main.h +++ b/main.h @@ -174,5 +174,5 @@ int end_flag_detected = FALSE; int jpeg_start = 0; #define CAMERA_TIMEOUT 10000 // 20000 // Camera timeout in milli seconds -int battery_saver(); +int battery_saver(int setting); From 8e9ad630f32d57d1740d9b75f012dfdf08dd859e Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 16 Nov 2023 08:16:01 -0500 Subject: [PATCH 079/174] Update ina219.py remove signals --- ina219.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ina219.py b/ina219.py index 3fb5713e..6f1b44bd 100644 --- a/ina219.py +++ b/ina219.py @@ -7,6 +7,12 @@ import busio from adafruit_extended_bus import ExtendedI2C as I2C from adafruit_ina219 import INA219 from adafruit_ina219 import ADCResolution, BusVoltageRange +import signal + +# Don't turn these signal into exceptions, just die. +# https://stackoverflow.com/questions/26692284/how-to-prevent-brokenpipeerror-when-doing-a-flush-in-python +signal.signal(signal.SIGINT, signal.SIG_DFL) +signal.signal(signal.SIGPIPE, signal.SIG_DFL) if __name__ == "__main__": # print 'Length: ', len(sys.argv) From a8c760d85f30d493b9869ea11fb92f78315c5107 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 16 Nov 2023 08:38:28 -0500 Subject: [PATCH 080/174] Update main.c (void) battery_saver --- main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 21453ea4..72d4d11f 100644 --- a/main.c +++ b/main.c @@ -819,10 +819,10 @@ int main(int argc, char * argv[]) { #ifndef HAB if ((batteryCurrent > currentThreshold) && (batteryVoltage < (voltageThreshold + 0.15)) && !sim_mode) { - battery_saver(ON); + (void)battery_saver(ON); } else if ((battery_saver(CHECK)) && (batteryCurrent < 0)) { - battery_saver(OFF); + (void)battery_saver(OFF); } else if ((batteryCurrent > currentThreshold) && (batteryVoltage < voltageThreshold) && !sim_mode) // currentThreshold ensures that this won't happen when running on DC power. { fprintf(stderr, "Battery voltage too low: %f V - shutting down!\n", batteryVoltage); From c826869a53ffcc64b0b15e2ff29873cc9ddd74f5 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 16 Nov 2023 08:45:32 -0500 Subject: [PATCH 081/174] Update main.c typo in HAB mode --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 72d4d11f..46f9f67b 100644 --- a/main.c +++ b/main.c @@ -68,7 +68,7 @@ int main(int argc, char * argv[]) { // sleep(2); #ifdef HAB - Serial.println("HAB mode enabled - balloon icon and BAT only telem and no low voltage shutdown"); + printf("HAB mode enabled - balloon icon and BAT only telem and no low voltage shutdown\n"); #endif // FILE * rpitx_restart = popen("sudo systemctl restart rpitx", "r"); From 1d5c4ca59578b6a2959db78107080b740e0803f2 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 16 Nov 2023 08:51:38 -0500 Subject: [PATCH 082/174] Update main.c added int battery_saver_check() --- main.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/main.c b/main.c index 46f9f67b..1c17c6ce 100644 --- a/main.c +++ b/main.c @@ -819,10 +819,10 @@ int main(int argc, char * argv[]) { #ifndef HAB if ((batteryCurrent > currentThreshold) && (batteryVoltage < (voltageThreshold + 0.15)) && !sim_mode) { - (void)battery_saver(ON); - } else if ((battery_saver(CHECK)) && (batteryCurrent < 0)) + battery_saver(ON); + } else if ((battery_saver_check()) && (batteryCurrent < 0)) { - (void)battery_saver(OFF); + battery_saver(OFF); } else if ((batteryCurrent > currentThreshold) && (batteryVoltage < voltageThreshold) && !sim_mode) // currentThreshold ensures that this won't happen when running on DC power. { fprintf(stderr, "Battery voltage too low: %f V - shutting down!\n", batteryVoltage); @@ -2237,33 +2237,34 @@ if ((uart_fd = serialOpen("/dev/ttyAMA0", 9600)) >= 0) { // was 9600 serialClose(uart_fd); } -int battery_saver(int setting) { - if (setting == CHECK) { - FILE *file = fopen("/home/pi/CubeSatSim/battery_saver", "r"); +int battery_saver_check() { + FILE *file = fopen("/home/pi/CubeSatSim/battery_saver", "r"); if (file == NULL) { - printf("Battery saver mode is OFF\n"); + printf("Battery saver mode is OFF\n"); fclose(file); return(0); - } + } fclose(file); - printf("Battery saver mode is ON\n"); + printf("Battery saver mode is ON\n"); return(1); - - } else if (setting == ON) { +} + +void battery_saver(int setting) { +if (setting == ON) { FILE *command = popen("touch /home/pi/CubeSatSim/battery_saver", "r"); pclose(command); printf("Turning Battery saver mode ON\n"); - return(1); + return; } else if (setting == OFF) { FILE *command = popen("sudo rm /home/pi/CubeSatSim/battery_saver", "r"); pclose(command); printf("Turning Battery saver mode OFF\n"); - return(1); + return; } else { printf("battery_saver function error"); - return(0); + return; } - return(2); + return; } From 629f299be2e13d5abdae94b2f671ed0d4cddb222 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 16 Nov 2023 08:52:17 -0500 Subject: [PATCH 083/174] Update main.h int battery_saver_check() --- main.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.h b/main.h index 7f4d04a0..53c7d63e 100644 --- a/main.h +++ b/main.h @@ -174,5 +174,6 @@ int end_flag_detected = FALSE; int jpeg_start = 0; #define CAMERA_TIMEOUT 10000 // 20000 // Camera timeout in milli seconds -int battery_saver(int setting); +void battery_saver(int setting); +int battery_saver_check(); From 697c3c142127cf8f6f67a0f92fd3e464f7b38f08 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 16 Nov 2023 08:57:03 -0500 Subject: [PATCH 084/174] Update main.c no sudo --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 1c17c6ce..df4c03b4 100644 --- a/main.c +++ b/main.c @@ -2257,7 +2257,7 @@ if (setting == ON) { return; } else if (setting == OFF) { - FILE *command = popen("sudo rm /home/pi/CubeSatSim/battery_saver", "r"); + FILE *command = popen("rm /home/pi/CubeSatSim/battery_saver", "r"); pclose(command); printf("Turning Battery saver mode OFF\n"); return; From d7ccb1694ae2c69e04d0d14bc7b6b07c76933c6b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 16 Nov 2023 09:04:11 -0500 Subject: [PATCH 085/174] Update main.c battery_saver(ON) do nothing --- main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/main.c b/main.c index df4c03b4..2438be8d 100644 --- a/main.c +++ b/main.c @@ -2257,6 +2257,7 @@ if (setting == ON) { return; } else if (setting == OFF) { + return; FILE *command = popen("rm /home/pi/CubeSatSim/battery_saver", "r"); pclose(command); printf("Turning Battery saver mode OFF\n"); From dfed6fccbc14b85e695dcb7756983f083375ddec Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 16 Nov 2023 09:07:40 -0500 Subject: [PATCH 086/174] Update main.c do nothing --- main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/main.c b/main.c index 2438be8d..0fa6867c 100644 --- a/main.c +++ b/main.c @@ -2250,6 +2250,7 @@ int battery_saver_check() { } void battery_saver(int setting) { + return; if (setting == ON) { FILE *command = popen("touch /home/pi/CubeSatSim/battery_saver", "r"); pclose(command); From f8ab2ec007e7baddc5f3dbea1468bbd3b62c2fd7 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 16 Nov 2023 11:25:22 -0500 Subject: [PATCH 087/174] Update config manual battery saver, change modes a,s,m --- config | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 53 insertions(+), 6 deletions(-) diff --git a/config b/config index 74f13c52..40ea295d 100755 --- a/config +++ b/config @@ -73,13 +73,9 @@ elif [ "$1" = "-a" ]; then if [ -f "$FILE" ]; then echo "Battery saver mode activated." if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi -# sudo sed -i ':a;N;$!ba;s/\ndtoverlay=pwm,pin=18,func=2//g' /boot/config.txt -# sudo sed -i ':a;N;$!ba;s/\ndtoverlay=audremap,enable_jack=on//g' /boot/config.txt else echo "Not battery saver mode" sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt -# if ! grep -q dtoverlay=pwm,pin=18,func=2 /boot/config.txt ; then sudo sh -c 'echo "\ndtoverlay=pwm,pin=18,func=2" >> /boot/config.txt'; fi -# if ! grep -q dtoverlay=audremap,enable_jack=on /boot/config.txt ; then sudo sh -c 'echo "\ndtoverlay=audremap,enable_jack=on" >> /boot/config.txt'; fi fi echo "rebooting" @@ -89,7 +85,15 @@ elif [ "$1" = "-a" ]; then elif [ "$1" = "-m" ]; then echo "changing CubeSatSim to CW mode" sudo echo "m" > /home/pi/CubeSatSim/.mode - sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt + + FILE=/home/pi/CubeSatSim/battery_saver + if [ -f "$FILE" ]; then + echo "Battery saver mode activated." + if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi + else + echo "Not battery saver mode" + sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt + fi echo "rebooting" sudo reboot now # sudo systemctl restart cubesatsim @@ -113,7 +117,15 @@ elif [ "$1" = "-b" ]; then elif [ "$1" = "-s" ]; then echo "changing CubeSatSim to SSTV mode" sudo echo "s" > /home/pi/CubeSatSim/.mode - sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt + + FILE=/home/pi/CubeSatSim/battery_saver + if [ -f "$FILE" ]; then + echo "Battery saver mode activated." + if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi + else + echo "Not battery saver mode" + sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt + fi echo "rebooting" sudo reboot now # sudo systemctl restart cubesatsim @@ -138,6 +150,7 @@ elif [ "$1" = "-h" ]; then echo " -C Clear logs" echo " -T Change command state" echo " -R Change the Commands Count in the file command_count.txt" + echo " -B Change battery saver mode manually" echo exit @@ -433,6 +446,40 @@ elif [ "$1" = "-R" ]; then else echo "Commands count not reset" fi + +elif [ "$1" = "-B" ]; then + + echo + echo "Manually setting battery saver mode" + echo + + FILE=/home/pi/CubeSatSim/battery_saver + if [ -f "$FILE" ]; then + echo "Battery saver mode is activated." + mode=1 + else + echo "Battery saver mode is not activated." + mode=0 + fi + + echo + + echo "Do you want Battery saver mode ON (y/n) " + read saver + echo + + if [ "$saver" = "y" ] || [ "$saver" = "yes" ] ; then + echo "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" + sudo rm /home/pi/CubeSatSim/battery_saver +# if ["$mode" = "1"] ; then sudo systemctl restart rpitx + fi + +# sudo systemctl restart cubesatsim + fi # sudo systemctl restart cubesatsim From 7c107b26e7740893c9db2165c53dc400e8f14a14 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 16 Nov 2023 11:30:38 -0500 Subject: [PATCH 088/174] Update rpitx.py read open battery_saver --- rpitx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index d301e968..df8df4dc 100644 --- a/rpitx.py +++ b/rpitx.py @@ -13,7 +13,7 @@ from PIL import Image, ImageDraw, ImageFont, ImageColor def battery_saver_check(): try: global txc - f = open("/home/pi/CubeSatSim/battery_saver") + f = open("/home/pi/CubeSatSim/battery_saver", "r") f.close() txc = False print("battery saver activated") From 326b57db66c4d5600563b5ce0cfdb12888ee1039 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 16 Nov 2023 11:45:29 -0500 Subject: [PATCH 089/174] Update main.c print battery_saver_chack() --- main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/main.c b/main.c index 0fa6867c..f24542bd 100644 --- a/main.c +++ b/main.c @@ -814,7 +814,7 @@ int main(int argc, char * argv[]) { fprintf(stderr, "INFO: Battery voltage: %5.2f V Threshold %5.2f V Current: %6.1f mA Threshold: %6.1f mA\n", batteryVoltage, voltageThreshold, batteryCurrent, currentThreshold); #endif // if ((batteryVoltage > 1.0) && (batteryVoltage < batteryThreshold)) // no battery INA219 will give 0V, no battery plugged into INA219 will read < 1V - +printf("battery_saver_check() : %d \n", battery_saver_check()); /**/ #ifndef HAB if ((batteryCurrent > currentThreshold) && (batteryVoltage < (voltageThreshold + 0.15)) && !sim_mode) @@ -2250,7 +2250,6 @@ int battery_saver_check() { } void battery_saver(int setting) { - return; if (setting == ON) { FILE *command = popen("touch /home/pi/CubeSatSim/battery_saver", "r"); pclose(command); From 0f2c2928f474e802eea0376da7eb1a09a7ae89a2 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 16 Nov 2023 11:52:23 -0500 Subject: [PATCH 090/174] Update main.c fix conditional --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index f24542bd..e9979002 100644 --- a/main.c +++ b/main.c @@ -820,7 +820,7 @@ printf("battery_saver_check() : %d \n", battery_saver_check()); if ((batteryCurrent > currentThreshold) && (batteryVoltage < (voltageThreshold + 0.15)) && !sim_mode) { battery_saver(ON); - } else if ((battery_saver_check()) && (batteryCurrent < 0)) + } else if ((battery_saver_check() == 1) && (batteryCurrent < 0)) { battery_saver(OFF); } else if ((batteryCurrent > currentThreshold) && (batteryVoltage < voltageThreshold) && !sim_mode) // currentThreshold ensures that this won't happen when running on DC power. From b2a881db97e798515c473e2732a09bb3013bbae7 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 16 Nov 2023 11:55:46 -0500 Subject: [PATCH 091/174] Update main.c print conditional --- main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index e9979002..b09e0297 100644 --- a/main.c +++ b/main.c @@ -814,7 +814,11 @@ int main(int argc, char * argv[]) { fprintf(stderr, "INFO: Battery voltage: %5.2f V Threshold %5.2f V Current: %6.1f mA Threshold: %6.1f mA\n", batteryVoltage, voltageThreshold, batteryCurrent, currentThreshold); #endif // if ((batteryVoltage > 1.0) && (batteryVoltage < batteryThreshold)) // no battery INA219 will give 0V, no battery plugged into INA219 will read < 1V -printf("battery_saver_check() : %d \n", battery_saver_check()); +printf("battery_saver_check() : %d current: %d\n", battery_saver_check(), batteryCurrent); +if ((battery_saver_check() == 1) && (batteryCurrent < 0)) + printf("Conditional true!\n"); + else + printf("Conditional false!\n"); /**/ #ifndef HAB if ((batteryCurrent > currentThreshold) && (batteryVoltage < (voltageThreshold + 0.15)) && !sim_mode) From 4d662427a872aa25ffee0ea3a357dd73794e7bf1 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 16 Nov 2023 12:01:19 -0500 Subject: [PATCH 092/174] Update main.c conditional test --- main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index b09e0297..cfba586c 100644 --- a/main.c +++ b/main.c @@ -814,11 +814,11 @@ int main(int argc, char * argv[]) { fprintf(stderr, "INFO: Battery voltage: %5.2f V Threshold %5.2f V Current: %6.1f mA Threshold: %6.1f mA\n", batteryVoltage, voltageThreshold, batteryCurrent, currentThreshold); #endif // if ((batteryVoltage > 1.0) && (batteryVoltage < batteryThreshold)) // no battery INA219 will give 0V, no battery plugged into INA219 will read < 1V -printf("battery_saver_check() : %d current: %d\n", battery_saver_check(), batteryCurrent); -if ((battery_saver_check() == 1) && (batteryCurrent < 0)) - printf("Conditional true!\n"); +printf("\n\nbattery_saver_check() : %d current: %f\n", battery_saver_check(), batteryCurrent); +if ((battery_saver_check() == 1) && (batteryCurrent < 0.0)) + printf("\nConditional true!\n"); else - printf("Conditional false!\n"); + printf("\nConditional false!\n"); /**/ #ifndef HAB if ((batteryCurrent > currentThreshold) && (batteryVoltage < (voltageThreshold + 0.15)) && !sim_mode) From 422cb1e3a91819d52341e707d74b42945ffaf820 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 16 Nov 2023 12:28:03 -0500 Subject: [PATCH 093/174] Update main.c added stderr to printfs --- main.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/main.c b/main.c index cfba586c..e883f76b 100644 --- a/main.c +++ b/main.c @@ -814,11 +814,11 @@ int main(int argc, char * argv[]) { fprintf(stderr, "INFO: Battery voltage: %5.2f V Threshold %5.2f V Current: %6.1f mA Threshold: %6.1f mA\n", batteryVoltage, voltageThreshold, batteryCurrent, currentThreshold); #endif // if ((batteryVoltage > 1.0) && (batteryVoltage < batteryThreshold)) // no battery INA219 will give 0V, no battery plugged into INA219 will read < 1V -printf("\n\nbattery_saver_check() : %d current: %f\n", battery_saver_check(), batteryCurrent); +fprintf(stderr, "\n\nbattery_saver_check() : %d current: %f\n", battery_saver_check(), batteryCurrent); if ((battery_saver_check() == 1) && (batteryCurrent < 0.0)) - printf("\nConditional true!\n"); + fprintf(stderr,"\nConditional true!\n"); else - printf("\nConditional false!\n"); + fprintf(stderr,"\nConditional false!\n"); /**/ #ifndef HAB if ((batteryCurrent > currentThreshold) && (batteryVoltage < (voltageThreshold + 0.15)) && !sim_mode) @@ -2244,12 +2244,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) { - printf("Battery saver mode is OFF\n"); + fprintf(stderr,"Battery saver mode is OFF\n"); fclose(file); return(0); } fclose(file); - printf("Battery saver mode is ON\n"); + fprintf(stderr,"Battery saver mode is ON\n"); return(1); } @@ -2257,18 +2257,18 @@ void battery_saver(int setting) { if (setting == ON) { FILE *command = popen("touch /home/pi/CubeSatSim/battery_saver", "r"); pclose(command); - printf("Turning Battery saver mode ON\n"); + fprintf(stderr,"Turning Battery saver mode ON\n"); return; } else if (setting == OFF) { return; FILE *command = popen("rm /home/pi/CubeSatSim/battery_saver", "r"); pclose(command); - printf("Turning Battery saver mode OFF\n"); + fprintf(stderr,"Turning Battery saver mode OFF\n"); return; } else { - printf("battery_saver function error"); + fprintf(stderr,"battery_saver function error"); return; } return; From 8b17d6c2ffb36efb0f59337d01d5e0fbb371abe9 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 16 Nov 2023 15:12:41 -0500 Subject: [PATCH 094/174] Update main.c removed stray off --- main.c | 1 - 1 file changed, 1 deletion(-) diff --git a/main.c b/main.c index e883f76b..c91bfc90 100644 --- a/main.c +++ b/main.c @@ -2261,7 +2261,6 @@ if (setting == ON) { return; } else if (setting == OFF) { - return; FILE *command = popen("rm /home/pi/CubeSatSim/battery_saver", "r"); pclose(command); fprintf(stderr,"Turning Battery saver mode OFF\n"); From 061921a4c1cbd701b9781653015b268e3f530af4 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 16 Nov 2023 15:29:37 -0500 Subject: [PATCH 095/174] Update main.c added to battery saver change mode --- main.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/main.c b/main.c index c91bfc90..4cfca191 100644 --- a/main.c +++ b/main.c @@ -2255,17 +2255,33 @@ int battery_saver_check() { void battery_saver(int setting) { if (setting == ON) { - FILE *command = popen("touch /home/pi/CubeSatSim/battery_saver", "r"); - pclose(command); - fprintf(stderr,"Turning Battery saver mode ON\n"); - return; - + if ((mode == APRS) || (mode == SSTV) || (mode == CW)) { + if (battery_saver_check() == 0) { + FILE *command = popen("touch /home/pi/CubeSatSim/battery_saver", "r"); + pclose(command); + 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); + *command = popen("sudo reboot now", "r"); + pclose(command); + sleep(60); + return; + } + } } else if (setting == OFF) { - FILE *command = popen("rm /home/pi/CubeSatSim/battery_saver", "r"); - pclose(command); - fprintf(stderr,"Turning Battery saver mode OFF\n"); - return; - + if ((mode == APRS) || (mode == SSTV) || (mode == CW)) { + if (battery_saver_check() == 1) { + FILE *command = popen("rm /home/pi/CubeSatSim/battery_saver", "r"); + pclose(command); + fprintf(stderr,"Turning Battery saver mode OFF\n"); + *command = popen("sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt ", "r"); + pclose(command); + *command = popen("sudo reboot now", "r"); + pclose(command); + sleep(60); + return; + } + } } else { fprintf(stderr,"battery_saver function error"); return; From 8576430d6d9bdc48be0c56daf3760f4222b5e21f Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 16 Nov 2023 15:36:46 -0500 Subject: [PATCH 096/174] Update main.c fixes to quotes --- main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 4cfca191..8f7a81dc 100644 --- a/main.c +++ b/main.c @@ -2255,12 +2255,12 @@ int battery_saver_check() { void battery_saver(int setting) { if (setting == ON) { - if ((mode == APRS) || (mode == SSTV) || (mode == CW)) { + if ((mode == AFSK) || (mode == SSTV) || (mode == CW)) { if (battery_saver_check() == 0) { FILE *command = popen("touch /home/pi/CubeSatSim/battery_saver", "r"); pclose(command); 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"); + *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); *command = popen("sudo reboot now", "r"); pclose(command); @@ -2269,7 +2269,7 @@ if (setting == ON) { } } } else if (setting == OFF) { - if ((mode == APRS) || (mode == SSTV) || (mode == CW)) { + if ((mode == AFSK) || (mode == SSTV) || (mode == CW)) { if (battery_saver_check() == 1) { FILE *command = popen("rm /home/pi/CubeSatSim/battery_saver", "r"); pclose(command); From 8125c9a13dfe1b1e7e1f7e67b0b75f9da304c762 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 16 Nov 2023 15:37:42 -0500 Subject: [PATCH 097/174] Update main.c fixed * --- main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index 8f7a81dc..39939601 100644 --- a/main.c +++ b/main.c @@ -2260,9 +2260,9 @@ if (setting == ON) { FILE *command = popen("touch /home/pi/CubeSatSim/battery_saver", "r"); pclose(command); 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"); + 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); - *command = popen("sudo reboot now", "r"); + command = popen("sudo reboot now", "r"); pclose(command); sleep(60); return; @@ -2274,9 +2274,9 @@ if (setting == ON) { FILE *command = popen("rm /home/pi/CubeSatSim/battery_saver", "r"); pclose(command); fprintf(stderr,"Turning Battery saver mode OFF\n"); - *command = popen("sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt ", "r"); + command = popen("sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt ", "r"); pclose(command); - *command = popen("sudo reboot now", "r"); + command = popen("sudo reboot now", "r"); pclose(command); sleep(60); return; From 544b2c87e32d10c26ad23d47366e8f5977987a4b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 16 Nov 2023 15:47:36 -0500 Subject: [PATCH 098/174] Update main.c add print --- main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 39939601..c237dc8f 100644 --- a/main.c +++ b/main.c @@ -2266,7 +2266,8 @@ if (setting == ON) { pclose(command); sleep(60); return; - } + } else + fprintf(stderr, "Nothing to do for battery_saver\n"); } } else if (setting == OFF) { if ((mode == AFSK) || (mode == SSTV) || (mode == CW)) { @@ -2280,7 +2281,8 @@ if (setting == ON) { pclose(command); sleep(60); return; - } + } else + fprintf(stderr, "Nothing to do for battery_saver\n"); } } else { fprintf(stderr,"battery_saver function error"); From c03b12bc5cd4c0d85a0737280e5edc9ce32b5941 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 18 Nov 2023 11:39:34 -0500 Subject: [PATCH 099/174] Update main.h added hab_mode and battery_saver_mode --- main.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main.h b/main.h index 53c7d63e..4c6b69a3 100644 --- a/main.h +++ b/main.h @@ -177,3 +177,5 @@ int jpeg_start = 0; void battery_saver(int setting); int battery_saver_check(); +int hab_mode = FALSE; +int battery_saver_mode = FALSE; From 34b176ec30e3fe9e510a3a0c342feec1c42939dc Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 18 Nov 2023 11:42:05 -0500 Subject: [PATCH 100/174] Update main.c added battery_saver_mode --- main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index c237dc8f..f0f9c825 100644 --- a/main.c +++ b/main.c @@ -177,6 +177,8 @@ int main(int argc, char * argv[]) { if (strcmp(sim_yes, "yes") == 0) sim_mode = TRUE; + battery_saver_mode = battery_saver_check(); + if (mode == AFSK) { // Check for SPI and AX-5043 Digital Transceiver Board @@ -814,7 +816,7 @@ int main(int argc, char * argv[]) { fprintf(stderr, "INFO: Battery voltage: %5.2f V Threshold %5.2f V Current: %6.1f mA Threshold: %6.1f mA\n", batteryVoltage, voltageThreshold, batteryCurrent, currentThreshold); #endif // if ((batteryVoltage > 1.0) && (batteryVoltage < batteryThreshold)) // no battery INA219 will give 0V, no battery plugged into INA219 will read < 1V -fprintf(stderr, "\n\nbattery_saver_check() : %d current: %f\n", battery_saver_check(), batteryCurrent); +fprintf(stderr, "\n\nbattery_saver_mode : %d current: %f\n", battery_saver_mode, batteryCurrent); if ((battery_saver_check() == 1) && (batteryCurrent < 0.0)) fprintf(stderr,"\nConditional true!\n"); else @@ -824,7 +826,7 @@ if ((battery_saver_check() == 1) && (batteryCurrent < 0.0)) if ((batteryCurrent > currentThreshold) && (batteryVoltage < (voltageThreshold + 0.15)) && !sim_mode) { battery_saver(ON); - } else if ((battery_saver_check() == 1) && (batteryCurrent < 0)) + } else if ((battery_saver_mode == ON) && (batteryCurrent < 0)) { battery_saver(OFF); } else if ((batteryCurrent > currentThreshold) && (batteryVoltage < voltageThreshold) && !sim_mode) // currentThreshold ensures that this won't happen when running on DC power. @@ -2246,11 +2248,11 @@ int battery_saver_check() { if (file == NULL) { fprintf(stderr,"Battery saver mode is OFF\n"); fclose(file); - return(0); + return(ON); } fclose(file); fprintf(stderr,"Battery saver mode is ON\n"); - return(1); + return(OFF); } void battery_saver(int setting) { From 888ce415b599e5f268b557060f5ecac486d500a0 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 18 Nov 2023 11:46:00 -0500 Subject: [PATCH 101/174] Update rpitx.py battery_saver_check() once at starty --- rpitx.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/rpitx.py b/rpitx.py index df8df4dc..29074e63 100644 --- a/rpitx.py +++ b/rpitx.py @@ -208,6 +208,7 @@ else: output(txLed, txLedOn) sleep(1) output(txLed, txLedOff) + battery_saver_check() # print(txLedOn) @@ -282,7 +283,7 @@ if __name__ == "__main__": # if (mode != 'a') and (command_tx == True): if (command_tx == True): - battery_saver_check() + battery_saver_mode output(txLed, txLedOn) if (txc): output(pd, 1) @@ -332,8 +333,8 @@ if __name__ == "__main__": # output(pd, 1) # output (ptt, 0) # sleep(.1) - - battery_saver_check() +# +# battery_saver_check() if (txc): output(pd, 1) output (ptt, 0) @@ -406,7 +407,7 @@ if __name__ == "__main__": if (command_tx == True): output(txLed, txLedOn) - battery_saver_check() +# battery_saver_check() if (txc): output (pd, 1) @@ -467,7 +468,7 @@ if __name__ == "__main__": output(txLed, txLedOn) output (ptt, 0) sleep(0.1) - battery_saver_check() +# battery_saver_check() if (txc): system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/morse.wav") @@ -517,7 +518,7 @@ if __name__ == "__main__": if (command_tx == True): print ("Sending SSTV image") output(txLed, txLedOn) - battery_saver_check() +# battery_saver_check() if (txc): output(pd, 1) @@ -602,7 +603,7 @@ if __name__ == "__main__": if (command_tx == True): print ("Sending SSTV image") output(txLed, txLedOn) - battery_saver_check() +# battery_saver_check() if (txc): output(pd, 1) @@ -632,7 +633,7 @@ if __name__ == "__main__": print ("Sending SSTV image") output(txLed, txLedOn) - battery_saver_check() +# battery_saver_check() if (txc): output(pd, 1) @@ -693,7 +694,7 @@ if __name__ == "__main__": if (command_tx == True): print ("Sending SSTV image") output(txLed, txLedOn) - battery_saver_check() +# battery_saver_check() if (txc): output(pd, 1) @@ -720,7 +721,7 @@ if __name__ == "__main__": if (command_tx == True): output(txLed, txLedOn) - battery_saver_check() +# battery_saver_check() if (txc): output(pd, 1) From 30bcd1ba442ac230aedaa9ceec4e1b7a39e2ce66 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 18 Nov 2023 12:25:51 -0500 Subject: [PATCH 102/174] Update config add rotate to clear logs --- config | 1 + 1 file changed, 1 insertion(+) diff --git a/config b/config index 40ea295d..29cd53e5 100755 --- a/config +++ b/config @@ -393,6 +393,7 @@ elif [ "$1" = "-C" ]; then sudo systemctl stop cubesatsim sudo systemctl stop rpitx + sudo journactl --rotate sudo journalctl --vacuum-time=1s sudo systemctl reboot now From ce6fd861d16dbfe95271255dfe53b7efa938bd8c Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 18 Nov 2023 12:30:22 -0500 Subject: [PATCH 103/174] Update rpitx.py stray battery_saver_mode --- rpitx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index 29074e63..f3d544bc 100644 --- a/rpitx.py +++ b/rpitx.py @@ -283,7 +283,7 @@ if __name__ == "__main__": # if (mode != 'a') and (command_tx == True): if (command_tx == True): - battery_saver_mode +# battery_saver_mode output(txLed, txLedOn) if (txc): output(pd, 1) From 1ba77180f254afb67cdb511d7687425c22b43067 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 18 Nov 2023 12:37:28 -0500 Subject: [PATCH 104/174] Update main.c only if battery_saver_mode changes execute --- main.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index f0f9c825..94e9010e 100644 --- a/main.c +++ b/main.c @@ -177,8 +177,10 @@ int main(int argc, char * argv[]) { if (strcmp(sim_yes, "yes") == 0) sim_mode = TRUE; - battery_saver_mode = battery_saver_check(); - + battery_saver_mode = battery_saver_check(); + fprintf(stderr, "\nbattery_saver_mode: %d \n\n", battery_saver_mode); + fflush(stderr); + if (mode == AFSK) { // Check for SPI and AX-5043 Digital Transceiver Board @@ -817,7 +819,7 @@ int main(int argc, char * argv[]) { #endif // if ((batteryVoltage > 1.0) && (batteryVoltage < batteryThreshold)) // no battery INA219 will give 0V, no battery plugged into INA219 will read < 1V fprintf(stderr, "\n\nbattery_saver_mode : %d current: %f\n", battery_saver_mode, batteryCurrent); -if ((battery_saver_check() == 1) && (batteryCurrent < 0.0)) +if ((battery_saver_mode == ON) && (batteryCurrent < 0.0)) fprintf(stderr,"\nConditional true!\n"); else fprintf(stderr,"\nConditional false!\n"); @@ -825,10 +827,12 @@ if ((battery_saver_check() == 1) && (batteryCurrent < 0.0)) #ifndef HAB if ((batteryCurrent > currentThreshold) && (batteryVoltage < (voltageThreshold + 0.15)) && !sim_mode) { - battery_saver(ON); + if (battery_saver_mode == OFF) + battery_saver(ON); } else if ((battery_saver_mode == ON) && (batteryCurrent < 0)) { - battery_saver(OFF); + if (battery_saver_mode == ON) + battery_saver(OFF); } else if ((batteryCurrent > currentThreshold) && (batteryVoltage < voltageThreshold) && !sim_mode) // currentThreshold ensures that this won't happen when running on DC power. { fprintf(stderr, "Battery voltage too low: %f V - shutting down!\n", batteryVoltage); From be72b99c8b8f0d137951ee5611d14faabaa00585 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 18 Nov 2023 12:38:18 -0500 Subject: [PATCH 105/174] Update main.c add ! --- main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 94e9010e..cbf59113 100644 --- a/main.c +++ b/main.c @@ -2250,12 +2250,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"); fclose(file); return(ON); } fclose(file); - fprintf(stderr,"Battery saver mode is ON\n"); + fprintf(stderr,"Battery saver mode is ON!\n"); return(OFF); } From 889d532f278b06b6d24274441e5cc2239f9661ae Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 18 Nov 2023 12:45:48 -0500 Subject: [PATCH 106/174] Update main.c paste battery_saver_check code --- main.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index cbf59113..3225af68 100644 --- a/main.c +++ b/main.c @@ -177,7 +177,21 @@ int main(int argc, char * argv[]) { if (strcmp(sim_yes, "yes") == 0) sim_mode = TRUE; - battery_saver_mode = battery_saver_check(); + + FILE *file = fopen("/home/pi/CubeSatSim/battery_saver", "r"); + if (file == NULL) { + fprintf(stderr,"Battery saver mode is OFF!\n"); + fclose(file); + battery_saver_mode = OFF; + } + else { + fclose(file); + fprintf(stderr,"Battery saver mode is ON!\n"); + battery_saver_mode = OFF; + } + +// battery_saver_mode = battery_saver_check(); + fprintf(stderr, "\nbattery_saver_mode: %d \n\n", battery_saver_mode); fflush(stderr); From 84d388bcfd8e3c770c90f2b2881041e8f5ada41e Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 18 Nov 2023 12:50:09 -0500 Subject: [PATCH 107/174] Update main.c don't close if open fails --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 3225af68..e7b514f5 100644 --- a/main.c +++ b/main.c @@ -181,7 +181,7 @@ int main(int argc, char * argv[]) { FILE *file = fopen("/home/pi/CubeSatSim/battery_saver", "r"); if (file == NULL) { fprintf(stderr,"Battery saver mode is OFF!\n"); - fclose(file); +// fclose(file); battery_saver_mode = OFF; } else { From 38926b7b4f60267cb4fe07800679180475ed3c5c Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 18 Nov 2023 12:57:00 -0500 Subject: [PATCH 108/174] Update main.c cleanup --- main.c | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/main.c b/main.c index e7b514f5..4be5e34d 100644 --- a/main.c +++ b/main.c @@ -177,20 +177,7 @@ int main(int argc, char * argv[]) { if (strcmp(sim_yes, "yes") == 0) sim_mode = TRUE; - - FILE *file = fopen("/home/pi/CubeSatSim/battery_saver", "r"); - if (file == NULL) { - fprintf(stderr,"Battery saver mode is OFF!\n"); -// fclose(file); - battery_saver_mode = OFF; - } - else { - fclose(file); - fprintf(stderr,"Battery saver mode is ON!\n"); - battery_saver_mode = OFF; - } - -// battery_saver_mode = battery_saver_check(); + battery_saver_mode = battery_saver_check(); fprintf(stderr, "\nbattery_saver_mode: %d \n\n", battery_saver_mode); fflush(stderr); @@ -833,11 +820,7 @@ int main(int argc, char * argv[]) { #endif // if ((batteryVoltage > 1.0) && (batteryVoltage < batteryThreshold)) // no battery INA219 will give 0V, no battery plugged into INA219 will read < 1V fprintf(stderr, "\n\nbattery_saver_mode : %d current: %f\n", battery_saver_mode, batteryCurrent); -if ((battery_saver_mode == ON) && (batteryCurrent < 0.0)) - fprintf(stderr,"\nConditional true!\n"); - else - fprintf(stderr,"\nConditional false!\n"); -/**/ + #ifndef HAB if ((batteryCurrent > currentThreshold) && (batteryVoltage < (voltageThreshold + 0.15)) && !sim_mode) { @@ -2265,7 +2248,6 @@ int battery_saver_check() { FILE *file = fopen("/home/pi/CubeSatSim/battery_saver", "r"); if (file == NULL) { fprintf(stderr,"Battery saver mode is OFF!\n"); - fclose(file); return(ON); } fclose(file); From 3488cc915fc227dee0da61b4792ab15ebd33fb1d Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 18 Nov 2023 12:58:06 -0500 Subject: [PATCH 109/174] Update config typo in journalctl --- config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config b/config index 29cd53e5..6b27189d 100755 --- a/config +++ b/config @@ -393,7 +393,7 @@ elif [ "$1" = "-C" ]; then sudo systemctl stop cubesatsim sudo systemctl stop rpitx - sudo journactl --rotate + sudo journalctl --rotate sudo journalctl --vacuum-time=1s sudo systemctl reboot now From 99d505f1cf606ea15f958ca3d3229cc6a13d65db Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 18 Nov 2023 13:43:09 -0500 Subject: [PATCH 110/174] Update main.c fix sed for battery on --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 4be5e34d..6743f988 100644 --- a/main.c +++ b/main.c @@ -2277,7 +2277,7 @@ if (setting == ON) { FILE *command = popen("rm /home/pi/CubeSatSim/battery_saver", "r"); pclose(command); fprintf(stderr,"Turning Battery saver mode OFF\n"); - command = popen("sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt ", "r"); + command = popen("sudo sed -i ':a;N;$!ba;s/\'$'\n''force_turbo=1//g' /boot/config.txt", "r"); pclose(command); command = popen("sudo reboot now", "r"); pclose(command); From 86dd8f86b01cb9c55f15beffd4a3bdb97b33f53f Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 18 Nov 2023 13:46:41 -0500 Subject: [PATCH 111/174] Update main.c switch battery_saver_check() outputs --- main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 6743f988..a429858f 100644 --- a/main.c +++ b/main.c @@ -2248,11 +2248,11 @@ int battery_saver_check() { FILE *file = fopen("/home/pi/CubeSatSim/battery_saver", "r"); if (file == NULL) { fprintf(stderr,"Battery saver mode is OFF!\n"); - return(ON); + return(OFF); } fclose(file); fprintf(stderr,"Battery saver mode is ON!\n"); - return(OFF); + return(ON); } void battery_saver(int setting) { From ed7ff129ab9da817ec2bff4129efd72946c381ac Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 18 Nov 2023 13:59:35 -0500 Subject: [PATCH 112/174] Update config restart CubeSatSim after -B --- config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config b/config index 6b27189d..ab3ece53 100755 --- a/config +++ b/config @@ -479,7 +479,7 @@ elif [ "$1" = "-B" ]; then # if ["$mode" = "1"] ; then sudo systemctl restart rpitx fi -# sudo systemctl restart cubesatsim + sudo systemctl restart cubesatsim fi From f89b6c412ac3fb1e17e12ec18fcb82108e8649d1 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 18 Nov 2023 14:18:29 -0500 Subject: [PATCH 113/174] Update main.c add battery prints --- main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main.c b/main.c index a429858f..dffeea47 100644 --- a/main.c +++ b/main.c @@ -824,10 +824,12 @@ fprintf(stderr, "\n\nbattery_saver_mode : %d current: %f\n", battery_saver_mode, #ifndef HAB if ((batteryCurrent > currentThreshold) && (batteryVoltage < (voltageThreshold + 0.15)) && !sim_mode) { + fprintf(stderr,"Battery voltage low - switch to battery saver\n"); if (battery_saver_mode == OFF) battery_saver(ON); } else if ((battery_saver_mode == ON) && (batteryCurrent < 0)) { + fprintf(stderr,"Battery is being charged - switch battery saver off\n"); if (battery_saver_mode == ON) battery_saver(OFF); } else if ((batteryCurrent > currentThreshold) && (batteryVoltage < voltageThreshold) && !sim_mode) // currentThreshold ensures that this won't happen when running on DC power. From 5361a5b93df14230880d0e4defbba64d13dd99dd Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 18 Nov 2023 14:30:05 -0500 Subject: [PATCH 114/174] Update main.c print battery status mode ON or OFF --- main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index dffeea47..2e8a968e 100644 --- a/main.c +++ b/main.c @@ -178,8 +178,12 @@ int main(int argc, char * argv[]) { sim_mode = TRUE; battery_saver_mode = battery_saver_check(); + + if (battery_saver_mode == ON) + fprintf(stderr, "\nBattery_saver_mode is ON\n\n"); + else + fprintf(stderr, "\nBattery_saver_mode is OFF\n\n"); - fprintf(stderr, "\nbattery_saver_mode: %d \n\n", battery_saver_mode); fflush(stderr); if (mode == AFSK) From 88ecd3f2f6b1a5262f03ecdf6b4eade5b0f88031 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 18 Nov 2023 14:39:55 -0500 Subject: [PATCH 115/174] Update main.c fix battery saver turn off --- main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 2e8a968e..1e705040 100644 --- a/main.c +++ b/main.c @@ -2264,7 +2264,7 @@ int battery_saver_check() { void battery_saver(int setting) { if (setting == ON) { if ((mode == AFSK) || (mode == SSTV) || (mode == CW)) { - if (battery_saver_check() == 0) { + if (battery_saver_check() == OFF) { FILE *command = popen("touch /home/pi/CubeSatSim/battery_saver", "r"); pclose(command); fprintf(stderr,"Turning Battery saver mode ON\n"); @@ -2279,7 +2279,7 @@ if (setting == ON) { } } else if (setting == OFF) { if ((mode == AFSK) || (mode == SSTV) || (mode == CW)) { - if (battery_saver_check() == 1) { + if (battery_saver_check() == ON) { FILE *command = popen("rm /home/pi/CubeSatSim/battery_saver", "r"); pclose(command); fprintf(stderr,"Turning Battery saver mode OFF\n"); From b8d328ec1d974df678c59d8a7f10710388b0d23a Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 18 Nov 2023 14:47:28 -0500 Subject: [PATCH 116/174] Update main.c add back in auto shutdown --- main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 1e705040..aa93d5a8 100644 --- a/main.c +++ b/main.c @@ -836,7 +836,8 @@ fprintf(stderr, "\n\nbattery_saver_mode : %d current: %f\n", battery_saver_mode, fprintf(stderr,"Battery is being charged - switch battery saver off\n"); if (battery_saver_mode == ON) battery_saver(OFF); - } else if ((batteryCurrent > currentThreshold) && (batteryVoltage < voltageThreshold) && !sim_mode) // currentThreshold ensures that this won't happen when running on DC power. + } + if ((batteryCurrent > currentThreshold) && (batteryVoltage < voltageThreshold) && !sim_mode) // currentThreshold ensures that this won't happen when running on DC power. { fprintf(stderr, "Battery voltage too low: %f V - shutting down!\n", batteryVoltage); digitalWrite(txLed, txLedOff); From c69169d8fff2e1ba73b574c5f495f85ad3f9145f Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 19 Nov 2023 11:15:09 -0500 Subject: [PATCH 117/174] Update main.c try removing AMSAT-11 from APRS string --- main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index aa93d5a8..5151ee65 100644 --- a/main.c +++ b/main.c @@ -1012,7 +1012,8 @@ void get_tlm(void) { // 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 - 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_str[] = " && echo 'AMSAT-11>APCSS:010101/hi hi ' >> t.txt && touch /home/pi/CubeSatSim/ready"; // transmit is done by rpitx.py + char footer_str[] = " && echo '010101/hi hi ' >> t.txt && touch /home/pi/CubeSatSim/ready"; // transmit is done by rpitx.py if (ax5043) { strcpy(str, header_str); From 959e3a46b4183771c3cbcc55345f7d950ce766cf Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 19 Nov 2023 11:19:22 -0500 Subject: [PATCH 118/174] Update update added git --no-rebase --- update | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/update b/update index 04409734..a3e72684 100755 --- a/update +++ b/update @@ -26,7 +26,7 @@ sudo sed -i 's/console=tty1 r/console=tty1 maxcpus=1 r/g' /boot/cmdline.txt # si cd /home/pi/CubeSatSim -git pull > .updated +git --no-rebase pull > .updated make debug @@ -135,7 +135,7 @@ cd /home/pi/pi-power-button # git checkout reboot-mode-change -git pull > .updated_p +git --no-rebase pull > .updated_p grep 'changed' /home/pi/pi-power-button/.updated_p if [[ $(grep 'changed' /home/pi/pi-power-button/.updated_p) ]]; then @@ -186,7 +186,7 @@ git pull > .updated_p FLAG=1 cd /home/pi/pi-power-button - git pull + git --no-rebase pull git checkout reboot-mode-change script/install From 87fbd64ef10e2cff7a5c93035982edfa006c9129 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 19 Nov 2023 11:21:54 -0500 Subject: [PATCH 119/174] Update main.c add str2 but not used yet --- main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 5151ee65..d09ad79a 100644 --- a/main.c +++ b/main.c @@ -1012,9 +1012,9 @@ void get_tlm(void) { // 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 -// 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_str[] = " && echo '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"; + if (ax5043) { strcpy(str, header_str); } else { From 3c81cdb2368b68e3cfb8c896e96871af35105163 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 19 Nov 2023 13:02:00 -0500 Subject: [PATCH 120/174] Update main.c add extra APRS packet only for battery_saver_mode --- main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index d09ad79a..494d9d4a 100644 --- a/main.c +++ b/main.c @@ -1196,7 +1196,11 @@ void get_tlm(void) { strcat(str, footer_str1); // strcat(str, call); - strcat(str, footer_str); + if (battery_saver_mode == ON) + strcat(str, footer_str); // add extra packet for rpitx transmission + else + strcat(str, footer_str2); + fprintf(stderr, "String to execute: %s\n", str); printf("\n\nTelemetry string is %s \n\n", str); From 139ca31adc87a04f27a1c31f9905ec6c6c065392 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 19 Nov 2023 13:06:07 -0500 Subject: [PATCH 121/174] Update update remove --no-rebase --- update | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/update b/update index a3e72684..04409734 100755 --- a/update +++ b/update @@ -26,7 +26,7 @@ sudo sed -i 's/console=tty1 r/console=tty1 maxcpus=1 r/g' /boot/cmdline.txt # si cd /home/pi/CubeSatSim -git --no-rebase pull > .updated +git pull > .updated make debug @@ -135,7 +135,7 @@ cd /home/pi/pi-power-button # git checkout reboot-mode-change -git --no-rebase pull > .updated_p +git pull > .updated_p grep 'changed' /home/pi/pi-power-button/.updated_p if [[ $(grep 'changed' /home/pi/pi-power-button/.updated_p) ]]; then @@ -186,7 +186,7 @@ git --no-rebase pull > .updated_p FLAG=1 cd /home/pi/pi-power-button - git --no-rebase pull + git pull git checkout reboot-mode-change script/install From 1cf9f767c9a0ee21aa0ce780b9f07e81bd9da9d7 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 19 Nov 2023 13:48:57 -0500 Subject: [PATCH 122/174] Update rpitx.py fix command --- rpitx.py | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/rpitx.py b/rpitx.py index f3d544bc..fb1ab782 100644 --- a/rpitx.py +++ b/rpitx.py @@ -137,7 +137,7 @@ print("CubeSatSim v1.3b rpitx.py starting...") pd = 21 ptt = 20 txc_pin = 7 -squelch = 6 + = 6 green = 16 command_tx = True @@ -150,9 +150,9 @@ GPIO.setup(27, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(txc_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(green, GPIO.OUT) -GPIO.setup(squelch, GPIO.IN, pull_up_down=GPIO.PUD_UP) ## pull up in case pin is not connected +GPIO.setup(, GPIO.IN, pull_up_down=GPIO.PUD_UP) ## pull up in case pin is not connected -if GPIO.input(squelch) == False: +if GPIO.input() == False: print("squelch not set correctly, no command input!") no_command = True else: @@ -355,6 +355,8 @@ if __name__ == "__main__": output(txLed, txLedOff) system("sudo rm /home/pi/CubeSatSim/ready") f.close() + output(pd, 1) + output(ptt, 1) sleep(1) if (no_command == False and GPIO.input(squelch) == False): print("carrier received!") @@ -387,7 +389,8 @@ if __name__ == "__main__": system("echo > command_tx False") else: print("No carrier received!") - + output(pd, 0) + if (debug_mode == 1): print("Ready for next packet!") @@ -428,6 +431,9 @@ if __name__ == "__main__": # output (ptt, 1) sleep(5) while True: + output(pd, 1) + output(ptt, 1) + sleep(1) if (no_command == False and GPIO.input(squelch) == False): print("carrier received!") # command_tx = not command_tx @@ -458,6 +464,8 @@ if __name__ == "__main__": print("Turning off transmit") system("echo > command_tx False") sleep(5) + output(pd, 0) + try: f = open("/home/pi/CubeSatSim/cwready") f.close() @@ -568,6 +576,7 @@ if __name__ == "__main__": system("sudo rm /home/pi/CubeSatSim/camera_out.jpg > /dev/null 2>&1") output(pd, 1) + output(ptt, 1) sleep(1) if (no_command == False and GPIO.input(squelch) == False): print("carrier received!") @@ -660,6 +669,7 @@ if __name__ == "__main__": while 1: output(pd, 1) + output(ptt, 1) sleep(1) if (no_command == False and GPIO.input(squelch) == False): print("carrier received!") @@ -689,7 +699,7 @@ if __name__ == "__main__": else: print("Turning off transmit") system("echo > command_tx False") -# output(pd, 0) + output(pd, 0) if (command_tx == True): print ("Sending SSTV image") @@ -751,6 +761,9 @@ if __name__ == "__main__": # output(txLed, txLedOn) # sleep(0.03) # output(txLed, txLedOff) + output(pd, 1) + output(ptt, 1) + sleep(1) if (no_command == False and GPIO.input(squelch) == False): print("carrier received!") # command_tx = not command_tx @@ -781,6 +794,8 @@ if __name__ == "__main__": system("sudo systemctl restart rpitx") # system("sudo reboot now") sleep(60) + output(pd, 0) + if (command_tx == True): output(txLed, txLedOn) sleep(4.0) @@ -799,6 +814,9 @@ if __name__ == "__main__": # output(txLed, txLedOn) # sleep(0.03) # output(txLed, txLedOff) + output(pd, 1) + output(ptt, 1) + sleep(1) if (no_command == False and GPIO.input(squelch) == False): print("carrier received!") # command_tx = not command_tx From 85e9018585c312f14a0295a982b939a7259d5e61 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 19 Nov 2023 14:18:57 -0500 Subject: [PATCH 123/174] Update config only restart on -B if a/s/m mode --- config | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/config b/config index ab3ece53..96e41337 100755 --- a/config +++ b/config @@ -479,8 +479,14 @@ elif [ "$1" = "-B" ]; then # if ["$mode" = "1"] ; then sudo systemctl restart rpitx fi - sudo systemctl restart cubesatsim - + value=`cat /home/pi/CubeSatSim/.mode` + echo "$value" > /dev/null + set -- $value + + if [ "$1" = "a" ] || [ "$1" = "s" ] || [ "$1" = "m" ] ; then + echo "restarting" + sudo systemctl restart cubesatsim + fi fi # sudo systemctl restart cubesatsim From edc66f9ed57d2305bb22c3102c368fe20cd22ef3 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 19 Nov 2023 14:20:45 -0500 Subject: [PATCH 124/174] Update update add back --no-rebase --- update | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/update b/update index 04409734..8e9f3c9b 100755 --- a/update +++ b/update @@ -26,7 +26,7 @@ sudo sed -i 's/console=tty1 r/console=tty1 maxcpus=1 r/g' /boot/cmdline.txt # si cd /home/pi/CubeSatSim -git pull > .updated +git pull --no-rebase > .updated make debug @@ -135,7 +135,7 @@ cd /home/pi/pi-power-button # git checkout reboot-mode-change -git pull > .updated_p +git pull --no-rebase > .updated_p grep 'changed' /home/pi/pi-power-button/.updated_p if [[ $(grep 'changed' /home/pi/pi-power-button/.updated_p) ]]; then @@ -186,7 +186,7 @@ git pull > .updated_p FLAG=1 cd /home/pi/pi-power-button - git pull + git pull --no-rebase git checkout reboot-mode-change script/install From 9f15edb8fc9269948d6df231e0b910750f679656 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 19 Nov 2023 14:27:40 -0500 Subject: [PATCH 125/174] Update rpitx.py added back missing squelch variable --- rpitx.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rpitx.py b/rpitx.py index fb1ab782..7d04a3bb 100644 --- a/rpitx.py +++ b/rpitx.py @@ -137,7 +137,7 @@ print("CubeSatSim v1.3b rpitx.py starting...") pd = 21 ptt = 20 txc_pin = 7 - = 6 +squelch = 6 green = 16 command_tx = True @@ -150,9 +150,9 @@ GPIO.setup(27, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(txc_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(green, GPIO.OUT) -GPIO.setup(, GPIO.IN, pull_up_down=GPIO.PUD_UP) ## pull up in case pin is not connected +GPIO.setup(squelch, GPIO.IN, pull_up_down=GPIO.PUD_UP) ## pull up in case pin is not connected -if GPIO.input() == False: +if GPIO.input(squelch) == False: print("squelch not set correctly, no command input!") no_command = True else: From c0d6d0d02b57d60fd3e92ca18cec60af1d50fab9 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 19 Nov 2023 14:54:12 -0500 Subject: [PATCH 126/174] Update main.c remove extra prints --- main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 494d9d4a..43192904 100644 --- a/main.c +++ b/main.c @@ -178,12 +178,12 @@ int main(int argc, char * argv[]) { sim_mode = TRUE; battery_saver_mode = battery_saver_check(); - +/* if (battery_saver_mode == ON) fprintf(stderr, "\nBattery_saver_mode is ON\n\n"); else fprintf(stderr, "\nBattery_saver_mode is OFF\n\n"); - +*/ fflush(stderr); if (mode == AFSK) @@ -823,7 +823,7 @@ int main(int argc, char * argv[]) { fprintf(stderr, "INFO: Battery voltage: %5.2f V Threshold %5.2f V Current: %6.1f mA Threshold: %6.1f mA\n", batteryVoltage, voltageThreshold, batteryCurrent, currentThreshold); #endif // if ((batteryVoltage > 1.0) && (batteryVoltage < batteryThreshold)) // no battery INA219 will give 0V, no battery plugged into INA219 will read < 1V -fprintf(stderr, "\n\nbattery_saver_mode : %d current: %f\n", battery_saver_mode, batteryCurrent); +// fprintf(stderr, "\n\nbattery_saver_mode : %d current: %f\n", battery_saver_mode, batteryCurrent); #ifndef HAB if ((batteryCurrent > currentThreshold) && (batteryVoltage < (voltageThreshold + 0.15)) && !sim_mode) From af82f4e9ac5b6c5685518f6687d32a26c2f9c5a4 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 19 Nov 2023 17:16:59 -0500 Subject: [PATCH 127/174] Update main.c command_count fix --- main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 044d6ff7..b0e12675 100644 --- a/main.c +++ b/main.c @@ -1575,9 +1575,10 @@ void get_tlm_fox() { char count_string[10]; if ( (fgets(count_string, 10, command_count_file)) != NULL) groundCommandCount = atoi(count_string); + fclose(command_count_file); } else printf("Error opening command_count.txt!\n"); - fclose(command_count_file); + printf("Command count: %d\n", groundCommandCount); int status = STEMBoardFailure + SafeMode * 2 + sim_mode * 4 + PayloadFailure1 * 8 + From a2a4a7d3b5f65a9e53838874787479339bb4cb49 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 20 Nov 2023 19:48:55 -0500 Subject: [PATCH 128/174] Update config added -H to set HAB mode --- config | 91 +++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 71 insertions(+), 20 deletions(-) diff --git a/config b/config index 3b562b38..1422bd49 100755 --- a/config +++ b/config @@ -40,6 +40,13 @@ if [ "$1" = "" ]; then echo "Simulated Telemetry is OFF" fi + + if [ "$9" = "yes" ] || [ "$9" = "y" ]; then + echo "HAB mode is ON" + else + echo "HAB mode is OFF" + fi + echo echo "Current command count is:" cat /home/pi/CubeSatSim/command_count.txt @@ -55,7 +62,7 @@ if [ "$1" = "" ]; then echo -e "Current sim.cfg configuration file:" echo - echo $1 $2 $3 $4 $5 $6 $7 $8 + echo $1 $2 $3 $4 $5 $6 $7 $8 $9 echo echo "To change, include an OPTION" @@ -157,6 +164,7 @@ elif [ "$1" = "-h" ]; then 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 HAB mode" echo exit @@ -179,7 +187,7 @@ elif [ "$1" = "-t" ]; then echo -# echo $1 $2 $3 $4 $5 $6 $7 $8 +# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 echo "Do you want Simulated Telemetry ON (y/n) " read sim @@ -196,8 +204,8 @@ elif [ "$1" = "-t" ]; then echo echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" echo - echo $1 $2 $3 $4 $sim $6 $7 $8 - echo $1 $2 $3 $4 $sim $6 $7 $8 > /home/pi/CubeSatSim/sim.cfg + echo $1 $2 $3 $4 $sim $6 $7 $8 $9 + echo $1 $2 $3 $4 $sim $6 $7 $8 $9 > /home/pi/CubeSatSim/sim.cfg echo echo "Restarting CubeSatSim with new configuraation file" echo @@ -222,7 +230,7 @@ elif [ "$1" = "-c" ]; then echo $1 echo -# echo $1 $2 $3 $4 $5 $6 $7 $8 +# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 echo "Enter callsign in all capitals: " read callsign @@ -236,8 +244,8 @@ elif [ "$1" = "-c" ]; then echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" - echo $callsign $2 $3 $4 $5 $6 $7 $8 - echo $callsign $2 $3 $4 $5 $6 $7 $8 > /home/pi/CubeSatSim/sim.cfg + echo $callsign $2 $3 $4 $5 $6 $7 $8 $9 + echo $callsign $2 $3 $4 $5 $6 $7 $8 $9 > /home/pi/CubeSatSim/sim.cfg fi if [ "$norestart" = "1" ]; then @@ -268,7 +276,7 @@ elif [ "$1" = "-r" ]; then echo $2 echo -# echo $1 $2 $3 $4 $5 $6 $7 $8 +# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 echo -e "Enter Reset Count (integer): " @@ -288,8 +296,8 @@ elif [ "$1" = "-r" ]; then echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" - echo $1 $resets $3 $4 $5 $6 $7 $8 - echo $1 $resets $3 $4 $5 $6 $7 $8 > /home/pi/CubeSatSim/sim.cfg + echo $1 $resets $3 $4 $5 $6 $7 $8 $9 + echo $1 $resets $3 $4 $5 $6 $7 $8 $9 > /home/pi/CubeSatSim/sim.cfg fi if [ "$norestart" = "1" ]; then @@ -321,7 +329,7 @@ elif [ "$1" = "-l" ]; then echo $3 echo -# echo $1 $2 $3 $4 $5 $6 $7 $8 +# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 echo -e "Enter latitude (decimal degrees, positive is north): " @@ -363,8 +371,8 @@ elif [ "$1" = "-l" ]; then fi echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" - echo $1 $2 $lat $long $5 $6 $7 $8 - echo $1 $2 $lat $long $5 $6 $7 $8 > /home/pi/CubeSatSim/sim.cfg + echo $1 $2 $lat $long $5 $6 $7 $8 $9 + echo $1 $2 $lat $long $5 $6 $7 $8 $9 > /home/pi/CubeSatSim/sim.cfg if [ "$norestart" = "1" ]; then echo @@ -510,7 +518,7 @@ elif [ "$1" = "-q" ]; then echo $6 echo -# echo $1 $2 $3 $4 $5 $6 $7 $8 +# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 echo -e "Enter squelch (integer 0 - 8): " @@ -532,8 +540,8 @@ elif [ "$1" = "-q" ]; then echo echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" echo - echo $1 $2 $3 $4 $5 $sq $7 $8 - echo $1 $2 $3 $4 $4 $sq $7 $8 > /home/pi/CubeSatSim/sim.cfg + echo $1 $2 $3 $4 $5 $sq $7 $8 $9 + echo $1 $2 $3 $4 $4 $sq $7 $8 $9 > /home/pi/CubeSatSim/sim.cfg echo echo "Restarting CubeSatSim with new configuraation file" echo @@ -561,7 +569,7 @@ elif [ "$1" = "-F" ]; then echo $8 echo -# echo $1 $2 $3 $4 $5 $6 $7 $8 +# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 echo "Enter tx frequency as 4XX.XXXX: " read tx @@ -584,8 +592,8 @@ elif [ "$1" = "-F" ]; then echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" - echo $1 $2 $3 $4 $5 $6 $tx $rx - echo $1 $2 $3 $4 $5 $6 $tx $rx > /home/pi/CubeSatSim/sim.cfg + echo $1 $2 $3 $4 $5 $6 $tx $rx $9 + echo $1 $2 $3 $4 $5 $6 $tx $rx $9 > /home/pi/CubeSatSim/sim.cfg # fi # if [ "$norestart" = "1" ]; then @@ -596,7 +604,50 @@ elif [ "$1" = "-F" ]; then echo sudo systemctl restart cubesatsim # fi - +elif [ "$1" = "-H" ]; then + + echo + echo "Editing the High Altitude Balloon (HAB) setting in" + echo "the configuration file for CubeSatSim" + echo + + value=`cat /home/pi/CubeSatSim/sim.cfg` + echo "$value" > /dev/null + set -- $value + + if [ "$9" = "yes" ] || [ "$9" = "y" ]; then + echo "HAB mode is ON" + else + echo "HAB mode is OFF" + fi + + echo + +# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 + + echo "Do you want HAB mode ON (y/n) " + read hab + echo + + if [ "$hab" = "y" ] || [ "$hab" = "yes" ] ; then + hab="yes" + echo "HAB mode is ON" + else + hab="no" + echo "HAB mode is OFF" + fi + + echo + echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" + echo + echo $1 $2 $3 $4 $5 $6 $7 $8 $hab + echo $1 $2 $3 $4 $5 $6 $7 $8 $hab > /home/pi/CubeSatSim/sim.cfg + echo + echo "Restarting CubeSatSim with new configuraation file" + echo + + sudo systemctl restart cubesatsim + fi # sudo systemctl restart cubesatsim From 388aeee8cd41364de39bceda704104f9fd4bee97 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 20 Nov 2023 20:03:03 -0500 Subject: [PATCH 129/174] Update main.c added hab_yes and hab_mode --- main.c | 54 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/main.c b/main.c index b0e12675..1c2edd48 100644 --- a/main.c +++ b/main.c @@ -59,10 +59,11 @@ int main(int argc, char * argv[]) { // char * cfg_buf[100]; - fscanf(config_file, "%s %d %f %f %s %d %s %s", call, & reset_count, & lat_file, & long_file, sim_yes, & squelch, tx, rx); + fscanf(config_file, "%s %d %f %f %s %d %s %s %s", + call, & reset_count, & lat_file, & long_file, sim_yes, & squelch, tx, rx, hab_yes); fclose(config_file); - printf("Config file /home/pi/CubeSatSim/sim.cfg contains %s %d %f %f %s %d %s %s\n", - call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx); + printf("Config file /home/pi/CubeSatSim/sim.cfg contains %s %d %f %f %s %d %s %s %s\n", + call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx, hab_yes); printf("Transmit on %s Receive on %s\n", tx, rx); @@ -90,6 +91,10 @@ int main(int argc, char * argv[]) { if (strcmp(sim_yes, "yes") == 0) sim_mode = TRUE; + if (strcmp(hab_yes, "yes") == 0) + hab_mode = TRUE; + + // FILE * rpitx_stop = popen("sudo systemctl stop rpitx", "r"); FILE * rpitx_stop = popen("sudo systemctl restart rpitx", "r"); pclose(rpitx_stop); @@ -108,9 +113,10 @@ int main(int argc, char * argv[]) { // sleep(2); -#ifdef HAB - printf("HAB mode enabled - balloon icon and BAT only telem and no low voltage shutdown\n"); -#endif +//#ifdef HAB + if (hab_mode) + printf("HAB mode enabled - balloon icon and BAT only telem and no low voltage shutdown\n"); +//#endif // FILE * rpitx_restart = popen("sudo systemctl restart rpitx", "r"); // pclose(rpitx_restart); @@ -830,18 +836,19 @@ int main(int argc, char * argv[]) { // fprintf(stderr, "\n\nbattery_saver_mode : %d current: %f\n", battery_saver_mode, batteryCurrent); #ifndef HAB - if ((batteryCurrent > currentThreshold) && (batteryVoltage < (voltageThreshold + 0.15)) && !sim_mode) + + 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) battery_saver(ON); - } else if ((battery_saver_mode == ON) && (batteryCurrent < 0)) + } 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 ((batteryCurrent > currentThreshold) && (batteryVoltage < voltageThreshold) && !sim_mode) // currentThreshold ensures that this won't happen when running on DC power. + if ((batteryCurrent > currentThreshold) && (batteryVoltage < voltageThreshold) && !sim_mode && !hab_mode) // currentThreshold ensures that this won't happen when running on DC power. { fprintf(stderr, "Battery voltage too low: %f V - shutting down!\n", batteryVoltage); digitalWrite(txLed, txLedOff); @@ -1047,11 +1054,13 @@ void get_tlm(void) { if (ax5043) sprintf(header_str2b, "=%s%c%sShi hi ", header_lat, 0x5c, header_long); // add APRS lat and long else -#ifdef HAB - sprintf(header_str2b, "=%s%c%sOhi hi ", header_lat, 0x2f, header_long); // add APRS lat and long with Balloon HAB icon -#else - sprintf(header_str2b, "=%s%c%c%sShi hi ", header_lat, 0x5c, 0x5c, header_long); // add APRS lat and long with Satellite icon -#endif +//#ifdef HAB + if (hab_mode) + sprintf(header_str2b, "=%s%c%sOhi hi ", header_lat, 0x2f, header_long); // add APRS lat and long with Balloon HAB icon +//#else + else + sprintf(header_str2b, "=%s%c%c%sShi hi ", header_lat, 0x5c, 0x5c, header_long); // add APRS lat and long with Satellite icon +//#endif printf("\n\nString is %s \n\n", header_str2b); strcat(str, header_str2b); @@ -1070,18 +1079,21 @@ void get_tlm(void) { channel, upper_digit(tlm[channel][4]), lower_digit(tlm[channel][4])); // printf("%s",tlm_str); -#ifdef HAB - if (mode != AFSK) -#endif +//#ifdef HAB +// if (mode != AFSK) +//#endif + if ((!hab_mode) || ((hab_mode) && (mode != AFSK))) strcat(str, tlm_str); } -#ifdef HAB - if (mode == AFSK) { +//#ifdef HAB + if ((mode == AFSK) && (hab_mode)) { sprintf(tlm_str, "BAT %4.2f %5.1f ", batteryVoltage, batteryCurrent); strcat(str, tlm_str); - } -#endif + } else + strcat(str, tlm_str); // Is this needed??? + +//#endif // read payload sensor if available /* char sensor_payload[500]; From 41070be35038e523f36c1c41e82cb4739bfd9041 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 20 Nov 2023 20:03:34 -0500 Subject: [PATCH 130/174] Update main.h added hab_yes --- main.h | 1 + 1 file changed, 1 insertion(+) diff --git a/main.h b/main.h index fdbc7323..19079191 100644 --- a/main.h +++ b/main.h @@ -124,6 +124,7 @@ float uptime_sec = 0; long int uptime; char call[5]; char sim_yes[10]; +char hab_yes[10]; int squelch = 3; // default squelch char rx[12], tx[12]; From bdb17d76257068cf7d14aa274a2dd06a8d3cdae4 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 20 Nov 2023 22:35:05 -0500 Subject: [PATCH 131/174] Update main.c print sim mode --- main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index 1c2edd48..e9a167b9 100644 --- a/main.c +++ b/main.c @@ -88,12 +88,14 @@ int main(int argc, char * argv[]) { newGpsTime = millis(); } - if (strcmp(sim_yes, "yes") == 0) + if (strcmp(sim_yes, "yes") == 0) { sim_mode = TRUE; - - if (strcmp(hab_yes, "yes") == 0) + fprintf(stderr, "Sim mode is ON\n"); + } + if (strcmp(hab_yes, "yes") == 0) { hab_mode = TRUE; - + fprintf(stderr, "HAB mode is ON\n"); + } // FILE * rpitx_stop = popen("sudo systemctl stop rpitx", "r"); FILE * rpitx_stop = popen("sudo systemctl restart rpitx", "r"); From b69a78c8e21995b3607640ec242731d5807c02fa Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 20 Nov 2023 22:40:05 -0500 Subject: [PATCH 132/174] Update main.c removed HAB macro --- main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index e9a167b9..1b4eef09 100644 --- a/main.c +++ b/main.c @@ -837,7 +837,7 @@ int main(int argc, char * argv[]) { // if ((batteryVoltage > 1.0) && (batteryVoltage < batteryThreshold)) // no battery INA219 will give 0V, no battery plugged into INA219 will read < 1V // fprintf(stderr, "\n\nbattery_saver_mode : %d current: %f\n", battery_saver_mode, batteryCurrent); -#ifndef HAB +//#ifndef HAB if ((batteryCurrent > currentThreshold) && (batteryVoltage < (voltageThreshold + 0.15)) && !sim_mode && !hab_mode) { @@ -872,7 +872,8 @@ int main(int argc, char * argv[]) { pclose(file6); sleep(10); } -#endif +//#endif + FILE * fp = fopen("/home/pi/CubeSatSim/telem_string.txt", "w"); if (fp != NULL) { printf("Writing telem_string.txt\n"); From 31ee958dc5869daaa20855f6cafb1890342a4ab7 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 20 Nov 2023 22:49:34 -0500 Subject: [PATCH 133/174] Update main.c added more printfs --- main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/main.c b/main.c index 1b4eef09..8b8476e4 100644 --- a/main.c +++ b/main.c @@ -62,24 +62,24 @@ int main(int argc, char * argv[]) { fscanf(config_file, "%s %d %f %f %s %d %s %s %s", call, & reset_count, & lat_file, & long_file, sim_yes, & squelch, tx, rx, hab_yes); fclose(config_file); - printf("Config file /home/pi/CubeSatSim/sim.cfg contains %s %d %f %f %s %d %s %s %s\n", + fprintf(stderr,"Config file /home/pi/CubeSatSim/sim.cfg contains %s %d %f %f %s %d %s %s %s\n", call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx, hab_yes); - printf("Transmit on %s Receive on %s\n", tx, rx); + fprintf(stderr, "Transmit on %s Receive on %s\n", tx, rx); // program_radio(); // do in rpitx instead reset_count = (reset_count + 1) % 0xffff; 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"); + fprintf(stderr, "Valid latitude and longitude in config file\n"); // convert to APRS DDMM.MM format // latitude = toAprsFormat(lat_file); // longitude = toAprsFormat(long_file); latitude = lat_file; longitude = long_file; - printf("Lat/Long %f %f\n", latitude, longitude); - printf("Lat/Long in APRS DDMM.MM format: %07.2f/%08.2f\n", toAprsFormat(latitude), toAprsFormat(longitude)); + fprintf(stderr, "Lat/Long %f %f\n", latitude, longitude); + fprintf(stderr, "Lat/Long in APRS DDMM.MM format: %07.2f/%08.2f\n", toAprsFormat(latitude), toAprsFormat(longitude)); newGpsTime = millis(); } else { // set default @@ -117,7 +117,7 @@ int main(int argc, char * argv[]) { //#ifdef HAB if (hab_mode) - printf("HAB mode enabled - balloon icon and BAT only telem and no low voltage shutdown\n"); + fprintf(stderr, "HAB mode enabled - balloon icon and BAT only telem and no low voltage shutdown\n"); //#endif // FILE * rpitx_restart = popen("sudo systemctl restart rpitx", "r"); From 91a1e3b63115c75de9b0f354aec1b1aa93ae2749 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 20 Nov 2023 22:53:56 -0500 Subject: [PATCH 134/174] Update main.c fixed writing of sim.cfg --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 8b8476e4..ab6a7204 100644 --- a/main.c +++ b/main.c @@ -319,7 +319,7 @@ int main(int argc, char * argv[]) { } */ config_file = fopen("sim.cfg", "w"); - fprintf(config_file, "%s %d %8.4f %8.4f %s %d %s %s", call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx); + fprintf(config_file, "%s %d %8.4f %8.4f %s %d %s %s %s", call, reset_count, lat_file, long_file, sim_yes, squelch, tx, rx, hab_yes); // fprintf(config_file, "%s %d", call, reset_count); fclose(config_file); config_file = fopen("sim.cfg", "r"); From 200939cee615689cd232e18bdef25e881ff64be1 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 21 Nov 2023 09:47:27 -0500 Subject: [PATCH 135/174] Update config cleanup --- config | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/config b/config index 1422bd49..c124f620 100755 --- a/config +++ b/config @@ -39,7 +39,7 @@ if [ "$1" = "" ]; then # sim="no" echo "Simulated Telemetry is OFF" fi - + echo if [ "$9" = "yes" ] || [ "$9" = "y" ]; then echo "HAB mode is ON" @@ -48,16 +48,25 @@ if [ "$1" = "" ]; then fi echo - echo "Current command count is:" + echo -e "Current command count is: " cat /home/pi/CubeSatSim/command_count.txt echo echo - echo "Current beacon transmit mode is:" - cat /home/pi/CubeSatSim/command_tx - echo +# echo "Current beacon transmit mode is:" +# cat /home/pi/CubeSatSim/command_tx +# echo echo "Squelch level is:" echo $6 + echo + + FILE=/home/pi/CubeSatSim/battery_saver + if [ -f "$FILE" ]; then + echo "Battery saver mode is ON" + else + echo "Battery saver is OFF" + fi + echo echo -e "Current sim.cfg configuration file:" echo From 39f9e322abe4076bc4b6e83974ddeacc5d98612c Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 21 Nov 2023 10:00:31 -0500 Subject: [PATCH 136/174] Update config more cleanup --- config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config b/config index c124f620..180689b4 100755 --- a/config +++ b/config @@ -48,7 +48,7 @@ if [ "$1" = "" ]; then fi echo - echo -e "Current command count is: " + echo -n "Current command count is: " cat /home/pi/CubeSatSim/command_count.txt echo echo @@ -56,7 +56,7 @@ if [ "$1" = "" ]; then # cat /home/pi/CubeSatSim/command_tx # echo - echo "Squelch level is:" + echo -n "Squelch level is: " echo $6 echo From 8581a490b0d9ff19f88b0decfe915766ecb89683 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 21 Nov 2023 14:29:54 -0500 Subject: [PATCH 137/174] Update main.c don't change config.txt --- main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index ab6a7204..6ac03a3c 100644 --- a/main.c +++ b/main.c @@ -2316,8 +2316,8 @@ if (setting == ON) { FILE *command = popen("touch /home/pi/CubeSatSim/battery_saver", "r"); pclose(command); 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); +// 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); command = popen("sudo reboot now", "r"); pclose(command); sleep(60); @@ -2331,8 +2331,8 @@ if (setting == ON) { FILE *command = popen("rm /home/pi/CubeSatSim/battery_saver", "r"); pclose(command); fprintf(stderr,"Turning Battery saver mode OFF\n"); - command = popen("sudo sed -i ':a;N;$!ba;s/\'$'\n''force_turbo=1//g' /boot/config.txt", "r"); - pclose(command); +// command = popen("sudo sed -i ':a;N;$!ba;s/\'$'\n''force_turbo=1//g' /boot/config.txt", "r"); +// pclose(command); command = popen("sudo reboot now", "r"); pclose(command); sleep(60); From 9a5390f30993ea4d7afe5ec413a3ff9743add8cd Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 21 Nov 2023 14:32:47 -0500 Subject: [PATCH 138/174] Update config no config,txt change --- config | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/config b/config index 180689b4..0bc7cde9 100755 --- a/config +++ b/config @@ -92,10 +92,10 @@ elif [ "$1" = "-a" ]; then FILE=/home/pi/CubeSatSim/battery_saver if [ -f "$FILE" ]; then echo "Battery saver mode activated." - if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi +# if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi else echo "Not battery saver mode" - sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt +# sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt fi echo "rebooting" @@ -109,10 +109,10 @@ elif [ "$1" = "-m" ]; then FILE=/home/pi/CubeSatSim/battery_saver if [ -f "$FILE" ]; then echo "Battery saver mode activated." - if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi + # if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi else echo "Not battery saver mode" - sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt + # sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt fi echo "rebooting" sudo reboot now @@ -121,7 +121,7 @@ elif [ "$1" = "-m" ]; then elif [ "$1" = "-f" ]; then echo "changing CubeSatSim to FSK mode" sudo echo "f" > /home/pi/CubeSatSim/.mode - if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi +# if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi echo "rebooting" sudo reboot now # sudo systemctl restart cubesatsim @@ -129,7 +129,7 @@ elif [ "$1" = "-f" ]; then elif [ "$1" = "-b" ]; then echo "changing CubeSatSim to BPSK mode" sudo echo "b" > /home/pi/CubeSatSim/.mode - if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi +# if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi echo "rebooting" sudo reboot now # sudo systemctl restart cubesatsim @@ -141,10 +141,10 @@ elif [ "$1" = "-s" ]; then FILE=/home/pi/CubeSatSim/battery_saver if [ -f "$FILE" ]; then echo "Battery saver mode activated." - if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi +# if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi else echo "Not battery saver mode" - sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt +# sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt fi echo "rebooting" sudo reboot now From f4750bb9eb4971833dc35c62dd70d9107c8e1344 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 21 Nov 2023 15:07:08 -0500 Subject: [PATCH 139/174] Update config stop rpitx when rebooting --- config | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config b/config index 0bc7cde9..f0c677a6 100755 --- a/config +++ b/config @@ -115,6 +115,7 @@ elif [ "$1" = "-m" ]; then # sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt fi echo "rebooting" + sudo systemctl stop rpitx sudo reboot now # sudo systemctl restart cubesatsim exit @@ -123,6 +124,7 @@ elif [ "$1" = "-f" ]; then sudo echo "f" > /home/pi/CubeSatSim/.mode # if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi echo "rebooting" + sudo systemctl stop rpitx sudo reboot now # sudo systemctl restart cubesatsim exit @@ -131,6 +133,7 @@ elif [ "$1" = "-b" ]; then sudo echo "b" > /home/pi/CubeSatSim/.mode # if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi echo "rebooting" + sudo systemctl stop rpitx sudo reboot now # sudo systemctl restart cubesatsim exit @@ -147,6 +150,7 @@ elif [ "$1" = "-s" ]; then # sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt fi echo "rebooting" + sudo systemctl stop rpitx sudo reboot now # sudo systemctl restart cubesatsim exit @@ -441,11 +445,13 @@ elif [ "$1" = "-T" ]; then sudo sed -i 's/False/True/g' /home/pi/CubeSatSim/command_tx echo "Command state set to True to enable beacon" echo "rebooting" + sudo systemctl stop rpitx sudo reboot now else sudo sed -i 's/True/False/g' /home/pi/CubeSatSim/command_tx echo "Command state set to False to disable beacon" echo "rebooting" + sudo systemctl stop rpitx sudo reboot now fi From 56e655b9f7f3af7ec86baed2cd3efe45341ee7cb Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 21 Nov 2023 15:32:38 -0500 Subject: [PATCH 140/174] Update main.c APRS always BAT telem --- main.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/main.c b/main.c index 6ac03a3c..c4fb6418 100644 --- a/main.c +++ b/main.c @@ -117,7 +117,7 @@ int main(int argc, char * argv[]) { //#ifdef HAB if (hab_mode) - fprintf(stderr, "HAB mode enabled - balloon icon and BAT only telem and no low voltage shutdown\n"); + fprintf(stderr, "HAB mode enabled - in APRS balloon icon and no battery saver or low voltage shutdown\n"); //#endif // FILE * rpitx_restart = popen("sudo systemctl restart rpitx", "r"); @@ -1072,7 +1072,7 @@ void get_tlm(void) { } // } printf("Str: %s \n", str); - + 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 ", @@ -1085,17 +1085,18 @@ void get_tlm(void) { //#ifdef HAB // if (mode != AFSK) //#endif - if ((!hab_mode) || ((hab_mode) && (mode != AFSK))) + // if ((!hab_mode) || ((hab_mode) && (mode != AFSK))) strcat(str, tlm_str); } + } else { // APRS //#ifdef HAB - if ((mode == AFSK) && (hab_mode)) { +// if ((mode == AFSK) && (hab_mode)) { sprintf(tlm_str, "BAT %4.2f %5.1f ", batteryVoltage, batteryCurrent); strcat(str, tlm_str); - } else - strcat(str, tlm_str); // Is this needed??? - +// } else +// strcat(str, tlm_str); // Is this needed??? + } //#endif // read payload sensor if available /* From e5520abcdd053d9139ef154807a25ad2123406d4 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 21 Nov 2023 15:50:03 -0500 Subject: [PATCH 141/174] Update main.c simulated telem to APRS --- main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index c4fb6418..8daa18ea 100644 --- a/main.c +++ b/main.c @@ -428,7 +428,7 @@ int main(int argc, char * argv[]) { sim_mode = TRUE; - printf("Simulated telemetry mode!\n"); + fprintf(stderr. "Simulated telemetry mode!\n"); srand((unsigned int)time(0)); @@ -702,7 +702,7 @@ int main(int argc, char * argv[]) { batteryVoltage = voltage[map[BAT]]; batteryCurrent = current[map[BAT]]; - if (batteryVoltage < 3.6) { + if (batteryVoltage < 3.7) { SafeMode = 1; printf("Safe Mode!\n"); } else @@ -1092,7 +1092,8 @@ void get_tlm(void) { } else { // APRS //#ifdef HAB // if ((mode == AFSK) && (hab_mode)) { - sprintf(tlm_str, "BAT %4.2f %5.1f ", batteryVoltage, batteryCurrent); +// sprintf(tlm_str, "BAT %4.2f %5.1f ", batteryVoltage, batteryCurrent); + sprintf(tlm_str, "BAT %4.2f %5.1f ", voltage[map[BAT]] , current[map[BAT]] ); strcat(str, tlm_str); // } else // strcat(str, tlm_str); // Is this needed??? From 0ea5b659804689aa132c7bfbf371af16ec49cb70 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 21 Nov 2023 15:51:57 -0500 Subject: [PATCH 142/174] Update main.c typo --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 8daa18ea..3f5fa799 100644 --- a/main.c +++ b/main.c @@ -428,7 +428,7 @@ int main(int argc, char * argv[]) { sim_mode = TRUE; - fprintf(stderr. "Simulated telemetry mode!\n"); + fprintf(stderr, "Simulated telemetry mode!\n"); srand((unsigned int)time(0)); From 3559a954a03b71bf528cec17ed808fdb8510fc95 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 21 Nov 2023 15:57:58 -0500 Subject: [PATCH 143/174] Update config battery_saver restart --- config | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/config b/config index f0c677a6..06ce0862 100755 --- a/config +++ b/config @@ -98,10 +98,11 @@ elif [ "$1" = "-a" ]; then # sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt fi - echo "rebooting" - sudo reboot now -# sudo systemctl restart cubesatsim +# echo "rebooting" +# sudo reboot now + sudo systemctl restart cubesatsim exit + elif [ "$1" = "-m" ]; then echo "changing CubeSatSim to CW mode" sudo echo "m" > /home/pi/CubeSatSim/.mode From df072962c35c61c23326541fb7a414357dd4a58e Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 21 Nov 2023 16:04:53 -0500 Subject: [PATCH 144/174] Update config removed "is activated" --- config | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/config b/config index 06ce0862..4ca87ee1 100755 --- a/config +++ b/config @@ -91,10 +91,10 @@ elif [ "$1" = "-a" ]; then FILE=/home/pi/CubeSatSim/battery_saver if [ -f "$FILE" ]; then - echo "Battery saver mode activated." + 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 - echo "Not battery saver mode" + echo "Battery saver mode os OFF." # sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt fi @@ -109,10 +109,10 @@ elif [ "$1" = "-m" ]; then FILE=/home/pi/CubeSatSim/battery_saver if [ -f "$FILE" ]; then - echo "Battery saver mode activated." + 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 - echo "Not battery saver mode" + echo "Battery saver mode is OFF." # sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt fi echo "rebooting" @@ -144,10 +144,10 @@ elif [ "$1" = "-s" ]; then FILE=/home/pi/CubeSatSim/battery_saver if [ -f "$FILE" ]; then - echo "Battery saver mode activated." + 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 - echo "Not battery saver mode" + echo "Battery saver mode is OFF." # sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt fi echo "rebooting" @@ -486,10 +486,10 @@ elif [ "$1" = "-B" ]; then FILE=/home/pi/CubeSatSim/battery_saver if [ -f "$FILE" ]; then - echo "Battery saver mode is activated." + echo "Battery saver mode is ON." mode=1 else - echo "Battery saver mode is not activated." + echo "Battery saver mode is OFF." mode=0 fi From 2ad4952dd77362db3c93182e4e7588114f873e55 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 21 Nov 2023 16:28:58 -0500 Subject: [PATCH 145/174] Update config reboot for battery_saver change --- config | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/config b/config index 4ca87ee1..e61682b3 100755 --- a/config +++ b/config @@ -64,7 +64,7 @@ if [ "$1" = "" ]; then if [ -f "$FILE" ]; then echo "Battery saver mode is ON" else - echo "Battery saver is OFF" + echo "Battery saver mode is OFF" fi echo @@ -98,9 +98,10 @@ elif [ "$1" = "-a" ]; then # sudo sed -i ':a;N;$!ba;s/\nforce_turbo=1//g' /boot/config.txt fi -# echo "rebooting" -# sudo reboot now - sudo systemctl restart cubesatsim + echo "rebooting" + sudo systemctl stop rpitx + sudo reboot now +# sudo systemctl restart cubesatsim exit elif [ "$1" = "-m" ]; then @@ -514,8 +515,9 @@ elif [ "$1" = "-B" ]; then set -- $value if [ "$1" = "a" ] || [ "$1" = "s" ] || [ "$1" = "m" ] ; then - echo "restarting" - sudo systemctl restart cubesatsim + echo "rebooting" +# sudo systemctl restart cubesatsim + sudo reboot now fi elif [ "$1" = "-q" ]; then From 622947da04ca992cdb9930efae7d81c5f6c65700 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 22 Nov 2023 08:59:07 -0500 Subject: [PATCH 146/174] Update install add force_turbo if not present --- install | 2 ++ 1 file changed, 2 insertions(+) diff --git a/install b/install index 44a6ef3f..636e9b92 100755 --- a/install +++ b/install @@ -221,6 +221,8 @@ sudo raspi-config nonint do_legacy 0 sudo sh -c 'echo "\nboot_delay=0" >> /boot/config.txt' fi + if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi + sudo sh -c 'echo "\n" >> /boot/config.txt' echo "Would you like to reboot to complete the installation (y/n)?" From f667dda598eb6c2deeeb16880706a19bdbac6e5c Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 22 Nov 2023 09:00:16 -0500 Subject: [PATCH 147/174] Update update add force_turbo if not present --- update | 2 ++ 1 file changed, 2 insertions(+) diff --git a/update b/update index 8e9f3c9b..74eeb250 100755 --- a/update +++ b/update @@ -212,6 +212,8 @@ git pull --no-rebase > .updated_p FLAG=1 fi + if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi + #if [ ! -f "/home/pi/CubeSatSim/telem_string.txt" ]; then # sudo apt-get update && sudo apt-get dist-upgrade -y From 39f4605149eaa60621b2d4b60dcb3a635db8e5d3 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 22 Nov 2023 09:07:47 -0500 Subject: [PATCH 148/174] Update update for new version --- update | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/update b/update index 74eeb250..7aa04e5a 100755 --- a/update +++ b/update @@ -212,7 +212,10 @@ git pull --no-rebase > .updated_p FLAG=1 fi - if ! grep -q force_turbo=1 /boot/config.txt ; then sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'; fi + if ! grep -q force_turbo=1 /boot/config.txt ; then + sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt' + FLAG=1 + fi #if [ ! -f "/home/pi/CubeSatSim/telem_string.txt" ]; then From 329045a81f3b3e81c4678c6622d7a13e6f6991ce Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 22 Nov 2023 10:52:59 -0500 Subject: [PATCH 149/174] Update update add defaults to sim.cfg test --- update | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/update b/update index 7aa04e5a..8d22ba85 100755 --- a/update +++ b/update @@ -227,6 +227,29 @@ git pull --no-rebase > .updated_p #fi + value=`cat /home/pi/CubeSatSim/sim.cfg` + echo "$value" > /dev/null + set -- $value + + echo -e "Current sim.cfg configuration file:" + echo + echo $1 $2 $3 $4 $5 $6 $7 $8 $9 + echo + + if [ -z "$1" ] ; then n1="AMSAT" ; else n1=$1 ; fi + if [ -z "$2" ] ; then n2="AMSAT" ; else n2=$2 ; fi + if [ -z "$3" ] ; then n3="AMSAT" ; else n3=$3 ; fi + if [ -z "$4" ] ; then n4="AMSAT" ; else n4=$4 ; fi + if [ -z "$5" ] ; then n5="AMSAT" ; else n5=$5 ; fi + if [ -z "$6" ] ; then n6="AMSAT" ; else n6=$6 ; fi + if [ -z "$7" ] ; then n7="AMSAT" ; else n7=$7 ; fi + if [ -z "$8" ] ; then n8="AMSAT" ; else n8=$8 ; fi + if [ -z "$9" ] ; then n9="AMSAT" ; else n9=$9 ; fi + + echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" + echo + echo $n1 $n2 $n3 $n4 $n5 $n6 $n7 $n8 $n9 + echo $n1 $n2 $n3 $n4 $n5 $n6 $n7 $n8 $n9 > /home/pi/CubeSatSim/sim.cfg if [ $FLAG -eq 1 ]; then echo "systemctl daemon-reload and reboot" From ed1dd9c04e916164b7f6bf00b4824c10f5c50e01 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 22 Nov 2023 10:57:49 -0500 Subject: [PATCH 150/174] Update update only write sim.cfg if changed --- update | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/update b/update index 8d22ba85..fa21943a 100755 --- a/update +++ b/update @@ -227,29 +227,32 @@ git pull --no-rebase > .updated_p #fi - value=`cat /home/pi/CubeSatSim/sim.cfg` - echo "$value" > /dev/null - set -- $value - +changed=0 +value=`cat /home/pi/CubeSatSim/sim.cfg` +echo "$value" > /dev/null +set -- $value + +if [ -z "$1" ] ; then n1="AMSAT" ; else n1=$1 ; fi +if [ -z "$2" ] ; then n2="AMSAT" ; else n2=$2 ; fi +if [ -z "$3" ] ; then n3="AMSAT" ; else n3=$3 ; fi +if [ -z "$4" ] ; then n4="AMSAT" ; else n4=$4 ; fi +if [ -z "$5" ] ; then n5="AMSAT" ; else n5=$5 ; fi +if [ -z "$6" ] ; then n6="AMSAT" ; else n6=$6 ; fi +if [ -z "$7" ] ; then n7="AMSAT" ; else n7=$7 ; fi +if [ -z "$8" ] ; then n8="AMSAT" ; else n8=$8 ; fi +if [ -z "$9" ] ; then n9="AMSAT" ; changed=1 ; else n9=$9 ; fi + +if [ $changed -eq 1 ]; then echo -e "Current sim.cfg configuration file:" echo echo $1 $2 $3 $4 $5 $6 $7 $8 $9 echo - - if [ -z "$1" ] ; then n1="AMSAT" ; else n1=$1 ; fi - if [ -z "$2" ] ; then n2="AMSAT" ; else n2=$2 ; fi - if [ -z "$3" ] ; then n3="AMSAT" ; else n3=$3 ; fi - if [ -z "$4" ] ; then n4="AMSAT" ; else n4=$4 ; fi - if [ -z "$5" ] ; then n5="AMSAT" ; else n5=$5 ; fi - if [ -z "$6" ] ; then n6="AMSAT" ; else n6=$6 ; fi - if [ -z "$7" ] ; then n7="AMSAT" ; else n7=$7 ; fi - if [ -z "$8" ] ; then n8="AMSAT" ; else n8=$8 ; fi - if [ -z "$9" ] ; then n9="AMSAT" ; else n9=$9 ; fi echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" echo echo $n1 $n2 $n3 $n4 $n5 $n6 $n7 $n8 $n9 echo $n1 $n2 $n3 $n4 $n5 $n6 $n7 $n8 $n9 > /home/pi/CubeSatSim/sim.cfg +fi if [ $FLAG -eq 1 ]; then echo "systemctl daemon-reload and reboot" From 63e41e5faf99ca43a534b91c3bb4fce869a9787c Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 22 Nov 2023 11:03:06 -0500 Subject: [PATCH 151/174] Update update added sim.cfg defaults --- update | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/update b/update index fa21943a..92c95b1b 100755 --- a/update +++ b/update @@ -232,15 +232,15 @@ value=`cat /home/pi/CubeSatSim/sim.cfg` echo "$value" > /dev/null set -- $value -if [ -z "$1" ] ; then n1="AMSAT" ; else n1=$1 ; fi -if [ -z "$2" ] ; then n2="AMSAT" ; else n2=$2 ; fi -if [ -z "$3" ] ; then n3="AMSAT" ; else n3=$3 ; fi -if [ -z "$4" ] ; then n4="AMSAT" ; else n4=$4 ; fi -if [ -z "$5" ] ; then n5="AMSAT" ; else n5=$5 ; fi -if [ -z "$6" ] ; then n6="AMSAT" ; else n6=$6 ; fi -if [ -z "$7" ] ; then n7="AMSAT" ; else n7=$7 ; fi -if [ -z "$8" ] ; then n8="AMSAT" ; else n8=$8 ; fi -if [ -z "$9" ] ; then n9="AMSAT" ; changed=1 ; else n9=$9 ; fi +if [ -z "$1" ] ; then n1="AMSAT" ; changed=1 ; else n1=$1 ; fi # callsign +if [ -z "$2" ] ; then n2="0" ; changed=1 ; else n2=$2 ; fi # reset count +if [ -z "$3" ] ; then n3="0" ; changed=1 ; else n3=$3 ; fi # lat +if [ -z "$4" ] ; then n4="0" ; changed=1 ; else n4=$4 ; fi # lon +if [ -z "$5" ] ; then n5="no" ; changed=1 ; else n5=$5 ; fi # sim mode +if [ -z "$6" ] ; then n6="3" ; changed=1 ; else n6=$6 ; fi # squelch +if [ -z "$7" ] ; then n7="434.9000" ; changed=1 ; else n7=$7 ; fi # transmit frequency +if [ -z "$8" ] ; then n8="436.0000" ; changed=1 ; else n8=$8 ; fi # receive frequency +if [ -z "$9" ] ; then n9="no" ; changed=1 ; else n9=$9 ; fi # hab mode if [ $changed -eq 1 ]; then echo -e "Current sim.cfg configuration file:" From df597d5df8f288e48ff35f126c75465ffed37929 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 22 Nov 2023 11:08:02 -0500 Subject: [PATCH 152/174] Update update cleanup --- update | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/update b/update index 92c95b1b..f0d2d72b 100755 --- a/update +++ b/update @@ -246,12 +246,11 @@ if [ $changed -eq 1 ]; then echo -e "Current sim.cfg configuration file:" echo echo $1 $2 $3 $4 $5 $6 $7 $8 $9 - echo - echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" echo echo $n1 $n2 $n3 $n4 $n5 $n6 $n7 $n8 $n9 echo $n1 $n2 $n3 $n4 $n5 $n6 $n7 $n8 $n9 > /home/pi/CubeSatSim/sim.cfg + echo fi if [ $FLAG -eq 1 ]; then From 9dce00eed18bb0e300f8daeed5d9079e46a2b4d6 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 22 Nov 2023 11:25:56 -0500 Subject: [PATCH 153/174] Update config Configuraation --- config | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/config b/config index e61682b3..025f8990 100755 --- a/config +++ b/config @@ -216,9 +216,9 @@ elif [ "$1" = "-t" ]; then echo "Simulated Telemetry is OFF" fi - echo - echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" - echo +# echo + echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" +# echo echo $1 $2 $3 $4 $sim $6 $7 $8 $9 echo $1 $2 $3 $4 $sim $6 $7 $8 $9 > /home/pi/CubeSatSim/sim.cfg echo @@ -257,7 +257,7 @@ elif [ "$1" = "-c" ]; then norestart=1 else - echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" + echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" echo $callsign $2 $3 $4 $5 $6 $7 $8 $9 echo $callsign $2 $3 $4 $5 $6 $7 $8 $9 > /home/pi/CubeSatSim/sim.cfg @@ -309,7 +309,7 @@ elif [ "$1" = "-r" ]; then norestart=1 else - echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" + echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" echo $1 $resets $3 $4 $5 $6 $7 $8 $9 echo $1 $resets $3 $4 $5 $6 $7 $8 $9 > /home/pi/CubeSatSim/sim.cfg @@ -385,7 +385,7 @@ elif [ "$1" = "-l" ]; then echo "Keeping value of" $long fi - echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" + echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" echo $1 $2 $lat $long $5 $6 $7 $8 $9 echo $1 $2 $lat $long $5 $6 $7 $8 $9 > /home/pi/CubeSatSim/sim.cfg @@ -555,9 +555,9 @@ elif [ "$1" = "-q" ]; then echo "Keeping value of" $sq fi - echo - echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" - echo +# echo + echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" +# echo echo $1 $2 $3 $4 $5 $sq $7 $8 $9 echo $1 $2 $3 $4 $4 $sq $7 $8 $9 > /home/pi/CubeSatSim/sim.cfg echo @@ -608,7 +608,7 @@ elif [ "$1" = "-F" ]; then fi # else - echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" + echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" echo $1 $2 $3 $4 $5 $6 $tx $rx $9 echo $1 $2 $3 $4 $5 $6 $tx $rx $9 > /home/pi/CubeSatSim/sim.cfg @@ -655,9 +655,9 @@ elif [ "$1" = "-H" ]; then echo "HAB mode is OFF" fi - echo - echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" - echo +# echo + echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" +# echo echo $1 $2 $3 $4 $5 $6 $7 $8 $hab echo $1 $2 $3 $4 $5 $6 $7 $8 $hab > /home/pi/CubeSatSim/sim.cfg echo From 56bca8de37ecf31748643c8d6841f11bdbc1e306 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 22 Nov 2023 11:29:34 -0500 Subject: [PATCH 154/174] Update config rest of configuraation --- config | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/config b/config index 025f8990..96d58544 100755 --- a/config +++ b/config @@ -67,9 +67,9 @@ if [ "$1" = "" ]; then echo "Battery saver mode is OFF" fi - echo +# echo echo -e "Current sim.cfg configuration file:" - echo +# echo echo $1 $2 $3 $4 $5 $6 $7 $8 $9 echo @@ -222,7 +222,7 @@ elif [ "$1" = "-t" ]; then echo $1 $2 $3 $4 $sim $6 $7 $8 $9 echo $1 $2 $3 $4 $sim $6 $7 $8 $9 > /home/pi/CubeSatSim/sim.cfg echo - echo "Restarting CubeSatSim with new configuraation file" + echo "Restarting CubeSatSim with new configuration file" echo sudo systemctl restart cubesatsim @@ -267,7 +267,7 @@ elif [ "$1" = "-c" ]; then echo else echo - echo "Restarting CubeSatSim with new configuraation file" + echo "Restarting CubeSatSim with new configuration file" echo sudo systemctl restart cubesatsim fi @@ -319,7 +319,7 @@ elif [ "$1" = "-r" ]; then echo else echo - echo "Restarting CubeSatSim with new configuraation file" + echo "Restarting CubeSatSim with new configuration file" echo sudo systemctl restart cubesatsim fi @@ -393,7 +393,7 @@ elif [ "$1" = "-l" ]; then echo else echo - echo "Restarting CubeSatSim with new configuraation file" + echo "Restarting CubeSatSim with new configuration file" echo sudo systemctl restart cubesatsim fi @@ -561,7 +561,7 @@ elif [ "$1" = "-q" ]; then echo $1 $2 $3 $4 $5 $sq $7 $8 $9 echo $1 $2 $3 $4 $4 $sq $7 $8 $9 > /home/pi/CubeSatSim/sim.cfg echo - echo "Restarting CubeSatSim with new configuraation file" + echo "Restarting CubeSatSim with new configuration file" echo sudo systemctl restart cubesatsim @@ -618,7 +618,7 @@ elif [ "$1" = "-F" ]; then # echo # else echo - echo "Restarting CubeSatSim with new configuraation file" + echo "Restarting CubeSatSim with new configuration file" echo sudo systemctl restart cubesatsim # fi @@ -661,7 +661,7 @@ elif [ "$1" = "-H" ]; then echo $1 $2 $3 $4 $5 $6 $7 $8 $hab echo $1 $2 $3 $4 $5 $6 $7 $8 $hab > /home/pi/CubeSatSim/sim.cfg echo - echo "Restarting CubeSatSim with new configuraation file" + echo "Restarting CubeSatSim with new configuration file" echo sudo systemctl restart cubesatsim From 550c8b0c8b6cac4cfe54220b3c7f258f832ebcde Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 22 Nov 2023 13:07:47 -0500 Subject: [PATCH 155/174] Update payload_pico.ino gpio 0 and 1 to input --- stempayload/payload_pico/payload_pico.ino | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stempayload/payload_pico/payload_pico.ino b/stempayload/payload_pico/payload_pico.ino index bbebb246..a56ae7bd 100644 --- a/stempayload/payload_pico/payload_pico.ino +++ b/stempayload/payload_pico/payload_pico.ino @@ -157,6 +157,9 @@ void loop() { } void config_gpio() { + + pinMode(0, INPUT); + pinMode(1, INPUT); // set all Pico GPIO connected pins to input for (int i = 6; i < 22; i++) { From 5ddc12fe7c402e4dbb489d0691316325c9da7087 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 22 Nov 2023 17:49:32 -0500 Subject: [PATCH 156/174] Update payload_pico.ino --- stempayload/payload_pico/payload_pico.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stempayload/payload_pico/payload_pico.ino b/stempayload/payload_pico/payload_pico.ino index a56ae7bd..1a987912 100644 --- a/stempayload/payload_pico/payload_pico.ino +++ b/stempayload/payload_pico/payload_pico.ino @@ -113,7 +113,7 @@ void setup() { // otherwise, run CubeSatSim Pico code - Serial.println("CubeSatSim Pico Payload v0.2 starting...\n"); + Serial.println("CubeSatSim Pico Payload v0.3 starting...\n"); /**/ if (check_for_wifi()) { From e502c87527a8d541a3a767c28d6a4212d1adb726 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 22 Nov 2023 18:08:58 -0500 Subject: [PATCH 157/174] Update payload_pico.ino GPS and AN --- stempayload/payload_pico/payload_pico.ino | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stempayload/payload_pico/payload_pico.ino b/stempayload/payload_pico/payload_pico.ino index 1a987912..0bc4d7a5 100644 --- a/stempayload/payload_pico/payload_pico.ino +++ b/stempayload/payload_pico/payload_pico.ino @@ -462,13 +462,13 @@ void payload_OK_only() Temp = T1 + (sensorValue - R1) *((T2 - T1)/(R2 - R1)); - Serial.print(" XS2 "); + Serial.print(" GPS "); Serial.print(Sensor1,4); Serial.print(" "); Serial.print(Sensor2,4); Serial.print(" "); Serial.print(Sensor3,2); - Serial.print(" MQ "); + Serial.print(" AN "); Serial.println(sensorValue); // ,0); if (mpuPresent) { @@ -610,13 +610,13 @@ void payload_OK_only() //Serial.println(sensorValue); Temp = T1 + (sensorValue - R1) *((T2 - T1)/(R2 - R1)); - Serial1.print(" XS2 "); + Serial1.print(" GPS "); Serial1.print(Sensor1,4); Serial1.print(" "); Serial1.print(Sensor2,4); Serial1.print(" "); Serial1.print(Sensor3,2); - Serial1.print(" MQ "); + Serial1.print(" AN "); Serial1.print(sensorValue); //,0); // Serial1.println("END_FLAG"); Serial1.println(sensor_end_flag); From fddb27bb90329f65b760b6d37bc339c1bdec58d6 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 22 Nov 2023 18:16:25 -0500 Subject: [PATCH 158/174] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 354ac31e..92bbd682 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ To get the software follow these steps: `cd CubeSatSim` -`git checkout beta-v1.3.1` +`git checkout beta-v1.3.1.1` You are now ready to install the software using this script in the CubeSatSim directory: From 9e031a560bfe595c7a188eea444fd0058f2246b6 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 22 Nov 2023 22:07:10 -0500 Subject: [PATCH 159/174] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 92bbd682..06dff875 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ To get the software follow these steps: `git checkout beta-v1.3.1.1` -You are now ready to install the software using this script in the CubeSatSim directory: +# You are now ready to install the software using this script in the CubeSatSim directory: `./install` From 108f841d10af4171d8220ff5a46313f8c5633e3b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 22 Nov 2023 22:07:33 -0500 Subject: [PATCH 160/174] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 06dff875..9c859551 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ To get the software follow these steps: `git checkout beta-v1.3.1.1` -# You are now ready to install the software using this script in the CubeSatSim directory: +`# You are now ready to install the software using this script in the CubeSatSim directory:` `./install` From 736183eb22b2fd6db0734901203e6b4ac3141af3 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 22 Nov 2023 22:55:45 -0500 Subject: [PATCH 161/174] Update install added sim.cfg update --- install | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/install b/install index 636e9b92..91ad9052 100755 --- a/install +++ b/install @@ -225,6 +225,32 @@ sudo raspi-config nonint do_legacy 0 sudo sh -c 'echo "\n" >> /boot/config.txt' +changed=0 +value=`cat /home/pi/CubeSatSim/sim.cfg` +echo "$value" > /dev/null +set -- $value + +if [ -z "$1" ] ; then n1="AMSAT" ; changed=1 ; else n1=$1 ; fi # callsign +if [ -z "$2" ] ; then n2="0" ; changed=1 ; else n2=$2 ; fi # reset count +if [ -z "$3" ] ; then n3="0" ; changed=1 ; else n3=$3 ; fi # lat +if [ -z "$4" ] ; then n4="0" ; changed=1 ; else n4=$4 ; fi # lon +if [ -z "$5" ] ; then n5="no" ; changed=1 ; else n5=$5 ; fi # sim mode +if [ -z "$6" ] ; then n6="3" ; changed=1 ; else n6=$6 ; fi # squelch +if [ -z "$7" ] ; then n7="434.9000" ; changed=1 ; else n7=$7 ; fi # transmit frequency +if [ -z "$8" ] ; then n8="436.0000" ; changed=1 ; else n8=$8 ; fi # receive frequency +if [ -z "$9" ] ; then n9="no" ; changed=1 ; else n9=$9 ; fi # hab mode + +if [ $changed -eq 1 ]; then + echo -e "Current sim.cfg configuration file:" + echo + echo $1 $2 $3 $4 $5 $6 $7 $8 $9 + echo -e "\nCubeSatSim configuraation sim.cfg file updated to: \n" + echo + echo $n1 $n2 $n3 $n4 $n5 $n6 $n7 $n8 $n9 + echo $n1 $n2 $n3 $n4 $n5 $n6 $n7 $n8 $n9 > /home/pi/CubeSatSim/sim.cfg + echo +fi + echo "Would you like to reboot to complete the installation (y/n)?" read -r ANS From 19bb63002cb5ea4dacb0ced6c9fa89aa360fb084 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 23 Nov 2023 09:01:03 -0500 Subject: [PATCH 162/174] Update install with --no-rebase --- install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install b/install index 91ad9052..6f1a01eb 100755 --- a/install +++ b/install @@ -57,7 +57,7 @@ sudo pip3 install adafruit-blinka RPI.GPIO adafruit-extended-bus adafruit-circui cd ~/CubeSatSim -git pull +git pull --no-rebase make debug From c9ea7e10ffdedd066f9fa3fba608d10da36a0bfe Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Thu, 23 Nov 2023 09:06:11 -0500 Subject: [PATCH 163/174] Update install default mode FSK --- install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install b/install index 6f1a01eb..c05da114 100755 --- a/install +++ b/install @@ -66,7 +66,7 @@ if [ -f "$FILE" ]; then echo "$FILE exists." else echo "creating $FILE" - echo "ARG1=s" > .mode + echo "f" > .mode fi cd From da68e0e1dd7fd75d643715e1ee1194074f13f817 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Dec 2023 15:42:18 -0500 Subject: [PATCH 164/174] Update rpitx.py don't use ./config script to change mode --- rpitx.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/rpitx.py b/rpitx.py index aa4bb5de..9211e162 100644 --- a/rpitx.py +++ b/rpitx.py @@ -110,16 +110,16 @@ def increment_mode(): sleep(2.5) try: -# file = open("/home/pi/CubeSatSim/.mode", "w") -# count_string = str(command_count) -# file.write(mode) -# file.close() -# print(".mode file written") + file = open("/home/pi/CubeSatSim/.mode", "w") + count_string = str(command_count) + file.write(mode) + file.close() + print(".mode file written") GPIO.setwarnings(False) GPIO.output(txLed, 0) GPIO.output(powerPin, 0) -# print("sudo reboot -h now") + print("sudo reboot -h now") GPIO.setwarnings(False) GPIO.setup(powerPin, GPIO.OUT) GPIO.output(powerPin, 0); @@ -127,7 +127,8 @@ def increment_mode(): # release = True; print("Changing mode now") - system("/home/pi/CubeSatSim/config -" + mode) +# system("/home/pi/CubeSatSim/config -" + mode) + system("reboot -h now") sleep(10); except: From 0507620f26ff4509105d2928613bcb3882987b50 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 2 Dec 2023 15:44:55 -0500 Subject: [PATCH 165/174] Update config cleanup --- config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config b/config index 96d58544..eaf52e7c 100755 --- a/config +++ b/config @@ -67,7 +67,7 @@ if [ "$1" = "" ]; then echo "Battery saver mode is OFF" fi -# echo + echo echo -e "Current sim.cfg configuration file:" # echo From 3fdd053113706b46c0978dc776d30eb4ebb3af0c Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 5 Dec 2023 08:50:23 -0500 Subject: [PATCH 166/174] Update rpitx.py turn off debugging mode --- rpitx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index 9211e162..012ee0d4 100644 --- a/rpitx.py +++ b/rpitx.py @@ -219,7 +219,7 @@ print(txLed) # GPIO.setup(27, GPIO.OUT) # GPIO.output(27, 0) -debug_mode = 1 #no debugging rpitx +debug_mode = 0 #no debugging rpitx if __name__ == "__main__": From ec1d595093b6f2dba82cec41fc6a153e5ab548d4 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 9 Dec 2023 09:22:13 -0500 Subject: [PATCH 167/174] Update rpitx.py more time at start of APRS packet --- rpitx.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpitx.py b/rpitx.py index 012ee0d4..2197c7bf 100644 --- a/rpitx.py +++ b/rpitx.py @@ -388,7 +388,7 @@ if __name__ == "__main__": if (txc): output(pd, 1) output (ptt, 0) - sleep(0.1) + sleep(0.2) # add more time at start system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/telem.wav") sleep(0.1) output (ptt, 1) From d7b182c1ef49f9ea978015a32ae3f5520992b044 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 10 Dec 2023 16:15:10 -0500 Subject: [PATCH 168/174] Update update pi-power-button uses FLAG=1 to reboot --- update | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/update b/update index f0d2d72b..4df23d26 100755 --- a/update +++ b/update @@ -143,20 +143,22 @@ git pull --no-rebase > .updated_p echo "updating pi-power-button." script/install + + FLAG=1 - echo "You need to reboot to complete this update. Reboot now (y/n)?" +# echo "You need to reboot to complete this update. Reboot now (y/n)?" - read -r ANS +# read -r ANS - if [ "$ANS" = "y" ]; then + # if [ "$ANS" = "y" ]; then - sudo reboot now + # sudo reboot now - else + # else - echo "The CubeSatSim software may not work correctly until you reboot." + # echo "The CubeSatSim software may not work correctly until you reboot." - fi + # fi else echo "nothing to do for pi-power-button." From 8030080c1972dc37c0f106e91a197e173e6004e5 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 12 Dec 2023 11:52:24 -0500 Subject: [PATCH 169/174] Update rpitx.py formatting of tx and rx frequency --- rpitx.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/rpitx.py b/rpitx.py index 2197c7bf..82c94710 100644 --- a/rpitx.py +++ b/rpitx.py @@ -279,13 +279,21 @@ if __name__ == "__main__": else: sq = '0' if len(config) > 6: - tx = config[6] - print(tx) +# tx = config[6] + txf = float(config[6]) + print(txf) +# print( "{:.4f}".format(txf)) + tx = "{:.4f}".format(txf) + print(tx) else: tx = '434.9000' if len(config) > 7: - rx = config[7] - print(rx) +# rx = config[7] + rxf = float(config[7]) + print(rxf) +# print( "{:.4f}".format(rxf)) + rx = "{:.4f}".format(rxf) + print(rx) else: rx = '435.0000' print(config) From 52529700971da455ee4dd4134bfaa0a54130d568 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 13 Dec 2023 10:57:15 -0500 Subject: [PATCH 170/174] Update main.c read sensors in sim mode --- main.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index 3f5fa799..c09d269a 100644 --- a/main.c +++ b/main.c @@ -545,7 +545,7 @@ int main(int argc, char * argv[]) { get_tlm_fox(); // fill transmit buffer with reset count 0 packets that will be ignored firstTime = 1; - if (!sim_mode) +// if (!sim_mode) // always read sensors, even in sim mode { strcpy(pythonStr, pythonCmd); strcat(pythonStr, busStr); @@ -603,7 +603,42 @@ int main(int argc, char * argv[]) { printf("++++ Loop time: %5.3f sec +++++\n", (millis() - loopTime)/1000.0); fflush(stdout); loopTime = millis(); - + + { + int count1; + char * token; + fputc('\n', file1); + fgets(cmdbuffer, 1000, file1); + fprintf(stderr, "Python read Result: %s\n", cmdbuffer); + + const char space[2] = " "; + token = strtok(cmdbuffer, space); + + for (count1 = 0; count1 < 8; count1++) { + if (token != NULL) { + voltage[count1] = (float) atof(token); + #ifdef DEBUG_LOGGING +// printf("voltage: %f ", voltage[count1]); + #endif + token = strtok(NULL, space); + if (token != NULL) { + current[count1] = (float) atof(token); + if ((current[count1] < 0) && (current[count1] > -0.5)) + current[count1] *= (-1.0f); + #ifdef DEBUG_LOGGING +// printf("current: %f\n", current[count1]); + #endif + token = strtok(NULL, space); + } + } + if (voltage[map[BAT]] == 0.0) + batteryVoltage = 4.5; + else + batteryVoltage = voltage[map[BAT]]; + batteryCurrent = current[map[BAT]]; + + } + if (sim_mode) { // simulated telemetry double time = ((long int)millis() - time_start) / 1000.0; @@ -671,6 +706,9 @@ int main(int argc, char * argv[]) { // end of simulated telemetry } else { +// code moved + +/* int count1; char * token; fputc('\n', file1); @@ -697,10 +735,16 @@ int main(int argc, char * argv[]) { token = strtok(NULL, space); } } + if (voltage[map[BAT]] == 0.0) + batteryVoltage = 4.5; + else + batteryVoltage = voltage[map[BAT]]; + batteryCurrent = current[map[BAT]]; +*/ } - batteryVoltage = voltage[map[BAT]]; - batteryCurrent = current[map[BAT]]; +// batteryVoltage = voltage[map[BAT]]; +// batteryCurrent = current[map[BAT]]; if (batteryVoltage < 3.7) { SafeMode = 1; From fc81909d9e78192f900e1961ae9a666ca0e08b45 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 13 Dec 2023 11:43:27 -0500 Subject: [PATCH 171/174] Update main.c don't show voltage and current in sstv if not sensor --- main.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index c09d269a..4191c9d9 100644 --- a/main.c +++ b/main.c @@ -919,9 +919,13 @@ int main(int argc, char * argv[]) { //#endif FILE * fp = fopen("/home/pi/CubeSatSim/telem_string.txt", "w"); - if (fp != NULL) { - printf("Writing telem_string.txt\n"); - fprintf(fp, "BAT %4.2fV %5.1fmA\n", batteryVoltage, batteryCurrent); + if ((fp != NULL) { + printf("Writing telem_string.txt\n"); + if (batteryVoltage != 4.5) + fprintf(fp, "BAT %4.2fV %5.1fmA\n", batteryVoltage, batteryCurrent); + else + fprintf(fp, "\n"); // don't show voltage and current if it isn't a sensor value + fclose(fp); } else printf("Error writing to telem_string.txt\n"); From b96200aff09b1234eda3a120a588c0cc8f444281 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Wed, 13 Dec 2023 11:48:42 -0500 Subject: [PATCH 172/174] Update main.c typo --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 4191c9d9..ef252f27 100644 --- a/main.c +++ b/main.c @@ -919,7 +919,7 @@ int main(int argc, char * argv[]) { //#endif FILE * fp = fopen("/home/pi/CubeSatSim/telem_string.txt", "w"); - if ((fp != NULL) { + if (fp != NULL) { printf("Writing telem_string.txt\n"); if (batteryVoltage != 4.5) fprintf(fp, "BAT %4.2fV %5.1fmA\n", batteryVoltage, batteryCurrent); From 4a2fb41d9b0e08bad055d8bd58a02684304e33d0 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Dec 2023 08:07:49 -0500 Subject: [PATCH 173/174] Update config change HAB to Balloon --- config | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/config b/config index eaf52e7c..1e1228fd 100755 --- a/config +++ b/config @@ -42,9 +42,9 @@ if [ "$1" = "" ]; then echo if [ "$9" = "yes" ] || [ "$9" = "y" ]; then - echo "HAB mode is ON" + echo "Balloon mode is ON" else - echo "HAB mode is OFF" + echo "Balloon mode is OFF" fi echo @@ -625,7 +625,7 @@ elif [ "$1" = "-F" ]; then elif [ "$1" = "-H" ]; then echo - echo "Editing the High Altitude Balloon (HAB) setting in" + echo "Editing the Balloon mode setting in" echo "the configuration file for CubeSatSim" echo @@ -634,25 +634,25 @@ elif [ "$1" = "-H" ]; then set -- $value if [ "$9" = "yes" ] || [ "$9" = "y" ]; then - echo "HAB mode is ON" + echo "Balloon mode is ON" else - echo "HAB mode is OFF" + echo "Balloon mode is OFF" fi echo # echo $1 $2 $3 $4 $5 $6 $7 $8 $9 - echo "Do you want HAB mode ON (y/n) " + echo "Do you want Balloon mode ON (y/n) " read hab echo if [ "$hab" = "y" ] || [ "$hab" = "yes" ] ; then hab="yes" - echo "HAB mode is ON" + echo "Balloon mode is ON" else hab="no" - echo "HAB mode is OFF" + echo "Balloon mode is OFF" fi # echo From 2621dd23a52d0ccd1c64a15804991ca0e9f1966e Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 16 Dec 2023 08:16:35 -0500 Subject: [PATCH 174/174] Update config Balloon mode --- config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config b/config index 1e1228fd..3fc44235 100755 --- a/config +++ b/config @@ -179,7 +179,7 @@ elif [ "$1" = "-h" ]; then 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 HAB mode" + echo " -H Chnage the Balloon mode" echo exit @@ -624,7 +624,7 @@ elif [ "$1" = "-F" ]; then # fi elif [ "$1" = "-H" ]; then - echo +# echo echo "Editing the Balloon mode setting in" echo "the configuration file for CubeSatSim" echo