asterisk 1.6.1; TDM400-clone; SuSe 11.1; no outgoing call

Hi,

after successfully generating my asterisk from source for my OpenSuSE 11.1, one problem showed up: I could call from analogue phone to SIP-phone, I could receive inbound calls on analogue phone, but could not do outbound analog calls, in case I started dahdi and asterisk automatically during boot. In case, I started dahdi and asterisk manually, it worked.
(I am using a TDM400-clone from OpenVox, A400P.)

I had a similar issue already in the past with older asterisk and zaptel, and I found out, that I could solve my problem with a “Dirty Trick”:

So, first of all I disabled “Parallel Execution” of start-up scripts for the services during boot, to start all services in serial. SuSE by default starts services, which do not depend upon each others, in parallel within the same run-level.
Second, I made shure, that dahdi is started “far erlier” than asterisk.
Third, I used the “Last Weapon of a desperate Programmer” (who suspects a timing problem; I am a programming-dinosaur myself, never needed to use this trick permanently, though): I introduced some time-delay in /etc/init./asterisk. Below you see this in more detail.
And now it works.

But that means, there is still a race-condition/timing issue/load-problem etc. during start-up of asterisk/dahdi after boot, which more looks like a asterisk/dahdi issue and not like a SuSE problem.
But, can anybody with a real TDM400-card confirm this problem ?

Below some system info:

asterisk -vvvvvvvvvr, when trying to do analogue call from phone to PSTN without my “Dirty Trick”, just after fresh install:

– Starting simple switch on ‘DAHDI/2-1’
– Executing [470555@to_analog_phone:1] Dial(“DAHDI/2-1”, “dahdi/1/470555,10,tTm”) in new stack
[May 13 19:10:10] WARNING[6461]: app_dial.c:1518 dial_exec_full: Unable to create channel of type ‘dahdi’ (cause 0 - Unknown)
== Everyone is busy/congested at this time (1:0/0/1)
– Executing [470555@to_analog_phone:2] VoiceMail(“DAHDI/2-1”, “100”) in new stack
– <DAHDI/2-1> Playing ‘vm-intro.gsm’ (language ‘ru’)
== Spawn extension (to_analog_phone, 470555, 2) exited non-zero on ‘DAHDI/2-1’
– Hungup ‘DAHDI/2-1’

dahdi show channels
Chan Extension Context Language MOH Interpret Blocked State
pseudo default default In Service
1 to_UKRTelcom ru default In Service
2 to_analog_phone ru default In Service
Gateway-Niko*CLI>

Excerpt from extensions.conf:
[to_analog_phone]
exten => _00X.,1,Dial(SIP/${EXTEN:2}@bellshare,30,tr)
exten => _00X.,2,hangup()
exten => _8X.,1,Dial(SIP/${EXTEN:1}@bellshare,30,trg)
exten => _999X.,1,SetCallerID(“023658568281”)
exten => _999X.,2,Dial(SIP/${EXTEN:4}@GSM-Gateway,60,r)
exten => _999X.,3,hangUp()
exten => 2001,1,Dial(SIP/Tanyusha2,20)
exten => 2001,2,Voicemail(2001)
exten => 2001,3,hangUp()
exten => _X.,1,Dial(dahdi/1/${EXTEN},10,tTm)
exten => _X.,2,Voicemail(100)
exten => _X.,3,hangUp()

Gateway-NikoCLI> dahdi show channel 1
Channel: 1ko
CLI>
File Descriptor: 10
Span: 1
Extension:
Dialing: no
Context: to_UKRTelcom
Caller ID: 0
Calling TON: 0
Caller ID name: PSTN
Mailbox: none
Destroy: 0
InAlarm: 0
Signalling Type: FXS Kewlstart
Radio: 0
Owner: <None>
Real: <None>
Callwait: <None>
Threeway: <None>
Confno: -1
Propagated Conference: -1
Real in conference: 0
DSP: no
Busy Detection: yes
Busy Count: 10
Busy Pattern: 0,0
TDD: no
Relax DTMF: no
Dialing/CallwaitCAS: 0/0
Default law: ulaw
Fax Handled: no
Pulse phone: no
DND: no
Echo Cancellation:
128 taps
(unless TDM bridged) currently OFF
Actual Confinfo: Num/0, Mode/0x0000
Actual Confmute: No
Hookstate (FXS only): Onhook

Autogenerated by /usr/sbin/dahdi_genconf on Sat May 9 22:34:41 2009 – do not hand edit

Dahdi Configuration File

This file is parsed by the Dahdi Configurator, dahdi_cfg

Span 1: WCTDM/4 “Wildcard TDM400P REV E/F Board 5” (MASTER)

fxsks=1
echocanceller=mg2,1
fxoks=2
echocanceller=mg2,2

channel 3, WCTDM/4/2, no module.

channel 4, WCTDM/4/3, no module.

Global data

loadzone = ru
defaultzone = ru
~
Gateway-Niko:~ # lsdahdi

Span 1: WCTDM/4 “Wildcard TDM400P REV E/F Board 5” (MASTER)

1 FXS FXSKS (In use) (EC: MG2)
2 FXO FXOKS (In use) (EC: MG2)

Implementing my “Dirty Trick”, to delay automatic execution of dahdi and asterisk after boot:
Start asterisk much later than dahdi

Gateway-Niko:~ # ls /etc/init.d/rc3.d
K01SuSEfirewall2_setup K02kbd S05splash_early
K01apache2 K02network-remotefs S07kbd
K01asterisk K02ntp S08alsasound
K01auditd K02postfix S08avahi-daemon
K01cron K03boot.clock S08clamd
K01dhcpd K03haldaemon S08dahdi
K01java.binfmt_misc K03named S08java.binfmt_misc
K01privoxyd K06rpcbind S08network-remotefs
K01random K07syslog S08privoxyd
K01rpmconfigcheck K08earlysyslog S08rpmconfigcheck
K01smb K08network S08sshd
K01splash K09SuSEfirewall2_init S09named
K01splash_early K09dbus S09splash
K01squid S01SuSEfirewall2_init S10ntp
K01sshd S01acpid S11cups
K01stopblktrace S01dbus S11dhcpd
K01tb-p S01earlysyslog S11postfix
K01xinetd S01fbset S11xinetd
K02acpid S01random S12apache2
K02alsasound S01tb-p S13cron
K02avahi-daemon S02haldaemon S13smb
K02clamd S02network S13squid
K02cups S03syslog S14dansguardian
K02dahdi S04boot.clock S15asterisk
K02dansguardian S05auditd S16SuSEfirewall2_setup
K02fbset S05rpcbind S16stopblktrace
Gateway-Niko:~ #

Introduce 5s time-delay before starting asterisk

/etc/init.d/asterisk:
#!/bin/sh
#set -x

asterisk Starts, Stops and Reloads Asterisk.

BEGIN INIT INFO

Provides: asterisk

Required-Start: dahdi $network $named dansguardian

Required-Stop:

Default-Start: 3 5

Default-Stop: 0 1 2 4 6

Description: Asterisk Phone System, using DAHDI

END INIT INFO

Source function library.

. /lib/lsb/init-functions
if ! -x /usr/sbin/asterisk ] ; then
echo “ERROR: /usr/sbin/asterisk not found”
exit 5
fi
if ! -d /etc/asterisk ] ; then
echo “ERROR: /etc/asterisk directory not found”
exit 5
fi
. /etc/rc.status

Reset status of this service

rc_reset

Full path to asterisk binary

DAEMON=/usr/sbin/asterisk

Full path to safe_asterisk script

SAFE_ASTERISK=/usr/sbin/safe_asterisk
RETVAL=0
case “$1” in
start)

Start daemons.

    echo -n "Starting asterisk phone system "

Check if Asterisk is already running. If it is, then bug out, because

starting Asterisk when Asterisk is already running is very bad.

VERSION=/usr/sbin/asterisk -rx 'core show version'
if “echo $VERSION | cut -c 1-8” = “Asterisk” ]; then

echo “Asterisk is already running. $0 will exit now.”

rc_status -v
exit
fi
if -f $SAFE_ASTERISK ] ; then
DAEMON=$SAFE_ASTERISK
fi
if $AST_USER ] ; then
ASTARGS="-U $AST_USER"
fi
if $AST_GROUP ] ; then
ASTARGS="echo $ASTARGS -G $AST_GROUP"
fi
#RKA+: Give dahdi_cfg and DNS some more time to complete …
#RKA- Should not be necessary any more,
#because we force asterisk to be loaded after dansguardian,

so to be almost the last one.

#Sorry, I was wrong, still necessary …
#----------------
sleep 5s
#---------------
$DAEMON $ASTARGS
$RETVAL -eq 0 ] && touch /var/lock/subsys/asterisk
rc_status -v
;;
stop)

Stop daemons.

echo -n $"Shutting down asterisk: "
killproc asterisk > /dev/null
$RETVAL -eq 0 ] && rm -f /var/lock/subsys/asterisk
rc_status -v
;;
restart)
“$0” stop
“$0” start
rc_status -v
;;
reload)
$DAEMON -rx ‘reload’ > /dev/null 2> /dev/null
rc_status -v
;;
status)
#RKA+
echo -n "Checking for asterisk "
-f /var/lock/subsys/asterisk ]
rc_status -v
#RKA- status asterisk
;;
*)
echo “Usage: asterisk {start|stop|restart|reload|condrestart|status}”
exit 1
;;
esac
rc_exit