diff --git a/man/tio.1 b/man/tio.1 index 953ecf5..38f1e84 100644 --- a/man/tio.1 +++ b/man/tio.1 @@ -61,6 +61,8 @@ Display help. .PP .TP 16n In session, the following key sequences are intercepted as tio commands: +.IP "\fBctrl-t i" +Show session settings information (baudrate, databits, etc.) .IP "\fBctrl-t q" Quit .IP "\fBctrl-t s" @@ -70,11 +72,11 @@ Send ctrl-t key code .SH "EXAMPLES" .TP -The most common use is without options. For example: +A typical use is without options. For example: tio /dev/ttyUSB0 .TP -Which corresponds to: +Which corresponds to the commonly used options: tio \-b 115200 \-d 8 \-f none \-s 1 \-p none /dev/ttyUSB0 .TP diff --git a/src/include/tio/options.h b/src/include/tio/options.h index 09e65b3..925a93f 100644 --- a/src/include/tio/options.h +++ b/src/include/tio/options.h @@ -36,6 +36,11 @@ struct option_t bool no_autoconnect; int output_delay; struct termios tio; + int baudrate; + int databits; + char *flow; + int stopbits; + char *parity; }; extern struct option_t option; diff --git a/src/include/tio/tty.h b/src/include/tio/tty.h index cab663e..61c8487 100644 --- a/src/include/tio/tty.h +++ b/src/include/tio/tty.h @@ -22,6 +22,7 @@ #ifndef TTY_H #define TTY_H +#define KEY_I 0x69 #define KEY_Q 0x71 #define KEY_S 0x73 #define KEY_T 0x74 diff --git a/src/options.c b/src/options.c index 15b6f2a..7eb964b 100644 --- a/src/options.c +++ b/src/options.c @@ -39,6 +39,12 @@ struct option_t option = "", // Log filename false, // No autoconnect 0, // No output delay + {}, + 115200, // Baudrate + 8, // Databits + "none", // Flow + 1, // Stopbits + "none" // Parity }; void print_options_help(char *argv[]) @@ -65,8 +71,6 @@ void parse_options(int argc, char *argv[]) { int c; int baudrate; - int databits; - int stopbits; if (argc == 1) { @@ -122,7 +126,7 @@ void parse_options(int argc, char *argv[]) break; case 'b': - baudrate = atoi(optarg); + option.baudrate = baudrate = atoi(optarg); switch (baudrate) { case 0: @@ -223,9 +227,9 @@ void parse_options(int argc, char *argv[]) break; case 'd': - databits = atoi(optarg); + option.databits = atoi(optarg); option.tio.c_cflag &= ~CSIZE; - switch (databits) + switch (option.databits) { case 5: option.tio.c_cflag |= CS5; @@ -246,6 +250,8 @@ void parse_options(int argc, char *argv[]) break; case 'f': + option.flow = optarg; + if (strcmp("hard", optarg) == 0) { option.tio.c_cflag |= CRTSCTS; @@ -269,8 +275,8 @@ void parse_options(int argc, char *argv[]) break; case 's': - stopbits = atoi(optarg); - switch (stopbits) + option.stopbits = atoi(optarg); + switch (option.stopbits) { case 1: option.tio.c_cflag &= ~CSTOPB; @@ -285,6 +291,8 @@ void parse_options(int argc, char *argv[]) break; case 'p': + option.parity = optarg; + if (strcmp("odd", optarg) == 0) { option.tio.c_cflag |= PARENB; diff --git a/src/tty.c b/src/tty.c index 6d318ac..3b9a38f 100644 --- a/src/tty.c +++ b/src/tty.c @@ -62,6 +62,21 @@ void handle_command_sequence(char input_char, char previous_char, char *output_c { switch (input_char) { + case KEY_I: + if (tainted) + putchar('\n'); + color_printf("[tio %s] TTY device: %s", current_time(), option.tty_device); + color_printf("[tio %s] Baudrate: %d", current_time(), option.baudrate); + color_printf("[tio %s] Databits: %d", current_time(), option.databits); + color_printf("[tio %s] Flow: %s", current_time(), option.flow); + color_printf("[tio %s] Stopbits: %d", current_time(), option.stopbits); + color_printf("[tio %s] Parity: %s", current_time(), option.parity); + color_printf("[tio %s] Output delay: %d", current_time(), option.output_delay); + if (option.log) + color_printf("[tio %s] Log file: %s", current_time(), option.log_filename); + tainted = false; + *forward = false; + break; case KEY_Q: /* Exit upon ctrl-t q sequence */ exit(EXIT_SUCCESS);