From: Jakob Haufe Date: Tue, 14 Jun 2016 14:14:20 +0000 (+0200) Subject: Imported Upstream version 1.20 X-Git-Tag: upstream/1.20^0 X-Git-Url: https://git.sur5r.net/?p=tio;a=commitdiff_plain;h=4e5d8990fa44d64bbb091bd9f082a4e101c761d8 Imported Upstream version 1.20 --- diff --git a/ChangeLog b/ChangeLog index 7f41639..960e020 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,40 @@ -=== tio v1.18 === +=== tio v1.20 === + +Changes since tio v1.19: + + * Added more error handling of terminal calls + + Also removed duplicate terminal flushing calls. + + * Revert "Added support for non-standard baud rates" + + This reverts commit deec83a4eeddd5c3b2d4df041aede2bceb8867da. + + Reverting because supporting non-standard or arbitrary baud rates is + troublesome because the c library provides no means of doing so and even + if bare metal linux kernel interface is used it will not work on all + Linux kernels version. + + + +Changes since tio v1.18: + + * Rearranged key commands + + Rearranged the key commands: + + ctrl-t c (clear screen) is now + ctrl-t l which is similar to the well known shell ctrl-l + + ctrl-t i (show settings information) is now + ctrl-t c (show configuration) + + Updated man page accordingly. + + * Added "ctrl-t c" key command to clear screen + + Changes since tio v1.17: diff --git a/configure b/configure index ab01973..1a07e8d 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for tio 1.18. +# Generated by GNU Autoconf 2.69 for tio 1.20. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -576,8 +576,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='tio' PACKAGE_TARNAME='tio' -PACKAGE_VERSION='1.18' -PACKAGE_STRING='tio 1.18' +PACKAGE_VERSION='1.20' +PACKAGE_STRING='tio 1.20' PACKAGE_BUGREPORT='' PACKAGE_URL='https://tio.github.io' @@ -1249,7 +1249,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures tio 1.18 to adapt to many kinds of systems. +\`configure' configures tio 1.20 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1316,7 +1316,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of tio 1.18:";; + short | recursive ) echo "Configuration of tio 1.20:";; esac cat <<\_ACEOF @@ -1424,7 +1424,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -tio configure 1.18 +tio configure 1.20 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1525,7 +1525,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by tio $as_me 1.18, which was +It was created by tio $as_me 1.20, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2390,7 +2390,7 @@ fi # Define the identity of the package. PACKAGE='tio' - VERSION='1.18' + VERSION='1.20' cat >>confdefs.h <<_ACEOF @@ -4633,20 +4633,6 @@ cat >>confdefs.h <<_ACEOF _ACEOF -# Check that it is possible to set arbitrary baud rates using BOTHER -ac_fn_c_check_decl "$LINENO" "BOTHER" "ac_cv_have_decl_BOTHER" "#include -" -if test "x$ac_cv_have_decl_BOTHER" = xyes; then : - ac_have_decl=1 -else - ac_have_decl=0 -fi - -cat >>confdefs.h <<_ACEOF -#define HAVE_DECL_BOTHER $ac_have_decl -_ACEOF - - ac_config_files="$ac_config_files Makefile" ac_config_files="$ac_config_files src/Makefile" @@ -5189,7 +5175,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by tio $as_me 1.18, which was +This file was extended by tio $as_me 1.20, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -5256,7 +5242,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -tio config.status 1.18 +tio config.status 1.20 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index e80cb75..57b1d71 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.68]) -AC_INIT([tio], [1.18], [], [tio], [https://tio.github.io]) +AC_INIT([tio], [1.20], [], [tio], [https://tio.github.io]) AC_CONFIG_HEADERS([src/include/config.h]) AM_INIT_AUTOMAKE([1.11 foreign dist-xz no-dist-gzip -Wall -Werror]) AM_SILENT_RULES([yes]) @@ -87,9 +87,6 @@ TIO_CHECK_BAUDRATES( AC_DEFINE_UNQUOTED([AUTOCONF_BAUDRATE_CASES],[$BAUDRATE_CASES],[Switch cases for detected baud rates]) -# Check that it is possible to set arbitrary baud rates using BOTHER -AC_CHECK_DECLS([BOTHER], [], [], [[#include ]]) - AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([src/Makefile]) AC_CONFIG_FILES([src/bash-completion/tio]) diff --git a/man/tio.1 b/man/tio.1 index c71ae84..628723b 100644 --- a/man/tio.1 +++ b/man/tio.1 @@ -70,8 +70,10 @@ Display help. In session, the following key sequences are intercepted as tio commands: .IP "\fBctrl-t ?" List available key commands -.IP "\fBctrl-t i" -Show settings information (baudrate, databits, etc.) +.IP "\fBctrl-t c" +Show configuration (baudrate, databits, etc.) +.IP "\fBctrl-t l" +Clear screen .IP "\fBctrl-t q" Quit .IP "\fBctrl-t s" diff --git a/src/include/config.h.in b/src/include/config.h.in index 213f300..5e68228 100644 --- a/src/include/config.h.in +++ b/src/include/config.h.in @@ -3,10 +3,6 @@ /* Switch cases for detected baud rates */ #undef AUTOCONF_BAUDRATE_CASES -/* Define to 1 if you have the declaration of `BOTHER', and to 0 if you don't. - */ -#undef HAVE_DECL_BOTHER - /* Name of package */ #undef PACKAGE diff --git a/src/include/tio/tty.h b/src/include/tio/tty.h index f0339a0..c2fd813 100644 --- a/src/include/tio/tty.h +++ b/src/include/tio/tty.h @@ -23,7 +23,8 @@ #define TTY_H #define KEY_QUESTION 0x3f -#define KEY_I 0x69 +#define KEY_C 0x63 +#define KEY_L 0x6C #define KEY_Q 0x71 #define KEY_S 0x73 #define KEY_T 0x74 diff --git a/src/tty.c b/src/tty.c index fccd5ff..c4d52b4 100644 --- a/src/tty.c +++ b/src/tty.c @@ -21,6 +21,7 @@ #include "config.h" #include +#include #include #include #include @@ -45,13 +46,8 @@ static struct termios tio, new_stdout, old_stdout, old_tio; static unsigned long rx_total = 0, tx_total = 0; static bool connected = false; static bool tainted = false; -static bool standard_baudrate = true; static int fd; -#ifndef BOTHER -#define BOTHER 0010000 -#endif - #define tio_printf(format, args...) \ { \ if (tainted) putchar('\n'); \ @@ -63,6 +59,7 @@ void handle_command_sequence(char input_char, char previous_char, char *output_c { char unused_char; bool unused_bool; + int __attribute__((unused)) status; /* Ignore unused arguments */ if (output_char == NULL) @@ -79,14 +76,15 @@ void handle_command_sequence(char input_char, char previous_char, char *output_c case KEY_QUESTION: tio_printf("Key commands:"); tio_printf(" ctrl-t ? List available key commands"); - tio_printf(" ctrl-t i Show settings information"); + tio_printf(" ctrl-t c Show configuration"); + tio_printf(" ctrl-t l Clear screen"); tio_printf(" ctrl-t q Quit"); tio_printf(" ctrl-t s Show statistics"); tio_printf(" ctrl-t t Send ctrl-t key code"); *forward = false; break; - case KEY_I: - tio_printf("Settings information:"); + case KEY_C: + tio_printf("Configuration:"); tio_printf(" TTY device: %s", option.tty_device); tio_printf(" Baudrate: %u", option.baudrate); tio_printf(" Databits: %d", option.databits); @@ -98,19 +96,23 @@ void handle_command_sequence(char input_char, char previous_char, char *output_c tio_printf(" Log file: %s", option.log_filename); *forward = false; break; + case KEY_L: + status = system("clear"); + *forward = false; + break; case KEY_Q: /* Exit upon ctrl-t q sequence */ exit(EXIT_SUCCESS); - case KEY_T: - /* Send ctrl-t key code upon ctrl-t t sequence */ - *output_char = KEY_CTRL_T; - break; case KEY_S: /* Show tx/rx statistics upon ctrl-t s sequence */ tio_printf("Statistics:"); tio_printf(" Sent %lu bytes, received %lu bytes", tx_total, rx_total); *forward = false; break; + case KEY_T: + /* Send ctrl-t key code upon ctrl-t t sequence */ + *output_char = KEY_CTRL_T; + break; default: /* Ignore unknown ctrl-t escaped keys */ *forward = false; @@ -121,6 +123,8 @@ void handle_command_sequence(char input_char, char previous_char, char *output_c void stdout_configure(void) { + int status; + /* Save current stdout settings */ if (tcgetattr(STDOUT_FILENO, &old_stdout) < 0) { @@ -142,8 +146,12 @@ void stdout_configure(void) new_stdout.c_cc[VMIN] = 1; /* Blocking read until 1 character received */ /* Activate new stdout settings */ - tcsetattr(STDOUT_FILENO, TCSANOW, &new_stdout); - tcsetattr(STDOUT_FILENO, TCSAFLUSH, &new_stdout); + status = tcsetattr(STDOUT_FILENO, TCSANOW, &new_stdout); + if (status == -1) + { + error_printf("Could not apply new stdout settings (%s)", strerror(errno)); + exit(EXIT_FAILURE); + } /* Print launch hints */ tio_printf("tio v%s", VERSION); @@ -156,12 +164,12 @@ void stdout_configure(void) void stdout_restore(void) { tcsetattr(STDOUT_FILENO, TCSANOW, &old_stdout); - tcsetattr(STDOUT_FILENO, TCSAFLUSH, &old_stdout); } void tty_configure(void) { - speed_t baudrate = 0; + int status; + speed_t baudrate; memset(&tio, 0, sizeof(tio)); @@ -182,24 +190,24 @@ void tty_configure(void) AUTOCONF_BAUDRATE_CASES default: -#if !HAVE_DECL_BOTHER error_printf("Invalid baud rate"); exit(EXIT_FAILURE); -#else - standard_baudrate = false; - break; -#endif } - if (standard_baudrate) + // Set input speed + status = cfsetispeed(&tio, baudrate); + if (status == -1) { - cfsetispeed(&tio, baudrate); - cfsetospeed(&tio, baudrate); - } else + error_printf("Could not configure input speed (%s)", strerror(errno)); + exit(EXIT_FAILURE); + } + + // Set output speed + cfsetospeed(&tio, baudrate); + if (status == -1) { - tio.c_ispeed = tio.c_ospeed = baudrate; - tio.c_cflag &= ~CBAUD; - tio.c_cflag |= BOTHER; + error_printf("Could not configure output speed (%s)", strerror(errno)); + exit(EXIT_FAILURE); } /* Set databits */ @@ -351,7 +359,6 @@ void tty_disconnect(void) void tty_restore(void) { tcsetattr(fd, TCSANOW, &old_tio); - tcsetattr(fd, TCSAFLUSH, &old_tio); if (connected) tty_disconnect(); @@ -392,10 +399,6 @@ int tty_connect(void) /* Flush stale I/O data (if any) */ tcflush(fd, TCIOFLUSH); - /* Warn if non standard baud rate is used */ - if (!standard_baudrate) - tio_printf("Warning: Using a non standard baud rate"); - /* Print connect status */ tio_printf("Connected"); connected = true; @@ -422,8 +425,12 @@ int tty_connect(void) tio.c_cc[VMIN] = 1; /* Blocking read until 1 character received */ /* Activate new port settings */ - tcsetattr(fd, TCSANOW, &tio); - tcsetattr(fd, TCSAFLUSH, &tio); + status = tcsetattr(fd, TCSANOW, &tio); + if (status == -1) + { + error_printf_silent("Could not apply port settings (%s)", strerror(errno)); + goto error_tcsetattr; + } maxfd = MAX(fd, STDIN_FILENO) + 1; /* Maximum bit entry (fd) to test */ @@ -510,6 +517,7 @@ int tty_connect(void) return TIO_SUCCESS; +error_tcsetattr: error_tcgetattr: error_read: tty_disconnect();