Changed command line options
* All lower case options define common options * All upper case options define network specific options
This commit is contained in:
@@ -15,8 +15,9 @@ extern int use_mncc_sock;
|
||||
extern int send_patterns;
|
||||
extern int loopback;
|
||||
extern int rt_prio;
|
||||
extern const char *read_wave;
|
||||
extern const char *write_wave;
|
||||
extern const char *write_rx_wave;
|
||||
extern const char *write_tx_wave;
|
||||
extern const char *read_rx_wave;
|
||||
|
||||
void print_help(const char *arg0);
|
||||
void print_help_common(const char *arg0, const char *ext_usage);
|
||||
|
@@ -51,8 +51,9 @@ int send_patterns = 1;
|
||||
int release_on_disconnect = 1;
|
||||
int loopback = 0;
|
||||
int rt_prio = 0;
|
||||
const char *read_wave = NULL;
|
||||
const char *write_wave = NULL;
|
||||
const char *write_rx_wave = NULL;
|
||||
const char *write_tx_wave = NULL;
|
||||
const char *read_rx_wave = NULL;
|
||||
|
||||
void print_help_common(const char *arg0, const char *ext_usage)
|
||||
{
|
||||
@@ -61,14 +62,15 @@ void print_help_common(const char *arg0, const char *ext_usage)
|
||||
/* - - */
|
||||
printf(" -h --help\n");
|
||||
printf(" This help\n");
|
||||
printf(" -D --debug <level> | <level>,<category>[,<category>[,...]] | list\n");
|
||||
printf(" -v --verbose <level> | <level>,<category>[,<category>[,...]] | list\n");
|
||||
printf(" Use 'list' to get a list of all levels and categories\n");
|
||||
printf(" Debug level: digit of debug level (default = '%d')\n", debuglevel);
|
||||
printf(" Debug level+category: level digit followed by one or more categories\n");
|
||||
printf(" Verbose level: digit of debug level (default = '%d')\n", debuglevel);
|
||||
printf(" Verbose level+category: level digit followed by one or more categories\n");
|
||||
printf(" -> If no category is specified, all categories are selected\n");
|
||||
printf(" -k --kanal <channel>\n");
|
||||
printf(" Channel number of \"Sender\"\n");
|
||||
printf(" -d --device hw:<card>,<device>\n");
|
||||
printf(" -k --channel <channel>\n");
|
||||
printf(" Channel (German = Kanal) number of \"Sender\" (German = Transceiver)\n");
|
||||
printf(" -a --audio-device hw:<card>,<device>\n");
|
||||
printf(" Sound card and device number (default = '%s')\n", sounddev[0]);
|
||||
printf(" -s --samplerate <rate>\n");
|
||||
printf(" Sample rate of sound device (default = '%d')\n", samplerate);
|
||||
@@ -76,18 +78,18 @@ void print_help_common(const char *arg0, const char *ext_usage)
|
||||
printf(" Interval of processing loop in ms (default = '%d' ms)\n", interval);
|
||||
printf(" Use 25 to drastically reduce CPU usage. In case of buffer underrun,\n");
|
||||
printf(" increase latency accordingly.\n");
|
||||
printf(" -l --latency <delay>\n");
|
||||
printf(" How many milliseconds processed in advance (default = '%d')\n", latency);
|
||||
printf(" -b --buffer <ms>\n");
|
||||
printf(" How many milliseconds are processed in advance (default = '%d')\n", latency);
|
||||
printf(" -x --cross\n");
|
||||
printf(" Cross channels on sound card. 1st channel (right) is swapped with\n");
|
||||
printf(" second channel (left)\n");
|
||||
printf(" -E --pre-emphasis\n");
|
||||
printf(" -p --pre-emphasis\n");
|
||||
printf(" Enable pre-emphasis, if you directly connect to the oscillator of the\n");
|
||||
printf(" transmitter. (No pre-emphasis done by the transmitter.)\n");
|
||||
printf(" -e --de-emphasis\n");
|
||||
printf(" -d --de-emphasis\n");
|
||||
printf(" Enable de-emphasis, if you directly connect to the discriminator of\n");
|
||||
printf(" the receiver. (No de-emphasis done by the receiver.)\n");
|
||||
printf(" -G --rx-gain <dB>\n");
|
||||
printf(" -g --rx-gain <dB>\n");
|
||||
printf(" Raise receiver RX level by given gain in dB. This is useful if input\n");
|
||||
printf(" level of the sound device is too low, even after setting maximum level\n");
|
||||
printf(" with the mixer settings.\n");
|
||||
@@ -95,55 +97,80 @@ void print_help_common(const char *arg0, const char *ext_usage)
|
||||
printf(" Disable built-in call contol and offer socket (to LCR)\n");
|
||||
printf(" -c --call-device hw:<card>,<device>\n");
|
||||
printf(" Sound card and device number for headset (default = '%s')\n", call_sounddev);
|
||||
printf(" -p --send-patterns 0 | 1\n");
|
||||
printf(" -t --tones 0 | 1\n");
|
||||
printf(" Connect call on setup/release to provide classic tones towards fixed\n");
|
||||
printf(" network (default = '%d')\n", send_patterns);
|
||||
printf(" -L --loopback <type>\n");
|
||||
printf(" -l --loopback <type>\n");
|
||||
printf(" Loopback test: 1 = internal | 2 = external | 3 = echo\n");
|
||||
printf(" -r --realtime <prio>\n");
|
||||
printf(" Set prio: 0 to diable, 99 for maximum (default = %d)\n", rt_prio);
|
||||
printf(" -W --write-wave <file>\n");
|
||||
printf(" --write-rx-wave <file>\n");
|
||||
printf(" Write received audio to given wav audio file.\n");
|
||||
printf(" -R --read-wave <file>\n");
|
||||
printf(" --write-tx-wave <file>\n");
|
||||
printf(" Write transmitted audio to given wav audio file.\n");
|
||||
printf(" --read-rx-wave <file>\n");
|
||||
printf(" Replace received audio by given wav audio file.\n");
|
||||
}
|
||||
|
||||
#define OPT_CHANNEL 1000
|
||||
#define OPT_WRITE_RX_WAVE 1001
|
||||
#define OPT_WRITE_TX_WAVE 1002
|
||||
#define OPT_READ_RX_WAVE 1003
|
||||
|
||||
static struct option long_options_common[] = {
|
||||
{"help", 0, 0, 'h'},
|
||||
{"debug", 1, 0, 'D'},
|
||||
{"debug", 1, 0, 'v'},
|
||||
{"kanal", 1, 0, 'k'},
|
||||
{"device", 1, 0, 'd'},
|
||||
{"call-device", 1, 0, 'c'},
|
||||
{"channel", 1, 0, OPT_CHANNEL},
|
||||
{"call-device", 1, 0, 'a'},
|
||||
{"samplerate", 1, 0, 's'},
|
||||
{"interval", 1, 0, 'i'},
|
||||
{"latency", 1, 0, 'l'},
|
||||
{"buffer", 1, 0, 'b'},
|
||||
{"cross", 0, 0, 'x'},
|
||||
{"pre-emphasis", 0, 0, 'E'},
|
||||
{"de-emphasis", 0, 0, 'e'},
|
||||
{"rx-gain", 0, 0, 'G'},
|
||||
{"pre-emphasis", 0, 0, 'p'},
|
||||
{"de-emphasis", 0, 0, 'd'},
|
||||
{"rx-gain", 0, 0, 'g'},
|
||||
{"mncc-sock", 0, 0, 'm'},
|
||||
{"send-patterns", 0, 0, 'p'},
|
||||
{"loopback", 1, 0, 'L'},
|
||||
{"call-device", 1, 0, 'c'},
|
||||
{"tones", 0, 0, 't'},
|
||||
{"loopback", 1, 0, 'l'},
|
||||
{"realtime", 1, 0, 'r'},
|
||||
{"write-wave", 1, 0, 'W'},
|
||||
{"read-wave", 1, 0, 'R'},
|
||||
{"write-rx-wave", 1, 0, OPT_WRITE_RX_WAVE},
|
||||
{"write-tx-wave", 1, 0, OPT_WRITE_TX_WAVE},
|
||||
{"read-rx-wave", 1, 0, OPT_READ_RX_WAVE},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
const char *optstring_common = "hD:k:d:s:c:i:l:xEeG:mp:L:r:W:R:";
|
||||
const char *optstring_common = "hv:k:a:s:i:b:xpdg:mc:t:l:r:";
|
||||
|
||||
struct option *long_options;
|
||||
char *optstring;
|
||||
|
||||
static void check_duplicate_option(int num, struct option *option)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < num; i++) {
|
||||
if (long_options[i].val == option->val) {
|
||||
fprintf(stderr, "Duplicate option %d. Please fix!\n", option->val);
|
||||
abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void set_options_common(const char *optstring_special, struct option *long_options_special)
|
||||
{
|
||||
int i;
|
||||
|
||||
long_options = calloc(sizeof(*long_options), 100);
|
||||
for (i = 0; long_options_common[i].name; i++)
|
||||
for (i = 0; long_options_common[i].name; i++) {
|
||||
check_duplicate_option(i, &long_options_common[i]);
|
||||
memcpy(&long_options[i], &long_options_common[i], sizeof(*long_options));
|
||||
for (; long_options_special->name; i++)
|
||||
}
|
||||
for (; long_options_special->name; i++) {
|
||||
check_duplicate_option(i, long_options_special);
|
||||
memcpy(&long_options[i], long_options_special++, sizeof(*long_options));
|
||||
}
|
||||
|
||||
optstring = calloc(strlen(optstring_common) + strlen(optstring_special) + 1, 1);
|
||||
strcpy(optstring, optstring_common);
|
||||
@@ -158,7 +185,7 @@ void opt_switch_common(int c, char *arg0, int *skip_args)
|
||||
case 'h':
|
||||
print_help(arg0);
|
||||
exit(0);
|
||||
case 'D':
|
||||
case 'v':
|
||||
if (!strcasecmp(optarg, "list")) {
|
||||
debug_list_cat();
|
||||
exit(0);
|
||||
@@ -170,10 +197,11 @@ void opt_switch_common(int c, char *arg0, int *skip_args)
|
||||
*skip_args += 2;
|
||||
break;
|
||||
case 'k':
|
||||
case OPT_CHANNEL:
|
||||
OPT_ARRAY(num_kanal, kanal, atoi(optarg))
|
||||
*skip_args += 2;
|
||||
break;
|
||||
case 'd':
|
||||
case 'a':
|
||||
OPT_ARRAY(num_sounddev, sounddev, strdup(optarg))
|
||||
*skip_args += 2;
|
||||
break;
|
||||
@@ -181,10 +209,6 @@ void opt_switch_common(int c, char *arg0, int *skip_args)
|
||||
samplerate = atoi(optarg);
|
||||
*skip_args += 2;
|
||||
break;
|
||||
case 'c':
|
||||
call_sounddev = strdup(optarg);
|
||||
*skip_args += 2;
|
||||
break;
|
||||
case 'i':
|
||||
interval = atoi(optarg);
|
||||
*skip_args += 2;
|
||||
@@ -193,7 +217,7 @@ void opt_switch_common(int c, char *arg0, int *skip_args)
|
||||
if (interval > 25)
|
||||
interval = 25;
|
||||
break;
|
||||
case 'l':
|
||||
case 'b':
|
||||
latency = atoi(optarg);
|
||||
*skip_args += 2;
|
||||
break;
|
||||
@@ -201,15 +225,15 @@ void opt_switch_common(int c, char *arg0, int *skip_args)
|
||||
cross_channels = 1;
|
||||
*skip_args += 1;
|
||||
break;
|
||||
case 'E':
|
||||
case 'p':
|
||||
do_pre_emphasis = 1;
|
||||
*skip_args += 1;
|
||||
break;
|
||||
case 'e':
|
||||
case 'd':
|
||||
do_de_emphasis = 1;
|
||||
*skip_args += 1;
|
||||
break;
|
||||
case 'G':
|
||||
case 'g':
|
||||
gain_db = atof(optarg);
|
||||
if (gain_db < 0.0) {
|
||||
fprintf(stderr, "Given gain is below 0. Tto reduce RX signal, use sound card's mixer (or resistor net)!\n");
|
||||
@@ -222,11 +246,15 @@ void opt_switch_common(int c, char *arg0, int *skip_args)
|
||||
use_mncc_sock = 1;
|
||||
*skip_args += 1;
|
||||
break;
|
||||
case 'p':
|
||||
case 'c':
|
||||
call_sounddev = strdup(optarg);
|
||||
*skip_args += 2;
|
||||
break;
|
||||
case 't':
|
||||
send_patterns = atoi(optarg);
|
||||
*skip_args += 2;
|
||||
break;
|
||||
case 'L':
|
||||
case 'l':
|
||||
loopback = atoi(optarg);
|
||||
*skip_args += 2;
|
||||
break;
|
||||
@@ -234,12 +262,16 @@ void opt_switch_common(int c, char *arg0, int *skip_args)
|
||||
rt_prio = atoi(optarg);
|
||||
*skip_args += 2;
|
||||
break;
|
||||
case 'W':
|
||||
write_wave = strdup(optarg);
|
||||
case OPT_WRITE_RX_WAVE:
|
||||
write_rx_wave = strdup(optarg);
|
||||
*skip_args += 2;
|
||||
break;
|
||||
case 'R':
|
||||
read_wave = strdup(optarg);
|
||||
case OPT_WRITE_TX_WAVE:
|
||||
write_tx_wave = strdup(optarg);
|
||||
*skip_args += 2;
|
||||
break;
|
||||
case OPT_READ_RX_WAVE:
|
||||
read_rx_wave = strdup(optarg);
|
||||
*skip_args += 2;
|
||||
break;
|
||||
default:
|
||||
|
@@ -17,9 +17,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* Uncomment this for writing TX as wave (For debug purpose) */
|
||||
//#define WAVE_WRITE_TX
|
||||
|
||||
#define CHAN sender->kanal
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -35,7 +32,7 @@ static sender_t **sender_tailp = &sender_head;
|
||||
int cant_recover = 0;
|
||||
|
||||
/* Init transceiver instance and link to list of transceivers. */
|
||||
int sender_create(sender_t *sender, int kanal, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int pre_emphasis, int de_emphasis, const char *write_wave, const char *read_wave, int loopback, double loss_volume, enum pilot_signal pilot_signal)
|
||||
int sender_create(sender_t *sender, int kanal, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, int loopback, double loss_volume, enum pilot_signal pilot_signal)
|
||||
{
|
||||
sender_t *master;
|
||||
int rc = 0;
|
||||
@@ -115,15 +112,22 @@ int sender_create(sender_t *sender, int kanal, const char *sounddev, int sampler
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (write_wave) {
|
||||
rc = wave_create_record(&sender->wave_rec, write_wave, samplerate);
|
||||
if (write_rx_wave) {
|
||||
rc = wave_create_record(&sender->wave_rx_rec, write_rx_wave, samplerate);
|
||||
if (rc < 0) {
|
||||
PDEBUG(DSENDER, DEBUG_ERROR, "Failed to create WAVE recoding instance!\n");
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
if (read_wave) {
|
||||
rc = wave_create_playback(&sender->wave_play, read_wave, samplerate);
|
||||
if (write_tx_wave) {
|
||||
rc = wave_create_record(&sender->wave_tx_rec, write_tx_wave, samplerate);
|
||||
if (rc < 0) {
|
||||
PDEBUG(DSENDER, DEBUG_ERROR, "Failed to create WAVE recoding instance!\n");
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
if (read_rx_wave) {
|
||||
rc = wave_create_playback(&sender->wave_rx_play, read_rx_wave, samplerate);
|
||||
if (rc < 0) {
|
||||
PDEBUG(DSENDER, DEBUG_ERROR, "Failed to create WAVE playback instance!\n");
|
||||
goto error;
|
||||
@@ -169,8 +173,9 @@ void sender_destroy(sender_t *sender)
|
||||
sender->sound = NULL;
|
||||
}
|
||||
|
||||
wave_destroy_record(&sender->wave_rec);
|
||||
wave_destroy_playback(&sender->wave_play);
|
||||
wave_destroy_record(&sender->wave_rx_rec);
|
||||
wave_destroy_record(&sender->wave_tx_rec);
|
||||
wave_destroy_playback(&sender->wave_rx_play);
|
||||
|
||||
jitter_destroy(&sender->audio);
|
||||
}
|
||||
@@ -239,18 +244,14 @@ cant_recover:
|
||||
jitter_load(&sender->audio, samples, count);
|
||||
else
|
||||
sender_send(sender, samples, count);
|
||||
#ifdef WAVE_WRITE_TX
|
||||
if (sender->wave_rec.fp)
|
||||
wave_write(&sender->wave_rec, samples, count);
|
||||
#endif
|
||||
if (sender->wave_tx_rec.fp)
|
||||
wave_write(&sender->wave_tx_rec, samples, count);
|
||||
/* internal loopback: loop back TX audio to RX */
|
||||
if (sender->loopback == 1) {
|
||||
#ifndef WAVE_WRITE_TX
|
||||
if (sender->wave_rec.fp)
|
||||
wave_write(&sender->wave_rec, samples, count);
|
||||
if (sender->wave_rx_rec.fp)
|
||||
wave_write(&sender->wave_rx_rec, samples, count);
|
||||
display_wave(sender, samples, count);
|
||||
sender_receive(sender, samples, count);
|
||||
#endif
|
||||
}
|
||||
/* do pre emphasis towards radio, not wave_write */
|
||||
if (sender->pre_emphasis)
|
||||
@@ -261,16 +262,12 @@ cant_recover:
|
||||
jitter_load(&slave->audio, slave_samples, count);
|
||||
else
|
||||
sender_send(slave, slave_samples, count);
|
||||
#ifdef WAVE_WRITE_TX
|
||||
if (sender->wave_rec.fp)
|
||||
wave_write(&slave->wave_rec, slave_samples, count);
|
||||
#endif
|
||||
if (sender->wave_tx_rec.fp)
|
||||
wave_write(&slave->wave_tx_rec, slave_samples, count);
|
||||
/* internal loopback, if audio slave is set */
|
||||
if (slave && slave->loopback == 1) {
|
||||
#ifndef WAVE_WRITE_TX
|
||||
if (slave->wave_rec.fp)
|
||||
wave_write(&slave->wave_rec, slave_samples, count);
|
||||
#endif
|
||||
if (slave->wave_rx_rec.fp)
|
||||
wave_write(&slave->wave_rx_rec, slave_samples, count);
|
||||
display_wave(slave, slave_samples, count);
|
||||
sender_receive(slave, slave_samples, count);
|
||||
}
|
||||
@@ -371,13 +368,11 @@ cant_recover:
|
||||
/* do de emphasis from radio (then write_wave/wave_read), receive audio, process echo test */
|
||||
if (sender->de_emphasis)
|
||||
de_emphasis(&sender->estate, samples, count);
|
||||
if (sender->wave_play.fp)
|
||||
wave_read(&sender->wave_play, samples, count);
|
||||
if (sender->wave_rx_play.fp)
|
||||
wave_read(&sender->wave_rx_play, samples, count);
|
||||
if (sender->loopback != 1) {
|
||||
#ifndef WAVE_WRITE_TX
|
||||
if (sender->wave_rec.fp)
|
||||
wave_write(&sender->wave_rec, samples, count);
|
||||
#endif
|
||||
if (sender->wave_rx_rec.fp)
|
||||
wave_write(&sender->wave_rx_rec, samples, count);
|
||||
display_wave(sender, samples, count);
|
||||
sender_receive(sender, samples, count);
|
||||
}
|
||||
@@ -389,13 +384,11 @@ cant_recover:
|
||||
gain_samples(slave_samples, count, slave->rx_gain);
|
||||
if (slave->de_emphasis)
|
||||
de_emphasis(&slave->estate, slave_samples, count);
|
||||
if (slave->wave_play.fp)
|
||||
wave_read(&slave->wave_play, slave_samples, count);
|
||||
if (slave->wave_rx_play.fp)
|
||||
wave_read(&slave->wave_rx_play, slave_samples, count);
|
||||
if (slave->loopback != 1) {
|
||||
#ifndef WAVE_WRITE_TX
|
||||
if (slave->wave_rec.fp)
|
||||
wave_write(&slave->wave_rec, slave_samples, count);
|
||||
#endif
|
||||
if (slave->wave_rx_rec.fp)
|
||||
wave_write(&slave->wave_rx_rec, slave_samples, count);
|
||||
display_wave(slave, slave_samples, count);
|
||||
sender_receive(slave, slave_samples, count);
|
||||
}
|
||||
|
@@ -41,8 +41,9 @@ typedef struct sender {
|
||||
int loopback; /* 0 = off, 1 = internal, 2 = external */
|
||||
|
||||
/* record and playback */
|
||||
wave_rec_t wave_rec; /* wave recording */
|
||||
wave_play_t wave_play; /* wave playback */
|
||||
wave_rec_t wave_rx_rec; /* wave recording (from rx) */
|
||||
wave_rec_t wave_tx_rec; /* wave recording (from tx) */
|
||||
wave_play_t wave_rx_play; /* wave playback (as rx) */
|
||||
|
||||
/* audio buffer for audio to send to transmitter (also used as loopback buffer) */
|
||||
jitter_t audio;
|
||||
@@ -69,7 +70,7 @@ typedef struct sender {
|
||||
extern sender_t *sender_head;
|
||||
extern int cant_recover;
|
||||
|
||||
int sender_create(sender_t *sender, int kanal, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int pre_emphasis, int de_emphasis, const char *write_wave, const char *read_wave, int loopback, double loss_volume, enum pilot_signal pilot_signal);
|
||||
int sender_create(sender_t *sender, int kanal, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, int loopback, double loss_volume, enum pilot_signal pilot_signal);
|
||||
void sender_destroy(sender_t *sender);
|
||||
void process_sender_audio(sender_t *sender, int *quit, int latspl);
|
||||
void sender_send(sender_t *sender, int16_t *samples, int count);
|
||||
|
Reference in New Issue
Block a user