From ad3a12e4a16a14ec28e89f794840a135f9310855 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 21 Feb 2026 08:22:55 -0500 Subject: [PATCH 01/26] Refactor GPIO handling with output and input functions Refactor GPIO handling by creating output and input functions. Replace direct GPIO calls with these functions for better abstraction and error handling. --- transmit.py | 402 ++++++++++++++++++++++------------------------------ 1 file changed, 168 insertions(+), 234 deletions(-) diff --git a/transmit.py b/transmit.py index 9a249d82..7353d1ad 100644 --- a/transmit.py +++ b/transmit.py @@ -1,7 +1,7 @@ #!/usr/bin/env python -import RPi.GPIO as GPIO -from RPi.GPIO import output +#import RPi.GPIO as GPIO +#from RPi.GPIO import output #import subprocess import time from time import sleep @@ -14,6 +14,41 @@ import serial import random import subprocess +def output(pin, value): + command = "gpio -g write " + str(pin) + " " + str(value) + system(command) + +def input(pin): + # command = "gpio -g read " + str(pin) + query = ["gpio", "-g", "read", str(pin)] # Read GPIO pin + try: + result = subprocess.run(query, capture_output=True, text=True, check=True) + print(f"Command run was: {query}") + print("Sucess!") + print(f"Output of the command (stdout): {result}") + return result + except subprocess.CalledProcessError as e: + print(f"Command failed with return code: {e.returncode}") + print(f"Command run was: {e.cmd}") + print(f"Output of the command (stdout): {e.stdout}") + print(f"Error output of the command (stderr): {e.stderr}") + return 0 + +def setup(pin, config): + if config == "in" or config == "out" or config == "up" or config == "down": + command = "gpio -g mode " + str(powerPin) + " " + config + system(command) + else + print(f"Unknown GPIO setup configuration: {config}") + +def blink(times): + powerPin = 16 + for i in range(times): + system("gpio -g write " + str(powerPin) + " 0") # blink two times + sleep(0.1) + system("gpio -g write " + str(powerPin) + " 1") + sleep(0.1) + def sim_failure_check(): try: global card @@ -46,7 +81,6 @@ def sim_failure_check(): except: print("No failure mode") card = "Headphones" -# card = "Device" if sim_config: sim_mode = True @@ -65,9 +99,9 @@ def battery_saver_check(): def blink(times): powerPin = 16 for i in range(times): - system("gpio -g write " + str(powerPin) + " 0") # blink two times + output(powerPin, 0) # blink sleep(0.1) - system("gpio -g write " + str(powerPin) + " 1") + output(powerPin, 1) sleep(0.1) def increment_mode(): @@ -114,13 +148,13 @@ def increment_mode(): file.close() print(".mode file written") - GPIO.setwarnings(False) - system("gpio -g write " + str(txLed) + " 0") - system("gpio -g write " + str(powerPin) + " 0") +# GPIO.setwarnings(False) + output(txLed, 0) + output(powerPin, 0) print("sudo reboot -h now") - GPIO.setwarnings(False) - system("gpio -g mode " + str(powerPin) + " out") - system("gpio -g write " + str(powerPin) + " 0"); +# GPIO.setwarnings(False) + setup(powerPin, "out") + output(powerPin, 0); # system("reboot -h now") # release = True; @@ -181,7 +215,7 @@ def camera_photo(): return True else: return False - + print("CubeSatSim v2.2 transmit.py starting...") pd = 21 @@ -193,70 +227,54 @@ powerPin = 16 command_tx = True -try: - system("gpio -g write " + str(powerPin) + " 1") - GPIO.setmode(GPIO.BCM) - 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(txc_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP) - GPIO.setup(green, GPIO.OUT) - GPIO.setup(27, GPIO.IN) -except: - print("gpio setup problem") - system("gpio -g mode 27 IN") -try: - GPIO.setup(27, GPIO.IN, pull_up_down=GPIO.PUD_UP) -except: - print("Can't set txLed") +GPIO.setmode(GPIO.BCM) +GPIO.setwarnings(False) +setup(13, "up") +setup(12, "up") +setup(27, "up") +setup(txc_pin, "up") +setup(green, "out") +output(powerPin, 1) transmit = False txLed = 27 -# txLed = 17 -txLedOn = 1 -txLedOff = 0 -if GPIO.input(12) == False: +1 = 1 +0 = 0 +if input(12) == False: print("LPF present") transmit = True else: print("No LPF") -# system("gpio -g mode " + str(txLed) + " out") -# system("gpio -g write " + str(txLed) + " 0") +# GPIO.setup(txLed, GPIO.OUT) +# output(txLed, 0) -GPIO.setmode(GPIO.BCM) # Repeat to make LED work on Pi 4 -GPIO.setwarnings(False) -try: - system("gpio -g mode " + str(txLed) + " out") -except: - print("Can't set txLed") +# GPIO.setmode(GPIO.BCM) # Repeat to make LED work on Pi 4 +# GPIO.setwarnings(False) +setup(txLed, "out") -GPIO.setup(pd, GPIO.OUT) +setup(pd, "out") #output(pd, 1) output(pd, 0) -GPIO.setup(ptt, GPIO.OUT) +setup(ptt, "out") output (ptt, 1) txc = False -if GPIO.input(txc_pin) == False: +if input(txc_pin) == False: print("TXC is present") txc = True; else: print("TXC not present") # txc = False # forcing it off - -try: - system("gpio -g write " + str(txLed) + " 1") - sleep(1) - system("gpio -g write " + str(txLed) + " 0") -except: - print("Can't set txLed") +output(txLed, 1) +sleep(1) +output(txLed, 0) battery_saver_check() -# print(txLedOn) +# print(1) print(txLed) # GPIO.setup(27, GPIO.OUT) # GPIO.output(27, 0) @@ -440,10 +458,10 @@ if __name__ == "__main__": try: f = open("/home/pi/CubeSatSim/command_control", "r") f.close() - GPIO.setmode(GPIO.BCM) - GPIO.setwarnings(False) - GPIO.setup(squelch, GPIO.IN, pull_up_down=GPIO.PUD_UP) ## pull up in case pin is not connected - if GPIO.input(squelch) == False: +# GPIO.setmode(GPIO.BCM) +# GPIO.setwarnings(False) + setup(squelch, "up") ## pull up in case pin is not connected + if input(squelch) == False: print("squelch not set correctly, no command input!") else: if (mode != 'n') and (mode != 'x'): @@ -458,34 +476,13 @@ if __name__ == "__main__": print(callsign) - GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4 - try: - print(txLed) - print(txLedOn) - system("gpio -g mode " + str(txLed) + " out") - except: - print("Can't set txLed") - -# card = "Headphones" # default using pcm audio output of Pi Zero - card = "Device" # using USB sound card for audio output +# GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4 +# print(txLed) +# print(1) + setup(txLed, "out") - query = ["grep", "VERSION_CODENAME=bullseye", "/etc/os-release"] - try: - result = subprocess.run(query, capture_output=True, text=True, check=True) - print(f"Command run was: {query}") - os_status = result.stdout.strip() - print(f"Output of the command (stdout): {os_status}") - except subprocess.CalledProcessError as e: -# print(f"Command failed with return code: {e.returncode}") - print(f"Command run was: {e.cmd}") - os_status = e.stdout.strip() - print(f"Output of the command (stdout): {e.stdout}") -# print(f"Error output of the command (stderr): {e.stderr}") - if os_status != "VERSION_CODENAME=bullseye": - os_status = "bookworm" - else: - os_status = "bullseye" - print (os_status) + card = "Headphones" # default using pcm audio output of Pi Zero +# card = "Device" # using USB sound card for audio output query = ["sudo", "systemctl", "is-active", "gpsd.socket"] try: @@ -532,12 +529,9 @@ if __name__ == "__main__": print("Don't transmit CW ID since APRS HAB mode is active") else: if (((mode == 'a') or (mode == 'b') or (mode == 'f') or (mode == 's') or (mode == 'j')) and (command_tx == True) and (skip == False)) or ((mode == 'e') and (command_tx == True)): # battery_saver_mode - GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 - try: - system("gpio -g mode " + str(txLed) + " out") - system("gpio -g write " + str(txLed) + " 1") - except: - print("Can't set txLed") +# GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 + setup(txLed, "out") + output(txLed, 1) print("Transmit CW ID") status = "" if not no_command: @@ -548,10 +542,7 @@ if __name__ == "__main__": system("echo 'hi hi de " + callsign + status + "' > 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 + status + "' > 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") - try: - system("gpio -g write " + str(txLed) + " 0") - except: - print("Can't set txLed") + output(txLed, 0) sleep(1) else: @@ -570,7 +561,7 @@ if __name__ == "__main__": if (mode == 'a'): print("AFSK") else: -# system("gpio -g write " + str(powerPin) + " 0") +# GPIO.output(powerPin, 0) print("Transmit APRS Commands") system("sudo systemctl stop command") # while True: @@ -587,12 +578,9 @@ if __name__ == "__main__": system("gen_packets -o /home/pi/CubeSatSim/telem.wav /home/pi/CubeSatSim/t.txt -r 48000 > /dev/null 2>&1") system("cat /home/pi/CubeSatSim/t.txt") if (command_tx == True): - GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 - try: - system("gpio -g mode " + str(txLed) + " out") - system("gpio -g write " + str(txLed) + " 1") - except: - print("Can't set txLed") +# GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 + setup(txLed, "out") + output(txLed, 1) # output(pd, 1) # output (ptt, 0) # sleep(.1) @@ -618,10 +606,7 @@ if __name__ == "__main__": sleep(0.1) # output (ptt, 1) # output(pd, 0) - try: - system("gpio -g write " + str(txLed) + " 0") - except: - print("Can't set txLed") + output(txLed, 0) system("sudo rm /home/pi/CubeSatSim/ready") f.close() @@ -651,12 +636,9 @@ if __name__ == "__main__": system(command) ## chan = chan + 1 if (command_tx == True): - GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 - system("gpio -g mode " + str(txLed) + " out") - try: - system("gpio -g write " + str(txLed) + " 1") - except: - print("Can't set txLed") +# GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 + setup(txLed, "out") + output(txLed, 1) if (txc): sim_failure_check() @@ -672,10 +654,7 @@ if __name__ == "__main__": system("cat /home/pi/CubeSatSim/morse.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f " + tx + "e3") else: system("cat /home/pi/CubeSatSim/morse.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f " + tx + "e3 > /dev/null 2>&1") - try: - system("gpio -g write " + str(txLed) + " 0") - except: - print("Can't set txLed") + output(txLed, 0) # command_control_check() sleep(2) @@ -688,21 +667,28 @@ if __name__ == "__main__": print("SSTV") # command_control_check() output (ptt, 1) - output(pd, 1) - - print("Testing for camera") - if camera_photo(): + output(pd, 1) + try: +# from picamera import PiCamera +# from pysstv.sstv import SSTV +# camera = PiCamera() + print("Testing for camera") + if os_status == "bookworm": + system("rpicam-still -o /home/pi/CubeSatSim/camera_out.jpg --width 320 --height 256") # > /dev/null 2>&1") + else: + system("raspistill -o /home/pi/CubeSatSim/camera_out.jpg -w 320 -h 256") + f = open("/home/pi/CubeSatSim/camera_out.jpg") + f.close() + print("Camera present") camera_present = 1 - print("camera present") - else: - camera_present = 0 +# camera.close() + except: print("No camera available") print(" -> if camera plugged in, is software enabled?") - - try: - system("gpio -g write " + str(txLed) + " 0") - except: - print("Can't set txLed") + camera_present = 0 + +# while 1: + output(txLed, 0) # output (ptt, 1) # output(pd, 0) if (camera_present == 1): @@ -714,12 +700,9 @@ if __name__ == "__main__": if (command_tx == True): print ("Sending SSTV image") - GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 - try: - system("gpio -g mode " + str(txLed) + " out") - system("gpio -g write " + str(txLed) + " 1") - except: - print("Can't set txLed") +# GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 + setup(txLed, "out") + output(txLed, 1) # battery_saver_check() if (txc): @@ -735,11 +718,8 @@ if __name__ == "__main__": 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 " + tx + "e3 > /dev/null 2>&1") - try: - system("gpio -g write " + str(txLed) + " 0") - except: - print("Can't set txLed") - + output(txLed, 0) + # sleep(1) except: print("image 2 did not load - copy from CubeSatSim/sstv directory") @@ -753,12 +733,9 @@ if __name__ == "__main__": if (command_tx == True): print ("Sending SSTV image") - GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 - try: - system("gpio -g mode " + str(txLed) + " out") - system("gpio -g write " + str(txLed) + " 1") - except: - print("Can't set txLed") +# GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 + setup(txLed, "out") + output(txLed, 1) # battery_saver_check() if (txc): @@ -774,10 +751,8 @@ 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 " + 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 " + tx + "e3 > /dev/null 2>&1") - try: - system("gpio -g write " + str(txLed) + " 0") - except: - print("Can't set txLed") + + output(txLed, 0) # output (ptt, 1) # output(pd, 0) @@ -796,12 +771,9 @@ if __name__ == "__main__": if (command_tx == True): print ("Sending SSTV image") - GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 - try: - system("gpio -g mode " + str(txLed) + " out") - system("gpio -g write " + str(txLed) + " 1") - except: - print("Can't set txLed") +# GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 + setup(txLed, "out") + output(txLed, 1) # battery_saver_check() @@ -817,10 +789,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 " + 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 " + tx + "e3 > /dev/null 2>&1") - try: - system("gpio -g write " + str(txLed) + " 0") - except: - print("Can't set txLed") + + output(txLed, 0) # output (ptt, 1) # output(pd, 0) sleep(1) @@ -839,12 +809,9 @@ if __name__ == "__main__": if (command_tx == True): print ("Sending SSTV image") - try: - GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 - system("gpio -g mode " + str(txLed) + " out") - system("gpio -g write " + str(txLed) + " 1") - except: - print("Can't set txLed") +# GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 + setup(txLed, "out") + output(txLed, 1) # battery_saver_check() if (txc): @@ -859,10 +826,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 " + 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 " + tx + "e3 > /dev/null 2>&1") - try: - system("gpio -g write " + str(txLed) + " 0") - except: - print("Can't set txLed") + + output(txLed, 0) # output (ptt, 1) # output(pd, 0) sleep(10) @@ -875,12 +840,9 @@ if __name__ == "__main__": if (command_tx == True): # command_control_check() - GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 - try: - system("gpio -g mode " + str(txLed) + " out") - system("gpio -g write " + str(txLed) + " 1") - except: - print("Can't set txLed") +# GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 + setup(txLed, "out") + output(txLed, 1) # battery_saver_check() @@ -893,10 +855,8 @@ if __name__ == "__main__": # output (pd, 0) else: sleep(60) - try: - system("gpio -g write " + str(txLed) + " 0") - except: - print("Can't set txLed") + + output(txLed, 0) # output (ptt, 1) # output(pd, 0) sleep(10) @@ -910,11 +870,9 @@ if __name__ == "__main__": print("turn on FM rx") output(pd, 1) output(ptt, 1) - try: - GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4 - system("gpio -g mode " + str(txLed) + " out") - except: - print("Can't set txLed") + +# GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4 + setup(txLed, "out") 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 &") @@ -924,26 +882,20 @@ if __name__ == "__main__": print("Initial image_id: " + str(image_id) + "\n") while 1: # print ("LED on") - try: - system("gpio -g write " + str(txLed) + " 0") - except: - print("Can't set txLed") + output(txLed, 0) sleep(0.4) # if (command_tx == False): -# system("gpio -g write " + str(txLed) + " 1") +# output(txLed, 1) # sleep(0.03) -# system("gpio -g write " + str(txLed) + " 0") +# output(txLed, 0) # command_control_check() if (command_tx == True): - GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 - try: - system("gpio -g mode " + str(txLed) + " out") - system("gpio -g write " + str(txLed) + " 1") - except: - print("Can't set txLed") +# GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 + setup(txLed, "out") + output(txLed, 1) # print(txLed) -# print(txLedOn) +# print(1) if (mode == 'b'): sleep(4.2) @@ -979,14 +931,11 @@ if __name__ == "__main__": print("turn on FM rx") output(pd, 1) output(ptt, 1) - GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4 - try: - system("gpio -g mode " + str(txLed) + " out") - except: - print("Can't set txLed") -# system("gpio -g mode " + str(powerPin) + " out") - GPIO.setup(squelch, GPIO.IN, pull_up_down=GPIO.PUD_UP) ## pull up in case pin is not connected -# system("gpio -g write " + str(powerPin) + " 1") # was 0 +# GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4 + setup(txLed, "out") +# GPIO.setup(powerPin, GPIO.OUT) + setup(squelch, "up") ## pull up in case pin is not connected +# GPIO.output(powerPin, 1) # was 0 # txf = float(tx) - 288.9 # print("Transmit frequency: ",txf) if (command_tx != True): @@ -994,24 +943,18 @@ if __name__ == "__main__": print("Ready to detect carrier") while True: - if (GPIO.input(squelch) == False) and (command_tx == True): + if (input(squelch) == False) and (command_tx == True): print("Carrier detected, starting repeater") - GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 - try: - system("gpio -g mode " + str(txLed) + " out") - system("gpio -g write " + str(txLed) + " 1") - except: - print("Can't set txLed") +# GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 + setup(txLed, "out") + output(txLed, 1) system("sudo nc -l 8011 | csdr convert_i16_f | csdr gain_ff 16000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3 > /dev/null 2>&1 &") sleep(0.5) system("sudo arecord -D shared_mic -r48000 -fS16_LE -c1 | nc localhost 8011 &") - while (GPIO.input(squelch) == False): + while (input(squelch) == False): sleep(1) print("No carrier detected, stopping repeater") - try: - system("gpio -g write " + str(txLed) + " 0") - except: - print("Can't set txLed") + output(txLed, 0) system("sudo rpitx -i null > /dev/null 2>&1") system("sudo killall -9 arecord > /dev/null 2>&1") system("sudo killall -9 nc > /dev/null 2>&1") @@ -1026,36 +969,27 @@ if __name__ == "__main__": print("turn on FM rx") output(pd, 1) output(ptt, 1) - - try: - GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4 - system("gpio -g mode " + str(txLed) + " out") - except: - print("Can't set txLed") + +# GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4 + setup(txLed, "out") 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 " + tx + "e3 &") print("Turning LED on/off and listening for carrier") while 1: - try: - system("gpio -g write " + str(txLed) + " 0") - except: - print("Can't set txLed") + output(txLed, 0) sleep(0.4) # if (command_tx == False): -# system("gpio -g write " + str(txLed) + " 1") +# output(txLed, 1) # sleep(0.03) -# system("gpio -g write " + str(txLed) + " 0") +# output(txLed, 0) # command_control_check() - if (command_tx == True): - try: - GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 - system("gpio -g mode " + str(txLed) + " out") - system("gpio -g write " + str(txLed) + " 1") - except: - print("Can't set txLed") + if (command_tx == True): +# GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 + setup(txLed, "out") + output(txLed, 1) # print(txLed) -# print(txLedOn) +# print(1) sleep(4.2) else: print("No Low Pass Filter so no telemetry transmit. See http://cubesatsim.org/wiki for instructions on how to build the LPF.") From ea2a63d515cb7d0f99fcc12c29aaf6455c4b7f1b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 21 Feb 2026 08:30:28 -0500 Subject: [PATCH 02/26] missing : --- transmit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/transmit.py b/transmit.py index 7353d1ad..e18b0a96 100644 --- a/transmit.py +++ b/transmit.py @@ -38,7 +38,7 @@ def setup(pin, config): if config == "in" or config == "out" or config == "up" or config == "down": command = "gpio -g mode " + str(powerPin) + " " + config system(command) - else + else: print(f"Unknown GPIO setup configuration: {config}") def blink(times): From 10147585a96dadcdc1f2b70a3d3fd1194cdbc76b Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 21 Feb 2026 08:32:19 -0500 Subject: [PATCH 03/26] remove txLedOn and Off Removed unnecessary assignments for transmit variables. --- transmit.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/transmit.py b/transmit.py index e18b0a96..4bea6822 100644 --- a/transmit.py +++ b/transmit.py @@ -238,8 +238,6 @@ output(powerPin, 1) transmit = False txLed = 27 -1 = 1 -0 = 0 if input(12) == False: print("LPF present") transmit = True From e7b66a1a65dfc780acb55d6faf9eefd595dca3cd Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 21 Feb 2026 08:32:57 -0500 Subject: [PATCH 04/26] Comment out GPIO setup mode and warnings Comment out GPIO setup lines for power management. --- transmit.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/transmit.py b/transmit.py index 4bea6822..e390db0f 100644 --- a/transmit.py +++ b/transmit.py @@ -227,8 +227,8 @@ powerPin = 16 command_tx = True -GPIO.setmode(GPIO.BCM) -GPIO.setwarnings(False) +# GPIO.setmode(GPIO.BCM) +# GPIO.setwarnings(False) setup(13, "up") setup(12, "up") setup(27, "up") From 04cdbd68a15a37f25f8e7fe2b694db290607bc5a Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 21 Feb 2026 08:37:08 -0500 Subject: [PATCH 05/26] input return integer not string Change return type of subprocess result to int and update error handling. --- transmit.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/transmit.py b/transmit.py index e390db0f..67d4c314 100644 --- a/transmit.py +++ b/transmit.py @@ -26,13 +26,13 @@ def input(pin): print(f"Command run was: {query}") print("Sucess!") print(f"Output of the command (stdout): {result}") - return result + return int(result) except subprocess.CalledProcessError as e: print(f"Command failed with return code: {e.returncode}") print(f"Command run was: {e.cmd}") print(f"Output of the command (stdout): {e.stdout}") print(f"Error output of the command (stderr): {e.stderr}") - return 0 + return -1 def setup(pin, config): if config == "in" or config == "out" or config == "up" or config == "down": From eae73235b45ad19adeec2b10f7fa75be7ed9c527 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 21 Feb 2026 08:39:21 -0500 Subject: [PATCH 06/26] input return int of stdout --- transmit.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/transmit.py b/transmit.py index 67d4c314..b5e99fff 100644 --- a/transmit.py +++ b/transmit.py @@ -25,8 +25,8 @@ def input(pin): result = subprocess.run(query, capture_output=True, text=True, check=True) print(f"Command run was: {query}") print("Sucess!") - print(f"Output of the command (stdout): {result}") - return int(result) + print(f"Output of the command (stdout): {result.stdout}") + return int(result.stdout) except subprocess.CalledProcessError as e: print(f"Command failed with return code: {e.returncode}") print(f"Command run was: {e.cmd}") From 7cf32b6d554524618c556a9710ee9ae8892dcfcc Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 21 Feb 2026 15:31:40 -0500 Subject: [PATCH 07/26] start merging update into install Updated installation script for CubeSatSim to handle various OS versions and improved configuration handling for sim.cfg. --- install | 146 ++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 100 insertions(+), 46 deletions(-) diff --git a/install b/install index 02c8b158..af233f2d 100755 --- a/install +++ b/install @@ -1,6 +1,35 @@ #!/bin/bash -echo -e "\ninstallation script for CubeSatSim v2.2\n" +FLAG=0 +checkout=0 + +if [ ! -d "/home/pi/CubeSatSim" ]; then + + echo -e "\nInstallation script for CubeSatSim v2.2\n" + + touch /home/pi/CubeSatSim/command_control_direwolf + +else + + echo -e "\nUpdate script for CubeSatSim v2.2\n" + + if [ -z "$1" ] ; then + checkout=0 + else + checkout=1 + branch="$1" + echo -n "changing to branch " + echo $branch + FLAG=1 + fi + + if [ "$2" = "n" ] ; then + noreboot=1 + else + noreboot=0 + fi + +fi if [[ $(grep '11.' /etc/debian_version) ]]; then echo "Installing on Debian 11 (Bullseye)" @@ -9,19 +38,12 @@ echo -e "\ninstallation script for CubeSatSim v2.2\n" sudo cp /boot/cmdline.txt /boot/cmdline.txt.0 - sudo raspi-config nonint do_i2c 0 sudo raspi-config nonint do_camera 0 sudo raspi-config nonint do_legacy 0 - - #if [ "$1" = "u" ]; then - #fi - - ## sudo sed -i 's/console=serial0,115200 //g' /boot/cmdline.txt - sudo sed -i 's/console=serial0,115200 //g' /boot/cmdline.txt sudo sed -i 's/console=tty1 r/console=tty1 maxcpus=1 r/g' /boot/cmdline.txt # single core if Pi Zero 2 @@ -112,19 +134,12 @@ if [[ $(grep 'bookworm' /etc/os-release) ]]; then sudo cp /boot/firmware/cmdline.txt /boot/firmware/cmdline.txt.0 - sudo raspi-config nonint do_i2c 0 sudo raspi-config nonint do_camera 0 sudo raspi-config nonint do_legacy 0 - #if [ "$1" = "u" ]; then - #fi - - ## sudo sed -i 's/console=serial0,115200 //g' /boot/firmware/cmdline.txt - - sudo sed -i 's/console=serial0,115200 //g' /boot/firmware/cmdline.txt sudo sed -i 's/console=tty1 r/console=tty1 maxcpus=1 r/g' /boot/firmware/cmdline.txt # single core if Pi Zero 2 @@ -214,8 +229,10 @@ if [[ $(grep 'bookworm' /etc/os-release) ]]; then sudo sh -c 'echo "\n" >> /boot/firmware/config.txt' -else - echo "Your Pi OS version is not Bookworm." +elif [[ $(grep 'trixie' /etc/os-release) ]]; then + + echo "Trixie detected, installation continuing." + echo "Your Pi OS version is not Bookworm or Bullseye." echo "The software installation will likely not work." echo "See the README.md for how to install using Bookworm." echo @@ -232,9 +249,41 @@ fi FILE=/home/pi/CubeSatSim/sim.cfg if [ -f "$FILE" ]; then echo "$FILE exists." + + changed=0 + value=`cat /home/pi/CubeSatSim/sim.cfg` + # echo "$value" + 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="435.0000" ; changed=1 ; else n8=$8 ; fi # receive frequency + if [ -z "$9" ] ; then n9="no" ; changed=1 ; else n9=$9 ; fi # hab mode + if [ -z "${10}" ] ; then m1="0" ; changed=1 ; else m1=${10} ; fi # rx pl code + if [ -z "${11}" ] ; then m2="0" ; changed=1 ; else m2=${11} ; fi # tx pl code + if [ -z "${12}" ] ; then m1="no" ; changed=1 ; else m1=${12} ; fi # random fail + if [ -z "${13}" ] ; then m2="60" ; changed=1 ; else m2=${13} ; fi # random fail period + + if [ $changed -eq 1 ]; then + echo -e "Current sim.cfg configuration file:" + echo + echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} ${12} ${13} + echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" + echo + echo $n1 $n2 $n3 $n4 $n5 $n6 $n7 $n8 $n9 $m1 $m2 $m3 $m4 + echo $n1 $n2 $n3 $n4 $n5 $n6 $n7 $n8 $n9 $m1 $m2 $m3 $m4> /home/pi/CubeSatSim/sim.cfg + echo + fi + else echo "creating $FILE" - echo "AMSAT 1 0.0 0.0" > /home/pi/CubeSatSim/sim.cfg + echo "AMSAT 0 0 0 no 3 434.9 435 no 0 0 no 60" > /home/pi/CubeSatSim/sim.cfg fi if [[ $(grep 'cubesatsim' /etc/motd) ]]; then @@ -260,7 +309,6 @@ else echo "0\n" > /home/pi/CubeSatSim/command_count.txt fi -touch /home/pi/CubeSatSim/command_control_direwolf sudo apt-get update && sudo apt-get dist-upgrade -y @@ -271,36 +319,42 @@ sudo apt-get install -y gcc g++ make cmake libasound2-dev libudev-dev libavahi-c # removed wiringpi and python-picamera python3-picamera sudo apt-get install -y git libasound2-dev i2c-tools build-essential libgd-dev libmagic-dev minicom -cd - -git clone https://github.com/alanbjohnston/direwolf.git - -cd direwolf - -make -j - -sudo make install - -make install-rpi - -sudo apt-get install -y gpsd gpsd-clients libgps-dev python3-gps +if [ ! -d "/home/pi/direwolf" ]; then -sudo systemctl disable gpsd -sudo systemctl disable gpsd.socket - -cd /tmp - -# wget https://project-downloads.drogon.net/wiringpi-latest.deb - -# sudo dpkg -i wiringpi-latest.deb - -cd + cd + + git clone https://github.com/alanbjohnston/direwolf.git + + cd direwolf + + make -j + + sudo make install + + make install-rpi + + sudo apt-get install -y gpsd gpsd-clients libgps-dev python3-gps + + sudo systemctl disable gpsd + sudo systemctl disable gpsd.socket +fi -git clone https://github.com/alanbjohnston/WiringPi -cd WiringPi -./build debian +if [ ! -d "/home/pi/WiringPi" ]; then -sudo dpkg -i debian-template/wiringpi-2.61-1.deb + cd /tmp + + # wget https://project-downloads.drogon.net/wiringpi-latest.deb + + # sudo dpkg -i wiringpi-latest.deb + + cd + + git clone https://github.com/alanbjohnston/WiringPi + cd WiringPi + ./build debian + + sudo dpkg -i debian-template/wiringpi-2.61-1.deb +fi cd From af9afad6acf4891965930341d64d6935bdf6e6a5 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sat, 21 Feb 2026 16:10:15 -0500 Subject: [PATCH 08/26] rest of changes to merge update into install --- install | 364 ++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 250 insertions(+), 114 deletions(-) diff --git a/install b/install index af233f2d..dd79d8d1 100755 --- a/install +++ b/install @@ -3,13 +3,8 @@ FLAG=0 checkout=0 -if [ ! -d "/home/pi/CubeSatSim" ]; then - - echo -e "\nInstallation script for CubeSatSim v2.2\n" - - touch /home/pi/CubeSatSim/command_control_direwolf - -else +FILE=/home/pi/CubeSatSim/cubesatsim # code has already been compiled +if [ -f "$FILE" ]; then echo -e "\nUpdate script for CubeSatSim v2.2\n" @@ -29,9 +24,19 @@ else noreboot=0 fi +else + + echo -e "\nInstallation script for CubeSatSim v2.2\n" + + touch /home/pi/CubeSatSim/command_control_direwolf + + /home/piCubeSatSim/config -c -n + + /home/piCubeSatSim/config -l -n + fi - if [[ $(grep '11.' /etc/debian_version) ]]; then +if [[ $(grep '11.' /etc/debian_version) ]]; then echo "Installing on Debian 11 (Bullseye)" sudo cp /boot/config.txt /boot/config.txt.0 @@ -308,7 +313,6 @@ else echo "creating $FILE" echo "0\n" > /home/pi/CubeSatSim/command_count.txt fi - sudo apt-get update && sudo apt-get dist-upgrade -y @@ -321,34 +325,21 @@ sudo apt-get install -y git libasound2-dev i2c-tools build-essential libgd-dev l if [ ! -d "/home/pi/direwolf" ]; then - cd - + cd git clone https://github.com/alanbjohnston/direwolf.git - - cd direwolf - + cd direwolf make -j - - sudo make install - + sudo make install make install-rpi - +fi + sudo apt-get install -y gpsd gpsd-clients libgps-dev python3-gps - sudo systemctl disable gpsd sudo systemctl disable gpsd.socket -fi if [ ! -d "/home/pi/WiringPi" ]; then - cd /tmp - - # wget https://project-downloads.drogon.net/wiringpi-latest.deb - - # sudo dpkg -i wiringpi-latest.deb - cd - git clone https://github.com/alanbjohnston/WiringPi cd WiringPi ./build debian @@ -368,9 +359,17 @@ sudo pip3 install --upgrade setuptools sudo pip3 install adafruit-blinka RPI.GPIO adafruit-extended-bus adafruit-circuitpython-ina219 -cd ~/CubeSatSim +cd /home/pi/CubeSatSim -git pull --no-rebase +git pull --no-rebase > .updated + +if [ $checkout -eq 1 ]; then + git checkout $branch + git pull --no-rebase > .updated + FLAG=1 + echo "Running update script again" + /home/pi/CubeSatSim/install +fi make debug @@ -382,81 +381,133 @@ else echo "b" > .mode fi -cd - -git clone https://github.com/alanbjohnston/pi-power-button.git - -cd pi-power-button - -git checkout master - -./script/install - -sudo apt-get install -y libraspberrypi-dev - -cd - -echo "Installing SSDV for FUNcube mode" -git clone https://github.com/alanbjohnston/ssdv.git # install ssdv for FUNcube images -cd ssdv -make -cd - -echo "Installing fctelem binary v0.2 for FUNcube mode" -mkdir /home/pi/fctelem -mkdir /home/pi/fctelem/public_html -cd fctelem -wget https://github.com/alanbjohnston/go/releases/download/v0.2/fctelem.zip -unzip -u fctelem.zip - -cd -echo "Installing fcdctl to set FUNcubeDongle Pro gain" -# sudo rm /var/lib/dpkg/info/python3-pip.list -# sudo apt install python3-pip --reinstall -# sudo apt-get install -y python3-smbus libusb-1.0 -cd -git clone https://github.com/csete/fcdctl.git -cd fcdctl -make fcdpp - -cd +if [ ! -d "/home/pi/pi-power-button" ]; then -git clone https://github.com/alanbjohnston/PiSSTVpp.git + cd + git clone https://github.com/alanbjohnston/pi-power-button.git + cd pi-power-button + git checkout master + ./script/install + sudo apt-get install -y libraspberrypi-dev -cd PiSSTVpp +fi -make pisstvpp +cd /home/pi/pi-power-button -echo "Copying SSTV image 1" -cp /home/pi/CubeSatSim/sstv/sstv_image_1_320_x_256.jpg /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg +git pull --no-rebase > .updated_p +git checkout master +grep 'changed' /home/pi/pi-power-button/.updated_p +if [[ $(grep 'changed' /home/pi/pi-power-button/.updated_p) ]]; then -echo "Copying SSTV image 2" -cp /home/pi/CubeSatSim/sstv/sstv_image_2_320_x_256.jpg /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg + echo "updating pi-power-button." + script/install + FLAG=1 +fi cd -git clone https://github.com/alanbjohnston/rpitx.git +if [ ! -d "/home/pi/PiSSTVpp" ]; then -cd rpitx + sudo apt-get update -y + sudo apt-get install -y python-picamera python3-picamera build-essential libgd-dev libmagic-dev + cd + git clone https://github.com/alanbjohnston/PiSSTVpp.git + cd PiSSTVpp + make pisstvpp -./install.sh +fi -cd +if [ ! -d "/home/pi/rpitx" ]; then -sudo cp ~/CubeSatSim/systemd/cubesatsim.service /etc/systemd/system/cubesatsim.service + cd + git clone https://github.com/alanbjohnston/rpitx.git + cd rpitx + ./install.sh + cd +else -sudo systemctl enable cubesatsim + if [[ $(grep 'SYNCWITHPWM' /home/pi/rpitx/src/librpitx/src/fskburst.h) ]]; then + echo "rpitx library already updated" + else + echo "updating rpitx" + cd /home/pi/rpitx + git pull + ./update.sh + cd + fi +fi -sudo cp ~/CubeSatSim/systemd/transmit.service /etc/systemd/system/transmit.service +if [[ $(diff systemd/cubesatsim.service /etc/systemd/system/cubesatsim.service) ]]; then + echo "changed cubesatsim.service." + sudo cp /home/pi/CubeSatSim/systemd/cubesatsim.service /etc/systemd/system/cubesatsim.service + FLAG=1 +else + echo "no changes to cubesatsim.service." +fi -# sudo systemctl enable transmit +FILE=/etc/systemd/system/rpitx.service +if [ -f "$FILE" ]; then + sudo systemctl disable rpitx + sudo rm /etc/systemd/system/rpitx.service +fi -sudo cp ~/CubeSatSim/systemd/command.service /etc/systemd/system/command.service +FILE=/etc/systemd/system/transmit.service +if [ -f "$FILE" ]; then + if [[ $(diff systemd/transmit.service /etc/systemd/system/transmit.service) ]]; then + echo "changed transmit.service." + sudo cp /home/pi/CubeSatSim/systemd/transmit.service /etc/systemd/system/transmit.service + FLAG=1 + else + echo "no change to transmit.service." + fi +else + echo "creating transmit.service." + sudo cp /home/pi/CubeSatSim/systemd/transmit.service /etc/systemd/system/transmit.service + FLAG=1 +fi -sudo systemctl enable command +FILE=/etc/systemd/system/command.service +if [ -f "$FILE" ]; then + if [[ $(diff systemd/command.service /etc/systemd/system/command.service) ]]; then + echo "changed command.service." + sudo cp /home/pi/CubeSatSim/systemd/command.service /etc/systemd/system/command.service + FLAG=1 + else + echo "no change to command.service." + fi +else + echo "creating command.service." + sudo cp /home/pi/CubeSatSim/systemd/command.service /etc/systemd/system/command.service + sudo systemctl enable command + FLAG=1 +fi -sudo cp /home/pi/CubeSatSim/asound.conf /etc/asound.conf +FILE=/etc/asound.conf +if [ -f "$FILE" ]; then + if [[ $(diff /home/pi/CubeSatSim/asound.conf /etc/asound.conf) ]]; then + echo "changed /etc/asound.conf." + sudo cp /home/pi/CubeSatSim/asound.conf /etc/asound.conf + FLAG=1 + else + echo "no change to /etc/asound.conf." + fi +else + echo "creating /etc/asound.conf." + sudo cp /home/pi/CubeSatSim/asound.conf /etc/asound.conf + FLAG=1 +fi +FILE=/home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg +if [ ! -f "$FILE" ]; then + echo "Copying SSTV image 1." + cp /home/pi/CubeSatSim/sstv/sstv_image_1_320_x_256.jpg /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg +fi + +FILE=/home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg +if [ ! -f "$FILE" ]; then + echo "Copying SSTV image 2." + cp /home/pi/CubeSatSim/sstv/sstv_image_2_320_x_256.jpg /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg +fi sudo sed -i 's/DEVICES=""/DEVICES="\/dev\/serial0"/g' /etc/default/gpsd @@ -490,48 +541,133 @@ if [ $changed -eq 1 ]; then echo fi -echo "Installing MPU6050-C-CPP-Library-for-Raspberry-Pi" -sudo apt-get install -y libi2c-dev -cd -git clone https://github.com/alanbjohnston/MPU6050-C-CPP-Library-for-Raspberry-Pi.git -cd MPU6050-C-CPP-Library-for-Raspberry-Pi -sudo make install -make payload +if [ ! -d "/home/pi/fctelem" ]; then + echo "Installing fctelem binary v0.2 for FUNcube mode" + cd + mkdir /home/pi/fctelem + mkdir /home/pi/fctelem/public_html + cd fctelem + wget https://github.com/alanbjohnston/go/releases/download/v0.2/fctelem.zip + unzip -u fctelem.zip + FLAG=1 +elif [ ! -f "/home/pi/fctelem/v0.2" ]; then + echo "Updating fctelem binary to version v0.2 for FUNcube mode" + cd + cd /home/pi/fctelem + sudo mv fctelem fctelem.bk + sudo mv fcdecode.conf fcdecode.conf.bk + sudo mv fctelem.zip fctelem.zip.1 + wget https://github.com/alanbjohnston/go/releases/download/v0.2/fctelem.zip + unzip -u fctelem.zip + FLAG=1 +fi -echo "Installing raspberry-pi-bme280" -sudo apt-get install -y libi2c-dev -cd -git clone https://github.com/alanbjohnston/raspberry-pi-bme280.git -cd raspberry-pi-bme280 +if [ ! -f "/home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi/mpu6050" ]; then + echo "Installing MPU6050-C-CPP-Library-for-Raspberry-Pi" + sudo apt-get install -y libi2c-dev + cd + git clone https://github.com/alanbjohnston/MPU6050-C-CPP-Library-for-Raspberry-Pi.git + cd MPU6050-C-CPP-Library-for-Raspberry-Pi + sudo make install + make payload +fi + +cd /home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi +git checkout master +git pull --no-rebase > .updated_p + +if [[ $(grep 'changed' /home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi/.updated_p) ]]; then + echo "updating MPU6050-C-CPP-Library-for-Raspberry-Pi" + sudo make install + make payload +else + echo "nothing to do for MPU6050-C-CPP-Library-for-Raspberry-Pi." +fi + +if [ ! -f "/home/pi/raspberry-pi-bme280/bme280" ]; then + echo "Installing raspberry-pi-bme280" + sudo apt-get install -y libi2c-dev + cd + git clone https://github.com/alanbjohnston/raspberry-pi-bme280.git + cd raspberry-pi-bme280 + git checkout payload + make +fi + +cd /home/pi/raspberry-pi-bme280 git checkout payload -make +git pull --no-rebase > .updated_p -cd -sudo apt install python3-venv -sudo python3 -m venv venv -source /home/pi/venv/bin/activate +if [[ $(grep 'changed' /home/pi/raspberry-pi-bme280/.updated_p) ]]; then -curl https://bootstrap.pypa.io/get-pip.py | sudo /home/pi/venv/bin/python3 + echo "updating raspberry-pi-bme280" + make -sudo /home/pi/venv/bin/pip3 install adafruit_extended_bus -sudo /home/pi/venv/bin/pip3 install adafruit-circuitpython-ina219 +else + echo "nothing to do for raspberry-pi-bme280." +fi + +if [ ! -f "/home/pi/fcdctl/fcdctl" ]; then + echo "Installing fcdctl to set FUNcubeDongle Pro gain" + sudo rm /var/lib/dpkg/info/python3-pip.list + sudo apt install python3-pip --reinstall + sudo apt-get install -y python3-smbus libusb-1.0 + cd + git clone https://github.com/csete/fcdctl.git + cd fcdctl + make fcdpp +fi -cd -CubeSatSim/config -c -n +if [ ! -d "/home/pi/venv" ]; then -CubeSatSim/config -l -n + cd + sudo apt install python3-venv + sudo python3 -m venv venv + source /home/pi/venv/bin/activate + + curl https://bootstrap.pypa.io/get-pip.py | sudo /home/pi/venv/bin/python3 + + sudo /home/pi/venv/bin/pip3 install adafruit_extended_bus + sudo /home/pi/venv/bin/pip3 install adafruit-circuitpython-ina219 -echo "Would you like to reboot to complete the installation (y/n)?" +fi -read -r ANS +cd -if [ "$ANS" = "y" ]; then +#echo "Would you like to reboot to complete the installation (y/n)?" - sudo reboot now +#read -r ANS -else +#if [ "$ANS" = "y" ]; then + +# sudo reboot now + +#else - echo "The CubeSatSim software will start next time you reboot" + # echo "The CubeSatSim software will start next time you reboot" +#fi + +if [ "$noreboot" = "0" ] ; then + + if [ $FLAG -eq 1 ]; then + echo "systemctl daemon-reload and reboot" + sudo systemctl daemon-reload + sudo reboot -h now +# sudo cubesatsim + else + grep 'changed' /home/pi/CubeSatSim/.updated + if [[ $(grep 'changed' /home/pi/CubeSatSim/.updated) ]]; then + echo "reboot due to code changes " | wall + sudo reboot -h now +# sudo cubesatsim + else + echo "nothing to do." + fi + fi +else + if [ $FLAG -eq 1 ]; then + echo "reboot needed for changes to take effect" | wall + fi fi From 666c4af6e13fa69e50ae193991316215b0350dd1 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 22 Feb 2026 09:37:57 -0500 Subject: [PATCH 09/26] move venv to start of script Added support for Bullseye OS and updated installation steps for Python virtual environment and dependencies. --- install | 77 ++++++++++++++++++--------------------------------------- 1 file changed, 24 insertions(+), 53 deletions(-) diff --git a/install b/install index dd79d8d1..433952e6 100755 --- a/install +++ b/install @@ -2,6 +2,7 @@ FLAG=0 checkout=0 +BULLSEYE=0 FILE=/home/pi/CubeSatSim/cubesatsim # code has already been compiled if [ -f "$FILE" ]; then @@ -133,6 +134,7 @@ if [[ $(grep '11.' /etc/debian_version) ]]; then fi if [[ $(grep 'bookworm' /etc/os-release) ]]; then + BULLSEYE=1 echo "Bookworm detected, installation continuing." sudo cp /boot/firmware/config.txt /boot/firmware/config.txt.0 @@ -251,6 +253,20 @@ elif [[ $(grep 'trixie' /etc/os-release) ]]; then fi fi +if [ ! -d "/home/pi/venv" ]; then + + cd + sudo apt install -y python3-venv + sudo python3 -m venv venv + source /home/pi/venv/bin/activate + + curl https://bootstrap.pypa.io/get-pip.py | sudo /home/pi/venv/bin/python3 + + sudo /home/pi/venv/bin/pip3 install adafruit_extended_bus + sudo /home/pi/venv/bin/pip3 install adafruit-circuitpython-ina219 + +fi + FILE=/home/pi/CubeSatSim/sim.cfg if [ -f "$FILE" ]; then echo "$FILE exists." @@ -272,8 +288,8 @@ if [ -f "$FILE" ]; then if [ -z "$9" ] ; then n9="no" ; changed=1 ; else n9=$9 ; fi # hab mode if [ -z "${10}" ] ; then m1="0" ; changed=1 ; else m1=${10} ; fi # rx pl code if [ -z "${11}" ] ; then m2="0" ; changed=1 ; else m2=${11} ; fi # tx pl code - if [ -z "${12}" ] ; then m1="no" ; changed=1 ; else m1=${12} ; fi # random fail - if [ -z "${13}" ] ; then m2="60" ; changed=1 ; else m2=${13} ; fi # random fail period + if [ -z "${12}" ] ; then m3="no" ; changed=1 ; else m3=${12} ; fi # random fail + if [ -z "${13}" ] ; then m4="60" ; changed=1 ; else m4=${13} ; fi # random fail period if [ $changed -eq 1 ]; then echo -e "Current sim.cfg configuration file:" @@ -338,20 +354,18 @@ fi sudo systemctl disable gpsd.socket if [ ! -d "/home/pi/WiringPi" ]; then - cd git clone https://github.com/alanbjohnston/WiringPi cd WiringPi ./build debian - sudo dpkg -i debian-template/wiringpi-2.61-1.deb fi cd -#changed to python3-smbus - -sudo apt install -y libtiff6 +if [ ! $BULLSEYE -eq 1 ]; then + sudo apt install -y libtiff6 +fi sudo apt install -y python3-pip python3-smbus libjpeg-dev zlib1g-dev libfreetype6-dev libopenjp2-7 python3-pil python3-serial libusb-1.0-0 libusb-1.0-0-dev @@ -437,7 +451,7 @@ else fi fi -if [[ $(diff systemd/cubesatsim.service /etc/systemd/system/cubesatsim.service) ]]; then +if [[ $(diff /home/pi/CubeSatSim/systemd/cubesatsim.service /etc/systemd/system/cubesatsim.service) ]]; then echo "changed cubesatsim.service." sudo cp /home/pi/CubeSatSim/systemd/cubesatsim.service /etc/systemd/system/cubesatsim.service FLAG=1 @@ -453,7 +467,7 @@ fi FILE=/etc/systemd/system/transmit.service if [ -f "$FILE" ]; then - if [[ $(diff systemd/transmit.service /etc/systemd/system/transmit.service) ]]; then + if [[ $(diff /home/pi/CubeSatSim/systemd/transmit.service /etc/systemd/system/transmit.service) ]]; then echo "changed transmit.service." sudo cp /home/pi/CubeSatSim/systemd/transmit.service /etc/systemd/system/transmit.service FLAG=1 @@ -468,7 +482,7 @@ fi FILE=/etc/systemd/system/command.service if [ -f "$FILE" ]; then - if [[ $(diff systemd/command.service /etc/systemd/system/command.service) ]]; then + if [[ $(diff /home/pi/CubeSatSim/systemd/command.service /etc/systemd/system/command.service) ]]; then echo "changed command.service." sudo cp /home/pi/CubeSatSim/systemd/command.service /etc/systemd/system/command.service FLAG=1 @@ -513,34 +527,6 @@ sudo sed -i 's/DEVICES=""/DEVICES="\/dev\/serial0"/g' /etc/default/gpsd sudo sed -i 's/GPSD_OPTIONS=""/GPSD_OPTIONS="-s 9600"/g' /etc/default/gpsd -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="435.0000" ; changed=1 ; else n8=$8 ; fi # receive frequency -if [ -z "$9" ] ; then n9="no" ; changed=1 ; else n9=$9 ; fi # hab mode -if [ -z "${10}" ] ; then n10="0" ; changed=1 ; else n10=${10} ; fi # rx pl code -if [ -z "${11}" ] ; then n11="0" ; changed=1 ; else n11=${11} ; fi # tx pl code - -if [ $changed -eq 1 ]; then - echo -e "Current sim.cfg configuration file:" - echo - echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} - echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" - echo - echo $n1 $n2 $n3 $n4 $n5 $n6 $n7 $n8 $n9 $n10 $n11 - echo $n1 $n2 $n3 $n4 $n5 $n6 $n7 $n8 $n9 $n10 $n11 > /home/pi/CubeSatSim/sim.cfg - echo -fi - if [ ! -d "/home/pi/fctelem" ]; then echo "Installing fctelem binary v0.2 for FUNcube mode" cd @@ -618,21 +604,6 @@ if [ ! -f "/home/pi/fcdctl/fcdctl" ]; then make fcdpp fi - -if [ ! -d "/home/pi/venv" ]; then - - cd - sudo apt install python3-venv - sudo python3 -m venv venv - source /home/pi/venv/bin/activate - - curl https://bootstrap.pypa.io/get-pip.py | sudo /home/pi/venv/bin/python3 - - sudo /home/pi/venv/bin/pip3 install adafruit_extended_bus - sudo /home/pi/venv/bin/pip3 install adafruit-circuitpython-ina219 - -fi - cd #echo "Would you like to reboot to complete the installation (y/n)?" From 060cf095e358124ced8ca65c359466da4ca7f561 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 22 Feb 2026 10:18:26 -0500 Subject: [PATCH 10/26] move venv again --- install | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/install b/install index 433952e6..ee4de9d6 100755 --- a/install +++ b/install @@ -38,7 +38,7 @@ else fi if [[ $(grep '11.' /etc/debian_version) ]]; then - echo "Installing on Debian 11 (Bullseye)" + echo "Debian 11 (Bullseye) detected" sudo cp /boot/config.txt /boot/config.txt.0 @@ -135,7 +135,7 @@ if [[ $(grep '11.' /etc/debian_version) ]]; then if [[ $(grep 'bookworm' /etc/os-release) ]]; then BULLSEYE=1 - echo "Bookworm detected, installation continuing." + echo "Bookworm detected." sudo cp /boot/firmware/config.txt /boot/firmware/config.txt.0 @@ -253,20 +253,6 @@ elif [[ $(grep 'trixie' /etc/os-release) ]]; then fi fi -if [ ! -d "/home/pi/venv" ]; then - - cd - sudo apt install -y python3-venv - sudo python3 -m venv venv - source /home/pi/venv/bin/activate - - curl https://bootstrap.pypa.io/get-pip.py | sudo /home/pi/venv/bin/python3 - - sudo /home/pi/venv/bin/pip3 install adafruit_extended_bus - sudo /home/pi/venv/bin/pip3 install adafruit-circuitpython-ina219 - -fi - FILE=/home/pi/CubeSatSim/sim.cfg if [ -f "$FILE" ]; then echo "$FILE exists." @@ -332,6 +318,20 @@ fi sudo apt-get update && sudo apt-get dist-upgrade -y +if [ ! -d "/home/pi/venv" ]; then + + cd + sudo apt install -y python3-venv + sudo python3 -m venv venv + source /home/pi/venv/bin/activate + + curl https://bootstrap.pypa.io/get-pip.py | sudo /home/pi/venv/bin/python3 + + sudo /home/pi/venv/bin/pip3 install adafruit_extended_bus + sudo /home/pi/venv/bin/pip3 install adafruit-circuitpython-ina219 + +fi + sudo apt-get remove pulseaudio -y sudo apt-get install -y gcc g++ make cmake libasound2-dev libudev-dev libavahi-client-dev libgpiod-dev raspi-config From 140b76c9fbcded4d5b28e2d79c56234e27ea6ecc Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 22 Feb 2026 10:20:11 -0500 Subject: [PATCH 11/26] Update detection message for Debian 12 (Bookworm) --- install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install b/install index ee4de9d6..9e5d4bf9 100755 --- a/install +++ b/install @@ -135,7 +135,7 @@ if [[ $(grep '11.' /etc/debian_version) ]]; then if [[ $(grep 'bookworm' /etc/os-release) ]]; then BULLSEYE=1 - echo "Bookworm detected." + echo "Debian 12 (Bookworm) detected" sudo cp /boot/firmware/config.txt /boot/firmware/config.txt.0 From 53ffba11822ac3fa18de9fc438e9950debfd1058 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 22 Feb 2026 10:45:22 -0500 Subject: [PATCH 12/26] fix splash --- install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install b/install index 9e5d4bf9..596dc39c 100755 --- a/install +++ b/install @@ -114,7 +114,7 @@ if [[ $(grep '11.' /etc/debian_version) ]]; then sudo sh -c 'echo "\ndtoverlay=pwm,pin=18,func=2" >> /boot/config.txt' fi - if [[ $(grep 'disable_splash=1 ' /boot/config.txt) ]]; then + if [[ $(grep 'disable_splash=1' /boot/config.txt) ]]; then echo "disable_splash=1 already in /boot/config.txt" else echo "adding disable_splash=1 to /boot/config.txt" @@ -211,7 +211,7 @@ if [[ $(grep 'bookworm' /etc/os-release) ]]; then sudo sh -c 'echo "\ndtoverlay=pwm,pin=18,func=2" >> /boot/firmware/config.txt' fi - if [[ $(grep 'disable_splash=1 ' /boot/firmware/config.txt) ]]; then + if [[ $(grep 'disable_splash=1' /boot/firmware/config.txt) ]]; then echo "disable_splash=1 already in /boot/firmware/config.txt" else echo "adding disable_splash=1 to /boot/firmware/config.txt" From 721b16c91c77ffae787aaea7828ae09c93a90e35 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 22 Feb 2026 10:58:47 -0500 Subject: [PATCH 13/26] fix BULLSEYE variable --- install | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/install b/install index 596dc39c..6b2c9d69 100755 --- a/install +++ b/install @@ -38,6 +38,9 @@ else fi if [[ $(grep '11.' /etc/debian_version) ]]; then + + BULLSEYE=1 + echo "Debian 11 (Bullseye) detected" sudo cp /boot/config.txt /boot/config.txt.0 @@ -134,7 +137,7 @@ if [[ $(grep '11.' /etc/debian_version) ]]; then fi if [[ $(grep 'bookworm' /etc/os-release) ]]; then - BULLSEYE=1 + echo "Debian 12 (Bookworm) detected" sudo cp /boot/firmware/config.txt /boot/firmware/config.txt.0 From 7bee60873f94be0247f4ad8ee1cd6498e453ac99 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 22 Feb 2026 11:10:15 -0500 Subject: [PATCH 14/26] add purge and reinstall python3-pip for bullseye --- install | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/install b/install index 6b2c9d69..4f9beecb 100755 --- a/install +++ b/install @@ -368,8 +368,12 @@ cd if [ ! $BULLSEYE -eq 1 ]; then sudo apt install -y libtiff6 +else + sudo apt purge -y python3-pip + sudo apt install -y python3-pip fi + sudo apt install -y python3-pip python3-smbus libjpeg-dev zlib1g-dev libfreetype6-dev libopenjp2-7 python3-pil python3-serial libusb-1.0-0 libusb-1.0-0-dev sudo pip3 install --upgrade setuptools From 96d0b845d2f25a36b5812486b01b3362ec01d1d1 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 22 Feb 2026 11:37:20 -0500 Subject: [PATCH 15/26] move purge pip --- install | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/install b/install index 4f9beecb..5ca46688 100755 --- a/install +++ b/install @@ -321,6 +321,11 @@ fi sudo apt-get update && sudo apt-get dist-upgrade -y +if [ $BULLSEYE -eq 1 ]; then + sudo apt purge -y python3-pip + sudo apt install -y python3-pip +fi + if [ ! -d "/home/pi/venv" ]; then cd @@ -368,12 +373,8 @@ cd if [ ! $BULLSEYE -eq 1 ]; then sudo apt install -y libtiff6 -else - sudo apt purge -y python3-pip - sudo apt install -y python3-pip fi - sudo apt install -y python3-pip python3-smbus libjpeg-dev zlib1g-dev libfreetype6-dev libopenjp2-7 python3-pil python3-serial libusb-1.0-0 libusb-1.0-0-dev sudo pip3 install --upgrade setuptools From e680adc2ee97be0a83848721019dc97834150b88 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 22 Feb 2026 13:09:52 -0500 Subject: [PATCH 16/26] Disable python3-pip purge for BULLSEYE Comment out the installation of python3-pip for BULLSEYE. --- install | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/install b/install index 5ca46688..ced94371 100755 --- a/install +++ b/install @@ -321,10 +321,10 @@ fi sudo apt-get update && sudo apt-get dist-upgrade -y -if [ $BULLSEYE -eq 1 ]; then - sudo apt purge -y python3-pip - sudo apt install -y python3-pip -fi +# if [ $BULLSEYE -eq 1 ]; then +# sudo apt purge -y python3-pip +# sudo apt install -y python3-pip +# fi if [ ! -d "/home/pi/venv" ]; then From 4bf37051869c05e966e58c4e720842038141d7bb Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 22 Feb 2026 16:52:51 -0500 Subject: [PATCH 17/26] only do pip3 install if bullseye or initial install Added update check for CubeSatSim installation script. --- install | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/install b/install index ced94371..ea757f88 100755 --- a/install +++ b/install @@ -3,10 +3,13 @@ FLAG=0 checkout=0 BULLSEYE=0 +UPDATE=0 FILE=/home/pi/CubeSatSim/cubesatsim # code has already been compiled if [ -f "$FILE" ]; then + UPDATE=1 + echo -e "\nUpdate script for CubeSatSim v2.2\n" if [ -z "$1" ] ; then @@ -377,9 +380,13 @@ fi sudo apt install -y python3-pip python3-smbus libjpeg-dev zlib1g-dev libfreetype6-dev libopenjp2-7 python3-pil python3-serial libusb-1.0-0 libusb-1.0-0-dev -sudo pip3 install --upgrade setuptools +if [ $BULLSEYE -eq 1 ] || [ $UPDATE -eq 0] ; then + + sudo pip3 install --upgrade setuptools + + sudo pip3 install adafruit-blinka RPI.GPIO adafruit-extended-bus adafruit-circuitpython-ina219 -sudo pip3 install adafruit-blinka RPI.GPIO adafruit-extended-bus adafruit-circuitpython-ina219 +fi cd /home/pi/CubeSatSim From 92730d5b7cb3146fde4e97db2c402dd5b3b158a5 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 22 Feb 2026 17:04:18 -0500 Subject: [PATCH 18/26] Add debug print statements in transmit.py and fix setup to use pin Added print statements to output and setup functions for debugging. --- transmit.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/transmit.py b/transmit.py index b5e99fff..3dbcd5c1 100644 --- a/transmit.py +++ b/transmit.py @@ -17,6 +17,7 @@ import subprocess def output(pin, value): command = "gpio -g write " + str(pin) + " " + str(value) system(command) + print(command) def input(pin): # command = "gpio -g read " + str(pin) @@ -36,8 +37,9 @@ def input(pin): def setup(pin, config): if config == "in" or config == "out" or config == "up" or config == "down": - command = "gpio -g mode " + str(powerPin) + " " + config + command = "gpio -g mode " + str(pin) + " " + config system(command) + print(command) else: print(f"Unknown GPIO setup configuration: {config}") From 7d4d0d517f0b8725eede3e59234015c2f1ead713 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 22 Feb 2026 17:20:44 -0500 Subject: [PATCH 19/26] Implement OS version check in transmit.py from master-b-cam Add OS version check and update os_status based on command output. --- transmit.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/transmit.py b/transmit.py index 3dbcd5c1..958985af 100644 --- a/transmit.py +++ b/transmit.py @@ -481,6 +481,24 @@ if __name__ == "__main__": # print(1) setup(txLed, "out") + query = ["grep", "VERSION_CODENAME=bullseye", "/etc/os-release"] + try: + result = subprocess.run(query, capture_output=True, text=True, check=True) + print(f"Command run was: {query}") + os_status = result.stdout.strip() + print(f"Output of the command (stdout): {os_status}") + except subprocess.CalledProcessError as e: +# print(f"Command failed with return code: {e.returncode}") + print(f"Command run was: {e.cmd}") + os_status = e.stdout.strip() + print(f"Output of the command (stdout): {e.stdout}") +# print(f"Error output of the command (stderr): {e.stderr}") + if os_status != "VERSION_CODENAME=bullseye": + os_status = "bookworm" + else: + os_status = "bullseye" + print (os_status) + card = "Headphones" # default using pcm audio output of Pi Zero # card = "Device" # using USB sound card for audio output From 8e958ffd4c1c06a520b315178355b792a57eff6d Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Sun, 22 Feb 2026 22:57:23 -0500 Subject: [PATCH 20/26] Comment out txLed extra setup calls Comment out setup calls for txLed --- transmit.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/transmit.py b/transmit.py index 958985af..0ba37e65 100644 --- a/transmit.py +++ b/transmit.py @@ -479,7 +479,7 @@ if __name__ == "__main__": # GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4 # print(txLed) # print(1) - setup(txLed, "out") +# setup(txLed, "out") query = ["grep", "VERSION_CODENAME=bullseye", "/etc/os-release"] try: @@ -548,7 +548,7 @@ if __name__ == "__main__": else: if (((mode == 'a') or (mode == 'b') or (mode == 'f') or (mode == 's') or (mode == 'j')) and (command_tx == True) and (skip == False)) or ((mode == 'e') and (command_tx == True)): # battery_saver_mode # GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 - setup(txLed, "out") +# setup(txLed, "out") output(txLed, 1) print("Transmit CW ID") status = "" @@ -597,7 +597,7 @@ if __name__ == "__main__": system("cat /home/pi/CubeSatSim/t.txt") if (command_tx == True): # GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 - setup(txLed, "out") +# setup(txLed, "out") output(txLed, 1) # output(pd, 1) # output (ptt, 0) @@ -655,7 +655,7 @@ if __name__ == "__main__": ## chan = chan + 1 if (command_tx == True): # GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 - setup(txLed, "out") +# setup(txLed, "out") output(txLed, 1) if (txc): @@ -719,7 +719,7 @@ if __name__ == "__main__": if (command_tx == True): print ("Sending SSTV image") # GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 - setup(txLed, "out") +# setup(txLed, "out") output(txLed, 1) # battery_saver_check() @@ -752,7 +752,7 @@ if __name__ == "__main__": if (command_tx == True): print ("Sending SSTV image") # GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 - setup(txLed, "out") +# setup(txLed, "out") output(txLed, 1) # battery_saver_check() @@ -790,7 +790,7 @@ if __name__ == "__main__": print ("Sending SSTV image") # GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 - setup(txLed, "out") +# setup(txLed, "out") output(txLed, 1) # battery_saver_check() @@ -828,7 +828,7 @@ if __name__ == "__main__": if (command_tx == True): print ("Sending SSTV image") # GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 - setup(txLed, "out") +# setup(txLed, "out") output(txLed, 1) # battery_saver_check() @@ -859,7 +859,7 @@ if __name__ == "__main__": # command_control_check() # GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 - setup(txLed, "out") +# setup(txLed, "out") output(txLed, 1) # battery_saver_check() @@ -890,7 +890,7 @@ if __name__ == "__main__": output(ptt, 1) # GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4 - setup(txLed, "out") +# setup(txLed, "out") 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 &") @@ -910,7 +910,7 @@ if __name__ == "__main__": if (command_tx == True): # GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 - setup(txLed, "out") +# setup(txLed, "out") output(txLed, 1) # print(txLed) # print(1) @@ -950,7 +950,7 @@ if __name__ == "__main__": output(pd, 1) output(ptt, 1) # GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4 - setup(txLed, "out") +# setup(txLed, "out") # GPIO.setup(powerPin, GPIO.OUT) setup(squelch, "up") ## pull up in case pin is not connected # GPIO.output(powerPin, 1) # was 0 @@ -964,7 +964,7 @@ if __name__ == "__main__": if (input(squelch) == False) and (command_tx == True): print("Carrier detected, starting repeater") # GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 - setup(txLed, "out") +# setup(txLed, "out") output(txLed, 1) system("sudo nc -l 8011 | csdr convert_i16_f | csdr gain_ff 16000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3 > /dev/null 2>&1 &") sleep(0.5) @@ -989,7 +989,7 @@ if __name__ == "__main__": output(ptt, 1) # GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi 4 - setup(txLed, "out") +# setup(txLed, "out") 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 " + tx + "e3 &") @@ -1004,7 +1004,7 @@ if __name__ == "__main__": # command_control_check() if (command_tx == True): # GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4 - setup(txLed, "out") +# setup(txLed, "out") output(txLed, 1) # print(txLed) # print(1) From d62db52115dc858c796753a3aeac2a41f9c9b531 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 23 Feb 2026 10:29:11 -0500 Subject: [PATCH 21/26] Fix path for CubeSatSim configuration commands at start --- install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install b/install index ea757f88..45831321 100755 --- a/install +++ b/install @@ -34,9 +34,9 @@ else touch /home/pi/CubeSatSim/command_control_direwolf - /home/piCubeSatSim/config -c -n + /home/pi/CubeSatSim/config -c -n - /home/piCubeSatSim/config -l -n + /home/pi/CubeSatSim/config -l -n fi From 0096541e8017b6c76f84ae527bd3f00a92078f92 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 23 Feb 2026 10:48:57 -0500 Subject: [PATCH 22/26] Update install script to create sim.cfg before config call Add configuration line to create sim.cfg file --- install | 3 +++ 1 file changed, 3 insertions(+) diff --git a/install b/install index 45831321..68897186 100755 --- a/install +++ b/install @@ -34,6 +34,9 @@ else touch /home/pi/CubeSatSim/command_control_direwolf + echo "creating $FILE" + echo "AMSAT 0 0 0 no 3 434.9 435 no 0 0 no 60" > /home/pi/CubeSatSim/sim.cfg + /home/pi/CubeSatSim/config -c -n /home/pi/CubeSatSim/config -l -n From 2c2fde9aa0f860d48fc801ec9b163c7622ad0e33 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 23 Feb 2026 11:30:43 -0500 Subject: [PATCH 23/26] fix cubesatsim.service install Refactor cubesatsim.service handling in install script. --- install | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/install b/install index 68897186..5d99333a 100755 --- a/install +++ b/install @@ -469,12 +469,21 @@ else fi fi -if [[ $(diff /home/pi/CubeSatSim/systemd/cubesatsim.service /etc/systemd/system/cubesatsim.service) ]]; then - echo "changed cubesatsim.service." +FILE=/etc/systemd/system/cubesatsim.service +if [ -f "$FILE" ]; then + if [[ $(diff /home/pi/CubeSatSim/systemd/cubesatsim.service /etc/systemd/system/cubesatsim.service) ]]; then + echo "changed cubesatsim.service." + sudo cp /home/pi/CubeSatSim/systemd/cubesatsim.service /etc/systemd/system/cubesatsim.service + FLAG=1 + else + echo "no changes to cubesatsim.service." + fi +else + echo "creating cubesatsim.service." sudo cp /home/pi/CubeSatSim/systemd/cubesatsim.service /etc/systemd/system/cubesatsim.service + sudo systemctl enable command + FLAG=1 -else - echo "no changes to cubesatsim.service." fi FILE=/etc/systemd/system/rpitx.service From 7903b12cbd8893d7049a40e5fb2ddc776f045a78 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 23 Feb 2026 11:41:15 -0500 Subject: [PATCH 24/26] Fix spacing in conditional statement for install script --- install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install b/install index 5d99333a..0b90e65e 100755 --- a/install +++ b/install @@ -383,7 +383,7 @@ fi sudo apt install -y python3-pip python3-smbus libjpeg-dev zlib1g-dev libfreetype6-dev libopenjp2-7 python3-pil python3-serial libusb-1.0-0 libusb-1.0-0-dev -if [ $BULLSEYE -eq 1 ] || [ $UPDATE -eq 0] ; then +if [ $BULLSEYE -eq 1 ] || [ $UPDATE -eq 0 ] ; then sudo pip3 install --upgrade setuptools From 8fbe0ea4f5dd8c4c5f69d26118be405eb12a8ef8 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 23 Feb 2026 13:46:16 -0500 Subject: [PATCH 25/26] Implement SSDV installation if not present Add installation steps for SSDV in FUNcube mode. --- install | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/install b/install index 0b90e65e..a49022a0 100755 --- a/install +++ b/install @@ -631,6 +631,14 @@ if [ ! -f "/home/pi/fcdctl/fcdctl" ]; then make fcdpp fi +if [ ! -f "/home/pi/ssdv/ssdv" ]; then + cd + echo "Installing SSDV for FUNcube mode" + git clone https://github.com/alanbjohnston/ssdv.git # install ssdv for FUNcube images + cd ssdv + make +fi + cd #echo "Would you like to reboot to complete the installation (y/n)?" From 92a12d7866d670c429cd50c42f5922ca19228e63 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Tue, 24 Feb 2026 02:56:03 +0000 Subject: [PATCH 26/26] change update to link to install --- update | 482 +-------------------------------------------------------- 1 file changed, 1 insertion(+), 481 deletions(-) mode change 100755 => 120000 update diff --git a/update b/update deleted file mode 100755 index 4fe1187a..00000000 --- a/update +++ /dev/null @@ -1,481 +0,0 @@ -#!/bin/bash - -echo -e "\nupdate script for CubeSatSim v2.2\n" - -FLAG=0 -checkout=0 - -if [ -z "$1" ] ; then - checkout=0 -else - checkout=1 - branch="$1" - echo -n "changing to branch " - echo $branch - FLAG=1 -fi - -if [ "$1" = "n" ] ; then - noreboot=1 -else - noreboot=0 -fi - -# echo "No reboot" -# echo $noreboot - -sudo rm /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/id.txt /home/pi/CubeSatSim/cw.txt > /dev/null 2>&1 - -#if [ "$1" = "u" ]; then - -# sudo apt-get update && sudo apt-get dist-upgrade -y - sudo apt-get update -y - - sudo apt-get install -y git libasound2-dev i2c-tools build-essential libgd-dev libmagic-dev python3-pip minicom gpsd gpsd-clients libgps-dev python3-gps - -#fi - -sudo apt-get install -y gpsd gpsd-clients libgps-dev python3-gps - -# sudo apt-get install -y python3-smbus libusb-1.0 - -sudo sed -i 's/update.sh/update /g' /etc/motd - -sudo sed -i 's/installed and/installed\nand/g' /etc/motd - -sudo sed -i 's/more information/more\ninformation/g' /etc/motd - -sudo sed -i 's/update to/update\nto/g' /etc/motd - -sudo sed -i 's/console=tty1 r/console=tty1 maxcpus=1 r/g' /boot/cmdline.txt # single core if Pi Zero 2 - -sudo sed -i 's/maxcpus=2/maxcpus=1/g' /boot/cmdline.txt # single core if Pi Zero 2 - -sudo sed -i 's/DEVICES=""/DEVICES="\/dev\/serial0"/g' /etc/default/gpsd - -sudo sed -i 's/GPSD_OPTIONS=""/GPSD_OPTIONS="-s 9600"/g' /etc/default/gpsd - -sudo systemctl disable gpsd > /dev/null 2>&1 -sudo systemctl disable gpsd.socket > /dev/null 2>&1 - -cd /home/pi/CubeSatSim - -git pull --no-rebase > .updated - -if [ $checkout -eq 1 ]; then - git checkout $branch - git pull --no-rebase > .updated - FLAG=1 - echo "Running update script again" - /home/pi/CubeSatSim/update -fi - -make debug - -FILE=/home/pi/CubeSatSim/command_tx -if [ -f "$FILE" ]; then - echo "$FILE exists." -else - echo "creating $FILE" - echo "True\n" > /home/pi/CubeSatSim/command_tx -fi - -FILE=/home/pi/CubeSatSim/command_count.txt -if [ -f "$FILE" ]; then - echo "$FILE exists." -else - echo "creating $FILE" - echo "0\n" > /home/pi/CubeSatSim/command_count.txt -fi - -if [[ $(diff systemd/cubesatsim.service /etc/systemd/system/cubesatsim.service) ]]; then - echo "changed cubesatsim.service." - sudo cp /home/pi/CubeSatSim/systemd/cubesatsim.service /etc/systemd/system/cubesatsim.service - FLAG=1 -else - echo "no changes to cubesatsim.service." -fi - -FILE=/etc/systemd/system/rpitx.service -if [ -f "$FILE" ]; then - sudo systemctl disable rpitx - sudo rm /etc/systemd/system/rpitx.service -fi - -FILE=/etc/systemd/system/transmit.service -if [ -f "$FILE" ]; then - if [[ $(diff systemd/transmit.service /etc/systemd/system/transmit.service) ]]; then - echo "changed transmit.service." - sudo cp /home/pi/CubeSatSim/systemd/transmit.service /etc/systemd/system/transmit.service - FLAG=1 - else - echo "no change to transmit.service." - fi -else - echo "creating transmit.service." - sudo cp /home/pi/CubeSatSim/systemd/transmit.service /etc/systemd/system/transmit.service - FLAG=1 -fi - -FILE=/etc/systemd/system/command.service -if [ -f "$FILE" ]; then - if [[ $(diff systemd/command.service /etc/systemd/system/command.service) ]]; then - echo "changed command.service." - sudo cp /home/pi/CubeSatSim/systemd/command.service /etc/systemd/system/command.service - FLAG=1 - else - echo "no change to command.service." - fi -else - echo "creating command.service." - sudo cp /home/pi/CubeSatSim/systemd/command.service /etc/systemd/system/command.service - sudo systemctl enable command - FLAG=1 -fi - -FILE=/etc/asound.conf -if [ -f "$FILE" ]; then - if [[ $(diff /home/pi/CubeSatSim/asound.conf /etc/asound.conf) ]]; then - echo "changed /etc/asound.conf." - sudo cp /home/pi/CubeSatSim/asound.conf /etc/asound.conf - FLAG=1 - else - echo "no change to /etc/asound.conf." - fi -else - echo "creating /etc/asound.conf." - sudo cp /home/pi/CubeSatSim/asound.conf /etc/asound.conf - FLAG=1 -fi - -FILE=/home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg -if [ ! -f "$FILE" ]; then - echo "Copying SSTV image 1." - cp /home/pi/CubeSatSim/sstv/sstv_image_1_320_x_256.jpg /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg -fi - -FILE=/home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg -if [ ! -f "$FILE" ]; then - echo "Copying SSTV image 2." - cp /home/pi/CubeSatSim/sstv/sstv_image_2_320_x_256.jpg /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg -fi - -grep 'update' /home/pi/CubeSatSim/.updated -if [[ $(grep 'update' /home/pi/CubeSatSim/.updated) ]]; then - echo "update script updated, running again" - /home/pi/CubeSatSim/update -fi - -if [ ! -d "/home/pi/PiSSTVpp" ]; then - -# sudo apt-get update && sudo apt-get dist-upgrade -y - sudo apt-get update -y - - sudo apt-get install -y python-picamera python3-picamera build-essential libgd-dev libmagic-dev - - - cd - - git clone https://github.com/alanbjohnston/PiSSTVpp.git - - cd PiSSTVpp - - make pisstvpp - - cd - - - sudo raspi-config nonint do_camera 0 - -fi - -if [ ! -d "/home/pi/rpitx" ]; then - - cd - git clone https://github.com/alanbjohnston/rpitx.git - cd rpitx - ./install.sh - cd -else - - if [[ $(grep 'SYNCWITHPWM' /home/pi/rpitx/src/librpitx/src/fskburst.h) ]]; then - echo "rpitx library already updated" - else - echo "updating rpitx" - cd /home/pi/rpitx - git pull - ./update.sh - cd - fi -fi - -if [ ! -d "/home/pi/WiringPi" ]; then - - cd - - git clone https://github.com/alanbjohnston/WiringPi - cd WiringPi - ./build debian - - sudo dpkg -i debian-template/wiringpi-2.61-1.deb - - cd - - cd CubeSatSim - make debug - - FLAG=1 - - cd - -fi - -if [ ! -d "/home/pi/ssdv" ]; then - - echo "Installing SSDV for FUNcube mode" - cd - git clone https://github.com/alanbjohnston/ssdv.git # install ssdv for FUNcube images - cd ssdv - make - cd - FLAG=1 -fi - -if [ ! -d "/home/pi/fctelem" ]; then - echo "Installing fctelem binary v0.2 for FUNcube mode" - cd - mkdir /home/pi/fctelem - mkdir /home/pi/fctelem/public_html - cd fctelem - wget https://github.com/alanbjohnston/go/releases/download/v0.2/fctelem.zip - unzip -u fctelem.zip - FLAG=1 -elif [ ! -f "/home/pi/fctelem/v0.2" ]; then - echo "Updating fctelem binary to version v0.2 for FUNcube mode" - cd - cd /home/pi/fctelem - sudo mv fctelem fctelem.bk - sudo mv fcdecode.conf fcdecode.conf.bk - sudo mv fctelem.zip fctelem.zip.1 - wget https://github.com/alanbjohnston/go/releases/download/v0.2/fctelem.zip - unzip -u fctelem.zip - FLAG=1 -fi - -if [ ! -f "/home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi/mpu6050" ]; then - echo "Installing MPU6050-C-CPP-Library-for-Raspberry-Pi" - sudo apt-get install -y libi2c-dev - cd - git clone https://github.com/alanbjohnston/MPU6050-C-CPP-Library-for-Raspberry-Pi.git - cd MPU6050-C-CPP-Library-for-Raspberry-Pi - sudo make install - make payload -fi - -cd /home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi -git checkout master -git pull --no-rebase > .updated_p - -if [[ $(grep 'changed' /home/pi/MPU6050-C-CPP-Library-for-Raspberry-Pi/.updated_p) ]]; then - - echo "updating MPU6050-C-CPP-Library-for-Raspberry-Pi" - sudo make install - make payload -else - echo "nothing to do for MPU6050-C-CPP-Library-for-Raspberry-Pi." -fi - -if [ ! -f "/home/pi/raspberry-pi-bme280/bme280" ]; then - echo "Installing raspberry-pi-bme280" - sudo apt-get install -y libi2c-dev - cd - git clone https://github.com/alanbjohnston/raspberry-pi-bme280.git - cd raspberry-pi-bme280 - git checkout payload - make -fi - -cd /home/pi/raspberry-pi-bme280 -git checkout payload -git pull --no-rebase > .updated_p - -if [[ $(grep 'changed' /home/pi/raspberry-pi-bme280/.updated_p) ]]; then - - echo "updating raspberry-pi-bme280" - make - -else - echo "nothing to do for raspberry-pi-bme280." -fi - -if [ ! -f "/home/pi/fcdctl/fcdctl" ]; then - echo "Installing fcdctl to set FUNcubeDongle Pro gain" - sudo rm /var/lib/dpkg/info/python3-pip.list - sudo apt install python3-pip --reinstall - sudo apt-get install -y python3-smbus libusb-1.0 - cd - git clone https://github.com/csete/fcdctl.git - cd fcdctl - make fcdpp -fi - -cd /home/pi/pi-power-button - - git pull --no-rebase > .updated_p - - git checkout master - -# grep 'changed' /home/pi/pi-power-button/.updated_p -# if [[ $(grep 'changed' /home/pi/pi-power-button/.updated_p) ]]; then - - echo "updating pi-power-button." - - script/install - - FLAG=1 - - # else - # echo "nothing to do for pi-power-button." - # fi - -cd /home/pi/ssdv - - git checkout master - - git pull --no-rebase > .updated_p - - grep 'changed' /home/pi/ssdv/.updated_p - if [[ $(grep 'changed' /home/pi/ssdv/.updated_p) ]]; then - - echo "updating ssdv." - -# git checkout master - - script/install - - FLAG=1 - - else - echo "nothing to do for ssdv." - fi - - - if [[ $(grep 'dtparam=audio=on' /boot/config.txt) ]]; then - echo "dtparam=audio=on already in /boot/config.txt" - else - echo "adding dtparam=audio=on to /boot/config.txt" - sudo sh -c 'echo "\ndtparam=audio=on" >> /boot/config.txt' - FLAG=1 - fi - - if [[ $(grep 'dtoverlay=audremap,enable_jack=on' /boot/config.txt) ]]; then - echo "dtoverlay=audremap,enable_jack=on already in /boot/config.txt" - else - echo "adding dtoverlay=audremap,enable_jack=on to /boot/config.txt" - sudo sh -c 'echo "\ndtoverlay=audremap,enable_jack=on" >> /boot/config.txt' - FLAG=1 - fi - - if [[ $(grep 'dtoverlay=pwm,pin=18,func=2' /boot/config.txt) ]]; then - echo "dtoverlay=pwm,pin=18,func=2 already in /boot/config.txt" - else - echo "adding dtoverlay=pwm,pin=18,func=2 to /boot/config.txt" - sudo sh -c 'echo "\ndtoverlay=pwm,pin=18,func=2" >> /boot/config.txt' - FLAG=1 - -# cd /home/pi/pi-power-button -# git pull --no-rebase -# git checkout reboot-mode-change -# script/install - -## sudo apt-get update && sudo apt-get dist-upgrade -y -# sudo apt-get update -y -# sudo apt-get install -y libjpeg-dev zlib1g-dev libfreetype6-dev liblcms1-dev libopenjp2-7 libtiff5 python3-pil -# sudo pip3 install -y adafruit-blinka RPI.GPIO adafruit-extended-bus adafruit-circuitpython-ina219 pillow - - fi - - if [[ $(grep 'disable_splash=1' /boot/config.txt) ]]; then - echo "disable_splash=1 already in /boot/config.txt" - else - echo "adding to /boot/config.txt" - sudo sh -c 'echo "\ndisable_splash=1" >> /boot/config.txt' - FLAG=1 - fi - - if [[ $(grep 'boot_delay=0' /boot/config.txt) ]]; then - echo "boot_delay=0 already in /boot/config.txt" - else - echo "adding to /boot/config.txt" - sudo sh -c 'echo "\nboot_delay=0" >> /boot/config.txt' - FLAG=1 - 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 - -# sudo apt-get update && sudo apt-get dist-upgrade -y - -# sudo apt-get install -y libjpeg-dev zlib1g-dev libfreetype6-dev liblcms1-dev libopenjp2-7 libtiff5 -y - -# sudo pip3 install pillow - -#fi - -changed=0 -value=`cat /home/pi/CubeSatSim/sim.cfg` -# echo "$value" -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="435.0000" ; changed=1 ; else n8=$8 ; fi # receive frequency -if [ -z "$9" ] ; then n9="no" ; changed=1 ; else n9=$9 ; fi # hab mode -if [ -z "${10}" ] ; then m1="0" ; changed=1 ; else m1=${10} ; fi # rx pl code -if [ -z "${11}" ] ; then m2="0" ; changed=1 ; else m2=${11} ; fi # tx pl code - -if [ $changed -eq 1 ]; then - echo -e "Current sim.cfg configuration file:" - echo - echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11} - echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n" - echo - echo $n1 $n2 $n3 $n4 $n5 $n6 $n7 $n8 $n9 $m1 $m2 - echo $n1 $n2 $n3 $n4 $n5 $n6 $n7 $n8 $n9 $m1 $m2 > /home/pi/CubeSatSim/sim.cfg - echo -fi - -if [ "$noreboot" = "0" ] ; then - - if [ $FLAG -eq 1 ]; then - echo "systemctl daemon-reload and reboot" - sudo systemctl daemon-reload - sudo reboot -h now -# sudo cubesatsim - else - grep 'changed' /home/pi/CubeSatSim/.updated - if [[ $(grep 'changed' /home/pi/CubeSatSim/.updated) ]]; then - echo "reboot due to code changes " | wall - sudo reboot -h now -# sudo cubesatsim - else - echo "nothing to do." - fi - fi -else - if [ $FLAG -eq 1 ]; then - echo "reboot needed for changes to take effect" | wall - fi -fi - -echo "CubeSatSim update complete." diff --git a/update b/update new file mode 120000 index 00000000..f7ffc47a --- /dev/null +++ b/update @@ -0,0 +1 @@ +install \ No newline at end of file