Commit graph

51 commits

Author SHA1 Message Date
Martin Lund
148a3c1da1 Add --log-append option
Add --log-append option which makes tio append to any existing log file.

This also changes the default behaviour of tio from appending to
overwriting any existing log file. Now you have to use this new option
to make tio append.
2023-04-28 20:50:34 +02:00
Martin Lund
4e9d29c88d Add support for $HOME/.tioconfig
Replaces what used to be $HOME/.tiorc
2022-12-07 04:10:56 +01:00
Vyacheslav Patkov
42739c0817 Better error checking in config file, rename the file
Accept "true", "enable", "on", "yes", "1" as true values, their
counterparts as false ones. Check integer values for errors and range.
Warn about ignored (e.g. misspelled) options.

Check getenv() return value for NULL.

Rename "tiorc" to "config", as it's a static INI file, not an executable
"run commands".
2022-12-06 20:27:14 +04:00
Martin Lund
c80f833a06 Add mute feature
This will make tio go fully silent and not print anything.
2022-10-22 08:59:41 +02:00
Martin Lund
784201ea2e Deprecate tty config keyword but keep it around for now 2022-10-19 23:56:31 +02:00
Martin Lund
fba56318f8 Update show config 2022-10-19 22:35:34 +02:00
Martin Lund
48a2298e81 Rename config variable 'tty' to 'device' 2022-10-19 22:29:33 +02:00
Martin Lund
ad9b93dc52 Simplify configfile implementation 2022-10-17 00:23:26 +02:00
Martin Lund
a97b2c00cd Add shell completion of sub-configuration names
Does not work with sub configuration names that contains one or more
white spaces.
2022-10-16 23:02:04 +02: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
e837fd0303 Add line response feature
Add a simple line response feature to make it possible to send e.g. a
command string to your serial device and easily receive and parse a line
response.

This is a convenience feature for simple request/response interaction
based on lines. For more advanced interaction the socket feature should
be used instead.

The line response feature is detailed via the following options:

 -r, --response-wait

Wait for line response then quit. A line is considered any string ending
with either CR or NL character. If no line is received tio will quit
after response timeout.

Any tio text is automatically muted when piping a string to tio while in
response mode to make it easy to parse the response.

 --response-timeout <ms>

Set timeout [ms] of line response (default: 100).

Example:

Sending a string (SCPI command) to a test instrument (Korad PSU) and
print line response:

 $ echo "*IDN?" | tio /dev/ttyACM0 --response-wait
 KORAD KD3305P V4.2 SN:32477045
2022-08-15 19:58:28 +02:00
Martin Lund
3903880106 Rework toggle and pulse feature to support all lines
Replace existing toggle and pulse key commands with the following
generalized key commands which allows to toggle or pulse all serial port
lines:

 ctrl-t g   Toggle serial port line
 ctrl-t p   Pulse serial port line

When used, user will be asked which serial line to toggle or pulse.

Also introduce --line-pulse-duration option for setting specific pulse
duration in milliseconds for each serial line using a key value pair
format. Each key represents a serial line. The following keys are
available: DTR, RTS, CTS, DSR, DCD, RI.

Example:

 $ tio /dev/ttyUSB0 --line-pulse-duration DTR=200,RTS=300,RI=50

Likewise, the pulse duration can also be set via configuration file
using the line-pulse-duration variable:

 line-pulse-duration = DTR=200,RTS=300,RI=50
2022-07-19 12:54:40 +02:00
Martin Lund
fc3e6c40ec Optimization 2022-07-17 09:34:03 +02:00
Martin Lund
9733bdf19c Introduce bold color option
Introduce "bold" color option which only apply bold color formatting to
existing system color.

Also make "bold" the default color option.

Fixes all white issue with black on white tio text.
2022-07-15 18:42:03 +02:00
Martin Lund
02729c10b1 Add support for remapping prefix key
Make it possible to remap the prefix key (default: ctrl-t) by setting
the prefix-ctrl-key variable in the configuration file.

Allowed values are in the range a..z.

Example, to set the prefix key to ctrl-a simply do:

prefix-ctrl-key = a
2022-07-15 12:18:40 +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
Martin Lund
39af74f263 Rename EOL delay to Output line delay 2022-07-11 14:08:12 +02:00
Martin Lund
11762b2300 Replace -U,--upcase with mapping flag OLTU 2022-07-11 10:15:12 +02:00
Robert Snell
f459a462c5 Fixed indentation in configfile.c, tty.c, options.c 2022-07-10 18:14:29 -04:00
Robert Snell
1c29aac9fa fixed indentation in configfile.c 2022-07-10 14:06:22 -04:00
Robert Snell
944ee9173b Additional commands: EOL delay, lower to upper translation, added mark parity
Added command line options:
-O, --eol-delay to have a separate delay for end of line
-U, --upper to enable translation of lower case alpha to upper case

Added ability to set mark parity.
Added ctrl-t U key sequence to allow enable/disable lower case alpha to
upper case during a session.
Updated Man page with command line options, ctrl-t sequences and
configuration file options.
Updated README.md, with above information.
2022-07-09 21:22:43 -04:00
George Joseph
f24cee61e7 Add Pulse DTR command
MCUs like the ESP32 can be reset if the serial port DTR line is
pulsed for a short time.  You could just type CTRL-t d CTRL-t d
but that's a little awkward since you have to lift your finger
off the CTRL key to type the Ds.  Now you can just type CTRL-T D.

* Added new command "D" to pulse the DTR line.  I.E.  Toggle its
  state twice with a configurable duration between toggles.

* Added new config/command line option "--dtr-pulse-duration"
  to set the duration between the DTR state toggles.  The default
  is 100ms.
2022-07-07 12:45:29 -06:00
V2
c10c47343e
Update configfile.c 2022-07-04 16:31:32 +01:00
Martin Lund
b72fae4c87 Cleanup 2022-07-03 18:28:51 +02:00
Martin Lund
1b91fd9f69 Rename --hex-mode to --hexadecimal 2022-07-01 13:16:14 +02:00
Martin Lund
1dabf0fdf5 Add config support for log-strip 2022-06-17 10:59:59 +02:00
Martin Lund
f48402f7ed Add config support for hex-mode 2022-06-17 10:58:55 +02:00
Martin Lund
1b99a103cb Rename log-filename to log-file in config file 2022-06-14 01:07:54 +02:00
Martin Lund
b5c3193411 Remove debug 2022-06-12 00:47:26 +02:00
Martin Lund
16c42bb9ae Fix config file memory leak 2022-06-12 00:44:52 +02:00
Martin Lund
94485ec9ac Make sure only matched config section is parsed 2022-06-12 00:44:35 +02:00
Martin Lund
9b55f18c07 Add support for "disable" keyword in config file 2022-06-12 00:42:24 +02:00
Martin Lund
a0d4be068b Fix command-line tty-device|config parsing
Allow user to add options on both sides of the provided config argument.

For example:

 $ tio -b 9600 am64-evm -e

Before, tio only allowed adding arguments after the config argument.

Implemented as simple as possible by introducing two stage option parsing.
2022-06-11 22:56:03 +02:00
Martin Lund
46b5783789 Rework color option
Rework the color option to support setting ANSI color code values
ranging from 0..255 or "none" for no color or "list" to print a list of
available ANSI colors codes.

Also, disables color when piping.
2022-06-08 16:19:47 +02:00
Martin Lund
5b7191ed7c Fix configfile memory leaks 2022-06-04 20:37:06 +02:00
Martin Lund
9476422922 Remove command-line option inconsistencies
Optional arguments, as parsed by the getopt_long mechanism, are
inherently inconsistent with how you define required arguments.

To avoid confusion we decide to avoid this inconsistency by replacing
optional options with additional options with required argmuments.
2022-06-04 19:08:05 +02:00
Martin Lund
d43ef3333f Replace '1' with 'enable' in config files 2022-06-04 17:33:36 +02:00
Martin Lund
836c28098c Redirect error messages to stderr 2022-06-01 19:55:44 +02:00
Martin Lund
c94e8826fd Fix running without config file 2022-06-01 18:37:11 +02:00
Martin Lund
c96c3c4c83 Fix config file error messages 2022-06-01 18:23:14 +02:00
Martin Lund
9a1afc09c2 Fix parsing of default settings
Default configuration file settings were not parsed in case a section
was matched. Now we make sure that the default (unnamed) settings are
always parsed.
2022-05-15 22:37:59 +02:00
Peter Collingbourne
a81c43a01a Match user input against config section names if pattern matching was unsuccessful.
This allows for better config file ergonomics if the user has a diverse
set of serial devices as the name does not need to be specified in
the config file twice.
2022-04-20 15:31:41 -07: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
28c880cdab Remove verbose option
Remove the command-line verbose option but let the ctrl-t c feature
print some of the verbose information (active config path/section).
2022-04-13 16:28:30 +02:00
Sylvain LAFRASSE
a543fbd7ef Factorize timestamp parsing to be coherent with command line format in configuration file. 2022-03-30 17:11:50 +02:00
Martin Lund
09bcd91bf0 Add support for defaults in config file
If no section name is specified the configuration will be considered the
default one.

This allows to set e.g. a default color code for sections which do not
configure a color code.
2022-03-19 18:37:37 +01:00
Martin Lund
e81e76473a Add color configuration support 2022-03-11 16:09:21 +01:00
Martin Lund
8965b7b42c Update headers 2022-03-11 15:15:39 +01:00