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"
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
if [ -f "$FILE" ]; then
restart=1
@ -392,7 +392,7 @@ elif [ "$1" = "-m" ]; then
echo "changing CubeSatSim to CW 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
if [ -f "$FILE" ]; then
restart=1
@ -452,7 +452,7 @@ elif [ "$1" = "-s" ]; then
echo "changing CubeSatSim to SSTV 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
if [ -f "$FILE" ]; then
@ -1431,8 +1431,9 @@ fi
if [ "$restart" = "1" ] ; then
if [ "$reboot" = "0" ] ; then
echo "Restarting"
sudo systemctl stop rpitx
# sudo systemctl stop rpitx
sudo systemctl restart cubesatsim
sudo systemctl restart rpitx
else
echo "Restart needed for changes to take effect"
fi

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

@ -11,53 +11,6 @@ from os import system
from PIL import Image, ImageDraw, ImageFont, ImageColor
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():
try:
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")
command_control_check()
# command_control_check()
# if (mode != ) and (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):
# 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)
# if (txc):
# output(pd, 1)
@ -472,7 +427,7 @@ if __name__ == "__main__":
# if (len(sys.argv)) > 1:
# print("There are arguments!")
if (mode == 'a') or (mode == 'x') or (mode == 'n'):
command_control_check()
# command_control_check()
output(pd, 1)
output(ptt, 1)
if (mode == 'a'):
@ -482,6 +437,7 @@ if __name__ == "__main__":
print("Transmit APRS Commands")
# while True:
# sleep(0.1)
if (mode != 'n'):
system("touch /home/pi/CubeSatSim/ready")
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("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
GPIO.setup(txLed, GPIO.OUT)
output(txLed, txLedOn)
# output(pd, 1)
# output (ptt, 0)
@ -527,13 +485,13 @@ if __name__ == "__main__":
sleep(0.5)
except:
command_control_check()
# command_control_check()
sleep(1)
elif (mode == 'm'):
system("touch /home/pi/CubeSatSim/cwready")
print("CW")
while True:
command_control_check()
# command_control_check()
output (pd, 1)
output (ptt, 1)
try:
@ -547,6 +505,8 @@ 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
GPIO.setup(txLed, GPIO.OUT)
output(txLed, txLedOn)
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")
output(txLed, txLedOff)
command_control_check()
# command_control_check()
sleep(2)
f.close()
sleep(10)
@ -573,7 +533,7 @@ if __name__ == "__main__":
sleep(1)
elif (mode == 's'):
print("SSTV")
command_control_check()
# command_control_check()
output (ptt, 1)
output(pd, 1)
try:
@ -601,10 +561,12 @@ if __name__ == "__main__":
file = open("/home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg")
print("First SSTV stored image detected")
system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg")
command_control_check()
# command_control_check()
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
GPIO.setup(txLed, GPIO.OUT)
output(txLed, txLedOn)
# battery_saver_check()
@ -626,7 +588,7 @@ if __name__ == "__main__":
except:
print("image 2 did not load - copy from CubeSatSim/sstv directory")
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")
print("Photo taken")
@ -654,15 +616,17 @@ if __name__ == "__main__":
draw.text((120, 10), telem_string, font=font2, fill='white')
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("sudo rm /home/pi/CubeSatSim/camera_out.jpg > /dev/null 2>&1")
command_control_check()
# command_control_check()
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
GPIO.setup(txLed, GPIO.OUT)
output(txLed, txLedOn)
# battery_saver_check()
@ -686,17 +650,19 @@ if __name__ == "__main__":
sleep(10)
else:
try:
command_control_check()
# command_control_check()
file = open("/home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg")
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")
command_control_check()
# command_control_check()
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
GPIO.setup(txLed, GPIO.OUT)
output(txLed, txLedOn)
# battery_saver_check()
@ -720,7 +686,7 @@ if __name__ == "__main__":
except:
print("image 1 did not load - copy from CubeSatSim/sstv directory")
try:
command_control_check()
# command_control_check()
file = open("/home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg")
print("Second SSTV stored image detected")
@ -728,10 +694,12 @@ if __name__ == "__main__":
while 1:
command_control_check()
# command_control_check()
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
GPIO.setup(txLed, GPIO.OUT)
output(txLed, txLedOn)
# 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 &")
while 1:
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)
# battery_saver_check()
if (txc):
@ -800,6 +772,8 @@ 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
GPIO.setup(txLed, GPIO.OUT)
output(txLed, txLedOn)
print(txLed)
print(txLedOn)
@ -816,6 +790,8 @@ if __name__ == "__main__":
sleep(0.5)
if (GPIO.input(squelch) == False):
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)
# 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 &")
@ -849,6 +825,8 @@ if __name__ == "__main__":
# output(txLed, txLedOff)
# command_control_check()
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)
print(txLed)
print(txLedOn)

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

Loading…
Cancel
Save

Powered by TurnKey Linux.