old-www/HOWTO/Modem-HOWTO-8.html

273 lines
14 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.21">
<TITLE> Modem-HOWTO: Modem Configuration (excluding serial port) </TITLE>
<LINK HREF="Modem-HOWTO-9.html" REL=next>
<LINK HREF="Modem-HOWTO-7.html" REL=previous>
<LINK HREF="Modem-HOWTO.html#toc8" REL=contents>
</HEAD>
<BODY>
<A HREF="Modem-HOWTO-9.html">Next</A>
<A HREF="Modem-HOWTO-7.html">Previous</A>
<A HREF="Modem-HOWTO.html#toc8">Contents</A>
<HR>
<H2><A NAME="modem_conf"></A> <A NAME="s8">8.</A> <A HREF="Modem-HOWTO.html#toc8">Modem Configuration (excluding serial port) </A></H2>
<H2><A NAME="ss8.1">8.1</A> <A HREF="Modem-HOWTO.html#toc8.1">Finding Your Modem</A>
</H2>
<P> Before spending a lot of time deciding how to configure your
modem, you first need to make sure it can be found and that
AT-commands and the like can be sent to it. So I suggest you first
give it a very simple configuration using the communication program
you will be using on the port and see it it works. If this works you
may then want to improve on the configuration, If not then see
<A HREF="Modem-HOWTO-18.html#cant_find_modem">My Modem is Physically There but Can't be Found</A>. A winmodem may be hard to find and will not work under
Linux.</P>
<H2><A NAME="ss8.2">8.2</A> <A HREF="Modem-HOWTO.html#toc8.2">AT Commands</A>
</H2>
<P> While the serial port on which a modem resides requires
configuring, so does the modem itself. The modem is configured by
sending AT commands (or the like) to it on the same serial line that
is used to send data.</P>
<P>Most modems use an AT command set. These are cryptic and short ASCII
commands where all command strings must be prefaced by the letters AT.
AT means: ATtention, expect a command to follow. For example:
ATZ&amp;K3&lt;return&gt; This is an AT-command string with two
commands here: Z and &amp;K3. Z is short for Z0 and a few modems
require that you use Z0 instead of just Z. It's like this for other
commands ending in 0. The command string is terminated by a return
character (use the &lt;enter&gt; key if you are manually typing it). A
string that's too long (40 or more characters) may not work on older
modems. You may use either uppercase or lowercase letters.</P>
<P>Unfortunately there are many different variations of the AT
command set so that what works for one modem may or may not work for
another modem. Thus there is no guarantee that the AT commands given
in this section will work on your modem.</P>
<P>Such command strings are either automatically sent to the modem by
communication programs or are manually typed in by you. Most
communication programs provide a screen where you may change (edit)
and save the init string that the communication program will use.
The modem itself has a stored configuration (profile) which is like a
long init string. It represents the configuration of the modem when
it's first tuned on. You may change it to suit your taste. In most
cases there are a few different such configurations (profiles) and
there are ways to designate one of them to be active.</P>
<P>If you have a manual for your modem (either on paper or on floppy
disk) you might find AT-commands there. 3Com modems (and others ??)
have AT-Command help files built into the modem so if you type say
"AT$" to the modem it will display some "online help".</P>
<P>You can also find info on AT commands on the Internet. You should
first try a site for your modem manufacturer. If this doesn't work
out then you can search the Internet using terms that are from AT
commands such as &amp;C1, &amp;D3, etc. This will tend to find sites
that actually list AT-Commands instead of sites that just talk about
them in general. You might also try a few of the sites listed in the
subsection
<A HREF="Modem-HOWTO-20.html#web_sites">Web Sites</A>. Be warned that the
AT-commands for a different brand of modem may be somewhat different.</P>
<H2><A NAME="init_str"></A> <A NAME="ss8.3">8.3</A> <A HREF="Modem-HOWTO.html#toc8.3">Init Strings: Saving and Recalling </A>
</H2>
<P> The examples given in this subsection are from the Hayes AT modem
command set. All command strings must be prefaced by the two letters
AT. For example: AT&amp;C1&amp;D3^M (^M is the return character).
When a modem is powered on, it automatically configures itself with
one of the configurations it has stored in its non-volatile memory.
If this configuration is satisfactory there is nothing further to do.</P>
<P>If it's not satisfactory, then one may either alter the stored
configuration or configure the modem each time you use it by sending
it a string of commands known as an "init string" (= initialization
string). Normally, a communication program does this. What it
sends will depend on how you configured the communications program.
Your communication program should allow you to edit the init string
and change it to whatever you want. Sometimes the communications
program will let you select the model of your modem and then it will
use an init string that it thinks is best for that modem.</P>
<P>The configuration of the modem when it's first powered on may be
expressed by an init string. You might think of this as the default
"string" (called a profile). If your communications program sends the
modem another string (the init string), then this string will modify
the default configuration. For example, if the init string only
contains two commands, then only those two items will be changed.
However, some commands will recall a stored profile from inside the
modem so a single such command in the init string can thereby change
everything in the configuration.</P>
<P>Modern modems have a few different stored profiles to choose from that
are stored in the modem's non-volatile memory (it's still there when
you turn it off). In my modem there are two factory profiles (0 and
1, neither of which you can change) and two user defined profiles (0
and 1) that the user may set and store. Your modem may have more. To
view some of these profiles send the command &amp;V. At power-up one
of the user-defined profiles is loaded. For example, if you type the
command &amp;Y0 (just Y0 for a 3Com modem) then in the future profile
0 will be used at power-on.</P>
<P>There are also commands to load (activate) any of the stored profiles.
Such a load command may be put in an init string. Of course if it
loads the same profile that was automatically loaded at power-up,
nothing is changed (unless the active profile has been modified since
power-up). Since your profile could have thus been modified it's a
good idea to use some kind of an init string even if it does nothing
more than load a stored profile.</P>
<P>Examples of loading saved profiles:<BR>
Z0 loads user-defined profile 0 and resets (hangs up, etc.)<BR>
&amp;F1 loads factory profile 1</P>
<P>Once you have sent commands to the modem to configure it the way you
want (such as loading a factory profile and modifying it a little)
you may save this as a user-defined profile:<BR>
&amp;W0 saves the current configuration to user-profile 0.</P>
<P>Many people don't bother saving a good configuration in their modem,
but instead, send the modem a longer init string each time the modem
is used. Another method is to restore the factory default by &amp;F1
at the start of the init string and then modify it a little by adding
a few other commands to the end of the init string. Since there is no
way to modify the factory default this prevents anyone from changing
the configuration by modifying (and saving) the user-defined profile.</P>
<P>You may choose an init string supplied by someone else that they think
is right for your modem. Some communication programs have a library
of init strings to select from. The most difficult method (and one
which will teach you the most about modems) is to study the modem
manual and write one yourself. You could save this configuration
inside the modem so that you don't need an init string. A third
alternative is to start with an init string that someone else wrote,
but modify it to suit your purposes.</P>
<P>If you look at init strings used by communication programs you may see
symbols which are not valid modem commands. These symbols are
commands to the communication program itself and will not be sent to
the modem. For example, ~ may mean to pause briefly.</P>
<H3>Where is my "init string" so I can modify it ?</H3>
<P> This depends on your communication program (often a PPP program).
If this is the latest version of Modem-HOWTO send me info for other
cases.
<UL>
<LI> Gnome: run pppsetup</LI>
<LI> wvdial: edit /etc/wvdial.conf</LI>
<LI> minicom: hit ^Ao (or possibly ALT-o), then select "Modem and
Dialing"</LI>
</UL>
</P>
<H2><A NAME="modem_commands"></A> <A NAME="ss8.4">8.4</A> <A HREF="Modem-HOWTO.html#toc8.4">Other AT Modem Commands </A>
</H2>
<P> For dial-in see
<A HREF="Modem-HOWTO-12.html#dial-in_conf">Dial-in Modem Configuration</A>. The rest of
this section is mostly what was in the old Serial-HOWTO. All strings
must start with AT. Here's a few Hayes AT codes that should be in the
string (if they are not set by using a factory default or by a saved
configuration).</P>
<P>
<UL>
<LI>E1 command echo ON</LI>
<LI>Q0 result codes are reported</LI>
<LI>V1 result codes are verbose</LI>
<LI>S0=0 never answer (uugetty does this with the WAITFOR option)</LI>
</UL>
</P>
<P>Here's some more AT commands for special purposes:
<UL>
<LI>&amp;C1 CD is only on when you're connected</LI>
<LI>&amp;S0 DSR is always on</LI>
<LI>X3 Dial even if there is no dialtone (Blind dial. Use where
dial-tones don't exist).</LI>
</UL>
</P>
<P> Note: to get his old USR Courier V.34 modem to reset correctly
when DTR drops, Greg Hankins had to set <CODE>&amp;D2</CODE> and <CODE>S13=1</CODE>
(this sets bit 0 of register S13). This has been confirmed to work on
USR Sportster V.34 modems as well.</P>
<P> Note: some old Supra modems treat CD differently than other
modems. If you are using a Supra, try setting <CODE>&amp;C0</CODE> and
<EM>not</EM> <CODE>&amp;C1</CODE>. You must also set <CODE>&amp;D2</CODE> to handle DTR
correctly.</P>
<H2><A NAME="ss8.5">8.5</A> <A HREF="Modem-HOWTO.html#toc8.5">Blacklisting</A>
</H2>
<P>If phone number is dialed a few times with no success, some
modems may blacklist a phone number. After a certain time you may try
again. Some countries require this to reduce needless repeated
dialing. To view the blacklist try %B. To delete the blacklist use
these AT commands:
<UL>
<LI> SR Robotics o 3COM: s40=2 or if NG try s40=7</LI>
<LI> Lucent: %t21,18,0</LI>
<LI> Rockwell: %tcb</LI>
<LI> Cirrus Logic: *nc9</LI>
</UL>
</P>
<H2><A NAME="ss8.6">8.6</A> <A HREF="Modem-HOWTO.html#toc8.6">What AT Commands are Now Set in my Modem?</A>
</H2>
<P> You may try to use minicom for viewing your modem profile. It's
best not to have any other process running on the modem port when you
do this. If you have set up minicom for your modem, then you may type
on the command line: <CODE>minicom -o</CODE> to start minicom without
restoring the saved modem profile. Then type <CODE>at&amp;v</CODE> (or
atI4 on 3Com modems) to display the profile. To exit minicom without
disturbing this profile, use the q (quit) command for exiting without
resetting.</P>
<P>The above may not work for various reasons. If the modem has been set
not to echo result codes it may not even display any profile. If there
is another process running on the modem port at the same time, some of
what the modem sends to you is likely to be read by the other process
so you will see only part of the profile. Is there some way to
temporarily stop the other process on the port so it will not
interfere? I tried the "stop" signal using the "kill" command but it
didn't work. If this is the latest version of this HOWTO, let me know
if you find a way to do it.</P>
<P>If you have at least one process running on the modem port and kill
them, the modem's profile may be reset so you will not observe
what the original profile was. This will happen if you kill getty (or
it's replacements: login or bash) and have &amp;D3 set. The killing
of getty (or the like) will drop DTR and reset the modem's profile to
the power-on state. To keep getty from respawning when killed, comment
it out in /etc/inittab and do an "init q".</P>
<H2><A NAME="ss8.7">8.7</A> <A HREF="Modem-HOWTO.html#toc8.7">Modem States (or Modes)</A>
</H2>
<P> Since the channel for sending AT commands to the modem is the same
channel that is used for the flow of data (files, packets, etc.) then
it's important to cleanly separate the AT commands from the data.</P>
<P>When the modem is first turned on it's in the command mode (also
called terminal mode, idle state or AT-command mode). Anything sent
to it from the PC is assumed to be an AT command and not data. Then
if a dial command is sent to it (ATD...), it dials and connects to
another modem. It's now in the on-line data mode (connected) and
sends and receives data (such as Internet pages). In this mode, any
AT command one trys to send it will not work but will be transmitted
to the other modem instead. Except for the escape command. This is
+++ with a minimum time delay both at the start and end. The time
delay allows the modem to determine that it is likely a real escape
and not just +++ in a file being transmitted.</P>
<P>So we have two states so far: AT-command and on-line data. But there
is a third important state which is sort of a combination of these
two. It's the on-line command mode. This is when the modem maintains
a connection (without sending/receiving data) but anything sent from
the PC is interpreted as an AT command. This is the state reached
with a +++ escape signal or by a DTR drop from the PC provided the
&amp;D1 has been set. Then one can send AT commands to the modem
including commands which will leave this state and go to one of the
other two states.</P>
<P>There are other states also: dialing state and handshaking state but
they normally lead to the connected (on-line) state. If they don't
then the modem should hang up, thereby returning to the initial
AT-command (or idle) state.</P>
<HR>
<A HREF="Modem-HOWTO-9.html">Next</A>
<A HREF="Modem-HOWTO-7.html">Previous</A>
<A HREF="Modem-HOWTO.html#toc8">Contents</A>
</BODY>
</HTML>