Skip to content

Instantly share code, notes, and snippets.

@Ellsworth
Created June 14, 2017 16:58
Show Gist options
  • Save Ellsworth/b857cace72836acb03078756330b9a15 to your computer and use it in GitHub Desktop.
Save Ellsworth/b857cace72836acb03078756330b9a15 to your computer and use it in GitHub Desktop.
print("FT450cqRPT by Erich KG5KEY...\n")
from time import sleep
import serial
import configparser
config = configparser.ConfigParser()
config.read('config.ini')
ser = serial.Serial()
ser.baudrate = config['FT450cqRPT']['baudrate']
ser.port = config['FT450cqRPT']['port']
#LM01 to reccord!
#PB7 to send!
def closeSerial():
print("\nClosing the " + ser.port + " serial port at " +
str(ser.baudrate) + " baud.")
ser.close()
if ser.is_open == False:
print("Serial closed successfully!")
exit()
def openSerial():
print("Opening the " + ser.port + " serial port at " +
str(ser.baudrate) + " baud.")
try:
ser.open()
except IOError:
print("\nUnable to connect to serial port!\n" +
"Perhaps the port is incorrect or already in use!")
closeSerial()
if ser.is_open:
print("Serial opened successfully!\n")
def transmitReccording():
ser.write(b'PB7;')
print("Playing back reccording!")
openSerial()
x = input("Press enter to start the loop.")
while True:
while True:
try:
transmitReccording()
print("Press Ctrl+C to cancel the loop.")
sleep(30)
except KeyboardInterrupt:
print("Stopping the loop.\n")
x = input("Press enter to start the loop.")
closeSerial()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment