Commit graph

17 commits

Author SHA1 Message Date
Martin Lund
d60363a64c Cleanup global variable name shadowing 2024-04-15 11:21:36 +02:00
Martin Lund
0afae5d3ee Update text 2024-04-12 13:03:51 +02:00
Braden Young
afc9e3be5b Move map variables to tty to keep them all in one spot 2023-04-14 15:00:03 -07:00
Braden Young
5651c1c5d7 Configure socket mapping flags from tty parsing logic. Remove duplicate parsing logic in socket 2023-04-14 13:08:48 -07:00
Braden Young
65b3353f57 Support input mapping modes for sockets 2023-04-14 11:18:27 -07:00
Martin Lund
8188bb5b76 Handle stale unix socket file
Delete existing unix socket file if it is tested to be stale, meaning no
one is listening on it.
2022-09-11 11:20:27 +02:00
Martin Lund
ac859f41b9 Cleanup error printing routines
Clean up so that only the following error related printing functions are
used: tio_error_printf(), tio_error_printf_silent(),
tio_warning_printf().

A session mode switch is introduced for error printing so that it will
print error messages with better formatting depending on in or out of
session.
2022-07-11 23:18:19 +02:00
Sylvain LAFRASSE
16d6807de7 Add missing 'string.h' include. 2022-07-04 17:34:38 +02:00
Martin Lund
b72fae4c87 Cleanup 2022-07-03 18:28:51 +02:00
Martin Lund
a37ad26a88 Clean up main 2022-06-16 18:16:41 +02:00
Martin Lund
b8b0ec6575 Socket code cleanup 2022-06-14 22:33:58 +02:00
Martin Lund
0a892006ea Unify error message formating 2022-06-11 23:36:51 +02:00
Martin Lund
c38ba262d3 Cleanup IPv6 code 2022-06-11 15:16:47 +02:00
Martin Lund
17e96d70bc Add support for IPv4 and IPv6 network sockets
Add support for IPv4 and IPv6 network sockets via socket syntax
"inet:<port>" and "inet6:<port>" respectively.

For example, to listen and redirect serial device I/O to a host bound
IPv4 socket simply do:

 $ tio /dev/ttyUSB0 --socket inet:4444

To connect do e.g.:

 $ nc 127.0.0.1 4444

Likewise, for IPv6 do:

 $ tio /dev/ttyUSB0 --socket inet6:4444

To connect do e.g.:

 $ nc ::1 4444

If port is 0 or no port is provided default port 3333 is used.
2022-06-11 14:19:29 +02:00
Martin Lund
ba22191800 Fix tio deleting unix socket file
If tio has a unix file socket open, a second tio instance of tio may
delete the socket file. This change fixes so that it will not be deleted
and tio will instead error and complain about conflicting socket file.
2022-06-11 02:56:44 +02:00
Martin Lund
b0b0856a8b Print socket info at startup 2022-04-20 19:20:26 +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