Merge pull request #86 from alanbjohnston/camera

Pi camera photo to SSTV
pull/87/head
alanbjohnston 5 years ago committed by GitHub
commit c8cf505068
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -3,79 +3,114 @@
import RPi.GPIO as GPIO import RPi.GPIO as GPIO
import subprocess import subprocess
import time import time
import os #import os
import sys import sys
from os import system
GPIO.setmode(GPIO.BCM) GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False) GPIO.setwarnings(False)
GPIO.setup(27, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_UP)
transmit = False transmit = False
if GPIO.input(12) == False: if GPIO.input(12) == False:
transmit = True transmit = True
if GPIO.input(27) == False: if GPIO.input(22) == False:
transmit = True transmit = True
txLed = 22 txLed = 27
txLedOn = False txLedOn = 0
txLedOff = True txLedOff = 1
else: else:
txLed = 27 txLed = 27
txLedOn = True txLedOn = 1
txLedOff = False txLedOff = 0
GPIO.setup(txLed, GPIO.OUT) GPIO.setup(txLed, GPIO.OUT)
print(txLedOn)
print(txLed)
GPIO.setup(27, GPIO.OUT)
GPIO.output(27, 0)
print(transmit) print(transmit)
file = open("/home/pi/CubeSatSim/sim.cfg") file = open("/home/pi/CubeSatSim/sim.cfg")
callsign = file.readline().split(" ")[0] callsign = file.readline().split(" ")[0]
print(callsign) print(callsign)
#GPIO.output(27, 1);
GPIO.output(txLed, txLedOn); GPIO.output(txLed, txLedOn);
os.system("echo 'de " + callsign + "' > id.txt && gen_packets -M 20 id.txt -o morse.wav -r 48000 > /dev/null 2>&1 && cat 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") system("echo 'de " + callsign + "' > id.txt && gen_packets -M 20 id.txt -o morse.wav -r 48000 > /dev/null 2>&1 && cat 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")
#GPIO.output(27, 0);
GPIO.output(txLed, txLedOff); GPIO.output(txLed, txLedOff);
time.sleep(2) time.sleep(2)
if __name__ == "__main__": if __name__ == "__main__":
if (transmit): if (transmit):
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 (('a' == sys.argv[1]) or ('afsk' in sys.argv[1])):
print("AFSK") print("AFSK")
while True: while True:
try: try:
f = open("ready") f = open("ready")
os.system("gen_packets -o telem.wav t.txt -r 48000 > /dev/null 2>&1 && cat 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") os.system("gen_packets -o telem.wav t.txt -r 48000 > /dev/null 2>&1 && cat 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")
os.system("rm ready") os.system("rm ready")
time.sleep(0.5) time.sleep(0.5)
except: except:
time.sleep(0.5) time.sleep(0.5)
elif (('s' == sys.argv[1]) or ('sstv' in sys.argv[1])): elif (('s' == sys.argv[1]) or ('sstv' in sys.argv[1])):
print("SSTV") print("SSTV")
GPIO.output(txLed, txLedOn); try:
os.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") from picamera import PiCamera
# while True: # from pysstv.sstv import SSTV
# GPIO.output(txLed, txLedOff); camera = PiCamera()
# print("Sleeping") print("Camera present")
# time.sleep(10) camera_present = 1
# print("Transmitting SSTV") camera.close()
# GPIO.output(txLed, txLedOn); except:
# os.system("cat /home/pi/CubeSatSim/wav/sstv.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3") print("No camera")
elif (('b' == sys.argv[1]) or ('bpsk' in sys.argv[1])): camera_present = 0
print("BPSK")
os.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") while 1:
# 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 &")
GPIO.output(txLed, txLedOff)
if (camera_present == 1):
system("raspistill -o /home/pi/camera_out.jpg -w 320 -h 256") # > /dev/null 2>&1")
print("Photo taken")
GPIO.output(txLed, txLedOn)
# system("sudo python3 -m pysstv --mode PD120 /home/pi/camera_out.jpg /home/pi/sstv_camera.wav") # > /dev/null 2>&1")
system("/home/pi/PiSSTVpp/pisstvpp -r 48000 -p s2 /home/pi/camera_out.jpg") # > /dev/null 2>&1")
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")
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")
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")
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:
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("No Band Pass Filter so no telemetry transmit. See http://cubesatsim.org/wiki for instructions on how to build the BPF.")
os.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") while 1:
else: time.sleep(5)
print("FSK")
os.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("No Band Pass Filter so no telemetry transmit. See http://cubesatsim.org/wiki for instructions on how to build the BPF.")
while True:
time.sleep(5)

@ -8,18 +8,18 @@ if [ "$1" = "c" ]; then
echo $y echo $y
if [ $(($y % 4)) = 3 ]; then if [ $(($y % 4)) = 3 ]; then
echo "Mode is continuous AFSK" echo "Mode is continuous AFSK"
python -u /home/pi/CubeSatSim/rpitx.py a python3 -u /home/pi/CubeSatSim/rpitx.py a
elif [ $(($y % 4)) = 1 ]; then elif [ $(($y % 4)) = 1 ]; then
echo "Mode is continuous BPSK" echo "Mode is continuous BPSK"
python -u /home/pi/CubeSatSim/rpitx.py b python3 -u /home/pi/CubeSatSim/rpitx.py b
elif [ $(($y % 4)) = 2 ]; then elif [ $(($y % 4)) = 2 ]; then
echo "Mode is continuous SSTV" echo "Mode is continuous SSTV"
python -u /home/pi/CubeSatSim/rpitx.py s python3 -u /home/pi/CubeSatSim/rpitx.py s
else else
echo "Mode is continuous FSK" echo "Mode is continuous FSK"
python -u /home/pi/CubeSatSim/rpitx.py f python3 -u /home/pi/CubeSatSim/rpitx.py f
fi fi
else else
python -u /home/pi/CubeSatSim/rpitx.py $1 python3 -u /home/pi/CubeSatSim/rpitx.py $1
fi fi

Loading…
Cancel
Save

Powered by TurnKey Linux.