#include #include #include #include #include #include #include #include "zaptel.h" #include "tonezone.h" #include "wcfxs.h" static int tones[] = { ZT_TONE_DIALTONE, ZT_TONE_BUSY, ZT_TONE_RINGTONE, ZT_TONE_CONGESTION, ZT_TONE_DIALRECALL, }; int main(int argc, char *argv[]) { int fd; int res; int x; if (argc < 3) { fprintf(stderr, "Usage: fxstest \n" " where cmd is one of:\n" " stats - reports voltages\n" " regdump - dumps ProSLIC registers\n" " tones - plays a series of tones\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"); sleep(2); } } else if (!strcasecmp(argv[2], "tones")) { int x = 0; for (;;) { res = tone_zone_play_tone(fd, tones[x]); if (res) fprintf(stderr, "Unable to play tone %d\n", tones[x]); sleep(3); x=(x+1) % (sizeof(tones) / sizeof(tones[0])); } } 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; int numregs = NUM_REGS; memset(®s, 0, sizeof(regs)); res = ioctl(fd, WCFXS_GET_REGS, ®s); if (res) { fprintf(stderr, "Unable to get registers on channel %s\n", argv[1]); } else { for (x=60;x