Add a CLI command that will use a DAHDI ioctl to query the registers on the WCTDM series of analog cards to report the tip/ring/battery voltage levels (ideally, we would also be able to report current, but I don't think there is a register for that).
Query the stats from these cards using the WCTDM_GET_STATS ioctl call, which really has nothing to do with chan_dahdi
, it just acts on the DAHDI channels directly. However, since the channel is open by chan_dahdi already, open fails with EBUSY if trying to open the channel again, even if RDONLY, so it doesn't seem like a DAHDI channel can be used by more than one thing at a time. Other use cases like app_flash already have a reference to an existing Asterisk channel, and you can get the DAHDI fd from that, but that doesn't work if there is no Asterisk channel to begin with, so this will likely have to be part of the chan_dahdi
module.
Relevant code: https://github.com/asterisk/dahdi-linux/blob/master/drivers/dahdi/wctdm.c#L2066
TDM400P manual: https://www.sangoma.com/wp-content/uploads/2014/01/tdm400p-manual.pdf
Sample code in MWI loop thread:
if (i->sig & __DAHDI_SIG_FXS && !i->ignore_fxo_query) {
< struct wctdm_stats stats;
< struct wctdm_regs regs;
< ast_debug(3, "Querying FXO channel %d\n", i->channel);
< if (ioctl(i->subs[SUB_REAL].dfd, WCTDM_GET_STATS, &stats)) {
< ast_debug(1, "ioctl failed: %s\n", strerror(errno));
< if (errno == ENOTTY) {
< /* Don't try this again. */
< i->ignore_fxo_query = 1;
< }
< } else if (0) {
< ast_debug(1, "Channel %d: tipvolt %d, ringvolt %d, batvolt %d\n", i->channel, stats.tipvolt, stats.ringvolt, stats.batvolt);
< if (ioctl(i->subs[SUB_REAL].dfd, WCTDM_GET_REGS, ®s)) {
< ast_debug(1, "ioctl failed: %s\n", strerror(errno));
< } else {
< //int x;
< //#define NUM_FXO_REGS 60
< //for (x=0;x<NUM_FXO_REGS;x++) {
< // ast_debug(3, "regs.direct[%d] = %d\n", x, regs.direct[x]);
< //}
< }
< }
< }
You must be