Commit graph

28 commits

Author SHA1 Message Date
Martin Lund
f887756a71 meson: Enable compiler warnings on unused result and global shadows 2025-04-29 17:44:08 +02:00
Robert Lipe
7516dff802 Add missing build piece. 2025-04-24 17:55:26 +02:00
Martin Lund
b8135ea639 Rename git version to simply version 2024-11-30 11:37:27 +01:00
Martin Lund
ab678e6c88 Use version from git 2024-10-25 19:35:13 +02:00
Martin Lund
8c471105fe Fix line input mode ignoring characters ABCD 2024-06-27 18:54:19 +02:00
Martin Lund
65c5a068d8 Replace inih with glib key file parser
After including the use of glib we might as well replace inih
with the glib key file parser.

All configuraiton file parsing has been reworked and also the options
parsing has been cleaned up, resulting in better and stricter
configuration file and option value checks.

Compared to old, configuration files now requires any default
configurations to be put in a group/section named [default].

Configuration file keywords such as "enable", "disable", "on",
"off", "yes", "no", "0", "1" have been retired. Now only "true" and
"false" apply to boolean configuration options. This is done to simplify
things and avoid any confusion.

The pattern option feature has been reworked so now the user can now
access the full match string and any matching subexpression using the
%mN syntax.

For example:

[usb devices]
pattern = usb([0-9]*)
device = /dev/ttyUSB%m1

Then when using tio:
$ tio usb12

   %m0 = 'usb12'  // Full match string
   %m1 = 12       // First match subexpression

Which results in device = /dev/ttyUSB12
2024-05-02 18:35:37 +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
0becfa3274 Add Lua scripting feature
Add support for running Lua scripts that can manipulate the tty control
lines. Script is activated automatically on connect or manually via in
session key command.

The Lua scripting feature opens up for many posibilities in the future
such as adding expect like functionality to easily and programatically
interact with the connected device.
2024-04-01 15:37:40 +02:00
Martin Lund
c9c5f03c10 Fix meson source listing 2023-09-16 12:20:34 +02:00
pnrhub
e6ffbd9058
Add xmodem and ymodem file send support (#208)
* Add xmodem and ymodem file send support
---------

Co-authored-by: pnr <pnr@home25.nl>
2023-09-16 12:17:38 +02:00
Martin Lund
93e6efc001 Add threaded input handling
To make tio more responsive to quit and I/O flush key command when main I/O
thread is blocked on output.
2022-11-28 14:44:32 +01:00
Martin Lund
ba2d49d2f7 Consolidate timestamp implementation in one file 2022-09-10 23:29:23 +02:00
Martin Lund
dbc9a8e82d Add visual or audible alert support on connect/disconnect
The feature is detailed via the following option:

 --alert none|bell|blink

     Set alert action on connect/disconnect.

     It will sound the bell once or blink once on successful connect.
     Likewise it will sound the bell twice or blink twice on disconnect.

     Default value is "none" for no alert.
2022-09-10 22:33:42 +02:00
Martin Lund
ee46686fb6 Add experimental RS-485 support
Many modern RS-485 serial devices such as the ones from FTDI already
operate in RS-485 mode by default and will work with tio out of the box.
However, there are some RS-232/485 devices which need to be switched
from e.g. RS-232 to RS-485 mode to operate accordingly on the physical
level.

This commit implements the switching mechanism and interface required to
enable RS-485 mode. It only works on Linux and with serial devices which
use device drivers that support the Linux RS-485 control interface.

The RS-485 feature is detailed via the following options:

 --rs-485                           Enable RS-485 mode
 --rs-485-config <config>           Set RS-485 configuration

Set the RS-485 configuration using the following key or key value pair
format in the configuration field:

 RTS_ON_SEND=value             Set logical level (0 or 1) for RTS pin when sending
 RTS_AFTER_SEND=value          Set logical level (0 or 1) for RTS pin after sending
 RTS_DELAY_BEFORE_SEND=value   Set RTS delay (ms) before sending
 RTS_DELAY_AFTER_SEND=value    Set RTS delay (ms) after sending
 RX_DURING_TX                  Receive data even while sending data

If defining more than one key or key value pair, they must be comma
separated.

Example use:

 $ tio /dev/ttyUSB0 --rs-485 --rs-r485-config=RTS_DELAY_AFTER_SEND=50,RX_DURING_TX
2022-09-10 17:52:54 +02:00
Martin Lund
a23be7f2c2 Simplify arbitrary baudrate code 2022-07-12 12:09:09 +02:00
Peter Collingbourne
fb453160ef Add support for external control via a Unix domain socket.
This feature allows an external program to inject output into and
listen to input from a serial port via a Unix domain socket (path
specified via the -S/--socket command line flag, or the socket
config file option) while tio is running. This is useful for ad-hoc
scripting of serial port interactions while still permitting manual
control. Since many serial devices (at least on Linux) get confused
when opened by multiple processes, and most commands do not know
how to correctly open a serial device, this allows a more convenient
usage model than directly writing to the device node from an external
program.

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
ctrl-t 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.

Example usage 1 (issue a command):

  echo command | nc -UN /path/to/socket > /dev/null

Example usage 2 (use the expect command to script an interaction):

  #!/usr/bin/expect -f

  set timeout -1
  log_user 0

  spawn nc -UN /path/to/socket
  set uart $spawn_id

  send -i $uart "command1\n"
  expect -i $uart "prompt> "
  send -i $uart "command2\n"
  expect -i $uart "prompt> "
2022-04-18 14:06:33 -07:00
Martin Lund
1ec39d1c7b Make libinih a fallback dependency
This means that in case meson does not find libinih it will
automatically clone libinih and include it in the build.

The libinih library is reconfigured to be statically built so that no
shared object will be installed.
2022-03-29 17:54:33 +02:00
Martin Lund
03cf4ef197 Handle SIGHUP
Handle SIGHUP so that the registered exit handlers are called to restore
the terminal back to its orignal state.
2022-03-18 19:19:11 +01:00
Martin Lund
410fc8bffe Bypass unused result warnings 2022-03-11 15:30:33 +01:00
Martin Lund
659336af51 Force dependency on libinih
Configuration file support is considered a mandatory feature.
2022-03-11 15:28:35 +01:00
Martin Lund
a2b164519f Mostly cosmetic updates 2022-03-11 15:11:43 +01:00
Liam Beguin
2e5c1ff20c add support for a configuration file
Signed-off-by: Liam Beguin <liambeguin@gmail.com>
2022-03-10 10:34:52 -05:00
Martin Lund
7ffeeccdf5 Merge branch 'osx-baudrate' of https://github.com/robey/tio into robey-osx-baudrate 2022-02-16 05:24:35 +01:00
Martin Lund
3d08787142 Fix setspeed2 compilation 2022-02-15 03:47:24 +01:00
Martin Lund
32e853e46e Fix setspeed2 check 2022-02-14 21:01:58 +01:00
Martin Lund
d4c3751405 Meson cleanup 2022-02-13 11:07:51 +01:00
Martin Lund
b6eac3f001 Improve printed output
Get rid of inconsistencies in the printed output (error printing,
colors, etc.).

Prepare for user configurable color.

Cleanup.
2022-02-12 22:47:42 +01:00
Martin Lund
e9208d693e Replace autotools with meson
To introduce much simpler build configuration which is also easier to
maintain.
2022-02-10 05:09:32 +01:00