-=== tio v2.2 ===
+=== tio v2.4 ===
+
+
+
+Changes since tio v2.3:
+
+ * Add threaded input handling
+
+ To make tio more responsive to quit and I/O flush key command when main I/O
+ thread is blocked on output.
+
+ * Fix so that is it possible to quit tio in tio etc.
+
+ Fix regression so that it is possible to send the prefix key code to the
+ remote tio session without local tio session reacting to same key code
+ (quitting etc.).
+
+ * Add key command to toggle log on/off
+
+ Add key command 'ctrl-t f' which will toggle log on/off.
+
+ If no log filename has been specified via the 'log-filename' option then
+ tio will automatically generate a new log filename every time the log
+ feature is toggled on. Meaning, when toggled multiple times, multiple
+ log files will be generated.
+
+ However, if a log filename has been specified, tio will only write and
+ append to that same file.
+
+
+
+Changes since tio v2.2:
+
+ * Add mute feature
+
+ This will make tio go fully silent and not print anything.
+
+ * Rename config variable 'tty' to 'device'
+
+ * Deprecate tty config keyword but keep it around for now
+
+ * Update show config
+
+ * Update example tiorc
[![](https://img.shields.io/circleci/build/gh/tio/tio?token=da7e7fd0d0ee99b9f986f8877dcdbe28f73d9e06)](https://circleci.com/gh/tio/tio/tree/master)
[![](https://img.shields.io/github/v/release/tio/tio?sort=semver)](https://github.com/tio/tio/releases)
-[![](https://img.shields.io/tokei/lines/github/tio/tio)](https://github.com/tio/tio)
[![](https://img.shields.io/repology/repositories/tio)](https://repology.org/project/tio/versions)
+[![](https://img.shields.io/tokei/lines/github/tio/tio)](https://github.com/tio/tio)
## 1. Introduction
```
Usage: tio [<options>] <tty-device|sub-config>
- Connect to tty device directly or via sub-configuration.
+ Connect to TTY device directly or via sub-configuration.
Options:
-b, --baudrate <bps> Baud rate (default: 115200)
$ tio -b 115200 -d 8 -f none -s 1 -p none /dev/ttyUSB0
```
-It is recommended to connect serial tty devices by ID:
+It is recommended to connect serial TTY devices by ID:
```
$ tio /dev/serial/by-id/usb-FTDI_TTL232R-3V3_FTGQVXBL-if00-port0
```
$ tio --list-devices
```
Note: One can also use tio shell completion on /dev which will automatically
-list all available serial tty devices.
+list all available serial TTY devices.
Log to file with autogenerated filename:
```
[20:19:12.040] ctrl-t b Send break
[20:19:12.040] ctrl-t c Show configuration
[20:19:12.040] ctrl-t e Toggle local echo mode
+[20:19:12.040] ctrl-t f Toggle log to file
[20:19:12.040] ctrl-t g Toggle serial port line
[20:19:12.040] ctrl-t h Toggle hexadecimal mode
[20:19:12.040] ctrl-t l Clear screen
The configuration file supports sub-configurations using named sections which can
be activated via the command-line by name or pattern. A sub-configuration
-specifies which tty to connect to and other options.
+specifies which TTY device to connect to and other options.
Example configuration file:
color = 10
[rpi3]
-tty = /dev/serial/by-id/usb-FTDI_TTL232R-3V3_FTGQVXBL-if00-port0
+device = /dev/serial/by-id/usb-FTDI_TTL232R-3V3_FTGQVXBL-if00-port0
baudrate = 115200
no-autoconnect = enable
log = enable
[usb devices]
pattern = usb([0-9]*)
-tty = /dev/ttyUSB%s
+device = /dev/ttyUSB%s
color = 13
```
+ * Allow tio to connect to socket
+
+ After some more consideration I think it makes sense to support connecting to a
+ socket as that will make tio be able to both serve a serial port via a socket
+ and connect to it - it will be an end to end solution. In short we will be able
+ to do the following:
+
+ Host serial port on socket (existing feature):
+ $ tio --socket unix:/tmp/tio-socket-0 /dev/ttyUSB0
+
+ Connect to same socket (new feature):
+ $ tio unix:/tmp/tio-socket-0
+
+ Besides a bit of refactoring the following required changes spring to mind:
+
+ * Socket mode and type of socket should be activated via device name prefix. For example:
+ * UNIX socket: tio unix:<filename>
+ * TCPv4 socket: tio inet:<ip>:<port>
+ * TCPv6 socket: tio inet6:<ip>:<port>
+ * If no port number defined default to 3333
+ * Mapping flags INLCR, IGNCR, ICRNL needs implementation for socket mode
+ * Error messages should just say "device" instead of "tty device" etc.
+ * Remove other tty'isms (tty_write() should be device_write() etc.)
+ * In session key commands that do not work in socket mode should either not be listed or print an error messages if used.
+ * All non-tty features should continue work (auto-connect etc.)
+ * Shell completion script update
+ * Man page update
+
+
* Split I/O feature
Allow to split input and output so that it is possible to manage these
[rpi3]
baudrate = 115200
-tty = /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A6009HU3-if00-port0
+device = /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A6009HU3-if00-port0
socket = unix:/tmp/tio-socket-0
color = 9
[am64-evm]
baudrate = 115200
-tty = /dev/serial/by-id/usb-Silicon_Labs_CP2105_Dual_USB_to_UART_Bridge_Controller_01093176-if01-port0
+device = /dev/serial/by-id/usb-Silicon_Labs_CP2105_Dual_USB_to_UART_Bridge_Controller_01093176-if01-port0
line-pulse-duration = DTR=200,RTS=300,RI=50
alert = bell
color = 10
[tincan]
baudrate = 9600
-tty = /dev/serial/by-id/usb-TinCanTools_Flyswatter2_FS20000-if00-port0
+device = /dev/serial/by-id/usb-TinCanTools_Flyswatter2_FS20000-if00-port0
log = enable
log-file = tincan.log
log-strip = enable
color = 11
-[usb devices]
+[usb]
pattern = usb([0-9]*)
-tty = /dev/ttyUSB%s
+device = /dev/ttyUSB%s
color = 12
[rs-485-device]
-tty = /dev/ttyUSB0
+device = /dev/ttyUSB0
rs-485 = enable
rs-485-config = RTS_ON_SEND=1,RTS_AFTER_SEND=1,RTS_DELAY_BEFORE_SEND=60,RTS_DELAY_AFTER_SEND=80,RX_DURING_TX
color = 13
Show configuration (baudrate, databits, etc.)
.IP "\fBctrl-t e"
Toggle local echo mode
+.IP "\fBctrl-t f"
+Toggle log to file
+.IP "\fBctrl-t F"
+Flush data I/O buffers (discard data written but not transmitted and data received but not read)
.IP "\fBctrl-t g"
Toggle serial port line
.IP "\fBctrl-t h"
.PP
\fBtio\fR will try to match the user input to a sub-configuration by name or by
-pattern to get the tty and other options.
+pattern to get the TTY device and other options.
.PP
Options without any label change the default options.
.TP 25n
.IP "\fBpattern"
Pattern matching user input. This pattern can be an extended regular expression with a single group.
-.IP "\fBtty"
-tty device to open. If it contains a "%s" it is substituted with the first group match.
+.IP "\fBdevice"
+TTY device to open. If it contains a "%s" it is substituted with the first group match.
.IP "\fBbaudrate"
Set baud rate
.IP "\fBdatabits"
.nf
.eo
[rpi3]
-tty = /dev/serial/by-id/usb-FTDI_TTL232R-3V3_FTGQVXBL-if00-port0
+device = /dev/serial/by-id/usb-FTDI_TTL232R-3V3_FTGQVXBL-if00-port0
baudrate = 115200
color = 11
.ec
.eo
[usb device]
pattern = usb([0-9]*)
-tty = /dev/ttyUSB%s
+device = /dev/ttyUSB%s
baudrate = 115200
.ec
.fi
$ tio \-b 115200 \-d 8 \-f none \-s 1 \-p none /dev/ttyUSB0
.TP
-It is recommended to connect serial tty devices by ID:
+It is recommended to connect serial TTY devices by ID:
$ tio /dev/serial/by\-id/usb\-FTDI_TTL232R-3V3_FTGQVXBL\-if00\-port0
.PP
.RE
.TP
-Redirect device I/O to network file socket for remote tty sharing:
+Redirect device I/O to network file socket for remote TTY sharing:
$ tio --socket inet:4444 /dev/ttyUSB0
.TP
-Then, use netcat to connect to the shared tty session over network (assuming tio is hosted on IP 10.0.0.42):
+Then, use netcat to connect to the shared TTY session over network (assuming tio is hosted on IP 10.0.0.42):
$ nc -N 10.0.0.42 4444
ctrl-t e Toggle local echo mode
+ ctrl-t f Toggle log to file
+
+ ctrl-t F Flush data I/O buffers (discard data written but not transmitted and data received but not read)
+
ctrl-t g Toggle serial port line
ctrl-t h Toggle hexadecimal mode
Labels can be used to group settings into named sub-configurations which can be activated from the command-line when starting tio.
- tio will try to match the user input to a sub-configuration by name or by pattern to get the tty and other options.
+ tio will try to match the user input to a sub-configuration by name or by pattern to get the TTY device and other options.
Options without any label change the default options.
pattern Pattern matching user input. This pattern can be an extended regular expression with a single group.
- tty tty device to open. If it contains a "%s" it is substituted with the first group match.
+ device TTY device to open. If it contains a "%s" it is substituted with the first group match.
baudrate Set baud rate
Named sub-configurations can be added via labels:
[rpi3]
- tty = /dev/serial/by-id/usb-FTDI_TTL232R-3V3_FTGQVXBL-if00-port0
+ device = /dev/serial/by-id/usb-FTDI_TTL232R-3V3_FTGQVXBL-if00-port0
baudrate = 115200
color = 11
[usb device]
pattern = usb([0-9]*)
- tty = /dev/ttyUSB%s
+ device = /dev/ttyUSB%s
baudrate = 115200
Activate the sub-configuration by pattern match:
$ tio -b 115200 -d 8 -f none -s 1 -p none /dev/ttyUSB0
- It is recommended to connect serial tty devices by ID:
+ It is recommended to connect serial TTY devices by ID:
$ tio /dev/serial/by-id/usb-FTDI_TTL232R-3V3_FTGQVXBL-if00-port0
send -i $uart "ls -la\n"
expect -i $uart "prompt> "
- Redirect device I/O to network file socket for remote tty sharing:
+ Redirect device I/O to network file socket for remote TTY sharing:
$ tio --socket inet:4444 /dev/ttyUSB0
- Then, use netcat to connect to the shared tty session over network (assuming tio is hosted on IP 10.0.0.42):
+ Then, use netcat to connect to the shared TTY session over network (assuming tio is hosted on IP 10.0.0.42):
$ nc -N 10.0.0.42 4444
AUTHOR
Created by Martin Lund <martin.lund@keep-it-simple.com>.
-tio 2.2 2022-10-18 tio(1)
+tio 2.4 2022-11-02 tio(1)
project('tio', 'c',
- version : '2.2',
+ version : '2.4',
license : [ 'GPL-2'],
meson_version : '>= 0.53.2',
default_options : [ 'warning_level=2', 'buildtype=release', 'c_std=gnu99' ]
)
# The tag date of the project_version(), update when the version bumps.
-version_date = '2022-10-18'
+version_date = '2022-11-02'
# Test for dynamic baudrate configuration interface
compiler = meson.get_compiler('c')
--rs-485 \
--rs-485-config \
--alert \
+ --mute \
-v --version \
-h --help"
COMPREPLY=( $(compgen -W "none bell blink" -- ${cur}) )
return 0
;;
+ --mute)
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
+ ;;
-v | --version)
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
if (!strcmp(section, c.section_name))
{
// Set configuration parameter if found
- if (!strcmp(name, "tty"))
+ if (!strcmp(name, "device") || !strcmp(name, "tty"))
{
asprintf(&c.tty, value, c.match);
option.tty_device = c.tty;
{
option.alert = alert_option_parse(value);
}
+ else if (!strcmp(name, "mute"))
+ {
+ if (!strcmp(value, "enable"))
+ {
+ option.mute = true;
+ }
+ else if (!strcmp(value, "disable"))
+ {
+ option.mute = false;
+ }
+ }
}
return 0;
{
if (c.path != NULL)
{
- tio_printf(" Path: %s", c.path);
+ tio_printf(" Active configuration file: %s", c.path);
if (c.section_name != NULL)
{
tio_printf(" Active sub-configuration: %s", c.section_name);
#define IS_ESC_END_CHAR(c) ((c >= 0x30) && (c <= 0x7E))
#define IS_CTRL_CHAR(c) ((c >= 0x00) && (c <= 0x1F))
-static FILE *fp;
-static bool log_error = false;
+static FILE *fp = NULL;
static char file_buffer[BUFSIZ];
+static const char *log_filename = NULL;
static char *date_time(void)
{
return date_time_string;
}
-void log_open(const char *filename)
+int log_open(const char *filename)
{
static char automatic_filename[400];
// Generate filename if none provided ("tio_DEVICE_YYYY-MM-DDTHH:MM:SS.log")
sprintf(automatic_filename, "tio_%s_%s.log", basename((char *)option.tty_device), date_time());
filename = automatic_filename;
- option.log_filename = automatic_filename;
}
+ log_filename = filename;
+
// Open log file in append write mode
fp = fopen(filename, "a+");
if (fp == NULL)
{
- log_error = true;
- exit(EXIT_FAILURE);
+ tio_warning_printf("Could not open log file %s (%s)", filename, strerror(errno));
+ return -1;
}
// Enable line buffering
setvbuf(fp, file_buffer, _IOLBF, BUFSIZ);
+
+ return 0;
}
bool log_strip(char c)
void log_printf(const char *format, ...)
{
+ if (fp == NULL)
+ {
+ return;
+ }
+
char *line;
va_list(args);
void log_putc(char c)
{
- if (fp != NULL)
+ if (fp == NULL)
{
- if (option.log_strip)
- {
- if (!log_strip(c))
- {
- fputc(c, fp);
- }
- }
- else
+ return;
+ }
+
+ if (option.log_strip)
+ {
+ if (!log_strip(c))
{
fputc(c, fp);
}
}
+ else
+ {
+ fputc(c, fp);
+ }
}
void log_close(void)
if (fp != NULL)
{
fclose(fp);
+ fp = NULL;
+ log_filename = NULL;
}
}
{
if (option.log)
{
+ tio_printf("Saved log to file %s", log_filename);
log_close();
}
+}
- if (log_error)
- {
- tio_error_printf("Could not open log file %s (%s)", option.log_filename, strerror(errno));
- }
- else if (option.log)
- {
- tio_printf("Saved log to file %s", option.log_filename);
- }
+const char *log_get_filename(void)
+{
+ return log_filename;
}
#pragma once
-void log_open(const char *filename);
+int log_open(const char *filename);
void log_printf(const char *format, ...);
void log_putc(char c);
void log_close(void);
void log_exit(void);
+const char * log_get_filename(void);
socket_configure();
}
+ /* Spawn input handling into separate thread */
+ tty_input_thread_create();
+
+ /* Wait for input to be ready */
+ tty_input_thread_wait_ready();
+
/* Connect to tty device */
if (option.no_autoconnect)
{
'alert.c'
]
-tio_dep = dependency('inih', required: true,
+tio_dep = [
+ dependency('threads', required: true),
+ dependency('inih', required: true,
fallback : ['libinih', 'inih_dep'],
default_options: ['default_library=static', 'distro_install=false'])
+]
tio_c_args = ['-Wno-unused-result']
#include "rs485.h"
#include "timestamp.h"
#include "alert.h"
+#include "log.h"
enum opt_t
{
OPT_RS485_CONFIG,
OPT_ALERT,
OPT_COMPLETE_SUB_CONFIGS,
+ OPT_MUTE,
};
/* Default options */
printf("Usage: tio [<options>] <tty-device|sub-config>\n");
printf("\n");
- printf("Connect to tty device directly or via sub-configuration.\n");
+ printf("Connect to TTY device directly or via sub-configuration.\n");
printf("\n");
printf("Options:\n");
printf(" -b, --baudrate <bps> Baud rate (default: 115200)\n");
printf(" --rs-485 Enable RS-485 mode\n");
printf(" --rs-485-config <config> Set RS-485 configuration\n");
printf(" --alert bell|blink|none Alert on connect/disconnect (default: none)\n");
+ printf(" --mute Mute tio\n");
printf(" -v, --version Display version\n");
printf(" -h, --help Display help\n");
printf("\n");
void options_print()
{
- tio_printf(" TTY device: %s", option.tty_device);
+ tio_printf(" Device: %s", option.tty_device);
tio_printf(" Baudrate: %u", option.baudrate);
tio_printf(" Databits: %d", option.databits);
tio_printf(" Flow: %s", option.flow);
if (option.map[0] != 0)
tio_printf(" Map flags: %s", option.map);
if (option.log)
- tio_printf(" Log file: %s", option.log_filename);
+ tio_printf(" Log file: %s", log_get_filename());
if (option.socket)
tio_printf(" Socket: %s", option.socket);
}
{"rs-485", no_argument, 0, OPT_RS485 },
{"rs-485-config", required_argument, 0, OPT_RS485_CONFIG },
{"alert", required_argument, 0, OPT_ALERT },
+ {"mute", no_argument, 0, OPT_MUTE },
{"version", no_argument, 0, 'v' },
{"help", no_argument, 0, 'h' },
{"complete-sub-configs", no_argument, 0, OPT_COMPLETE_SUB_CONFIGS},
option.alert = alert_option_parse(optarg);
break;
+ case OPT_MUTE:
+ option.mute = true;
+ break;
+
case 'v':
printf("tio v%s\n", VERSION);
exit(EXIT_SUCCESS);
#include <errno.h>
#include <time.h>
#include <dirent.h>
+#include <pthread.h>
#include "config.h"
#include "configfile.h"
#include "tty.h"
#define KEY_B 0x62
#define KEY_C 0x63
#define KEY_E 0x65
+#define KEY_F 0x66
+#define KEY_SHIFT_F 0x46
#define KEY_G 0x67
#define KEY_H 0x68
#define KEY_L 0x6C
static char tty_buffer[BUFSIZ*2];
static size_t tty_buffer_count = 0;
static char *tty_buffer_write_ptr = tty_buffer;
+static pthread_t thread;
+static int pipefd[2];
+static pthread_mutex_t mutex_input_ready = PTHREAD_MUTEX_INITIALIZER;
static void optional_local_echo(char c)
{
return bytes_written;
}
+void *tty_stdin_input_thread(void *arg)
+{
+ UNUSED(arg);
+ char input_buffer[BUFSIZ];
+ ssize_t byte_count;
+ ssize_t bytes_written;
+
+ // Create FIFO pipe
+ if (pipe(pipefd) == -1)
+ {
+ tio_error_printf("Failed to create pipe");
+ exit(EXIT_FAILURE);
+ }
+
+ // Signal that input pipe is ready
+ pthread_mutex_unlock(&mutex_input_ready);
+
+ // Input loop for stdin
+ while (1)
+ {
+ /* Input from stdin ready */
+ byte_count = read(STDIN_FILENO, input_buffer, BUFSIZ);
+ if (byte_count < 0)
+ {
+ tio_warning_printf("Could not read from stdin (%s)", strerror(errno));
+ }
+ else if (byte_count == 0)
+ {
+ // Close write end to signal EOF in read end
+ close(pipefd[1]);
+ pthread_exit(0);
+ }
+
+ if (interactive_mode)
+ {
+ static char previous_char = 0;
+ char input_char;
+
+ // Process quit and flush key command
+ for (int i = 0; i<byte_count; i++)
+ {
+ input_char = input_buffer[i];
+
+ if (previous_char == option.prefix_code)
+ {
+ switch (input_char)
+ {
+ case KEY_Q:
+ exit(EXIT_FAILURE);
+ break;
+ case KEY_SHIFT_F:
+ tio_printf("Flushed data I/O channels")
+ tcflush(fd, TCIOFLUSH);
+ break;
+ default:
+ break;
+ }
+ }
+ previous_char = input_char;
+ }
+ }
+
+ // Write all bytes read to pipe
+ while (byte_count)
+ {
+ bytes_written = write(pipefd[1], input_buffer, byte_count);
+ if (bytes_written < 0)
+ {
+ tio_warning_printf("Could not write to pipe (%s)", strerror(errno));
+ break;
+ }
+ byte_count -= bytes_written;
+ }
+ }
+
+ pthread_exit(0);
+}
+
+void tty_input_thread_create(void)
+{
+ pthread_mutex_lock(&mutex_input_ready);
+
+ if (pthread_create(&thread, NULL, tty_stdin_input_thread, NULL) != 0) {
+ tio_error_printf("pthread_create() error");
+ exit(1);
+ }
+}
+
+void tty_input_thread_wait_ready(void)
+{
+ pthread_mutex_lock(&mutex_input_ready);
+}
+
static void output_hex(char c)
{
hex_chars[hex_char_index++] = c;
}
}
-void handle_command_sequence(char input_char, char previous_char, char *output_char, bool *forward)
+void handle_command_sequence(char input_char, char *output_char, bool *forward)
{
char unused_char;
bool unused_bool;
int state;
static enum line_mode_t line_mode = LINE_OFF;
+ static char previous_char = 0;
/* Ignore unused arguments */
if (output_char == NULL)
/* Do not forward input char to output by default */
*forward = false;
+ /* Handle special double prefix key input case */
+ if (input_char == option.prefix_code)
+ {
+ /* Forward prefix character to tty */
+ *output_char = option.prefix_code;
+ *forward = true;
+ previous_char = 0;
+ return;
+ }
+
switch (input_char)
{
case KEY_QUESTION:
tio_printf(" ctrl-%c b Send break", option.prefix_key);
tio_printf(" ctrl-%c c Show configuration", option.prefix_key);
tio_printf(" ctrl-%c e Toggle local echo mode", option.prefix_key);
+ tio_printf(" ctrl-%c f Toggle log to file", option.prefix_key);
+ tio_printf(" ctrl-%c F Flush data I/O buffers", option.prefix_key);
tio_printf(" ctrl-%c g Toggle serial port line", option.prefix_key);
tio_printf(" ctrl-%c h Toggle hexadecimal mode", option.prefix_key);
tio_printf(" ctrl-%c l Clear screen", option.prefix_key);
tio_printf(" RI : %s", (state & TIOCM_RI) ? "HIGH" : "LOW");
break;
+ case KEY_F:
+ if (option.log)
+ {
+ log_close();
+ option.log = false;
+ }
+ else
+ {
+ if (log_open(option.log_filename) == 0)
+ {
+ option.log = true;
+ }
+ }
+ tio_printf("Switched log to file %s", option.log ? "on" : "off");
+ break;
+
+ case KEY_SHIFT_F:
+ break;
+
case KEY_G:
tio_printf("Please enter which serial line number to toggle:");
tio_printf(" DTR (0)");
case KEY_C:
tio_printf("Configuration:");
- config_file_print();
options_print();
+ config_file_print();
if (option.rs485)
{
rs485_print_config();
break;
default:
- /* Handle double prefix key input case */
- if (input_char == option.prefix_code)
- {
- static int count = 0;
- if (count++ == 1)
- {
- // Do not forward prefix characters excessively
- count = 0;
- break;
- }
-
- /* Forward prefix character to tty */
- *output_char = option.prefix_code;
- *forward = true;
- break;
- }
-
/* Ignore unknown ctrl-t escaped keys */
break;
}
}
+
+ previous_char = input_char;
}
void stdin_restore(void)
int status;
int maxfd;
struct timeval tv;
- static char input_char, previous_char = 0;
+ static char input_char;
static bool first = true;
static int last_errno = 0;
}
FD_ZERO(&rdfs);
- FD_SET(STDIN_FILENO, &rdfs);
- maxfd = MAX(STDIN_FILENO, socket_add_fds(&rdfs, false));
+ FD_SET(pipefd[0], &rdfs);
+ maxfd = MAX(pipefd[0], socket_add_fds(&rdfs, false));
/* Block until input becomes available or timeout */
status = select(maxfd + 1, &rdfs, NULL, NULL, &tv);
if (status > 0)
{
- if (FD_ISSET(STDIN_FILENO, &rdfs))
+ if (FD_ISSET(pipefd[0], &rdfs))
{
/* Input from stdin ready */
/* Read one character */
- status = read(STDIN_FILENO, &input_char, 1);
+ status = read(pipefd[0], &input_char, 1);
if (status <= 0)
{
tio_error_printf("Could not read from stdin");
}
/* Handle commands */
- handle_command_sequence(input_char, previous_char, NULL, NULL);
-
- previous_char = input_char;
+ handle_command_sequence(input_char, NULL, NULL);
}
socket_handle_input(&rdfs, NULL);
}
int maxfd; /* Maximum file descriptor used */
char input_char, output_char;
char input_buffer[BUFSIZ];
- static char previous_char = 0;
static bool first = true;
int status;
bool next_timestamp = false;
FD_SET(fd, &rdfs);
if (!ignore_stdin)
{
- FD_SET(STDIN_FILENO, &rdfs);
+ FD_SET(pipefd[0], &rdfs);
}
- maxfd = MAX(fd, STDIN_FILENO);
+ maxfd = MAX(fd, pipefd[0]);
maxfd = MAX(maxfd, socket_add_fds(&rdfs, true));
/* Manage timeout */
}
}
}
- else if (FD_ISSET(STDIN_FILENO, &rdfs))
+ else if (FD_ISSET(pipefd[0], &rdfs))
{
/* Input from stdin ready */
- ssize_t bytes_read = read(STDIN_FILENO, input_buffer, BUFSIZ);
+ ssize_t bytes_read = read(pipefd[0], input_buffer, BUFSIZ);
if (bytes_read < 0)
{
tio_error_printf_silent("Could not read from stdin (%s)", strerror(errno));
}
/* Handle commands */
- handle_command_sequence(input_char, previous_char, &output_char, &forward);
-
- /* Save previous key */
- previous_char = input_char;
+ handle_command_sequence(input_char, &output_char, &forward);
if ((option.hex_mode) && (forward))
{
}
else
{
+ /* Input from socket ready */
forward = socket_handle_input(&rdfs, &output_char);
if (forward)
int tty_connect(void);
void tty_wait_for_device(void);
void list_serial_devices(void);
+void tty_input_thread_create(void);
+void tty_input_thread_wait_ready(void);