Modem Configuration

When your serial port is set up, next you need to make sure the modem itself is configured correctly.

You've probably heard of "Hayes Compatible" modems. The compatibility refers not to which other modems you can talk to (that's covered by the modulation standards: V34, V32bis, V22bis etc), but to the set of commands which the computer can issue to the modem.

Unfortunately the Hayes "standard" isn't. Simple commands, like placing a call, are pretty much the same between modems; but when you need to do something more complex, such as setting how fast your modem communicates with a remote modem, you have little choice but to dig out the manual and look up the command, since the command set varies widely from one manufacturer to another.

There are also many different parameters you can set, and manufacturers do not agree what is a "good" default setting to send from the factory. For example, U.S. Robotics Sportsters used to ship with software handshaking (XON/XOFF) enabled by default. However this setting interferes with many dial-up protocols such as SLIP and XMODEM, and in general needs to be changed.

So when you get a new modem you will need to check out its parameters, and probably change them, before using it. To do this you connect it up and use a terminal program to issue commands to to the modem directly from the keyboard. Under Linux, the following command will connect you to cua0 (COM1) at 38400 bits per second:

    cu -l cua0 -s 38400
("cu" is part of the uucp package). To disconnect, you hit [Enter] then ~ followed by . (Enter, Tilde, Period)

The sequence of commands I recommend you issue to your modem is as follows. Remember that not all modems support all the commands given here; if one fails (it gives "ERROR" instead of "OK" as the result) you will have to look in the manual to find the equivalent command for your modem. For example, on a Telebit T3000, the command to set hardware handshaking is not AT&K3 but it is ATS58=2. To further complicate matters, some modems have switches which set defaults for certain parameters.

Reset current settings to Factory Defaults. On some modems there are several sets of defaults to choose from (AT&F0, AT&F1, AT&F2 etc) - look in the manual and choose one for "hardware (or RTS/CTS) flow control". For a USR modem this is AT&F1, and you also have to set ATY0 so that the modem will load its settings from non-volatile memory next time you power up.
Show current settings. You can use this to save time - not all the changes below may be necessary - and to check that the changes you have made have been accepted. For USR modems, this is ATI4
Fix serial port (DTE) speed
There is no standard for this one. On a Telebit T3000 it is ATS51=6 to lock the serial port at 38400bps. On a USR Sportster, AT&B1 tells the serial port speed not to change when the modem connects, but the actual serial port speed used is the speed of the last AT command. This is a problem because if the modem is reset, the serial port speed is also reset to its default (9600bps). This means that it is important to issue an 'AT' command to the modem at power-up and at every time it might be reset; preferably before every incoming call.
Enable full call failure result codes, such as BUSY and NO DIALTONE
Optional, and not supported on many modems. Enable full connect status messages, such as CARRIER and PROTOCOL, which are useful to see how good the connection you have made really is.
US Robotics: AT&A3
Modem DCD output signal follows connection status. This is so that the computer can tell if the far end disconnected. Without this, a process could stay talking to the modem even when a call has been lost; if another call came in, that person could access another user's account!
Modem terminates call when its DTR input is dropped. This is so that the computer can drop the call when it needs to, e.g. when a user logs off. Some modems have AT&D3 which also reinitialises the modem when DTR is dropped. This is a good idea, as long as this does not cause the modem's serial port to reset its speed to a different value.
AT&K3 (??? - varies widely)
Modem uses hardware handshaking (RTS/CTS) to control the flow of data. This is important! The alternative is to use Ctrl-S (XOFF) to stop data flow, and Ctrl-Q (XON) to restart it; but if a Ctrl-S happens to occur in the normal data stream, as might happen when transferring a file, the modem can lock up. SLIP and XMODEM are always affected by this; PPP and ZMODEM can avoid sending those characters, but it is always better to just use hardware handshaking.
US Robotics: AT&H1&I0&R2
AT&Q5 (??? - varies widely)
Use error correction when possible, or speed buffering if not. Amazingly, the factory default setting of some modems prevents the use of error correction even if the far-end modem has it. The best setting to choose is one which tries v42, falling back to MNP4, and falling back to a speed-buffered connection without error correction.
US Robotics: AT&B1&M4
ATS0=0 or ATS0=1
Don't or Do auto-answer. This depends on how your getty is set up. If it just waits for DCD to go high before issuing a login prompt, you need to get the modem to answer by itself. However if it waits for a RING message then issues an ATA command to pick up the phone, then you do not want the modem to answer by itself.
I strongly believe that the second method is better: it ensures that incoming calls will not be answered when the computer is down or you are using 'cu' or 'minicom' to talk to the modem. However this does require that all programs are properly compiled to use 'lock files' so that the serial port can be shared between cua (call-out) and ttyS (call-in) devices. Slackware 3.1 was broken in this respect.
Don't respond to the Hayes '+++' interrupt sequence, which brings the modem back to command mode. Otherwise, if a user types '+++' at a command prompt, and our system echoes it, it can lock up our modem. We don't need it since we can drop the call using DTR anyway.
Don't echo back commands, as this may cause the computer to 'chat' endlessly with the modem. Of course once you have issued this command you won't be able to see what you're typing, so leave this to the end.
Write the current settings to non-volatile RAM. These settings will automatically be reinstated each time the modem is powered up, or whenever the command ATZ is given.

Aside:A much nicer terminal program than cu is minicom. Apart from having a pretty screen display, you can use it to dial up to BBSes and transfer files using X/Y/Zmodem. Beware, however, that in its normal configuration minicom itself sends initialisation strings to the modem when you enter it, and again when you leave. You can view and edit these with 'minicom -s'

You should create or edit /etc/minirc.dfl (Red Hat) or /var/lib/minicom/minirc.dfl (Slackware) so it looks like this:

pr port             /dev/cua0
pu baudrate         38400
pu bits             8
pu parity           N
Note that you should never use /dev/modem to refer to your modem - it creates problems with lock files as one program might refer to the device as "/dev/modem" while another refers to it as "/dev/cua0", for example.

To get minicom to give a nice colour display, add '-c on' to the command line, or put the following line in /etc/profile:

export MINICOM='-c on'

Last updated 14 June 1998