mirror of
https://github.com/tio/tio.git
synced 2026-05-01 23:07:58 +02:00
Enter non-interactive mode when piping to tio
Add support for a non interactive mode which allows other application to pipe data to tio which then forwards the data to the connected serial device. Non ineractive means that tio does not react to interactive key commands in the incoming stream. This allows users to pipe binary data directly to the connected serial device. Example use: $ cat commands.txt | tio /dev/ttyUSB0
This commit is contained in:
parent
a37ad26a88
commit
dba77eb912
3 changed files with 27 additions and 9 deletions
20
src/tty.c
20
src/tty.c
|
|
@ -63,6 +63,8 @@ extern int iossiospeed(int fd, int baudrate);
|
|||
#define PATH_SERIAL_DEVICES "/dev/serial/by-id/"
|
||||
#endif
|
||||
|
||||
bool interactive_mode = true;
|
||||
|
||||
static struct termios tio, tio_old, stdout_new, stdout_old, stdin_new, stdin_old;
|
||||
static unsigned long rx_total = 0, tx_total = 0;
|
||||
static bool connected = false;
|
||||
|
|
@ -855,17 +857,21 @@ int tty_connect(void)
|
|||
goto error_read;
|
||||
}
|
||||
|
||||
/* Forward input to output except ctrl-t key */
|
||||
/* Forward input to output */
|
||||
output_char = input_char;
|
||||
if (input_char == KEY_CTRL_T)
|
||||
forward = false;
|
||||
|
||||
/* Handle commands */
|
||||
handle_command_sequence(input_char, previous_char, &output_char, &forward);
|
||||
if (interactive_mode)
|
||||
{
|
||||
/* Do not forward ctrl-t key */
|
||||
if (input_char == KEY_CTRL_T)
|
||||
forward = false;
|
||||
|
||||
/* Save previous key */
|
||||
previous_char = input_char;
|
||||
/* Handle commands */
|
||||
handle_command_sequence(input_char, previous_char, &output_char, &forward);
|
||||
|
||||
/* Save previous key */
|
||||
previous_char = input_char;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue