first quick and dirty version for starting rigctld

This commit is contained in:
dj2ls 2022-09-20 19:24:07 +02:00
parent 153dd7f7da
commit 6846936559
3 changed files with 114 additions and 11 deletions

View file

@ -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)
}
});

View file

@ -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;

View file

@ -305,9 +305,6 @@
<label class="btn btn-sm btn-outline-secondary" for="radio-control-switch-ptt">
<i class="bi bi-alt" style="font-size: 0.8rem; color: black;"></i>
</label>
<input type="radio" class="btn-check" name="radio-control-switch" id="radio-control-switch-network" autocomplete="off">
<label class="btn btn-sm btn-outline-secondary" for="radio-control-switch-network"><strong><i class="bi bi-ethernet"></i></strong>
</label>
</div>
<div class="btn-group btn-group-sm" role="group" aria-label="radio-control-switch-rigctld">
@ -321,6 +318,14 @@
</label>
</div>
<div class="btn-group btn-group-sm" role="group" aria-label="radio-control-switch-rigctld">
<input type="radio" class="btn-check" name="radio-control-switch" id="radio-control-switch-network" autocomplete="off">
<label class="btn btn-sm btn-outline-secondary" for="radio-control-switch-network">
<i class="bi bi-ethernet" style="font-size: 0.8rem; color: black;"></i>
</label>
</div>
<div class="btn-group" role="group">
<button type="button" id="testHamlib" class="btn btn-sm btn-outline-secondary" data-bs-placement="bottom" data-bs-toggle="tooltip" data-bs-html="true" title="Test your hamlib settings and toggle PTT once. Button will become <strong class='text-success'>green</strong> on success and <strong class='text-danger'>red</strong> if fails.">PTT Test</button>
</div>
@ -685,6 +690,8 @@
<div class="input-group input-group-sm mb-1">
<span class="input-group-text" id="basic-addon1">Rigctld Path</span>
<input type="text" class="form-control" placeholder="rigctld Path" id="hamlib_rigctld_path" aria-label="Device IP" aria-describedby="basic-addon1">
</div>
<div class="input-group input-group-sm mb-1">
<span class="input-group-text" id="basic-addon1">Rigctld Server Port</span>
<input type="text" class="form-control" placeholder="rigctld port" id="hamlib_rigctld_server_port" aria-label="Device Port" aria-describedby="basic-addon1">
</div>
@ -698,7 +705,13 @@
<span class="input-group-text" id="basic-addon1">Rigctld Version</span>
<input type="text" class="form-control" placeholder="Version" id="hamlib_rigctld_version" aria-label="Device Port" aria-describedby="basic-addon1">
</div>
Start Stop
<div class="input-group input-group-sm mb-1">
<span class="input-group-text" id="hamlib_rigctld_start">start</span>
<span class="input-group-text" id="hamlib_rigctld_stop">stop</span>
</div>
</div>