Fix line termination for response wait feature

The response wait feature waited for a line response, a string
terminated with either CR or NL. However, some devices may send a CR and
then their line content and then NL. This means tio will quit before
receiving and printing the line response. To solve this we simply ignore
the CR character and only consider lines terminated with a NL character.

This should work for all devices as lines are AFAIK always terminated
with either CRNL or a NL.
This commit is contained in:
Martin Lund 2023-04-20 17:28:39 +02:00
parent b5ca54c56e
commit 8fe5dde4b8
2 changed files with 3 additions and 3 deletions

View file

@ -220,8 +220,8 @@ At present there is a hardcoded limit of 16 clients connected at one time.
.TP .TP
.BR \-r ", " \-\-response-wait .BR \-r ", " \-\-response-wait
Wait for line response then quit. A line is considered any string ending with Wait for line response then quit. A line is considered any string terminated
either CR or NL character. If no line is received tio will quit after response with a NL character. If no line is received tio will quit after response
timeout. timeout.
Any tio text is automatically muted when piping a string to tio while in Any tio text is automatically muted when piping a string to tio while in

View file

@ -1426,7 +1426,7 @@ int tty_connect(void)
if (option.response_wait) if (option.response_wait)
{ {
if ((input_char == '\r') || (input_char == '\n')) if (input_char == '\n')
{ {
tty_sync(fd); tty_sync(fd);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);