mirror of https://github.com/wb2osz/direwolf.git
More error checking.
This commit is contained in:
parent
12abb8d91e
commit
6f0c1518c0
86
src/config.c
86
src/config.c
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// This file is part of Dire Wolf, an amateur radio packet TNC.
|
// This file is part of Dire Wolf, an amateur radio packet TNC.
|
||||||
//
|
//
|
||||||
// Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2021 John Langner, WB2OSZ
|
// Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2021, 2023 John Langner, WB2OSZ
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License as published by
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
@ -755,12 +755,13 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
||||||
strlcpy (p_audio_config->adev[adevice].adevice_out, DEFAULT_ADEVICE, sizeof(p_audio_config->adev[adevice].adevice_out));
|
strlcpy (p_audio_config->adev[adevice].adevice_out, DEFAULT_ADEVICE, sizeof(p_audio_config->adev[adevice].adevice_out));
|
||||||
|
|
||||||
p_audio_config->adev[adevice].defined = 0;
|
p_audio_config->adev[adevice].defined = 0;
|
||||||
|
p_audio_config->adev[adevice].copy_from = -1;
|
||||||
p_audio_config->adev[adevice].num_channels = DEFAULT_NUM_CHANNELS; /* -2 stereo */
|
p_audio_config->adev[adevice].num_channels = DEFAULT_NUM_CHANNELS; /* -2 stereo */
|
||||||
p_audio_config->adev[adevice].samples_per_sec = DEFAULT_SAMPLES_PER_SEC; /* -r option */
|
p_audio_config->adev[adevice].samples_per_sec = DEFAULT_SAMPLES_PER_SEC; /* -r option */
|
||||||
p_audio_config->adev[adevice].bits_per_sample = DEFAULT_BITS_PER_SAMPLE; /* -8 option for 8 instead of 16 bits */
|
p_audio_config->adev[adevice].bits_per_sample = DEFAULT_BITS_PER_SAMPLE; /* -8 option for 8 instead of 16 bits */
|
||||||
}
|
}
|
||||||
|
|
||||||
p_audio_config->adev[0].defined = 1;
|
p_audio_config->adev[0].defined = 2; // 2 means it was done by default and not the user's config file.
|
||||||
|
|
||||||
for (channel=0; channel<MAX_CHANS; channel++) {
|
for (channel=0; channel<MAX_CHANS; channel++) {
|
||||||
int ot, it;
|
int ot, it;
|
||||||
|
@ -925,10 +926,13 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
||||||
|
|
||||||
p_misc_config->maxframe_extended = AX25_K_MAXFRAME_EXTENDED_DEFAULT; /* Max frames to send before ACK. mod 128 "Window" size. */
|
p_misc_config->maxframe_extended = AX25_K_MAXFRAME_EXTENDED_DEFAULT; /* Max frames to send before ACK. mod 128 "Window" size. */
|
||||||
|
|
||||||
p_misc_config->maxv22 = AX25_N2_RETRY_DEFAULT / 3; /* Max SABME before falling back to SABM. */
|
p_misc_config->maxv22 = AX25_N2_RETRY_DEFAULT / 3; /* Send SABME this many times before falling back to SABM. */
|
||||||
p_misc_config->v20_addrs = NULL; /* Go directly to v2.0 for stations listed. */
|
p_misc_config->v20_addrs = NULL; /* Go directly to v2.0 for stations listed */
|
||||||
|
/* without trying v2.2 first. */
|
||||||
p_misc_config->v20_count = 0;
|
p_misc_config->v20_count = 0;
|
||||||
p_misc_config->noxid_addrs = NULL; /* Don't send XID to these stations. */
|
p_misc_config->noxid_addrs = NULL; /* Don't send XID to these stations. */
|
||||||
|
/* Might work with a partial v2.2 implementation */
|
||||||
|
/* on the other end. */
|
||||||
p_misc_config->noxid_count = 0;
|
p_misc_config->noxid_count = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1012,7 +1016,11 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
||||||
* ADEVICE plughw:1,0 -- same for in and out.
|
* ADEVICE plughw:1,0 -- same for in and out.
|
||||||
* ADEVICE plughw:2,0 plughw:3,0 -- different in/out for a channel or channel pair.
|
* ADEVICE plughw:2,0 plughw:3,0 -- different in/out for a channel or channel pair.
|
||||||
* ADEVICE1 udp:7355 default -- from Software defined radio (SDR) via UDP.
|
* ADEVICE1 udp:7355 default -- from Software defined radio (SDR) via UDP.
|
||||||
*
|
*
|
||||||
|
* New in 1.8: Ability to map to another audio device.
|
||||||
|
* This allows multiple modems (i.e. data speeds) on the same audio interface.
|
||||||
|
*
|
||||||
|
* ADEVICEn = n -- Copy from different already defined channel.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Note that ALSA name can contain comma such as hw:1,0 */
|
/* Note that ALSA name can contain comma such as hw:1,0 */
|
||||||
|
@ -1040,17 +1048,42 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Do not allow same adevice to be defined more than once.
|
||||||
|
// Overriding the default for adevice 0 is ok.
|
||||||
|
// In that case definded was 2. That's why we check for 1, not just non-zero.
|
||||||
|
|
||||||
|
if (p_audio_config->adev[adevice].defined == 1) { // 1 means defined by user.
|
||||||
|
text_color_set(DW_COLOR_ERROR);
|
||||||
|
dw_printf ("Config file: ADEVICE%d can't be defined more than once. Line %d.\n", adevice, line);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
p_audio_config->adev[adevice].defined = 1;
|
p_audio_config->adev[adevice].defined = 1;
|
||||||
|
|
||||||
/* First channel of device is valid. */
|
|
||||||
p_audio_config->chan_medium[ADEVFIRSTCHAN(adevice)] = MEDIUM_RADIO;
|
|
||||||
|
|
||||||
strlcpy (p_audio_config->adev[adevice].adevice_in, t, sizeof(p_audio_config->adev[adevice].adevice_in));
|
// New case for release 1.8.
|
||||||
strlcpy (p_audio_config->adev[adevice].adevice_out, t, sizeof(p_audio_config->adev[adevice].adevice_out));
|
|
||||||
|
|
||||||
t = split(NULL,0);
|
if (strcmp(t, "=") == 0) {
|
||||||
if (t != NULL) {
|
t = split(NULL,0);
|
||||||
|
if (t != NULL) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
///////// to be continued.... FIXME
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* First channel of device is valid. */
|
||||||
|
// This might be changed to UDP or STDIN when the device name is examined.
|
||||||
|
p_audio_config->chan_medium[ADEVFIRSTCHAN(adevice)] = MEDIUM_RADIO;
|
||||||
|
|
||||||
|
strlcpy (p_audio_config->adev[adevice].adevice_in, t, sizeof(p_audio_config->adev[adevice].adevice_in));
|
||||||
strlcpy (p_audio_config->adev[adevice].adevice_out, t, sizeof(p_audio_config->adev[adevice].adevice_out));
|
strlcpy (p_audio_config->adev[adevice].adevice_out, t, sizeof(p_audio_config->adev[adevice].adevice_out));
|
||||||
|
|
||||||
|
t = split(NULL,0);
|
||||||
|
if (t != NULL) {
|
||||||
|
// Different audio devices for receive and transmit.
|
||||||
|
strlcpy (p_audio_config->adev[adevice].adevice_out, t, sizeof(p_audio_config->adev[adevice].adevice_out));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2173,7 +2206,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
||||||
else {
|
else {
|
||||||
p_audio_config->achan[channel].slottime = DEFAULT_SLOTTIME;
|
p_audio_config->achan[channel].slottime = DEFAULT_SLOTTIME;
|
||||||
text_color_set(DW_COLOR_ERROR);
|
text_color_set(DW_COLOR_ERROR);
|
||||||
dw_printf ("Line %d: Invalid delay time for persist algorithm. Using %d.\n",
|
dw_printf ("Line %d: Invalid delay time for persist algorithm. Using default %d.\n",
|
||||||
line, p_audio_config->achan[channel].slottime);
|
line, p_audio_config->achan[channel].slottime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2197,7 +2230,7 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
||||||
else {
|
else {
|
||||||
p_audio_config->achan[channel].persist = DEFAULT_PERSIST;
|
p_audio_config->achan[channel].persist = DEFAULT_PERSIST;
|
||||||
text_color_set(DW_COLOR_ERROR);
|
text_color_set(DW_COLOR_ERROR);
|
||||||
dw_printf ("Line %d: Invalid probability for persist algorithm. Using %d.\n",
|
dw_printf ("Line %d: Invalid probability for persist algorithm. Using default %d.\n",
|
||||||
line, p_audio_config->achan[channel].persist);
|
line, p_audio_config->achan[channel].persist);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2216,6 +2249,19 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
||||||
}
|
}
|
||||||
n = atoi(t);
|
n = atoi(t);
|
||||||
if (n >= 0 && n <= 255) {
|
if (n >= 0 && n <= 255) {
|
||||||
|
text_color_set(DW_COLOR_ERROR);
|
||||||
|
if (n == 0) {
|
||||||
|
dw_printf ("Line %d: Setting TXDELAY to 0 is a REALLY BAD idea if you want other stations to hear you.\n",
|
||||||
|
line);
|
||||||
|
dw_printf ("Line %d: See User Guide, \"Radio Channel - Transmit Timing\" for an explanation.\n",
|
||||||
|
line);
|
||||||
|
}
|
||||||
|
if (n >= 100) {
|
||||||
|
dw_printf ("Line %d: Keeping with tradition, going back to the 1980s, TXDELAY is in 10 millisecond units.\n",
|
||||||
|
line);
|
||||||
|
dw_printf ("Line %d: The value %d would be %.3f seconds which seems rather excessive. Are you sure you want that?\n",
|
||||||
|
line, n, (double)n * 10. / 1000.);
|
||||||
|
}
|
||||||
p_audio_config->achan[channel].txdelay = n;
|
p_audio_config->achan[channel].txdelay = n;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -2240,6 +2286,18 @@ void config_init (char *fname, struct audio_s *p_audio_config,
|
||||||
}
|
}
|
||||||
n = atoi(t);
|
n = atoi(t);
|
||||||
if (n >= 0 && n <= 255) {
|
if (n >= 0 && n <= 255) {
|
||||||
|
if (n == 0) {
|
||||||
|
dw_printf ("Line %d: Setting TXTAIL to 0 is a REALLY BAD idea if you want other stations to hear you.\n",
|
||||||
|
line);
|
||||||
|
dw_printf ("Line %d: See User Guide, \"Radio Channel - Transmit Timing\" for an explanation.\n",
|
||||||
|
line);
|
||||||
|
}
|
||||||
|
if (n >= 50) {
|
||||||
|
dw_printf ("Line %d: Keeping with tradition, going back to the 1980s, TXTAIL is in 10 millisecond units.\n",
|
||||||
|
line);
|
||||||
|
dw_printf ("Line %d: The value %d would be %.3f seconds which seems rather excessive. Are you sure you want that?\n",
|
||||||
|
line, n, (double)n * 10. / 1000.);
|
||||||
|
}
|
||||||
p_audio_config->achan[channel].txtail = n;
|
p_audio_config->achan[channel].txtail = n;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in New Issue