Skip to content

Commit 35e8a5c

Browse files
authored
Improve digimode configuration (#492)
* use DIGIMODE if FLDIGI is set * use rig_parse_mode() for DIGI_RIG_MODE this value is transparent to TLF, let Hamlib do the parsing allowing any supported mode * add DIGITAL_MODE configuration for ADIF export it's value is used in the MODE tag reused and renamed modem_mode variable (it was used for RTTY only) * use RY/DG for digimode in cabrillo depending on DIGITAL_MODE
1 parent 4b3c584 commit 35e8a5c

8 files changed

Lines changed: 66 additions & 41 deletions

File tree

src/gettxinfo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ void gettxinfo(void) {
250250
}
251251

252252
} else if (reqf == SETDIGIMODE) {
253-
rmode_t new_mode = digi_mode;
253+
rmode_t new_mode = digi_rig_mode;
254254
if (new_mode == RIG_MODE_NONE) {
255255
if (digikeyer == FLDIGI)
256256
new_mode = RIG_MODE_USB;

src/globalvars.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ extern int new_cty;
130130
extern int new_zone;
131131
extern bool new_pfx;
132132
extern bool no_rst;
133-
extern rmode_t digi_mode;
133+
extern rmode_t digi_rig_mode;
134134
extern int minitest; // minitest period length in seconds, 0 if not used
135135
extern int portnum;
136136
extern int lan_port;
@@ -222,7 +222,7 @@ extern char markerfile[];
222222
extern char countrylist[255][6];
223223
extern char continent_multiplier_list[7][3];
224224
extern char controllerport[]; // port for multi-mode controller
225-
extern char modem_mode[];
225+
extern char digital_mode[];
226226
extern char sc_volume[];
227227
extern char clusterlogin[];
228228
extern char rigconf[];

src/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ bool keyer_backspace = false; // disabled
316316

317317
char controllerport[80] = "/dev/ttyS0"; // for GMFSK or MFJ-1278
318318
char rttyoutput[120]; // where to GMFSK digimode output
319-
rmode_t digi_mode = RIG_MODE_NONE;
319+
rmode_t digi_rig_mode = RIG_MODE_NONE;
320320

321321
int txdelay = 0;
322322
int weight = 0;
@@ -326,7 +326,7 @@ int k_pin14 = 0;
326326
int k_ptt = 0;
327327

328328
int miniterm = 0; /* is miniterm for digimode active? */
329-
char modem_mode[8];
329+
char digital_mode[8];
330330
int commentfield = 0; /* 1 if we are in comment/exchange input */
331331

332332
/*-------------------------------------packet-------------------------------*/

src/parse_logcfg.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,7 @@ static int cfg_gmfsk(const cfg_arg_t arg) {
10331033
return rc;
10341034
}
10351035
digikeyer = GMFSK;
1036+
trxmode = DIGIMODE;
10361037
return PARSE_OK;
10371038
}
10381039

@@ -1060,7 +1061,7 @@ static int cfg_change_rst(const cfg_arg_t arg) {
10601061

10611062
static int cfg_rttymode(const cfg_arg_t arg) {
10621063
trxmode = DIGIMODE;
1063-
strcpy(modem_mode, "RTTY");
1064+
strcpy(digital_mode, "RTTY");
10641065
return PARSE_OK;
10651066
}
10661067

@@ -1183,6 +1184,7 @@ static int cfg_fldigi(const cfg_arg_t arg) {
11831184
if (!fldigi_isenabled()) {
11841185
fldigi_toggle();
11851186
}
1187+
trxmode = DIGIMODE;
11861188
#endif
11871189

11881190
return PARSE_OK;
@@ -1242,17 +1244,11 @@ static int cfg_digi_rig_mode(const cfg_arg_t arg) {
12421244
char *str = g_ascii_strup(parameter, -1);
12431245
g_strstrip(str);
12441246

1245-
if (strcmp(str, "USB") == 0) {
1246-
digi_mode = RIG_MODE_USB;
1247-
} else if (strcmp(str, "LSB") == 0) {
1248-
digi_mode = RIG_MODE_LSB;
1249-
} else if (strcmp(str, "RTTY") == 0) {
1250-
digi_mode = RIG_MODE_RTTY;
1251-
} else if (strcmp(str, "RTTYR") == 0) {
1252-
digi_mode = RIG_MODE_RTTYR;
1253-
} else {
1247+
digi_rig_mode = rig_parse_mode(str);
1248+
1249+
if (digi_rig_mode == RIG_MODE_NONE) {
1250+
error_details = g_strdup_printf("invalid mode %s", str);
12541251
g_free(str);
1255-
error_details = g_strdup("must be USB, LSB, RTTY, or RTTYR");
12561252
return PARSE_WRONG_PARAMETER;
12571253
}
12581254

@@ -1419,6 +1415,7 @@ static config_t logcfg_configs[] = {
14191415
{"SYNCFILE", CFG_STRING_STATIC(synclogfile, 120)},
14201416
{"INITIAL_EXCHANGE", CFG_STRING_STATIC(exchange_list, 40)},
14211417
{"DIGIMODEM", CFG_STRING_STATIC(rttyoutput, 120)},
1418+
{"DIGITAL_MODE", CFG_STRING_STATIC(digital_mode, 8)},
14221419
{"FKEY-HEADER", CFG_STRING_STATIC(fkey_header, sizeof(fkey_header))},
14231420

14241421
{"CABRILLO", CFG_STRING(cabrillo)},

src/writecabrillo.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,17 @@ void info(char *s) {
243243
}
244244

245245

246-
const char *to_mode[] = {
247-
"CW",
248-
"PH",
249-
"RY"
246+
static const char *cabrillo_mode(int mode) {
247+
if (mode == CWMODE)
248+
return "CW";
249+
if (mode == SSBMODE)
250+
return "PH";
251+
252+
// for digimode: either RY for RTTY or else DG for generic digital mode
253+
if (strcmp(digital_mode, "RTTY") == 0)
254+
return "RY";
255+
256+
return "DG";
250257
};
251258

252259
/* add 'src' to 'dst' with max. 'len' chars left padded */
@@ -364,7 +371,7 @@ void prepare_line(struct linedata_t *qso, struct cabrillo_desc *desc,
364371
add_lpadded(buf, tmp, item->len);
365372
break;
366373
case MODE:
367-
sprintf(tmp, "%s", to_mode[qso->mode]);
374+
sprintf(tmp, "%s", cabrillo_mode(qso->mode));
368375
add_lpadded(buf, tmp, item->len);
369376
break;
370377
case DATE:
@@ -731,8 +738,8 @@ void prepare_adif_line(char *buffer, struct linedata_t *qso) {
731738
tmp = "CW";
732739
else if (qso->mode == SSBMODE)
733740
tmp = "SSB";
734-
else if (strcmp(modem_mode, "RTTY") == 0)
735-
tmp = "RTTY";
741+
else if (digital_mode[0])
742+
tmp = digital_mode;
736743
else
737744
/* \todo DIGI is no allowed mode */
738745
tmp = "DIGI";

test/data.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ int multi = 0; /* 0 = SO , 1 = MOST, 2 = MM */
138138
int trxmode = CWMODE;
139139
/* RIG_MODE_NONE in hamlib/rig.h, but if hamlib not compiled, then no dependency */
140140
rmode_t rigmode = 0;
141-
rmode_t digi_mode = 0;
141+
rmode_t digi_rig_mode = 0;
142142
bool mixedmode = false;
143143
char sent_rst[4] = "599";
144144
char recvd_rst[4] = "599";
@@ -288,7 +288,7 @@ int k_pin14;
288288
int k_ptt;
289289
char controllerport[80] = "/dev/ttyS0";
290290
int miniterm = 0; /* is miniterm for digimode active? */
291-
char modem_mode[8];
291+
char digital_mode[8];
292292
int commentfield = 0; /* 1 if we are in comment/exchange input */
293293

294294
/*-------------------------------------packet-------------------------------*/

test/test_parse_logcfg.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ int setup_default(void **state) {
201201
markerfile[0] = 0;
202202
synclogfile[0] = 0;
203203
sc_volume[0] = 0;
204-
modem_mode[0] = 0;
204+
digital_mode[0] = 0;
205205
controllerport[0] = 0;
206206
clusterlogin[0] = 0;
207207
exchange_list[0] = 0;
@@ -211,7 +211,7 @@ int setup_default(void **state) {
211211
qtcrec_record_command_shutdown[0] = 0;
212212
unique_call_multi = MULT_NONE;
213213
generic_mult = MULT_NONE;
214-
digi_mode = -1;
214+
digi_rig_mode = -1;
215215

216216
for (int i = 0; i < SP_CALL_MSG; ++i) {
217217
message[i][0] = 0;
@@ -1300,14 +1300,21 @@ void test_gmfsk(void **state) {
13001300
int rc = call_parse_logcfg("GMFSK=jkl\n");
13011301
assert_int_equal(rc, PARSE_OK);
13021302
assert_int_equal(digikeyer, GMFSK);
1303+
assert_int_equal(trxmode, DIGIMODE);
13031304
assert_string_equal(controllerport, "jkl");
13041305
}
13051306

13061307
void test_rttymode(void **state) {
13071308
int rc = call_parse_logcfg("RTTYMODE\n");
13081309
assert_int_equal(rc, PARSE_OK);
13091310
assert_int_equal(trxmode, DIGIMODE);
1310-
assert_string_equal(modem_mode, "RTTY");
1311+
assert_string_equal(digital_mode, "RTTY");
1312+
}
1313+
1314+
void test_digital_mode(void **state) {
1315+
int rc = call_parse_logcfg("DIGITAL_MODE=PSK\n");
1316+
assert_int_equal(rc, PARSE_OK);
1317+
assert_string_equal(digital_mode, "PSK");
13111318
}
13121319

13131320
void test_digimodem(void **state) {
@@ -1521,25 +1528,25 @@ void test_generic_mult_band(void **state) {
15211528
void test_digi_rig_mode_usb(void **state) {
15221529
int rc = call_parse_logcfg("DIGI_RIG_MODE=USB");
15231530
assert_int_equal(rc, PARSE_OK);
1524-
assert_int_equal(digi_mode, RIG_MODE_USB);
1531+
assert_int_equal(digi_rig_mode, RIG_MODE_USB);
15251532
}
15261533

15271534
void test_digi_rig_mode_lsb(void **state) {
15281535
int rc = call_parse_logcfg("DIGI_RIG_MODE=LSB");
15291536
assert_int_equal(rc, PARSE_OK);
1530-
assert_int_equal(digi_mode, RIG_MODE_LSB);
1537+
assert_int_equal(digi_rig_mode, RIG_MODE_LSB);
15311538
}
15321539

15331540
void test_digi_rig_mode_rtty(void **state) {
15341541
int rc = call_parse_logcfg("DIGI_RIG_MODE=RTTY");
15351542
assert_int_equal(rc, PARSE_OK);
1536-
assert_int_equal(digi_mode, RIG_MODE_RTTY);
1543+
assert_int_equal(digi_rig_mode, RIG_MODE_RTTY);
15371544
}
15381545

15391546
void test_digi_rig_mode_rttyr(void **state) {
15401547
int rc = call_parse_logcfg("DIGI_RIG_MODE=RTTYR");
15411548
assert_int_equal(rc, PARSE_OK);
1542-
assert_int_equal(digi_mode, RIG_MODE_RTTYR);
1549+
assert_int_equal(digi_rig_mode, RIG_MODE_RTTYR);
15431550
}
15441551

15451552
void test_band40_ok(void **state) {

tlf.1.in

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ Restore previous CQ frequency from MEM and send message
996996
.
997997
.TP
998998
.B F2-F11
999-
Send CW, RTTY or VOICE messages 2 through 11. If the callsign field is empty
999+
Send CW, digital or voice messages 2 through 11. If the callsign field is empty
10001000
the messages will be sent with the preceding qso data.
10011001
.
10021002
.TP
@@ -1079,7 +1079,7 @@ instead.
10791079
.BR ?\ (Query)
10801080
In CW or DIGIMODE sends the partial call followed by \(lq ?\(rq.
10811081
.
1082-
In VOICE mode sends recorded message 5 (F5).
1082+
In voice mode sends recorded message 5 (F5).
10831083
.
10841084
.TP
10851085
.BR ;\ (Semicolon)
@@ -1135,11 +1135,11 @@ Confirm last exchange.
11351135
.
11361136
.TP
11371137
.BR {\ "(Open brace)"
1138-
In RTTY (DIGIMODE), keyboard mode switch TX on.
1138+
In digital mode, keyboard mode switch TX on.
11391139
.
11401140
.TP
11411141
.BR }\ "(Close brace)"
1142-
In RTTY (DIGIMODE), keyboard mode switch TX off (RX).
1142+
In digital mode, keyboard mode switch TX off (RX).
11431143
.
11441144
.TP
11451145
.BR \e\ (Backslash)
@@ -1163,11 +1163,11 @@ Pop MEM frequency: MEM \(-> transceiver VFO frequency and clear MEM.
11631163
Swap transceiver VFO frequency and MEM.
11641164
.
11651165
.TP
1166-
.B ^ (Circumflex, mnemonic: arrow)
1166+
.B ^ \fR(Circumflex, mnemonic: arrow)
11671167
Rotate antenna towards the country of the current call, if a rotator is configured.
11681168
.
11691169
.TP
1170-
.B & (Ampersand)
1170+
.BR &\ (Ampersand)
11711171
Rotate antenna long-path towards the country of the current call, if a rotator is configured.
11721172
(This is 180° opposite of the short-path direction.)
11731173
.
@@ -1748,7 +1748,11 @@ Start @PACKAGE_NAME@ in SSB mode (default is CW).
17481748
.
17491749
.TP
17501750
.B RTTYMODE
1751-
Start @PACKAGE_NAME@ in RTTY mode (default is CW)
1751+
Start @PACKAGE_NAME@ in digital mode (default is CW)
1752+
assuming RTTY modulation (see
1753+
.BR DIGITAL_MODE ).
1754+
.
1755+
The radio mode (\fBDIGI_RIG_MODE\fR) is not affected.
17521756
.
17531757
.TP
17541758
\fBGMFSK\fR=\fI$HOME/gMFSK.log\fR
@@ -2115,11 +2119,21 @@ mode is selected.
21152119
.
21162120
.IP
21172121
.I mode
2118-
may be one of \(lqUSB\(rq, \(lqLSB\(rq, \(lqRTTY\(rq, or \(lqRTTYR\(rq.
2122+
may be \(lqUSB\(rq, \(lqLSB\(rq, \(lqRTTY\(rq,
2123+
or any radio mode supported by Hamlib.
21192124
.
21202125
If this parameter is not set, \(lqUSB\(rq is used if the Fldigi parameter is
21212126
set else \(lqLSB\(rq is used.
21222127
.
2128+
.TP
2129+
\fBDIGITAL_MODE\fR=\fImode\fR
2130+
The digital mode (modulation type) to be used as MODE in ADIF export.
2131+
.
2132+
.IP
2133+
If this parameter is not set, then the non-ADIF compliant generic
2134+
\(lqDIGI\(rq is used. The user shall then edit the ADIF file to match
2135+
the actually used mode or modes.
2136+
.
21232137
.SS Rotator Control Commands
21242138
.
21252139
.TP
@@ -2575,7 +2589,7 @@ If you work RTTY (or any other digital modes), you can communicate with Fldigi
25752589
through
25762590
.BR XMLRPC .
25772591
.
2578-
This parameter activates the interface.
2592+
This parameter activates the interface and sets start-up mode to DIGIMODE.
25792593
.
25802594
.IP
25812595
By default @PACKAGE_NAME@ connects to:

0 commit comments

Comments
 (0)