[comp.os.msdos.programmer] How to hang up modem line?

so@brownie.cs.wisc.edu (Bryan S. So) (11/18/90)

Other than sending +++ATZ to the modem, is there a more 
efficient way to hang up the phone line?  

I have tried to 

    outportb(mcr, 0);	/*  Modem control register 	*/
    outportb(lcr, 0);	/*  Line control register 	*/
    outportb(ier, 0);	/*  Interrupt enable register 	*/

in Turbo C.  It hangs up the phone line on many modems,
but not on several.  Is there a better way to do it?


Bryan So 

rhys@batserver.cs.uq.oz.au (Rhys Weatherley) (11/18/90)

so@brownie.cs.wisc.edu (Bryan S. So) writes:


>Other than sending +++ATZ to the modem, is there a more 
>efficient way to hang up the phone line?  

Try "+++ATH0" instead - it doesn't re-initialise the modem.  (The "H0" may
vary a bit - use the proper hangup sequence of your modem).  And don't forget
to have at least a one second pause either side of the "+++" sequence.

>I have tried to 

>    outportb(mcr, 0);	/*  Modem control register 	*/
>    outportb(lcr, 0);	/*  Line control register 	*/
>    outportb(ier, 0);	/*  Interrupt enable register 	*/

Rather than clearing everything, just drop the DTR signal for a few
milliseconds.  The code I use is:

	outportb(mcr,inportb(mcr) & 0xFE);	/* Zero out bit 0 (DTR) */
	delay(100);				/* Wait 100 ms: can vary */
	outportb(mcr,inportb(mcr) | 0x01);	/* Set DTR to 1 again */

This way, you can keep communicating with the modem to maybe begin a
new connection or whatever.  Also, it allows you to send the hangup
string afterwards if dropping the DTR didn't work (see below).

>in Turbo C.  It hangs up the phone line on many modems,
>but not on several.  Is there a better way to do it?

Ultimately, there is no "foolproof" way, but the best I have found is
to drop the DTR signal (as I have done above), and then if a carrier still
exists on the line, then send the hangup string.  This is used by Telix
(as far as I can tell), and many of my programs and seems quite adequate.
Make the hangup string configurable by the user, and it should be possible
the handle any situation.

Rhys.

+===============================+==============================+
||  Rhys Weatherley             |  University of Queensland,  ||
||  rhys@batserver.cs.uq.oz.au  |  Australia.  G'day!!        ||
+===============================+==============================+

TOMIII@MTUS5.BITNET (Thomas Dwyer III) (11/18/90)

Gee...I can't figure out a nifty-neato way of including the relavent
part(s) of previous posting(s).  Anyway, about hanging up the modem -
The reason +++ATZ doesn't work is because there must be a delay both
before and after the +++.  The delay is specified by an S register (sorry,
I don't have my modem manual here so I don't remember which) usually a
second will do.  As for dropping DTR, this only works if the switches
on the modem are set to "FOLLOW DTR" ie - they must not force DTR on.
Many modems also have software commands to follow/ignore the DTR signal.

Regards,
Thomas Dwyer III                        Email: tomiii@mtu.edu
Network Programmer                             tomiii@mtus5.BITNET
Computing Technology Services           Voice: (906) 487-2110
Michigan Technological University       Fax:   (906) 487-2787

poffen@sj.ate.slb.com (Russ Poffenberger) (11/20/90)

In article <5750@uqcspe.cs.uq.oz.au> rhys@batserver.cs.uq.oz.au writes:
>so@brownie.cs.wisc.edu (Bryan S. So) writes:
>
>
>>Other than sending +++ATZ to the modem, is there a more 
>>efficient way to hang up the phone line?  
>
>Try "+++ATH0" instead - it doesn't re-initialise the modem.  (The "H0" may
>vary a bit - use the proper hangup sequence of your modem).  And don't forget
>to have at least a one second pause either side of the "+++" sequence.
>
>>I have tried to 
>
>>    outportb(mcr, 0);	/*  Modem control register 	*/
>>    outportb(lcr, 0);	/*  Line control register 	*/
>>    outportb(ier, 0);	/*  Interrupt enable register 	*/
>
>Rather than clearing everything, just drop the DTR signal for a few
>milliseconds.  The code I use is:
>
>	outportb(mcr,inportb(mcr) & 0xFE);	/* Zero out bit 0 (DTR) */
>	delay(100);				/* Wait 100 ms: can vary */
>	outportb(mcr,inportb(mcr) | 0x01);	/* Set DTR to 1 again */
>
>This way, you can keep communicating with the modem to maybe begin a
>new connection or whatever.  Also, it allows you to send the hangup
>string afterwards if dropping the DTR didn't work (see below).
>
>>in Turbo C.  It hangs up the phone line on many modems,
>>but not on several.  Is there a better way to do it?
>
>Ultimately, there is no "foolproof" way, but the best I have found is
>to drop the DTR signal (as I have done above), and then if a carrier still
>exists on the line, then send the hangup string.  This is used by Telix
>(as far as I can tell), and many of my programs and seems quite adequate.
>Make the hangup string configurable by the user, and it should be possible
>the handle any situation.
>

Many modems can be configured for the action to take when DTR changes state.

If you have problems, read the modem manual and see it it can be setup so that
DTR hangs up the line.

Russ Poffenberger               DOMAIN: poffen@sj.ate.slb.com
Schlumberger Technologies       UUCP:   {uunet,decwrl,amdahl}!sjsca4!poffen
1601 Technology Drive		CIS:	72401,276
San Jose, Ca. 95110             (408)437-5254