|
|
@ -18,39 +18,44 @@ def monitor():
|
|
|
|
if tc < 15: #15 seconds
|
|
|
|
if tc < 15: #15 seconds
|
|
|
|
time.sleep(6)
|
|
|
|
time.sleep(6)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
writehtml(f"Radio off")
|
|
|
|
writehtml(f"Radio Off or Log4OM Not Running", False)
|
|
|
|
time.sleep(30)
|
|
|
|
time.sleep(30) # Slow checks when radio off/no UDP
|
|
|
|
|
|
|
|
|
|
|
|
def log4om():
|
|
|
|
def log4om():
|
|
|
|
global tot
|
|
|
|
global tot
|
|
|
|
global rstatus
|
|
|
|
|
|
|
|
while True:
|
|
|
|
while True:
|
|
|
|
data, addr = sock.recvfrom(1024)
|
|
|
|
data, addr = sock.recvfrom(1024)
|
|
|
|
root = ET.fromstring(data.decode("utf-8"))
|
|
|
|
root = ET.fromstring(data.decode("utf-8"))
|
|
|
|
freq = int(root.find("Freq").text)
|
|
|
|
freq = int(root.find("Freq").text)
|
|
|
|
tx_freq = int(root.find("TXFreq").text)
|
|
|
|
tx_freq = int(root.find("TXFreq").text)
|
|
|
|
mode = root.find("Mode").text
|
|
|
|
mode = root.find("Mode").text
|
|
|
|
|
|
|
|
onair = (root.find("IsTransmitting").text == "true")
|
|
|
|
f = freq / 100
|
|
|
|
f = freq / 100
|
|
|
|
tf = tx_freq / 100
|
|
|
|
tf = tx_freq / 100
|
|
|
|
sv = tf - f # Determines split value
|
|
|
|
sv = tf - f # Determines split value
|
|
|
|
if sv > 0:
|
|
|
|
if sv > 0:
|
|
|
|
writehtml(f"Frequency: {f}kHz {mode}<br>Up: {sv:.2f} kHz")
|
|
|
|
writehtml(f"Frequency: {f}kHz {mode}<br>Tx Split Up: {sv:.2f} kHz", onair)
|
|
|
|
elif sv < 0:
|
|
|
|
elif sv < 0:
|
|
|
|
sv = sv * -1 # Invert negative numbers
|
|
|
|
sv = sv * -1 # Invert negative numbers
|
|
|
|
writehtml(f"Frequency: {f}kHz {mode}<br>Down: {sv:.2f} kHz")
|
|
|
|
writehtml(f"Frequency: {f}kHz {mode}<br>Tx Split Down: {sv:.2f} kHz", onair)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
writehtml(f"Frequency: {f}kHz {mode}")
|
|
|
|
writehtml(f"Frequency: {f}kHz {mode}", onair)
|
|
|
|
tot = time.time() #timestamp
|
|
|
|
tot = time.time() #timestamp
|
|
|
|
time.sleep(.1)
|
|
|
|
time.sleep(.1)
|
|
|
|
|
|
|
|
|
|
|
|
def writehtml(rs):
|
|
|
|
def writehtml(rs, t = "true"):
|
|
|
|
header = "<html>\n<head>\n<title>FT-1000MP Status</title>\n<meta http-equiv=\"refresh\" content=\"5\">\n</head>\n<body>\n"
|
|
|
|
header = "<html>\n<head>\n<title>FT-1000MP Status</title>\n<meta http-equiv=\"refresh\" content=\"5\">\n</head>\n<body>\n"
|
|
|
|
with open("/var/www/log/radio.html", "w") as html: # Modify file location as needed.
|
|
|
|
footer = "\n</body>\n</html>"
|
|
|
|
html.write(header + rs + "\n</body>\n</html>")
|
|
|
|
isonair = "ON THE AIR<br>\n"
|
|
|
|
|
|
|
|
with open("/var/www/log/radio.html", "w") as html: # Modifiy file location as needed.
|
|
|
|
T = Thread(target=monitor,daemon=True)
|
|
|
|
if t == True: # Checks for on-air
|
|
|
|
|
|
|
|
html.write(header + isonair + rs + footer)
|
|
|
|
|
|
|
|
if t == False: # Checks for on-air
|
|
|
|
|
|
|
|
html.write(header + rs + footer)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
T = Thread(target=monitor,daemon=True) # Daemon the monitor thread
|
|
|
|
L = Thread(target=log4om)
|
|
|
|
L = Thread(target=log4om)
|
|
|
|
|
|
|
|
|
|
|
|
L.start() # Start the UDP thread
|
|
|
|
L.start() # Start the UDP thread
|
|
|
|
time.sleep(5) # Wait 5 seconds in case Log4OM is already running.
|
|
|
|
time.sleep(5) # Wait 5 seconds in case Log4OM is already running and outputting messages
|
|
|
|
T.start() # Start monitor
|
|
|
|
T.start() # Start monitor thread
|
|
|
|