tio(1) | User Commands | tio(1) |
tio - a serial device I/O tool
tio [<options>] <tty-device|profile|tid>
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.
Set baud rate [bps] (default: 115200).
Set data bits (default: 8).
Set flow control (default: none).
Set stop bits (default: 1).
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.
Set output delay [ms] inserted between each sent character (default: 0).
Set output delay [ms] inserted between each sent line (default: 0).
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:
If defining more than one key value pair, the pairs must be comma separated.
The default pulse duration for each line is 100 ms.
Automatically connect to serial device according to one of the following strategies:
All the listed strategies automatically reconnects according to strategy if device is not available or connection is lost.
Default value is "direct".
Exclude devices by pattern ('*' and '?' supported).
Exclude drivers by pattern ('*' and '?' supported).
Exclude topology IDs by pattern ('*' and '?' supported).
Do not reconnect.
This means that tio will exit if it fails to connect to device or an established connection is lost.
Enable local echo.
Enable line timestamp.
Set timestamp format to any of the following timestamp formats:
Default format is 24hour
Set timestamp timeout value in milliseconds.
This value only takes effect in hex output mode where timestamps are only printed after elapsed timeout time of no output activity from tty device.
Default value is 200.
List available targets (serial devices, TIDs, configuration profiles).
Enable log to file.
The log file will be automatically named using the following format tio_TARGET_YYYY-MM-DDTHH:MM:SS.log. Target being the command line target such as tty-device, tid, or configuration profile.
The filename can be manually set using the --log-file option.
Set log filename.
Set log directory path in which to save automatically named log files.
Append to log file.
Strip control characters and escape sequences from log.
Map (replace, translate) characters on input to the serial device or output from the serial device. The following mapping flags are supported:
If defining more than one flag, the flags must be comma separated.
Set input mode.
In normal mode input characters are sent immediately as they are typed.
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.
In line input mode input characters are sent when you press enter. The only editing feature supported in this mode is backspace.
Default value is "normal".
Set output mode.
In hex mode each incoming byte is printed out as a 1 byte hex value.
In hexN mode, N is a number less than or equal to 4096 which defines how many hex values will be printed before a line break.
Default value is "normal".
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".
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:
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.
Set the RS-485 configuration using the following key or key value pair format in the configuration field:
If defining more than one key or key value pair, they must be comma separated.
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".
Mute tio messages.
Run script from string.
Run script from file with filename.
Run script on connect once, always, or never.
Default value is "always".
Execute shell command with I/O redirected to device
Display program version.
Display help.
Tio suppots Lua scripting to easily automate interaction with the tty device.
In addition to the Lua API tio makes the following functions available:
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.
Returns number of bytes written on success or -1 on error.
Protocol can be any of XMODEM_1K, XMODEM_CRC, YMODEM.
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.
Returns number of bytes read on success, 0 on timeout, or -1 on error.
On success, returns read string as second return value.
Line can be any of DTR, RTS, CTS, DSR, CD, RI
State is high, low, or toggle.
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:
It is possible to include the content of other configuration files using the include directive like so: "[include <file>]".
[default] baudrate = 9600 databits = 8 parity = none stopbits = 1 color = 10 line-pulse-duration = DTR=200,RTS=400
[rpi3] device = /dev/serial/by-id/usb-FTDI_TTL232R-3V3_FTGQVXBL-if00-port0 baudrate = 115200 color = 11
$ tio rpi3
$ tio -b 115200 -c 11 /dev/serial/by-id/usb-FTDI_TTL232R-3V3_FTGQVXBL-if00-port0
[usb-devices] pattern = ^usb([0-9]*) device = /dev/ttyUSB%m1 baudrate = 115200
$ tio usb12
$ tio -b 115200 /dev/ttyUSB12
$ tio -l -t usb12
$ tio /dev/ttyUSB0
$ tio -b 115200 -d 8 -f none -s 1 -p none /dev/ttyUSB0
$ 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.
$ tio -S unix:/tmp/tio-socket0 /dev/ttyUSB0
$ echo "ls -la" | nc -UN /tmp/tio-socket0 > /dev/null
#!/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> "
$ tio --script 'expect("login: "); send("root\n"); expect("Password: "); send("root\n")' /dev/ttyUSB0
$ tio --socket inet:4444 /dev/ttyUSB0
$ nc -N 10.0.0.42 4444
$ echo "ls -la" | tio /dev/serial/by-id/usb-FTDI_TTL232R-3V3_FTGQVXBL-if00-port0
$ echo "*IDN?" | tio /dev/ttyACM0 --script "expect('\r\n', 1000)" --mute
$ cat data.bin | tio /dev/serial/by-id/usb-FTDI_TTL232R-3V3_FTGQVXBL-if00-port0
$ tio --rs-485 --rs-485-config=RTS_ON_SEND=1,RX_DURING_TX /dev/ttyUSB0
$ tio --script "set{DTR=high,RTS=low}; msleep(100); set{RTS=toggle}" --script-run once /dev/ttyUSB0
Visit https://tio.github.io
Maintained by Martin Lund <martin.lund@keep-it-simple.com>.
2024-08-31 | tio 3.7 |