Skip to content

Commit 2e33717

Browse files
committed
Issue 569 - MODEM AIS doesn't work as -B AIS.
1 parent c99e842 commit 2e33717

File tree

6 files changed

+33
-17
lines changed

6 files changed

+33
-17
lines changed

src/atest.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,10 @@ int main (int argc, char *argv[])
278278
/* Also implies modem type based on speed. */
279279
/* Special cases AIS, EAS rather than number. */
280280
if (strcasecmp(optarg, "AIS") == 0) {
281-
B_opt = 0xA15A15; // See special case below.
281+
B_opt = BAUD_SENTINEL_AIS; // See special case below.
282282
}
283283
else if (strcasecmp(optarg, "EAS") == 0) {
284-
B_opt = 0xEA5EA5; // See special case below.
284+
B_opt = BAUD_SENTINEL_EAS; // See special case below.
285285
}
286286
else {
287287
B_opt = atoi(optarg);
@@ -458,14 +458,14 @@ int main (int argc, char *argv[])
458458
my_audio_config.achan[0].space_freq = 0;
459459
strlcpy (my_audio_config.achan[0].profiles, "", sizeof(my_audio_config.achan[0].profiles));
460460
}
461-
else if (my_audio_config.achan[0].baud == 0xA15A15) { // Hack for different use of 9600
461+
else if (my_audio_config.achan[0].baud == BAUD_SENTINEL_AIS) { // Hack for different use of 9600
462462
my_audio_config.achan[0].modem_type = MODEM_AIS;
463463
my_audio_config.achan[0].baud = 9600;
464464
my_audio_config.achan[0].mark_freq = 0;
465465
my_audio_config.achan[0].space_freq = 0;
466466
strlcpy (my_audio_config.achan[0].profiles, " ", sizeof(my_audio_config.achan[0].profiles)); // avoid getting default later.
467467
}
468-
else if (my_audio_config.achan[0].baud == 0xEA5EA5) {
468+
else if (my_audio_config.achan[0].baud == BAUD_SENTINEL_EAS) {
469469
my_audio_config.achan[0].modem_type = MODEM_EAS;
470470
my_audio_config.achan[0].baud = 521; // Actually 520.83 but we have an integer field here.
471471
// Will make more precise in afsk demod init.

src/audio.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,16 @@ struct audio_s {
479479
//#define MAX_BAUD 10000
480480
#define MAX_BAUD 40000 // Anyone want to try 38.4 k baud?
481481

482+
// When command line -B or config file MODEM has AIS or EAS,
483+
// we store a special reserved value at that point and select
484+
// the proper mode and actual speed later.
485+
// It should probably be outside the min-max range but we would
486+
// have more checking and testing to do.
487+
488+
#define BAUD_SENTINEL_AIS (MAX_BAUD-1)
489+
#define BAUD_SENTINEL_EAS (MAX_BAUD-2)
490+
491+
482492
/*
483493
* Typical transmit timings for VHF.
484494
*/

src/config.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,17 +1465,17 @@ void config_init (char *fname, struct audio_s *p_audio_config,
14651465
continue;
14661466
}
14671467
if (strcasecmp(t,"AIS") == 0) {
1468-
n = MAX_BAUD-1; // Hack - See special case later.
1468+
n = BAUD_SENTINEL_AIS; // Hack - See special case later.
14691469
}
14701470
else if (strcasecmp(t,"EAS") == 0) {
1471-
n = MAX_BAUD-2; // Hack - See special case later.
1471+
n = BAUD_SENTINEL_EAS; // Hack - See special case later.
14721472
}
14731473
else {
14741474
n = atoi(t);
14751475
}
14761476
if (n >= MIN_BAUD && n <= MAX_BAUD) {
14771477
p_audio_config->achan[channel].baud = n;
1478-
if (n != 300 && n != 1200 && n != 2400 && n != 4800 && n != 9600 && n != 19200 && n != MAX_BAUD-1 && n != MAX_BAUD-2) {
1478+
if (n != 300 && n != 1200 && n != 2400 && n != 4800 && n != 9600 && n != 19200 && n != BAUD_SENTINEL_AIS && n != BAUD_SENTINEL_EAS) {
14791479
text_color_set(DW_COLOR_ERROR);
14801480
dw_printf ("Line %d: Warning: Non-standard data rate of %d bits per second. Are you sure?\n", line, n);
14811481
}
@@ -1514,21 +1514,22 @@ void config_init (char *fname, struct audio_s *p_audio_config,
15141514
p_audio_config->achan[channel].mark_freq = 0;
15151515
p_audio_config->achan[channel].space_freq = 0;
15161516
}
1517-
else if (p_audio_config->achan[channel].baud == MAX_BAUD-1) {
1517+
else if (p_audio_config->achan[channel].baud == BAUD_SENTINEL_AIS) {
15181518
p_audio_config->achan[channel].modem_type = MODEM_AIS;
1519+
p_audio_config->achan[channel].baud = 9600;
15191520
p_audio_config->achan[channel].mark_freq = 0;
15201521
p_audio_config->achan[channel].space_freq = 0;
15211522
}
1522-
else if (p_audio_config->achan[channel].baud == MAX_BAUD-2) {
1523+
else if (p_audio_config->achan[channel].baud == BAUD_SENTINEL_EAS) {
15231524
p_audio_config->achan[channel].modem_type = MODEM_EAS;
15241525
p_audio_config->achan[channel].baud = 521; // Actually 520.83 but we have an integer field here.
15251526
// Will make more precise in afsk demod init.
15261527
p_audio_config->achan[channel].mark_freq = 2083; // Actually 2083.3 - logic 1.
15271528
p_audio_config->achan[channel].space_freq = 1563; // Actually 1562.5 - logic 0.
1528-
// ? strlcpy (p_audio_config->achan[channel].profiles, "A", sizeof(p_audio_config->achan[channel].profiles));
1529+
strlcpy (p_audio_config->achan[channel].profiles, "A", sizeof(p_audio_config->achan[channel].profiles));
15291530
}
15301531
else {
1531-
p_audio_config->achan[channel].modem_type = MODEM_SCRAMBLE;
1532+
p_audio_config->achan[channel].modem_type = MODEM_SCRAMBLE; // Commonly knowa as G3RUH.
15321533
p_audio_config->achan[channel].mark_freq = 0;
15331534
p_audio_config->achan[channel].space_freq = 0;
15341535
}

src/direwolf.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -483,10 +483,10 @@ int main (int argc, char *argv[])
483483
/* Also implies modem type based on speed. */
484484
/* Special case "AIS" rather than number. */
485485
if (strcasecmp(optarg, "AIS") == 0) {
486-
B_opt = 12345; // See special case below.
486+
B_opt = BAUD_SENTINEL_AIS; // See special case below.
487487
}
488488
else if (strcasecmp(optarg, "EAS") == 0) {
489-
B_opt = 23456; // See special case below.
489+
B_opt = BAUD_SENTINEL_EAS; // See special case below.
490490
}
491491
else {
492492
B_opt = atoi(optarg);
@@ -843,13 +843,13 @@ int main (int argc, char *argv[])
843843
dw_printf ("Bit rate should be standard 4800 rather than specified %d.\n", audio_config.achan[0].baud);
844844
}
845845
}
846-
else if (audio_config.achan[0].baud == 12345) {
846+
else if (audio_config.achan[0].baud == BAUD_SENTINEL_AIS) {
847847
audio_config.achan[0].modem_type = MODEM_AIS;
848848
audio_config.achan[0].baud = 9600;
849849
audio_config.achan[0].mark_freq = 0;
850850
audio_config.achan[0].space_freq = 0;
851851
}
852-
else if (audio_config.achan[0].baud == 23456) {
852+
else if (audio_config.achan[0].baud == BAUD_SENTINEL_EAS) {
853853
audio_config.achan[0].modem_type = MODEM_EAS;
854854
audio_config.achan[0].baud = 521; // Actually 520.83 but we have an integer field here.
855855
// Will make more precise in afsk demod init.

src/direwolf.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
#define _WIN32_WINNT 0x0501 /* Minimum OS version is XP. */
3333
#define WINVER 0x0501 /* Minimum OS version is XP. */
3434

35+
// Other values are in Windows SDK sdkddkver.h
36+
// 0x0600 - Windows Vista
37+
// 0x0601 - Windows 7
38+
// 0x0A00 - Windows 10
39+
3540
#include <winsock2.h>
3641
#include <windows.h>
3742

src/gen_packets.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ int main(int argc, char **argv)
321321
// FIXME: options should not be order dependent.
322322

323323
if (strcasecmp(optarg, "EAS") == 0) {
324-
modem.achan[0].baud = 0xEA5EA5; // See special case below.
324+
modem.achan[0].baud = BAUD_SENTINEL_EAS; // See special case below.
325325
}
326326
else {
327327
modem.achan[0].baud = atoi(optarg);
@@ -338,7 +338,7 @@ int main(int argc, char **argv)
338338
modem.achan[0].mark_freq = 1615;
339339
modem.achan[0].space_freq = 1785;
340340
}
341-
else if (modem.achan[0].baud == 0xEA5EA5) {
341+
else if (modem.achan[0].baud == BAUD_SENTINEL_EAS) {
342342
modem.achan[0].baud = 521; // Fine tuned later. 520.83333
343343
// Proper fix is to make this float.
344344
modem.achan[0].modem_type = MODEM_EAS;

0 commit comments

Comments
 (0)