[Asterisk-Dev] callerid spill

Gurminder Arora gurmi.linux at gmail.com
Thu Sep 8 23:33:34 MST 2005


Hi,
      I am a beginner in asterisk. Implementing it in my dept in India
using TDM400b card with asterisk, zaptel, libpri version latest of CVS
HEAD

Callerid on my system is coming tough. 
Asterisk doesnot finishes the callerid spill and Cancells it.
After going through code in Callerid.c and chan_zap.c I found that my
line is providing caller id of length 8867.


Flow enters in zt_call and generates callerid id of length 8867 from
callerid generate in callerid.c
*****************snip** zt_call** chan_zap.c**************************

	if (p->cidspill)
	p->cidlen = ast_callerid_generate(p->cidspill, ast->cid.cid_name,
ast->cid.cid_num, AST_LAW(p));
		p->cidpos = 0;				                                       send_callerid(p);
************************************************************************

//Flow enters in send callerid in a while loop which checks 
cidpos<cidlen; Initial cidpos=0 and cidlen =8867
***************snip** send_callerid*****chan_zap.c****************
// 
	while(p->cidpos < p->cidlen) {
	    if(!p->cidpos)
	    {
  res = write(p->subs[SUB_REAL].zfd, p->cidspill + p->cidpos,
p->cidlen - p->cidpos);
//res here comes out to be 160	
	    }
		if (res < 0) {
			if (errno == EAGAIN)
				return 0;
			else {
	 ast_log(LOG_WARNING, "write failed: %s\n", strerror(errno));
				return -1;
			}
		}
		if (!res)
 			return 0;
// res increments pos by 160
			p->cidpos += res;
	}


*************************************************************************
The strange thing happens here when loop is executed 35-37 times
cidpos is inreased to near about 5700 < 8867 and suddenly control gets
in zt_handle_event function in a switch case statement and cancells
the callerid spill and continues.

***********snip***zt_handle_event***chan_zap.c*********************

	case ZT_EVENT_RINGEROFF:
  			if (p->inalarm) break;
			if (p->radio) break;
    		ast->rings++;
if ((ast->rings > p->cidrings) && (p->cidspill)) {
	ast_log(LOG_WARNING, "Didn't finish Caller-ID spill.  Cancelling.\n");
				free(p->cidspill);
				p->cidspill = NULL;
				p->callwaitcas = 0;
			}
	p->subs[index].f.frametype = AST_FRAME_CONTROL;
	p->subs[index].f.subclass = AST_CONTROL_RINGING;
break;

***********************************************************************
I am seaching Why loop exits before reaching limit of 8867 or what
makes zt_handle_event to control the flow.
Please help me with any idea you have. Also tell if I am on wrong path
for right problem

PS: I have tried best to explain it but if ny doubt prevails pls tell me.


Regards 
Gurminder



More information about the asterisk-dev mailing list