diff --git a/rpitx.py b/rpitx.py index dc039370..c1e3ee06 100644 --- a/rpitx.py +++ b/rpitx.py @@ -372,7 +372,6 @@ if __name__ == "__main__": print("Programming FM module!\n"); output(pd, 1) output (ptt, 1) - try: ser = serial.Serial("/dev/ttyAMA0", 9600) print(ser.portstr) @@ -385,12 +384,13 @@ if __name__ == "__main__": except: print("Error in serial write") ser.close() - output(pd, 0) sleep(10) # delay so cubesatsim code catches up - 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") + 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") + + command_control_check() # if (mode != 'a') and (command_tx == True): if (command_tx == True): @@ -426,14 +426,9 @@ if __name__ == "__main__": # if (len(sys.argv)) > 1: # print("There are arguments!") if (mode == 'a'): + command_control_check() # output(pd, 1) print("AFSK") -# sleep(5) -## try: -## file = open("/home/pi/CubeSatSim/t.txt") -## file.close() -## except: -## system("echo '" + callsign + "-11>APCSS:hi hi 100 199 199 199 298 299 299 278 380 350 300 300 439 400 400 400 500 500 500 500 600 600 600 650' > /home/pi/CubeSatSim/t.txt && echo 'AMSAT>APCSS:010101/hi hi ' >> /home/pi/CubeSatSim/t.txt") while True: try: f = open("/home/pi/CubeSatSim/ready") @@ -480,72 +475,23 @@ if __name__ == "__main__": sleep(1) elif (mode == 'm'): print("CW") -# sleep(4) -# try: -# file = open("/home/pi/CubeSatSim/cw.txt") -# file.close() -# except: -# system("echo 'hi hi 100 199 199 199 298 299 299 278 380 350 300 300 439 400 400 400 500 500 500 500 600 600 600 650' > /home/pi/CubeSatSim/cw.txt") -# output(pd, 1) -# -# if (command_tx == True): -# output(txLed, txLedOn) -# battery_saver_check() -# -# if (txc): -# output (pd, 1) -# output (ptt, 0) -# sleep(0.1) -# -# system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw.txt -r 48000 > /dev/null 2>&1 && aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/morse.wav") -# sleep(0.1) -# output (ptt, 1) -# output (pd, 0) -# else: -# if (debug_mode == 1): -# system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw.txt -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 " + tx + "e3") -# else: -# system("gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw.txt -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 " + tx + "e3 > /dev/null 2>&1") -# -# output(txLed, txLedOff) -# output (ptt, 1) -# sleep(5) while True: command_control_check() -# print("don't command control check 0") try: f = open("/home/pi/CubeSatSim/cwready") f.close() system("sudo rm /home/pi/CubeSatSim/cwready") - print("after rm") ch = 1 - print("after ch") -# print(channel) for chan in range(7): -# print(channel) - print(chan) - print("after for chan") - print("done for") - for chan in range(7): - print("for loop") - command = "gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw" + str(ch) + ".txt -r 48000 > /dev/null 2>&1" - print("after command assignment") + command = "gen_packets -M 20 -o /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/cw" + str(chan) + ".txt -r 48000 > /dev/null 2>&1" system(command) - print("for loop1") - ch = ch + 1 - print("for loop2") - -# print("Sending cw1.txt") -# system("cat /home/pi/CubeSatSim/cw1.txt") - + chan = chan + 1 if (command_tx == True): - print("for loop3") output(txLed, txLedOn) output (pd, 1) sleep(0.1) output (ptt, 0) - # battery_saver_check() if (txc): system("aplay -D hw:CARD=Headphones,DEV=0 /home/pi/CubeSatSim/morse.wav") @@ -558,23 +504,15 @@ if __name__ == "__main__": sleep(0.1) output(txLed, txLedOff) output (ptt, 1) - print("for loop4") - print("for loop5") - print(chan) command_control_check() -# print("dont command control check") - print("for loop6") - print(chan) - print("done 2nd for") f.close() -# system("sudo rm /home/pi/CubeSatSim/cwready") sleep(5) except: command_control_check() -# print("dont command control check 1") sleep(1) elif (mode == 's'): print("SSTV") + command_control_check() try: # from picamera import PiCamera # from pysstv.sstv import SSTV @@ -600,6 +538,7 @@ if __name__ == "__main__": file = open("/home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg") 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") + command_control_check() if (command_tx == True): print ("Sending SSTV image") @@ -756,7 +695,7 @@ if __name__ == "__main__": 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 " + tx + "e3 &") while 1: if (command_tx == True): - + command_control_check() output(txLed, txLedOn) # battery_saver_check() @@ -773,7 +712,9 @@ if __name__ == "__main__": # output (ptt, 1) # output(pd, 0) sleep(1) + elif (mode == 'b'): + command_control_check() print("BPSK") print("turn on FM rx") output(pd, 1)