 |
|
| |
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.
- -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:
- DTR
- Data Terminal Ready
- RTS
- Request To Send
- CTS
- Clear To Send
- DSR
- Data Set Ready
- DCD
- Data Carrier Detect
- RI
- 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.
- -a, --auto-connect
new|latest|direct
-
Automatically connect to serial device according to one of the
following strategies:
- new
- Automatically connect to first new appearing serial device.
- latest
- Automatically connect to latest registered serial device.
- direct
- Connect directly to specified TTY device.
All the listed strategies automatically reconnects according to
strategy if device is not available or connection is lost.
Default value is "direct".
- --exclude-devices
<pattern>
-
Exclude devices by pattern ('*' and '?' supported).
-
--exclude-drivers <pattern>
-
Exclude drivers by pattern ('*' and '?' supported).
- --exclude-tids
<pattern>
-
Exclude topology IDs by pattern ('*' and '?' supported).
- -n,
--no-reconnect
-
Do not reconnect.
This means that tio will exit if it fails to connect to device
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:
- 24hour
- 24-hour format ("hh:mm:ss.sss")
- 24hour-start
- 24-hour format relative to start time
- 24hour-delta
- 24-hour format relative to previous timestamp
- iso8601
- ISO8601 format ("YYYY-MM-DDThh:mm:ss.sss")
- epoch
- Seconds since Unix epoch (1970-01-01)
Default format is 24hour
- --timestamp-timeout <ms>
-
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.
- -l, --list
-
List available targets (serial devices, TIDs, configuration
profiles).
- -L, --log
-
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.
- --log-file <filename>
-
Set log filename.
- --log-directory <path>
-
Set log directory path in which to save automatically named
log files.
- --log-append
-
Append to log file.
- --log-strip
-
Strip control characters and escape sequences from log.
- -m, --map
<flags>
-
Map (replace, translate) characters on input to the serial
device or output from the serial device. The following mapping flags are
supported:
- ICRNL
- Map CR to NL on input (unless IGNCR is set)
- IGNCR
- Ignore CR on input
- IFFESCC
- Map FF to ESC-c on input
- INLCR
- Map NL to CR on input
- INLCRNL
- Map NL to CR-NL on input
- IMSB2LSB
- Map MSB bit order to LSB on input
- OCRNL
- Map CR to NL on output
- ODELBS
- Map DEL to BS on output
- ONLCRNL
- Map NL to CR-NL on output
- OLTU
- Map lowercase characters to uppercase on output
- ONULBRK
- Map nul (zero) to send break signal on output
- OIGNCR
- Ignore CR on output
If defining more than one flag, the flags must be comma
separated.
- --input-mode
normal|hex|line
-
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".
- --output-mode
normal|hex|hexN
-
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".
- -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:<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.
At present there is a hardcoded limit of 16 clients connected at
one time.
- --rs-485
-
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:
- --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".
- --mute
-
Mute tio messages.
- --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".
- --exec <command>
-
Execute shell command with I/O redirected to device
- -v, --version
-
Display program version.
- -h, --help
-
Display help.
Tio suppots Lua scripting to easily automate interaction with the
tty device.
In addition to the standard Lua API tio makes the following
functions available:
- 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.
- 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 per options.timestamp
and options.log.
- 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 per
options.timestamp and options.log.
- 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 of XMODEM_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.
- set{line=state,
...}
- Set state of one or multiple tty modem lines.
Line can be any of DTR, RTS, CTS, DSR, CD, RI
State is high, low, or toggle.
- sleep(seconds)
- Sleep for seconds.
- msleep(ms)
- Sleep for milliseconds.
- exit(code)
- Exit with exit code.
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 rate
- databits
- Set data bits
- flow
- Set flow control
- stopbits
- Set stop bits
- parity
- Set parity
- output-delay
- Set output character delay
- output-line-delay
- Set output line delay
- line-pulse-duration
- Set line pulse duration
- no-reconnect
- Do not reconnect
- log
- Enable log to file
- log-file
- Set log filename
- log-directory
- Set log directory path in which to save automatically named log
files.
- log-append
- Append to log file
- log-strip
- Enable strip of control and escape sequences from log
- local-echo
- Enable local echo
- timestamp
- Enable line timestamp
- timestamp-format
- Set timestamp format
- timestamp-timeout
- Set timestamp timeout
- map
- Map characters on input or output
- color
- Colorize tio text using ANSI color code ranging from 0 to 255
- input-mode
- Set input mode
- output-mode
- Set output mode
- socket
- Set socket to redirect I/O to
- prefix-ctrl-key
- Set prefix ctrl key (a..z or 'none', default: t)
- rs-485
- Enable RS-485 mode
- rs-485-config
- Set RS-485 configuration
- alert
- Set alert action on connect/disconnect
- mute
- Mute tio messages
- script
- Run script from string
- script-file
- Run script from file
- script-run
- Run script on connect
- exec
- 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>]".
Visit https://tio.github.io
Maintained by Martin Lund
<martin.lund@keep-it-simple.com>.
Visit the GSP FreeBSD Man Page Interface. Output converted with ManDoc.
|