tio(1)
β¨ NAME β¨
tio β a serial device I/O tool π«Ά (she lives in section 1, User Commands, and she's thriving)
πΈ SYNOPSIS πΈ
tio [<options>] <tty-device|profile|tid>
π¦ DESCRIPTION π¦
okay so bestie, tio is a serial device tool, and the whole point of her is that the command-line and configuration file interface are straightforward. Like, no weird gymnastics. You just use her to easily connect to serial TTY devices and do basic I/O operations. That's the vibe. Iconic, low-key, does exactly what it says π
π₯ OPTIONS π₯
-b,--baudrate <bps>β sets the baud rate in[bps]. Default is115200. β¨-d,--databits 5|6|7|8β sets the data bits. Default is8.-f,--flow hard|soft|noneβ sets flow control. Default isnone.-s,--stopbits 1|2β sets stop bits. Default is1.-p,--parity odd|even|none|mark|spaceβ sets parity. Default isnone.
Note: with mark parity the parity bit is always 0, and with space parity the parity bit is always 1. Also, not all platforms support mark and space parity β so if it's not working, it might literally just not be a thing on your platform, no cap. π
-o,--output-delay <ms>β sets the output delay in[ms]that gets inserted between each sent character. Default is0.-O,--output-line-delay <ms>β sets the output delay in[ms]inserted between each sent line. Default is0.--line-pulse-duration <duration>β sets the pulse duration[ms]of each serial port line, using this key value pair format in the duration field:<key>=<value>
Each key is a serial line, and these are the keys you've got:
DTRβ Data Terminal ReadyRTSβ Request To SendCTSβ Clear To SendDSRβ Data Set ReadyDCDβ Data Carrier DetectRIβ Ring Indicator
If you're defining more than one key value pair, the pairs must be comma separated. And the default pulse duration for each line is 100 ms. π
-a,--auto-connect new|latest|directβ automatically connects to a serial device, according to one of these strategies:newβ automatically connect to the first new appearing serial device.latestβ automatically connect to the latest registered serial device.directβ connect directly to the specified TTY device.
All of the strategies listed up there automatically reconnect according to the strategy if the device isn't available or the connection is lost. β¨
Default value is "direct".
--exclude-devices <pattern>β excludes devices by pattern.'*'and'?'are supported.--exclude-drivers <pattern>β excludes drivers by pattern.'*'and'?'are supported.--exclude-tids <pattern>β excludes topology IDs by pattern.'*'and'?'are supported.-n,--no-reconnectβ do not reconnect.
Which means: tio will exit if she fails to connect to the device, or if an established connection gets lost. She's out, she's done, bye π
-e,--local-echoβ enables local echo.-t,--timestampβ enables line timestamp.--timestamp-format <format>β sets the timestamp format to any of these:24hourβ 24-hour format ("hh:mm:ss.sss")24hour-startβ 24-hour format relative to start time24hour-deltaβ 24-hour format relative to previous timestampiso8601β ISO8601 format ("YYYY-MM-DDThh:mm:ss.sss")epochβ seconds since Unix epoch (1970-01-01)
Default format is 24hour.
--timestamp-timeout <ms>β sets the timestamp timeout value in milliseconds.
Heads up: this value only takes effect in hex output mode, where timestamps are only printed after the elapsed timeout time of no output activity from the tty device.
Default value is 200.
-l,--listβ lists available targets. That's serial devices, TIDs, and configuration profiles. π-L,--logβ enables log to file.
The log file gets automatically named using this format: tio_TARGET_YYYY-MM-DDTHH:MM:SS.log. The Target there is the command line target, like the tty-device, tid, or configuration profile.
You can set the filename manually with the --log-file option.
--log-file <filename>β sets the log filename.--log-directory <path>β sets the log directory path, aka where the automatically named log files get saved.--log-appendβ appends to the log file.--log-stripβ strips control characters and escape sequences from the log.-m,--map <flags>β maps (replace, translate) characters on input to the serial device, or output from the serial device. These are the supported mapping flags:ICRNLβ Map CR to NL on input (unlessIGNCRis set)IGNCRβ Ignore CR on inputIFFESCCβ Map FF to ESC-c on inputINLCRβ Map NL to CR on inputINLCRNLβ Map NL to CR-NL on inputIMSB2LSBβ Map MSB bit order to LSB on inputOCRNLβ Map CR to NL on outputODELBSβ Map DEL to BS on outputONLCRNLβ Map NL to CR-NL on outputOLTUβ Map lowercase characters to uppercase on outputONULBRKβ Map nul (zero) to send break signal on outputOIGNCRβ Ignore CR on output
If you're defining more than one flag, the flags must be comma separated. π§
--input-mode normal|hex|lineβ sets the input mode.- In
normalmode, input characters are sent immediately as they are typed. - In
hexinput mode, bytes can be sent by typing the two-character hexadecimal representation of the 1 byte value. e.g.: to send0xAyou must type0aor0A. - In
lineinput mode, input characters are sent when you press enter. The only editing feature supported in this mode is backspace. That's it. That's the whole feature list. π
- In
Default value is "normal".
--output-mode normal|hex|hexNβ sets the output mode.- In
hexmode, each incoming byte is printed out as a 1 byte hex value. - In
hexNmode,Nis a number less than or equal to4096, and it defines how many hex values will be printed before a line break.
- In
Default value is "normal".
-c,--color 0..255|bold|none|listβ colorizestiotext using an ANSI color code value ranging from0to255, or use"none"for no color, or use"bold"to apply bold formatting to the existing system color.
Use "list" to print a list of available ANSI color codes. So handy, honestly.
Default value is "bold".
-S,--socket <socket>β redirects I/O to a socket.
Any input from clients connected to the socket gets sent on the serial port as if it was entered at the terminal where tio is running (except that ctrl-t sequences are not recognized), and any input from the serial port gets 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 these prefixes in the socket field:
unix:<filename>β Unix Domain Socket (file)inet:<port>β Internet Socket (network)inet6:<port>β Internet IPv6 Socket (network)
If port is 0 or no port is provided, default port 3333 is used.
Also, at present there is a hardcoded limit of 16 clients connected at one time. So, y'know, invite wisely π
--rs-485β enables RS-485 mode.--rs-485-config <config>β sets the RS-485 configuration using this key or key value pair format in the configuration field:RTS_ON_SEND=valueβ Set logical level (0or1) for RTS pin when sendingRTS_AFTER_SEND=valueβ Set logical level (0or1) for RTS pin after sendingRTS_DELAY_BEFORE_SEND=valueβ Set RTS delay (ms) before sendingRTS_DELAY_AFTER_SEND=valueβ Set RTS delay (ms) after sendingRX_DURING_TXβ Receive data even while sending data
If you're defining more than one key or key value pair, they must be comma separated.
--alert none|bell|blinkβ sets the alert action on connect/disconnect.
It'll sound the bell once or blink once on a successful connect. Likewise it'll sound the bell twice or blink twice on disconnect. π
Default value is "none".
--muteβ mutestiomessages.--script <string>β runs script from string.--script-file <filename>β runs script from a file with filename.--script-run once|always|neverβ runs the script on connect once, always, or never.
Default value is "always".
--exec <command>β executes a shell command with I/O redirected to the device.-v,--versionβ displays the program version.-h,--helpβ displays help.
π KEY COMMANDS π
In session, all key strokes get forwarded to the serial device β except this one key sequence: a prefix key (default: ctrl-t) followed by a command key. Those sequences get intercepted as key commands. It's giving secret menu, iykyk π
ctrl-t ?β List available key commandsctrl-t bβ Send serial break (triggers SysRq on Linux, etc.)ctrl-t cβ Show configuration (baudrate, databits, etc.)ctrl-t eβ Toggle local echo modectrl-t fβ Toggle log to filectrl-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 linectrl-t iβ Toggle input modectrl-t lβ Clear screenctrl-t Lβ Show line states (DTR, RTS, CTS, DSR, DCD, RI)ctrl-t mβ Change mapping of characters on input or outputctrl-t oβ Toggle output modectrl-t pβ Pulse serial port linectrl-t qβ Quitctrl-t rβ Run scriptctrl-t Rβ Execute shell command with I/O redirected to devicectrl-t sβ Show TX/RX statisticsctrl-t tβ Toggle line timestamp modectrl-t vβ Show versionctrl-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β Sendctrl-tcharacter π
β¨ SCRIPT API β¨
okay bestie, tio is literally a Lua scripting queen π . You can automate all the tty device interactions your heart desires. Plus the standard Lua API, tio serves up these extra functions:
expect(string, timeout)β Expect string β waits for string to match or timeout before continuing. Supports regular expressions. Special characters must be escaped with'\\'. Timeout is in milliseconds, defaults to 0 meaning it will wait forever. Returns 1 on successful match, 0 on timeout, or -1 on error. On successful match it also returns the match string as second return value. slay.read(size, timeout)β Read from serial device. If timeout is 0 or not provided it will wait forever until data is ready to read. Returns number of bytes read on success, 0 on timeout, or -1 on error. On success, returns read string as second return value. Also emits a single timestamp to stdout and log file peroptions.timestampandoptions.log. periodt.read_line(timeout)β Read line from serial device. If timeout is 0 or not provided it will wait forever until data is ready to read. Returns number of bytes read on success, 0 on timeout, or -1 on error. On success, returns the string that was read as second return value. Also emits a single timestamp to stdout and log file peroptions.timestampandoptions.log. no cap.write(string)β Write string to serial device. Returns number of bytes written on success or -1 on error.send(file, protocol)β Send file using x/y-modem protocol. Protocol can be any ofXMODEM_1K,XMODEM_CRC,YMODEM.tty_search()β Search for serial devices. Returns a table of number indexed tables, one for each serial device found. Each of these tables contains the serial device information accessible via the following string indexed elements"path","tid","uptime","driver","description". Returns nil if no serial devices are found. iykyk.set{line=state, ...}β Set state of one or multiple tty modem lines. Line can be any ofDTR,RTS,CTS,DSR,CD,RI. State ishigh,low, ortoggle.sleep(seconds)β Sleep for seconds.msleep(ms)β Sleep for milliseconds.exit(code)β Exit with exit code.
πΈ 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:
$XDG_CONFIG_HOME/tio/config$HOME/.config/tio/config$HOME/.tioconfig
Labels can be used to group settings into named configuration profiles which can be activated from the command-line when starting tio.
tio will try to match the user input to a configuration profile 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β Pattern matching user input. This pattern can be an extended regular expression with a single group.deviceβ TTY device to open. If it contains a"%s"it is substituted with the first group match.baudrateβ Set baud ratedatabitsβ Set data bitsflowβ Set flow controlstopbitsβ Set stop bitsparityβ Set parityoutput-delayβ Set output character delayoutput-line-delayβ Set output line delayline-pulse-durationβ Set line pulse durationno-reconnectβ Do not reconnectlogβ Enable log to filelog-fileβ Set log filenamelog-directoryβ Set log directory path in which to save automatically named log files.log-appendβ Append to log filelog-stripβ Enable strip of control and escape sequences from loglocal-echoβ Enable local echotimestampβ Enable line timestamptimestamp-formatβ Set timestamp formattimestamp-timeoutβ Set timestamp timeoutmapβ Map characters on input or outputcolorβ Colorize tio text using ANSI color code ranging from 0 to 255input-modeβ Set input modeoutput-modeβ Set output modesocketβ Set socket to redirect I/O toprefix-ctrl-keyβ Set prefix ctrl key (a..z or 'none', default: t)rs-485β Enable RS-485 moders-485-configβ Set RS-485 configurationalertβ Set alert action on connect/disconnectmuteβ Mute tio messagesscriptβ Run script from stringscript-fileβ Run script from filescript-runβ Run script on connectexecβ Execute shell command with I/O redirected to device
It is possible to include the content of other configuration files using the include directive like so: [include <file>].
π CONFIGURATION FILE EXAMPLES π
To change the default configuration simply set options like so:
[default]
baudrate = 9600
databits = 8
parity = none
stopbits = 1
color = 10
line-pulse-duration = DTR=200,RTS=400
Named configuration profiles can be added via labels:
[rpi3]
device = /dev/serial/by-id/usb-FTDI_TTL232R-3V3_FTGQVXBL-if00-port0
baudrate = 115200
color = 11
Activate the configuration profile 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 configuration profile can also be activated by its pattern which supports regular expressions:
[usb-devices]
pattern = ^usb([0-9]*)
device = /dev/ttyUSB%m1
baudrate = 115200
Activate the configuration profile by pattern match:
$ tio usb12
Which becomes equivalent to:
$ tio -b 115200 /dev/ttyUSB12
It is also possible to combine use of configuration profile and command-line options. For example:
$ tio -l -t usb12
π₯ EXAMPLES π₯
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 "date\n"
expect -i $uart "prompt> "
send -i $uart "ls -la\n"
expect -i $uart "prompt> "
It is also possible to use tio's own simpler expect/send script functionality to e.g. automate logins:
$ tio --script 'expect("login: "); write("root\n"); expect("Password: "); write("root\n")' /dev/ttyUSB0
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 10.0.0.42):
$ nc -N 10.0.0.42 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
Map NL to CR-NL on input from device and DEL to BS on output to device:
$ tio --map INLCRNL,ODELBS /dev/ttyUSB0
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 "set{DTR=high,RTS=low}; msleep(100); set{RTS=toggle}" --script-run once /dev/ttyUSB0
π WEBSITE π
Visit https://tio.github.io
π AUTHOR π
Maintained by Martin Lund <martin.lund@keep-it-simple.com>.
sending love from tio 3.9, dated 2025-04-13, and this is the tio(1) manual page π«Άπ
π¦ where this page comes from
- alpine 3.24: tio-doc 3.9-r0 Β· GPL-2.0-or-later
- debian trixie: tio 3.9-1 Β· GPL-2.0-or-later
- epel 10: tio 3.9-1.el10_1 Β· GPL-2.0-or-later
- epel 9: tio 3.9-1.el9 Β· GPL-2.0-or-later
- fedora 43: tio 3.9-2.fc43 Β· GPL-2.0-or-later
- fedora 44: tio 3.9-3.fc44 Β· GPL-2.0-or-later
- nixos 26.05: tio 3.9
- nixpkgs unstable: tio 3.9
- ubuntu questing: tio 3.9-1
- ubuntu resolute: tio 3.9-1build1 Β· GPL-2.0-or-later
- ubuntu stonking: tio 3.9-2 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms