[asterisk-dev] Change RX Signalling Bits in Dahdi drivers

Optical Phoenix opticalphoenix at gmail.com
Mon Mar 11 15:24:44 CDT 2013


On Fri, Mar 8, 2013 at 4:17 PM, Optical Phoenix <opticalphoenix at gmail.com>wrote:

> Thanks very much for the positive response, I will try to keep things
> reasonable.
>
> 1) If you just want to be able to have "hot-lines" that
>> connect stations without dialing, you might not even need to
>> add a new signaling type. Check out the 'immediate' option in
>> chan_dahdi which could be used to configure an extension to
>> automatically ring a group of extensions as opposed to
>> providing dial-tone and reading digits.
>>
> Yes, I am familiar withe the immediate=yes command, but as I will mention
> below, I have a different need
>
>>
>> 2) If you *really* do need PLAR specific signaling because
>> you're connecting to another system that implements this, are
>> you using a channel bank and digital lines or an analog
>> interface card?   The analog interface cards handle the
>> signaling a little differently than the digital cards.
>>
>
> Right again, I am connecting directly to a t1 line with PLAR signalling
> using a sangoma a104 t1 card. The carrier looped line 1 to line 2, and I am
> testing on my own. Earlier, when I got TX working I was testing with a live
> person with the carrier.
>
> So thats the whole story. so far my edits of the dahdi_rbsbits have
> created... interesting results. Now when I get a call in on the line, when
> the rx bits go from 1111 to 0000 ,I get nothing. no ring, or anything.
> Then, when the line is hung up, and the 0000 goes to 1111 THEN I get a ring
> on the line I am assuming I have fouled something up. Do you know if
> "cursig" a single bit or the whole abcd bit pattern? That is the only thing
> I can think of that could be fouling this up.
>
>    case DAHDI_SIG_FXSLS:
> if (!(cursig & DAHDI_BITS_ABCD)) {
>  /* Check for ringing first */
> __dahdi_hooksig_pvt(chan, DAHDI_RXSIG_RING);
>  break;
> }
> if ((chan->sig != DAHDI_SIG_FXSLS) && (!(~cursig & DAHDI_BITS_ABCD))) {
>     /* if went on hook */
> __dahdi_hooksig_pvt(chan, DAHDI_RXSIG_ONHOOK);
>  } else {
> __dahdi_hooksig_pvt(chan, DAHDI_RXSIG_OFFHOOK);
> }
>  break;
>
> Still Digging,
> Dennis
>



Great News,
I was able to get PLAR signalling working!  Thanks for the help! (Now onto
creating a proper signalling type!)

After learning a bit more about debugging c code, I was able to get it up
and running so I could test. Here is the code changes I made, for people in
a hurry. I am editing dahdi-base.c in the 2.6.1 source.

line number
2581 .bits[DAHDI_TXSIG_ONHOOK]  = DAHDI_BITS_ABCD,
2582 .bits[DAHDI_TXSIG_OFFHOOK] = (0),
2583 .bits[DAHDI_TXSIG_START]   = DAHDI_BITS_ABCD,

8233  if ((cursig & DAHDI_BITS_ABCD)) {

8238  if ((chan->sig != DAHDI_SIG_FXSLS) && (!(~cursig & DAHDI_BITS_ABCD)))
{


More complete code below
at around line 2559
static void dahdi_rbs_sethook(struct dahdi_chan *chan, int txsig, int
txstate,
int timeout)
{
static const struct {
unsigned int sig_type;
/* Index is dahdi_txsig enum */
unsigned int bits[DAHDI_TXSIG_TOTAL];
} outs[NUM_SIGS] = {
{
/*
 * We set the idle case of the DAHDI_SIG_NONE to this pattern to make idle
E1 CAS
 * channels happy. Should not matter with T1, since on an un-configured
channel,
 * who cares what the sig bits are as long as they are stable
 */
.sig_type = DAHDI_SIG_NONE,
.bits[DAHDI_TXSIG_ONHOOK]  = DAHDI_BITS_ACD,
}, {
.sig_type = DAHDI_SIG_EM,
.bits[DAHDI_TXSIG_OFFHOOK] = (0),
.bits[DAHDI_TXSIG_START]   = DAHDI_BITS_ABCD,  /*changed by Dennis Wright
for PLAR BUT NOT USED*/
}, {
.sig_type = DAHDI_SIG_FXSLS,
.bits[DAHDI_TXSIG_ONHOOK]  = DAHDI_BITS_ABCD, /*changed by Dennis Wright
for PLAR*/
.bits[DAHDI_TXSIG_OFFHOOK] = (0), /*changed by Dennis Wright for PLAR.
perhaps can use DAHDI_SIG_NONE instead*/
.bits[DAHDI_TXSIG_START]   = DAHDI_BITS_ABCD, /*changed by Dennis Wright
for PLAR*/
}, {
.sig_type = DAHDI_SIG_FXSGS,
.bits[DAHDI_TXSIG_ONHOOK]  = DAHDI_BITS_ABCD,
.bits[DAHDI_TXSIG_OFFHOOK] = (0),
#ifndef CONFIG_CAC_GROUNDSTART
.bits[DAHDI_TXSIG_START]   = DAHDI_BITS_ABCD,
#endif
}, {
.sig_type = DAHDI_SIG_FXSKS,
.bits[DAHDI_TXSIG_ONHOOK]  = DAHDI_BITS_ABCD,
.bits[DAHDI_TXSIG_OFFHOOK] = (0),
.bits[DAHDI_TXSIG_START]   = DAHDI_BITS_ABCD,
}, {
.sig_type = DAHDI_SIG_FXOLS,
.bits[DAHDI_TXSIG_ONHOOK]  = (0),  /*changed by Dennis Wright for PLAR BUT
NOT USED*/
.bits[DAHDI_TXSIG_OFFHOOK] = DAHDI_BITS_ABCD,  /*changed by Dennis Wright
for PLAR BUT NOT USED*/
}, {
.sig_type = DAHDI_SIG_FXOGS,
.bits[DAHDI_TXSIG_ONHOOK]  = DAHDI_BITS_ABCD,
.bits[DAHDI_TXSIG_OFFHOOK] = DAHDI_BITS_BD,
}, {
.sig_type = DAHDI_SIG_FXOKS,
.bits[DAHDI_TXSIG_ONHOOK]  = DAHDI_BITS_BD,
.bits[DAHDI_TXSIG_OFFHOOK] = DAHDI_BITS_BD,
.bits[DAHDI_TXSIG_KEWL]    = DAHDI_BITS_ABCD,
}, {
.sig_type = DAHDI_SIG_SF,
.bits[DAHDI_TXSIG_ONHOOK]  = DAHDI_BITS_BCD,
.bits[DAHDI_TXSIG_OFFHOOK] = DAHDI_BITS_ABCD,
.bits[DAHDI_TXSIG_START]   = DAHDI_BITS_ABCD,
.bits[DAHDI_TXSIG_KEWL]    = DAHDI_BITS_BCD,
}, {
.sig_type = DAHDI_SIG_EM_E1,
.bits[DAHDI_TXSIG_ONHOOK]  = DAHDI_DBIT,
.bits[DAHDI_TXSIG_OFFHOOK] = DAHDI_BITS_ABD,
.bits[DAHDI_TXSIG_START]   = DAHDI_BITS_ABD,
.bits[DAHDI_TXSIG_KEWL]    = DAHDI_DBIT,
}
};

and later at around 8174

/**
 * dahdi_hooksig() - send a signal on a channel to userspace
 * @chan: the DAHDI channel
 * @rxsig: signal (number) to send
 *
 * Called from a channel driver to send a DAHDI signal to userspace.
 * The signal will be queued for delivery to userspace.
 *
 * If the signal is the same as previous one sent, it won't be re-sent.
 */
void dahdi_hooksig(struct dahdi_chan *chan, enum dahdi_rxsig rxsig)
{
  /* skip if no change */
unsigned long flags;
spin_lock_irqsave(&chan->lock, flags);
__dahdi_hooksig_pvt(chan,rxsig);
spin_unlock_irqrestore(&chan->lock, flags);
}


/**
 * dahdi_rbsbits() - set Rx RBS bits on the channel
 * @chan: the DAHDI channel
 * @cursig: the bits to set
 *
 * Set the channel's rxsig (received: from device to userspace) and act
 * accordingly.
 */
void dahdi_rbsbits(struct dahdi_chan *chan, int cursig)
{
unsigned long flags;
chan_notice(chan, "DENNIS dahdi_rbsbits started,Detected sigbits change to
%04x\n", cursig);
if (cursig == chan->rxsig)
return;

if ((chan->flags & DAHDI_FLAG_SIGFREEZE)) return;

spin_lock_irqsave(&chan->lock, flags);
switch(chan->sig) {
    case DAHDI_SIG_FXOGS: /* FXO Groundstart */
/* B-bit only matters for FXO GS */
if (!(cursig & DAHDI_BBIT)) {
__dahdi_hooksig_pvt(chan, DAHDI_RXSIG_START);
break;
}
/* Fall through */
    case DAHDI_SIG_EM:  /* E and M */
    case DAHDI_SIG_EM_E1:
    case DAHDI_SIG_FXOLS: /* FXO Loopstart */
    case DAHDI_SIG_FXOKS: /* FXO Kewlstart */
if (cursig & DAHDI_ABIT)  /* off hook */
__dahdi_hooksig_pvt(chan,DAHDI_RXSIG_OFFHOOK);
else /* on hook */
__dahdi_hooksig_pvt(chan,DAHDI_RXSIG_ONHOOK);
break;

   case DAHDI_SIG_FXSKS:  /* FXS Kewlstart */
   case DAHDI_SIG_FXSGS:  /* FXS Groundstart */
/* Fall through */
   case DAHDI_SIG_FXSLS:
if ((cursig & DAHDI_BITS_ABCD)) {      /*Dennis RINGING. Not super sure if
I did this correctly, or its just not used. will be true if given anything
BUT 0000, which is logically incorrect. */
/* Check for ringing first */

        if ((debug & DEBUG_RBS)) {
                chan_notice(chan, "DENNIS RING SIGNAL,Detected sigbits
change to %04x\n", cursig); /*added for debugging these notices show up in
the */
        }
__dahdi_hooksig_pvt(chan, DAHDI_RXSIG_RING);
break;
}
if ((chan->sig != DAHDI_SIG_FXSLS) && (!(~cursig & DAHDI_BITS_ABCD))) { /*
DENNIS added PLAR. checks if bit pattern is 1111. is false (and goes off
hook) for everything else*/
    /* if went on hook */

        if ((debug & DEBUG_RBS)) {
                chan_notice(chan, "DENNIS ONHOOK,Detected sigbits change to
%04x\n", cursig);  /*added for debugging*/
        }
__dahdi_hooksig_pvt(chan, DAHDI_RXSIG_ONHOOK);
} else {

        if ((debug & DEBUG_RBS)) {
                chan_notice(chan, "DENNIS OFFHOOK,Detected sigbits change
to %04x\n", cursig); /*added for debugging*/
        }

__dahdi_hooksig_pvt(chan, DAHDI_RXSIG_OFFHOOK);
}
break;
   case DAHDI_SIG_CAS:
/* send event that something changed */
__qevent(chan, DAHDI_EVENT_BITSCHANGED);
break;

   default:
break;
}

 There are several gotchas I ran into. I am using sangoma cards, so to
reload I was doing a "wanrouter stop" and "wanrouter start" to reload dahdi
after recompiling. When this didn't seem to be working, I started using
service dahdi stop. I then checked the running programs with ps aux |grep
dahdi, I saw there was a dahdi_tool still running.  To do the debugging I
used  "cat /sys/module/dahdi/parameters/debug" to check the debug level,
then "echo 32 >/sys/module/dahdi/parameters/debug" to debug for rbs. I
turned this off when I figured out I could put chan_notice(chan,"WORDS
HERE") to generate my own debug comments. Debugging this way was a big
help, as it led to the discovery that the changes weren't being made. I
used replaced FXSLS to make my PLAR signalling work, so you have to set
your signalling to FXSLS if you want to use this code.

I will post the cleaned up code shortly, and shortly after that I will post
the new Signaling type, so you can set your signalling type to PLAR in the
chan_dahdi.conf. I am going to search out all the places
where DAHDI_SIG_FXSLS is mentioned, and try to replicate it.  If anyone
knows of a guide that might help with this, or has done it before, feel
free to chime in.

Oh, and I noticed that in the default wanrouter auto configure for
chan_dahdi.conf sets usecallerid to yes. This creates a 10 second delay
while asterisk is waiting for caller id signals that will never come, so
set it to no.

Thanks,
Dennis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20130311/de24e4d7/attachment-0001.htm>


More information about the asterisk-dev mailing list