.TH "tio" "1" "@version_date@" "tio @version@" "User Commands" .SH "NAME" tio \- a simple serial device I/O tool .SH "SYNOPSIS" .PP .B tio .RI "[" "] " "" .SH "DESCRIPTION" .PP \fBtio\fR is a simple 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. .SH "OPTIONS" .TP .BR \-b ", " "\-\-baudrate " \fI Set baud rate [bps] (default: 115200). .TP .BR \-d ", " "\-\-databits 5" | 6 | 7 | 8 Set data bits (default: 8). .TP .BR \-f ", " "\-\-flow hard" | soft | none Set flow control (default: none). .TP .BR \-s ", " "\-\-stopbits 1" | 2 Set stop bits (default: 1). .TP .BR \-p ", " "\-\-parity odd" | even | none | mark | space Set parity (default: none). Note: With \fBmark\fR parity the parity bit is always 0. With \fBspace\fR parity the parity bit is always 1. Not all platforms support \fBmark\fR and \fBspace\fR parity. .TP .BR \-o ", " "\-\-output\-delay " \fI Set output delay [ms] inserted between each sent character (default: 0). .TP .BR \-O ", " "\-\-output\-line\-delay " \fI Set output delay [ms] inserted between each sent line (default: 0). .TP .BR " \-\-dtr\-pulse\-duration " \fI Set the duration [ms] of the DTR pulse (default: 100). .TP .BR \-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 \fB\-\-no\-autoconnect\fR option is provided, tio will exit if the device is not present or an established connection is lost. .TP .BR \-e ", " "\-\-local\-echo Enable local echo. .TP .BR \-t ", " \-\-timestamp Enable line timestamp. .TP .BR " \-\-timestamp-format \fI Set timestamp format to any of the following timestamp formats: .RS .TP 16n .IP "\fB24hour" 24-hour format ("hh:mm:ss.sss") .IP "\fB24hour-start" 24-hour format relative to start time .IP "\fB24hour-delta" 24-hour format relative to previous timestamp .IP "\fBiso8601" ISO8601 format ("YYYY-MM-DDThh:mm:ss.sss") .PP Default format is \fB24hour\fR .RE .TP .BR \-L ", " \-\-list\-devices List available serial devices. .TP .BR \-l ", " \-\-log Enable log to file. If no filename is provided the filename will be automatically generated. .TP .BR " \-\-log-file \fI Set log filename. .TP .BR " \-\-log-strip Strip control characters and escape sequences from log. .TP .BR \-m ", " "\-\-map " \fI Map (replace, translate) characters on input or output. The following mapping flags are supported: .RS .TP 12n .IP "\fBICRNL" Map CR to NL on input (unless IGNCR is set) .IP "\fBIGNCR" Ignore CR on input .IP "\fBINLCR" Map NL to CR on input .IP "\fBINLCRNL" Map NL to CR-NL on input .IP "\fBOCRNL" Map CR to NL on output .IP "\fBODELBS" Map DEL to BS on output .IP "\fBONLCRNL" Map NL to CR-NL on output .IP "\fBOLTU" Map lowercase characters to uppercase on output .P If defining more than one flag, the flags must be comma separated. .RE .TP .BR \-x ", " \-\-hexadecimal Enable hexadecimal mode. .TP .BR \-c ", " "\-\-color " \fI0..255|none|list Colorize tio text using ANSI color code value ranging from 0 to 255 or use "none" for no color. Use "list" to print a list of available ANSI color codes. Default value is 15. .TP .BR \-S ", " "\-\-socket \fI\fR\fB 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 \fBctrl-t\fR 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: .RS .TP 20n .IP "\fBunix:" Unix Domain Socket (file) .IP "\fBinet:" Internet Socket (network) .IP "\fBinet6:" Internet IPv6 Socket (network) .P If port is 0 or no port is provided default port 3333 is used. .P At present there is a hardcoded limit of 16 clients connected at one time. .RE .TP .BR \-v ", " \-\-version Display program version. .TP .BR \-h ", " \-\-help Display help. .SH "KEYS" .PP .TP 16n In session, the following key sequences are intercepted as tio commands: .IP "\fBctrl-t ?" List available key commands .IP "\fBctrl-t b" Send serial break (triggers SysRq on Linux, etc.) .IP "\fBctrl-t c" Show configuration (baudrate, databits, etc.) .IP "\fBctrl-t e" Toggle local echo mode .IP "\fBctrl-t h" Toggle hexadecimal mode .IP "\fBctrl-t l" Clear screen .IP "\fBctrl-t q" Quit .IP "\fBctrl-t s" Show TX/RX statistics .IP "\fBctrl-t t" Send ctrl-t key code .IP "\fBctrl-t L" Show line states (DTR, RTS, CTS, DSR, DCD, RI) .IP "\fBctrl-t d" Toggle DTR .IP "\fBctrl-t D" Pulse DTR .IP "\fBctrl-t r" Toggle RTS .IP "\fBctrl-t U" Toggle conversion to uppercase on output .IP "\fBctrl-t v" Show version .SH "HEXADECIMAL MODE" .PP In hexadecimal mode each incoming byte is printed out as a hexadecimal value. .PP Bytes can be sent in this mode by typing the \fBtwo-character hexadecimal\fR representation of the value, e.g.: to send \fI0xA\fR you must type \fI0a\fR or \fI0A\fR. .SH "CONFIGURATION FILE" .PP Options can be set via configuration file using the INI format. \fBtio\fR uses the configuration file first found in the following locations in the order listed: .PP .I $XDG_CONFIG_HOME/tio/tiorc .PP .I $HOME/.config/tio/tiorc .PP .I $HOME/.tiorc .PP Labels can be used to group settings into named sub-configurations which can be activated from the command-line when starting tio. .PP \fBtio\fR will try to match the user input to a sub-configuration by name or by pattern to get the tty and other options. .PP Options without any label change the default options. .PP Any options set via command-line will override options set in the configuration file. .PP The following configuration file options are available: .TP 20n .IP "\fBpattern" Pattern matching user input. This pattern can be an extended regular expression with a single group. .IP "\fBtty" tty device to open. If it contains a "%s" it is substituted with the first group match. .IP "\fBbaudrate" Set baud rate .IP "\fBdatabits" Set data bits .IP "\fBflow" Set flow control .IP "\fBstopbits" Set stop bits .IP "\fBparity" Set parity .IP "\fBoutput-delay" Set output character delay .IP "\fBoutput-line-delay" Set output line delay .IP "\fBdtr-pulse-duration" Set DTR pulse duration .IP "\fBno-autoconnect" Disable automatic connect .IP "\fBlog" Enable log to file .IP "\fBlog-file" Set log filename .IP "\fBlog-strip" Enable strip of control and escape sequences from log .IP "\fBlocal-echo" Enable local echo .IP "\fBtimestamp" Enable line timestamp .IP "\fBtimestamp-format" Set timestamp format .IP "\fBmap" Map characters on input or output .IP "\fBcolor" Colorize tio text using ANSI color code ranging from 0 to 255 .IP "\fBhexadecimal" Enable hexadecimal mode .IP "\fBsocket" Set socket to redirect I/O to .SH "CONFIGURATION FILE EXAMPLES" .TP To change the default configuration simply set options like so: .RS .nf .eo # Defaults baudrate = 9600 databits = 8 parity = none stopbits = 1 color = 10 dtr-pulse-duration = 50 .ec .fi .RE .TP Named sub-configurations can be added via labels: .RS .nf .eo [rpi3] tty = /dev/serial/by-id/usb-FTDI_TTL232R-3V3_FTGQVXBL-if00-port0 baudrate = 115200 color = 11 .ec .fi .RE .TP Activate the sub-configuration by name: $ tio rpi3 .TP Which is equivalent to: $ tio -b 115200 -c 11 /dev/serial/by-id/usb-FTDI_TTL232R-3V3_FTGQVXBL-if00-port0 .TP A sub-configuration can also be activated by its pattern which supports regular expressions: .RS .nf .eo [usb device] pattern = usb([0-9]*) tty = /dev/ttyUSB%s baudrate = 115200 .ec .fi .RE .TP Activate the sub-configuration by pattern match: $ tio usb12 .TP Which is equivalent to: $ tio -b 115200 /dev/ttyUSB12 .TP It is also possible to combine use of sub-configuration and command-line options. For example: $ tio -l -t usb12 .SH "EXAMPLES" .TP Typical use is without options: $ tio /dev/ttyUSB0 .TP Which corresponds to the commonly used default options: $ tio \-b 115200 \-d 8 \-f none \-s 1 \-p none /dev/ttyUSB0 .TP It is recommended to connect serial tty devices by ID: $ tio /dev/serial/by\-id/usb\-FTDI_TTL232R-3V3_FTGQVXBL\-if00\-port0 .PP Using serial devices by ID ensures that tio automatically reconnects to the correct serial device if it is disconnected and then reconnected. .TP Redirect serial device I/O to Unix file socket for scripting: $ tio -S unix:/tmp/tmux-socket0 /dev/ttyUSB0 .TP Then, to issue a command via the file socket simply do: $ echo "ls -la" | nc -UN /tmp/tmux-socket0 > /dev/null .TP Or use the expect command to script an interaction: .RS .nf .eo #!/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> " .ec .fi .RE .TP Redirect device I/O to network file socket for remote tty sharing: $ tio --socket inet:4444 /dev/ttyUSB0 .TP 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 .TP Pipe data from file to the serial device: $ cat data.bin | tio /dev/serial/by\-id/usb\-FTDI_TTL232R-3V3_FTGQVXBL\-if00\-port0 .SH "WEBSITE" .PP Visit https://tio.github.io .SH "AUTHOR" .PP Created by Martin Lund .