hadling a call


[ Follow Ups ] [ Post Followup ] [ Netlib Discussion Forum ] [ FAQ ]

Posted by lawrence Ha on September 23, 1998 at 14:55:22:

Dear Sir;
I am still new in programming, I am trying to develop a system using Borland C++4.5, herer how the system work. the system will detect call, & handle the call, caller will dial a number, the system will base on the number & give caller an answer. I attched the file I wrote, the problem is that it casnnot always initialize the comm port, & cannot handle tha call, I do hope you can help me on this.
thank you.
the code r below
#include
#include

int main()
{
int iErr, idCommDev,nuring=0;
DCB dcb;


idCommDev = OpenComm ("COM2", 1024, 128);
if (idCommDev < 0)
{MessageBox(NULL,"Error Opening Comm Port",
"Open Comm", MB_ICONSTOP);
return 0;}

iErr = BuildCommDCB("COM2:2400,n,8,1", &dcb);
if(iErr<0)
{MessageBox(NULL,"error creating DCB","builtCommDCB", MB_ICONSTOP);
return 0;}

iErr = SetCommState(&dcb);
if(iErr<0)
{MessageBox(NULL,"error setting comm state","setcommstate",MB_ICONSTOP);
return 0;}

SetCommEventMask(idCommDev,EV_RING);
//SetCommEventMask(idCommDev,EV_RLSD);
for(;;)
{
GetCommEventMask(idCommDev,EV_RING);
nuring++;
if (nuring>2)
EscapeCommFunction(idCommDev,SETDTR) ;
break;
}


//iErr = CloseComm (idCommDev);
//if(iErr<0)
//{MessageBox(NULL,"error closingcomm port","close commport",MB_ICONSTOP);
//return 0;}
return 1;}



Follow Ups: