<HTML><HEAD></HEAD>
<BODY dir=ltr>
<DIV dir=ltr>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: 'Calibri'; COLOR: #000000">
<DIV>Hi All,</DIV>
<DIV> </DIV>
<DIV>I have managed to narrow the problem. My driver supports FXS and FXO 
channel.</DIV>
<DIV>I register SIP client to Asterisk  and whatever I dial from the SIP I 
dial(DAHDI/FXS). </DIV>
<DIV>I have analog loopback from FXS to FXS. The incoming calls in the FXO are 
IVR terminated (see my FXO dialplan on my previous email)</DIV>
<DIV>I get DIAHDI pick up FXO on the second call not on the first one. </DIV>
<DIV>(From time to time DAHDI actually pickup on the first call and in this case 
I do have callerid )</DIV>
<DIV>but most of the cases the pickup is on the second call and in those cases I 
have ${CALLERID(num) empty </DIV>
<DIV> </DIV>
<DIV>Bellow I include a typical log in my FXS/FXO driver:</DIV>
<DIV> </DIV>
<DIV>Driver receive from DAHDI: "FXS: DAHDI_TXSIG_START", driver sets the SLIC 
linefeed to 
"rininging"                     
< ------------- first ring</DIV>
<DIV>Detect FXO ringing and diver calls dahdi_hooksig(fxo_channel, 
DAHDI_RXSIG_RING);</DIV>
<DIV>Driver receive from DAHDI: "FXS DAHDI_TXSIG_OFFHOOK", driver set the SLIC 
linefeed to "Forward OHT"</DIV>
<DIV>Driver detects the stop rining event and calls dahdi_hooksig(fxo_channel, 
DAHDI_RXSIG_OFFHOOK);</DIV>
<DIV>Driver receive "ioctl DAHDI_TONEDETECT" and returns -ENOTTY</DIV>
<DIV> </DIV>
<DIV>Driver receive from DAHDI: "FXS: DAHDI_TXSIG_START", driver sets the SLIC 
linefeed to 
"rininging"                   
< ------------- second ring </DIV>
<DIV>Detect FXO ringing and diver calls dahdi_hooksig(fxo_channel, 
DAHDI_RXSIG_RING);</DIV>
<DIV>Driver receive from DAHDI: "FXS DAHDI_TXSIG_OFFHOOK", driver set the SLIC 
linefeed to "Forward OHT"</DIV>
<DIV>Driver detects the stop rining event and calls dahdi_hooksig(fxo_channel, 
DAHDI_RXSIG_OFFHOOK);</DIV>
<DIV>Driver receives from DAHDI "FXO: DAHDI_TXSIG_OFFHOOK" and puts the DAA in 
offhook state</DIV>
<DIV>Driver detects that the SLIC has in offhook state  and calls 
dahdi_hooksig(&wc.chans[0], DAHDI_RXSIG_OFFHOOK);</DIV>
<DIV> </DIV>
<DIV>---- Conversation established. but caller id is empty -------- </DIV>
<DIV> </DIV>
<DIV>Anyone being able to point me in the right direction?</DIV>
<DIV>It is Asterisk 11.16.0 and dahdi: Version: 2.10.0.1</DIV>
<DIV> </DIV>
<DIV>Best Regards</DIV>
<DIV>Dimitar</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV 
style='FONT-SIZE: small; TEXT-DECORATION: none; FONT-FAMILY: "Calibri"; FONT-WEIGHT: normal; COLOR: #000000; FONT-STYLE: normal; DISPLAY: inline'>
<DIV style="FONT: 10pt tahoma">
<DIV> </DIV>
<DIV style="BACKGROUND: #f5f5f5">
<DIV style="font-color: black"><B>From:</B> <A 
title=dpn@switchvoice.com>dpn@switchvoice.com</A> </DIV>
<DIV><B>Sent:</B> Tuesday, January 3, 2017 22:28</DIV>
<DIV><B>To:</B> <A 
title=asterisk-dev@lists.digium.com>asterisk-dev@lists.digium.com</A> </DIV>
<DIV><B>Subject:</B> Fw: Caller ID in FXO channel</DIV></DIV></DIV>
<DIV> </DIV></DIV>
<DIV 
style='FONT-SIZE: small; TEXT-DECORATION: none; FONT-FAMILY: "Calibri"; FONT-WEIGHT: normal; COLOR: #000000; FONT-STYLE: normal; DISPLAY: inline'>
<DIV dir=ltr>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: 'Calibri'; COLOR: #000000">
<DIV 
style='FONT-SIZE: small; TEXT-DECORATION: none; FONT-FAMILY: "Calibri"; FONT-WEIGHT: normal; COLOR: #000000; FONT-STYLE: normal; DISPLAY: inline'>
<DIV dir=ltr>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: 'Calibri'; COLOR: #000000">
<DIV>Hi All,</DIV>
<DIV> </DIV>
<DIV>First of all happy new year to everyone!</DIV>
<DIV> </DIV>
<DIV>I am developing an FXO driver to use with Asterisk.</DIV>
<DIV>My driver is working fine and I can receive and originate calls and I have 
both ways audio.</DIV>
<DIV> </DIV>
<DIV>I have issue with the callerid however.  I have set in can_dahdi.conf 
the default bell type starting after the first ring.</DIV>
<DIV>For testing I use FXS port which seems to send the calerid properly as it 
is displayed on an analog phone.</DIV>
<DIV>Occasionally I get the callerid (on the incoming calls for the FXO channel 
) working but it is once per 20 calls.</DIV>
<DIV>It seems enabling Asterisk debug in the CLI makes the callerid detection a 
bit better as I see it working more often with CLI debug enabled.</DIV>
<DIV>This makes me think that I have timing or noise issue. </DIV>
<DIV>On the FXO RING/TIP terminals I do see (with oscilloscope) the callerID FSK 
signals. It I swith about 5Vpp and yes I see some noise.</DIV>
<DIV>Not sure how sensitive the demodulator is. </DIV>
<DIV> </DIV>
<DIV>Before going into more details I want to ask the mailing list. Probably I 
have some simple signaling issue like getting the FXO off hook to early or too 
late.</DIV>
<DIV> </DIV>
<DIV>I have my FXO context like</DIV>
<DIV>[fxo]</DIV>
<DIV>exten => 
s,1,Answer                                                                   
</DIV>
<DIV>exten => s,2, 
Noop(${CALLERID(num)})                                                         
</DIV>
<DIV>exten => 
s,3,Background(/demo-congrats)                                      
</DIV>
<DIV>exten => s,4,Hangup   </DIV>
<DIV> </DIV>
<DIV>Bellow I include the log for reference. </DIV>
<DIV>Any thoughts or advices how to narrow the problem are welcome!</DIV>
<DIV> </DIV>
<DIV>d-ffffff*CLI> [Jan  2 19:35:56] DEBUG[1672]: chan_dahdi.c:12229 
do_monitor: Monitor doohicky got event Ring Begin on channel 2</DIV>
<DIV>[Jan  2 19:35:56] DEBUG[1672]: sig_analog.c:3697 
analog_handle_init_event: channel (2) - signaling (5) - event 
(ANALOG_EVENT_RINGBEGIN)</DIV>
<DIV>[Jan  2 19:35:56] DEBUG[1672]: chan_dahdi.c:12229 do_monitor: Monitor 
doohicky got event Ring Begin on channel 2</DIV>
<DIV>[Jan  2 19:35:56] DEBUG[1672]: sig_analog.c:3697 
analog_handle_init_event: channel (2) - signaling (5) - event 
(ANALOG_EVENT_RINGBEGIN)</DIV>
<DIV>d-ffffff*CLI> [Jan  2 19:35:58] DEBUG[1672]: chan_dahdi.c:12229 
do_monitor: Monitor doohicky got event Ring/Answered on channel 2</DIV>
<DIV>[Jan  2 19:35:58] DEBUG[1672]: chan_dahdi.c:12229 do_monitor: Monitor 
doohicky got event Ring/Answered on channel 2</DIV>
<DIV>d-ffffff*CLI> [Jan  2 19:35:58] DEBUG[1672]: sig_analog.c:3697 
analog_handle_init_event: channel (2) - signaling (5) - event 
(ANALOG_EVENT_RINGOFFHOOK)</DIV>
<DIV>[Jan  2 19:35:58] DEBUG[1672]: sig_analog.c:3697 
analog_handle_init_event: channel (2) - signaling (5) - event 
(ANALOG_EVENT_RINGOFFHOOK)</DIV>
<DIV>d-ffffff*CLI> [Jan  2 19:35:58] DEBUG[1672][C-00000007]: dsp.c:482 
ast_tone_detect_init: Setup tone 1100 Hz, 500 ms, block_size=160, 
hits_required=21</DIV>
<DIV>[Jan  2 19:35:58] DEBUG[1672][C-00000007]: dsp.c:482 
ast_tone_detect_init: Setup tone 1100 Hz, 500 ms, block_size=160, 
hits_required=21</DIV>
<DIV>d-ffffff*CLI> [Jan  2 19:35:58] DEBUG[1672][C-00000007]: dsp.c:482 
ast_tone_detect_init: Setup tone 2100 Hz, 2600 ms, block_size=160, 
hits_required=116</DIV>
<DIV>[Jan  2 19:35:58] DEBUG[1672][C-00000007]: dsp.c:482 
ast_tone_detect_init: Setup tone 2100 Hz, 2600 ms, block_size=160, 
hits_required=116</DIV>
<DIV>d-ffffff*CLI> [Jan  2 19:35:58] DEBUG[1696]: sig_analog.c:1764 
__analog_ss_thread: __analog_ss_thread 2</DIV>
<DIV>[Jan  2 19:35:58] DEBUG[1696]: sig_analog.c:1764 __analog_ss_thread: 
__analog_ss_thread 2</DIV>
<DIV>    -- Starting simple switch on 'DAHDI/2-1'</DIV>
<DIV>d-ffffff*CLI>     -- Starting simple switch on 
'DAHDI/2-1'</DIV>
<DIV>[Jan  2 19:36:02] DEBUG[1696][C-00000007]: pbx.c:4883 
pbx_extension_helper: Launching 'Answer'</DIV>
<DIV>[Jan  2 19:36:02] DEBUG[1696][C-00000007]: pbx.c:4883 
pbx_extension_helper: Launching 'Answer'</DIV>
<DIV>d-ffffff*CLI>     -- Executing [s@penev_fxo:1] 
Answer("DAHDI/2-1", "") in new stack</DIV>
<DIV>    -- Executing [s@penev_fxo:1] Answer("DAHDI/2-1", "") in 
new stack</DIV>
<DIV>d-ffffff*CLI> [Jan  2 19:36:02] DEBUG[1696][C-00000007]: 
sig_analog.c:1497 analog_answer: analog_answer 2</DIV>
<DIV>[Jan  2 19:36:02] DEBUG[1696][C-00000007]: sig_analog.c:1497 
analog_answer: analog_answer 2</DIV>
<DIV>d-ffffff*CLI> [Jan  2 19:36:02] DEBUG[1696][C-00000007]: 
sig_analog.c:1528 analog_answer: Took DAHDI/2-1 off hook</DIV>
<DIV>[Jan  2 19:36:02] DEBUG[1696][C-00000007]: sig_analog.c:1528 
analog_answer: Took DAHDI/2-1 off hook</DIV>
<DIV>d-ffffff*CLI> [Jan  2 19:36:02] DEBUG[1696][C-00000007]: 
chan_dahdi.c:5061 dahdi_enable_ec: No echo cancellation requested</DIV>
<DIV>[Jan  2 19:36:02] DEBUG[1696][C-00000007]: chan_dahdi.c:5061 
dahdi_enable_ec: No echo cancellation requested</DIV>
<DIV>d-ffffff*CLI> [Jan  2 19:36:02] DEBUG[1696][C-00000007]: 
chan_dahdi.c:5077 dahdi_train_ec: No echo training requested</DIV>
<DIV>[Jan  2 19:36:02] DEBUG[1696][C-00000007]: chan_dahdi.c:5077 
dahdi_train_ec: No echo training requested</DIV>
<DIV>d-ffffff*CLI> [Jan  2 19:36:02] DEBUG[1696][C-00000007]: 
chan_dahdi.c:9656 dahdi_indicate: Requested indication -1 on channel 
DAHDI/2-1</DIV>
<DIV>[Jan  2 19:36:02] DEBUG[1696][C-00000007]: chan_dahdi.c:9656 
dahdi_indicate: Requested indication -1 on channel DAHDI/2-1</DIV>
<DIV>d-ffffff*CLI> [Jan  2 19:36:02] DEBUG[1696][C-00000007]: pbx.c:4883 
pbx_extension_helper: Launching 'NoOp'</DIV>
<DIV>[Jan  2 19:36:02] DEBUG[1696][C-00000007]: pbx.c:4883 
pbx_extension_helper: Launching 'NoOp'</DIV>
<DIV>    -- Executing [s@penev_fxo:2] NoOp("DAHDI/2-1", "") in 
new stack</DIV>
<DIV>d-ffffff*CLI>     -- Executing [s@penev_fxo:2] 
NoOp("DAHDI/2-1", "") in new stack</DIV>
<DIV>[Jan  2 19:36:02] DEBUG[1696][C-00000007]: pbx.c:4883 
pbx_extension_helper: Launching 'BackGround'</DIV>
<DIV>[Jan  2 19:36:02] DEBUG[1696][C-00000007]: pbx.c:4883 
pbx_extension_helper: Launching 'BackGround'</DIV>
<DIV>    -- Executing [s@penev_fxo:3] BackGround("DAHDI/2-1", 
"/demo-congrats") in new stack</DIV>
<DIV>d-ffffff*CLI>     -- Executing [s@penev_fxo:3] 
BackGround("DAHDI/2-1", "/demo-congrats") in new stack</DIV>
<DIV>    -- <DAHDI/2-1> Playing '/demo-congrats.ulaw' 
(language 'en')</DIV>
<DIV>d-ffffff*CLI>     -- <DAHDI/2-1> Playing 
'/demo-congrats.ulaw' (language 'en')</DIV>
<DIV>[Jan  2 19:36:02] DEBUG[1696][C-00000007]: sig_analog.c:3572 
analog_exception: analog_exception 2</DIV>
<DIV>[Jan  2 19:36:02] DEBUG[1696][C-00000007]: sig_analog.c:3572 
analog_exception: analog_exception 2</DIV>
<DIV>d-ffffff*CLI> [Jan  2 19:36:02] DEBUG[1696][C-00000007]: 
sig_analog.c:3666 analog_exception: Exception on 7, channel 2</DIV>
<DIV>[Jan  2 19:36:02] DEBUG[1696][C-00000007]: sig_analog.c:3666 
analog_exception: Exception on 7, channel 2</DIV>
<DIV>d-ffffff*CLI> [Jan  2 19:36:02] DEBUG[1696][C-00000007]: 
sig_analog.c:2679 __analog_handle_event: __analog_handle_event 2</DIV>
<DIV>[Jan  2 19:36:02] DEBUG[1696][C-00000007]: sig_analog.c:2679 
__analog_handle_event: __analog_handle_event 2</DIV>
<DIV>d-ffffff*CLI> [Jan  2 19:36:02] DEBUG[1696][C-00000007]: 
sig_analog.c:2706 __analog_handle_event: Got event ANALOG_EVENT_RINGOFFHOOK(2) 
on channel 2 (index 0)</DIV>
<DIV>[Jan  2 19:36:02] DEBUG[1696][C-00000007]: sig_analog.c:2706 
__analog_handle_event: Got event ANALOG_EVENT_RINGOFFHOOK(2) on channel 2 (index 
0)</DIV>
<DIV>d-ffffff*CLI> [Jan  2 19:36:02] WARNING[1696][C-00000007]: 
sig_analog.c:3103 __analog_handle_event: Ring/Off-hook in strange state 6 on 
channel 2</DIV>
<DIV>[Jan  2 19:36:02] WARNING[1696][C-00000007]: sig_analog.c:3103 
__analog_handle_event: Ring/Off-hook in strange state 6 on channel 2</DIV>
<DIV>d-ffffff*CLI> [Jan  2 19:36:28] DEBUG[1696][C-00000007]: 
sig_analog.c:3572 analog_exception: analog_exception 2</DIV>
<DIV>[Jan  2 19:36:28] DEBUG[1696][C-00000007]: sig_analog.c:3666 
analog_exception: Exception on 7, channel 2</DIV>
<DIV>[Jan  2 19:36:28] DEBUG[1696][C-00000007]: sig_analog.c:2679 
__analog_handle_event: __analog_handle_event 2</DIV>
<DIV>[Jan  2 19:36:28] DEBUG[1696][C-00000007]: sig_analog.c:2706 
__analog_handle_event: Got event ANALOG_EVENT_ONHOOK(1) on channel 2 (index 
0)</DIV>
<DIV>[Jan  2 19:36:28] DEBUG[1696][C-00000007]: pbx.c:6572 __ast_pbx_run: 
Spawn extension (penev_fxo,s,3) exited non-zero on 'DAHDI/2-1'</DIV>
<DIV>  == Spawn extension (penev_fxo, s, 3) exited non-zero on 
'DAHDI/2-1'</DIV>
<DIV>[Jan  2 19:36:28] DEBUG[1696][C-00000007]: channel.c:2661 
ast_softhangup_nolock: Soft-Hanging up channel 'DAHDI/2-1'</DIV>
<DIV>[Jan  2 19:36:28] DEBUG[1696][C-00000007]: channel.c:2840 ast_hangup: 
Hanging up channel 'DAHDI/2-1'</DIV>
<DIV>[Jan  2 19:36:28] DEBUG[1696][C-00000007]: chan_dahdi.c:6325 
dahdi_hangup: dahdi_hangup(DAHDI/2-1)</DIV>
<DIV>[Jan  2 19:36:28] DEBUG[1696][C-00000007]: sig_analog.c:1280 
analog_hangup: analog_hangup 2</DIV>
<DIV>[Jan  2 19:36:28] DEBUG[1696][C-00000007]: sig_analog.c:1303 
analog_hangup: Hangup: channel: 2 index = 0, normal = 1, callwait = 0, thirdcall 
= 0</DIV>
<DIV>[Jan  2 19:36:28] DEBUG[1696][C-00000007]: sig_analog.c:3572 
analog_exception: analog_exception 2</DIV>
<DIV>[Jan  2 19:36:28] DEBUG[1696][C-00000007]: sig_analog.c:3666 
analog_exception: Exception on 7, channel 2</DIV>
<DIV>[Jan  2 19:36:28] DEBUG[1696][C-00000007]: sig_analog.c:2679 
__analog_handle_event: __analog_handle_event 2</DIV>
<DIV>[Jan  2 19:36:28] DEBUG[1696][C-00000007]: sig_analog.c:2706 
__analog_handle_event: Got event ANALOG_EVENT_ONHOOK(1) on channel 2 (index 
0)</DIV>
<DIV>[Jan  2 19:36:28] DEBUG[1696][C-00000007]: pbx.c:6572 __ast_pbx_run: 
Spawn extension (penev_fxo,s,3) exited non-zero on 'DAHDI/2-1'</DIV>
<DIV>  == Spawn extension (penev_fxo, s, 3) exited non-zero on 
'DAHDI/2-1'</DIV>
<DIV>[Jan  2 19:36:28] DEBUG[1696][C-00000007]: channel.c:2661 
ast_softhangup_nolock: Soft-Hanging up channel 'DAHDI/2-1'</DIV>
<DIV>[Jan  2 19:36:28] DEBUG[1696][C-00000007]: channel.c:2840 ast_hangup: 
Hanging up channel 'DAHDI/2-1'</DIV>
<DIV>[Jan  2 19:36:28] DEBUG[1696][C-00000007]: chan_dahdi.c:6325 
dahdi_hangup: dahdi_hangup(DAHDI/2-1)</DIV>
<DIV>[Jan  2 19:36:28] DEBUG[1696][C-00000007]: sig_analog.c:1280 
analog_hangup: analog_hangup 2</DIV>
<DIV>[Jan  2 19:36:28] DEBUG[1696][C-00000007]: sig_analog.c:1303 
analog_hangup: Hangup: channel: 2 index = 0, normal = 1, callwait = 0, thirdcall 
= 0</DIV>
<DIV>d-ffffff*CLI> [Jan  2 19:36:28] DEBUG[1696][C-00000007]: 
chan_dahdi.c:6923 dahdi_setoption: Set option TONE VERIFY, mode: OFF(0) on 
DAHDI/2-1</DIV>
<DIV>[Jan  2 19:36:28] DEBUG[1696][C-00000007]: chan_dahdi.c:6923 
dahdi_setoption: Set option TONE VERIFY, mode: OFF(0) on DAHDI/2-1</DIV>
<DIV>d-ffffff*CLI> [Jan  2 19:36:28] DEBUG[1696][C-00000007]: 
chan_dahdi.c:6933 dahdi_setoption: Set option TDD MODE, value: OFF(0) on 
DAHDI/2-1</DIV>
<DIV>[Jan  2 19:36:28] DEBUG[1696][C-00000007]: chan_dahdi.c:6933 
dahdi_setoption: Set option TDD MODE, value: OFF(0) on DAHDI/2-1</DIV>
<DIV>d-ffffff*CLI> [Jan  2 19:36:28] DEBUG[1696][C-00000007]: 
sig_analog.c:785 analog_update_conf: Updated conferencing on 2, with 0 
conference users</DIV>
<DIV>[Jan  2 19:36:28] DEBUG[1696][C-00000007]: sig_analog.c:785 
analog_update_conf: Updated conferencing on 2, with 0 conference users</DIV>
<DIV>d-ffffff*CLI>     -- Hanging up on 'DAHDI/2-1'</DIV>
<DIV>    -- Hanging up on 'DAHDI/2-1'</DIV>
<DIV>d-ffffff*CLI>     -- Hungup 'DAHDI/2-1'</DIV>
<DIV> </DIV>
<DIV>Best Regards</DIV>
<DIV>Dimitar</DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></BODY></HTML>