# 5.3. Getting the modem to hang up

Sometimes, you may find kppp has difficulties hanging up the modem. This is likely the result of a mismatch between kppp settings and those of the modem. A standard modem uses two methods to decide to hangup: Command, and DTR. The Command method involves sending an escape sequence to the modem, which puts it in command mode, then issuing the hangup command (ATH).

Outside of kppp, when configuring the pppd package manually, it's often helpful to use the command method, so that one can exit a terminal session, and then start pppd without having the modem hangup. In most other situations, the DTR method is preferred, as it is simpler.

## 5.3.1. DTR (AT&Dn) method

The DTR method will have the modem hangup whenever kppp stops using the modem. If you obtain a modem session, and query the state via AT&V, and the among the settings displayed for the active profile are &D0, then the DTR hangup method is disabled. To enable the DTR method Use the Setup/More/Terminal to get a modem session. Then:

     ATZ		# reset to default profile
     AT&D2		# Set to hang up on DTR drop.
     AT&W		# Write to default profile

### 5.3.1.1. How The DTR Method Works

Whenever the Data Terminal Ready (DTR) line on the serial line between the host computer and the modem goes high, the modem hangs up. When kppp opens the serial port, the DTR line is pulled low, on an external modem, you can see the DTR (or TR) light come on when this happens. When the TR light goes out (because kppp has closed the serial port, or something worse!), the modem will hangup.

## 5.3.2. Command Method

The other way to have a modem hang up when connected (used when AT&Dn where n is not 2) is to have the modem accept the command when a session is in progress. To have it hangup properly, Get a modem session, and set the guard time to a short interval like so:

     ATZ
     ATS12=5
     AT&W

Then use the Settings/More/Modem Commands/Guard Time slider to match the register (S12) value to match (5) The modem should then hangup properly.

### 5.3.2.1. How The Command Method Works

When the local modem is connected to a remote modem, it is in the "connect" state, where it passes all the characters it receives to the remote modem without interpretation. To have the modem accept the characters as commands for itself, one must put the modem into the command state. The escape code does this.

The escape code is defined as a being three intervals of time whose length is defined by S12 (in fiftieth of a second.)

- Quiet (must last more than S12/50 seconds)

- Escape character (defined by register S2, default is "+") repeated three times (less than S12/50 seconds between each)

- Quiet (must last more than S12/50 seconds)

Once the modem is in the command state, you can send it commands. To have it hang up. Sent ATH. The escape codes and hangup string used by kppp are shown in the Setup/More/Modem Commands dialogs. These should match your modem.