diff --git a/groundstation/program_fm.py b/groundstation/program_fm.py new file mode 100644 index 00000000..c87b9bb1 --- /dev/null +++ b/groundstation/program_fm.py @@ -0,0 +1,39 @@ +import serial +from os import system + +if __name__ == "__main__": + txf = 434.9 + rxf = 435 + if (len(sys.argv)) > 1: + print("There are arguments!") + txf = float(sys.argv[1]) + if (len(sys.argv)) > 2: + rxf = loat(sys.argv[2]) + print("Programming FM module!\n") + tx = "{:.4f}".format(txf) + rx = "{:.4f}".format(rxf) + print(tx) + print(rx) + output(pd, 1) + output (ptt, 1) + + system("gpio -g mode 20 out") + system("gpio -g write 20 1") + system("gpio -g mode 21 out # set PD high") + system("gpio -g write 21 1") + + try: + ser = serial.Serial("/dev/ttyAMA0", 9600) + print(ser.portstr) + uhf_string = "AT+DMOSETGROUP=0," + rx +"," + tx + ",0,3,0,0\r\n" + # uhf_string = "AT+DMOSETGROUP=0," + rx + "," + tx + "," + rxpl_value + "," + sq + "," + txpl_value + ",0\r\n" + print(uhf_string) + for i in range(6): + # ser.write(b"AT+DMOSETGROUP=0,435.0000,434.9000,0,3,0,0\r\n") + ser.write(uhf_string.encode()) + sleep(0.1) + ser.close() + ser = serial.Serial("/dev/ttyAMA0", 115200) # reset back to 115200 for cubesatsim code for payload sensor data + except: + print("Error in serial write") + system("gpio -g write 21 0")