Added key command for showing session settings

A new key command "ctrl-t i" is added to allow the user to display the
various session settings information (baudrate, databits, log file, etc.).

This is usefull in case you have a running session but have forgotten
what the settings are.
This commit is contained in:
Martin Lund 2016-05-18 15:29:09 +02:00
parent d180b9f336
commit ffe87bc566
5 changed files with 40 additions and 9 deletions

View file

@ -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

View file

@ -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;

View file

@ -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

View file

@ -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;

View file

@ -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);