[Previous] [Contents] [Next]

modem

Modem handler to answer calls (QNX)

Syntax:

modem [options]

Options:

-a string
Use string to answer the phone (default is ATA).
-b baud
Use this baud rate when programming the modem or receiving result codes (default is 2400 baud).
-B baud
Assume this baud rate if the modem answers "connect" without a specified baud rate (default is 2400 baud).
-c command
Start this command (default is login -p).
-C
Don't wait for CTS.
-d [P]number
Dial this number and attempt to connect to a remote modem. If the number is preceded by a P, then pulse dialing as opposed to tone dialing will be used. Upon a successful connection, modem will attempt to login to the remote system if the -U user:pass:cmd option is specified. It will then exec() into either the command specified by the -c option or /bin/qtalk if -c is not specified.
-D file
Log debug information. If file is a dash character (-), then output is sent to stderr. (Default: no logging of debug info)
-f command
Command to start for a fax call. (default: /bin/fax re)
-F fax_id
Local fax machine identification. (default: "Unknown")
-g file
On connect, print the greeting message stored in file.
-i string
Use this string to initialize the modem (default is ATZ).
-I file
Identification file for caller-id/callback processing.
-l
("el") Do not lock the baud rate.
-L
Use locked baud rate. (default)
-p parity
Set the parity, number of data bits, and number of stop bits specified in parity. This consists of a three-character string:
parity data stop
{e|o|m|s|n} {7|8} {1|2}

The default is n81.

-P millisec
Wait this number of milliseconds before responding to a RING with the answer string (usually ATA). The default is 0.
-r rings
Wait for this number of rings before answering (default is 1 unless -I is specified, in which case the default is 2). To suppress answering, specify -r 0.
-R minutes
Resynchronize the modem by sending the initialization string (specified via option -i) every specified number of minutes minutes (default is every 15 minutes). Specify -R 0 to disable resynchronization.
-s seconds
Delay this number of seconds before starting command (default is 3 seconds).
-t tries
Number of times to try and dialout or callback. (default: 2)
-T pppd_cmd
Command to start on a ppp call (default: none)
-U user:pass:cmd
Userid and password to login as. Only valid with -d option.

Description:

The modem utility monitors a serial line connected to a modem. It is usually started by the tinit utility to automatically provide dial-in users with a login.


Note: For testing, you can start modem on a serial line using I/O redirection in place of the tinit utility. This will operate modem on a one-shot basis. That is, when a call is answered by the modem utility, it will start a login (this can be changed with the -c option) and terminate. When the login user logs out, modem will not be restarted. For example:
on -t /dev/ser1 modem -b 57600 -L -D debug_output
The -D filename option will write all the communication that occurs between the modem utility and the modem to the named file.

To configure a modem, the modem utility can be told to send commands to the modem. It will then wait for the modem to issue messages concerning an incoming call.

After modem has answered the phone and determined the baud rate, it waits for the delay specified via the -s option. This delay avoids the burst of noise characters that often occur when two older modems first connect. (On some ancient modems, this has been observed to be up to 10 seconds.) After the delay, a greeting is displayed, provided the -g option was used to specify a greeting file. The modem program will then replace itself via the exec() function call with either the login utility or the command specified with the -c option. The user may now log in as usual. If the user logs out, tinit restarts another modem program on the line and the whole process is repeated.

You can periodically reprogram a modem via the -R option. This is useful if the modem is powered off, then on again. This practice might also improve the reliability of some modems that "forget" their settings over time (this isn't supposed to happen in a perfect world...).

The -p option sets the line parameters for the parity, number of data bits, and the number of stop bits. It consists of a three-character string. The following table summarizes the five most common configurations. Note that most modern systems expect n81, the default.

Configuration parity data bits stop bits
n81 (default) none 8 1
e71 even 7 1
o71 odd 7 1
m71 mark 7 1
s71 space 7 1

Note: To talk to another QNX system, n81 should be selected.

The -L option should be used with high-speed modems that talk to the computer at a fixed baud rate and use hardware flow control to regulate the data. This option will enable QNX hardware flow control. Make sure you program your modem to support hardware flow control as well. Most modems support hardware flow control by default.

So that modem can detect the modem status (on or off line), you have your modem configured to provide the CD (carrier detect) RS-232 signal to the computer. A few modems do not support this capability, but most modern modems are configured for this by default. For older Hayes modems, the command to enable this is AT&C1, but check the manual for your modem since this command does vary. When a loss of carrier occurs, a SIGHUP is sent to the session leader, typically the login shell. This will cause it to terminate, which will send a SIGHUP to non-background children. The net effect is to remove all the users' processes, thus logging the user off.

So that modem and other programs can force the modem to hang up if necessary, the DTR (Data Terminal Ready) RS-232 signal should also be connected from the computer to the modem. Your modem should be programmed to force a hangup and reset itself when the computer "drops" DTR. Most modern modems do this by default. For older Hayes modems, the command to do this is AT&D2, but check the manual for your modem since this command varies.

As part of the baud rate determination, modem posts an environment variable called BAUD, which is set equal to the baud rate for the modem connection. The BAUD variable is useful since many high-speed modems operate with the serial link between the modem and the computer at a fixed high speed (usually 19200 or greater), and then use hardware flow control to regulate the flow of data for slower connections. Since the true baud rate cannot be determined by the stty setting, modem posts this information as an environment variable so that the tasks started by the dial-up user can determine the true transfer rate.

To change the modem initialization string used by modem, you use the -i option. The default string is "ATZ".

The modem initialization string supports a number of special characters that are processed by modem rather than being passed to the modem. These characters, and their actions, are:

Character Action
| carriage return
~ (tilde) 1-second delay
' (apostrophe) 100-millisecond delay
^ (caret) drop DTR for 1 second (forces a modem to hang up and reset)
! send a 500-millisecond break

As the modem initialization string is processed, any characters not in this special set are passed through to the modem, unmodified. Using these special characters, modem initialization strings that perform many steps can be easily constructed. For example:

    ^~~~ATZ

would force a hangup of the modem with DTR (^), delay 3 seconds (~~~) and then command the modem to reset to its saved state (ATZ, supported by most modems).

To accept incoming calls, your modem need not be programmed for auto-answer. The modem can be set to "not auto answer" (ATS0=0). The modem will emit "RING" statements when an incoming call is detected and modem will detect the "RING" and provide the answer string (default is "ATA") to force the modem to answer. This has the added advantage that your system won't answer the phone unless it is powered up and the modem program is ready for the incoming call. We recommend operating your modem in this mode.

We also recommend you default your serial ports to 8 bits, no-parity, and 1-stop bit for communication with other QNX systems.

Caller-ID and callback

If the -I option is specified modem will enforce caller-id authentication. Before being presented with a login prompt, modem will prompt you for a callback id. You will enter a name which modem will lookup in the callback file specified by the -I option. If it finds a match it will hangup, and callback the number associated with the name. For the person dialing in from a QNX system, they will typically be in qtalk and should type ATA to answer the phone when it rings. They will then connect to the remote modem utility which will immediately exec() into login as it would have if callback was not specified.

If you have a modem which supports caller-id and you have subscribed to this service with your telecom provider then modem will detect the special modem message "nmbr = number" and lookup the number on the callback file. If it finds a match, modem will not challenge you for a callback name but will exec() directly into login. Callback files consist of a number of one-line callback entries, each of which is in the format

A typical callback file follows:

tom:		atdt 8385866
dick:		atdt 7398837
harry:		atdt1 7059420088

The symbolic name is terminated with a colon. The number to dial consists of two parts. The first part is the command necessary to cause your modem to dial. The second part is the part which is matched against the caller id sent by the telecom company. Note that caller-id strings do not have the leading 1 required to make a long distance call. That is why in the above example the 1 is included as part of the modem dial command. The same would be true if a 9 was required to dial out.

If a call fails caller-id authentication, the number is logged to a file with the same path as specified by the -I option with a ".bad" concatenated to the end. For example if modem was run with a -I /etc/config/callback option, then

/etc/config/callback
would be the callback file
/etc/config/callback.bad
would be the failed callback attempt logfile

This logfile can be used to determine the correct number to use when caller-id is enabled on a line, as well as for determining the identity of unauthorized callers.

Automatic login on callback

When dialing out, the -U option can be used to automatically log in. After a successful connect, if -U is specified modem will wait for a "login:", "password:" and "$" or "#" issuing the appropriate user, pass and cmd specified on the command line.

Fax calls

Modem will detect a fax call and by default invoke the program /bin/fax to process it. This can be changed by using the -f option. Note that although modem can detect a fax call it has no code to receive a fax itself. The program /bin/fax is a suggested name and is not shipped with the operating system.

PPP calls

Modem will detect a TCP/IP PPP call if this option is set and start the specified ppp daemon. This will introduce a 2 second delay in the answering of all calls as modem waits for a potential ppp connect. If you use this option you should make sure PPP enforces one of the authorization protocols.

Log File

The modem utility will log connect messages to the file /etc/acclog, provided the file exists. For details, see the QNX Installation & Configuration.

Examples:


Note: Note that normally you would start each of these commands via the tinit utility, as opposed to directly from the command line. See "Connecting Character Devices" in QNX Installation & Configuration.

Handle calls on a 57600 baud modem that supports a locked baud rate and hardware flow control between itself and the computer:

    modem -g /etc/modem_msg -b 57600 -L

Handle calls on a 57600 baud modem (as above), but print diagnostic information to console 9 for troubleshooting:

    modem -b 57600 -L -D /dev/con9

Handle calls on an ancient 1890's brass-and-magnet 2400 baud formerly-state-of-the-art-but-now-a-museum-piece modem ensconced in the manufacturer's original equipment giltwood curio cabinet:

    modem -l -b 2400

Files:

/etc/acclog
(accounting records are appended to this file)
callback_file
A file of authorized users, a callback command and their caller-id or callback numbers can be specified using the -I option. See the section "Caller ID and callback".
callback_file.bad
When -I is used, a logfile of failed callback or caller-id authorization attempts will be maintained. The name of this file is the name of the callback file with a .bad suffix.

See also:

login, qcp, qtalk, tinit


[Previous] [Contents] [Next]