summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarkster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2002-08-22 16:51:05 +0000
committermarkster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2002-08-22 16:51:05 +0000
commit1c9885532e2572eeb5a95fa240c501d5fb91459a (patch)
tree70202dba33ce0175c398bcaa09114f94b4fec8a8
parent9ba4e07b16bf5efa450f9ab3b9f1eaa937d54a82 (diff)
Version 0.3.0 from FTP
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@99 5390a7c7-147a-4af0-8ec9-7488f05a26cb
-rwxr-xr-xusbfxstest.c86
-rwxr-xr-xwcfxsusb.c8
-rwxr-xr-xwcusb.c8
3 files changed, 98 insertions, 4 deletions
diff --git a/usbfxstest.c b/usbfxstest.c
new file mode 100755
index 0000000..1174dda
--- /dev/null
+++ b/usbfxstest.c
@@ -0,0 +1,86 @@
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include "zap.h"
+#include <linux/zaptel.h>
+
+int main(int argc, char *argv[])
+{
+ ZAP *z;
+ ZT_PARAMS p;
+ char tmp[1024];
+ int len;
+ int res;
+ int firstpass=1;
+ int linear=0;
+ if (argc < 2) {
+ fprintf(stderr, "Usage: usbfxstest <device> [options]\n");
+ exit(1);
+ }
+ if (argc > 2) {
+ if (!strcasecmp(argv[2], "linear")) {
+ linear=1;
+ }
+ }
+ z = zap_open(argv[1], 0);
+ if (!z) {
+ fprintf(stderr, "Unable to open %s: %s\n", argv[1], strerror(errno));
+ exit(1);
+ }
+ /* Ring phone until it goes off hook. This shows how you mix direct
+ and indirect calls */
+ for (;;) {
+ p.channo = 0;
+ res = ioctl(zap_fd(z), ZT_GET_PARAMS, &p);
+ if (res) {
+ fprintf(stderr, "Failed to get parameters: %s\n", strerror(errno));
+ exit(1);
+ }
+ if (p.rxisoffhook)
+ break;
+ if (firstpass)
+ res = zap_ringclid(z, "2565551212", "Nifty Cool");
+ else
+ res = zap_ring(z, 1);
+ }
+ if (linear) {
+ printf("Going linear!\n");
+ zap_setlinear(z, linear);
+ }
+ printf("Off Hook!\n");
+ len = 204;
+ for (;;) {
+ /* Record, play, and check for events */
+ res = zap_recchunk(z, tmp, len, ZAP_DTMFINT);
+ if (res == len) {
+ res = zap_playchunk(z, tmp, len, 0);
+ }
+ if (res < len) {
+ res = zap_getevent(z);
+ if (zap_dtmfwaiting(z)) {
+ zap_getdtmf(z, 1, NULL, 0, 1, 1, 0);
+ printf("Got DTMF: %s\n", zap_dtmfbuf(z));
+ zap_clrdtmfn(z);
+ } else if (res) {
+ switch(res) {
+ case ZAP_EVENT_ONHOOK:
+ printf("On Hook!\n");
+ break;
+ case ZAP_EVENT_RINGANSWER:
+ printf("Off hook!\n");
+ break;
+ case ZAP_EVENT_WINKFLASH:
+ printf("Flash!\n");
+ break;
+ default:
+ printf("Unknown event %d\n", res);
+ }
+ }
+ }
+ }
+ return 0;
+}
diff --git a/wcfxsusb.c b/wcfxsusb.c
index 7b0f615..9985dbd 100755
--- a/wcfxsusb.c
+++ b/wcfxsusb.c
@@ -311,7 +311,7 @@ static void wcusb_async_control(urb_t *urb)
p->urbcount--;
if (urb->status) {
printk("Error in transfer...\n");
- return;
+ /* return; */
}
if (!(p->flags & FLAG_RUNNING)) {
return;
@@ -1407,8 +1407,12 @@ static void wc_usb_disconnect(struct usb_device *dev, void *ptr)
if (p->pvt_data)
kfree(p->pvt_data);
kfree(ptr);
- } else
+ } else {
+ /* Generate alarm and note that we're dead */
+ p->span.alarms = ZT_ALARM_RED;
+ zt_alarm_notify(&p->span);
p->dead = 1;
+ }
}
printk("wcusb: Removed a Wildcard device\n");
return;
diff --git a/wcusb.c b/wcusb.c
index f2acff9..e00bcd3 100755
--- a/wcusb.c
+++ b/wcusb.c
@@ -203,7 +203,7 @@ static void wcusb_async_control(urb_t *urb)
p->urbcount--;
if (urb->status) {
printk("Error in transfer...\n");
- return;
+ /* return is the "right thing", but don't... */
}
if (!(p->flags & FLAG_RUNNING)) {
return;
@@ -1212,8 +1212,12 @@ static void wc_usb_disconnect(struct usb_device *dev, void *ptr)
if (p->pvt_data)
kfree(p->pvt_data);
kfree(ptr);
- } else
+ } else {
+ /* Generate alarm and note that we're dead */
+ p->span.alarms = ZT_ALARM_RED;
+ zt_alarm_notify(&p->span);
p->dead = 1;
+ }
}
devcount--;
printk("wcusb: Removed a Wildcard device\n");