Commit graph

12 commits

Author SHA1 Message Date
yabu76
2316c0216a Add documentation and examples for new features. 2026-03-08 11:17:50 +09:00
yabu76
a19bf0aa44 Add Lua API tio.twrite's documentation and example 2026-02-22 16:40:57 +09:00
ii8
86f48a2fb6 Overhaul Lua API
Lua API moved into a tio library table and names adjusted to Lua stdlib style.
Regex in expect() replaced with Lua patterns so binary data can be handled.
New tio.alwaysecho variable allows enabling and disabling echo to console.
Read and write functions now manage complex retry and timeout logic internally,
giving the user a simple "nil if fail" API like the rest of Lua.
exit() was removed, os.exit() already exists in the Lua standard library.
2025-06-14 15:09:21 +02:00
Martin Lund
c49faa7337 Clean up lua API
Rename modem_send() to send()
Rename send to write()
2024-11-30 11:09:43 +01:00
Keith Hill
afd82f7ac4 + Add system timestamps to lua read() and new lua read_line() per global options
+ Add missing timestamp-format epoch
+ Update send_ to use fsync and tcdrain like normal tty_sync does
+ Rework read_line to save partial line at timeout
+ Simplified read_line to reduce cyclomatic complexity

+ renamed example files read.lua and read_line.lua
+ moved #define READ_LINE_SIZE to top of file
+ renamed g_linebuf to linebuf, and moved it into read_line as a static variable
2024-11-07 21:45:06 +01:00
Martin Lund
6d77201ba0 Simplify lua line manipulation API
Collapses lua high(), low(), toggle(), config_high(), config_low(),
config_apply() into one simple function:

set{<line>=<state>, ...}

Line can be any of DTR, RTS, CTS, DSR, CD, RI.

State is high, low, or toggle.

Example:
script = set{DTR=high, RTS=low}; msleep(100); set{DTR=low, RTS=high}; msleep(100); set{RTS=low}

Notice the use of {} instad of () when calling the set function. This is
required to pass parameters by name in lua.
2024-04-29 15:20:53 +02:00
Martin Lund
6e779a0520 Use lua io.write() instead of print()
io.write() gives better output control as print() is hardcoded to always
print a newline.
2024-04-27 00:48:38 +02:00
Martin Lund
d19ba1c492 Add new ways to manage serial devices
* Rename --list-devices to --list

 * Rename --no-autoconnect to --no-reconnect

 * Switch -l and -L options

   * -l now lists available serial devices

   * -L enables log to file

 * Add option --auto-connect <strategy>

   * Supported strategies:

     * "new" - Waits to connect first new appearing serial device

     * "latest" - Connects to latest registered serial device

     * "direct" - Connect directly to specified serial device (default)

 * Add options to exclude serial devices from auto connect strategy by
   pattern

   * Supported exclude options:

     * --exclude-devices <pattern>

       Example: '--exclude-devices "/dev/ttyUSB2,/dev/ttyS?"'

     * --exclude-drivers <pattern>

       Example: '--exclude-drivers "cdc_acm"'

     * --exclude-tids <pattern>

       Example: '--exclude-tids "yW07,bCC2"'

     * Patterns support '*' and '?'

 * Connect to same port/device combination via unique topology ID (TID)

   * Topology ID is a 4 digit base62 encoded hash of a device topology
     string coming from the Linux kernel. This means that whenever you
     plug in the same e.g. USB serial port device to the same USB hub
     port connected via the exact same hub topology all the way to your
     computer, you will get the same unique TID.

   * Useful for stable reconnections when serial device has no serial
     device by ID

   * For now, only tested on Linux.

 * Reworked and improved listing of serial devices to show serial devices:

   * By device

     * Including TID, uptime, driver, and description.

     * Sorted by uptime (newest device listed last)

   * By unique topology ID

   * By ID

   * By path

 * Add script interface 'list = tty_search()' for searching for serial
   devices.
2024-04-26 22:19:22 +02:00
Martin Lund
96fafc5fb4 Generalize automatic login example for Linux 2024-04-19 14:44:54 +02:00
Davis C
29546bb13a Updated login example with new expect logic 2024-04-19 14:41:30 +02:00
Martin Lund
f4c4387e05 Add automatic login script example 2024-04-17 18:27:46 +02:00
Martin Lund
a1987b61b4 Organize examples directory 2024-04-17 18:24:33 +02:00