[Asterisk-cvs] zaptel fxotune.c,1.16,1.17

mattf at lists.digium.com mattf at lists.digium.com
Fri Feb 11 09:50:03 CST 2005


Update of /usr/cvsroot/zaptel
In directory mongoose.digium.com:/tmp/cvs-serv6746

Modified Files:
	fxotune.c 
Log Message:
Fixed bug in processing code, also added support to output the data gathered to a file


Index: fxotune.c
===================================================================
RCS file: /usr/cvsroot/zaptel/fxotune.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- fxotune.c	9 Feb 2005 03:30:13 -0000	1.16
+++ fxotune.c	11 Feb 2005 15:50:05 -0000	1.17
@@ -8,7 +8,7 @@
  *
  * by Matthew Fredrickson
  * 
- * (C) 2004 Digium, Inc.
+ * (C) 2004-2005 Digium, Inc.
  */
 
 #include <stdio.h>
@@ -66,7 +66,7 @@
  * 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 @@
  *
  * 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 @@
 #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 @@
 	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 @@
 			/* 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 */




More information about the svn-commits mailing list