From ed45d6267c2ead5ca9558d720056b469342c0c6f Mon Sep 17 00:00:00 2001 From: Doug Bailey Date: Thu, 20 Aug 2009 19:20:36 +0000 Subject: Add a capability to send only DTMF tones over an on-hook fxs channel git-svn-id: http://svn.asterisk.org/svn/dahdi/tools/trunk@7045 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- fxstest.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/fxstest.c b/fxstest.c index 8260217..130fad5 100644 --- a/fxstest.c +++ b/fxstest.c @@ -117,6 +117,7 @@ int main(int argc, char *argv[]) " vmwi - toggles VMWI LED lamp\n" " hvdc - toggles VMWI HV lamp\n" " neon - toggles VMWI NEON lamp\n" + " dtmf []- Send a sequence of dtmf tones (\"-\" denotes no tone)\n" " dtmfcid - create a dtmf cid spill without polarity reversal\n"); exit(1); } @@ -263,6 +264,38 @@ int main(int argc, char *argv[]) else printf("Success.\n"); } + } else if (!strcasecmp(argv[2], "dtmf")) { + int duration = 50; /* default to 50 mS duration */ + char * outstring = ""; + int dtmftone; + + if(argc < 4) { /* user supplied string */ + fprintf(stderr, "You must specify a string of dtmf characters to send\n"); + } else { + outstring = argv[3]; + if(argc >= 5) { + sscanf(argv[4], "%30i", &duration); + } + printf("Going to send a set of DTMF tones >%s<\n", outstring); + printf("Using a duration of %d mS per tone\n", duration); + /* Flush any left remaining characs in the buffer and place the channel into on-hook transfer mode */ + x = DAHDI_FLUSH_BOTH; + res = ioctl(fd, DAHDI_FLUSH, &x); + x = 500 + strlen(outstring) * duration; + ioctl(fd, DAHDI_ONHOOKTRANSFER, &x); + + for (x = 0; '\0' != outstring[x]; x++) { + dtmftone = digit_to_dtmfindex(outstring[x]); + if (0 > dtmftone) { + dtmftone = -1; + } + res = tone_zone_play_tone(fd, dtmftone); + if (res) { + fprintf(stderr, "Unable to play DTMF tone %d (0x%x)\n", dtmftone, dtmftone); + } + usleep(duration * 1000); + } + } } else if (!strcasecmp(argv[2], "dtmfcid")) { char * outstring = "A5551212C"; /* Default string using A and C tones to bracket the number */ int dtmftone; -- cgit v1.2.3