Dahdi For Analog

Q1, Where to get lastest openvox dahdi driver?

http://www.openvox.cn/pub/drivers/dahdi-linux-complete/openvox_dahdi-linux-complete-current.tar.gz

Q2, How can you compile dahdi?

Openvox hardware requires drivers and libraries that are not integrated with the Linux kernel. These drivers and libraries including application software
For an introduction to Asterisk®setup and features, please refer to: http://www.asterisk.org

  • Linux 2.6.18 or later
Openvox recommends CentOS, Debian, RedHat, and Ubuntu distributions of Linux.
  • Development libraries and headers for ncurses, zlib, openssl and libnewt
  • GCC and standard software build tools
Debian like OS:  # apt-get install gcc libncurses-devel kernel-devel kernel-smp-devel gcc-c++ libnewt-dev zlib-devel unixODBC-devel libtool make
Red Hat like OS: # yum install gcc ncurses-devel libtermcap-devel kernel-devel gcc-c++ newt-devel zlib-devel unixODBC-devel libtool make
Note: These commands includes optional libaries which are used by Asterisk and Asterisk-addons 

It is recommended that you use the most recent version of the Asterisk, DAHDI, and libpri software for the best results. If you have previously installed any of these, Openvox recommends that you upgrade to the latest “-current” version of each.

Also, please be aware that you may need to re-compile Asterisk if you are upgrading DAHDI or libpri. The Application programming interface (API) of these packges tends to change between versions, re-compilation is the only way that you make Asterisk's adapt  to the new API. 

# wget http://www.openvox.cn/pub/drivers/dahdi-linux-complete/openvox_dahdi-linux-complete-current.tar.gz
# tar -zxvf  openvox_dahdi-linux-complete-current.tar.gz
# cd dahdi-linux-complete-X.X.X+X.X.X.tar.gz
# make 
# make install
# make config
# wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-X.X.X.tar.gz
# tar -zxvf libpri-X.X.X.tar.gz
# cd libpri-X.X.X/
# make 
# make install

Q3, How to use fxstest tool for DAHDI FXS adapters?

Hardware Environment:A800P(2FXS+1FXO),A400P(2FXS+1FXO),BBK HCD007(6082)TSDL
Software Environment:Centos 5.5,dahdi-linux-complete-2.3.0.1+2.3.0 
1.Compiling and installation
1)Please input following commands:
#cd /usr/src/dahdi-linux-complete-2.3.0.1+2.3.0/tools
#make menuselect
Select "fxstest" in the menu Then Save&Exit.

2)Beginning to compile dahdi.Input commands like below:
#cd /usr/src/dahdi-linux-complete-2.3.0.1+2.3.0 
#make && make install && make config

3)Reloading the drivers.Perform the following command:
#service dahdi stop
#modprobe –r wctdm 
#modprobe –r opvxa1200 
#modprobe –r dahdi 
#modprobe dahdi 
#modprobe opvxa1200 opermode=YOUR COUNTRY 
#modprobe wctdm opermode= YOUR COUNTRY 
#dahdi_genconf 
#dahdi_cfg –vvv(If there is no error,then installed OK) 
#dahdi_scan(It prints information about DAHDI spans in the system.For analog spans it provides a list of channels.)

2.Beginning to test
All of thoses tests operate on a single dahdi channel which has to be an FXS port,and must not be in use by Asterisk or any other program.Analog adapters should be intended to connect phones. The command has two mandatory parameters.The first parameters is the device file to operate on.It is typically /dev/dahdi/NN,a device file under /dev/dahdi. The second parameter is the name of the command to run on that channel.

1)Reporting voltages:
#fxstest /dev/dahdi/1 stats //A800P volts of channel 1

TIP: -5.6400 Volts 
RING: -54.1440 Volts 
VBAT: -62.7920 Volts

#fxstest /dev/dahdi/11 stats //A400P volts of channel 3

TIP: -5.6400 Volts
RING: -54.8960 Volts
VBAT: -63.9200 Volts

2)Dumping ProSLIC registers:
#fxstest /dev/dahdi/1 regdump //A800P registers of channel 1

Direct registers: 
  0. 05    1. 28    2. 18    3. 00    4. 18    5. 00    6. 00    7. 00  
  8. 00    9. 00   10. 08   11. 33   12. 80   13. 10   14. 00   15. 00  
 ….
 
Indirect registers: 
  0. 55c2    1. 51e6    2. 4b85    3. 4937    4. 3333    5. 0202  
  6. 0202    7. 0198    8. 0198    9. 0611   10. 0202   11. 00e5  
….

3)Playing a series of tones: 
#fxstest /dev/dahdi/1 tones
Then picking up the phone,you could hear of a series of tones.Press Ctrl+C to stop this command. 

4)Creating a dtmf cid spill without polarity reversal: 
#fxstest /dev/dahdi/1 dtmfcid

Going to send a set of DTMF tones >A5551212C<
Phone is ringing
Ringing Done

5)Testing polarity reversal(This test must be followd in creating a dtmf cid):
#fxstest /dev/dahdi/1 polarity

Twiddling polarity...
Polarity is forward...
Polarity is reversed...
Polarity is forward...

6)Sending a sequence of dtmf tones:
#fxstest /dev/dahdi/1 dtmf "12324" 70

Going to send a set of DTMF tones >12324<
Using a duration of 70 mS per tone

Then you can see the set of DTMF tones”12324” sent on the phone. Note:The duration should be 70ms or above to display whole sequence on the phone.

7)Toggling VMWI lamp(A800P not supported): 
#fxstest /dev/dahdi/11 vmwi

Twiddling vmwi ...
Set 1 Voice Message...
Set 2 Voice Messages...
Set No Voice messages...


Q4, Unable to create channel of type 'DAHDI' (Cause 0 - Unknown)

This is most commonly caused by the absence of chan_dahdi module Run the command module load chan_dahdi.so within the Asterisk CLI to correct the problem. In the event that the module cannot be loaded, you will need to confirm if the module exist or check the module configuration for any issues.

In order to generate the default configuration for your OpenVox cards you can use the following steps

  1. Log into the system as root

  2. Execute dahdi_genconf -vv

  3. Add #include dahdi-channels.conf at the end of the file /etc/asterisk/chan_dahdi.conf

Note: dahdi_genconf generates the default configuration for the modules loaded that detected the cards, it for some reason dahdi_genconf output is empty you will may need to update your DAHDI version and make sure that all the modules are being loaded. (Before you compile and install DAHDI, make sure that the file /etc/dahdi/module is removed so the update process will generate a new file)

Q5, How do I record calls using dahdi_monitor?

The dahdi_monitor utility can be used to take recordings at the driver level of DAHDI channels, and to visually monitor volume levels on a channel.  
Note: When using dahdi_monitor, the first parameter is always the channel number, as seen by DAHDI, you will need to check the DAHDI configuration file in order to find out the channel number of the specifict  card that you want to troubleshoot.  Also for more information about the application options, please run  dahdi_monitor without any options. 

Visual Monitoring

To visually monitor a channel, run the following command: dahdi_monitor X -v  (Where 'X' is the channel number of your choosing.)

Recording

You have many options when recording audio using dahdi_monitor. You can split the audio into separate files for TX and RX to better distinguish which side of the communication is having an issue, or mix TX and RX into the same file. You can also get the audio before it is sent through echo-cancellation as well as after it has come through echo-cancellation.
For troubleshooting we normally split TX and RX into separate files, but collecting the audio prior to echo-cancellation depends on the situation.
 
Currently, as of DAHDI 2.2.1 and all previous versions of DAHDI and Zaptel, you can not get audio prior to echo-cancellation when using a VPM hardware echo-cancellation module. If a hardware echo-cancellation module is installed and in-use, all audio captured through dahdi_monitor will be post echo-cancellation.
dahdi_monitor normally records audio to a 'raw' audio format. For this reason, we often use the extension '.raw' when naming files for recording audio. However, newer versions of dahdi_monitor (2.2.1?) also support saving audio to wave format. To enable this, you simple change the extension of specified file names to '.wav' instead of raw.
 
When taking recordings it is important to name each file to give an indication of what is recorded in that file. Engineering has specified a standard for naming these files to make them readily understandable. The generic format is as follows:
 
<echocan type>-<version of echocan>-<PRE or POST echocan>-<TX or RX>-<echocan ON or OFF (hardware only)>.wav
 
Example:
vpm-tx-on.wav
vpm-rx-off.wav
hpec-pre-tx.wav
hpec-post-rx.wav 
Example Usage
 
Only post echo-cancellation
  • dahdi_monitor 1 -m -r vpm-rx-on.wav -t vpm-tx-on.wav
 
Pre and post echo-cancellation
  • dahdi_monitor 1 -m -r hpec-v10.04.001-post-rx.wav -t hpec-post-tx.wav -R hpec--pre-rx.wav -T hpec-v10.04.001-pre-tx.wav
 
Only pre echo-cancellation with visualization
  • dahdi_monitor 1 -m -v -R hpec-pre-rx.wav -T hpec-pre-tx.wav

When you have finished recording, simply hit Ctrl + c to kill the program and stop recording.

Q6, How to confirm if hardware EC detected in your system?

1) You can execute the command #dmesg | grep -i VPM

2) After confirm hardware EC detected, you need to enable echocancel under /etc/asterisk/chan-dahdi.conf file .

Once you've verified that the VPM firmware loaded successfully, check the file /etc/asterisk/chan_dahdi.conf for the "echocancel" line. To enable the VPM, this setting needs to be set to "yes"

echocancel=yes
The 'echocancel' parameter must be declared before the 'channel' parameter in order to turn on echo cancellation for those channels.
It's very important to mention that Asterisk also allows a numerical value as echocancel parameter but it only applies when your system is using software echo cancellation. When hardware is installed the numerical value will be ignored.
3) You can determine if echo cancellation is enabled for a given DAHDI channel by issuing the following command in the Asterisk CLI:
dahdi show channel X
 
Where 'X' is the number of the channel you wish to examine. You should see a line in that output similar to this:
 
Echo Cancellation: 128 taps, currently OFF
 
Note that echo cancellation will only show as ON when a call is currently active on that channel. The number of taps can be used to verify that it is enabled instead. The number of taps reported for a given channel should match the value of the echocancel parameter. If the number of taps is reported as 0 or 1, then echocancellation is not enabled.
 
4) Alternatively, you can run the command 'lsdahdi' from the Linux shell to print out a list of all the configured DAHDI channels and see at a glance what echo cancellation is being used. You should see lines that resembles the following:
 
1 PRI   (In use) (EC: VPMOCT128 - ACTIVE)
2 PRI   (In use) (EC: VPMOCT128 - INACTIVE)
3 PRI   (In use) (EC: VPMOCT128 - ACTIVE)
4 PRI   (In use) (EC: VPMOCT128 - INACTIVE)
 
The "EC" value is the type of echo canceler being used, while the "ACTIVE" and "INACTIVE" statuses reflect whether that channel is currently on a call or not. This can be an effective way of seeing at a glance whether the VPM is being used by all of your DAHDI channels.

Q7, How to use fxotune?

Notes:
-'#' indicates a command to be entered in the bash prompt as root. Do not type the '#' or the command will not execute.
- It's best to do this during a maintanance window, as you will be using the lines and may be restarting Dahdi and Asterisk.  

1) Verify that you are using the latest version of dahdi-linux and dahdi tools. If not, follow the README directions to upgrade. 

       -To find your Dahdi-Tools version and Dahdi-linux version, at the bash prompt enter the command:

          # dahdi_cfg -v

      - If dahdi doesn't show up on this list, reboot the system and run the command again

2) Verify the channels you are going to tune are not in use. 
 
3) From the bash prompt enter the command: 

       # fxotune

   and examine the options listed.

    The most commonly used command option is '-i' '[0-9]' which will run fxotune on every channel from 1 to 252.  Another common option is -n which will set the number to dial that cancels dialtone.

  An example command that will calibrate echo settings on channels 1 through 24 is:

         # fxotune -i -n 4 -b 1 -e 24 -p -vvv

The -p option is added to print the top five detected echo cancellation parameters.  See the note below about detuning the fxotune output.  

4) After determining what options your system needs, type the entire command at the bash prompt, formatted as the example above.  Fxotune should take about a minute per channel.

5) When fxotune is complete, restart the system, or restart dahdi using 

      # /etc/init.d/dahdi stop
      # /etc/init.d/dahdi start
  or
      # service dahdi stop
      # service dahdi start

The recommend step is to restart the system.  This will apply the changes to the module.  If the system or dahdi isn't restarted, then the changes are only written to /etc/fxotune.conf but not loaded onto the module.

For more detailed information about fxotune and it's options, read the man page by entering the command:
       # man fxotune

About the -p option to fxotune:  this can be useful in "detuning" the hardware echo canceler, since allowing more noise into the system may allow the echo canceler to be more effective.  To detune the fxotune settings, choose one of the top five scores from fxotune, select a line that does not have coefficients of all zeroes, and place this line in /etc/fxotune.conf.

Here is a simulated fxotune result, taken from fxotune -p:

Top 5 results for Acim2_tune Test
Res #1: index=15,   0,  0,  0,  0,  0,  0,  0,  0,  0: magnitude = 8, echo = -60.4568 dB
Res #2: index=9,  0,253,254,  2,255,  0,  0,  0: magnitude = 190, echo = -32.6914 dB
Res #3: index=5,  1,249,254,  4,253,  1,  0,  0: magnitude = 310, echo = -28.4269 dB
Res #4: index=5,252,250,  1,  1,254,  0,255,  0: magnitude = 403, echo = -26.1399 dB
Res #5: index=5,  3,251,250,  2,253,255,255,255: magnitude = 454, echo = -25.1064 dB

fxotune will write the following to /etc/fxotune.conf:

1=15,0,0,0,0,0,0,0,0

To detune the line, replace that line with the second result (first result without all zeroes for the from above:

1=9,0,253,254,2,255,0,0,0

Again, this was simulated, your values will be much more appropriate for your system.

Q8, Analog card is not being detected

If you have PBX system (such as FreePBX, Elastix or AsteriskNOW) that is unable to detect the card, you may need to reinstall DAHDI. 

How to determine if the card is being detected by the Operating System?

Before installing the latest DAHDI driver, it's important to check if the analog card is detected by the Operating System by running the command: #lspci (This process will rule out any potential hardware issue with the card or the motherboard) 

If one of the previous devices are shown by the command, you have confirmed that the card is being detected by the Operating System.

The next step would be to confirm if you have the correct version of DAHDI installed. You can run the command asterisk -rx"dahdi show version" or dmesg | grep -i dahdi

# asterisk -rx"dahdi show version"

DAHDI Version: 2.7.0.2 Echo Canceller: 

# dmesg | grep -i dahdi

[   19.430444] dahdi: Version: 2.7.0.2

[   19.433360] dahdi: Telephony Interface Registered on major 196

[   20.408099] dahdi_transcode: Loaded.

[   20.580588] INFO-xpp: FEATURE: with sync_tick() from DAHDI

The output of dmesg may not show the version of DAHDI; please make sure to reboot your system if you encounter this issue. 


If your PBX does not have 2.8.0.1 or later, you won't be able to use our new generation of cards. 

How to get help

PBX system such as Elastix, FreePBX and AsteriskNOW are third party software packages that are supported by their respective developers. Digium recommend to contact them for instruction of how to install the DAHDI-2.8+

AsteriskNOW is a project maintained by the Asterisk Community; it's our understanding that they are working on including DAHDI-2.8 in a future release. 

How to install DAHDI-2.8+  from source. 

Please be aware that this process may break your system, some versions of DAHDI do not have the necessary API that Asterisk uses to communicate. Please make sure to make a backup of your system before continuing. 

Connect to the Linux shell on your PBX using ssh (or an ssh client, such as Putty).

  1. Update your system to the last version available

#yum update

  1. Install DAHDI dependencies

  • Linux  2.6 kernel headers

  • Development libraries and headers for ncurses, zlib, libnewt and openssl

  • GCC and standard software build tools

#yum install gcc ncurses-devel libtermcap-devel gcc-c++ newt-devel zlib-devel libtool make libxml2 libxml2-devel

  1. Navigate to the /usr/src folder:

#cd /usr/src

  1. Download the source code for DAHDI using the 'wget' command:

wget http://www.openvox.cn/pub/drivers/dahdi-linux-complete/openvox_dahdi-linux-complete-current.tar.gz

  1. Extract the source tarball:

tar -xvzf openvox_dahdi-linux-complete-current.tar.gz

  1. Navigate to the newly created folder containing the extracted source, and run the commands to install it:

#cd /usr/src/dahdi-linux-complete-2.x.x+2.x.x
#make
#make install

  1. Restart DAHDI and Asterisk 

  2. To confirm the version of DAHDI that is installed