old-www/HOWTO/Remote-Serial-Console-HOWTO/modem-hayes.html

820 lines
12 KiB
HTML

<HTML
><HEAD
><TITLE
>Configure modem with AT commands</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Remote Serial Console HOWTO"
HREF="index.html"><LINK
REL="UP"
TITLE="Modem configuration"
HREF="modem.html"><LINK
REL="PREVIOUS"
TITLE="Configure dumb modem"
HREF="modem-dumb.html"><LINK
REL="NEXT"
TITLE="Internal modems"
HREF="modem-internal.html"></HEAD
><BODY
CLASS="SECTION"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Remote Serial Console HOWTO</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="modem-dumb.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 12. Modem configuration</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="modem-internal.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECTION"
><H1
CLASS="SECTION"
><A
NAME="MODEM-HAYES"
></A
>12.3. Configure modem with <SPAN
CLASS="ACRONYM"
>AT</SPAN
> commands</H1
><P
>Most modems today are smart modems based upon the Hayes
modems and their command sets. But as discussed above, the
<SPAN
CLASS="SYSTEMITEM"
>Linux</SPAN
> serial console is
designed to operate with a dumb modem.</P
><P
>Thus the smart modem is dumbed-down until it resembles a dumb
modem. Some expensive modems will have a <SPAN
CLASS="ACRONYM"
>DIP</SPAN
>
switch or board jumper to put them into dumb mode.</P
><P
>It is essential to have a manual for the modem which describes
that modem's <TT
CLASS="LITERAL"
>AT</TT
> commands. Although most modems
agree on the more popular <TT
CLASS="LITERAL"
>AT</TT
> commands, they
differ in the more technical commands.</P
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="MODEM-HAYES-BPS"
></A
>12.3.1. Configure port speed</H2
><P
>Hayes <SPAN
CLASS="ACRONYM"
>AT</SPAN
>-style modems can maintain a
static speed between the computer and the modem, no matter what
speed the dialing modem uses.</P
><P
>For most modems this is set automatically based upon the
speed of the first characters sent after power-on.</P
><P
>Power cycle the modem and connect to it with the command
<B
CLASS="COMMAND"
>minicom -o console</B
>. Press
<B
CLASS="KEYCAP"
>Enter</B
> a few times. The modem should now be
running at the same bit rate used by
<SPAN
CLASS="APPLICATION"
>Minicom</SPAN
>, which we set to the speed of
the serial console in <A
HREF="modem-minicom.html"
>Section 12.1</A
>.</P
><P
>You can check the port speed by asking the modem to generate
some output.</P
><DIV
CLASS="FIGURE"
><A
NAME="MODEM-HAYES-BPS-ATI"
></A
><P
><B
>Figure 12-2. Testing the modem's port speed</B
></P
><TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
><TT
CLASS="PROMPT"
>bash#</TT
> <B
CLASS="COMMAND"
>minicom -o console</B
>
Welcome to minicom
Press CTRL-A Z for help on special keys
<B
CLASS="KEYCAP"
>Enter</B
> <B
CLASS="KEYCAP"
>Enter</B
> <B
CLASS="KEYCAP"
>Enter</B
>
<B
CLASS="COMMAND"
>ATI</B
> <B
CLASS="KEYCAP"
>Enter</B
>
56k V.90 Series 3 External V2.20
<B
CLASS="KEYCAP"
>Ctrl</B
>-<B
CLASS="KEYCAP"
>A</B
> <B
CLASS="KEYCAP"
>Q</B
>
<SPAN
CLASS="GUIMENU"
>Leave without reset?</SPAN
> <SPAN
CLASS="GUIMENUITEM"
>Yes</SPAN
></PRE
></FONT
></TD
></TR
></TABLE
></DIV
><P
>Some modems have an <SPAN
CLASS="ACRONYM"
>AT</SPAN
> command to
re-establish the port speed, look in your modem's manual for the
<B
CLASS="COMMAND"
>AT&#38;B1</B
> command. Some modems have a command
to explicitly set the port speed, look in you modem's manual for
the <B
CLASS="COMMAND"
>ATB</B
> command.</P
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="MODEM-HAYES-ANSWER"
></A
>12.3.2. Configure answer mode</H2
><P
>The modem will answer an incoming call on the second ring
using the command <B
CLASS="COMMAND"
>ATS0=2</B
>.</P
><P
>Don't answer the phone on the first ring as this may
invalidate the certification of the modem in some telephony
jurisdictions.</P
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="MODEM-HAYES-CTSRTS"
></A
>12.3.3. Configure <SPAN
CLASS="ACRONYM"
>CTS</SPAN
>/<SPAN
CLASS="ACRONYM"
>RTS</SPAN
> handshaking</H2
><P
><SPAN
CLASS="ACRONYM"
>CTS</SPAN
>/<SPAN
CLASS="ACRONYM"
>RTS</SPAN
> handshaking
prevents lost characters.</P
><P
>The <TT
CLASS="LITERAL"
>AT</TT
> command is
<B
CLASS="COMMAND"
>AT&#38;K3</B
>.</P
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="MODEM-HAYES-DCD"
></A
>12.3.4. Configure Data Carrier Detect</H2
><P
>Data Carrier Detect should follow the presence or absence of
a calling modem.</P
><P
>The <SPAN
CLASS="ACRONYM"
>AT</SPAN
> command is
<B
CLASS="COMMAND"
>AT&#38;C1</B
>.</P
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="MODEM-HAYES-DTR"
></A
>12.3.5. Configure Data Terminal Ready</H2
><P
>Data Terminal Ready should control the modem. If
<SPAN
CLASS="ACRONYM"
>DTR</SPAN
> is high the modem is ready to receive calls.
If <SPAN
CLASS="ACRONYM"
>DTR</SPAN
> is low the modem should not receive any
more calls and should hang up any existing call.</P
><P
>The <SPAN
CLASS="ACRONYM"
>AT</SPAN
> command is
<B
CLASS="COMMAND"
>AT&#38;D2</B
>.</P
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="MODEM-HAYES-CONNECT"
></A
>12.3.6. Configure no <TT
CLASS="COMPUTEROUTPUT"
>CONNECT</TT
>
messages</H2
><P
>A Hayes <SPAN
CLASS="ACRONYM"
>AT</SPAN
>-style modem usually outputs a
message when a call is received. For example:</P
><DIV
CLASS="INFORMALFIGURE"
><A
NAME="MODEM-HAYES-CONNECT-EXAMPLE"
></A
><P
></P
><TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
><TT
CLASS="COMPUTEROUTPUT"
>CONNECT 9600</TT
></PRE
></FONT
></TD
></TR
></TABLE
><P
></P
></DIV
><P
>The modem has a <SPAN
CLASS="QUOTE"
>"quiet mode"</SPAN
> that disables these
messages.</P
><P
>The <SPAN
CLASS="ACRONYM"
>AT</SPAN
> command is
<B
CLASS="COMMAND"
>ATQ1</B
>. There will be no
<TT
CLASS="COMPUTEROUTPUT"
>OK</TT
> printed in response to this
command.</P
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="MODEM-HAYES-ECHO"
></A
>12.3.7. Configure no echo of commands</H2
><P
>Echoing commands can confuse the console, so turn off
command echoing.</P
><P
>The <TT
CLASS="LITERAL"
>AT</TT
> command is
<B
CLASS="COMMAND"
>ATE0</B
>.</P
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="MODEM-HAYES-SPEAKER"
></A
>12.3.8. Optionally, configure silent connection</H2
><P
>Most modems have a speaker. By default this is connected
whilst a modem is connecting and negotiating a common protocol and
speed. This is very useful for a dialing modem, as it prevents a
human being accidentally repeatedly called. The speaker can be
annoying on answering modems.</P
><P
>If a quieter computer room is desirable, use the
<B
CLASS="COMMAND"
>ATM0</B
> command to turn off the speaker.</P
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="MODEM-HAYES-DTRDROP"
></A
>12.3.9. Optionally, configure DTR delay</H2
><P
>Data Terminal Ready drops when the semiconductor that
supports the <SPAN
CLASS="ACRONYM"
>RS-232</SPAN
> link is reset. This then
hangs up the modem. This can be annoying. If the
<SPAN
CLASS="APPLICATION"
>getty</SPAN
> supports a parameter similar to
<SPAN
CLASS="APPLICATION"
>mgetty</SPAN
>'s
<TT
CLASS="LITERAL"
>toggle-dtr-waittime</TT
> then it is possible to
extend the time that the modem will ignore <SPAN
CLASS="ACRONYM"
>DTR</SPAN
>.
The time that <SPAN
CLASS="APPLICATION"
>getty</SPAN
> holds
<SPAN
CLASS="ACRONYM"
>DTR</SPAN
> low to force a hang up is extended beyond the
modem's setting. The result is that resetting the semiconductor
does not hang up the modem, but <SPAN
CLASS="APPLICATION"
>getty</SPAN
>
can still hang up the modem at the end of a login session.</P
><P
>Check your modem's documentation. Our example modem uses
S-register 25 to contain the threshold for noticing a change in
<SPAN
CLASS="ACRONYM"
>DTR</SPAN
>. The value is in one-hundreds of a second.
By setting the modem with <B
CLASS="COMMAND"
>ATS25=150</B
> (1.5
seconds) and setting <SPAN
CLASS="APPLICATION"
>mgetty</SPAN
> with
<TT
CLASS="LITERAL"
>toggle-dtr-waittime 2000</TT
> (2 seconds) we ignore
small blips in <SPAN
CLASS="ACRONYM"
>DTR</SPAN
>.</P
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="MODEM-HAYES-ATTENTION"
></A
>12.3.10. Configure no attention sequence</H2
><P
>Once the modem is correctly configured and works well,
disable the <TT
CLASS="LITERAL"
>+++</TT
> sequence that gives access to
the modem's command mode.</P
><P
>The <SPAN
CLASS="ACRONYM"
>AT</SPAN
> command is
<B
CLASS="COMMAND"
>ATS2=255</B
>.</P
><P
>If this command is accidentally given see <A
HREF="modem-hayes.html#MODEM-HAYES-RESET"
>Section 12.3.12</A
> to reset the modem to its factory
default parameters and start again.</P
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="MODEM-HAYES-EXAMPLE"
></A
>12.3.11. Configuration example</H2
><DIV
CLASS="FIGURE"
><A
NAME="MODEM-HAYES-EXAMPLE-CONFIG"
></A
><P
><B
>Figure 12-3. Configure modem using <SPAN
CLASS="ACRONYM"
>AT</SPAN
>
commands</B
></P
><TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
><TT
CLASS="PROMPT"
>bash#</TT
> <B
CLASS="COMMAND"
>minicom -o console</B
>
<TT
CLASS="COMPUTEROUTPUT"
>Welcome to minicom
Press CTRL-A Z for help on special keys</TT
>
<B
CLASS="COMMAND"
>AT &#38;F</B
> <B
CLASS="KEYCAP"
>Enter</B
>
<TT
CLASS="COMPUTEROUTPUT"
>OK</TT
>
<B
CLASS="COMMAND"
>AT Z</B
> <B
CLASS="KEYCAP"
>Enter</B
>
<TT
CLASS="COMPUTEROUTPUT"
>OK</TT
>
<B
CLASS="COMMAND"
>AT &#38;C1 &#38;D2 &#38;K3 S0=2 M0</B
> <B
CLASS="KEYCAP"
>Enter</B
>
<TT
CLASS="COMPUTEROUTPUT"
>OK</TT
>
<B
CLASS="COMMAND"
>AT E0 Q1 S2=255 &#38;W</B
> <B
CLASS="KEYCAP"
>Enter</B
>
<B
CLASS="KEYCAP"
>Alt</B
>-<B
CLASS="KEYCAP"
>A</B
> <B
CLASS="KEYCAP"
>Q</B
>
<SPAN
CLASS="GUIMENU"
>Leave without reset?</SPAN
> <SPAN
CLASS="GUIMENUITEM"
>Yes</SPAN
></PRE
></FONT
></TD
></TR
></TABLE
></DIV
></DIV
><DIV
CLASS="SECTION"
><H2
CLASS="SECTION"
><A
NAME="MODEM-HAYES-RESET"
></A
>12.3.12. Resetting the modem</H2
><P
>If you need to issue more <SPAN
CLASS="ACRONYM"
>AT</SPAN
> commands to
the modem then power cycle the modem. This should place the modem
into command mode.</P
><P
>Now issue the following commands to restore the modem's
factory configuration.</P
><DIV
CLASS="FIGURE"
><A
NAME="MODEM-HAYES-ATTENTION-REGAIN"
></A
><P
><B
>Figure 12-4. Resetting a Hayes <SPAN
CLASS="ACRONYM"
>AT</SPAN
>-style
modem</B
></P
><TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
><TT
CLASS="PROMPT"
>bash#</TT
> <B
CLASS="COMMAND"
>minicom -o console</B
>
<TT
CLASS="COMPUTEROUTPUT"
>Welcome to minicom
Press CTRL-A Z for help on special keys</TT
>
<B
CLASS="COMMAND"
>AT &#38;F &#38;Y0 &#38;W &#38;W1</B
> <B
CLASS="KEYCAP"
>Enter</B
>
OK
<B
CLASS="COMMAND"
>AT Z</B
> <B
CLASS="KEYCAP"
>Enter</B
>
OK
<B
CLASS="KEYCAP"
>Alt</B
>-<B
CLASS="KEYCAP"
>A</B
> <B
CLASS="KEYCAP"
>Q</B
>
<SPAN
CLASS="GUIMENU"
>Leave without reset?</SPAN
> <SPAN
CLASS="GUIMENUITEM"
>Yes</SPAN
></PRE
></FONT
></TD
></TR
></TABLE
></DIV
><P
>If this fails then you will need to clear the modem's
configuration memory. The procedure for this varies by
manufacturer, and probably requires the disassembly of the
modem.</P
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="modem-dumb.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="modem-internal.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Configure dumb modem</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="modem.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Internal modems</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>