mirror of
https://codeberg.org/mclemens/hr50ctl.git
synced 2024-06-16 09:15:30 +00:00
-t now needs no parameter
new parameter -k lets user change keying method
This commit is contained in:
parent
078219d925
commit
5b486ac433
40
hr50ctl.py
40
hr50ctl.py
|
@ -39,6 +39,7 @@ vlcd = {
|
||||||
def send_command(cmd, param):
|
def send_command(cmd, param):
|
||||||
ser = serial.Serial(serial_port, baud, timeout=1)
|
ser = serial.Serial(serial_port, baud, timeout=1)
|
||||||
command = cmd + param + ';'
|
command = cmd + param + ';'
|
||||||
|
#print(command)
|
||||||
ser.write(str.encode(command))
|
ser.write(str.encode(command))
|
||||||
ser.close()
|
ser.close()
|
||||||
|
|
||||||
|
@ -64,25 +65,48 @@ def get_info():
|
||||||
vlcd['SWR'] = res[3][1:2] + "." + res[3][2:3]
|
vlcd['SWR'] = res[3][1:2] + "." + res[3][2:3]
|
||||||
ser.close()
|
ser.close()
|
||||||
|
|
||||||
|
keying_methods = {
|
||||||
|
"off" : "0",
|
||||||
|
"ptt" : "1",
|
||||||
|
"cor" : "2",
|
||||||
|
"qrp" : "3"
|
||||||
|
}
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(argv,"hb:t",["band=","tune="])
|
opts, args = getopt.getopt(argv,"hb:tk:")
|
||||||
except getopt.GetoptError:
|
except getopt.GetoptError:
|
||||||
print("hr50ctl.py -b <band> -t <1|0>")
|
print("Error :(")
|
||||||
|
print("Please consult help via ./hr50ctl.py -h")
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
for opt, arg in opts:
|
for opt, arg in opts:
|
||||||
if opt == '-h':
|
if opt == '-h':
|
||||||
print("hr50ctl.py -b <band> -t <1|0>")
|
print("\nUSAGE: # ./hr50ctl.py -b <band> -t -k <keying mode>")
|
||||||
|
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()
|
sys.exit()
|
||||||
elif opt in ("-b", "--band"):
|
elif opt == "-b":
|
||||||
if arg in bands:
|
if arg in bands:
|
||||||
# change the band
|
# change the band
|
||||||
send_command("HRBN",bands[arg])
|
send_command("HRBN",bands[arg])
|
||||||
elif opt in ("-t", "--tune"):
|
elif opt == "-t":
|
||||||
if arg == "1":
|
# 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
|
# let the HR50 know that it should retunr
|
||||||
send_command("HRTU1","")
|
send_command("HRMD",keying_methods[arg])
|
||||||
|
|
||||||
# query all desired info from the HR50
|
# query all desired info from the HR50
|
||||||
get_info()
|
get_info()
|
||||||
|
@ -90,8 +114,10 @@ def main(argv):
|
||||||
# print info to stdout
|
# print info to stdout
|
||||||
table = PrettyTable(['1', '2', '3', '4'])
|
table = PrettyTable(['1', '2', '3', '4'])
|
||||||
table.add_row([
|
table.add_row([
|
||||||
|
#"STA: " + str_color(vlcd["STA"],"green"),
|
||||||
"STA: " + vlcd["STA"],
|
"STA: " + vlcd["STA"],
|
||||||
"PTT: " + vlcd["PTT"],
|
"PTT: " + vlcd["PTT"],
|
||||||
|
#"BND: " + str_color(vlcd["BND"],"yellow"),
|
||||||
"BND: " + vlcd["BND"],
|
"BND: " + vlcd["BND"],
|
||||||
"VLT: " + vlcd["VLT"]])
|
"VLT: " + vlcd["VLT"]])
|
||||||
table.add_row([
|
table.add_row([
|
||||||
|
|
Loading…
Reference in New Issue
Block a user