set mode based on reading .mode file

pull/93/head
alanbjohnston 5 years ago committed by GitHub
parent c418a21f54
commit 04864dc2aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -37,7 +37,7 @@ try:
mode = file.read(1) mode = file.read(1)
except: except:
mode = "f" mode = "f"
print("Mode char is: ") print("Mode is: ")
print(mode) print(mode)
try: try:
@ -61,88 +61,88 @@ if __name__ == "__main__":
# print 'Length: ', len(sys.argv) # print 'Length: ', len(sys.argv)
if (len(sys.argv)) > 1: # if (len(sys.argv)) > 1:
# print("There are arguments!") # print("There are arguments!")
if (('a' == sys.argv[1]) or ('afsk' in sys.argv[1])): if (mode == 'a'):
print("AFSK") print("AFSK")
time.sleep(4)
for x in range(5):
GPIO.output(txLed, txLedOn);
system("sudo 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")
GPIO.output(txLed, txLedOff);
time.sleep(4) time.sleep(4)
for x in range(5): while True:
GPIO.output(txLed, txLedOn); try:
f = open("/home/pi/CubeSatSim/ready")
system("sudo 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") system("sudo 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")
GPIO.output(txLed, txLedOff); f.close()
time.sleep(4) system("sudo rm ready")
while True: time.sleep(0.5)
try: except:
f = open("/home/pi/CubeSatSim/ready") time.sleep(0.5)
system("sudo 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") elif (mode == 's'):
f.close() print("SSTV")
system("sudo rm ready") try:
time.sleep(0.5) from picamera import PiCamera
except:
time.sleep(0.5)
elif (('s' == sys.argv[1]) or ('sstv' in sys.argv[1])):
print("SSTV")
try:
from picamera import PiCamera
# from pysstv.sstv import SSTV # from pysstv.sstv import SSTV
camera = PiCamera() camera = PiCamera()
print("Camera present") print("Camera present")
camera_present = 1 camera_present = 1
camera.close() camera.close()
except: except:
print("No camera") print("No camera")
camera_present = 0 camera_present = 0
try: try:
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")
print ("Sending SSTV image")
GPIO.output(txLed, txLedOn);
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)
except:
print("No first image")
# while 1:
GPIO.output(txLed, txLedOff)
if (camera_present == 1):
while 1:
system("raspistill -o /home/pi/CubeSatSim/camera_out.jpg -w 320 -h 256") # > /dev/null 2>&1")
print("Photo taken")
system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/CubeSatSim/camera_out.jpg")
print ("Sending SSTV image") print ("Sending SSTV image")
GPIO.output(txLed, txLedOn); GPIO.output(txLed, txLedOn);
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/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) GPIO.output(txLed, txLedOff)
# time.sleep(1) time.sleep(1)
except: else:
print("No first image") try:
# while 1: file = open("/home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg")
GPIO.output(txLed, txLedOff) print("Second SSTV stored image detected")
if (camera_present == 1): system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg")
while 1: while 1:
system("raspistill -o /home/pi/CubeSatSim/camera_out.jpg -w 320 -h 256") # > /dev/null 2>&1")
print("Photo taken")
system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/CubeSatSim/camera_out.jpg")
print ("Sending SSTV image") print ("Sending SSTV image")
GPIO.output(txLed, txLedOn); GPIO.output(txLed, txLedOn);
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") 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)
except:
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) GPIO.output(txLed, txLedOff)
time.sleep(1) time.sleep(1)
else:
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")
GPIO.output(txLed, txLedOn);
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)
except:
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])): elif (mode == 'b'):
print("BPSK") print("BPSK")
system("sudo nc -l 8080 | csdr convert_i16_f | csdr fir_interpolate_cc 2 | csdr dsb_fc | csdr bandpass_fir_fft_cc 0.002 0.06 0.01 | csdr fastagc_ff | sudo /home/pi/rpitx/sendiq -i /dev/stdin -s 96000 -f 434.9e6 -t float") system("sudo nc -l 8080 | csdr convert_i16_f | csdr fir_interpolate_cc 2 | csdr dsb_fc | csdr bandpass_fir_fft_cc 0.002 0.06 0.01 | csdr fastagc_ff | sudo /home/pi/rpitx/sendiq -i /dev/stdin -s 96000 -f 434.9e6 -t float")
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")
else: else:
print("FSK") 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") 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")
# 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")
else: else:
print("No Band Pass Filter so no telemetry transmit. See http://cubesatsim.org/wiki for instructions on how to build the BPF.") print("No Band Pass Filter so no telemetry transmit. See http://cubesatsim.org/wiki for instructions on how to build the BPF.")

Loading…
Cancel
Save

Powered by TurnKey Linux.