Skip to content

Commit 1464a0f

Browse files
authored
Merge pull request #96 from int2001/rm_split
Fix HamLib bug for ModeChange
2 parents 23a50b2 + 6a6d59e commit 1464a0f

File tree

3 files changed

+36
-9
lines changed

3 files changed

+36
-9
lines changed

main.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -633,10 +633,25 @@ function broadcastRadioStatus(radioData) {
633633

634634
async function get_modes() {
635635
return new Promise((resolve) => {
636-
ipcMain.once('get_info_result', (event, modes) => {
637-
resolve(modes);
638-
});
639-
s_mainWindow.webContents.send('get_info', 'rig.get_modes');
636+
// Check which radio type is enabled
637+
const profile = defaultcfg.profiles[defaultcfg.profile ?? 0];
638+
639+
if (profile.hamlib_ena) {
640+
// For Hamlib, send the command directly
641+
ipcMain.once('get_info_result', (event, modes) => {
642+
resolve(modes ?? ['CW','LSB','USB']);
643+
});
644+
s_mainWindow.webContents.send('get_info', 'rig.get_modes');
645+
} else if (profile.flrig_ena) {
646+
// For FLRig, use the existing method
647+
ipcMain.once('get_info_result', (event, modes) => {
648+
resolve(modes ?? ['CW','LSB','USB']);
649+
});
650+
s_mainWindow.webContents.send('get_info', 'rig.get_modes');
651+
} else {
652+
// No radio control enabled, return default modes
653+
resolve(['CW','LSB','USB']);
654+
}
640655
});
641656
}
642657

@@ -719,7 +734,7 @@ async function settrx(qrg, mode = '') {
719734
const client = net.createConnection({ host: defaultcfg.profiles[defaultcfg.profile ?? 0].hamlib_host, port: defaultcfg.profiles[defaultcfg.profile ?? 0].hamlib_port }, () => {
720735
client.write("F " + to.qrg + "\n");
721736
if (defaultcfg.profiles[defaultcfg.profile ?? 0].wavelog_pmode) {
722-
client.write("M " + to.mode + "\n-1");
737+
client.write("M " + to.mode + " 0\n");
723738
}
724739
client.end();
725740
});

package.json

Lines changed: 1 addition & 1 deletion
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.12",
7+
"version": "1.1.13",
88
"author": "DJ7NT",
99
"scripts": {
1010
"start": "electron-forge start",

renderer.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,14 +312,20 @@ async function getInfo(which) {
312312
}
313313
}
314314
if (cfg.profiles[active_cfg].hamlib_ena) {
315-
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};
315+
var commands = {"rig.get_vfo": "f", "rig.get_mode": "m", "rig.get_modes": "M ? 0", "rig.get_ptt": 0, "rig.get_power": 0, "rig.get_split": 0, "rig.get_vfoB": 0, "rig.get_modeB": 0};
316316

317317
const host = cfg.profiles[active_cfg].hamlib_host;
318318
const port = parseInt(cfg.profiles[active_cfg].hamlib_port, 10);
319319

320320
return new Promise((resolve, reject) => {
321321
if (commands[which]) {
322-
const client = net.createConnection({ host, port }, () => client.write(commands[which]));
322+
const client = net.createConnection({ host, port }, () => {
323+
if (which === 'rig.get_modes') {
324+
client.write(commands[which] + "\n");
325+
} else {
326+
client.write(commands[which]);
327+
}
328+
});
323329

324330
// Track the connection for cleanup
325331
activeConnections.add(client);
@@ -329,7 +335,13 @@ async function getInfo(which) {
329335
if(data.startsWith("RPRT")){
330336
reject();
331337
} else {
332-
resolve(data.split('\n')[0]);
338+
if (which === 'rig.get_modes') {
339+
// Parse modes list - split by whitespace and filter empty strings
340+
const modes = data.trim().split(/\s+/).filter(mode => mode.length > 0);
341+
resolve(modes);
342+
} else {
343+
resolve(data.split('\n')[0]);
344+
}
333345
}
334346
client.end();
335347
});

0 commit comments

Comments
 (0)