Merge pull request #328 from alanbjohnston/beta-extra-2

LED fixes and others
beta-extra
Alan Johnston 1 year ago committed by GitHub
commit 8fa53873ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -366,7 +366,7 @@ elif [ "$1" = "-a" ]; then
echo "changing CubeSatSim to AFSK mode" echo "changing CubeSatSim to AFSK mode"
sudo echo "a" > /home/pi/CubeSatSim/.mode sudo echo "a" > /home/pi/CubeSatSim/.mode
if [ "$1" == "f" ] || [ "$1" == "b" ] ; then if [ "$1" == "f" ] || [ "$1" == "b" ] || [ "$1" == "e" ] ; then
FILE=/home/pi/CubeSatSim/battery_saver FILE=/home/pi/CubeSatSim/battery_saver
if [ -f "$FILE" ]; then if [ -f "$FILE" ]; then
restart=1 restart=1
@ -392,7 +392,7 @@ elif [ "$1" = "-m" ]; then
echo "changing CubeSatSim to CW mode" echo "changing CubeSatSim to CW mode"
sudo echo "m" > /home/pi/CubeSatSim/.mode sudo echo "m" > /home/pi/CubeSatSim/.mode
if [ "$1" == "f" ] || [ "$1" == "b" ] ; then if [ "$1" == "f" ] || [ "$1" == "b" ] || [ "$1" == "e" ] ; then
FILE=/home/pi/CubeSatSim/battery_saver FILE=/home/pi/CubeSatSim/battery_saver
if [ -f "$FILE" ]; then if [ -f "$FILE" ]; then
restart=1 restart=1
@ -452,7 +452,7 @@ elif [ "$1" = "-s" ]; then
echo "changing CubeSatSim to SSTV mode" echo "changing CubeSatSim to SSTV mode"
sudo echo "s" > /home/pi/CubeSatSim/.mode sudo echo "s" > /home/pi/CubeSatSim/.mode
if [ "$1" == "f" ] || [ "$1" == "b" ] ; then if [ "$1" == "f" ] || [ "$1" == "b" ] || [ "$1" == "e" ] ; then
FILE=/home/pi/CubeSatSim/battery_saver FILE=/home/pi/CubeSatSim/battery_saver
if [ -f "$FILE" ]; then if [ -f "$FILE" ]; then
@ -1431,8 +1431,9 @@ fi
if [ "$restart" = "1" ] ; then if [ "$restart" = "1" ] ; then
if [ "$reboot" = "0" ] ; then if [ "$reboot" = "0" ] ; then
echo "Restarting" echo "Restarting"
sudo systemctl stop rpitx # sudo systemctl stop rpitx
sudo systemctl restart cubesatsim sudo systemctl restart cubesatsim
sudo systemctl restart rpitx
else else
echo "Restart needed for changes to take effect" echo "Restart needed for changes to take effect"
fi fi

@ -45,6 +45,8 @@ int main(int argc, char * argv[]) {
fprintf(stderr, "Pi Zero 2 detected\n"); fprintf(stderr, "Pi Zero 2 detected\n");
pi_zero_2_offset = 500; pi_zero_2_offset = 500;
if (uptime_sec < 30.0) { if (uptime_sec < 30.0) {
FILE * rpitx_stop = popen("sudo systemctl start rpitx", "r");
pclose(rpitx_stop);
fprintf(stderr, "Sleep 5 sec"); fprintf(stderr, "Sleep 5 sec");
sleep(5); // try sleep at start to help boot sleep(5); // try sleep at start to help boot
} }
@ -63,6 +65,8 @@ int main(int argc, char * argv[]) {
} }
} }
if (uptime_sec < 30.0) { if (uptime_sec < 30.0) {
FILE * rpitx_stop = popen("sudo systemctl start rpitx", "r");
pclose(rpitx_stop);
fprintf(stderr,"Sleep 10 sec"); fprintf(stderr,"Sleep 10 sec");
sleep(10); sleep(10);
} }
@ -124,8 +128,8 @@ int main(int argc, char * argv[]) {
} }
// FILE * rpitx_stop = popen("sudo systemctl stop rpitx", "r"); // FILE * rpitx_stop = popen("sudo systemctl stop rpitx", "r");
FILE * rpitx_stop = popen("sudo systemctl restart rpitx", "r"); // FILE * rpitx_stop = popen("sudo systemctl restart rpitx", "r");
pclose(rpitx_stop);
// FILE * cc_start = popen("/home/pi/CubeSatSim/command &", "r"); // FILE * cc_start = popen("/home/pi/CubeSatSim/command &", "r");
// pclose(cc_start); // pclose(cc_start);
@ -340,15 +344,15 @@ int main(int argc, char * argv[]) {
} }
} }
} }
pinMode(txLed, OUTPUT); // pinMode(txLed, OUTPUT);
digitalWrite(txLed, txLedOff); // digitalWrite(txLed, txLedOff);
#ifdef DEBUG_LOGGING #ifdef DEBUG_LOGGING
printf("Tx LED Off\n"); // printf("Tx LED Off\n");
#endif #endif
pinMode(onLed, OUTPUT); // pinMode(onLed, OUTPUT);
digitalWrite(onLed, onLedOn); // digitalWrite(onLed, onLedOn);
#ifdef DEBUG_LOGGING #ifdef DEBUG_LOGGING
printf("Power LED On\n"); // printf("Power LED On\n");
#endif #endif
/* /*
if (mode == SSTV) { if (mode == SSTV) {

@ -11,53 +11,6 @@ from os import system
from PIL import Image, ImageDraw, ImageFont, ImageColor from PIL import Image, ImageDraw, ImageFont, ImageColor
import serial import serial
def command_control_check():
global command_control
global no_command
global debug_mode
global command_count
return
output(pd, 1)
output(ptt, 1)
sleep(1)
if (no_command == False and GPIO.input(squelch) == False):
print("carrier received!")
# command_tx = not command_tx
# print(command_tx)
try:
command_count += 1
filec = open("/home/pi/CubeSatSim/command_count.txt", "w")
command_count_string = str(command_count)
print(command_count_string)
string = filec.write(command_count_string)
filec.close()
except:
if (debug_mode == 1):
print("Can't write command_count file!")
print("Command_count: ")
print(command_count)
increment_mode()
# if (command_tx == True):
# print("Turning on transmit")
# system("echo > command_tx True")
# output(txLed, txLedOn)
# sleep(0.5)
# output(txLed, txLedff)
# else:
# print("Turning off transmit")
# system("echo > command_tx False")
else:
print("No carrier received!")
# output(pd, 0)
# sleep(1)
def battery_saver_check(): def battery_saver_check():
try: try:
global txc global txc
@ -435,12 +388,14 @@ if __name__ == "__main__":
system("echo 'hi hi de " + callsign + "' > id.txt && gen_packets -M 20 /home/pi/CubeSatSim/id.txt -o /home/pi/CubeSatSim/morse.wav -r 48000 > /dev/null 2>&1") system("echo 'hi hi de " + callsign + "' > id.txt && gen_packets -M 20 /home/pi/CubeSatSim/id.txt -o /home/pi/CubeSatSim/morse.wav -r 48000 > /dev/null 2>&1")
command_control_check() # command_control_check()
# if (mode != ) and (command_tx == True): # if (mode != ) and (command_tx == True):
# if (command_tx == True): # if (command_tx == True):
if ((mode == 'a') or (mode == 'b') or (mode == 'f') or (mode == 's')) and (command_tx == True) and (skip == False): if ((mode == 'a') or (mode == 'b') or (mode == 'f') or (mode == 's')) and (command_tx == True) and (skip == False):
# battery_saver_mode # battery_saver_mode
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
GPIO.setup(txLed, GPIO.OUT)
output(txLed, txLedOn) output(txLed, txLedOn)
# if (txc): # if (txc):
# output(pd, 1) # output(pd, 1)
@ -472,7 +427,7 @@ if __name__ == "__main__":
# if (len(sys.argv)) > 1: # if (len(sys.argv)) > 1:
# print("There are arguments!") # print("There are arguments!")
if (mode == 'a') or (mode == 'x') or (mode == 'n'): if (mode == 'a') or (mode == 'x') or (mode == 'n'):
command_control_check() # command_control_check()
output(pd, 1) output(pd, 1)
output(ptt, 1) output(ptt, 1)
if (mode == 'a'): if (mode == 'a'):
@ -482,6 +437,7 @@ if __name__ == "__main__":
print("Transmit APRS Commands") print("Transmit APRS Commands")
# while True: # while True:
# sleep(0.1) # sleep(0.1)
if (mode != 'n'):
system("touch /home/pi/CubeSatSim/ready") system("touch /home/pi/CubeSatSim/ready")
while True: while True:
@ -493,6 +449,8 @@ if __name__ == "__main__":
system("gen_packets -o /home/pi/CubeSatSim/telem.wav /home/pi/CubeSatSim/t.txt -r 48000 > /dev/null 2>&1") system("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") system("cat /home/pi/CubeSatSim/t.txt")
if (command_tx == True): if (command_tx == True):
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
GPIO.setup(txLed, GPIO.OUT)
output(txLed, txLedOn) output(txLed, txLedOn)
# output(pd, 1) # output(pd, 1)
# output (ptt, 0) # output (ptt, 0)
@ -527,13 +485,13 @@ if __name__ == "__main__":
sleep(0.5) sleep(0.5)
except: except:
command_control_check() # command_control_check()
sleep(1) sleep(1)
elif (mode == 'm'): elif (mode == 'm'):
system("touch /home/pi/CubeSatSim/cwready") system("touch /home/pi/CubeSatSim/cwready")
print("CW") print("CW")
while True: while True:
command_control_check() # command_control_check()
output (pd, 1) output (pd, 1)
output (ptt, 1) output (ptt, 1)
try: try:
@ -547,6 +505,8 @@ if __name__ == "__main__":
system(command) system(command)
## chan = chan + 1 ## chan = chan + 1
if (command_tx == True): if (command_tx == True):
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
GPIO.setup(txLed, GPIO.OUT)
output(txLed, txLedOn) output(txLed, txLedOn)
if (txc): if (txc):
@ -564,7 +524,7 @@ if __name__ == "__main__":
system("cat /home/pi/CubeSatSim/morse.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f " + tx + "e3 > /dev/null 2>&1") system("cat /home/pi/CubeSatSim/morse.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f " + tx + "e3 > /dev/null 2>&1")
output(txLed, txLedOff) output(txLed, txLedOff)
command_control_check() # command_control_check()
sleep(2) sleep(2)
f.close() f.close()
sleep(10) sleep(10)
@ -573,7 +533,7 @@ if __name__ == "__main__":
sleep(1) sleep(1)
elif (mode == 's'): elif (mode == 's'):
print("SSTV") print("SSTV")
command_control_check() # command_control_check()
output (ptt, 1) output (ptt, 1)
output(pd, 1) output(pd, 1)
try: try:
@ -601,10 +561,12 @@ if __name__ == "__main__":
file = open("/home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg") file = open("/home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg")
print("First SSTV stored image detected") print("First SSTV stored image detected")
system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg") system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg")
command_control_check() # command_control_check()
if (command_tx == True): if (command_tx == True):
print ("Sending SSTV image") print ("Sending SSTV image")
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
GPIO.setup(txLed, GPIO.OUT)
output(txLed, txLedOn) output(txLed, txLedOn)
# battery_saver_check() # battery_saver_check()
@ -626,7 +588,7 @@ if __name__ == "__main__":
except: except:
print("image 2 did not load - copy from CubeSatSim/sstv directory") print("image 2 did not load - copy from CubeSatSim/sstv directory")
while 1: while 1:
command_control_check() # command_control_check()
system("raspistill -o /home/pi/CubeSatSim/camera_out.jpg -w 320 -h 256") # > /dev/null 2>&1") system("raspistill -o /home/pi/CubeSatSim/camera_out.jpg -w 320 -h 256") # > /dev/null 2>&1")
print("Photo taken") print("Photo taken")
@ -654,15 +616,17 @@ if __name__ == "__main__":
draw.text((120, 10), telem_string, font=font2, fill='white') draw.text((120, 10), telem_string, font=font2, fill='white')
img.save(file) img.save(file)
command_control_check() # command_control_check()
system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/CubeSatSim/camera_out.jpg") system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/CubeSatSim/camera_out.jpg")
system("sudo rm /home/pi/CubeSatSim/camera_out.jpg > /dev/null 2>&1") system("sudo rm /home/pi/CubeSatSim/camera_out.jpg > /dev/null 2>&1")
command_control_check() # command_control_check()
if (command_tx == True): if (command_tx == True):
print ("Sending SSTV image") print ("Sending SSTV image")
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
GPIO.setup(txLed, GPIO.OUT)
output(txLed, txLedOn) output(txLed, txLedOn)
# battery_saver_check() # battery_saver_check()
@ -686,17 +650,19 @@ if __name__ == "__main__":
sleep(10) sleep(10)
else: else:
try: try:
command_control_check() # command_control_check()
file = open("/home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg") file = open("/home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg")
print("First SSTV stored image detected") print("First SSTV stored image detected")
system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg") system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg")
command_control_check() # command_control_check()
if (command_tx == True): if (command_tx == True):
print ("Sending SSTV image") print ("Sending SSTV image")
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
GPIO.setup(txLed, GPIO.OUT)
output(txLed, txLedOn) output(txLed, txLedOn)
# battery_saver_check() # battery_saver_check()
@ -720,7 +686,7 @@ if __name__ == "__main__":
except: except:
print("image 1 did not load - copy from CubeSatSim/sstv directory") print("image 1 did not load - copy from CubeSatSim/sstv directory")
try: try:
command_control_check() # command_control_check()
file = open("/home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg") file = open("/home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg")
print("Second SSTV stored image detected") print("Second SSTV stored image detected")
@ -728,10 +694,12 @@ if __name__ == "__main__":
while 1: while 1:
command_control_check() # command_control_check()
if (command_tx == True): if (command_tx == True):
print ("Sending SSTV image") print ("Sending SSTV image")
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
GPIO.setup(txLed, GPIO.OUT)
output(txLed, txLedOn) output(txLed, txLedOn)
# battery_saver_check() # battery_saver_check()
@ -758,8 +726,12 @@ if __name__ == "__main__":
system("(while true; do (sleep 10 && cat /home/pi/CubeSatSim/wav/sstv.wav); done) | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3 &") system("(while true; do (sleep 10 && cat /home/pi/CubeSatSim/wav/sstv.wav); done) | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3 &")
while 1: while 1:
if (command_tx == True): if (command_tx == True):
command_control_check() # command_control_check()
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
GPIO.setup(txLed, GPIO.OUT)
output(txLed, txLedOn) output(txLed, txLedOn)
# battery_saver_check() # battery_saver_check()
if (txc): if (txc):
@ -800,6 +772,8 @@ if __name__ == "__main__":
# command_control_check() # command_control_check()
if (command_tx == True): if (command_tx == True):
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
GPIO.setup(txLed, GPIO.OUT)
output(txLed, txLedOn) output(txLed, txLedOn)
print(txLed) print(txLed)
print(txLedOn) print(txLedOn)
@ -816,6 +790,8 @@ if __name__ == "__main__":
sleep(0.5) sleep(0.5)
if (GPIO.input(squelch) == False): if (GPIO.input(squelch) == False):
print("Carrier detected, starting repeater") print("Carrier detected, starting repeater")
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
GPIO.setup(txLed, GPIO.OUT)
output(txLed, txLedOn) output(txLed, txLedOn)
# system("arecord -D hw:CARD=Device,DEV=0 | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3 &") # system("arecord -D hw:CARD=Device,DEV=0 | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3 &")
system("arecord -D hw:CARD=Device,DEV=0 -f S16_LE -r 48000 -c 1 | csdr convert_s16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3 &") system("arecord -D hw:CARD=Device,DEV=0 -f S16_LE -r 48000 -c 1 | csdr convert_s16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f " + tx + "e3 &")
@ -849,6 +825,8 @@ if __name__ == "__main__":
# output(txLed, txLedOff) # output(txLed, txLedOff)
# command_control_check() # command_control_check()
if (command_tx == True): if (command_tx == True):
GPIO.setmode(GPIO.BCM) # added to make Tx LED work on Pi Zero 2 and Pi 4
GPIO.setup(txLed, GPIO.OUT)
output(txLed, txLedOn) output(txLed, txLedOn)
print(txLed) print(txLed)
print(txLedOn) print(txLedOn)

@ -66,6 +66,8 @@ else
echo "no changes to cubesatsim.service." echo "no changes to cubesatsim.service."
fi fi
sudo systemctl disable rpitx
if [[ $(diff systemd/rpitx.service /etc/systemd/system/rpitx.service) ]]; then if [[ $(diff systemd/rpitx.service /etc/systemd/system/rpitx.service) ]]; then
echo "changed rpitx.service." echo "changed rpitx.service."
sudo cp /home/pi/CubeSatSim/systemd/rpitx.service /etc/systemd/system/rpitx.service sudo cp /home/pi/CubeSatSim/systemd/rpitx.service /etc/systemd/system/rpitx.service

Loading…
Cancel
Save

Powered by TurnKey Linux.