From 1dbcfc672e6bf01837b03ab6dfaa9e831e4df9ff Mon Sep 17 00:00:00 2001 From: dj2ls Date: Tue, 4 Oct 2022 10:55:42 +0200 Subject: [PATCH 1/7] fixed windows rigctld list command --- gui/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/main.js b/gui/main.js index dab66fc9..1683c873 100644 --- a/gui/main.js +++ b/gui/main.js @@ -829,7 +829,7 @@ ipcMain.on('request-check-rigctld',(data)=>{ try { if(os.platform()=='win32' || os.platform()=='win64'){ - var state = exec('tasklist', ['/svc', '/FI', 'ImageName eq rigctld*']) + var state = exec('tasklist', ['/svc', '/FI', '"ImageName eq rigctld*"']) state.on('close', function(code) { if(code == 0){ let Data = { From 81d68076076a33e3436d7beda793a458ecc849be Mon Sep 17 00:00:00 2001 From: dj2ls Date: Wed, 5 Oct 2022 10:56:58 +0200 Subject: [PATCH 2/7] another way of checking if process is running --- gui/main.js | 132 +++++++++++++++++++++++----------------------------- 1 file changed, 58 insertions(+), 74 deletions(-) diff --git a/gui/main.js b/gui/main.js index 1683c873..e750b921 100644 --- a/gui/main.js +++ b/gui/main.js @@ -9,7 +9,9 @@ const { autoUpdater } = require('electron-updater'); const path = require('path'); const fs = require('fs'); const os = require('os'); -const exec = require('child_process').spawn; +const spawn = require('child_process').spawn; +const exec = require('child_process').exec; + const log = require('electron-log'); const mainLog = log.scope('main'); const daemonProcessLog = log.scope('freedata-daemon'); @@ -285,7 +287,7 @@ app.whenReady().then(() => { mainLog.info('Starting freedata-daemon binary'); if(os.platform()=='darwin'){ - daemonProcess = exec(path.join(process.resourcesPath, 'tnc', 'freedata-daemon'), [], + daemonProcess = spawn(path.join(process.resourcesPath, 'tnc', 'freedata-daemon'), [], { cwd: path.join(process.resourcesPath, 'tnc'), }); @@ -310,7 +312,7 @@ app.whenReady().then(() => { }); */ - daemonProcess = exec(path.join(process.resourcesPath, 'tnc', 'freedata-daemon'), [], + daemonProcess = spawn(path.join(process.resourcesPath, 'tnc', 'freedata-daemon'), [], { cwd: path.join(process.resourcesPath, 'tnc'), }); @@ -321,7 +323,7 @@ app.whenReady().then(() => { // for windows the relative path via path.join(__dirname) is not needed for some reason //daemonProcess = exec('\\tnc\\daemon.exe', []) - daemonProcess = exec(path.join(process.resourcesPath, 'tnc', 'freedata-daemon.exe'), [], + daemonProcess = spawn(path.join(process.resourcesPath, 'tnc', 'freedata-daemon.exe'), [], { cwd: path.join(process.resourcesPath, 'tnc'), }); @@ -735,20 +737,20 @@ function close_sub_processes(){ try { if(os.platform()=='win32' || os.platform()=='win64'){ - exec('Taskkill', ['/IM', 'freedata-tnc.exe', '/F']) - exec('Taskkill', ['/IM', 'freedata-daemon.exe', '/F']) + spawn('Taskkill', ['/IM', 'freedata-tnc.exe', '/F']) + spawn('Taskkill', ['/IM', 'freedata-daemon.exe', '/F']) } if(os.platform()=='linux'){ - exec('pkill', ['-9', 'freedata-tnc']) - exec('pkill', ['-9', 'freedata-daemon']) + spawn('pkill', ['-9', 'freedata-tnc']) + spawn('pkill', ['-9', 'freedata-daemon']) } if(os.platform()=='darwin'){ - exec('pkill', ['-9', 'freedata-tnc']) - exec('pkill', ['-9', 'freedata-daemon']) + spawn('pkill', ['-9', 'freedata-tnc']) + spawn('pkill', ['-9', 'freedata-daemon']) } } catch (e) { @@ -779,7 +781,7 @@ ipcMain.on('request-start-rigctld',(event, data)=>{ try{ - exec(data.path, data.parameters); + spawn(data.path, data.parameters); } catch (e) { console.log(e); } @@ -803,18 +805,18 @@ ipcMain.on('request-stop-rigctld',(event,data)=>{ try { if(os.platform()=='win32' || os.platform()=='win64'){ - exec('Taskkill', ['/IM', 'rigctld.exe', '/F']) + spawn('Taskkill', ['/IM', 'rigctld.exe', '/F']) } if(os.platform()=='linux'){ - exec('pkill', ['-9', 'rigctld']) + spawn('pkill', ['-9', 'rigctld']) } if(os.platform()=='darwin'){ - exec('pkill', ['-9', 'rigctld']) + spawn('pkill', ['-9', 'rigctld']) } } catch (e) { @@ -827,68 +829,50 @@ ipcMain.on('request-stop-rigctld',(event,data)=>{ // CHECK RIGCTLD ipcMain.on('request-check-rigctld',(data)=>{ try { + let Data = { + state: "unknown", + }; - if(os.platform()=='win32' || os.platform()=='win64'){ - var state = exec('tasklist', ['/svc', '/FI', '"ImageName eq rigctld*"']) - state.on('close', function(code) { - if(code == 0){ - let Data = { - state: "running", - }; - win.webContents.send('action-check-rigctld', Data); + isRunning('rigctld', (status) => { + if (status){ + Data["state"] = "running"; + } else { + Data["state"] = "unknown"; + } + win.webContents.send('action-check-rigctld', Data); + }) - } else { - let Data = { - state: "unknown", - }; - win.webContents.send('action-check-rigctld', Data); - - } - }); - } - - if(os.platform()=='linux'){ - - var state = exec('pgrep', ['rigctld']) - state.on('close', function(code) { - if(code == 0){ - let Data = { - state: "running", - }; - win.webContents.send('action-check-rigctld', Data); - - } else { - let Data = { - state: "unknown", - }; - win.webContents.send('action-check-rigctld', Data); - - } - }); - - } - - if(os.platform()=='darwin'){ - - var state = exec('pgrep', ['rigctld']) - state.on('close', function(code) { - if(code == 0){ - let Data = { - state: "running", - }; - win.webContents.send('action-check-rigctld', Data); - - } else { - let Data = { - state: "unknown", - }; - win.webContents.send('action-check-rigctld', Data); - - } - }); - - } } catch (e) { mainLog.error(e) } -}); \ No newline at end of file +}); + + + + +// https://stackoverflow.com/a/51084163 +// Function for checking if a process is running or not +/* +isRunning('rigctld', (status) => { + if (status){ + Data["state"] = "running"; + } else { + Data["state"] = "unknown"; + } + win.webContents.send('action-check-rigctld', Data); + }) +*/ +const isRunning = (query, cb) => { + let platform = process.platform; + let cmd = ''; + switch (platform) { + case 'win32' : cmd = `tasklist`; break; + case 'darwin' : cmd = `ps -ax | grep ${query}`; break; + case 'linux' : cmd = `ps -A`; break; + default: break; + } + exec(cmd, (err, stdout, stderr) => { + cb(stdout.toLowerCase().indexOf(query.toLowerCase()) > -1); + }); +} + From a4f133e434123a18a1a049ca6fdbab6c91e3cf24 Mon Sep 17 00:00:00 2001 From: dj2ls Date: Wed, 5 Oct 2022 10:58:38 +0200 Subject: [PATCH 3/7] added stopped information --- gui/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/main.js b/gui/main.js index e750b921..269c84eb 100644 --- a/gui/main.js +++ b/gui/main.js @@ -837,7 +837,7 @@ ipcMain.on('request-check-rigctld',(data)=>{ if (status){ Data["state"] = "running"; } else { - Data["state"] = "unknown"; + Data["state"] = "unknown/stopped"; } win.webContents.send('action-check-rigctld', Data); }) From a7c3764fbe6442aa8a26b93c9e526cd30fc38954 Mon Sep 17 00:00:00 2001 From: dj2ls Date: Wed, 5 Oct 2022 11:00:05 +0200 Subject: [PATCH 4/7] removed stderr --- gui/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/main.js b/gui/main.js index 269c84eb..48a1b3b1 100644 --- a/gui/main.js +++ b/gui/main.js @@ -871,7 +871,7 @@ const isRunning = (query, cb) => { case 'linux' : cmd = `ps -A`; break; default: break; } - exec(cmd, (err, stdout, stderr) => { + exec(cmd, (err, stdout) => { cb(stdout.toLowerCase().indexOf(query.toLowerCase()) > -1); }); } From 0fb632394bbeaf7332ec148533f0ae3ac5e740ac Mon Sep 17 00:00:00 2001 From: dj2ls Date: Wed, 5 Oct 2022 12:19:28 +0200 Subject: [PATCH 5/7] changed 500Hz to 563Hz mode --- gui/src/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gui/src/index.html b/gui/src/index.html index 8d52e57c..31c72198 100644 --- a/gui/src/index.html +++ b/gui/src/index.html @@ -1185,11 +1185,11 @@
- +
From ee6aeb1f784501a0503b844841bca684c23fea11 Mon Sep 17 00:00:00 2001 From: dj2ls Date: Wed, 5 Oct 2022 12:41:36 +0200 Subject: [PATCH 6/7] fixed tnc state --- gui/preload-main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/preload-main.js b/gui/preload-main.js index c0c52235..58b475bb 100644 --- a/gui/preload-main.js +++ b/gui/preload-main.js @@ -1788,7 +1788,7 @@ ipcRenderer.on('action-update-daemon-connection', (event, arg) => { }); -ipcRenderer.on('action-update-tnc-connection', (arg) => { +ipcRenderer.on('action-update-tnc-connection', (event, arg) => { if (arg.tnc_connection == "open") { /* From b8ee0297a263bf2b55ac158a4676a456a86c4272 Mon Sep 17 00:00:00 2001 From: dj2ls Date: Thu, 6 Oct 2022 10:08:31 +0200 Subject: [PATCH 7/7] added DTR state --- gui/main.js | 2 ++ gui/preload-main.js | 21 +++++++++++++++++++++ gui/src/index.html | 17 ++++++++++++++--- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/gui/main.js b/gui/main.js index 48a1b3b1..9a7d2e5d 100644 --- a/gui/main.js +++ b/gui/main.js @@ -64,6 +64,8 @@ const configDefaultSettings = '{\ "enable_hamlib_serialspeed" : "False",\ "hamlib_serialspeed" : "9600",\ "enable_hamlib_pttprotocol" : "False",\ + "hamlib_dtrstate" : "OFF",\ + "enable_hamlib_dtrstate" : "False",\ "hamlib_pttprotocol" : "USB",\ "enable_hamlib_pttport" : "False",\ "hamlib_pttport": "/dev/ttyACM1",\ diff --git a/gui/preload-main.js b/gui/preload-main.js index 58b475bb..9aa9b168 100644 --- a/gui/preload-main.js +++ b/gui/preload-main.js @@ -109,6 +109,12 @@ set_setting_switch("enable_hamlib_ptt_port", "hamlib_ptt_port", config.enable_ha document.getElementById('hamlib_dcd').value = config.hamlib_dcd; set_setting_switch("enable_hamlib_dcd", "hamlib_dcd", config.enable_hamlib_dcd) + document.getElementById('hamlib_dtrstate').value = config.hamlib_dtrstate; + set_setting_switch("enable_hamlib_dtrstate", "hamlib_dtrstate", config.enable_hamlib_dtrstate) + + + + document.getElementById("hamlib_rigctld_ip").value = config.hamlib_rigctld_ip; document.getElementById("hamlib_rigctld_port").value = config.hamlib_rigctld_port; @@ -531,6 +537,11 @@ set_setting_switch("enable_hamlib_ptt_port", "hamlib_ptt_port", config.enable_ha enable_setting("enable_hamlib_dcd", "hamlib_dcd") }); + // radio settings 'enable hamlib dtr state' event listener + document.getElementById("enable_hamlib_dtrstate").addEventListener("change", () => { + enable_setting("enable_hamlib_dtrstate", "hamlib_dtrstate") + }); + /* document.getElementById('hamlib_rigctld_path').addEventListener('change', () => { @@ -622,6 +633,16 @@ document.getElementById('hamlib_rigctld_start').addEventListener('click', () => paramList = paramList.concat('--ptt-type=', hamlib_ptt_type) } + // hamlib dtr state + if (document.getElementById('enable_hamlib_dtrstate').checked){ + var hamlib_dtrstate = document.getElementById("hamlib_dtrstate").value; + paramList = paramList.concat('--set-conf=dtr_state=' + hamlib_dtrstate) + } + + + + + var hamlib_rigctld_server_port = document.getElementById("hamlib_rigctld_server_port").value; paramList = paramList.concat('-t', hamlib_rigctld_server_port) diff --git a/gui/src/index.html b/gui/src/index.html index 31c72198..be0588ee 100644 --- a/gui/src/index.html +++ b/gui/src/index.html @@ -615,14 +615,13 @@ - - -
DCD +
+ DCD + + + DTR + + +
+ +