72a74,77 > #ifdef REGDUMP > #include > #endif > 3357a3364,3458 > #ifdef REGDUMP > static char *dahdi_show_regdump(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) > { > struct wctdm_stats stats; > struct wctdm_regs regs; > > struct dahdi_pvt *tmp = NULL; > struct dahdi_pvt *start; > > ast_mutex_t *lock; > int numregs = NUM_REGS; > int res; > int x; > int zapfd = 0; > int channel; > start = iflist; > > switch (cmd) { > case CLI_INIT: > e->command = "dahdi show regdump"; > e->usage = > "Usage: dahdi show regdump \n" > " Returns voltage on a DAHDI channel (Digium cards only)\n"; > return NULL; > case CLI_GENERATE: > return NULL; > } > if (a->argc != 4) > return CLI_SHOWUSAGE; > > lock = &iflock; > channel = atoi(a->argv[3]); > ast_mutex_lock(lock); > tmp = start; > while (tmp) { > if (tmp->channel == channel) { > zapfd = tmp->subs[SUB_REAL].dfd; > ast_mutex_unlock(lock); > break; > } > tmp = tmp->next; > } > > if (!zapfd) > { > ast_cli(a->fd, "Unable to find given channel %d\n", channel); > ast_mutex_unlock(lock); > return CLI_FAILURE; > } > > memset(®s, 0, sizeof(regs)); > res = ioctl(zapfd, WCTDM_GET_REGS, ®s); > > if (res) { > ast_cli(a->fd, "Unable to get registers on channel %s\n", a->argv[3]); > } else { > for (x=60;x if (regs.direct[x]) > break; > } > if (x == NUM_REGS) > numregs = 60; > ast_cli(a->fd, "Direct registers: \n"); > for (x=0;x ast_cli(a->fd, "%3d. %02x ", x, regs.direct[x]); > if ((x % 8) == 7) > ast_cli(a->fd, "\n"); > } > if (numregs == NUM_REGS) { > ast_cli(a->fd, "\n\nIndirect registers: \n"); > for (x=0;x ast_cli(a->fd, "%3d. %04x ", x, regs.indirect[x]); > if ((x % 6) == 5) > ast_cli(a->fd, "\n"); > } > } > ast_cli(a->fd, "\n\n"); > } > > // now show voltage > res = ioctl(zapfd, WCTDM_GET_STATS, &stats); > if (res) { > ast_cli(a->fd, "Unable to get stats on channel %s\n", a->argv[3]); > } else { > ast_cli(a->fd, "TIP: %7.4f Volts\n", (float)stats.tipvolt / 1000.0); > ast_cli(a->fd, "RING: %7.4f Volts\n", (float)stats.ringvolt / 1000.0); > ast_cli(a->fd, "VBAT: %7.4f Volts\n", (float)stats.batvolt / 1000.0); > } > ast_cli(a->fd, "\n"); > > return CLI_SUCCESS; > } > #endif > > < if (res) { --- > if (res > 0) { 13011a13122,13124 > #ifdef REGDUMP > AST_CLI_DEFINE(dahdi_show_regdump, "Show voltage on DAHDI channel"), > #endif