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
This commit is contained in:
Martin Lund 2022-08-13 00:04:00 +02:00
parent a75e04b883
commit e837fd0303
9 changed files with 143 additions and 7 deletions

View file

@ -214,6 +214,21 @@ If port is 0 or no port is provided default port 3333 is used.
At present there is a hardcoded limit of 16 clients connected at one time.
.RE
.TP
.BR \-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.
.TP
.BR " \-\-response\-timeout " \fI<ms>
Set timeout [ms] of line response (default: 100).
.TP
.BR \-v ", " \-\-version
@ -339,6 +354,10 @@ Enable hexadecimal mode
Set socket to redirect I/O to
.IP "\fBprefix-ctrl-key"
Set prefix ctrl key (a..z, default: t)
.IP "\fBresponse-wait"
Enable wait for line response
.IP "\fBresponse-timeout"
Set line response timeout
.SH "CONFIGURATION FILE EXAMPLES"
@ -475,7 +494,14 @@ $ nc -N 10.0.0.42 4444
Pipe command to the serial device:
$ echo "ls -la" | tio /dev/serial/by\-id/usb\-FTDI_TTL232R-3V3_FTGQVXBL\-if00\-port0
.TP
Pipe command to the serial device and wait for line response (string ending with CR or NL):
$ echo "*IDN?" | tio /dev/ttyACM0 --response-wait
.TP
In this mode, only the response will be printed.
.TP
Likewise, to pipe data from file to the serial device: