connect
Opens a serial port and starts a background reader to let you send commands and read responses from consoles, radios, and microcontrollers. Supports presets for common devices.
Instructions
Open a serial port and start its background reader.
Defaults are 9600 baud, 8 data bits, no parity, 1 stop bit, no flow control
("9600 8N1"), CR line ending, which is what most console/craft ports expect.
Give preset (see list_presets) to load a device family's usual settings, and
override any field explicitly, e.g. "38400 with XON/XOFF" -> baud=38400,
xonxoff=True. Several ports can be open at once; each gets a name and later
tools default to the most recently used one. Nothing is specific to telecom
gear: any device on a serial port works, including IoT gateways, alarm and
control panels, UPS and PDU menus and lab instruments; choose terminal by
what the device prints.
Args:
port: System port name, e.g. "COM4" (Windows), "/dev/cu.usbserial-10"
(macOS), or "/dev/ttyUSB0" (Linux). Get exact names from
list_serial_ports.
preset: Device preset name such as "cisco-console", "juniper-craft",
"kenwood-cat", "icom-civ", "yaesu-rotator", "arduino", "nmea-gps".
name: Nickname for this connection ("rig", "rotator"). Defaults to the
port's short name. Use it in other tools' connection argument.
baud: Baud rate. Common values: 1200, 2400, 4800, 9600, 19200, 38400,
57600, 115200. Unknown? Use detect_baud first.
bytesize: Data bits: 5, 6, 7, or 8. Almost always 8.
parity: "N" none, "E" even, "O" odd. Almost always "N".
stopbits: 1, 1.5, or 2. Almost always 1.
rtscts: Hardware (RTS/CTS) flow control. Off unless the manual says so
and the cable carries those lines.
xonxoff: Software (XON/XOFF) flow control. Off by default. Never for
binary protocols (it swallows 0x11 / 0x13 bytes).
line_ending: Default line ending for send_text/query_text on this
connection: "CR" (most rigs, consoles), "LF" (Unix, Arduino), "CRLF",
or "NONE" (Kenwood-style CAT ending in ';').
prompt: Default prompt for read_until_prompt/query_text on this
connection, e.g. "# ", "> ", ";" (CAT replies). Say what the device
shows, with its trailing space.
prompt_regex: Treat prompt as a regular expression.
terminal: How to interpret what the device sends. "dumb" (default):
raw bytes, right for CAT, CI-V, rotators and most CLIs. "ansi":
strip colour/escape sequences and apply CR/backspace overwrites so
shells and coloured prompts read cleanly (the console presets use
it); prompts are also matched on the last line as displayed, so a
line redrawn with spaces and backspaces (Junos after ? or
Ctrl-U) still ends in its prompt. "vt100"/"xterm": additionally keep a real screen for
full-screen menus, BIOS/BMC consoles, vi/top; read it with the
screen tool, navigate with send_keys.
cols: Screen width for vt100/xterm (default 80).
rows: Screen height for vt100/xterm (default 24).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| baud | No | ||
| cols | No | ||
| name | No | ||
| port | Yes | ||
| rows | No | ||
| parity | No | ||
| preset | No | ||
| prompt | No | ||
| rtscts | No | ||
| xonxoff | No | ||
| bytesize | No | ||
| stopbits | No | ||
| terminal | No | ||
| line_ending | No | ||
| prompt_regex | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |