ModemStream

(Engine-Level Function)

Description: Open a serial stream on a modem and returns its status (prior to the connection being made), a modem stream (after the connection has been established), or an error code.
Returns: Varies - see description
Usage: Script Only.
Function Groups: Modem
Related to: ModemCount | ModemDial | ModemList | ModemMedia | ModemTransfer
Format: ModemStream(Modem [, RingCount, ReceiveLen, TransmitLen, MediaMode])
Parameters:  
Modem
Required. Any numeric expression giving the modem number between 1 and the number of modems in the system (the return from ModemCount).
RingCount
An optional parameter that is any numeric expression designating the number of rings after which the modem should be answered. If this parameter is 0 the modem will not answer the call. The default is 1.
ReceiveLen
An optional parameter that is any numeric expression giving the size of the receive buffer for the serial stream in bytes. ReceiveLen must be in the range 2 to 32 766. The default length is 1024. If more bytes are received than can fit in the receive buffer before the application removes them, the additional data will be lost.
TransmitLen
An optional parameter that is any numeric expression giving the size of the transmit buffer for the serial stream in bytes. TransmitLen must be in the range 2 to 32 766. The default length is 1024. The buffer must be large enough to hold the maximum number of bytes pending transmission at any instance.
MediaMode
An optional numeric expression, specifying the desired media mode for the call. See ModemMedia for a description of valid values and their meanings.
Comments Typically, this function is used to prepare a modem for the receipt of incoming calls. Use the ModemDial function to make outgoing calls.
The return value for this function will be one of the following integer values until the modem has a valid connection with a remote modem

Return Value

Status

0

Idle (no connection), waiting for a call

1

Starting outbound call

2

Outgoing call request accepted by modem

3

Dial tone on outbound call

4

Dialing outbound call

5

Remote phone ringing on outbound call

6

Remote phone busy on outbound call

7

Connected (should not be seen since a stream value will be returned at this point)

8

Another application is handling the call after a ModemTransfer

9

Incoming call detected. The modem is being called, but has not yet answered. Changes to 11 when the modem answers

10

The modem is temporarily unavailable. Occurs when trying to place an outgoing call and either the modem is still initializing or another TAPI aware application has the modem

11

The modem has answered a call. Modem training in progress. Normally followed by a valid stream connection

If an error has occurred, the return values will be one of the following error codes:

Error Code

Error

-1

The (numeric) first parameter to the function is out of range

-2

No dial tone detected on outbound call

-3

Remote phone busy on outbound call

-4

No answer on outbound call

-5

Remote hung up on incoming call

-6

Modem unavailable

-7

Other call termination condition

Errors equal to or less than -101 correspond to the Microsoft Telephony Interface (TAPI) errors (which are normally numbered from 1). Specific errors which may be encountered are:

-101 TAPI error code 1
(LINEERR_ALLOCATED)
the serial port is in exclusive use by some other process
-112 TAPI error code 12
(LINEERR_INCOMPATIBLEAPIVERSION)
the system does not have the required version of telephony support (TAPI 2.0 required)
-115 TAPI error code 15
(LINEERR_INUSE)
the line device is in use and cannot currently be configured, nor can it allow a party to be added or a call to be answered, placed or transferred
-147 TAPI error code 47
(LINEERR_INVALMEDIAMODE)
the
requested media mode could not be accommodated (e.g. voice
call request on a non voice modem).
-167 TAPI error code 67
(LINEERR_NODEVICE)
the specified device identifier, which was previously valid, is no longer accepted because the associated device has been removed from the system since TAPI was last initialized. Alternately, the line device has no associated device for the given device class
-168 TAPI error code 68
(LINEERR_NODRIVER)
either TAPIAddr.DLL could not be located or the telephone service provider for the specified device found that one of its components is missing or corrupt in a way that was not detected at initialization time. Use the Telephony Control Panel to correct the problem
-169 TAPI error code 69
(LINEERR_NOMEM)
insufficient memory to perform the operation, or unable to lock memory
-175 TAPI error code 75
(LINEERR_RESOURCEUNAVAIL)
insufficient resources to complete the operation (e.g. a line cannot be opened due to a dynamic resource over commitment). Also occurs where a modem is being used by a non-TAPI application. It is not possible to change the media mode of a call during a call.