Commit graph

379 commits

Author SHA1 Message Date
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
2cba4b863f Update text 2022-10-19 22:44:10 +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
6f9e41152b Update show config 2022-10-19 22:18:25 +02:00
Martin Lund
b00b0e872f Beautify help 2022-10-17 13:55:00 +02:00
Martin Lund
c2aa3489fd Fix error message 2022-10-17 01:12:35 +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
c8aeba7ef8 Fix output line delay
Apply output line delay on lines ending with \n.

On most systems lines ends with \n or \r\n.
2022-10-11 12:12:40 +02:00
Martin Lund
a65b5b0e3a Do not print timestamps in hex mode 2022-09-29 20:50:12 +02:00
Martin Lund
5f14924c96 Improve input mechanism in hex mode
Print the 2 character hex code that you input in hex mode but then
delete it before sending. This way it is easier to keep track of what
you are inputting. It basically mimics the ctrl-shift-u input mechanism
that is used to input unicode.
2022-09-29 20:18:36 +02:00
Attila Veghelyi
4924969268 Complete bit reorder feature for release 2022-09-29 17:33:35 +02:00
Attila Veghelyi
5b8f33bd78 Add bit reverse order feature 2022-09-29 15:42:44 +02:00
Martin Lund
ce3101a380 Clean up indentation 2022-09-18 19:20:12 +02:00
Martin Lund
ab885713b9 Add support for sending prefix character to serial device
Do so by inputting prefix key twice, e.g. input ctrl-t ctrl-t to send
ctrl-t character to serial device.
2022-09-11 22:17:29 +02:00
Martin Lund
6618642acf Fix tty path on MSYS/CYGWIN platforms 2022-09-11 13:38:13 +02:00
Martin Lund
16479c8d86 Cleanup 2022-09-11 11:55:19 +02: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
0afcef807b Cleanup 2022-09-11 00:57:05 +02:00
Martin Lund
1dc3a3891d Cleanup 2022-09-10 23:31:02 +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
68fc159654 Fix listing of serial devices in MSYS2/Cygwin
We generally try to list serial devices by ID but in the MSYS2/Cygwin
environment serial devices are not available by ID and so we simply list
the basic serial device paths instead.
2022-09-10 19:06:18 +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
a58d406a3c Update list description 2022-09-08 09:32:51 +02:00
Peter Collingbourne
db765bc371 Ignore SIGPIPE signals
If the remote end of a socket is closed between when an input character
is received from the serial port and when it is written to the socket,
tio will receive a SIGPIPE signal when writing the character to the
socket, which will terminate the program. To prevent this, ignore the
signal, which will cause write(2) to return -EPIPE, causing tio to close
the socket.
2022-08-17 16:51:15 -07: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
72eb682267 Cleanup hex mode code 2022-08-06 17:12:16 +02:00
Martin Lund
75aa066bf8 Fix potential sscanf() overflow 2022-08-06 16:54:59 +02:00
Martin Lund
15bef05179 Only print version on '--version' 2022-07-28 21:32:00 +02:00
Martin Lund
a9b7284ba2 Revert "Enable log feature when using --log-filename"
This reverts commit c3116b2b56.

On second thought, this is less appropriate when using the configuration
file. We may want to define the log filename in config file but not
necessarily enable log feature.
2022-07-28 21:23:52 +02:00
Martin Lund
70f69899fc Cleanup 2022-07-25 12:48:20 +02:00
Martin Lund
463415d63b Remove duplicate show config entry of DTR pulse duration 2022-07-24 20:57:34 +02:00
Martin Lund
c3116b2b56 Enable log feature when using --log-filename
No reason to not assume that the user wants to enable log when the
--log-filename is used. This way uses can skip the use of --log to
enable log.
2022-07-23 10:40:35 +02:00
Martin Lund
a13fe254f2 Enable line buffering of log
Replace flushing/writing of log at every log write operation with line
buffering, meaning log will be written line by line to make it more I/O
friendly but still update frequently.
2022-07-23 09:53:12 +02:00
Martin Lund
d28007f0d3 Avoid invalid hex character messages when switching hex mode 2022-07-22 22:03:47 +02:00
Martin Lund
c24cbfcd34 Force flushing of log writes 2022-07-22 17:57:11 +02:00
Martin Lund
f454bdaa3a Cleanup 2022-07-22 16:40:15 +02:00
Martin Lund
b322ecbdcf Renamed tty_flush() to tty_sync() 2022-07-22 16:37:49 +02:00
Martin Lund
de606d51ba Fix sync output to serial port
Using fsync() on filedescriptors for serial ports can not be relied on.
Add use of tcdrain() to make sure data has been written by the serial
port before proceeding.

This fixes a problem with tio sometimes not writing piped input data to
the serial port before exiting which results in the pending writes being
cancelled / flushed.
2022-07-22 16:28:38 +02:00
Martin Lund
0cdd69940f Clean up tty_flush() 2022-07-22 00:45:30 +02:00
Martin Lund
dd8b137b15 Force frequent sync on tty_flush() 2022-07-22 00:16:54 +02:00
Martin Lund
6462aac792 Simplify tty_flush() 2022-07-20 20:46:01 +02:00
Martin Lund
5f46136b28 Quit from non-interactive mode using ctrl-c
When piping to tio it will automatically enter "non-interactive" mode
which means it will not react to any input key sequences but simple read
the input stream and write it to the tty device.

This also means that ctrl-t q can not be used to quit and so tio would
hang forever when used in non-interactive mode.

This change allows to send the standard termination signal by pressing
ctrl-c on tio in non-interactive mode to make it quit.
2022-07-20 18:18:16 +02:00
Martin Lund
eadcc7e384 Make sure we flush output buffer to tty when piping to tio 2022-07-20 17:56:43 +02:00
Martin Lund
a0a8dccd51 Do not return false read error when piping to tio 2022-07-20 13:11:11 +02:00
Martin Lund
40c8753151 Show error message when reading port settings fail 2022-07-20 12:25:51 +02:00
Martin Lund
e96d289718 Cleanup 2022-07-19 14:54:02 +02:00