最後更新: 2016-02-18
介紹
卡的種類:
- Digital Cards
- Analog Cards
TDM410P
chinarob(http://www.chinaroby.com/)
Port:
- FXO(Red) <- 街線
- FXS(Green) <- 內線
Remark: 不同卡係用不同 module 的
Card:
- TDM410P (小弟用過)
- TDM800P (小弟用過)
- X400P (X400P-22 = 2fxo, 2fxs)
- AEX410(PCI-e)
- AEX800(PCI-e)
The card is fully compatible with all analog Digium
有關指令:
dahdi_*
Doc:
- http://docs.tzafrir.org.il/dahdi-linux/
- http://docs.tzafrir.org.il/dahdi-tools/
查看安裝了什麼卡
用 lsdahdi 及 dahdi_scan 可以看出 hardware 是否正常.
# lspci
07:00.0 Ethernet controller: Digium, Inc. Wildcard TDM410 4-port analog card (rev 11) 07:01.0 Ethernet controller: Digium, Inc. Wildcard TDM800P 8-port analog card (rev 11)
# dahdi_hardware
pci:0000:07:00.0 wctdm24xxp+ d161:8005 Wildcard TDM410P pci:0000:07:01.0 wctdm24xxp+ d161:0800 Wildcard TDM800P
# Load driver
如果只 load 了 dahdi module, 那只會見到
ls -al /dev/dahdi/
crw-rw---T 1 asterisk asterisk 196, 254 Jun 3 18:01 channel crw-rw---T 1 asterisk asterisk 196, 0 Jun 3 18:01 ctl crw-rw---T 1 asterisk asterisk 196, 255 Jun 3 18:01 pseudo crw-rw---T 1 asterisk asterisk 196, 253 Jun 3 18:01 timer
* 要 load 埋 wctdm24xxp 先見到 D Channel
ls -al /dev/dahdi/
crw-rw---- 1 asterisk asterisk 196, 1 May 2 11:54 1 crw-rw---- 1 asterisk asterisk 196, 10 May 2 11:54 10 crw-rw---- 1 asterisk asterisk 196, 11 May 2 11:54 11 crw-rw---- 1 asterisk asterisk 196, 12 May 2 11:54 12 crw-rw---- 1 asterisk asterisk 196, 2 May 2 11:54 2 crw-rw---- 1 asterisk asterisk 196, 3 May 2 11:54 3 crw-rw---- 1 asterisk asterisk 196, 4 May 2 11:54 4 crw-rw---- 1 asterisk asterisk 196, 5 May 2 11:54 5 crw-rw---- 1 asterisk asterisk 196, 6 May 2 11:54 6 crw-rw---- 1 asterisk asterisk 196, 7 May 2 11:54 7 crw-rw---- 1 asterisk asterisk 196, 8 May 2 11:54 8 crw-rw---- 1 asterisk asterisk 196, 9 May 2 11:54 9 crw-rw---- 1 asterisk asterisk 196, 254 May 2 11:54 channel crw-rw---- 1 asterisk asterisk 196, 0 May 2 11:54 ctl crw-rw---- 1 asterisk asterisk 196, 255 May 2 11:54 pseudo crw-rw---- 1 asterisk asterisk 196, 253 May 2 11:54 timer
# 查看有關 Kernel module
lsmod | grep dahdi
dahdi_echocan_oslec 1426 12 echo 3408 1 dahdi_echocan_oslec dahdi_voicebus 33736 1 wctdm24xxp dahdi 188201 7 dahdi_echocan_oslec,wctdm24xxp,dahdi_voicebus crc_ccitt 1323 2 wctdm24xxp,dahdi
# lsdahdi <-- List all dahdi channels with their types and spans
# 此 command 相當於 cat /proc/dahdi/SPAN
ie.
cat /proc/dahdi/1
Span 1: WCTDM/0 "Wildcard TDM800P" (MASTER) IRQ misses: 4 1 WCTDM/0/0 FXSKS (In use) RED (EC: OSLEC - INACTIVE) 2 WCTDM/0/1 FXSKS (In use) (EC: OSLEC - INACTIVE) 3 WCTDM/0/2 FXSKS RED (EC: OSLEC - INACTIVE) 4 WCTDM/0/3 FXSKS RED (EC: OSLEC - INACTIVE) 5 WCTDM/0/4 FXOKS (EC: OSLEC - INACTIVE) 6 WCTDM/0/5 FXOKS (EC: OSLEC - INACTIVE) 7 WCTDM/0/6 FXOKS (EC: OSLEC - INACTIVE) 8 WCTDM/0/7 FXOKS (EC: OSLEC - INACTIVE)
有什麼 Port:
# dahdi_scan [spans n] <-- Print Configuration of DAHDI Spans
dahdi_scan 1
[1] <-- span active=yes alarms=OK description=Wildcard TDM410P Board 1 name=WCTDM/0 manufacturer=Digium devicetype=Wildcard TDM410P (VPM100M) location=PCI Bus 03 Slot 03 basechan=1 totchans=4 irq=66 type=analog port=1,FXO port=2,FXO port=3,FXS port=4,FXS
spans:
channels are incorporated into logical units called spans (beginning with 1).
type:
- analog
- digital-T1
- digital-E1
Loopback Test
RJ-45: pins 1 to 4, and 2 to 5
dahdi configuration
span=1,0,0,esf,b8zs clear=1-24
* Restart Dahdi and make sure the necessary modules load properly.
測試
1) dahdi_tool
shows OK
2) dahdi_maint
Sets Dahdi spans into maintenance mode, e.g.: loopback
3) Send & Read back Verified
patlooptest
https://github.com/asterisk/dahdi-tools/blob/master/patlooptest.c
設定
cmd: dahdi_genconf 會讀取 /etc/dahdi/genconf_parameters 去建立以下檔案
- /etc/asterisk/dahdi-channels.conf
- /etc/dahdi/system.conf
Usage:
# dahdi_genconf -v
Default parameters from /etc/dahdi/genconf_parameters Generating /etc/dahdi/system.conf Generating /etc/asterisk/dahdi-channels.conf
檔案: /etc/dahdi/genconf_parameters:
fxo_default_start ks loadzone=us <-- tone zone values (busy, dial-tone) defaultzone=us
# Tone Zone Data (loadzone) <--- zonedata.c
載入:
/etc/init.d/dahdi
dahdi_cfg:
dahdi_cfg 讀取 /etc/dahdi/system.conf 去設定 DAHDI kernel modules
/etc/dahdi/system.conf 是由 dahdi_genconf 自動建立的
Help:
dahdi_cfg -h
- -f # Always configure every channel, even if it appears not to have changed
- -t # Test mode
- -v # Be more verbose (沒有加它, output 沒有野看)
Test:
# dahdi_cfg -v -t
DAHDI Tools Version - 2.2.1.1 DAHDI Version: 2.3.0.1 Echo Canceller(s): OSLEC Configuration ====================== 12 channels to configure.
# dahdi_cfg -d -t
Line 9: fxsks=1 Line 10: echocanceller=oslec,1 Line 11: fxsks=2 Line 12: echocanceller=oslec,2 Line 13: fxoks=3 Line 14: echocanceller=oslec,3 Line 15: fxoks=4 Line 16: echocanceller=oslec,4 Line 19: fxsks=5 Line 20: echocanceller=oslec,5 Line 21: fxsks=6 Line 22: echocanceller=oslec,6 Line 23: fxsks=7 Line 24: echocanceller=oslec,7 Line 25: fxsks=8 Line 26: echocanceller=oslec,8 Line 27: fxoks=9 Line 28: echocanceller=oslec,9 Line 29: fxoks=10 Line 30: echocanceller=oslec,10 Line 31: fxoks=11 Line 32: echocanceller=oslec,11 Line 33: fxoks=12 Line 34: echocanceller=oslec,12 Line 38: loadzone = us Line 39: defaultzone = us <End of File>
dahdi_test
runs a timing test in a loop
Measures accuracy of the FXO/FXS board software digital signal processing
/dev/dahdi/pseudo <--- reads 8192 bytes <-- take exactly 8000 ms
# -c count
dahdi_test -c 8
Opened pseudo dahdi interface, measuring accuracy... 99.999% 99.996% 99.999% 99.999% 99.999% 100.000% 100.000% 99.999% --- Results after 8 passes --- Best: 100.000% -- Worst: 99.996% -- Average: 99.998938% Cummulative Accuracy (not per pass): 99.999
dahdi_diag
Dump DAHDI channel parameters ( 要用 dmesg 去看資料 )
Usage:
dahdi_diag <channel>
i.e.
dahdi_diag 1
dmesg | tail -n 15 // output 資料在 dmesg
[35479200.482131] dahdi: Dump of DAHDI Channel 1 (WCTDM/0/0,1,1): [35479200.482133] [35479200.482137] dahdi: flags: 2c00601 hex, writechunk: ffff880235cf20c8, readchunk: ffff880235cf20d8 [35479200.482141] dahdi: rxgain: ffffffffa030cc70, txgain: ffffffffa030cc70, gainalloc: 0 [35479200.482144] dahdi: span: ffff880235d2d400, sig: 2004 hex, sigcap: 6085 hex [35479200.482147] dahdi: inreadbuf: -1, outreadbuf: 0, inwritebuf: 0, outwritebuf: -1 [35479200.482150] dahdi: blocksize: 160, numbufs: 4, txbufpolicy: 0, txbufpolicy: 0 [35479200.482153] dahdi: txdisable: 0, rxdisable: 0, iomask: 0 [35479200.482156] dahdi: curzone: ffff880233984000, tonezone: 0, curtone: (null), tonep: 0 [35479200.482159] dahdi: digitmode: 0, txdialbuf: , dialing: 0, aftdialtimer: 0, cadpos. 0 [35479200.482162] dahdi: confna: 0, confn: 0, confmode: 0, confmute: 0 [35479200.482165] dahdi: ec: (null), deflaw: 0, xlaw: ffffffffa030ca40 [35479200.482168] dahdi: itimer: 0, otimer: 0, ringdebtimer: 0
dahdi_monitor
checks the rx/tx levels of DAHDI channels
# -f FILE Record the content of the channel (Tx + Rx) to a file.
# -v Display Visual audio levels.
i.e.
# Record channel 3 to a file:
dahdi_monitor 3 -f output.raw
# Visualize audio levels on DAHDI channel 2:
dahdi_monitor 2 -v
Visual Audio Levels. -------------------- Use chan_dahdi.conf file to adjust the gains if needed. ( # = Audio Level * = Max Audio Hit ) <----------------(RX)----------------> <----------------(TX)---------------->
Debain6/7 - 安裝 dahdi
dahdi-source: source code for kernel driver
apt-get install dahdi-source
cd /usr/src/modules
tar -jxf dahdi.tar.bz2
cd /usr/src/modules/dahdi
make
make install
reboot 後 /dev 會有
/dev/dahdi ├── 1 ├── 2 ├── 3 ├── 4 ├── channel ├── ctl ├── pseudo └── timer
安裝過程中(make install)會順帶下載(http://downloads.digium.com)及安裝以下 firmware
- dahdi-fw-oct6114-064.bin
- dahdi-fw-oct6114-128.bin
- dahdi-fw-tc400m.bin
Debian7 的 module 放了在
/lib/modules/3.2.0-4-amd64/dahdi#
TDM800P 載入 dahdi_echocan_mg2 及 wctdm24xxp 即可使用
modprobe dahdi_echocan_mg2
modprobe wctdm24xxp
lsmod | grep 24xxp
wctdm24xxp 98629 0 dahdi_voicebus 45977 1 wctdm24xxp dahdi 191056 3 dahdi_echocan_mg2,dahdi_voicebus,wctdm24xxp crc_ccitt 12347 2 dahdi,wctdm24xxp
Troubleshoot
問題1:
dahdi_hardware 找到 hardware 但 dahdi_scan 沒有
解決1:
modprobe wctdm24xxp
問題2:
來電顯示不成功
解決2:
- DTMF
- ETSI-FSK
Asterisk 上查看 dahdi 的 status
asterisk -r
myserver*CLI> dahdi show version
DAHDI Version: 2.6.1 Echo Canceller: HWEC, OSLEC
myserver*CLI> dahdi show status
Description Alarms IRQ bpviol CRC Fra Codi Options LBO Wildcard TDM800P OK 0 0 0 CAS Unk 0 db (CSU)/0-133 feet (DSX-1)
myserver*CLI> dahdi show channels
Chan Extension Context Language MOH Interpret Blocked State pseudo default default In Service 1 DID_trunk_1 default In Service 2 DID_trunk_2 default In Service
myserver*CLI> dahdi show channel 1
Dialing: no Context: DID_trunk_1
myserver*CLI> dahdi restart