mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
adjusted daemon for starting rigctld
This commit is contained in:
parent
53dd156a3d
commit
c36933d622
5 changed files with 38 additions and 11 deletions
|
@ -11,6 +11,9 @@ setActivePinia(pinia);
|
||||||
import { useSettingsStore } from "../store/settingsStore.js";
|
import { useSettingsStore } from "../store/settingsStore.js";
|
||||||
const settings = useSettingsStore(pinia);
|
const settings = useSettingsStore(pinia);
|
||||||
|
|
||||||
|
import { useStateStore } from "../store/stateStore.js";
|
||||||
|
const state = useStateStore(pinia);
|
||||||
|
|
||||||
function selectRadioControl() {
|
function selectRadioControl() {
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
switch (event.target.id) {
|
switch (event.target.id) {
|
||||||
|
@ -177,6 +180,8 @@ alert("not yet implemented")
|
||||||
id="hamlib_rigctld_status"
|
id="hamlib_rigctld_status"
|
||||||
aria-label="State"
|
aria-label="State"
|
||||||
aria-describedby="basic-addon1"
|
aria-describedby="basic-addon1"
|
||||||
|
v-model="state.rigctld_started"
|
||||||
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
|
|
|
@ -148,6 +148,7 @@ daemon.on("data", function (socketdata) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(data)
|
||||||
if (data["command"] == "daemon_state") {
|
if (data["command"] == "daemon_state") {
|
||||||
let Data = {
|
let Data = {
|
||||||
input_devices: data["input_devices"],
|
input_devices: data["input_devices"],
|
||||||
|
@ -165,8 +166,16 @@ daemon.on("data", function (socketdata) {
|
||||||
audioStore.inputDevices = data["input_devices"];
|
audioStore.inputDevices = data["input_devices"];
|
||||||
audioStore.outputDevices = data["output_devices"];
|
audioStore.outputDevices = data["output_devices"];
|
||||||
state.tnc_running_state = data["daemon_state"][0]["status"];
|
state.tnc_running_state = data["daemon_state"][0]["status"];
|
||||||
|
|
||||||
|
state.rigctld_started = data["rigctld_state"][0]["status"];
|
||||||
|
//state.rigctld_process = data["daemon_state"][0]["rigctld_process"];
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (data["command"] == "test_hamlib") {
|
if (data["command"] == "test_hamlib") {
|
||||||
let Data = {
|
let Data = {
|
||||||
hamlib_result: data["result"],
|
hamlib_result: data["result"],
|
||||||
|
|
|
@ -53,6 +53,10 @@ export const useStateStore = defineStore("stateStore", () => {
|
||||||
var arq_seconds_until_timeout = ref();
|
var arq_seconds_until_timeout = ref();
|
||||||
var arq_seconds_until_timeout_percent = ref();
|
var arq_seconds_until_timeout_percent = ref();
|
||||||
|
|
||||||
|
var rigctld_started = ref();
|
||||||
|
var rigctld_process = ref();
|
||||||
|
|
||||||
|
|
||||||
function updateTncState(state) {
|
function updateTncState(state) {
|
||||||
tnc_connection.value = state;
|
tnc_connection.value = state;
|
||||||
|
|
||||||
|
@ -145,6 +149,8 @@ export const useStateStore = defineStore("stateStore", () => {
|
||||||
is_codec2_traffic,
|
is_codec2_traffic,
|
||||||
rf_level,
|
rf_level,
|
||||||
heard_stations,
|
heard_stations,
|
||||||
beacon_state
|
beacon_state,
|
||||||
|
rigctld_started,
|
||||||
|
rigctld_process
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
@ -252,17 +252,16 @@ class DAEMON:
|
||||||
elif sys.platform in ["win32", "win64"]:
|
elif sys.platform in ["win32", "win64"]:
|
||||||
command.append("rigctld.exe")
|
command.append("rigctld.exe")
|
||||||
|
|
||||||
options = ""
|
options = "--version"
|
||||||
command += options
|
command += options
|
||||||
proc = subprocess.Popen(command)
|
proc = subprocess.Popen(command)
|
||||||
atexit.register(proc.kill)
|
atexit.register(proc.kill)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
self.log.info("[DMN] starting rigctld: ", e=err)
|
self.log.info("[DMN] starting rigctld: ", e=err)
|
||||||
|
|
||||||
Daemon.rigctldrocess = proc
|
Daemon.rigctldprocess = proc
|
||||||
Daemon.rigctldstarted = True
|
Daemon.rigctldstarted = True
|
||||||
|
|
||||||
|
|
||||||
def start_tnc(self, data):
|
def start_tnc(self, data):
|
||||||
self.log.warning("[DMN] Starting TNC", rig=data[5], port=data[6])
|
self.log.warning("[DMN] Starting TNC", rig=data[5], port=data[6])
|
||||||
|
|
||||||
|
|
14
tnc/sock.py
14
tnc/sock.py
|
@ -956,7 +956,7 @@ class ThreadedTCPRequestHandler(socketserver.StreamRequestHandler):
|
||||||
if received_json["type"] == "set" and received_json["command"] == "stop_tnc":
|
if received_json["type"] == "set" and received_json["command"] == "stop_tnc":
|
||||||
self.daemon_stop_tnc(received_json)
|
self.daemon_stop_tnc(received_json)
|
||||||
|
|
||||||
if received_json["type"] == "set" and received_json["command"] == "start_rigctld":
|
if received_json["type"] == "set" and received_json["command"] == "start_rigctld" and not Daemon.rigctldstarted:
|
||||||
self.daemon_start_rigctld(received_json)
|
self.daemon_start_rigctld(received_json)
|
||||||
|
|
||||||
if received_json["type"] == "set" and received_json["command"] == "stop_rigctld":
|
if received_json["type"] == "set" and received_json["command"] == "stop_rigctld":
|
||||||
|
@ -1183,12 +1183,13 @@ class ThreadedTCPRequestHandler(socketserver.StreamRequestHandler):
|
||||||
try:
|
try:
|
||||||
log.warning("[SCK] Stopping rigctld")
|
log.warning("[SCK] Stopping rigctld")
|
||||||
|
|
||||||
|
if Daemon.rigctldstarted:
|
||||||
Daemon.rigctldprocess.kill()
|
Daemon.rigctldprocess.kill()
|
||||||
# unregister process from atexit to avoid process zombies
|
# unregister process from atexit to avoid process zombies
|
||||||
atexit.unregister(Daemon.rigctldprocess.kill)
|
atexit.unregister(Daemon.rigctldprocess.kill)
|
||||||
|
|
||||||
Daemon.rigctldstarted = False
|
Daemon.rigctldstarted = False
|
||||||
command_response("stop_tnc", True)
|
command_response("stop_rigctld", True)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
command_response("stop_tnc", False)
|
command_response("stop_tnc", False)
|
||||||
log.warning("[SCK] command execution error", e=err, command=received_json)
|
log.warning("[SCK] command execution error", e=err, command=received_json)
|
||||||
|
@ -1208,13 +1209,14 @@ def send_daemon_state():
|
||||||
output = {
|
output = {
|
||||||
"command": "daemon_state",
|
"command": "daemon_state",
|
||||||
"daemon_state": [],
|
"daemon_state": [],
|
||||||
|
"rigctld_state": [],
|
||||||
"python_version": str(python_version),
|
"python_version": str(python_version),
|
||||||
"input_devices": AudioParam.audio_input_devices,
|
"input_devices": AudioParam.audio_input_devices,
|
||||||
"output_devices": AudioParam.audio_output_devices,
|
"output_devices": AudioParam.audio_output_devices,
|
||||||
"serial_devices": Daemon.serial_devices,
|
"serial_devices": Daemon.serial_devices,
|
||||||
# 'cpu': str(psutil.cpu_percent()),
|
# 'cpu': str(psutil.cpu_percent()),
|
||||||
# 'ram': str(psutil.virtual_memory().percent),
|
# 'ram': str(psutil.virtual_memory().percent),
|
||||||
"version": "0.1",
|
"version": TNC.version,
|
||||||
}
|
}
|
||||||
|
|
||||||
if Daemon.tncstarted:
|
if Daemon.tncstarted:
|
||||||
|
@ -1222,6 +1224,11 @@ def send_daemon_state():
|
||||||
else:
|
else:
|
||||||
output["daemon_state"].append({"status": "stopped"})
|
output["daemon_state"].append({"status": "stopped"})
|
||||||
|
|
||||||
|
if Daemon.rigctldstarted:
|
||||||
|
output["rigctld_state"].append({"status": "running"})
|
||||||
|
else:
|
||||||
|
output["rigctld_state"].append({"status": "stopped"})
|
||||||
|
|
||||||
return json.dumps(output)
|
return json.dumps(output)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
log.warning("[SCK] error", e=err)
|
log.warning("[SCK] error", e=err)
|
||||||
|
@ -1277,6 +1284,7 @@ def send_tnc_state():
|
||||||
"hamlib_status": HamlibParam.hamlib_status,
|
"hamlib_status": HamlibParam.hamlib_status,
|
||||||
"listen": str(TNC.listen),
|
"listen": str(TNC.listen),
|
||||||
"audio_recording": str(AudioParam.audio_record),
|
"audio_recording": str(AudioParam.audio_record),
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# add heard stations to heard stations object
|
# add heard stations to heard stations object
|
||||||
|
|
Loading…
Reference in a new issue