diff options
author | markster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2002-02-08 15:02:21 +0000 |
---|---|---|
committer | markster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2002-02-08 15:02:21 +0000 |
commit | 380f566d2174975558b56ad0723da74857571b0c (patch) | |
tree | df9951f517431ee7b5927ae0dd64befd8c32c3d9 /fxstest.c | |
parent | 098016b337544a3c3a89bb9df2136082c25b32d8 (diff) |
Version 0.1.6 from FTP
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@54 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'fxstest.c')
-rwxr-xr-x | fxstest.c | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/fxstest.c b/fxstest.c new file mode 100755 index 0000000..9715a1f --- /dev/null +++ b/fxstest.c @@ -0,0 +1,72 @@ +#include <stdio.h> +#include <string.h> +#include <errno.h> +#include <fcntl.h> +#include <stdlib.h> +#include <unistd.h> +#include <sys/ioctl.h> +#include "zaptel.h" +#include "wcfxs.h" + +int main(int argc, char *argv[]) +{ + int fd; + int res; + int x; + if (argc < 3) { + fprintf(stderr, "Usage: fxstest <zap device> <cmd>\n" + " where cmd is one of:\n" + " stats - reports voltages\n" + " regdump - dumps ProSLIC registers\n" + " ring - rings phone\n"); + exit(1); + } + fd = open(argv[1], O_RDWR); + if (fd < 0) { + fprintf(stderr, "Unable to open %s: %s\n", argv[1], strerror(errno)); + exit(1); + } + if (!strcasecmp(argv[2], "ring")) { + fprintf(stderr, "Ringing phone...\n"); + x = ZT_RING; + res = ioctl(fd, ZT_HOOK, &x); + if (res) { + fprintf(stderr, "Unable to ring phone...\n"); + } else { + fprintf(stderr, "Phone is ringing...\n"); + } + } else if (!strcasecmp(argv[2], "stats")) { + struct wcfxs_stats stats; + res = ioctl(fd, WCFXS_GET_STATS, &stats); + if (res) { + fprintf(stderr, "Unable to get stats on channel %s\n", argv[1]); + } else { + printf("TIP: %7.4f Volts\n", (float)stats.tipvolt / 1000.0); + printf("RING: %7.4f Volts\n", (float)stats.ringvolt / 1000.0); + printf("VBAT: %7.4f Volts\n", (float)stats.batvolt / 1000.0); + } + } else if (!strcasecmp(argv[2], "regdump")) { + struct wcfxs_regs regs; + res = ioctl(fd, WCFXS_GET_REGS, ®s); + if (res) { + fprintf(stderr, "Unable to get registers on channel %s\n", argv[1]); + } else { + printf("Direct registers: \n"); + for (x=0;x<NUM_REGS;x++) { + printf("%3d. %02x ", x, regs.direct[x]); + if ((x % 8) == 7) + printf("\n"); + } + printf("\n\nIndirect registers: \n"); + for (x=0;x<NUM_INDIRECT_REGS;x++) { + printf("%3d. %04x ", x, regs.indirect[x]); + if ((x % 6) == 5) + printf("\n"); + } + printf("\n\n"); + } + } else + fprintf(stderr, "Invalid command\n"); + close(fd); + return 0; +} |