From 4e39d7fcea366e5ac990199573672321ccee6b54 Mon Sep 17 00:00:00 2001 From: alanbjohnston Date: Tue, 29 Jun 2021 09:15:28 -0400 Subject: [PATCH] removed subprocess import and changed time.sleep to sleep --- rpitx.py | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/rpitx.py b/rpitx.py index 60743990..31a62f92 100644 --- a/rpitx.py +++ b/rpitx.py @@ -1,8 +1,9 @@ #!/usr/bin/env python import RPi.GPIO as GPIO -import subprocess -import time +#import subprocess +#import time +from time import sleep #import os import sys from os import system @@ -83,10 +84,10 @@ if __name__ == "__main__": else: 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 && 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 434.9e3 > /dev/null 2>&1") - time.sleep(4); # was 8 + sleep(4); # was 8 GPIO.output(txLed, txLedOff) - time.sleep(1) + sleep(1) if (transmit): @@ -97,7 +98,7 @@ if __name__ == "__main__": # print("There are arguments!") if (mode == 'a'): print("AFSK") - time.sleep(5) + sleep(5) try: file = open("/home/pi/CubeSatSim/t.txt") file.close() @@ -109,9 +110,9 @@ if __name__ == "__main__": system("gen_packets -o /home/pi/CubeSatSim/telem.wav /home/pi/CubeSatSim/t.txt -r 48000 > /dev/null 2>&1 && cat /home/pi/CubeSatSim/telem.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.9e3") else: system("gen_packets -o /home/pi/CubeSatSim/telem.wav /home/pi/CubeSatSim/t.txt -r 48000 > /dev/null 2>&1 && cat /home/pi/CubeSatSim/telem.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.9e3 > /dev/null 2>&1") - time.sleep(0.2) + sleep(0.2) GPIO.output(txLed, txLedOff) - time.sleep(3.8) + sleep(3.8) while True: try: f = open("/home/pi/CubeSatSim/ready") @@ -123,12 +124,12 @@ if __name__ == "__main__": GPIO.output(txLed, txLedOff) f.close() system("sudo rm ready") - time.sleep(0.5) + sleep(0.5) except: - time.sleep(0.5) + sleep(0.5) elif (mode == 'm'): print("CW") -# time.sleep(4) +# sleep(4) try: file = open("/home/pi/CubeSatSim/cw.txt") file.close() @@ -152,9 +153,9 @@ if __name__ == "__main__": GPIO.output(txLed, txLedOff) f.close() system("sudo rm cwready") - time.sleep(1) + sleep(1) except: - time.sleep(1) + sleep(1) elif (mode == 's'): print("SSTV") try: @@ -183,7 +184,7 @@ 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 434.9e3 > /dev/null 2>&1") GPIO.output(txLed, txLedOff) - # time.sleep(1) + # sleep(1) except: print("image 2 did not load - copy from CubeSatSim/sstv directory") while 1: @@ -197,7 +198,7 @@ if __name__ == "__main__": 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 434.9e3 > /dev/null 2>&1") GPIO.output(txLed, txLedOff) - time.sleep(1) + sleep(1) else: try: file = open("/home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg") @@ -210,7 +211,7 @@ if __name__ == "__main__": 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") GPIO.output(txLed, txLedOff) - time.sleep(1) + sleep(1) except: print("image 1 did not load - copy from CubeSatSim/sstv directory") try: @@ -225,15 +226,15 @@ 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 434.9e3 > /dev/null 2>&1") GPIO.output(txLed, txLedOff) - time.sleep(5) + sleep(5) except: print("image 2 did not load - copy from CubeSatSim/sstv directory") 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) + sleep(60) GPIO.output(txLed, txLedOff) - time.sleep(1) + sleep(1) elif (mode == 'b'): print("BPSK") @@ -241,18 +242,18 @@ if __name__ == "__main__": print("Turning LED on/off") while 1: GPIO.output(txLed, txLedOff) - time.sleep(0.5) + sleep(0.5) GPIO.output(txLed, txLedOn) - time.sleep(4.0) + sleep(4.0) else: print("FSK") 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 434.9e3 &") print("Turning LED on/off") while 1: GPIO.output(txLed, txLedOff) - time.sleep(0.5) + sleep(0.5) GPIO.output(txLed, txLedOn) - time.sleep(4.0) + sleep(4.0) # else: # print("FSK") # 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 434.9e3") @@ -260,4 +261,4 @@ if __name__ == "__main__": else: print("No Band Pass Filter so no telemetry transmit. See http://cubesatsim.org/wiki for instructions on how to build the BPF.") while 1: - time.sleep(5) + sleep(5)