From 3e332658cce35df36bf40ecbe0a5ac28cdd8f534 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 31 Jul 2023 15:04:58 -0400 Subject: [PATCH] added command on and off for stored image sstv --- rpitx.py | 104 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 67 insertions(+), 37 deletions(-) diff --git a/rpitx.py b/rpitx.py index 6684b42c..37d08441 100644 --- a/rpitx.py +++ b/rpitx.py @@ -332,6 +332,7 @@ if __name__ == "__main__": system("sudo rm /home/pi/CubeSatSim/camera_out.jpg > /dev/null 2>&1") output(pd, 1) + sleep(1) if GPIO.input(squelch) == False: print("carrier received!") command_tx = not command_tx @@ -377,30 +378,8 @@ if __name__ == "__main__": 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") - print ("Sending SSTV image") - output(txLed, txLedOn) - output(pd, 1) - output (ptt, 0) - - if (txc): - system("aplay /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav") - else: - if (debug_mode == 1): - system("cat /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3") - else: - system("cat /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3 > /dev/null 2>&1") + if (command_tx == True): - output(txLed, txLedOff) - output (ptt, 1) - output(pd, 0) - sleep(1) - except: - print("image 1 did not load - copy from CubeSatSim/sstv directory") - try: - file = open("/home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg") - print("Second SSTV stored image detected") - system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg") - while 1: print ("Sending SSTV image") output(txLed, txLedOn) output(pd, 1) @@ -408,33 +387,84 @@ if __name__ == "__main__": if (txc): system("aplay /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav") - else: + else: if (debug_mode == 1): - system("cat /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3") + system("cat /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3") else: - system("cat /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3 > /dev/null 2>&1") + system("cat /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3 > /dev/null 2>&1") output(txLed, txLedOff) output (ptt, 1) output(pd, 0) + sleep(1) + except: + print("image 1 did not load - copy from CubeSatSim/sstv directory") + try: + file = open("/home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg") + print("Second SSTV stored image detected") + system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg") + while 1: + + output(pd, 1) + sleep(1) + if GPIO.input(squelch) == False: + print("carrier received!") + command_tx = not command_tx + print(command_tx) + + output(green, txLedOff) + sleep(0.03) + output(green, txLedOn) + + 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") + output(pd, 0) + + if (command_tx == True): + print ("Sending SSTV image") + output(txLed, txLedOn) + output(pd, 1) + output (ptt, 0) + + if (txc): + system("aplay /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg.wav") + else: + if (debug_mode == 1): + system("cat /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3") + else: + system("cat /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3 > /dev/null 2>&1") + + output(txLed, txLedOff) + output (ptt, 1) + output(pd, 0) sleep(5) except: print("image 2 did not load - copy from CubeSatSim/sstv directory") if (txc == False): - system("(while true; do (sleep 5 && cat /home/pi/CubeSatSim/wav/sstv.wav); done) | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3 &") + if (command_tx == True): + system("(while true; do (sleep 5 && cat /home/pi/CubeSatSim/wav/sstv.wav); done) | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3 &") while 1: - output(txLed, txLedOn) - output(pd, 1) - output (ptt, 0) + if (command_tx == True): + + output(txLed, txLedOn) + output(pd, 1) + output (ptt, 0) - if (txc): - system("aplay /home/pi/CubeSatSim/sstv.wav") - else: - sleep(60) + if (txc): + system("aplay /home/pi/CubeSatSim/sstv.wav") + else: + sleep(60) - output(txLed, txLedOff) - output (ptt, 1) - output(pd, 0) + output(txLed, txLedOff) + output (ptt, 1) + output(pd, 0) sleep(1) elif (mode == 'b'): print("BPSK")