From 3b4be831194921c34898511ca285b4a425a120aa Mon Sep 17 00:00:00 2001 From: Mashintime Date: Mon, 27 Mar 2023 17:06:11 -0400 Subject: [PATCH 1/5] Add option to autostart rigctld/tnc. Issue #385 --- gui/main.js | 5 ++++- gui/preload-main.js | 39 +++++++++++++++++++++++++++++++++++++++ gui/src/index.html | 23 ++++++++++++++++++++--- 3 files changed, 63 insertions(+), 4 deletions(-) diff --git a/gui/main.js b/gui/main.js index c5f9bfd7..21e6edce 100644 --- a/gui/main.js +++ b/gui/main.js @@ -95,7 +95,8 @@ const configDefaultSettings = "shared_folder_path" : ".", \ "enable_request_profile" : "True", \ "enable_request_shared_folder" : "False", \ - "tx_delay" : 0 \ + "tx_delay" : 0, \ + "auto_start": 0 \ }'; if (!fs.existsSync(configPath)) { @@ -950,6 +951,7 @@ ipcMain.on("request-check-rigctld", (event, data) => { rigctld_connection_state = true; Data["state"] = "connection possible - (" + data.ip + ":" + data.port + ")"; + Data["active"] = true; if (win !== null && win !== "" && typeof win != "undefined") { // try catch for being sure we have a clean app close try { @@ -963,6 +965,7 @@ ipcMain.on("request-check-rigctld", (event, data) => { rigctld_connection.on("error", function () { rigctld_connection_state = false; Data["state"] = "unknown/stopped - (" + data.ip + ":" + data.port + ")"; + Data["active"] = false; if (win !== null && win !== "" && typeof win != "undefined") { // try catch for being sure we have a clean app close try { diff --git a/gui/preload-main.js b/gui/preload-main.js index fbc99209..4c20ece2 100644 --- a/gui/preload-main.js +++ b/gui/preload-main.js @@ -336,6 +336,13 @@ window.addEventListener("DOMContentLoaded", () => { } else { document.getElementById("autoTuneSwitch").checked = false; } + + if (config.auto_start == 1) { + document.getElementById("AutoStartSwitch").checked = true; + } else { + document.getElementById("AutoStartSwitch").checked = false; + } + // theme selector changeGuiDesign(config.theme); @@ -1064,6 +1071,8 @@ window.addEventListener("DOMContentLoaded", () => { //fs.writeFileSync(configPath, JSON.stringify(config, null, 2)); FD.saveConfig(config, configPath); }); + + //Handle change of fancy graphics document.getElementById("GraphicsSwitch").addEventListener("click", () => { if (document.getElementById("GraphicsSwitch").checked == true) { config.high_graphics = "True"; @@ -1075,6 +1084,17 @@ window.addEventListener("DOMContentLoaded", () => { set_CPU_mode(); }); +//Handle change of Auto-start settings +document.getElementById("AutoStartSwitch").addEventListener("click", () => { + if (document.getElementById("AutoStartSwitch").checked == true) { + config.auto_start = "1"; + } else { + config.auto_start = "0"; + } + //fs.writeFileSync(configPath, JSON.stringify(config, null, 2)); + FD.saveConfig(config, configPath); +}); + // enable fsk Switch clicked document.getElementById("fskModeSwitch").addEventListener("click", () => { if (document.getElementById("fskModeSwitch").checked == true) { @@ -3164,6 +3184,7 @@ function set_setting_switch(setting_switch, enable_object, state) { enable_setting(setting_switch, enable_object); } +var rigctlActive = false; setInterval(checkRigctld, 500); function checkRigctld() { var rigctld_ip = document.getElementById("hamlib_rigctld_ip").value; @@ -3182,6 +3203,7 @@ function checkRigctld() { ipcRenderer.on("action-check-rigctld", (event, data) => { document.getElementById("hamlib_rigctld_status").value = data["state"]; + rigctlActive=data["active"]; }); ipcRenderer.on("action-set-app-version", (event, data) => { @@ -3421,4 +3443,21 @@ function changeGuiDesign(design) { //update path to css file document.getElementById("bootstrap_theme").href = escape(theme_path); + + function autostart() + { + //Auto start stuff if option is enabled + if (config.auto_start == 1) { + //Start rigctld if radiocontrol is in correct mode and is not active + if (config.radiocontrol == "rigctld" && rigctlActive == false){ + //console.log("Autostarting rigctld"); + document.getElementById("hamlib_rigctld_start").click(); + } + //Now start TNC + document.getElementById("startTNC").click(); + } + } + setTimeout(() => { + autostart() + }, 1250); } diff --git a/gui/src/index.html b/gui/src/index.html index a6650cad..54bf5478 100644 --- a/gui/src/index.html +++ b/gui/src/index.html @@ -1781,8 +1781,25 @@ +
+ + +
- +
- These options may - not work and are for experienced users only! + These options are experimental and may + not work as expected.
From 391019a1ce9159f19e0fee1d11feca7fe7cb3eb8 Mon Sep 17 00:00:00 2001 From: Mashintime Date: Mon, 27 Mar 2023 21:07:54 +0000 Subject: [PATCH 2/5] Prettified Code! --- gui/main.js | 2 +- gui/preload-main.js | 31 +++++++++++++++---------------- gui/src/index.html | 4 ++-- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/gui/main.js b/gui/main.js index 21e6edce..ab21fc1b 100644 --- a/gui/main.js +++ b/gui/main.js @@ -951,7 +951,7 @@ ipcMain.on("request-check-rigctld", (event, data) => { rigctld_connection_state = true; Data["state"] = "connection possible - (" + data.ip + ":" + data.port + ")"; - Data["active"] = true; + Data["active"] = true; if (win !== null && win !== "" && typeof win != "undefined") { // try catch for being sure we have a clean app close try { diff --git a/gui/preload-main.js b/gui/preload-main.js index 4c20ece2..9dfdfaeb 100644 --- a/gui/preload-main.js +++ b/gui/preload-main.js @@ -1084,16 +1084,16 @@ window.addEventListener("DOMContentLoaded", () => { set_CPU_mode(); }); -//Handle change of Auto-start settings -document.getElementById("AutoStartSwitch").addEventListener("click", () => { - if (document.getElementById("AutoStartSwitch").checked == true) { - config.auto_start = "1"; - } else { - config.auto_start = "0"; - } - //fs.writeFileSync(configPath, JSON.stringify(config, null, 2)); - FD.saveConfig(config, configPath); -}); + //Handle change of Auto-start settings + document.getElementById("AutoStartSwitch").addEventListener("click", () => { + if (document.getElementById("AutoStartSwitch").checked == true) { + config.auto_start = "1"; + } else { + config.auto_start = "0"; + } + //fs.writeFileSync(configPath, JSON.stringify(config, null, 2)); + FD.saveConfig(config, configPath); + }); // enable fsk Switch clicked document.getElementById("fskModeSwitch").addEventListener("click", () => { @@ -3203,7 +3203,7 @@ function checkRigctld() { ipcRenderer.on("action-check-rigctld", (event, data) => { document.getElementById("hamlib_rigctld_status").value = data["state"]; - rigctlActive=data["active"]; + rigctlActive = data["active"]; }); ipcRenderer.on("action-set-app-version", (event, data) => { @@ -3443,13 +3443,12 @@ function changeGuiDesign(design) { //update path to css file document.getElementById("bootstrap_theme").href = escape(theme_path); - - function autostart() - { + + function autostart() { //Auto start stuff if option is enabled if (config.auto_start == 1) { //Start rigctld if radiocontrol is in correct mode and is not active - if (config.radiocontrol == "rigctld" && rigctlActive == false){ + if (config.radiocontrol == "rigctld" && rigctlActive == false) { //console.log("Autostarting rigctld"); document.getElementById("hamlib_rigctld_start").click(); } @@ -3458,6 +3457,6 @@ function changeGuiDesign(design) { } } setTimeout(() => { - autostart() + autostart(); }, 1250); } diff --git a/gui/src/index.html b/gui/src/index.html index 54bf5478..6cf2ac4f 100644 --- a/gui/src/index.html +++ b/gui/src/index.html @@ -2622,8 +2622,8 @@
- These options are experimental and may - not work as expected. + These options are + experimental and may not work as expected.
From 521bcce2c959617390f5e8594d83ced79e57e4a0 Mon Sep 17 00:00:00 2001 From: Mashintime Date: Mon, 27 Mar 2023 20:18:18 -0400 Subject: [PATCH 3/5] Add tooltip to rigctld copy button --- gui/src/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/gui/src/index.html b/gui/src/index.html index 6cf2ac4f..807170b7 100644 --- a/gui/src/index.html +++ b/gui/src/index.html @@ -1890,6 +1890,7 @@ class="btn btn-outline-secondary" type="button" id="btnHamlibCopyCommand" + title="Copy exe and arguments to clipboard to run in terminal for troubleshooting" > From 3193ad1e856417c5ffe309aed436cf0b8cbb26ae Mon Sep 17 00:00:00 2001 From: Mashintime Date: Tue, 28 Mar 2023 19:27:48 -0400 Subject: [PATCH 4/5] Rename rigctlActive, ensure serial devices are always populated. Handle spaces in copy to clipboard for easier copy/paste into terminal. --- gui/preload-main.js | 132 +++++++++++++++++++++++++------------------- 1 file changed, 75 insertions(+), 57 deletions(-) diff --git a/gui/preload-main.js b/gui/preload-main.js index 9dfdfaeb..b261771e 100644 --- a/gui/preload-main.js +++ b/gui/preload-main.js @@ -584,7 +584,24 @@ window.addEventListener("DOMContentLoaded", () => { .addEventListener("click", () => { hamlib_params(); let rigctld = document.getElementById("hamlib_rigctld_path").value; - rigctld += " " + document.getElementById("hamlib_rigctld_command").value; + + //Escape spaces in executable file + switch (os.platform().toLowerCase()) { + case "darwin": + case "linux": + rigctld = rigctld.replace(" ","\\ "); + break; + case "win32": + case "win64": + if (rigctld.indexOf(" ") > -1) + rigctld = "\"" + rigctld + "\""; + break; + default: + console.log("Unhandled OS Platform: ", os.platform()); + break; + } + + rigctld += " " + document.getElementById("hamlib_rigctld_command").value + " -vv"; document.getElementById("btnHamlibCopyCommandBi").classList = "bi bi-clipboard2-check-fill"; clipboard.writeText(rigctld); @@ -2306,6 +2323,7 @@ function updateHeardStations(arg) { } } +var populateSerial = false; ipcRenderer.on("action-update-daemon-state", (event, arg) => { /* // deactivetd RAM und CPU view so we dont get errors. We need to find a new place for this feature @@ -2341,9 +2359,58 @@ ipcRenderer.on("action-update-daemon-state", (event, arg) => { document.getElementById("node_version").innerHTML = "Node " + process.version document.getElementById("node_version").className = "btn btn-sm btn-success"; */ + + if (arg.tnc_running_state != "stopped" && populateSerial == true) return; +// UPDATE SERIAL DEVICES + if ( + document.getElementById("hamlib_deviceport").length != + arg.serial_devices.length + ) { + document.getElementById("hamlib_deviceport").innerHTML = ""; + var ignore = document.createElement("option"); + ignore.text = "-- ignore --"; + ignore.value = "ignore"; + document.getElementById("hamlib_deviceport").add(ignore); + for (i = 0; i < arg.serial_devices.length; i++) { + var option = document.createElement("option"); + option.text = + arg.serial_devices[i]["port"] + + " -- " + + arg.serial_devices[i]["description"]; + option.value = arg.serial_devices[i]["port"]; + document.getElementById("hamlib_deviceport").add(option); + } + // set device from config if available + document.getElementById("hamlib_deviceport").value = + config.hamlib_deviceport; + } + if ( + document.getElementById("hamlib_ptt_port").length != + arg.serial_devices.length + ) { + document.getElementById("hamlib_ptt_port").innerHTML = ""; + var ignore = document.createElement("option"); + ignore.text = "-- ignore --"; + ignore.value = "ignore"; + document.getElementById("hamlib_ptt_port").add(ignore); + for (i = 0; i < arg.serial_devices.length; i++) { + var option = document.createElement("option"); + option.text = + arg.serial_devices[i]["port"] + + " -- " + + arg.serial_devices[i]["description"]; + option.value = arg.serial_devices[i]["port"]; + document.getElementById("hamlib_ptt_port").add(option); + } + // set device from config if available + document.getElementById("hamlib_ptt_port").value = config.hamlib_ptt_port; + } + //Serial devices are updated on first pass + populateSerial = true; + if (arg.tnc_running_state != "stopped") return; + // UPDATE AUDIO INPUT - if (arg.tnc_running_state == "stopped") { if ( document.getElementById("audio_input_selectbox").length != arg.input_devices.length @@ -2361,9 +2428,8 @@ ipcRenderer.on("action-update-daemon-state", (event, arg) => { document.getElementById("audio_input_selectbox").add(option); } } - } + // UPDATE AUDIO OUTPUT - if (arg.tnc_running_state == "stopped") { if ( document.getElementById("audio_output_selectbox").length != arg.output_devices.length @@ -2380,57 +2446,9 @@ ipcRenderer.on("action-update-daemon-state", (event, arg) => { document.getElementById("audio_output_selectbox").add(option); } } - } - // UPDATE SERIAL DEVICES - if (arg.tnc_running_state == "stopped") { - if ( - document.getElementById("hamlib_deviceport").length != - arg.serial_devices.length - ) { - document.getElementById("hamlib_deviceport").innerHTML = ""; - var ignore = document.createElement("option"); - ignore.text = "-- ignore --"; - ignore.value = "ignore"; - document.getElementById("hamlib_deviceport").add(ignore); - for (i = 0; i < arg.serial_devices.length; i++) { - var option = document.createElement("option"); - option.text = - arg.serial_devices[i]["port"] + - " -- " + - arg.serial_devices[i]["description"]; - option.value = arg.serial_devices[i]["port"]; - document.getElementById("hamlib_deviceport").add(option); - } - // set device from config if available - document.getElementById("hamlib_deviceport").value = - config.hamlib_deviceport; - } - } - - if (arg.tnc_running_state == "stopped") { - if ( - document.getElementById("hamlib_ptt_port").length != - arg.serial_devices.length - ) { - document.getElementById("hamlib_ptt_port").innerHTML = ""; - var ignore = document.createElement("option"); - ignore.text = "-- ignore --"; - ignore.value = "ignore"; - document.getElementById("hamlib_ptt_port").add(ignore); - for (i = 0; i < arg.serial_devices.length; i++) { - var option = document.createElement("option"); - option.text = - arg.serial_devices[i]["port"] + - " -- " + - arg.serial_devices[i]["description"]; - option.value = arg.serial_devices[i]["port"]; - document.getElementById("hamlib_ptt_port").add(option); - } - // set device from config if available - document.getElementById("hamlib_ptt_port").value = config.hamlib_ptt_port; - } - } + + }); // ACTION UPDATE HAMLIB TEST @@ -3184,7 +3202,7 @@ function set_setting_switch(setting_switch, enable_object, state) { enable_setting(setting_switch, enable_object); } -var rigctlActive = false; +var rigctldActive = false; setInterval(checkRigctld, 500); function checkRigctld() { var rigctld_ip = document.getElementById("hamlib_rigctld_ip").value; @@ -3203,7 +3221,7 @@ function checkRigctld() { ipcRenderer.on("action-check-rigctld", (event, data) => { document.getElementById("hamlib_rigctld_status").value = data["state"]; - rigctlActive = data["active"]; + rigctldActive = data["active"]; }); ipcRenderer.on("action-set-app-version", (event, data) => { @@ -3448,7 +3466,7 @@ function changeGuiDesign(design) { //Auto start stuff if option is enabled if (config.auto_start == 1) { //Start rigctld if radiocontrol is in correct mode and is not active - if (config.radiocontrol == "rigctld" && rigctlActive == false) { + if (config.radiocontrol == "rigctld" && rigctldActive == false) { //console.log("Autostarting rigctld"); document.getElementById("hamlib_rigctld_start").click(); } From 273d4589a513872c0caf936f1fc760f3f164d8e4 Mon Sep 17 00:00:00 2001 From: Mashintime Date: Tue, 28 Mar 2023 23:29:51 +0000 Subject: [PATCH 5/5] Prettified Code! --- gui/preload-main.js | 77 ++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 40 deletions(-) diff --git a/gui/preload-main.js b/gui/preload-main.js index b261771e..f8410fbb 100644 --- a/gui/preload-main.js +++ b/gui/preload-main.js @@ -589,19 +589,19 @@ window.addEventListener("DOMContentLoaded", () => { switch (os.platform().toLowerCase()) { case "darwin": case "linux": - rigctld = rigctld.replace(" ","\\ "); + rigctld = rigctld.replace(" ", "\\ "); break; case "win32": case "win64": - if (rigctld.indexOf(" ") > -1) - rigctld = "\"" + rigctld + "\""; + if (rigctld.indexOf(" ") > -1) rigctld = '"' + rigctld + '"'; break; default: console.log("Unhandled OS Platform: ", os.platform()); break; } - rigctld += " " + document.getElementById("hamlib_rigctld_command").value + " -vv"; + rigctld += + " " + document.getElementById("hamlib_rigctld_command").value + " -vv"; document.getElementById("btnHamlibCopyCommandBi").classList = "bi bi-clipboard2-check-fill"; clipboard.writeText(rigctld); @@ -2359,9 +2359,9 @@ ipcRenderer.on("action-update-daemon-state", (event, arg) => { document.getElementById("node_version").innerHTML = "Node " + process.version document.getElementById("node_version").className = "btn btn-sm btn-success"; */ - - if (arg.tnc_running_state != "stopped" && populateSerial == true) return; -// UPDATE SERIAL DEVICES + + if (arg.tnc_running_state != "stopped" && populateSerial == true) return; + // UPDATE SERIAL DEVICES if ( document.getElementById("hamlib_deviceport").length != arg.serial_devices.length @@ -2409,46 +2409,43 @@ ipcRenderer.on("action-update-daemon-state", (event, arg) => { //Serial devices are updated on first pass populateSerial = true; if (arg.tnc_running_state != "stopped") return; - + // UPDATE AUDIO INPUT - if ( - document.getElementById("audio_input_selectbox").length != - arg.input_devices.length - ) { - document.getElementById("audio_input_selectbox").innerHTML = ""; - for (i = 0; i < arg.input_devices.length; i++) { - var option = document.createElement("option"); - option.text = arg.input_devices[i]["name"]; - option.value = arg.input_devices[i]["id"]; - // set device from config if available + if ( + document.getElementById("audio_input_selectbox").length != + arg.input_devices.length + ) { + document.getElementById("audio_input_selectbox").innerHTML = ""; + for (i = 0; i < arg.input_devices.length; i++) { + var option = document.createElement("option"); + option.text = arg.input_devices[i]["name"]; + option.value = arg.input_devices[i]["id"]; + // set device from config if available - if (config.rx_audio == option.text) { - option.setAttribute("selected", true); - } - document.getElementById("audio_input_selectbox").add(option); + if (config.rx_audio == option.text) { + option.setAttribute("selected", true); } + document.getElementById("audio_input_selectbox").add(option); } - + } + // UPDATE AUDIO OUTPUT - if ( - document.getElementById("audio_output_selectbox").length != - arg.output_devices.length - ) { - document.getElementById("audio_output_selectbox").innerHTML = ""; - for (i = 0; i < arg.output_devices.length; i++) { - var option = document.createElement("option"); - option.text = arg.output_devices[i]["name"]; - option.value = arg.output_devices[i]["id"]; - // set device from config if available - if (config.tx_audio == option.text) { - option.setAttribute("selected", true); - } - document.getElementById("audio_output_selectbox").add(option); + if ( + document.getElementById("audio_output_selectbox").length != + arg.output_devices.length + ) { + document.getElementById("audio_output_selectbox").innerHTML = ""; + for (i = 0; i < arg.output_devices.length; i++) { + var option = document.createElement("option"); + option.text = arg.output_devices[i]["name"]; + option.value = arg.output_devices[i]["id"]; + // set device from config if available + if (config.tx_audio == option.text) { + option.setAttribute("selected", true); } + document.getElementById("audio_output_selectbox").add(option); } - - - + } }); // ACTION UPDATE HAMLIB TEST