1tio(1)                           User Commands                          tio(1)
2
3
4

NAME

6       tio - a simple serial device I/O tool
7
8

SYNOPSIS

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

DESCRIPTION

14       tio  is  a  simple  serial device tool which features a straightforward
15       command-line and configuration file interface to easily connect to  se‐
16       rial TTY devices for basic I/O operations.
17
18

OPTIONS

20       -b, --baudrate <bps>
21
22              Set baud rate [bps] (default: 115200).
23
24       -d, --databits 5|6|7|8
25
26              Set data bits (default: 8).
27
28       -f, --flow hard|soft|none
29
30              Set flow control (default: none).
31
32       -s, --stopbits 1|2
33
34              Set stop bits (default: 1).
35
36       -p, --parity odd|even|none|mark|space
37
38              Set parity (default: none).
39
40              Note:  With  mark  parity the parity bit is always 0. With space
41              parity the parity bit is always 1.  Not  all  platforms  support
42              mark and space parity.
43
44
45       -o, --output-delay <ms>
46
47              Set  output delay [ms] inserted between each sent character (de‐
48              fault: 0).
49
50
51       -O, --output-line-delay <ms>
52
53              Set output delay [ms] inserted between each sent line  (default:
54              0).
55
56
57           --line-pulse-duration <duration>
58
59              Set  the  pulse duration [ms] of each serial port line using the
60              following  key  value  pair  format  in  the   duration   field:
61              <key>=<value>
62
63              Each key represents a serial line. The following keys are avail‐
64              able:
65
66
67
68              DTR     Data Terminal Ready
69
70              RTS     Request To Send
71
72              CTS     Clear To Send
73
74              DSR     Data Set Ready
75
76              DCD     Data Carrier Detect
77
78              RI      Ring Indicator
79
80              If defining more than one key value  pair,  the  pairs  must  be
81              comma separated.
82
83              The default pulse duration for each line is 100 ms.
84
85
86       -n, --no-autoconnect
87
88              Disable automatic connect.
89
90              By  default tio automatically connects to the provided device if
91              present. If the device is not present, it will wait  for  it  to
92              appear  and  then connect. If the connection is lost (eg. device
93              disconnects), it will wait for the device to reappear  and  then
94              reconnect.
95
96              However,  if  the  --no-autoconnect option is provided, tio will
97              exit if the device is not present or an  established  connection
98              is lost.
99
100
101       -e, --local-echo
102
103              Enable local echo.
104
105
106       -t, --timestamp
107
108              Enable line timestamp.
109
110
111           --timestamp-format <format>
112
113              Set timestamp format to any of the following timestamp formats:
114
115
116
117              24hour          24-hour format ("hh:mm:ss.sss")
118
119              24hour-start    24-hour format relative to start time
120
121              24hour-delta    24-hour format relative to previous timestamp
122
123              iso8601         ISO8601 format ("YYYY-MM-DDThh:mm:ss.sss")
124
125              Default format is 24hour
126
127
128       -L, --list-devices
129
130              List available serial devices by ID.
131
132
133       -l, --log
134
135              Enable log to file.
136
137              If  no  filename  is provided the filename will be automatically
138              generated.
139
140
141           --log-file <filename>
142
143              Set log filename.
144
145
146           --log-strip
147
148              Strip control characters and escape sequences from log.
149
150
151       -m, --map <flags>
152
153              Map (replace, translate) characters on input or output. The fol‐
154              lowing mapping flags are supported:
155
156
157
158              ICRNL       Map CR to NL on input (unless IGNCR is set)
159
160              IGNCR       Ignore CR on input
161
162              INLCR       Map NL to CR on input
163
164              INLCRNL     Map NL to CR-NL on input
165
166              OCRNL       Map CR to NL on output
167
168              ODELBS      Map DEL to BS on output
169
170              ONLCRNL     Map NL to CR-NL on output
171
172              OLTU        Map lowercase characters to uppercase on output
173
174              MSB2LSB     Map MSB bit order to LSB on output
175
176              If  defining  more  than one flag, the flags must be comma sepa‐
177              rated.
178
179
180       -x, --hexadecimal
181
182              Enable hexadecimal mode.
183
184
185       -c, --color 0..255|bold|none|list
186
187              Colorize tio text using ANSI color code value ranging from 0  to
188              255  or use "none" for no color or use "bold" to apply bold for‐
189              matting to existing system color.
190
191              Use "list" to print a list of available ANSI color codes.
192
193              Default value is "bold".
194
195
196       -S, --socket <socket>
197
198              Redirect I/O to socket.
199
200              Any input from clients connected to the socket is  sent  on  the
201              serial  port  as if entered at the terminal where tio is running
202              (except that ctrl-t sequences are not recognized), and any input
203              from the serial port is multiplexed to the terminal and all con‐
204              nected clients.
205
206              Sockets remain open while the serial port is  disconnected,  and
207              writes will block.
208
209              Various  socket types are supported using the following prefixes
210              in the socket field:
211
212
213
214              unix:<filename>     Unix Domain Socket (file)
215
216              inet:<port>         Internet Socket (network)
217
218              inet6:<port>        Internet IPv6 Socket (network)
219
220              If port is 0 or no port is provided default port 3333 is used.
221
222              At present there is a hardcoded limit of 16 clients connected at
223              one time.
224
225
226       -r, --response-wait
227
228              Wait  for  line  response  then  quit.  A line is considered any
229              string ending with either CR or NL character. If no line is  re‐
230              ceived tio will quit after response timeout.
231
232              Any  tio text is automatically muted when piping a string to tio
233              while in response mode to make it easy to parse the response.
234
235
236           --response-timeout <ms>
237
238              Set timeout [ms] of line response (default: 100).
239
240
241           --rs-485
242
243              Enable RS-485 mode.
244
245
246           --rs-485-config <config>
247
248              Set the RS-485 configuration using  the  following  key  or  key
249              value pair format in the configuration field:
250
251
252
253              RTS_ON_SEND=value             Set logical level (0 or 1) for RTS
254                                            pin when sending
255
256              RTS_AFTER_SEND=value          Set logical level (0 or 1) for RTS
257                                            pin after sending
258
259              RTS_DELAY_BEFORE_SEND=value   Set RTS delay (ms) before sending
260
261              RTS_DELAY_AFTER_SEND=value    Set RTS delay (ms) after sending
262
263              RX_DURING_TX                  Receive  data  even  while sending
264                                            data
265
266              If defining more than one key or key value pair,  they  must  be
267              comma separated.
268
269
270       --alert none|bell|blink
271
272              Set alert action on connect/disconnect.
273
274              It will sound the bell once or blink once on successful connect.
275              Likewise it will sound the bell twice or blink twice on  discon‐
276              nect.
277
278              Default value is "none".
279
280
281       -v, --version
282
283              Display program version.
284
285       -h, --help
286
287              Display help.
288

KEYS

290       In session, the following key sequences, a prefix key (default: ctrl-t)
291       followed by a command key, are intercepted as tio commands:
292
293       ctrl-t ?        List available key commands
294
295       ctrl-t b        Send serial break (triggers SysRq on Linux, etc.)
296
297       ctrl-t c        Show configuration (baudrate, databits, etc.)
298
299       ctrl-t e        Toggle local echo mode
300
301       ctrl-t f        Toggle log to file
302
303       ctrl-t F        Flush data I/O buffers (discard data  written  but  not
304                       transmitted and data received but not read)
305
306       ctrl-t g        Toggle serial port line
307
308       ctrl-t h        Toggle hexadecimal mode
309
310       ctrl-t l        Clear screen
311
312       ctrl-t L        Show line states (DTR, RTS, CTS, DSR, DCD, RI)
313
314       ctrl-t p        Pulse serial port line
315
316       ctrl-t q        Quit
317
318       ctrl-t s        Show TX/RX statistics
319
320       ctrl-t t        Toggle line timestamp mode
321
322       ctrl-t U        Toggle conversion to uppercase on output
323
324       ctrl-t v        Show version
325
326       ctrl-t ctrl-t   Send ctrl-t character
327
328

HEXADECIMAL MODE

330       In  hexadecimal mode each incoming byte is printed out as a hexadecimal
331       value.
332
333
334       Bytes can be sent in this mode by typing the two-character  hexadecimal
335       representation of the value, e.g.: to send 0xA you must type 0a or 0A.
336
337

CONFIGURATION FILE

339       Options  can  be  set  via configuration file using the INI format. tio
340       uses the configuration file first found in the following  locations  in
341       the order listed:
342
343
344       $XDG_CONFIG_HOME/tio/config
345
346       $HOME/.config/tio/config
347
348       $HOME/.tioconfig
349
350
351       Labels  can  be  used  to  group settings into named sub-configurations
352       which can be activated from the command-line when starting tio.
353
354
355       tio will try to match the user input to a sub-configuration by name  or
356       by pattern to get the TTY device and other options.
357
358
359       Options without any label change the default options.
360
361
362       Any  options set via command-line will override options set in the con‐
363       figuration file.
364
365
366       The following configuration file options are available:
367
368
369
370       pattern                  Pattern matching user input. This pattern  can
371                                be  an extended regular expression with a sin‐
372                                gle group.
373
374       device                   TTY device to open. If it contains a  "%s"  it
375                                is substituted with the first group match.
376
377       baudrate                 Set baud rate
378
379       databits                 Set data bits
380
381       flow                     Set flow control
382
383       stopbits                 Set stop bits
384
385       parity                   Set parity
386
387       output-delay             Set output character delay
388
389       output-line-delay        Set output line delay
390
391       line-pulse-duration      Set line pulse duration
392
393       no-autoconnect           Disable automatic connect
394
395       log                      Enable log to file
396
397       log-file                 Set log filename
398
399       log-strip                Enable  strip  of control and escape sequences
400                                from log
401
402       local-echo               Enable local echo
403
404       timestamp                Enable line timestamp
405
406       timestamp-format         Set timestamp format
407
408       map                      Map characters on input or output
409
410       color                    Colorize tio text using ANSI color code  rang‐
411                                ing from 0 to 255
412
413       hexadecimal              Enable hexadecimal mode
414
415       socket                   Set socket to redirect I/O to
416
417       prefix-ctrl-key          Set prefix ctrl key (a..z, default: t)
418
419       response-wait            Enable wait for line response
420
421       response-timeout         Set line response timeout
422
423       rs-485                   Enable RS-485 mode
424
425       rs-485-config            Set RS-485 configuration
426
427       alert                    Set alert action on connect/disconnect
428
429

CONFIGURATION FILE EXAMPLES

431       To change the default configuration simply set options like so:
432
433              # Defaults
434              baudrate = 9600
435              databits = 8
436              parity = none
437              stopbits = 1
438              color = 10
439              line-pulse-duration = DTR=200,RTS=400
440
441
442       Named sub-configurations can be added via labels:
443
444              [rpi3]
445              device = /dev/serial/by-id/usb-FTDI_TTL232R-3V3_FTGQVXBL-if00-port0
446              baudrate = 115200
447              color = 11
448
449
450       Activate the sub-configuration by name:
451
452              $ tio rpi3
453
454
455       Which is equivalent to:
456
457              $ tio -b 115200 -c 11 /dev/serial/by-id/usb-FTDI_TTL232R-3V3_FT‐
458              GQVXBL-if00-port0
459
460
461       A sub-configuration can also be activated by its pattern which supports
462       regular expressions:
463
464              [usb device]
465              pattern = usb([0-9]*)
466              device = /dev/ttyUSB%s
467              baudrate = 115200
468
469
470       Activate the sub-configuration by pattern match:
471
472              $ tio usb12
473
474
475       Which is equivalent to:
476
477              $ tio -b 115200 /dev/ttyUSB12
478
479
480       It  is  also  possible to combine use of sub-configuration and command-
481       line options. For example:
482
483              $ tio -l -t usb12
484
485

EXAMPLES

487       Typical use is without options:
488
489              $ tio /dev/ttyUSB0
490
491       Which corresponds to the commonly used default options:
492
493              $ tio -b 115200 -d 8 -f none -s 1 -p none /dev/ttyUSB0
494
495       It is recommended to connect serial TTY devices by ID:
496
497              $ tio /dev/serial/by-id/usb-FTDI_TTL232R-3V3_FTGQVXBL-if00-port0
498
499       Using serial devices by ID ensures that tio automatically reconnects to
500       the correct serial device if it is disconnected and then reconnected.
501
502       Redirect serial device I/O to Unix file socket for scripting:
503
504              $ tio -S unix:/tmp/tmux-socket0 /dev/ttyUSB0
505
506
507       Then, to issue a command via the file socket simply do:
508
509              $ echo "ls -la" | nc -UN /tmp/tmux-socket0 > /dev/null
510
511
512       Or use the expect command to script an interaction:
513
514              #!/usr/bin/expect -f
515
516              set timeout -1
517              log_user 0
518
519              spawn nc -UN /tmp/tio-socket0
520              set uart $spawn_id
521
522              send -i $uart "date\n"
523              expect -i $uart "prompt> "
524              send -i $uart "ls -la\n"
525              expect -i $uart "prompt> "
526
527
528       Redirect device I/O to network file socket for remote TTY sharing:
529
530              $ tio --socket inet:4444 /dev/ttyUSB0
531
532
533
534       Then, use netcat to connect to the shared TTY session over network (as‐
535       suming tio is hosted on IP 10.0.0.42):
536
537              $ nc -N 10.0.0.42 4444
538
539
540       Pipe command to the serial device:
541
542              $ echo "ls -la" | tio /dev/serial/by-id/usb-FTDI_TTL232R-3V3_FT‐
543              GQVXBL-if00-port0
544
545
546       Pipe  command  to  the serial device and wait for line response (string
547       ending with CR or NL):
548
549              $ echo "*IDN?" | tio /dev/ttyACM0 --response-wait
550
551       In this mode, only the response will be printed.
552
553
554       Likewise, to pipe data from file to the serial device:
555
556              $ cat data.bin | tio  /dev/serial/by-id/usb-FTDI_TTL232R-3V3_FT‐
557              GQVXBL-if00-port0
558
559
560       Enable RS-485 mode:
561
562              $    tio   --rs-485   --rs-485-config=RTS_ON_SEND=1,RX_DURING_TX
563              /dev/ttyUSB0
564
565

WEBSITE

567       Visit https://tio.github.io
568
569

AUTHOR

571       Created by Martin Lund <martin.lund@keep-it-simple.com>.
572
573
574
575tio 2.5                           2022-12-17                            tio(1)
Impressum