From d21be383a6515760a38f403100a9d142633bf616 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Sat, 5 Mar 2016 08:14:36 +0100 Subject: [PATCH] anetz/bnetz: Move option 'loss detection' from common code to individual code --- src/anetz/main.c | 11 ++++++++++- src/bnetz/main.c | 11 ++++++++++- src/common/main.h | 1 - src/common/main_common.c | 11 +---------- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/anetz/main.c b/src/anetz/main.c index 47e1264..643c874 100644 --- a/src/anetz/main.c +++ b/src/anetz/main.c @@ -35,6 +35,7 @@ /* settings */ int page_sequence = 0; +double lossdetect = 0; void print_help(const char *arg0) { @@ -43,6 +44,9 @@ void print_help(const char *arg0) printf(" -P --page-sequence 0 | \n"); printf(" Cycle paging tones, rather than sending simultaniously.\n"); printf(" (default = '%d')\n", page_sequence); + printf(" -0 --loss \n"); + printf(" Detect loss of carrier by detecting steady noise above given volume in\n"); + printf(" percent. (disabled by default)\n"); printf("\nstation-id: Give (last) 5 digits of station-id, you don't need to enter it\n"); printf(" for every start of this program.\n"); } @@ -53,10 +57,11 @@ static int handle_options(int argc, char **argv) static struct option long_options_special[] = { {"page-sequence", 1, 0, 'P'}, + {"loss", 1, 0, '0'}, {0, 0, 0, 0} }; - set_options_common("P:", long_options_special); + set_options_common("P:0:", long_options_special); while (1) { int option_index = 0, c; @@ -71,6 +76,10 @@ static int handle_options(int argc, char **argv) page_sequence = atoi(optarg); skip_args += 2; break; + case '0': + lossdetect = atoi(optarg); + skip_args += 2; + break; default: opt_switch_common(c, argv[0], &skip_args); } diff --git a/src/bnetz/main.c b/src/bnetz/main.c index 79b4d29..2d7fa53 100644 --- a/src/bnetz/main.c +++ b/src/bnetz/main.c @@ -36,6 +36,7 @@ int gfs = 2; const char *pilot = "tone"; +double lossdetect = 0; void print_help(const char *arg0) { @@ -53,6 +54,9 @@ void print_help(const char *arg0) printf(" Example: /sys/class/gpio/gpio17/value=1:0 writes a '1' to\n"); printf(" /sys/class/gpio/gpio17/value to switching to channel 19 and a '0' to\n"); printf(" switch back. (default = %s)\n", pilot); + printf(" -0 --loss \n"); + printf(" Detect loss of carrier by detecting steady noise above given volume in\n"); + printf(" percent. (disabled by default)\n"); printf("\nstation-id: Give 5 digit station-id, you don't need to enter it for every\n"); printf(" start of this program.\n"); } @@ -64,10 +68,11 @@ static int handle_options(int argc, char **argv) static struct option long_options_special[] = { {"gfs", 1, 0, 'g'}, {"pilot", 1, 0, 'P'}, + {"loss", 1, 0, '0'}, {0, 0, 0, 0}, }; - set_options_common("g:P:", long_options_special); + set_options_common("g:P:0:", long_options_special); while (1) { int option_index = 0, c; @@ -86,6 +91,10 @@ static int handle_options(int argc, char **argv) pilot = strdup(optarg); skip_args += 2; break; + case '0': + lossdetect = atoi(optarg); + skip_args += 2; + break; default: opt_switch_common(c, argv[0], &skip_args); } diff --git a/src/common/main.h b/src/common/main.h index fcf7c06..9cd85c4 100644 --- a/src/common/main.h +++ b/src/common/main.h @@ -7,7 +7,6 @@ extern int latency; extern int use_mncc_sock; extern int send_patterns; extern int loopback; -extern double lossdetect; extern int rt_prio; void print_help(const char *arg0); diff --git a/src/common/main_common.c b/src/common/main_common.c index 3b2eb8f..7675712 100644 --- a/src/common/main_common.c +++ b/src/common/main_common.c @@ -35,7 +35,6 @@ int latency = 50; int use_mncc_sock = 0; int send_patterns = 1; int loopback = 0; -double lossdetect = 0; int rt_prio = 0; void print_help_common(const char *arg0) @@ -55,9 +54,6 @@ void print_help_common(const char *arg0) printf(" Sample rate of sound device (default = '%d')\n", samplerate); printf(" -l --latency \n"); printf(" How many milliseconds processed in advance (default = '%d')\n", latency); - printf(" -0 --loss \n"); - printf(" Detect loss of carrier by detecting steady noise above given volume in\n"); - printf(" percent. (disabled by default)\n"); printf(" -m --mncc-sock\n"); printf(" Disable built-in call contol and offer socket (to LCR)\n"); printf(" -c --call-device hw:,\n"); @@ -78,7 +74,6 @@ static struct option long_options_common[] = { {"call-device", 1, 0, 'c'}, {"samplerate", 1, 0, 's'}, {"latency", 1, 0, 'l'}, - {"loss", 1, 0, '0'}, {"mncc-sock", 0, 0, 'm'}, {"send-patterns", 0, 0, 'p'}, {"loopback", 1, 0, 'L'}, @@ -86,7 +81,7 @@ static struct option long_options_common[] = { {0, 0, 0, 0} }; -const char *optstring_common = "hD:k:d:s:c:l:0:mp:L:r:"; +const char *optstring_common = "hD:k:d:s:c:l:mp:L:r:"; struct option *long_options; char *optstring; @@ -140,10 +135,6 @@ void opt_switch_common(int c, char *arg0, int *skip_args) latency = atoi(optarg); *skip_args += 2; break; - case '0': - lossdetect = atoi(optarg); - *skip_args += 2; - break; case 'm': use_mncc_sock = 1; *skip_args += 1;