MODEMU2k(1)

NAME
modemu2k - dialup TCP connecting

SYNOPSIS
modemu2k [-c comm_prog] [-d pty_master] [-e atcmds] [-l port] [-h] [-s] [-V] [-v] [-w]

DESCRIPTION
Modemu2k is a TELNET client with a modem-like user interface. It can redirect its I/O via a pty(4) so that a comm program can handle the pty as a tty with a real modem.

Modemu2k has two major modes: a command mode and online mode. Invoked with at least one option (e.g. -c, -d, -e, or -l), modemu2k starts in command mode, waiting for AT commands input. Entering a D or O command will put into the online mode, in which modemu2k communicate with a remote host. Connection closing or a escape command input returns to the command mode.

Invoked with no arguments, modemu2k prints the same usage information as --help and exits without entering command mode. Use -e to reach standalone command mode on stdin/stdout (for example, modemu2k -e AT).

OPTIONS

-c comm_prog
    Invoke a comm program comm_prog. Modemu2k invokes it by passing /bin/sh an option `-c comm_prog'. Therefore, any sh(1) commands can be specified. The string comm_prog can include a `%s', which will be replaced with the device name of the slave device after removal of the initial "/dev/".
    Example:
        modemu2k -c "xc -l %s"

-d pty_master
    Open a file pty_master and talk through it. A named pipe can be a pty_master as well as a pty master device because modemu2k doesn't ioctl a pty_master.

-e atcmds
    Execute a series of AT commands atcmds initially. Atcmds must have an `AT' or `at' prefix. D and O commands in atcmds are ignored.

-l port
    Listen for a single incoming TCP connection on port and use the accepted socket as the TTY. The connecting peer drives modemu2k with AT commands. Intended primarily for use as a virtual modem backend for emulators such as dosemu2. Dual-stack IPv4/IPv6.

-h  Print a usage summary.

-v  Enable verbose narration to stderr. Installs a log callback and opens the runtime verbose mask (AT%V3, i.e. VERB_MISC | VERB_TELOPT ) so the existing instrumentation sites (telnet IAC negotiation, socket and pty events, ATH/ATZ disconnect) actually print. Useful for diagnosing connection or transfer issues. With -c (comm-program mode), modemu2k refuses to run when stderr is a terminal, because verbose output would corrupt the comm program's display. Redirect stderr first:

    modemu2k -v -c "minicom ..." 2>/tmp/m2k.log

-V  Print the modemu2k version and exit.

-s  Print the last two letters of a device name. The device is a pty master device which modemu2k talks through. Therefore, when modemu2k prints `p8', comm program must open /dev/ttyp8.

Note: The -c, -d, -l, and -s options are mutually exclusive. Specifying more than one is rejected with an error message; the former silent "last one wins" behavior was removed.

COMMAND MODE
Command mode expects lines in the following format:

    [garbage]at[sp][cmd[sp]]...cr

where at is an `AT' or `at', sp is spaces, cr is a carriage return character (register S3), garbage is a string includes no at. If a `#' prefixes a line, the line is ignored. Available cmds are listed below. They are all case in-sensitive except for some literally used arguments. A (*) marks default settings.

Dstr
    Dialing command. Open a connection to host. If port is specified, modemu2k attempts to connect with the port instead of the default TELNET port, and doesn't initiate TELNET option negotiation. The following formats are available for str:

    host [port]
        Host is an Internet address in numbers-and-dots notation. Optional port is a port number.

    "host [port]["]
        Host is an Internet address or host name. Optional port is a port number or service name. The closing double quote can be omitted if no command follows.

    Str can be prefixed with `T', `P', `digitW' and/or `digit,'. The prefixes are simply ignored.
    Example:
        ATDT0W127.0.0.1
        ATDP"foo.bar.jp daytime

E1  No operation.

F1  No operation.

H[0]
    Close the current TELNET session.

In  Print various information.

    I4  Current settings

    I5  `&W'ed settings

    I6  TELNET option states

    I7  Modemu2k version

O[0]
    Return to online mode.

P   No operation.

Q[0]
    No operation.

T   No operation.

V1  No operation.

X[0]
    No operation.

Sn=m
    Set S-register Sn to m. A number from 0-255 is allowed for m.

Sn? Print an S-register Sn's value.

Z   Close the current TELNET session, and restore `&W'ed settings.

&W  Save current settings. The saved settings will be lost with the end of the process because they are not stored into NV-RAM nor files.

%Bn=m
    Control TELNET binary option. Valid values for n are:

        0   Control the local (modemu2k) option

        1   Control the remote (TELNET server) option

    Valid values for m are:

        0   Request non-binary transmission mode (*)

        1   Request binary transmission (8bit through) mode

        above+2
            Disconnect if the request is refused

    Example:

        AT%B1=1
            Requesting binary mode in remote-to-modemu2k direction

        AT%B0=3%B1=3
            Requesting binary mode in both remote-to-modemu2k and modemu2k-to-remote direction. No use connecting in non-binary mode (using file xfer protocol or something)

%Dn Control dial-canceling.

    %D0 A keypress cancels dialing (*)

    %D1 Keypresses don't cancel dialing

%Ln Control line-mode.

    %L0 Request character-at-a-time mode (*)

    %L1 Request line-at-a-time mode (old line-mode). Input characters are buffered and not sent until a CR character is entered.

%Q  Quit modemu2k. Two consecutive Ctrl-C keystrokes from command mode are equivalent; a single Ctrl-C arms the trigger and clears any partial input line, but does not exit unless followed by another Ctrl-C with no intervening keystroke. Any other input byte disarms the trigger. In online mode Ctrl-C is treated as ordinary data and forwarded to the remote.

%Rn Control raw-mode.

    %R0 Normal mode (*)

    %R1 Raw mode. Modemu2k transmits every octet as received. Applied to both remote-to-modemu2k and modemu2k-to-remote direction. Override %B and %L settings.

%Tstr
    Control TELNET terminal-type option.

    %T0 Refuse terminal-type option

    %T1 Same as %T="$TERM" (TERM environment value is used) (*)

    %T="term["]
        Send term as the terminal-type if remote requests. The closing double quote can be omitted if no command follows.

%Vn Control verbose level. %V0 (*) is the quietest, and adding following values to n lets modemu2k print more information to stderr.

    +1  Print misc info to make up for less descriptive ATX0 indication

    +2  Print TELNET option negotiation

ONLINE MODE
Modemu2k recognizes only the following command when in online mode.

wait +++ wait
    Escape to command mode. The `+++' must be input within the guard time. Wait is a period of time longer than the guard time without hitting any key. See also S2 and S12 register descriptions.

S REGISTERS
Only meaningful registers are listed here. Values in braces are default ones.

S2  Escape character code. (43 = `+')

S3  Carriage return character code. (13)

S4  Line feed character code. (10)

S5  Backspace character code. (8)

S7  Connection attempt time-out (in seconds). (20)

S12 Escape sequence guard time in 50ths of a second. (50)

ENVIRONMENT VARIABLES

MODEMU2k
    Initially evaluated as AT commands (before -e option argument is evaluated). Must have an `AT' or `at' prefix.

TERM
    See %T1 command description.

MAINTAINER
Andy Alt

SEE ALSO
telnet(1), Your favorite modem's manual