diff options
author | mattf <mattf@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2005-02-11 15:50:05 +0000 |
---|---|---|
committer | mattf <mattf@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2005-02-11 15:50:05 +0000 |
commit | d5f969c40178901a4d809093f29b57757a2993d9 (patch) | |
tree | 00382f508a2f501793f3efbd787bdc117c823c36 /fxotune.c | |
parent | 0b782dfc6bc5db1738cc07d0836069082ec754d0 (diff) |
Fixed bug in processing code, also added support to output the data gathered to a file
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@583 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'fxotune.c')
-rwxr-xr-x | fxotune.c | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -8,7 +8,7 @@ * * by Matthew Fredrickson * - * (C) 2004 Digium, Inc. + * (C) 2004-2005 Digium, Inc. */ #include <stdio.h> @@ -66,7 +66,7 @@ int process_readbuf(short *ibuf) * to begenerated. For a normal waveform you need to increment * this every time you execute the function. * Returns a 16bit slinear sample. */ -short inline gentone(int hz, int index) +static short inline gentone(int hz, int index) { return sinf(index * 2 * PI * hz/8000); } @@ -76,7 +76,7 @@ short inline gentone(int hz, int index) * * TODO: make the function stateless so that you can have some sort of * progressive power calculation on the line */ -float power_of(void *prebuf, int bufsize, int short_format) +static float power_of(void *prebuf, int bufsize, int short_format) { float sum_of_squares = 0, square_of_sums = 0; int numsamples = 0; @@ -286,7 +286,7 @@ static int echo_tune(int whichzap, const char *dialstr) #endif /* Tune the line impedance. Look for best response range */ -int acim_tune(int whichzap, char *dialstr) +static int acim_tune(int whichzap, char *dialstr) { int i = 0, freq = 0, acim = 0; int res = 0, x = 0; @@ -295,8 +295,16 @@ int acim_tune(int whichzap, char *dialstr) struct wctdm_echo_coefs coefs; short inbuf[BUFFER_LENGTH]; int lowest = 0; + FILE *outfile = NULL; float acim_results[16]; + + outfile = fopen("/tmp/fxotune.vals", "w"); + if (!outfile) { + fprintf(stdout, "Cannot create /tmp/txotune.vals\n"); + return -1; + } + /* Set echo settings */ memset(&coefs, 0, sizeof(coefs)); if (ioctl(whichzap, WCTDM_SET_ECHOTUNE, &coefs)) { @@ -399,8 +407,10 @@ int acim_tune(int whichzap, char *dialstr) /* calculate power of response */ freq_results[(freq/200)-1] = power_of(inbuf+SKIP_BYTES, BUFFER_LENGTH-SKIP_BYTES, 1); + fprintf(outfile, "%d,%d,%f\n", i, freq, freq_results[(freq/200)-1]); } - acim_results[i] = power_of(freq_results, 16, 0); + + acim_results[i] = power_of(freq_results, 15, 0); } /* Find out what the "best" impedance is for the line */ |