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

Shaun Ruffell sruffell at digium.com
Thu Mar 7 13:53:18 CST 2013


On Thu, Mar 07, 2013 at 02:20:00PM -0500, Optical Phoenix wrote:
> On Wed, Mar 6, 2013 at 2:57 PM, Optical Phoenix <opticalphoenix at gmail.com>wrote:
>> On Wed, Mar 6, 2013 at 1:21 PM, Shaun Ruffell <sruffell at digium.com> wrote:
>>> On Wed, Mar 06, 2013 at 11:42:54AM -0500, Optical Phoenix wrote:
>>>>
>>> > When I go to change the rx, its a bit more complex. I have
>>> > learned from this list that dahdi_rbsbits() handles the rx
>>> > bits, but my changes seem to have no effect. Does anyone have
>>> > a good understanding of this function? I would appreciate any
>>> > help you can provide.
>>> >
>>> > case DAHDI_SIG_FXSLS:
>>> > if (!(cursig & DAHDI_BBIT)) {      /*Dennis RINGING  */  /*<----- I think
>>> > this is checking if the state is different from a set value? needs
>>> > clarification*/
>>> >  /* Check for ringing first */
>>> > __dahdi_hooksig_pvt(chan, DAHDI_RXSIG_RING);
>>> > break;
>>> >  }
>>>
>>> This is just checking if new BBIT is 0, which would indicate a
>>> ring.  At the top of dahdi_rbsbits there was already a check to
>>> see if cursig is different from the previously saved rxsig.
> 
> Above Shaun was kind enough to point out that  "if (!(cursig &
> DAHDI_BBIT))" was checking if the BBit is zero.  (thanks again!)
> for what values is this statement not true? it seems that no
> matter what I put in, it comes out as true.

Just to be clear, If I'm following I don't think this is a DAHDI
question but a C programming question? That statement is not true if
the B bit is set in cursig.

For example if you run the following program:

  #include <stdio.h>
  #include <stdbool.h>
  
  #define DAHDI_ABIT              (1 << 3)
  #define DAHDI_BBIT              (1 << 2)
  #define DAHDI_CBIT              (1 << 1)
  #define DAHDI_DBIT              (1 << 0)
  
  static inline bool b_is_not_set(int cursig)
  {
      return !(cursig & DAHDI_BBIT);
  }
  
  static void print_set(int cursig)
  {
      if (b_is_not_set(cursig)) {
          printf("B is not set\n");
      } else {
          printf("B is set\n");
      }
  }
  
  int main(int argc, char *argv[])
  {
      print_set(DAHDI_ABIT);
      print_set(DAHDI_ABIT | DAHDI_BBIT);
      print_set(DAHDI_BBIT | DAHDI_CBIT);
      print_set(DAHDI_ABIT | DAHDI_CBIT);
  }

The output is:

  B is not set
  B is set
  B is set
  B is not set


-- 
Shaun Ruffell
Digium, Inc. | Linux Kernel Developer
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: www.digium.com & www.asterisk.org



More information about the asterisk-dev mailing list