[Asterisk-cvs] zaptel fxstest.c, 1.6, 1.7 wctdm.c, 1.110, 1.111 zaptel.h, 1.42, 1.43

markster at lists.digium.com markster at lists.digium.com
Wed May 11 19:37:11 CDT 2005


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

Modified Files:
	fxstest.c wctdm.c zaptel.h 
Log Message:
Add support for polarity reversal


Index: fxstest.c
===================================================================
RCS file: /usr/cvsroot/zaptel/fxstest.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- fxstest.c	28 Dec 2004 20:26:47 -0000	1.6
+++ fxstest.c	11 May 2005 23:43:11 -0000	1.7
@@ -28,6 +28,7 @@
 		       "       stats - reports voltages\n"
 		       "       regdump - dumps ProSLIC registers\n"
 		       "       tones - plays a series of tones\n"
+		       "       polarity - tests polarity reversal\n"
 		       "       ring - rings phone\n");
 		exit(1);
 	}
@@ -46,6 +47,24 @@
 			fprintf(stderr, "Phone is ringing...\n");
 			sleep(2);
 		}
+	} else if (!strcasecmp(argv[2], "polarity")) {
+		fprintf(stderr, "Twiddling polarity...\n");
+		x = 0;
+		res = ioctl(fd, ZT_SETPOLARITY, &x);
+		if (res) {
+			fprintf(stderr, "Unable to polarity...\n");
+		} else {
+			fprintf(stderr, "Polarity is forward...\n");
+			sleep(2);
+			x = 1;
+			ioctl(fd, ZT_SETPOLARITY, &x);
+			fprintf(stderr, "Polarity is reversed...\n");
+			sleep(5);
+			x = 0;
+			ioctl(fd, ZT_SETPOLARITY, &x);
+			fprintf(stderr, "Polarity is forward...\n");
+			sleep(2);
+		}
 	} else if (!strcasecmp(argv[2], "tones")) {
 		int x = 0;
 		for (;;) {

Index: wctdm.c
===================================================================
RCS file: /usr/cvsroot/zaptel/wctdm.c,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -d -r1.110 -r1.111
--- wctdm.c	29 Apr 2005 23:04:34 -0000	1.110
+++ wctdm.c	11 May 2005 23:43:11 -0000	1.111
@@ -1657,6 +1657,22 @@
 				wctdm_setreg(wc, chan->chanpos - 1, 64, wc->mod.fxs.lasttxhook[chan->chanpos - 1]);
 		}
 		break;
+	case ZT_SETPOLARITY:
+		if (get_user(x, (int *)data))
+			return -EFAULT;
+		if (wc->modtype[chan->chanpos - 1] != MOD_TYPE_FXS)
+			return -EINVAL;
+		/* Can't change polarity while ringing or when open */
+		if ((wc->mod.fxs.lasttxhook[chan->chanpos -1 ] == 0x04) ||
+		    (wc->mod.fxs.lasttxhook[chan->chanpos -1 ] == 0x00))
+			return -EINVAL;
+
+		if (x)
+			wc->mod.fxs.lasttxhook[chan->chanpos - 1] |= 0x04;
+		else
+			wc->mod.fxs.lasttxhook[chan->chanpos - 1] &= ~0x04;
+		wctdm_setreg(wc, chan->chanpos - 1, 64, wc->mod.fxs.lasttxhook[chan->chanpos - 1]);
+		break;
 	case WCTDM_GET_STATS:
 		if (wc->modtype[chan->chanpos - 1] == MOD_TYPE_FXS) {
 			stats.tipvolt = wctdm_getreg(wc, chan->chanpos - 1, 80) * -376;

Index: zaptel.h
===================================================================
RCS file: /usr/cvsroot/zaptel/zaptel.h,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- zaptel.h	2 May 2005 20:15:07 -0000	1.42
+++ zaptel.h	11 May 2005 23:43:11 -0000	1.43
@@ -623,6 +623,12 @@
  */
 #define ZT_TONEDETECT _IOW (ZT_CODE, 91, int)
 
+
+/*
+ * Set polarity -- implemented by individual driver.  0 = forward, 1 = reverse
+ */
+#define	ZT_SETPOLARITY		_IOW (ZT_CODE, 92, int)
+
 /* 
  * Startup or Shutdown a span
  */




More information about the svn-commits mailing list