[svn-commits] kpfleming: tools/trunk r4846 - in /tools/trunk: fxotune.c makeopts.in

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Aug 27 11:18:48 CDT 2008


Author: kpfleming
Date: Wed Aug 27 11:18:47 2008
New Revision: 4846

URL: http://svn.digium.com/view/dahdi?view=rev&rev=4846
Log:
actually implement the rest of --enable-dev-mode, and fix up more problems it found

Modified:
    tools/trunk/fxotune.c
    tools/trunk/makeopts.in

Modified: tools/trunk/fxotune.c
URL: http://svn.digium.com/view/dahdi/tools/trunk/fxotune.c?view=diff&rev=4846&r1=4845&r2=4846
==============================================================================
--- tools/trunk/fxotune.c (original)
+++ tools/trunk/fxotune.c Wed Aug 27 11:18:47 2008
@@ -131,7 +131,9 @@
 {
 	struct timeval tv;
 	long int elapsedms;
-	
+	int x = DAHDI_ONHOOK;
+	struct dahdi_dialoperation dop;
+
 	gettimeofday(&tv, NULL);
 	
 	if (info->last_reset.tv_sec == 0) {
@@ -155,7 +157,6 @@
 	/* do a line reset */
 	/* prepare line for silence */
 	/* Do line hookstate reset */
-	int x = DAHDI_ONHOOK;
 
 	if (ioctl(info->device, DAHDI_HOOK, &x)) {
 		fprintf(stderr, "Unable to hang up fd %d\n", info->device);
@@ -170,7 +171,6 @@
 	}
 	sleep(2); /* Added to ensure that dial can actually takes place */
 
-	struct dahdi_dialoperation dop;
 	memset(&dop, 0, sizeof(dop));
 	dop.op = DAHDI_DIAL_OP_REPLACE;
 	dop.dialstr[0] = 'T';
@@ -350,6 +350,12 @@
 	struct dahdi_bufferinfo bi;
 	short inbuf[TEST_DURATION]; /* changed from BUFFER_LENGTH - this buffer is for short values, so it should be allocated using the length of the test */
 	FILE *outfile = NULL;
+	int leadin = 50;
+	int trailout = 100;
+	struct silence_info sinfo;
+	float power_result;
+	float power_waveform;
+	float echo;
 
 	outfile = fopen("fxotune_dump.vals", "w");
 	if (!outfile) {
@@ -378,8 +384,6 @@
 	}
 
 	/* Fill the output buffers */
-	int leadin = 50;
-	int trailout = 100;
 	for (i = 0; i < leadin; i++)
 		outbuf[i] = 0;
 	for (; i < TEST_DURATION - trailout; i++){
@@ -389,7 +393,6 @@
 		outbuf[i] = 0;
 
 	/* Make sure the line is clear */
-	struct silence_info sinfo;
 	memset(&sinfo, 0, sizeof(sinfo));
 	sinfo.device = whichdahdi;
 	sinfo.dialstr = dialstr;
@@ -426,9 +429,9 @@
 	}
 
 	/* write content of output buffer to debug file */
-	float power_result = power_of(inbuf, TEST_DURATION, 1); 
-	float power_waveform = power_of(outbuf, TEST_DURATION, 1); 
-	float echo = power_result/power_waveform;
+	power_result = power_of(inbuf, TEST_DURATION, 1); 
+	power_waveform = power_of(outbuf, TEST_DURATION, 1); 
+	echo = power_result/power_waveform;
 	
 	fprintf(outfile, "Buffers, freq=%d, outpower=%0.0f, echo=%0.4f\n", freq, power_result, echo);
 	fprintf(outfile, "Sample, Input (received from the line), Output (sent to the line)\n");
@@ -479,10 +482,15 @@
 	int res = 0, x = 0;
 	int lowesttry = -1;
 	float lowesttryresult = 999999999999.0;
-	float lowestecho = 999999999999.0;;
+	float lowestecho = 999999999999.0;
 	struct dahdi_bufferinfo bi;
-
 	short inbuf[TEST_DURATION * 2];
+	struct silence_info sinfo;
+	int echo_trys_size = 72;
+	int trys = 0;
+	float waveform_power;
+	float freq_result;
+	float echo;
 
 	if (debug && !debugoutfile) {
 		if (!(debugoutfile = fopen("fxotune.vals", "w"))) {
@@ -524,7 +532,6 @@
 
 
 	/* Set up silence settings */
-	struct silence_info sinfo;
 	memset(&sinfo, 0, sizeof(sinfo));
 	sinfo.device = whichdahdi;
 	sinfo.dialstr = dialstr;
@@ -536,13 +543,10 @@
 		outbuf[i] = freq > 0 ? gentone(freq, i) : genwaveform(i); /* if freq is negative, use a multi-frequency waveform */
 	
 	/* compute power of input (so we can later compute echo levels relative to input) */
-	float waveform_power = calc_magnitude(outbuf, TEST_DURATION);
-	
+	waveform_power = calc_magnitude(outbuf, TEST_DURATION);
 
 	/* sweep through the various coefficient settings and see how our responses look */
 
-	int echo_trys_size = 72;
-	int trys = 0;
 	for (trys = 0; trys < echo_trys_size; trys++){
 		
 		/* ensure silence on the line */
@@ -580,8 +584,8 @@
 			goto retry;
 		}
 
-		float freq_result = calc_magnitude(inbuf, TEST_DURATION * 2);
-		float echo = db_loss(freq_result, waveform_power);
+		freq_result = calc_magnitude(inbuf, TEST_DURATION * 2);
+		echo = db_loss(freq_result, waveform_power);
 		
 #if 0
 		if (debug > 0)
@@ -643,7 +647,7 @@
 	int lowest = 0;
 	FILE *outfile = NULL;
 	float acim_results[16];
-
+	struct silence_info sinfo;
 
 	if (debug) {
 		outfile = fopen("fxotune.vals", "w");
@@ -654,7 +658,6 @@
 	}
 
 	/* Set up silence settings */
-	struct silence_info sinfo;
 	memset(&sinfo, 0, sizeof(sinfo));
 	sinfo.device = whichdahdi;
 	sinfo.dialstr = dialstr;
@@ -996,16 +999,13 @@
 	int waveformtype = -1; /* -w multi-tone by default.  If > 0, single tone of specified frequency */
 	int delaytosilence = 0; /* -l */
 	int silencegoodfor = 18; /* -m */
-	
 	char* dialstr = "5"; /* -n */
-	
 	int res = 0;
-
 	int doset = 0; /* -s */
 	int docalibrate = 0; /* -i <dialstr> */
 	int dodump = 0; /* -d */
-
 	int i = 0;
+	int moreargs;
 	
 	for (i = 1; i < argc; i++){
 		if (!(argv[i][0] == '-' || argv[i][0] == '/') || (strlen(argv[i]) <= 1)){
@@ -1014,7 +1014,8 @@
 			fputs(usage, stdout);
 			return -1;
 		}
-		int moreargs = (i < argc - 1);
+
+		moreargs = (i < argc - 1);
 		
 		switch(argv[i][1]){
 			case 's':

Modified: tools/trunk/makeopts.in
URL: http://svn.digium.com/view/dahdi/tools/trunk/makeopts.in?view=diff&rev=4846&r1=4845&r2=4846
==============================================================================
--- tools/trunk/makeopts.in (original)
+++ tools/trunk/makeopts.in Wed Aug 27 11:18:47 2008
@@ -27,6 +27,7 @@
 DOWNLOAD=@DOWNLOAD@
 
 DAHDI_DEVMODE=@DAHDI_DEVMODE@
+DAHDI_DECLARATION_AFTER_STATEMENT=@DAHDI_DECLARATION_AFTER_STATEMENT@
 
 PBX_NEWT=@PBX_NEWT@
 NEWT_LIB=@NEWT_LIB@




More information about the svn-commits mailing list