Skip to content

Commit 2c31746

Browse files
authored
Merge pull request #45 from wavelog/dev
Stability Fix
2 parents 7a9b1c0 + 64f2fe7 commit 2c31746

File tree

2 files changed

+30
-33
lines changed

2 files changed

+30
-33
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Gateway for connecting WSJT-* and FLRig to Wavelog",
55
"keywords": [],
66
"main": "./main.js",
7-
"version": "1.1.3",
7+
"version": "1.1.4",
88
"author": "DJ7NT",
99
"scripts": {
1010
"start": "electron-forge start",

renderer.js

+29-32
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// Shorthand for document.querySelector.
1010
var cfg={};
1111
var active_cfg=0;
12+
var trxpoll=undefined;
1213

1314
const {ipcRenderer} = require('electron')
1415
const net = require('net');
@@ -39,7 +40,6 @@ $(document).ready(function() {
3940
$("#test").removeClass('btn-success');
4041
$("#test").removeClass('btn-danger');
4142
$("#test").addClass('btn-primary');
42-
getsettrx();
4343
});
4444

4545
bt_save.addEventListener('click', async () => {
@@ -98,16 +98,6 @@ $(document).ready(function() {
9898
getStations();
9999
});
100100

101-
getsettrx();
102-
103-
$("#flrig_ena").on( "click",async function() {
104-
await getsettrx();
105-
});
106-
107-
$("#hamlib_ena").on( "click",async function() {
108-
await getsettrx();
109-
});
110-
111101
setInterval(updateUtcTime, 1000);
112102
window.onload = updateUtcTime;
113103

@@ -143,9 +133,11 @@ async function load_config() {
143133
if (cfg.profiles[active_cfg].wavelog_key != "" && cfg.profiles[active_cfg].wavelog_url != "") {
144134
getStations();
145135
}
146-
147-
136+
if (trxpoll === undefined) {
137+
getsettrx();
138+
}
148139
}
140+
149141
function resizeme(size) {
150142
x=(ipcRenderer.sendSync("resize", size))
151143
return x;
@@ -191,22 +183,26 @@ async function get_trx() {
191183

192184
async function getInfo(which) {
193185
if (cfg.profiles[active_cfg].flrig_ena){
194-
const response = await fetch(
195-
"http://"+$("#flrig_host").val()+':'+$("#flrig_port").val(), {
196-
method: 'POST',
197-
// mode: 'no-cors',
198-
headers: {
199-
'Accept': 'application/json, application/xml, text/plain, text/html, *.*',
200-
'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8'
201-
},
202-
body: '<?xml version="1.0"?><methodCall><methodName>'+which+'</methodName></methodCall>'
203-
}
204-
);
205-
const data = await response.text();
206-
var parser = new DOMParser();
207-
var xmlDoc = parser.parseFromString(data, "text/xml");
208-
var qrgplain = xmlDoc.getElementsByTagName("value")[0].textContent;
209-
return qrgplain;
186+
try {
187+
const response = await fetch(
188+
"http://"+$("#flrig_host").val()+':'+$("#flrig_port").val(), {
189+
method: 'POST',
190+
// mode: 'no-cors',
191+
headers: {
192+
'Accept': 'application/json, application/xml, text/plain, text/html, *.*',
193+
'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8'
194+
},
195+
body: '<?xml version="1.0"?><methodCall><methodName>'+which+'</methodName></methodCall>',
196+
}
197+
);
198+
const data = await response.text();
199+
var parser = new DOMParser();
200+
var xmlDoc = parser.parseFromString(data, "text/xml");
201+
var qrgplain = xmlDoc.getElementsByTagName("value")[0].textContent;
202+
return qrgplain;
203+
} catch (e) {
204+
return '';
205+
}
210206
}
211207
if (cfg.profiles[active_cfg].hamlib_ena) {
212208
var commands = {"rig.get_vfo": "f", "rig.get_mode": "m", "rig.get_ptt": 0, "rig.get_power": 0, "rig.get_split": 0, "rig.get_vfoB": 0, "rig.get_modeB": 0};
@@ -237,11 +233,12 @@ async function getInfo(which) {
237233

238234
async function getsettrx() {
239235
if ($("#flrig_ena").is(':checked') || cfg.profiles[active_cfg].hamlib_ena) {
236+
console.log('Polling TRX '+trxpoll);
240237
x=get_trx();
241-
setTimeout(() => {
242-
getsettrx();
243-
}, 1000);
244238
}
239+
trxpoll = setTimeout(() => {
240+
getsettrx();
241+
}, 1000);
245242
}
246243

247244
const isDeepEqual = (object1, object2) => {

0 commit comments

Comments
 (0)