{"id":13470449,"url":"https://github.com/tio/tio","last_synced_at":"2025-04-29T18:58:58.521Z","repository":{"id":21215375,"uuid":"24528317","full_name":"tio/tio","owner":"tio","description":"A serial device I/O tool","archived":false,"fork":false,"pushed_at":"2025-04-29T15:44:25.000Z","size":18099,"stargazers_count":2322,"open_issues_count":14,"forks_count":166,"subscribers_count":42,"default_branch":"master","last_synced_at":"2025-04-29T18:58:51.561Z","etag":null,"topics":["automation","cli","command-line","developers","embedded","hackers","linux","lua","macos","open-source","rs-232","rs-485","script","serial","serial-port","terminal","tty","uart","xmodem","ymodem"],"latest_commit_sha":null,"homepage":"https://tio.github.io","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tio.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":["https://www.paypal.me/lundmar"]}},"created_at":"2014-09-27T09:36:32.000Z","updated_at":"2025-04-29T17:19:28.000Z","dependencies_parsed_at":"2023-09-23T04:30:08.016Z","dependency_job_id":"7c834b9e-3346-49ff-86d8-9849ed9fa468","html_url":"https://github.com/tio/tio","commit_stats":{"total_commits":1096,"total_committers":52,"mean_commits":"21.076923076923077","dds":"0.13868613138686137","last_synced_commit":"cdc773100ceffbad5ac4ac6b7ebd4bf356ef12fa"},"previous_names":[],"tags_count":75,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tio%2Ftio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tio%2Ftio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tio%2Ftio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tio%2Ftio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tio","download_url":"https://codeload.github.com/tio/tio/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251565802,"owners_count":21609979,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","cli","command-line","developers","embedded","hackers","linux","lua","macos","open-source","rs-232","rs-485","script","serial","serial-port","terminal","tty","uart","xmodem","ymodem"],"created_at":"2024-07-31T16:00:30.544Z","updated_at":"2025-04-29T18:58:58.496Z","avatar_url":"https://github.com/tio.png","language":"C","readme":"\n[![tio](images/tio-icon.png)]()\n\n# tio - a serial device I/O tool\n\n[![](https://img.shields.io/github/actions/workflow/status/tio/tio/ubuntu.yml?label=Ubuntu)](https://github.com/tio/tio/actions/workflows/ubuntu.yml)\n[![](https://img.shields.io/github/actions/workflow/status/tio/tio/macos.yml?label=MacOS)](https://github.com/tio/tio/actions/workflows/macos.yml)\n[![](https://github.com/tio/tio/actions/workflows/codeql.yml/badge.svg)](https://github.com/tio/tio/actions/workflows/codeql.yml)\n[![](https://img.shields.io/codefactor/grade/github/tio/tio)](https://www.codefactor.io/repository/github/tio/tio)\n[![](https://img.shields.io/github/v/release/tio/tio?sort=semver)](https://github.com/tio/tio/releases)\n[![](https://img.shields.io/repology/repositories/tio)](https://repology.org/project/tio/versions)\n\n## 1. Introduction\n\ntio is a serial device tool which features a straightforward command-line and\nconfiguration file interface to easily connect to serial TTY devices for basic\nI/O operations.\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"images/tio-demo.gif\"\u003e\n\u003c/p\u003e\n\n### 1.1 Motivation\n\nTo make a simpler serial device tool for working with serial TTY devices with\nless focus on classic terminal/modem features and more focus on the needs of\nembedded developers and hackers.\n\ntio was originally created as an alternative to\n[screen](https://www.gnu.org/software/screen) for connecting to serial devices\nwhen used in combination with [tmux](https://tmux.github.io).\n\n## 2. Features\n\n * Easily connect to serial TTY devices\n * Sensible defaults (115200 8n1)\n * Automatic connection management\n   * Automatic detection of serial ports\n   * Automatic reconnect\n   * Automatically connect to first new appearing serial device\n   * Automatically connect to latest registered serial device\n * Connect to same port/device combination via unique topology ID (TID)\n   * Useful for reconnecting when serial device has no serial device by ID\n * Support for non-standard baud rates\n * Support for mark and space parity\n * X-modem (1K/CRC) and Y-modem file upload\n * Support for RS-485 mode\n * List available serial devices\n   * By device\n     * Including topology ID, uptime, driver, description\n     * Sorted by uptime (newest device listed last)\n   * By ID\n   * By path\n * Show RX/TX statistics\n * Toggle serial lines\n * Pulse serial lines with configurable pulse duration\n * Local echo support\n * Remapping of characters (nl, cr-nl, bs, lowercase to uppercase, etc.)\n * Switchable independent input and output\n   * Normal mode\n   * Hex mode (output supports variable width)\n   * Line mode (input only)\n * Timestamp support\n   * Per line in normal output mode\n   * Output timeout timestamps in hex output mode\n * Support for delayed output\n   * Per character\n   * Per line\n * Log to file\n   * Automatic naming of log file (default)\n   * Configurable directory for saving automatic named log files\n   * Manual naming of log file\n   * Overwrite (default) or append to log file\n   * Strip control characters and escape sequences\n * Configuration file support\n   * Support for configuration profiles\n   * Activate configuration profiles by name or pattern\n   * Support for including other configuration files\n * Redirect I/O of shell command to serial device\n * Redirect I/O to UNIX socket or IPv4/v6 network socket\n   * Useful for scripting or TTY sharing\n * Pipe input and/or output\n * Bash completion on options, serial device names, and profile names\n * Configurable tio message text color\n   * Supports NO_COLOR env variable as per [no-color.org](https://no-color.org)\n * Visual or audible alert on connect/disconnect\n * Remapping of prefix key\n * Lua scripting support for automation\n   * Run script manually or automatically at connect (once/always/never)\n   * Simple expect/send like functionality with support for regular expressions\n   * Manipulate port modem lines (useful for microcontroller reset/boot etc.)\n   * Send files via x/y-modem protocol\n   * Search for serial devices\n * Man page documentation\n * Plays nicely with [tmux](https://tmux.github.io) and similar terminal multiplexers\n\n## 3. Usage\n\nFor more usage details please see the man page documentation\n[here](https://raw.githubusercontent.com/tio/tio/master/man/tio.1.txt).\n\n### 3.1 Command-line\n\nThe command-line interface is straightforward as reflected in the output from\n```tio --help```:\n```\nUsage: tio [\u003coptions\u003e] \u003ctty-device|profile|tid\u003e\n\nConnect to TTY device directly or via configuration profile or topology ID.\n\nOptions:\n  -b, --baudrate \u003cbps\u003e                   Baud rate (default: 115200)\n  -d, --databits 5|6|7|8                 Data bits (default: 8)\n  -f, --flow hard|soft|none              Flow control (default: none)\n  -s, --stopbits 1|2                     Stop bits (default: 1)\n  -p, --parity odd|even|none|mark|space  Parity (default: none)\n  -o, --output-delay \u003cms\u003e                Output character delay (default: 0)\n  -O, --output-line-delay \u003cms\u003e           Output line delay (default: 0)\n      --line-pulse-duration \u003cduration\u003e   Set line pulse duration\n  -a, --auto-connect new|latest|direct   Automatic connect strategy (default: direct)\n      --exclude-devices \u003cpattern\u003e        Exclude devices by pattern\n      --exclude-drivers \u003cpattern\u003e        Exclude drivers by pattern\n      --exclude-tids \u003cpattern\u003e           Exclude topology IDs by pattern\n  -n, --no-reconnect                     Do not reconnect\n  -e, --local-echo                       Enable local echo\n      --input-mode normal|hex|line       Select input mode (default: normal)\n      --output-mode normal|hex|hexN      Select output mode (default: normal)\n  -t, --timestamp                        Enable line timestamp\n      --timestamp-format \u003cformat\u003e        Set timestamp format (default: 24hour)\n      --timestamp-timeout \u003cms\u003e           Set timestamp timeout (default: 200)\n  -l, --list                             List available serial devices, TIDs, and profiles\n  -L, --log                              Enable log to file\n      --log-file \u003cfilename\u003e              Set log filename\n      --log-directory \u003cpath\u003e             Set log directory path for automatic named logs\n      --log-append                       Append to log file\n      --log-strip                        Strip control characters and escape sequences\n  -m, --map \u003cflags\u003e                      Map characters\n  -c, --color 0..255|bold|none|list      Colorize tio text (default: bold)\n  -S, --socket \u003csocket\u003e                  Redirect I/O to socket\n      --rs-485                           Enable RS-485 mode\n      --rs-485-config \u003cconfig\u003e           Set RS-485 configuration\n      --alert bell|blink|none            Alert on connect/disconnect (default: none)\n      --mute                             Mute tio messages\n      --script \u003cstring\u003e                  Run script from string\n      --script-file \u003cfilename\u003e           Run script from file\n      --script-run once|always|never     Run script on connect (default: always)\n      --exec \u003ccommand\u003e                   Execute shell command with I/O redirected to device\n  -v, --version                          Display version\n  -h, --help                             Display help\n\nOptions and profiles may be set via configuration file.\n\nIn session you can press ctrl-t ? to list available key commands.\n\nSee the man page for more details.\n```\n\nBy default tio automatically connects to the provided TTY device. If the device\nis not present, tio will wait for it to appear and then connect. If the\nconnection is lost (e.g. device is unplugged), it will wait for the device to\nreappear and then reconnect. However, if the `--no-reconnect` option is\nprovided, tio will exit if the device is not present or an established\nconnection is lost.\n\n#### 3.1.1 Examples\n\nTypical use is without options:\n```\n$ tio /dev/ttyUSB0\n```\n\nWhich corresponds to the commonly used default options:\n```\n$ tio --baudrate 115200 --databits 8 --flow none --stopbits 1 --parity none /dev/ttyUSB0\n```\n\nList available serial devices:\n```\n$ tio --list\nDevice            TID     Uptime [s] Driver           Description\n----------------- ---- ------------- ---------------- --------------------------\n/dev/ttyS4        BaaB     19526.576 port             16550A UART\n/dev/ttyS5        eV0Z     19525.845 port             16550A UART\n/dev/ttyUSB1      bCC2      1023.274 ftdi_sio         TTL232R-3V3\n/dev/ttyUSB0      SPpw       978.527 ftdi_sio         TTL232RG-VREG3V3\n/dev/ttyACM0      i5q4         2.079 cdc_acm          ST-Link VCP Ctrl\n\nBy-id\n--------------------------------------------------------------------------------\n/dev/serial/by-id/usb-FTDI_TTL232R-3V3_FTCHUV56-if00-port0\n/dev/serial/by-id/usb-FTDI_TTL232RG-VREG3V3_FT1NELUB-if00-port0\n/dev/serial/by-id/usb-STMicroelectronics_STLINK-V3_004900343438510234313939-if02\n\nBy-path\n--------------------------------------------------------------------------------\n/dev/serial/by-path/pci-0000:00:14.0-usb-0:8.1.3.1.4:1.0-port0\n/dev/serial/by-path/pci-0000:00:14.0-usbv2-0:8.1.3.1.4:1.0-port0\n/dev/serial/by-path/pci-0000:00:14.0-usbv2-0:6.4:1.0-port0\n/dev/serial/by-path/pci-0000:00:14.0-usb-0:6.4:1.0-port0\n/dev/serial/by-path/pci-0000:00:14.0-usbv2-0:6.3:1.2\n/dev/serial/by-path/pci-0000:00:14.0-usb-0:6.3:1.2\n\nConfiguration profiles (/home/lundmar/.config/tio/config)\n--------------------------------------------------------------------------------\nrpi3                stm32               esp32               am64-evm\nimx8mp-evk          nucleo-h743zi2      usb-devices\n```\n\nIt is recommended to connect serial TTY devices by ID:\n```\n$ tio /dev/serial/by-id/usb-FTDI_TTL232R-3V3_FTCHUV56-if00-port0\n```\nNote: Using serial devices by ID helps ensure that tio automatically reconnects\nto the same serial device when reattached, even when it enumerates differently.\n\nIf no serial device by ID is available it is recommended to connect via\ntopology ID (TID):\n```\n$ tio bCC2\n```\nNote: The TID is unique and will stay the same as long as your USB serial port\ndevice plugs into the same USB topology (same ports, same hubs, same\nconnections, etc.). This way it is possible for tio to successfully reconnect\nto the same device.\n\nConnect automatically to first new appearing serial device:\n```\n$ tio --auto-connect new\n```\n\nConnect automatically to latest registered serial device:\n```\n$ tio --auto-connect latest\n```\n\nIt is possible to use exclude options to affect which serial devices are\ninvolved in the automatic connection strategy:\n```\n$ tio --auto-connect new --exclude-devices \"/dev/ttyACM?,/dev/ttyUSB2\"\n```\n\nAnd to exclude drivers by pattern:\n```\n$ tio --auto-connect new --exclude-drivers \"cdc_acm,ftdi_sio\"\n```\nNote: Pattern matching supports '*' and '?'. Use comma separation to define\nmultiple patterns.\n\nTo include drivers by specific pattern simply negate the exclude option:\n```\n$ tio --auto-connect new --exclude-drivers !(\"cp2102\")\n```\n\nLog to file with autogenerated filename:\n```\n$ tio --log /dev/ttyUSB0\n```\n\nLog to file with specific filename:\n```\n$ tio --log --log-file my-log.txt\n```\n\nEnable ISO8601 timestamps per line:\n```\n$ tio --timestamp --timestamp-format iso8601 /dev/ttyUSB0\n```\n\nOutput to hex with width 16:\n```\n$ tio --output-mode hex16 /dev/ttyUSB0\n```\n\nRedirect I/O to IPv4 network socket on port 4242:\n```\n$ tio --socket inet:4242 /dev/ttyUSB0\n```\n\nMap NL to CR-NL on input from device and DEL to BS on output to device:\n```\n$ tio --map INLCRNL,ODELBS /dev/ttyUSB0\n```\n\nPipe data to the serial device:\n```\n$ cat data.bin | tio /dev/ttyUSB0\n```\n\nManipulate modem lines on connect:\n```\n$ tio --script \"set{DTR=high,RTS=low}; msleep(100); set{DTR=toggle,RTS=toggle}\" /dev/ttyUSB0\n```\n\nPipe command to serial device and wait for line response within 1 second:\n```\n$ echo \"*IDN?\" | tio /dev/ttyACM0 --script \"expect('\\r\\n', 1000)\" --mute\nKORAD KD3305P V4.2 SN:32475045\n```\n\n### 3.2 Key commands\n\nVarious in session key commands are supported. When tio is started, press\nctrl-t ? to list the available key commands.\n\n```\n[15:02:53.269] Key commands:\n[15:02:53.269]  ctrl-t ?       List available key commands\n[15:02:53.269]  ctrl-t b       Send break\n[15:02:53.269]  ctrl-t c       Show configuration\n[15:02:53.269]  ctrl-t e       Toggle local echo mode\n[15:02:53.269]  ctrl-t f       Toggle log to file\n[15:02:53.269]  ctrl-t F       Flush data I/O buffers\n[15:02:53.269]  ctrl-t g       Toggle serial port line\n[15:02:53.269]  ctrl-t i       Toggle input mode\n[15:02:53.269]  ctrl-t l       Clear screen\n[15:02:53.269]  ctrl-t L       Show line states\n[15:02:53.269]  ctrl-t m       Change mapping of characters on input or output\n[15:02:53.269]  ctrl-t o       Toggle output mode\n[15:02:53.269]  ctrl-t p       Pulse serial port line\n[15:02:53.269]  ctrl-t q       Quit\n[15:02:53.269]  ctrl-t r       Run script\n[15:02:53.269]  ctrl-t R       Execute shell command with I/O redirected to device\n[15:02:53.269]  ctrl-t s       Show statistics\n[15:02:53.269]  ctrl-t t       Toggle line timestamp mode\n[15:02:53.269]  ctrl-t v       Show version\n[15:02:53.269]  ctrl-t x       Send file via Xmodem\n[15:02:53.269]  ctrl-t y       Send file via Ymodem\n[15:02:53.269]  ctrl-t ctrl-t  Send ctrl-t character\n```\n\nIf needed, the prefix key (ctrl-t) can be remapped via configuration file.\n\n### 3.3 Configuration file\n\nOptions can be set via the configuration file first found in any of the\nfollowing locations in the order listed:\n - $XDG_CONFIG_HOME/tio/config\n - $HOME/.config/tio/config\n - $HOME/.tioconfig\n\nThe configuration file supports profiles using named sections which can be\nactivated via the command-line by name or pattern. A profile specifies which\nTTY device to connect to and other options.\n\n### 3.3.1 Example\n\nExample configuration file:\n\n```\n[default]\nbaudrate = 115200\ndatabits = 8\nparity = none\nstopbits = 1\ncolor = 10\n\n[rpi3]\ndevice = /dev/serial/by-id/usb-FTDI_TTL232R-3V3_FTGQVXBL-if00-port0\nno-reconnect = true\nlog = true\nlog-file = rpi3.log\nline-pulse-duration = DTR=200,RTS=150\ncolor = 11\n\n[svf2]\ndevice = /dev/ttyUSB0\nbaudrate = 9600\nscript = expect(\"login: \"); write(\"root\\n\"); expect(\"Password: \"); write(\"root\\n\")\ncolor = 12\n\n[esp32]\ndevice = /dev/serial/by-id/usb-0403_6014-if00-port0\nscript = set{DTR=high,RTS=low}; msleep(100); set{DTR=low,RTS=high}; msleep(100); set{RTS=low}\nscript-run = once\ncolor = 13\n\n[usb-devices]\npattern = ^usb([0-9]*)\ndevice = /dev/ttyUSB%m1\ncolor = 14\n```\n\nTo use a specific profile by name simply start tio like so:\n```\n$ tio rpi3\n```\nOr by pattern match:\n```\n$ tio usb12\n```\n\nAnother more elaborate configuration file example is available [here](examples/config/config).\n\n### 3.4 Lua script API\n\nTio suppots Lua scripting to easily automate interaction with the tty device.\n\nIn addition to the Lua API tio makes the following functions available:\n\n```\nexpect(string, timeout)\n      Expect string - waits for string to match or timeout before continueing.\n      Supports regular expressions. Special characters must be escaped with '\\\\'.\n      Timeout is in milliseconds, defaults to 0 meaning it will wait forever.\n\n      Returns 1 on successful match, 0 on timeout, or -1 on error.\n\n      On successful match it also returns the match string as second return value.\n\nread(size, timeout)\n      Read from serial device. If timeout is 0 or not provided it will wait\n      forever until data is ready to read.\n\n      Returns number of bytes read on success, 0 on timeout, or -1 on error.\n\n      On success, returns read string as second return value.\n\nread_line(timeout)\n      Read line from serial device. If timeout is 0 or not provided it will\n      wait forever until data is ready to read.\n\n      Returns number of bytes read on success, 0 on timeout, or -1 on error.\n\n      On success, returns the string that was read as second return value.\n      Also emits a single timestamp to stdout and log file per options.timestamp\n      and options.log.\n\nwrite(string)\n      Write string to serial device.\n\n      Returns number of bytes written on success or -1 on error.\n\nsend(file, protocol)\n      Send file using x/y-modem protocol.\n\n      Protocol can be any of XMODEM_1K, XMODEM_CRC, YMODEM.\n\ntty_search()\n      Search for serial devices.\n\n      Returns a table of number indexed tables, one for each serial device\n      found.  Each of these tables contains the serial device information accessible\n      via the following string indexed elements \"path\", \"tid\", \"uptime\", \"driver\",\n      \"description\".\n\n      Returns nil if no serial devices are found.\n\nset{line=state, ...}\n      Set state of one or multiple tty modem lines.\n\n      Line can be any of DTR, RTS, CTS, DSR, CD, RI\n\n      State is high, low, or toggle.\n\nsleep(seconds)\n      Sleep for seconds.\n\nmsleep(ms)\n      Sleep for miliseconds.\n\nexit(code)\n      Exit with exit code.\n```\n\n## 4. Installation\n\n### 4.1 Installation using package manager (Linux)\n\nPackages for various GNU/Linux distributions are available. Please consult your\npackage manager tool to find and install tio.\n\nIf you would like to see tio included in your favorite distribution, please\nreach out to its package maintainers team.\n\n### 4.2 Installation using snap (Linux)\n\nInstall latest stable version:\n```\n$ snap install tio --classic\n```\n\nNote: Classic confinement is currently required due to limitations of the snapcraft framework.\nSee [Issue #187](https://github.com/tio/tio/issues/187) for discussion.\n\n### 4.3 Installation using brew (MacOS, Linux)\n\nIf you have [brew](http://brew.sh) installed:\n```\n$ brew install tio\n```\n\n### 4.4 Installation using MSYS2 (Windows)\n\nIf you have [MSYS2](https://www.msys2.org) installed:\n```\n$ pacman -S tio\n```\n\n### 4.5 Installation from source\n\nThe latest source releases can be found [here](https://github.com/tio/tio/releases).\n\nBefore running the install steps make sure you have glib and lua libraries installed. For example:\n\n```\n$ sudo apt install libglib2.0-dev liblua5.2-dev\n```\n\nInstall steps:\n```\n$ meson setup build\n$ meson compile -C build\n$ meson install -C build\n```\n\nSee meson\\_options.txt for tio specific build options.\n\nNote: The meson install steps may differ depending on your specific system.\n\n### 4.6 Known issues\n\nGetting permission access errors trying to open your serial device?\n\nAdd your user to the group which allows serial device access permanently. For example, to add your user to the 'dialout' group do:\n```bash\nsudo usermod -a -G dialout \u003cusername\u003e\n```\nSwitch to the \"dialout\" group, temporary but immediately for this session.\n```bash\nnewgrp dialout\n```\n\n\n## 5. Contributing\n\nThis is an open source project - all contributions (bug reports, code, doc,\nideas, etc.) are welcome.\n\nPlease use the github issue tracker and pull request features.\n\nAlso, if you find this free open source software useful please feel free to\nconsider making a donation of your choice:\n\n[![Donate](images/paypal.png)](https://www.paypal.me/lundmar)\n\n\n## 6. Support\n\nSubmit bug reports via GitHub: https://github.com/tio/tio/issues\n\n\n## 7. Website\n\nVisit [tio.github.io](https://tio.github.io)\n\n\n## 8. License\n\ntio is GPLv2+. See LICENSE file for more details.\n\n\n## 9. Authors\n\nMaintained by Martin Lund \\\u003cmartin.lund@keep-it-simple.com\u003e\n\nSee the AUTHORS file for full list of contributors.\n","funding_links":["https://www.paypal.me/lundmar"],"categories":["C"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftio%2Ftio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftio%2Ftio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftio%2Ftio/lists"}