From 6846936559f5f8e961ecfe048e4bb8b301f24aeb Mon Sep 17 00:00:00 2001 From: dj2ls Date: Tue, 20 Sep 2022 19:24:07 +0200 Subject: [PATCH] first quick and dirty version for starting rigctld --- gui/main.js | 52 ++++++++++++++++++++++++++++++++++++++++++++- gui/preload-main.js | 52 +++++++++++++++++++++++++++++++++++++++------ gui/src/index.html | 21 ++++++++++++++---- 3 files changed, 114 insertions(+), 11 deletions(-) diff --git a/gui/main.js b/gui/main.js index 74dcaf78..77616cf1 100644 --- a/gui/main.js +++ b/gui/main.js @@ -78,7 +78,8 @@ const configDefaultSettings = '{\ "tuning_range_fmin" : "-50.0",\ "tuning_range_fmax" : "50.0",\ "respond_to_cq" : "True",\ - "rx_buffer_size" : "16" \ + "rx_buffer_size" : "16" ,\ + "hamlib_rigctld_path" : ""\ }'; if (!fs.existsSync(configPath)) { @@ -441,6 +442,15 @@ ipcMain.on('request-open-tnc-log', (event) => { logViewer.show(); }); +//file selector +ipcMain.on('get-file-path',(event,data)=>{ + dialog.showOpenDialog({defaultPath: path.join(__dirname, '../'), + buttonLabel: 'Select rigctld', properties: ['openFile']}).then(filePaths => { + win.webContents.send('return-file-paths', {path: filePaths,}) + + }); +}); + //folder selector ipcMain.on('get-folder-path',(event,data)=>{ dialog.showOpenDialog({defaultPath: path.join(__dirname, '../'), @@ -757,3 +767,43 @@ function close_all() { } +// RUN RIGCTLD +ipcMain.on('request-start-rigctld',(event,data)=>{ + //win.webContents.send('action-show-arq-toast-session-failed', data); + //exec('git', ['--version']) + + console.log(data.path) + console.log(data.parameters) + + + const rigctld = exec(data.path, data.parameters); + rigctld.stdout.on("data", data => { + console.log(`stdout: ${data}`); + }); + +}); + + +// STOP RIGCTLD +ipcMain.on('request-stop-rigctld',(event,data)=>{ + mainLog.warn('closing rigctld'); + try { + + if(os.platform()=='win32' || os.platform()=='win64'){ + exec('Taskkill', ['/IM', 'rigctld.exe', '/F']) + } + + if(os.platform()=='linux'){ + + exec('pkill', ['-9', 'rigctld']) + } + + if(os.platform()=='darwin'){ + + exec('pkill', ['-9', 'rigctld']) + + } + } catch (e) { + mainLog.error(e) + } +}); \ No newline at end of file diff --git a/gui/preload-main.js b/gui/preload-main.js index b9978965..8d7023dc 100644 --- a/gui/preload-main.js +++ b/gui/preload-main.js @@ -1,5 +1,6 @@ const path = require('path'); const {ipcRenderer} = require('electron'); +const exec = require('child_process').spawn; const sock = require('./sock.js'); const daemon = require('./daemon.js'); const fs = require('fs'); @@ -95,12 +96,14 @@ document.getElementById('openReceivedFilesFolder').addEventListener('click', () document.getElementById('hamlib_databits_advanced').value = config.data_bits_direct; document.getElementById('hamlib_stopbits_advanced').value = config.stop_bits_direct; document.getElementById('hamlib_handshake_advanced').value = config.handshake_direct; + document.getElementById("hamlib_rigctld_path").value = config.hamlib_rigctld_path; document.getElementById("beaconInterval").value = config.beacon_interval; document.getElementById("scatterSwitch").value = config.enable_scatter; document.getElementById("fftSwitch").value = config.enable_fft; + document.getElementById("received_files_folder").value = config.received_files_folder; @@ -450,6 +453,47 @@ document.getElementById('openReceivedFilesFolder').addEventListener('click', () config.radiocontrol = 'rigctld'; fs.writeFileSync(configPath, JSON.stringify(config, null, 2)); }); +/* +document.getElementById('hamlib_rigctld_path').addEventListener('change', () => { +var fileList = document.getElementById("dataModalFile").files; + console.log(fileList) + +}) +*/ + +document.getElementById('hamlib_rigctld_path').addEventListener('click', () => { + + ipcRenderer.send('get-file-path',{ + title: 'Title', + }); + + ipcRenderer.on('return-file-paths',(event,data)=>{ + rigctldPath = data.path.filePaths[0] + document.getElementById("hamlib_rigctld_path").value = rigctldPath + config.hamlib_rigctld_path = rigctldPath + fs.writeFileSync(configPath, JSON.stringify(config, null, 2)); + + }); +}) + +document.getElementById('hamlib_rigctld_start').addEventListener('click', () => { + var rigctldPath = document.getElementById("hamlib_rigctld_path").value; + ipcRenderer.send('request-start-rigctld',{ + path: rigctldPath, + parameters: ['-m', '3085', '-r', '/dev/ttyACM0'] + }); + + +}) +document.getElementById('hamlib_rigctld_stop').addEventListener('click', () => { + ipcRenderer.send('request-stop-rigctld',{ + path: '123', + parameters: '--version' + }); + + +}) + // on click waterfall scatter toggle view // waterfall @@ -805,19 +849,15 @@ document.getElementById('openReceivedFilesFolder').addEventListener('click', () } } - if (document.getElementById("radio-control-switch-network").checked) { + if (!document.getElementById("radio-control-switch-disabled").checked) { var radiocontrol = 'rigctld'; - - } else if (document.getElementById("radio-control-switch-radio").checked) { - var radiocontrol = 'direct'; - } else { var radiocontrol = 'disabled'; } var tx_audio_level = document.getElementById("audioLevelTX").value; var rx_buffer_size = document.getElementById("rx_buffer_size").value; - + config.radiocontrol = radiocontrol; config.mycall = callsign_ssid; config.mygrid = mygrid; diff --git a/gui/src/index.html b/gui/src/index.html index b842d088..5a7e821d 100644 --- a/gui/src/index.html +++ b/gui/src/index.html @@ -305,9 +305,6 @@ - -
@@ -321,6 +318,14 @@
+
+ + +
+ +
@@ -685,6 +690,8 @@
Rigctld Path +
+
Rigctld Server Port
@@ -698,7 +705,13 @@ Rigctld Version - Start Stop + +
+ start + stop +
+ +