From a5fc7fc4996aecfc2c4e4fdf716655ff3be93a21 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Sat, 5 Jun 2021 18:00:08 -0400 Subject: [PATCH] check for initial_image.jpg and copy and transmit as first SSTV image --- rpitx.py | 47 ++++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/rpitx.py b/rpitx.py index bbad70c2..b4d5bfe0 100644 --- a/rpitx.py +++ b/rpitx.py @@ -32,8 +32,11 @@ GPIO.output(27, 0) print(transmit) -file = open("/home/pi/CubeSatSim/sim.cfg") -callsign = file.readline().split(" ")[0] +try: + file = open("/home/pi/CubeSatSim/sim.cfg") + callsign = file.readline().split(" ")[0] +except: + callsign = "AMSAT" print(callsign) #GPIO.output(27, 1); @@ -80,28 +83,38 @@ if __name__ == "__main__": print("No camera") camera_present = 0 - while 1: - GPIO.output(txLed, txLedOff) - if (camera_present == 1): - GPIO.output(txLed, txLedOn) +# while 1: + GPIO.output(txLed, txLedOff) + if (camera_present == 1): + try: + file = open("/home/pi/CubeSatSim/initial_image.jpg") + system("cp /home/pi/CubeSatSim/initial_image.jpg /home/pi/CubeSatSim/camera_out.jpg") + print("Initial image copied") + except: + print("No initial image") + system("raspistill -o /home/pi/camera_out.jpg -w 320 -h 256") # > /dev/null 2>&1") + print("Photo taken") + while 1: +# GPIO.output(txLed, txLedOn) system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/camera_out.jpg") # > /dev/null 2>&1") - GPIO.output(txLed, txLedOff) +# GPIO.output(txLed, txLedOff) print ("Sending SSTV photo") time.sleep(1) - system("sudo killall -9 rpitx > /dev/null 2>&1") - system("sudo killall -9 csdr > /dev/null 2>&1") - system("sudo killall -9 cat > /dev/null 2>&1") +# system("sudo killall -9 rpitx > /dev/null 2>&1") +# system("sudo killall -9 csdr > /dev/null 2>&1") +# system("sudo killall -9 cat > /dev/null 2>&1") GPIO.output(txLed, txLedOn); system("cat /home/pi/camera_out.jpg.wav | csdr convert_i16_f | csdr gain_ff 14000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3") # > /dev/null 2>&1") + GPIO.output(txLed, txLedOff) system("raspistill -o /home/pi/camera_out.jpg -w 320 -h 256") # > /dev/null 2>&1") print("Photo taken") - else: - 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: - GPIO.output(txLed, txLedOn) - time.sleep(60) - GPIO.output(txLed, txLedOff) - time.sleep(1) + else: + 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: + GPIO.output(txLed, txLedOn) + time.sleep(60) + GPIO.output(txLed, txLedOff) + time.sleep(1) elif (('b' == sys.argv[1]) or ('bpsk' in sys.argv[1])): print("BPSK")