From c163caca008376313f9204a62aedda9c07f707ac Mon Sep 17 00:00:00 2001 From: Oron Peled Date: Mon, 21 Oct 2013 12:54:58 +0200 Subject: [PATCH] fxotune: Now options '-b/-e' also apply with '-s' * Now we can limit fxotune "set" mode to specific channel range. Signed-off-by: Tzafrir Cohen Acked-by: Russ Meyerriecks --- doc/fxotune.8 | 1 + fxotune.c | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/doc/fxotune.8 b/doc/fxotune.8 index efa94c3..d3257fc 100644 --- a/doc/fxotune.8 +++ b/doc/fxotune.8 @@ -11,6 +11,7 @@ fxotune \- automatically tune DAHDI FXO channels \- dump mode .B fxotune \-s +.I [ options ] \- Startup mode .SH .SH DESCRIPTION diff --git a/fxotune.c b/fxotune.c index 530ba21..865dc70 100644 --- a/fxotune.c +++ b/fxotune.c @@ -980,7 +980,7 @@ static int channel_open(int channo) * * @return 0 if successful, !0 otherwise */ -static int do_set(char *configfilename) +static int do_set(char *configfilename, int dev_range, int startdev, int stopdev) { FILE *fp = NULL; int res = 0; @@ -1007,6 +1007,8 @@ static int do_set(char *configfilename) if (res == EOF) { break; } + if (dev_range && (mydahdi < startdev || mydahdi > stopdev)) + continue; /* Check to be sure conversion is done correctly */ if (OUT_OF_BOUNDS(myacim) || OUT_OF_BOUNDS(mycoef1)|| @@ -1028,6 +1030,8 @@ static int do_set(char *configfilename) mycoefs.coef7 = mycoef7; mycoefs.coef8 = mycoef8; + if (debug >= 2) + printf("fxotune: set channel %d\n", mydahdi); fd = channel_open(mydahdi); if (fd < 0) { return -1; @@ -1187,6 +1191,7 @@ int main(int argc , char **argv) { int startdev = 1; /* -b */ int stopdev = 252; /* -e */ + int dev_range = 0; /* false */ int calibtype = 2; /* -t */ int waveformtype = -1; /* -w multi-tone by default. If > 0, single tone of specified frequency */ int delaytosilence = 0; /* -l */ @@ -1228,9 +1233,11 @@ int main(int argc , char **argv) continue; case 'b': startdev = moreargs ? atoi(argv[++i]) : startdev; + dev_range = 1; break; case 'e': stopdev = moreargs ? atoi(argv[++i]) : stopdev; + dev_range = 1; break; case 't': calibtype = moreargs ? atoi(argv[++i]) : calibtype; @@ -1300,13 +1307,13 @@ int main(int argc , char **argv) if (docalibrate){ res = do_calibrate(startdev, stopdev, calibtype, configfile, dialstr, delaytosilence, silencegoodfor); if (!res) - return do_set(configfile); + return do_set(configfile, dev_range, startdev, stopdev); else return -1; } if (doset) - return do_set(configfile); + return do_set(configfile, dev_range, startdev, stopdev); if (dodump){ res = do_dump(startdev, dialstr, delaytosilence, silencegoodfor, waveformtype);