problem with second call
- From: "Jerry" <jvelders@xxxxxxxxxxxxxx>
- Date: Thu, 3 Nov 2005 11:27:25 -0600
I'm new to tapi so I know I must be doing something dumb here, but after
several days I'm not making progress .. thus the call for help.
I've been asked to convert some old (15 yr old) DOS legacy home-brew
networking software to work under windows. It requires that I dial from a
current Windows machine TO a 2400 baud hayes-compatible modem. In the old
version, I just opened the comm port and sent AT commands to the modem.
Obviously, in the Windows world, this doesn't fly, so I've turned to TAPI.
I've had little problem making the connection by using the following
sequence (condensed and with all error checking removed). In the real code,
every call's retcode is checked and I've got messages going to a log file
....
retcode = lineInitialize( &hLineApp, ...
dwDeviceID = -1;
for (i = 0; i < lines && dwDeviceID == -1; i++)
{
pLineDevCaps = GetDevCaps(hLineApp, i, &dwAPIVersion); (function calls
negotiateapiversion for each iteration (1.4))
if (pLineDevCaps->dwMediaModes & LINEMEDIAMODE_DATAMODEM &&
pLineDevCaps->dwLineFeatures & LINEFEATURE_MAKECALL)
dwDeviceID = i;
free(pLineDevCaps);
if (dwDeviceID != -1)
break;
}
if (dwDeviceID == -1) // no suitable device
{
KillConnection();
return -1;
}
retcode = lineOpen(hLineApp ....
memset(&lineCallParams, 0, sizeof(LINECALLPARAMS));
lineCallParams.dwTotalSize = sizeof(LINECALLPARAMS);
lineCallParams.dwMinRate = 2400;
lineCallParams.dwMaxRate = 2400;
lineCallParams.dwMediaMode = LINEMEDIAMODE_DATAMODEM;
retcode = lineMakeCall(hLine, ....
peekmessage loop waits for line_reply or timeout and sets bConnected if ok
if (bConnected == 0) // timed out
{
KillConnection();
return -1;
}
lpDeviceID = (LPVARSTRING)malloc(sizeof(VARSTRING));
lpDeviceID->dwTotalSize = sizeof(VARSTRING);
lineGetID(0, 0, hCall, LINECALLSELECT_CALL, lpDeviceID,"comm/datamodem");
if (lpDeviceID->dwNeededSize > lpDeviceID->dwTotalSize)
{
lpDeviceID = (LPVARSTRING)realloc(lpDeviceID, lpDeviceID->dwNeededSize);
lpDeviceID->dwTotalSize = lpDeviceID->dwNeededSize;
lineGetID(0, 0, hCall, LINECALLSELECT_CALL, lpDeviceID,"comm/datamodem");
}
hComm = *((LPHANDLE)((char *)lpDeviceID + sizeof(VARSTRING)));
(hcomm is then used to set commstates, baud, etc)
The call connects ok and I establish communcation with the other end. When
I disconnect I go thru the following sequence ... the various handles are
global and obvious in their meaning .. Again, in the real code, all return
codes are checked and output to a log file. This is the code for
'KillConnection'
if( hComm)
{
retcode = CloseHandle( hComm );
hComm = NULL;
}
if(hCall)
{
retcode = lineDrop( hCall, NULL, 0 ); // Drop the call
if (retcode>0)
retcode = waitreply(retcode); (waits for line_reply)
while (gCallState != LINECALLSTATE_IDLE)
peekmessageloop(); (waits for linecallstate_idle)
retcode = lineDeallocateCall(hCall);
hCall = NULL;
}
if(hLine)
{
retcode = lineClose(hLine);
hLine = NULL;
}
if(hLineApp)
{
lineShutdown( hLineApp);
hLineApp = NULL;
}
This code runs without error and the call is terminated.
However, if I then try to establish another call, all code runs without
error until I get to the lineOpen command, which returns
LINEERR_OPERATIONFAILED.
What in the world am I doing wrong? Here's the output from my log file ...
Nov 03 10:57:20 - Program started...
Nov 03 10:57:24 - Received ID_CALL msg (initiates call)
Nov 03 10:57:24 - calling lineinitialize
Nov 03 10:57:24 - retcode = 0x0
Nov 03 10:57:24 - after lineinitialize, hLineApp = 0x800003ff
Nov 03 10:57:24 - after lineinitialize, lines = 0x7
Nov 03 10:57:24 - b4 getdevcaps
Nov 03 10:57:24 - calling lineNegotiateAPIVersion
Nov 03 10:57:24 - retcode = 0x0
Nov 03 10:57:24 - version = 0x10004
Nov 03 10:57:24 - calling lineGetDevCaps
Nov 03 10:57:24 - retcode = 0x0
Nov 03 10:57:24 - calling lineGetDevCaps (after changing memory
allocation)
Nov 03 10:57:24 - retcode = 0x0
Nov 03 10:57:24 - after getdevcaps, deviceID = 0x0
Nov 03 10:57:24 - calling lineopen
Nov 03 10:57:24 - hLineApp = 0x800003ff
Nov 03 10:57:24 - dwDeviceID = 0x0
Nov 03 10:57:24 - hline = 0x0
Nov 03 10:57:24 - dwAPIVersion = 0x10004
Nov 03 10:57:24 - retcode = 0x0
Nov 03 10:57:24 - after lineOpen, hLine = 0x10277
Nov 03 10:57:24 - calling linemakecall
Nov 03 10:57:24 - retcode = 0x10255
Nov 03 10:57:24 - after lineMakeCall, hCall = 0x0
Nov 03 10:57:24 - after linemakecall
Nov 03 10:57:24 - b4 idle loop
Nov 03 10:57:24 - linemakecall return = 0
Nov 03 10:57:24 - line reply
Nov 03 10:57:24 - Line Reply
Nov 03 10:57:24 - Dialing...
Nov 03 10:57:25 - Proceeding
Nov 03 10:57:44 - linecallstate connected
Nov 03 10:57:44 - Connected
Nov 03 10:57:44 - after idle loop
Nov 03 10:57:44 - after idle loop, hCall = 0x10233
Nov 03 10:57:44 - INFO request rec'd (1)
(successful comm received from the other end)
Nov 03 10:57:52 - Received ID_DISCONNECT msg (user clicked
'disconnect')
Nov 03 10:57:52 - CloseHandle called on hComm = 0x708
Nov 03 10:57:52 - succeeded
Nov 03 10:57:52 - calling lineDrop on hCall = 0x10233 (we wait for
LINE_REPLY before proceeding)
Nov 03 10:57:54 - LINECALLSTATE_DISCONNECTED
Nov 03 10:57:54 - LINECALLSTATE_IDLE (we wait for
IDLE before calling linedeallocatecall)
Nov 03 10:57:55 - retcode = 0x0
Nov 03 10:57:55 - calling lineDeallocateCall on hCall = 0x10233
Nov 03 10:57:55 - retcode = 0x0
Nov 03 10:57:55 - Call Dropped
Nov 03 10:57:55 - calling lineClose on hLine = 0x10277
Nov 03 10:57:55 - retcode = 0x0
Nov 03 10:57:55 - Line Closed
Nov 03 10:57:55 - lineShutdown called on hLineApp = 0x800003ff
Nov 03 10:57:55 - retcode = 0x0
Nov 03 10:57:55 - Line Shutdown
Nov 03 10:58:02 - Received ID_CALL msg (user
initiates the second call)
Nov 03 10:58:02 - calling lineinitialize
Nov 03 10:58:02 - retcode = 0x0
Nov 03 10:58:02 - after lineinitialize, hLineApp = 0x800003cc
Nov 03 10:58:02 - after lineinitialize, lines = 0x7
Nov 03 10:58:02 - b4 getdevcaps
Nov 03 10:58:02 - calling lineNegotiateAPIVersion
Nov 03 10:58:02 - retcode = 0x0
Nov 03 10:58:02 - version = 0x10004
Nov 03 10:58:02 - calling lineGetDevCaps
Nov 03 10:58:02 - retcode = 0x0
Nov 03 10:58:02 - calling lineGetDevCaps
Nov 03 10:58:02 - retcode = 0x0
Nov 03 10:58:02 - after getdevcaps, deviceID = 0x0
Nov 03 10:58:02 - calling lineopen
Nov 03 10:58:02 - hLineApp = 0x800003cc
Nov 03 10:58:02 - dwDeviceID = 0x0
Nov 03 10:58:02 - hline = 0x0
Nov 03 10:58:02 - dwAPIVersion = 0x10004
Nov 03 10:58:02 - retcode = 0x80000048 (OOPS)
Nov 03 10:58:02 - after lineOpen, hLine = 0x0
Nov 03 10:58:02 - lineopen error
Nov 03 10:58:02 - LINEERR_OPERATIONFAILED
Nov 03 10:58:03 - lineOpen error
Nov 03 10:58:03 - Unable to start a TAPI Function
Nov 03 10:58:04 - Received ID_DISCONNECT msg
Nov 03 10:58:04 - lineShutdown called on hLineApp = 0x800003cc
Nov 03 10:58:04 - retcode = 0x0
Nov 03 10:58:04 - Line Shutdown
I'd surely appreciate any guidance or insight. I'm under the gun on this
thing. Sorry this is so long.
Jerry
.
- Follow-Ups:
- Re: problem with second call
- From: Andreas Marschall [MVP TAPI]
- Re: problem with second call
- From: Andreas Marschall [MVP TAPI]
- Re: problem with second call
- Prev by Date: Re: Detect "CALL IN PROGESS" using the CallURL Voice 8LV TSP Board
- Next by Date: Re: Outgoing call and the window problem
- Previous by thread: Re: LINEERR_INVALCALLHANDLE
- Next by thread: Re: problem with second call
- Index(es):
Relevant Pages
|