[comp.windows.ms.programmer] Modem Hangup from inside Win 3.0 App

fac7@dayton.saic.com (Steven Poling) (05/23/91)

	I am writing a Windows 3.0 application that is utilizing
a modem to access a database system, download data and then terminating
the connection.  I can not get the application to hang up the modem
after the data transfer is complete.  I need a way to drop DTR from
inside the Windows application.  If anyone has experienced this 
problem and has a way to do it, I would be most thankful.  I have
tried to get the modem attention by send +++ and waiting for the
string OK, but on a 2400 baud modem this does not seem to work.  I
have had success with this method on a MultiTech 9600 baud modem,
but don't have a clue why it wouldn't work on the 2400 baud modem.

Thanks Again
(In advance)

-- 
_____________________________________________________________________________
               ____ ____    ___
Steven Poling /___ /___/ / /     Science Applications International Corporation
             ____//   / / /__                 Dayton, Ohio
-----------------------------------------------------------------------------
Internet: fac7@dayton.saic.com    uucp: dayvb!fac7

oneel@heawk1.gsfc.nasa.gov ( Bruce Oneel ) (05/29/91)

In article <1991May22.183530.1627@dayton.saic.com> fac7@dayton.saic.com (Steven Poling) writes:

	   I am writing a Windows 3.0 application that is utilizing
   a modem to access a database system, download data and then terminating
   the connection.  I can not get the application to hang up the modem
   after the data transfer is complete.  I need a way to drop DTR from
   inside the Windows application.  If anyone has experienced this 
   problem and has a way to do it, I would be most thankful.  I have
   tried to get the modem attention by send +++ and waiting for the
   string OK, but on a 2400 baud modem this does not seem to work.  I
   have had success with this method on a MultiTech 9600 baud modem,
   but don't have a clue why it wouldn't work on the 2400 baud modem.

   Thanks Again
   (In advance)


Look carefully at how you are sending the string +++  to the modem.
Many modems require that the port be quiet for a length of time before
you send the string, then the string must come within a certain
ammount of time (but not too fast), and then the port must continue to
be quiet.

eg.

(wait 1 sec) + (wait 1/4 sec) + (wait 1/4 sec) + (wait 1 sec) and you
should see the "OK" string.

All of this is to prevent a valid use of +++ to cause the modem to go
to local mode.

bruce
--
Bruce O'Neel              oneel@heasfs.gsfc.nasa.gov
NASA/GSFC/STX/Code 664

Norbert_Unterberg@p4.f36.n245.z2.fidonet.org (Norbert Unterberg) (05/31/91)

 >            I am writing a Windows 3.0 application that is utilizing
 >    a modem to access a database system, download data and then
 > terminating
 >    the connection.  I can not get the application to hang up the modem
 >    after the data transfer is complete.  I need a way to drop DTR from
 >    inside the Windows application.  If anyone has experienced this
 >    problem and has a way to do it, I would be most thankful.  I have
 >    tried to get the modem attention by send +++ and waiting for the
 >    string OK, but on a 2400 baud modem this does not seem to work.

Windows provides an easy way to manage the signals DTR and RTS. Just use 
EscapeCommFunction(nCid, CLRDTR).

Your other problem: As far as I know, +++ places the modem into the the command 
mode, but it does not answer with "OK". Try the following:

 - Flush the output buffer or wait until it is empty. (important!)
 - Wait for 2 seconds
 - Send a "+++" (without CR)
 - Wait for output buffer empty
 - Wait for 2 seconds
 - Send "AT" followed by a CR.

Now the modem should respond with an "OK" string and can safely assumed to be 
in command mode.

Norbert
Dortmund, Germany