如今的市面上已经挺多串口终端程序了,比如 Putty、minicom,还有我自己最近在用 Bootterm,但这并不意味着这类软件就没有市场了。最近,Martin Lund 就为 Linux 开发了 tio 串行设备 I/O 工具。
Martin 发现现有许多的工具主要都专注在调制解调器或者使用起来十分麻烦,因此他开发了 tio 作为一个更简单的替代方案。Tio 并不着重于经典终端和调制解调器功能,它更多关注地是嵌入式开发人员和黑客的需求。

你们可以从源代码构建tio
1 2 3 4 |
$ git clone https://github.com/tio/tio $ meson build $ meson compile -C build $ sudo meson install -C build |
使用快照安装方式应该要容易,而且这样也可以获得自动更新:
1 |
$ snap install tio --classic |
现在我们看看“help”参数提供的选项:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
tio --help Usage: /snap/tio/438/usr/bin/tio [<options>] <tty-device|config> Options: -b, --baudrate <bps> Baud rate (default: 115200) -d, --databits 5|6|7|8 Data bits (default: 8) -f, --flow hard|soft|none Flow control (default: none) -s, --stopbits 1|2 Stop bits (default: 1) -p, --parity odd|even|none Parity (default: none) -o, --output-delay <ms> Output delay (default: 0) -n, --no-autoconnect Disable automatic connect -e, --local-echo Enable local echo -t, --timestamp Enable line timestamp --timestamp-format <format> Set timestamp format (default: 24hour) -L, --list-devices List available serial devices -l, --log Enable log to file --log-file <filename> Set log filename --log-strip Strip control characters and escape sequences -m, --map <flags> Map special characters -c, --color 0..255|none|list Colorize tio text (default: 15) -S, --socket <socket> Redirect I/O to socket -x, --hex-mode Enable hexadecimal mode -v, --version Display version -h, --help Display help Options may be set via configuration file. In session, press ctrl-t q to quit. See the man page for more details. |
现在,我插上了一块 USB转TTL 转接板来进行检查:
1 2 |
$ tio -L /dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0 |
检查之后我发现可以正确检测到该转接板,不过由于转接板是连接到 /dev/ttyUSB0的,所以检测结果和普通的连接方式有所区别:
1 2 3 4 5 6 7 8 9 10 |
[10490.292941] usb 1-1: new full-speed USB device number 4 using xhci_hcd [10490.458456] usb 1-1: New USB device found, idVendor=1a86, idProduct=7523, bcdDevice= 2.54 [10490.458466] usb 1-1: New USB device strings: Mfr=0, Product=2, SerialNumber=0 [10490.458470] usb 1-1: Product: USB2.0-Serial [10490.542269] usbcore: registered new interface driver usbserial_generic [10490.542284] usbserial: USB Serial support registered for generic [10490.544859] usbcore: registered new interface driver ch341 [10490.544919] usbserial: USB Serial support registered for ch341-uart [10490.544948] ch341 1-1:1.0: ch341-uart converter detected [10490.557605] usb 1-1: ch341-uart converter now attached to ttyUSB0 |
不过无论如何,我将波特率设置为 921600 后 ,仍然还可以将它与Khadas VIM4板一起使用:
1 2 3 4 5 6 7 8 9 10 |
$ tio /dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0 -b 921600 [11:59:32.534] tio v1.40 [11:59:32.534] Press ctrl-t q to quit [11:59:32.544] Connected ���T7:BL:055c20;ID:9056601109811D08;FEAT:30F:1FFF0000:B002F:1;POC:CF;RCY:0;OVD:0;DFU:0;SD:2002;eMMC:0;RD-0:0;CHK:0;SCS:0; Bl2_early_platform_setup: indicates bl2ex flow! OTP_LIC00 : 0f0300000000ff1f2f000b0000000000 OTP_LIC10 : 008207000001fc000c00001000000300 |
在这里,我可以在启动开发板板之前启动程序来获取完整的日志。这个功能其实与 bootterm 非常相似,甚至时间戳选项也很类似:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
$ tio /dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0 -b 921600 -t [14:09:55.213] tio v1.40 [14:09:55.213] Press ctrl-t q to quit [14:09:55.223] Connected [14:09:56.976] T7:BL:055c20;ID:9056601109811D08;FEAT:30F:1FFF0000:B002F:1;POC:CF;RCY:0;OVD:0;DFU:0;SD:2002;eMMC:0;RD-0:0;CHK:0;SCS:0; [14:09:57.533] Bl2_early_platform_setup: indicates bl2ex flow! [14:09:57.550] OTP_LIC00 : 0f0300000000ff1f2f000b0000000000 [14:09:57.550] OTP_LIC10 : 008207000001fc000c00001000000300 [14:09:57.551] OTP_LIC20 : ffffffbfffff0700ff80008003000003 [14:09:57.551] OTP_LIC30 : 00000002010000008f03000203000000 [14:09:57.552] TE: 380759 [14:09:57.552] BL2 Built : 09:58:05, Nov 19 2021. t7 griscure-review-sc2-bl2-10272020-2-102-g199647c - jenkins@walle02-sh [14:09:57.553] Board ID = 5 [14:09:57.553] Set sys clock to 24Mhz [14:09:57.554] syspll is 1512Mhz. Locked [14:09:57.554] sys1pll is 1608Mhz. Locked [14:09:57.554] Set sys clock to 167Mhz [14:09:57.555] gp0pll is 0Mhz. Locked [14:09:57.555] bl2_platform_setup [14:09:57.555] boot area list: [14:09:57.555] 1STBLOB 00000200 00040000 [14:09:57.556] BL2E 00040200 00013000 [14:09:57.556] BL2X 00053200 00011000 [14:09:57.556] DDRFIP 00064200 00040000 [14:09:57.556] DEVFIP 000a4200 00300000 [14:09:57.557] s_setup from rom:00010081 |
不过,tio 确实也提供了很多功能,比如将 I/O 重定向到 sockets 协议脚本或 TTY 共享、十六进制模式和更改文本颜色等等。

Tio 也可以通过 $XDG_CONFIG_HOME/tio/tiorc、$HOME/.config/tio/tiorc 或 $HOME/.tiorc 文件更改 tio 的默认配置。
你们可以在 Github 的项目页面上找到有关 tio 串行设备 I/O 工具的所有详细信息。对了,这其实不是我第一次写关于 Martin 开源工具的文章了,之前我们介绍过Martin为“LAN eXtensions for Instrumentation”兼容测试仪器制作的 LXI 工具。

文章翻译者:Nicholas,技术支持工程师、瑞科慧联(RAK)高级工程师,深耕嵌入式开发技术、物联网行业多年,拥有丰富的行业经验和新颖独到的眼光!