Your company here, and a link to your site. Click to find out more.

tio - Man Page

a serial device I/O tool


tio [<options>] <tty-device|sub-config>


tio is a serial device tool which features a straightforward command-line and configuration file interface to easily connect to serial TTY devices for basic I/O operations.


-b,  --baudrate <bps>

Set baud rate [bps] (default: 115200).

-d,  --databits 5|6|7|8

Set data bits (default: 8).

-f,  --flow hard|soft|none

Set flow control (default: none).

-s,  --stopbits 1|2

Set stop bits (default: 1).

-p,  --parity odd|even|none|mark|space

Set parity (default: none).

Note: With mark parity the parity bit is always 0. With space parity the parity bit is always 1. Not all platforms support mark and space parity.

-o,  --output-delay <ms>

Set output delay [ms] inserted between each sent character (default: 0).

-O,  --output-line-delay <ms>

Set output delay [ms] inserted between each sent line (default: 0).

   --line-pulse-duration <duration>

Set the pulse duration [ms] of each serial port line using the following key value pair format in the duration field: <key>=<value>

Each key represents a serial line. The following keys are available:


Data Terminal Ready


Request To Send


Clear To Send


Data Set Ready


Data Carrier Detect


Ring Indicator

If defining more than one key value pair, the pairs must be comma separated.

The default pulse duration for each line is 100 ms.

-n,  --no-autoconnect

Disable automatic connect.

By default tio automatically connects to the provided device if present. If the device is not present, it will wait for it to appear and then connect. If the connection is lost (eg. device disconnects), it will wait for the device to reappear and then reconnect.

However, if the --no-autoconnect option is provided, tio will exit if the device is not present or an established connection is lost.

-e,  --local-echo

Enable local echo.

-t,  --timestamp

Enable line timestamp.

   --timestamp-format <format>

Set timestamp format to any of the following timestamp formats:


24-hour format ("hh:mm:ss.sss")


24-hour format relative to start time


24-hour format relative to previous timestamp


ISO8601 format ("YYYY-MM-DDThh:mm:ss.sss")

Default format is 24hour

-L,  --list-devices

List available serial devices by ID.

-l,  --log

Enable log to file.

The log file will be automatically named using the following format tio_DEVICE_YYYY-MM-DDTHH:MM:SS.log.

The filename can be manually set using the --log-file option.

   --log-file <filename>

Set log filename.

   --log-directory <path>

Set log directory path in which to save automatically named log files.


Append to log file.


Strip control characters and escape sequences from log.

-m,  --map <flags>

Map (replace, translate) characters on input or output. The following mapping flags are supported:


Map CR to NL on input (unless IGNCR is set)


Ignore CR on input


Map FF to ESC-c on input


Map NL to CR on input


Map NL to CR-NL on input


Map CR to NL on output


Map DEL to BS on output


Map NL to CR-NL on output


Map lowercase characters to uppercase on output


Map nul (zero) to send break signal on output


Map MSB bit order to LSB on output

If defining more than one flag, the flags must be comma separated.

   --input-mode normal|hex

Set input mode. In hex input mode bytes can be sent by typing the two-character hexadecimal representation of the 1 byte value, e.g.: to send 0xA you must type 0a or 0A.

Default value is "normal".

   --output-mode normal|hex

Set output mode. In hex mode each incoming byte is printed out as a 1 byte hex value.

Default value is "normal".

-c,  --color 0..255|bold|none|list

Colorize tio text using ANSI color code value ranging from 0 to 255 or use "none" for no color or use "bold" to apply bold formatting to existing system color.

Use "list" to print a list of available ANSI color codes.

Default value is "bold".

-S,  --socket <socket>

Redirect I/O to socket.

Any input from clients connected to the socket is sent on the serial port as if entered at the terminal where tio is running (except that ctrl-t sequences are not recognized), and any input from the serial port is multiplexed to the terminal and all connected clients.

Sockets remain open while the serial port is disconnected, and writes will block.

Various socket types are supported using the following prefixes in the socket field:


Unix Domain Socket (file)


Internet Socket (network)


Internet IPv6 Socket (network)

If port is 0 or no port is provided default port 3333 is used.

At present there is a hardcoded limit of 16 clients connected at one time.


Enable RS-485 mode.

   --rs-485-config <config>

Set the RS-485 configuration using the following key or key value pair format in the configuration field:


Set logical level (0 or 1) for RTS pin when sending


Set logical level (0 or 1) for RTS pin after sending


Set RTS delay (ms) before sending


Set RTS delay (ms) after sending


Receive data even while sending data

If defining more than one key or key value pair, they must be comma separated.

--alert none|bell|blink

Set alert action on connect/disconnect.

It will sound the bell once or blink once on successful connect. Likewise it will sound the bell twice or blink twice on disconnect.

Default value is "none".

--script <string>

Run script from string.

--script-file <filename>

Run script from file with filename.

--script-run once|always|never

Run script on connect once, always, or never.

Default value is "always".

-v,  --version

Display program version.

-h,  --help

Display help.


In session, all key strokes are forwarded to the serial device except the following key sequence: a prefix key (default: ctrl-t) followed by a command key. These sequences are intercepted as tio commands:
ctrl-t ?

List available key commands

ctrl-t b

Send serial break (triggers SysRq on Linux, etc.)

ctrl-t c

Show configuration (baudrate, databits, etc.)

ctrl-t e

Toggle local echo mode

ctrl-t f

Toggle log to file

ctrl-t F

Flush data I/O buffers (discard data written but not transmitted and data received but not read)

ctrl-t g

Toggle serial port line

ctrl-t i

Toggle input mode

ctrl-t l

Clear screen

ctrl-t L

Show line states (DTR, RTS, CTS, DSR, DCD, RI)

ctrl-t m

Toggle MSB to LSB bit order

ctrl-t o

Toggle output mode

ctrl-t p

Pulse serial port line

ctrl-t q


ctrl-t r

Run script

ctrl-t s

Show TX/RX statistics

ctrl-t t

Toggle line timestamp mode

ctrl-t U

Toggle conversion to uppercase on output

ctrl-t v

Show version

ctrl-t x

Send file using the XMODEM-1K or XMODEM-CRC protocol (prompts for file name and protocol)

ctrl-t y

Send file using the YMODEM protocol (prompts for file name)

ctrl-t ctrl-t

Send ctrl-t character

Script API

Tio suppots Lua scripting to easily automate interaction with the tty device.

In addition to the Lua API tio makes the following functions available:

expect(string, timeout)

Expect string - waits for string to match or timeout before continueing. Supports regular expressions. Special characters must be escaped with '\\'. Timeout is in milliseconds, defaults to 0 meaning it will wait forever.


Send string.

modem_send(file, protocol)

Send file using x/y-modem protocol.

Protocol can be any of XMODEM_1K, XMODEM_CRC, YMODEM.


Exit with exit code.


Set tty line high.


Set tty line low.


Toggle the tty line.


Sleep for seconds.


Sleep for miliseconds.


Set tty line state configuration to high.


Set tty line state configuration to low.


Apply tty line state configuration. Using the line state configuration API instead of high()/low() will help to make the lines physically switch as simultaneously as possible. This may solve timing issues on some platforms.

Note: Line can be any of DTR, RTS, CTS, DSR, CD, RI

Configuration File

Options can be set via configuration file using the INI format. tio uses the configuration file first found in the following locations in the order listed:




Labels can be used to group settings into named sub-configurations which can be activated from the command-line when starting tio.

tio will try to match the user input to a sub-configuration by name or by pattern to get the TTY device and other options.

Options without any label change the default options.

Any options set via command-line will override options set in the configuration file.

The following configuration file options are available:


Pattern matching user input. This pattern can be an extended regular expression with a single group.


TTY device to open. If it contains a "%s" it is substituted with the first group match.


Set baud rate


Set data bits


Set flow control


Set stop bits


Set parity


Set output character delay


Set output line delay


Set line pulse duration


Disable automatic connect


Enable log to file


Set log filename


Set log directory path in which to save automatically named log files.


Append to log file


Enable strip of control and escape sequences from log


Enable local echo


Enable line timestamp


Set timestamp format


Map characters on input or output


Colorize tio text using ANSI color code ranging from 0 to 255


Set input mode.


Set output mode.


Set socket to redirect I/O to


Set prefix ctrl key (a..z or 'none', default: t)


Enable RS-485 mode


Set RS-485 configuration


Set alert action on connect/disconnect


Run script from string


Run script from file


Run script on connect.

Configuration File Examples

To change the default configuration simply set options like so:
# Defaults
baudrate = 9600
databits = 8
parity = none
stopbits = 1
color = 10
line-pulse-duration = DTR=200,RTS=400
Named sub-configurations can be added via labels:
device = /dev/serial/by-id/usb-FTDI_TTL232R-3V3_FTGQVXBL-if00-port0
baudrate = 115200
color = 11
Activate the sub-configuration by name:

$ tio rpi3

Which is equivalent to:

$ tio -b 115200 -c 11 /dev/serial/by-id/usb-FTDI_TTL232R-3V3_FTGQVXBL-if00-port0

A sub-configuration can also be activated by its pattern which supports regular expressions:
[usb device]
pattern = usb([0-9]*)
device = /dev/ttyUSB%s
baudrate = 115200
Activate the sub-configuration by pattern match:

$ tio usb12

Which is equivalent to:

$ tio -b 115200 /dev/ttyUSB12

It is also possible to combine use of sub-configuration and command-line options. For example:

$ tio -l -t usb12


Typical use is without options:

$ tio /dev/ttyUSB0

Which corresponds to the commonly used default options:

$ tio -b 115200 -d 8 -f none -s 1 -p none /dev/ttyUSB0

It is recommended to connect serial TTY devices by ID:

$ tio /dev/serial/by-id/usb-FTDI_TTL232R-3V3_FTGQVXBL-if00-port0

Using serial devices by ID ensures that tio automatically reconnects to the correct serial device if it is disconnected and then reconnected.

Redirect serial device I/O to Unix file socket for scripting:

$ tio -S unix:/tmp/tio-socket0 /dev/ttyUSB0

Then, to issue a command via the file socket simply do:

$ echo "ls -la" | nc -UN /tmp/tio-socket0 > /dev/null

Or use the expect command to script an interaction:
#!/usr/bin/expect -f

set timeout -1
log_user 0

spawn nc -UN /tmp/tio-socket0
set uart $spawn_id

send -i $uart "date0
expect -i $uart "prompt> "
send -i $uart "ls -la0
expect -i $uart "prompt> "
Redirect device I/O to network file socket for remote TTY sharing:

$ tio --socket inet:4444 /dev/ttyUSB0

Then, use netcat to connect to the shared TTY session over network (assuming tio is hosted on IP

$ nc -N 4444

Pipe command to the serial device:

$ echo "ls -la" | tio /dev/serial/by-id/usb-FTDI_TTL232R-3V3_FTGQVXBL-if00-port0

Pipe command to serial device and wait for line response within 1 second:

$ echo "*IDN?" | tio /dev/ttyACM0 --script "expect('\r\n', 1000)" --mute

Likewise, to pipe data from file to the serial device:

$ cat data.bin | tio /dev/serial/by-id/usb-FTDI_TTL232R-3V3_FTGQVXBL-if00-port0

Enable RS-485 mode:

$ tio --rs-485 --rs-485-config=RTS_ON_SEND=1,RX_DURING_TX /dev/ttyUSB0

Manipulate DTR and RTS lines upon first connect to reset connected microcontroller:

$ tio --script "high(DTR); low(RTS); msleep(100); toggle(DTR)" --script-run once /dev/ttyUSB0

Automatically log in to connected OS:

$ tio --script "expect('password:'); send('my_password\n')" /dev/ttyUSB0


Visit https://tio.github.io


Maintained by Martin Lund <martin.lund@keep-it-simple.com>.


2024-04-14 tio 2.8