From 5b486ac43399d62418f5342507bde459bd5f5a0e Mon Sep 17 00:00:00 2001 From: Michael Clemens Date: Wed, 6 Oct 2021 13:01:42 +0100 Subject: [PATCH] -t now needs no parameter new parameter -k lets user change keying method --- hr50ctl.py | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/hr50ctl.py b/hr50ctl.py index dedfee8..3c4ac87 100755 --- a/hr50ctl.py +++ b/hr50ctl.py @@ -39,6 +39,7 @@ vlcd = { def send_command(cmd, param): ser = serial.Serial(serial_port, baud, timeout=1) command = cmd + param + ';' + #print(command) ser.write(str.encode(command)) ser.close() @@ -64,25 +65,48 @@ def get_info(): vlcd['SWR'] = res[3][1:2] + "." + res[3][2:3] ser.close() +keying_methods = { + "off" : "0", + "ptt" : "1", + "cor" : "2", + "qrp" : "3" + } def main(argv): try: - opts, args = getopt.getopt(argv,"hb:t",["band=","tune="]) + opts, args = getopt.getopt(argv,"hb:tk:") except getopt.GetoptError: - print("hr50ctl.py -b -t <1|0>") + print("Error :(") + print("Please consult help via ./hr50ctl.py -h") sys.exit(2) for opt, arg in opts: if opt == '-h': - print("hr50ctl.py -b -t <1|0>") + print("\nUSAGE: # ./hr50ctl.py -b -t -k ") + print("\nPARAMETERS:") + print(" -k: the following keying methods are available:") + print(" off, cor, ptt, qrp") + print(" This parameter changes the method how the HR50 will be put into TX mode.") + print(" -b: the following bands are available:") + print(" 6, 10, 12, 15, 20, 17, 20, 30, 40, 60, 80, 160") + print(" This parameter changes the band of the HR50") + print(" -t: no parameter required.") + print(" This parameters initiates the tuning during the next PTT") + print("\nEXAMPLES:") + print(" Change the band to 12m: # ./hr50ctl.py -b 12") + print(" Change the keying method to PTT: # ./hr50ctl.py -k ptt") + print(" Change the band to 6m and tune: # ./hr50ctl.py -b 6 -t ") sys.exit() - elif opt in ("-b", "--band"): + elif opt == "-b": if arg in bands: # change the band send_command("HRBN",bands[arg]) - elif opt in ("-t", "--tune"): - if arg == "1": + elif opt == "-t": + # let the HR50 know that it should return + send_command("HRTU","1") + elif opt == "-k": + if arg in keying_methods: # let the HR50 know that it should retunr - send_command("HRTU1","") + send_command("HRMD",keying_methods[arg]) # query all desired info from the HR50 get_info() @@ -90,8 +114,10 @@ def main(argv): # print info to stdout table = PrettyTable(['1', '2', '3', '4']) table.add_row([ + #"STA: " + str_color(vlcd["STA"],"green"), "STA: " + vlcd["STA"], "PTT: " + vlcd["PTT"], + #"BND: " + str_color(vlcd["BND"],"yellow"), "BND: " + vlcd["BND"], "VLT: " + vlcd["VLT"]]) table.add_row([