-
Notifications
You must be signed in to change notification settings - Fork 0
/
ytuner.py
66 lines (53 loc) · 2.58 KB
/
ytuner.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Tuning helper for the yaesu ft-dx10 - by DB8TS, 2022-12
# this script sets mode to cw-l, power to 5W, disables the
# internal tuner and keys the transmitter for a given period
# of time. After transmitting previous mode and power settings
# are restored.
import serial # (python -m pip install pyserial)
import keyboard # (python -m pip install keyboard)
import time
import sys
if (len(sys.argv)>1):
timer = int(sys.argv[1])
if (timer>=0) and (timer<=30):
with serial.Serial() as ser:
ser.baudrate = 38400 # baudrate, depends on your setup
ser.port = "COM4" # port, depends on your setup
ser.open()
ser.write(b"MD0;") # get current mode
mode_op = ser.read_until(b";")
ser.write(b"PC;") # get current power setting
power_op = ser.read_until(b";")
ser.write(b"AC000;") # disable internal tuner
ser.write(b"PC005;") # set power to 5W
ser.write(b"MD03;") # set mode to cw-l
ser.write(b"TX1;") # switch to tx
if timer == 0:
print ("\nTuning, press ESC to stop!\n")
while True:
if keyboard.is_pressed("esc"):
break
else:
time.sleep(timer)
ser.write(b"RM6;") # read swr
buffer = ser.read_until(b";")
swr = (buffer[3:6])
swr = int(swr.decode("utf-8"))
ser.write(b"TX0;") #switch to rx
time.sleep(0.1)
ser.write(mode_op) #set mode to previous mode
time.sleep(0.1)
ser.write(power_op) #set power to previous power
ser.close()
if (swr == 0): print ("SWR = 1")
elif (swr <= 64): print ("SWR <= 1.5")
elif (swr <= 96): print ("SWR <= 2")
elif (swr <= 128): print ("SWR <= 3")
elif (swr > 128): print ("SWR > 3 !!")
else:
print ("\n\n")
print ("Tuning helper for the yaesu ft-dx10 - by DB8TS, 2022-12")
print ("Syntax: " + sys.argv[0] + " + Time in seconds (between 0 and 30, 0 = tuning until ESC is pressed)")
else:
print ("tuning helper for the yaesu ft-dx10 - by DB8TS, 2022-12")
print ("Syntax: " + sys.argv[0] + " + Time in seconds (between 0 and 30, 0 = tuning until ESC is pressed)")