hamlib test settings

introduced a button and advanced settings modal for hamlib settings. This part is now much more clean and more settings can be set. May have some bugs for sure, but a first test seems to be running....
This commit is contained in:
DJ2LS 2021-10-17 15:57:41 +02:00
parent 07723ff2b8
commit 44f9446a5c
4 changed files with 462 additions and 134 deletions

View file

@ -107,9 +107,17 @@ daemon.on('data', function(data) {
version: data['VERSION'],
};
ipcRenderer.send('request-update-daemon-state', Data);
}
if (data['COMMAND'] == 'TEST_HAMLIB') {
let Data = {
hamlib_result: data['RESULT'],
};
ipcRenderer.send('request-update-hamlib-test', Data);
}
////// check if EOF ...
}
@ -130,7 +138,7 @@ exports.getDaemonState = function() {
// START TNC
// ` `== multi line string
exports.startTNC = function(rx_audio, tx_audio, deviceid, deviceport, pttprotocol, pttport, serialspeed) {
exports.startTNC = function(rx_audio, tx_audio, deviceid, deviceport, pttprotocol, pttport, serialspeed, pttspeed, data_bits, stop_bits, handshake) {
var json_command = JSON.stringify({
type: 'SET',
command: 'STARTTNC',
@ -141,7 +149,11 @@ exports.startTNC = function(rx_audio, tx_audio, deviceid, deviceport, pttprotoco
deviceport: deviceport,
pttprotocol: pttprotocol,
pttport: pttport,
serialspeed: serialspeed
serialspeed: serialspeed,
pttspeed: pttspeed,
data_bits: data_bits,
stop_bits: stop_bits,
handshake: handshake
}]
})
@ -155,4 +167,29 @@ exports.startTNC = function(rx_audio, tx_audio, deviceid, deviceport, pttprotoco
exports.stopTNC = function() {
command = '{"type" : "SET", "command": "STOPTNC" , "parameter": "---" }'
writeDaemonCommand(command)
}
}
// TEST HAMLIB
exports.testHamlib = function(deviceid, deviceport, serialspeed, pttprotocol, pttport, pttspeed, data_bits, stop_bits, handshake) {
var json_command = JSON.stringify({
type: 'GET',
command: 'TEST_HAMLIB',
parameter: [{
deviceid: deviceid,
deviceport: deviceport,
pttprotocol: pttprotocol,
pttport: pttport,
serialspeed: serialspeed,
pttspeed: pttspeed,
data_bits: data_bits,
stop_bits: stop_bits,
handshake: handshake
}]
})
console.log(json_command)
writeDaemonCommand(json_command)
}

View file

@ -43,12 +43,21 @@ window.addEventListener('DOMContentLoaded', () => {
document.getElementById("tnc_port").value = config.tnc_port
document.getElementById("myCall").value = config.mycall
document.getElementById("myGrid").value = config.mygrid
document.getElementById('hamlib_deviceid').value = config.deviceid
document.getElementById('hamlib_deviceport').value = config.deviceport
document.getElementById('hamlib_serialspeed').value = config.serialspeed
document.getElementById('hamlib_ptt_protocol').value = config.pttprotocol
document.getElementById('hamlib_ptt_port').value = config.pttport
document.getElementById('hamlib_ptt_protocol').value = config.pttprotocol
document.getElementById('hamlib_deviceport_advanced').value = config.deviceport
document.getElementById('hamlib_serialspeed_advanced').value = config.serialspeed
document.getElementById('hamlib_ptt_protocol_advanced').value = config.pttprotocol
document.getElementById('hamlib_pttspeed_advanced').value = config.pttspeed
document.getElementById('hamlib_ptt_port_advanced').value = config.pttport
document.getElementById('hamlib_databits_advanced').value = config.data_bits
document.getElementById('hamlib_stopbits_advanced').value = config.stop_bits
document.getElementById('hamlib_handshake_advanced').value = config.handshake
if (config.spectrum == 'waterfall') {
document.getElementById("waterfall-scatter-switch1").checked = true
@ -128,6 +137,17 @@ window.addEventListener('DOMContentLoaded', () => {
});
*/
/*
// advanced Hamlib Settings
document.getElementById("advancedHamlibSettingsButton").addEventListener("click", () => {
advancedHamlibSettingsModal
});
*/
// on click waterfall scatter toggle view
// waterfall
document.getElementById("waterfall-scatter-switch1").addEventListener("click", () => {
@ -232,17 +252,25 @@ window.addEventListener('DOMContentLoaded', () => {
var deviceport = document.getElementById("hamlib_deviceport").value
var serialspeed = document.getElementById("hamlib_serialspeed").value
var pttprotocol = document.getElementById("hamlib_ptt_protocol").value
var pttport = document.getElementById("hamlib_ptt_port").value
var pttport = document.getElementById("hamlib_ptt_port_advanced").value
var pttspeed = document.getElementById('hamlib_pttspeed_advanced').value
var data_bits = document.getElementById('hamlib_databits_advanced').value
var stop_bits = document.getElementById('hamlib_stopbits_advanced').value
var handshake = document.getElementById('hamlib_handshake_advanced').value
config.deviceid = deviceid
config.deviceport = deviceport
config.serialspeed = serialspeed
config.pttprotocol = pttprotocol
config.pttport = pttport
config.pttspeed = pttspeed
config.data_bits = data_bits
config.stop_bits = stop_bits
config.handshake = handshake
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
daemon.startTNC(rx_audio, tx_audio, deviceid, deviceport, pttprotocol, pttport, serialspeed)
daemon.startTNC(rx_audio, tx_audio, deviceid, deviceport, pttprotocol, pttport, serialspeed, pttspeed, data_bits, stop_bits, handshake)
setTimeout(function() {
sock.saveMyCall(config.mycall);
}, 3000);
@ -265,6 +293,60 @@ window.addEventListener('DOMContentLoaded', () => {
}
})
// openReceivedFiles button clicked
document.getElementById("openReceivedFiles").addEventListener("click", () => {
if (document.getElementById("receivedFilesSidebar").style.width == "40%") {
document.getElementById("receivedFilesSidebar").style.width = "0px";
} else {
document.getElementById("receivedFilesSidebar").style.width = "40%";
}
})
// TEST HAMLIB
document.getElementById("testHamlib").addEventListener("click", () => {
var deviceid = document.getElementById("hamlib_deviceid").value
var deviceport = document.getElementById("hamlib_deviceport").value
var serialspeed = document.getElementById("hamlib_serialspeed").value
var pttprotocol = document.getElementById("hamlib_ptt_protocol").value
var pttport = deviceport
var pttspeed = serialspeed
var data_bits = "8"
var stop_bits = "1"
var handshake = "None"
daemon.testHamlib(deviceid, deviceport, serialspeed, pttprotocol, pttport, pttspeed, data_bits, stop_bits, handshake)
})
// TEST HAMLIB ADVANCED
document.getElementById("testHamlibAdvanced").addEventListener("click", () => {
var deviceid = document.getElementById("hamlib_deviceid").value
var deviceport = document.getElementById("hamlib_deviceport_advanced").value
document.getElementById("hamlib_deviceport").value = deviceport
var serialspeed = document.getElementById("hamlib_serialspeed_advanced").value
document.getElementById("hamlib_serialspeed").value = serialspeed
var pttprotocol = document.getElementById("hamlib_ptt_protocol_advanced").value
document.getElementById("hamlib_ptt_protocol").value = pttprotocol
var pttport = document.getElementById("hamlib_deviceport").value
var pttspeed = document.getElementById("hamlib_serialspeed_advanced").value
var data_bits = document.getElementById("hamlib_databits_advanced").value
var stop_bits = document.getElementById("hamlib_stopbits_advanced").value
var handshake = document.getElementById("hamlib_handshake_advanced").value
daemon.testHamlib(deviceid, deviceport, serialspeed, pttprotocol, pttport, pttspeed, data_bits, stop_bits, handshake)
})
// START TRANSMISSION
document.getElementById("startTransmission").addEventListener("click", () => {
document.getElementById("mySidebar").style.width = "0px";
@ -312,21 +394,9 @@ window.addEventListener('DOMContentLoaded', () => {
ipcRenderer.on('action-update-tnc-state', (event, arg) => {
//console.log(arg)
/*
var fft = Array.from({
length: 2048
}, () => Math.floor(Math.random() * 10));
spectrum.addData(fft);
*/
// update FFT
if (typeof(arg.fft) !== 'undefined') {
//console.log(arg.fft)
//console.log(typeof(arg.fft))
var array = JSON.parse("[" + arg.fft + "]");
//console.log(typeof(array))
//console.log(array[0])
spectrum.addData(array[0]);
}
@ -800,17 +870,28 @@ ipcRenderer.on('action-update-daemon-state', (event, arg) => {
document.getElementById("hamlib_deviceport").add(option);
}
}
}
if (arg.tnc_running_state == "stopped") {
if (document.getElementById("hamlib_ptt_port").length != arg.serial_devices.length) {
document.getElementById("hamlib_ptt_port").innerHTML = ""
if (document.getElementById("hamlib_deviceport_advanced").length != arg.serial_devices.length) {
document.getElementById("hamlib_deviceport_advanced").innerHTML = ""
for (i = 0; i < arg.serial_devices.length; i++) {
var option = document.createElement("option");
option.text = arg.serial_devices[i]['DESCRIPTION'];
option.value = arg.serial_devices[i]['PORT'];
document.getElementById("hamlib_ptt_port").add(option);
document.getElementById("hamlib_deviceport_advanced").add(option);
}
}
}
if (arg.tnc_running_state == "stopped") {
if (document.getElementById("hamlib_ptt_port_advanced").length != arg.serial_devices.length) {
document.getElementById("hamlib_ptt_port_advanced").innerHTML = ""
for (i = 0; i < arg.serial_devices.length; i++) {
var option = document.createElement("option");
option.text = arg.serial_devices[i]['DESCRIPTION'];
option.value = arg.serial_devices[i]['PORT'];
document.getElementById("hamlib_ptt_port_advanced").add(option);
}
}
}
@ -819,7 +900,8 @@ ipcRenderer.on('action-update-daemon-state', (event, arg) => {
if (arg.tnc_running_state == "running") {
document.getElementById('hamlib_deviceid').disabled = true
document.getElementById('hamlib_deviceport').disabled = true
document.getElementById('hamlib_ptt_port').disabled = true
document.getElementById('advancedHamlibSettingsButton').disabled = true
document.getElementById('testHamlib').disabled = true
document.getElementById('hamlib_ptt_protocol').disabled = true
document.getElementById('audio_input_selectbox').disabled = true
document.getElementById('audio_output_selectbox').disabled = true
@ -832,11 +914,14 @@ ipcRenderer.on('action-update-daemon-state', (event, arg) => {
//document.getElementById('saveMyGrid').disabled = false
document.getElementById("hamlib_serialspeed").disabled = true
//document.getElementById("startTransmission").disabled = false
document.getElementById("openDataModule").disabled = false
} else {
document.getElementById('hamlib_deviceid').disabled = false
document.getElementById('hamlib_deviceport').disabled = false
document.getElementById('hamlib_ptt_port').disabled = false
document.getElementById('advancedHamlibSettingsButton').disabled = false
document.getElementById('testHamlib').disabled = false
document.getElementById('hamlib_ptt_protocol').disabled = false
document.getElementById('audio_input_selectbox').disabled = false
document.getElementById('audio_output_selectbox').disabled = false
@ -849,11 +934,37 @@ ipcRenderer.on('action-update-daemon-state', (event, arg) => {
//document.getElementById('saveMyGrid').disabled = true
document.getElementById("hamlib_serialspeed").disabled = false
//document.getElementById("startTransmission").disabled = true
document.getElementById("openDataModule").disabled = true
}
});
// ACTION UPDATE HAMLIB TEST
ipcRenderer.on('action-update-hamlib-test', (event, arg) => {
console.log(arg.hamlib_result)
if (arg.hamlib_result == 'SUCCESS') {
document.getElementById("testHamlib").className = "btn btn-sm btn-success";
document.getElementById("testHamlibAdvanced").className = "btn btn-sm btn-success";
}
if (arg.hamlib_result == 'NOSUCCESS') {
document.getElementById("testHamlib").className = "btn btn-sm btn-warning";
document.getElementById("testHamlibAdvanced").className = "btn btn-sm btn-warning";
}
if (arg.hamlib_result == 'FAILED') {
document.getElementById("testHamlib").className = "btn btn-sm btn-danger";
document.getElementById("testHamlibAdvanced").className = "btn btn-sm btn-danger";
}
});
ipcRenderer.on('action-update-daemon-connection', (event, arg) => {
if (arg.daemon_connection == 'open') {

View file

@ -17,43 +17,6 @@
<title>FreeDATA</title>
</head>
<body>
<!-- MAIN NAVBAR -->
<!--<nav class="navbar fixed-top bg-dark navbar-dark">
<div class="container-fluid">
<a class="navbar-brand"><b>FreeDATA</b></a>
<div class="container mt-1">
<div class="btn-toolbar" role="toolbar" aria-label="Toolbar with button groups">
<div class="btn-group btn-group-sm me-2" role="group" aria-label="local-remote-switch toggle button group">
<input type="radio" class="btn-check" name="local-remote-switch" id="local-remote-switch1" autocomplete="off" checked>
<label class="btn btn-outline-secondary" for="local-remote-switch1">local TNC</label>
<input type="radio" class="btn-check" name="local-remote-switch" id="local-remote-switch2" autocomplete="off">
<label class="btn btn-outline-secondary" for="local-remote-switch2">remote TNC</label>
</div>
<div class="input-group input-group-sm" id="remote-tnc-field">
<span class="input-group-text" id="basic-addon1">IP</span>
<input type="text" class="form-control" placeholder="ip adress" id="tnc_adress" value="192.168.178.163" maxlength="17" style="width: 8rem" aria-label="Username" aria-describedby="basic-addon1" >
<span class="input-group-text" id="basic-addon1">:</span>
<input type="text" class="form-control" placeholder="port" value="3000" id="tnc_port" maxlength="5" style="width: 4rem" aria-label="Username" aria-describedby="basic-addon1" >
<button class="btn btn-danger" id="daemon_connection_state" type="button" disabled>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-diagram-3" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M6 3.5A1.5 1.5 0 0 1 7.5 2h1A1.5 1.5 0 0 1 10 3.5v1A1.5 1.5 0 0 1 8.5 6v1H14a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-1 0V8h-5v.5a.5.5 0 0 1-1 0V8h-5v.5a.5.5 0 0 1-1 0v-1A.5.5 0 0 1 2 7h5.5V6A1.5 1.5 0 0 1 6 4.5v-1zM8.5 5a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1a.5.5 0 0 0 .5.5h1zM0 11.5A1.5 1.5 0 0 1 1.5 10h1A1.5 1.5 0 0 1 4 11.5v1A1.5 1.5 0 0 1 2.5 14h-1A1.5 1.5 0 0 1 0 12.5v-1zm1.5-.5a.5.5 0 0 0-.5.5v1a.5.5 0 0 0 .5.5h1a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5h-1zm4.5.5A1.5 1.5 0 0 1 7.5 10h1a1.5 1.5 0 0 1 1.5 1.5v1A1.5 1.5 0 0 1 8.5 14h-1A1.5 1.5 0 0 1 6 12.5v-1zm1.5-.5a.5.5 0 0 0-.5.5v1a.5.5 0 0 0 .5.5h1a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5h-1zm4.5.5a1.5 1.5 0 0 1 1.5-1.5h1a1.5 1.5 0 0 1 1.5 1.5v1a1.5 1.5 0 0 1-1.5 1.5h-1a1.5 1.5 0 0 1-1.5-1.5v-1zm1.5-.5a.5.5 0 0 0-.5.5v1a.5.5 0 0 0 .5.5h1a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5h-1z"/>
</svg>
</button>
</div>
</div>
</div>
<button class="btn btn-primary" id="openDataModule" type="button">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-folder-symlink" viewBox="0 0 16 16">
<path d="m11.798 8.271-3.182 1.97c-.27.166-.616-.036-.616-.372V9.1s-2.571-.3-4 2.4c.571-4.8 3.143-4.8 4-4.8v-.769c0-.336.346-.538.616-.371l3.182 1.969c.27.166.27.576 0 .742z"/>
<path d="m.5 3 .04.87a1.99 1.99 0 0 0-.342 1.311l.637 7A2 2 0 0 0 2.826 14h10.348a2 2 0 0 0 1.991-1.819l.637-7A2 2 0 0 0 13.81 3H9.828a2 2 0 0 1-1.414-.586l-.828-.828A2 2 0 0 0 6.172 1H2.5a2 2 0 0 0-2 2zm.694 2.09A1 1 0 0 1 2.19 4h11.62a1 1 0 0 1 .996 1.09l-.636 7a1 1 0 0 1-.996.91H2.826a1 1 0 0 1-.995-.91l-.637-7zM6.172 2a1 1 0 0 1 .707.293L7.586 3H2.19c-.24 0-.47.042-.683.12L1.5 2.98a1 1 0 0 1 1-.98h3.672z"/>
</svg>
</button>
</div>
</nav>-->
<!-- SECONDARY NAVBAR -->
<nav class="navbar bg-light fixed-top navbar-underline mt-0 mb-1 pb-1 pt-1 shadow">
<div class="container-fluid mt-0">
@ -76,12 +39,26 @@
</button>
</div>
</div>
<button class="btn btn-sm btn-primary" id="openDataModule" type="button">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-folder-symlink" viewBox="0 0 16 16">
<path d="m11.798 8.271-3.182 1.97c-.27.166-.616-.036-.616-.372V9.1s-2.571-.3-4 2.4c.571-4.8 3.143-4.8 4-4.8v-.769c0-.336.346-.538.616-.371l3.182 1.969c.27.166.27.576 0 .742z"/>
<path d="m.5 3 .04.87a1.99 1.99 0 0 0-.342 1.311l.637 7A2 2 0 0 0 2.826 14h10.348a2 2 0 0 0 1.991-1.819l.637-7A2 2 0 0 0 13.81 3H9.828a2 2 0 0 1-1.414-.586l-.828-.828A2 2 0 0 0 6.172 1H2.5a2 2 0 0 0-2 2zm.694 2.09A1 1 0 0 1 2.19 4h11.62a1 1 0 0 1 .996 1.09l-.636 7a1 1 0 0 1-.996.91H2.826a1 1 0 0 1-.995-.91l-.637-7zM6.172 2a1 1 0 0 1 .707.293L7.586 3H2.19c-.24 0-.47.042-.683.12L1.5 2.98a1 1 0 0 1 1-.98h3.672z"/>
</svg>
</button>
<div class="btn-toolbar" role="toolbar">
<button class="btn btn-sm btn-primary me-2" id="openRFChat" type="button" disabled>
<strong>RF Chat </strong>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-chat-left-text-fill" viewBox="0 0 16 16">
<path d="M0 2a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H4.414a1 1 0 0 0-.707.293L.854 15.146A.5.5 0 0 1 0 14.793V2zm3.5 1a.5.5 0 0 0 0 1h9a.5.5 0 0 0 0-1h-9zm0 2.5a.5.5 0 0 0 0 1h9a.5.5 0 0 0 0-1h-9zm0 2.5a.5.5 0 0 0 0 1h5a.5.5 0 0 0 0-1h-5z"/>
</svg>
</button>
<button class="btn btn-sm btn-primary me-2" id="openReceivedFiles" type="button">
<strong>Received Files </strong>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-file-earmark-arrow-down-fill" viewBox="0 0 16 16">
<path d="M9.293 0H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V4.707A1 1 0 0 0 13.707 4L10 .293A1 1 0 0 0 9.293 0zM9.5 3.5v-2l3 3h-2a1 1 0 0 1-1-1zm-1 4v3.793l1.146-1.147a.5.5 0 0 1 .708.708l-2 2a.5.5 0 0 1-.708 0l-2-2a.5.5 0 0 1 .708-.708L7.5 11.293V7.5a.5.5 0 0 1 1 0z"/>
</svg>
</button>
<button class="btn btn-sm btn-primary me-2" id="openDataModule" type="button">
<strong>Transmit File </strong>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-file-earmark-arrow-up-fill" viewBox="0 0 16 16">
<path d="M9.293 0H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V4.707A1 1 0 0 0 13.707 4L10 .293A1 1 0 0 0 9.293 0zM9.5 3.5v-2l3 3h-2a1 1 0 0 1-1-1zM6.354 9.854a.5.5 0 0 1-.708-.708l2-2a.5.5 0 0 1 .708 0l2 2a.5.5 0 0 1-.708.708L8.5 8.707V12.5a.5.5 0 0 1-1 0V8.707L6.354 9.854z"/>
</svg>
</button>
</div>
</div>
</nav>
<div id="blurdiv" style="-webkit-Filter: blur(10px)">
@ -235,7 +212,7 @@
<div class="card-header p-1">
<strong>Step 1: AUDIO SETTINGS</strong>
</div>
<div class="card-body p-2">
<div class="card-body p-2 mb-1">
<div class="input-group input-group-sm mb-1">
<span class="input-group-text" id="basic-addon1">RX</span>
<select class="form-select form-select-sm" id="audio_input_selectbox" aria-label=".form-select-sm">
@ -531,6 +508,24 @@
<option value="32002"> Barrett 950 </option>
<option value="33001"> ELAD FDM-DUO </option>
</select>
<span class="input-group-text" id="basic-addon1">PTT</span>
<select class="form-select form-select-sm" aria-label=".form-select-sm" id="hamlib_ptt_protocol" style="width: 0.5rem">
<option value="RIG">RIG</option>
<option value="RTS">Serial RTS</option>
<option value="DTR-H">Serial DTR-High</option>
<option value="DTR-H">Serial DTR-Low</option>
<option value="PARALLEL">Rig PARALLEL</option>
<option value="MICDATA">Rig MICDATA</option>
<option value="CM108">Rig CM108</option>
</select>
</div>
<!--<hr class="m-1">-->
<div class="input-group input-group-sm mb-1">
<span class="input-group-text" id="basic-addon1">Port</span>
<select class="form-select form-select-sm" aria-label=".form-select-sm" id="hamlib_deviceport" style="width:7rem">
<!--<option selected value="/dev/ttyUSB0">/dev/ttyUSB0</option>
<option value="/dev/ttyUSB1">/dev/ttyUSB1</option>-->
</select>
<span class="input-group-text" id="basic-addon1">Speed</span>
<select class="form-select form-select-sm" aria-label=".form-select-sm" id="hamlib_serialspeed">
<option value="1200">1200</option>
@ -545,30 +540,11 @@
<option value="115200">115200</option>
</select>
</div>
<div class="input-group input-group-sm mb-1">
<span class="input-group-text" id="basic-addon1">Port</span>
<select class="form-select form-select-sm" aria-label=".form-select-sm" id="hamlib_deviceport">
<!--<option selected value="/dev/ttyUSB0">/dev/ttyUSB0</option>
<option value="/dev/ttyUSB1">/dev/ttyUSB1</option>-->
</select>
<div class="btn-group" role="group">
<button type="button" id="advancedHamlibSettingsButton" data-bs-toggle="modal" data-bs-target="#advancedHamlibSettingsModal" class="btn btn-sm btn-secondary">Advanced settings</button>
</div>
<hr class="m-1">
<div class="input-group input-group-sm mb-1">
<span class="input-group-text" id="basic-addon1">PTT</span>
<select class="form-select form-select-sm" aria-label=".form-select-sm" id="hamlib_ptt_protocol" style="width: 0.5rem">
<option value="RIG">RIG</option>
<option value="RTS">Serial RTS</option>
<option value="DTR-H">Serial DTR-High</option>
<option value="DTR-H">Serial DTR-Low</option>
<option value="PARALLEL">Rig PARALLEL</option>
<option value="MICDATA">Rig MICDATA</option>
<option value="CM108">Rig CM108</option>
</select>
<span class="input-group-text" id="basic-addon1">Port</span>
<select class="form-select form-select-sm" aria-label=".form-select-sm" id="hamlib_ptt_port">
<!--<option selected value="/dev/ttyUSB0">/dev/ttyUSB0</option>
<option value="/dev/ttyUSB1">/dev/ttyUSB1</option>-->
</select>
<div class="btn-group" role="group">
<button type="button" id="testHamlib"class="btn btn-sm btn-outline-secondary">Test settings</button>
</div>
</div>
<!--
@ -581,7 +557,7 @@
<div class="col">
<div class="card text-dark bg-light mb-0" >
<div class="card-header p-1"><strong>Step 3: TNC STATUS</strong></div>
<div class="card-body p-2">
<div class="card-body p-1 mb-1">
<!--
<div class="input-group input-group-sm mb-1">
<button type="button" id="startTNC"class="btn btn-success">Start</button>
@ -757,7 +733,35 @@
</div>
</div>
</div>
<!---------------------------------------------------------------------- DATA SIDEBAR ------------------------------------------------------------>
<!------------------------------- RECEIVED FILES SIDEBAR ----------------------->
<div id="receivedFilesSidebar" class="sidebar shadow-lg rounded">
<h4 class="p-1">Received Files</h4>
<!-- START OF TABLE FOR RECEIVED FILES-->
<table class="table">
<thead>
<tr>
<th scope="col">Time</th>
<th scope="col">DXCall</th>
<!--<th scope="col">DXGrid</th>
<th scope="col">Distance</th>-->
<th scope="col">Filename</th>
<!--<th scope="col">SNR</th>-->
</tr>
</thead>
<tbody id="rx-data">
<!--
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>@mdo</td>
</tr>
-->
</tbody>
</table>
<!-- END OF RECEIVED FILES-->
</div>
<!------------------------------- DATA SIDEBAR ----------------------->
<div id="mySidebar" class="sidebar shadow-lg rounded">
<div class="container-fluid">
<div class="container mt-1">
@ -862,31 +866,6 @@
-->
<div class="row">
<div class="col">
<hr>
<!-- START OF TABLE FOR RECEIVED FILES-->
<table class="table">
<thead>
<tr>
<th scope="col">Time</th>
<th scope="col">DXCall</th>
<!--<th scope="col">DXGrid</th>
<th scope="col">Distance</th>-->
<th scope="col">Filename</th>
<!--<th scope="col">SNR</th>-->
</tr>
</thead>
<tbody id="rx-data">
<!--
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>@mdo</td>
</tr>
-->
</tbody>
</table>
<!-- END OF RECEIVED FILES-->
</div>
</div>
<!--row-->
@ -898,29 +877,29 @@
<!---------------------------------------------------------------------- FOOTER AREA ------------------------------------------------------------>
<nav class="navbar fixed-bottom navbar-light bg-light">
<div class="container-fluid">
<div class="btn-toolbar" style="width:20%" role="toolbar" aria-label="Toolbar with button groups">
<div class="btn-group btn-group-sm me-2" role="group" aria-label="First group">
<div class="btn-toolbar" style="width:20%" role="toolbar">
<div class="btn-group btn-group-sm me-2" role="group">
<button class="btn btn-secondary" id="ptt_state" type="button">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-broadcast-pin" viewBox="0 0 16 16">
<path d="M3.05 3.05a7 7 0 0 0 0 9.9.5.5 0 0 1-.707.707 8 8 0 0 1 0-11.314.5.5 0 0 1 .707.707zm2.122 2.122a4 4 0 0 0 0 5.656.5.5 0 1 1-.708.708 5 5 0 0 1 0-7.072.5.5 0 0 1 .708.708zm5.656-.708a.5.5 0 0 1 .708 0 5 5 0 0 1 0 7.072.5.5 0 1 1-.708-.708 4 4 0 0 0 0-5.656.5.5 0 0 1 0-.708zm2.122-2.12a.5.5 0 0 1 .707 0 8 8 0 0 1 0 11.313.5.5 0 0 1-.707-.707 7 7 0 0 0 0-9.9.5.5 0 0 1 0-.707zM6 8a2 2 0 1 1 2.5 1.937V15.5a.5.5 0 0 1-1 0V9.937A2 2 0 0 1 6 8z"/>
</svg>
</button>
</div>
<div class="btn-group btn-group-sm me-2" role="group" aria-label="Second group">
<div class="btn-group btn-group-sm me-2" role="group">
<button class="btn btn-secondary" id="busy_state" type="button">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-cpu" viewBox="0 0 16 16">
<path d="M5 0a.5.5 0 0 1 .5.5V2h1V.5a.5.5 0 0 1 1 0V2h1V.5a.5.5 0 0 1 1 0V2h1V.5a.5.5 0 0 1 1 0V2A2.5 2.5 0 0 1 14 4.5h1.5a.5.5 0 0 1 0 1H14v1h1.5a.5.5 0 0 1 0 1H14v1h1.5a.5.5 0 0 1 0 1H14v1h1.5a.5.5 0 0 1 0 1H14a2.5 2.5 0 0 1-2.5 2.5v1.5a.5.5 0 0 1-1 0V14h-1v1.5a.5.5 0 0 1-1 0V14h-1v1.5a.5.5 0 0 1-1 0V14h-1v1.5a.5.5 0 0 1-1 0V14A2.5 2.5 0 0 1 2 11.5H.5a.5.5 0 0 1 0-1H2v-1H.5a.5.5 0 0 1 0-1H2v-1H.5a.5.5 0 0 1 0-1H2v-1H.5a.5.5 0 0 1 0-1H2A2.5 2.5 0 0 1 4.5 2V.5A.5.5 0 0 1 5 0zm-.5 3A1.5 1.5 0 0 0 3 4.5v7A1.5 1.5 0 0 0 4.5 13h7a1.5 1.5 0 0 0 1.5-1.5v-7A1.5 1.5 0 0 0 11.5 3h-7zM5 6.5A1.5 1.5 0 0 1 6.5 5h3A1.5 1.5 0 0 1 11 6.5v3A1.5 1.5 0 0 1 9.5 11h-3A1.5 1.5 0 0 1 5 9.5v-3zM6.5 6a.5.5 0 0 0-.5.5v3a.5.5 0 0 0 .5.5h3a.5.5 0 0 0 .5-.5v-3a.5.5 0 0 0-.5-.5h-3z"/>
</svg>
</button>
</div>
<div class="btn-group btn-group-sm me-2" role="group" aria-label="Second group">
<div class="btn-group btn-group-sm me-2" role="group">
<button class="btn btn-secondary" id="arq_state" type="button">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-left-right" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M1 11.5a.5.5 0 0 0 .5.5h11.793l-3.147 3.146a.5.5 0 0 0 .708.708l4-4a.5.5 0 0 0 0-.708l-4-4a.5.5 0 0 0-.708.708L13.293 11H1.5a.5.5 0 0 0-.5.5zm14-7a.5.5 0 0 1-.5.5H2.707l3.147 3.146a.5.5 0 1 1-.708.708l-4-4a.5.5 0 0 1 0-.708l4-4a.5.5 0 1 1 .708.708L2.707 4H14.5a.5.5 0 0 1 .5.5z"/>
</svg>
</button>
</div>
<div class="btn-group btn-group-sm" role="group" aria-label="Third group">
<div class="btn-group btn-group-sm" role="group">
<button class="btn btn-secondary" id="signalling_state" type="button">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-journal-code" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M8.646 5.646a.5.5 0 0 1 .708 0l2 2a.5.5 0 0 1 0 .708l-2 2a.5.5 0 0 1-.708-.708L10.293 8 8.646 6.354a.5.5 0 0 1 0-.708zm-1.292 0a.5.5 0 0 0-.708 0l-2 2a.5.5 0 0 0 0 .708l2 2a.5.5 0 0 0 .708-.708L5.707 8l1.647-1.646a.5.5 0 0 0 0-.708z"/>
@ -974,6 +953,98 @@
<script src="waterfall/spectrum.js"></script>
<script src="waterfall/spectrogram.js"></script>
<!--<script src="waterfall/script.js"></script>-->
<div class="modal fade" data-bs-backdrop="static" tabindex="-1" id="advancedHamlibSettingsModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Hamlib advanced settings</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="input-group input-group-sm mb-1">
<span class="input-group-text" id="basic-addon1">Port</span>
<select class="form-select form-select-sm" aria-label=".form-select-sm" id="hamlib_deviceport_advanced">
<!--<option selected value="/dev/ttyUSB0">/dev/ttyUSB0</option>
<option value="/dev/ttyUSB1">/dev/ttyUSB1</option>-->
</select>
</div>
<div class="input-group input-group-sm mb-1">
<span class="input-group-text" id="basic-addon1">PTT</span>
<select class="form-select form-select-sm" aria-label=".form-select-sm" id="hamlib_ptt_protocol_advanced" style="width: 0.5rem">
<option value="RIG">RIG</option>
<option value="RTS">Serial RTS</option>
<option value="DTR-H">Serial DTR-High</option>
<option value="DTR-H">Serial DTR-Low</option>
<option value="PARALLEL">Rig PARALLEL</option>
<option value="MICDATA">Rig MICDATA</option>
<option value="CM108">Rig CM108</option>
</select>
</div>
<div class="input-group input-group-sm mb-1">
<span class="input-group-text" id="basic-addon1">Speed</span>
<select class="form-select form-select-sm" aria-label=".form-select-sm" id="hamlib_serialspeed_advanced">
<option value="1200">1200</option>
<option value="2400">2400</option>
<option value="4800">4800</option>
<option selected value="9600">9600</option>
<option value="14400">14400</option>
<option value="19200">19200</option>
<option value="28800">28800</option>
<option value="38400">38400</option>
<option value="57600">57600</option>
<option value="115200">115200</option>
</select>
</div>
<div class="input-group input-group-sm mb-1">
<span class="input-group-text" id="basic-addon1">Data bits</span>
<select class="form-select form-select-sm" aria-label=".form-select-sm" id="hamlib_databits_advanced">
<option value="7">7</option>
<option value="8">8 (Default)</option>
</select>
</div>
<div class="input-group input-group-sm mb-1">
<span class="input-group-text" id="basic-addon1">Stop bits</span>
<select class="form-select form-select-sm" aria-label=".form-select-sm" id="hamlib_stopbits_advanced">
<option value="1">1 (Default)</option>
<option value="2">2</option>
</select>
</div>
<div class="input-group input-group-sm mb-1">
<span class="input-group-text" id="basic-addon1">Handshake</span>
<select class="form-select form-select-sm" aria-label=".form-select-sm" id="hamlib_handshake_advanced">
<option value="None">None (Default)</option>
</select>
</div>
<div class="input-group input-group-sm mb-1">
<span class="input-group-text" id="basic-addon1">PTT Port</span>
<select class="form-select form-select-sm" aria-label=".form-select-sm" id="hamlib_ptt_port_advanced">
<!--<option selected value="/dev/ttyUSB0">/dev/ttyUSB0</option>
<option value="/dev/ttyUSB1">/dev/ttyUSB1</option>-->
</select>
</div>
<div class="input-group input-group-sm mb-1">
<span class="input-group-text" id="basic-addon1">PTT Speed</span>
<select class="form-select form-select-sm" aria-label=".form-select-sm" id="hamlib_pttspeed_advanced">
<option value="1200">1200</option>
<option value="2400">2400</option>
<option value="4800">4800</option>
<option selected value="9600">9600</option>
<option value="14400">14400</option>
<option value="19200">19200</option>
<option value="28800">28800</option>
<option value="38400">38400</option>
<option value="57600">57600</option>
<option value="115200">115200</option>
</select>
</div>
</div>
<div class="modal-footer">
<button type="button" id="testHamlibAdvanced"class="btn btn-sm btn-outline-secondary">Test settings</button>
<button type="button" class="btn btn-sm btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</body>
</html>

View file

@ -20,6 +20,20 @@ import serial.tools.list_ports
import pyaudio
import static
import crcengine
# sys.path.append("hamlib/linux")
try:
import Hamlib
print("running Hamlib from Sys Path")
except ImportError:
from hamlib.linux import Hamlib
print("running Hamlib from precompiled bundle")
else:
# place for rigctld
pass
crc_algorithm = crcengine.new('crc16-ccitt-false') # load crc8 library
@ -96,12 +110,9 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
rx_audio = str(received_json["parameter"][0]["rx_audio"])
tx_audio = str(received_json["parameter"][0]["tx_audio"])
deviceid = str(received_json["parameter"][0]["deviceid"])
deviceport = str(
received_json["parameter"][0]["deviceport"])
serialspeed = str(
received_json["parameter"][0]["serialspeed"])
pttprotocol = str(
received_json["parameter"][0]["pttprotocol"])
deviceport = str(received_json["parameter"][0]["deviceport"])
serialspeed = str(received_json["parameter"][0]["serialspeed"])
pttprotocol = str(received_json["parameter"][0]["pttprotocol"])
pttport = str(received_json["parameter"][0]["pttport"])
print("---- STARTING TNC !")
print(received_json["parameter"][0])
@ -203,6 +214,104 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
jsondata = json.dumps(data)
self.request.sendall(bytes(jsondata, encoding))
if received_json["type"] == 'GET' and received_json["command"] == 'TEST_HAMLIB':
print(received_json["parameter"])
deviceid = str(received_json["parameter"][0]["deviceid"])
deviceport = str(received_json["parameter"][0]["deviceport"])
serialspeed = str(received_json["parameter"][0]["serialspeed"])
pttprotocol = str(received_json["parameter"][0]["pttprotocol"])
pttport = str(received_json["parameter"][0]["pttport"])
pttspeed = str(received_json["parameter"][0]["pttspeed"])
data_bits = str(received_json["parameter"][0]["data_bits"])
stop_bits = str(received_json["parameter"][0]["stop_bits"])
handshake = str(received_json["parameter"][0]["handshake"])
print(deviceid)
print(deviceport)
print(serialspeed)
print(pttprotocol)
print(pttport)
print(pttspeed)
print(data_bits)
print(stop_bits)
print(handshake)
# try to init hamlib
try:
Hamlib.rig_set_debug(Hamlib.RIG_DEBUG_NONE)
my_rig = Hamlib.Rig(int(deviceid))
my_rig.set_conf("rig_pathname", deviceport)
my_rig.set_conf("retry", "1")
my_rig.set_conf("serial_speed", serialspeed)
my_rig.set_conf("serial_handshake", handshake)
my_rig.set_conf("stop_bits", stop_bits)
my_rig.set_conf("data_bits", data_bits)
if pttprotocol == 'RIG':
hamlib_ptt_type = Hamlib.RIG_PTT_RIG
elif pttprotocol == 'DTR-H':
hamlib_ptt_type = Hamlib.RIG_PTT_SERIAL_DTR
my_rig.set_conf("dtr_state", "HIGH")
my_rig.set_conf("ptt_type", "DTR")
elif pttprotocol == 'DTR-L':
hamlib_ptt_type = Hamlib.RIG_PTT_SERIAL_DTR
my_rig.set_conf("dtr_state", "LOW")
my_rig.set_conf("ptt_type", "DTR")
elif pttprotocol == 'RTS':
hamlib_ptt_type = Hamlib.RIG_PTT_SERIAL_RTS
my_rig.set_conf("dtr_state", "OFF")
my_rig.set_conf("ptt_type", "RTS")
elif pttprotocol == 'PARALLEL':
hamlib_ptt_type = Hamlib.RIG_PTT_PARALLEL
elif pttprotocol == 'MICDATA':
hamlib_ptt_type = Hamlib.RIG_PTT_RIG_MICDATA
elif pttprotocol == 'CM108':
hamlib_ptt_type = Hamlib.RIG_PTT_CM108
else: # static.HAMLIB_PTT_TYPE == 'RIG_PTT_NONE':
hamlib_ptt_type = Hamlib.RIG_PTT_NONE
my_rig.open()
my_rig.set_ptt(hamlib_ptt_type, 1)
pttstate = my_rig.get_ptt()
if pttstate == 1:
print("PTT SUCCESS")
data = {'COMMAND': 'TEST_HAMLIB', 'RESULT': 'SUCCESS'}
elif pttstate == 0:
print("PTT NO SUCCESS")
data = {'COMMAND': 'TEST_HAMLIB', 'RESULT': 'NOSUCCESS'}
else:
print("HAMLIB FAILED")
data = {'COMMAND': 'TEST_HAMLIB', 'RESULT': 'FAILED'}
my_rig.set_ptt(hamlib_ptt_type, 0)
my_rig.close
jsondata = json.dumps(data)
self.request.sendall(bytes(jsondata, encoding))
except:
print("Unexpected error:", sys.exc_info()[0])
print("can't open rig")
#sys.exit("hamlib error")
# exception, if JSON cant be decoded
# except Exception as e:
except ValueError as e: