Adam Borowski <kilobyte@angband.pl>
Robert Scheck <robert@fedoraproject.org>
Dmitri Goutnik <dg@syrec.org>
+Daniel Engberg <daniel.engberg.lists@pyret.net>
+Petr Vaněk <pv@excello.cz>
Thanks to everyone who has contributed to this project.
-=== tio v1.26 ===
+=== tio v1.29 ===
+
+
+
+Changes since tio v1.28:
+
+ * Add mapping flags INLCRNL and ODELBS
+
+ The following new mapping flags are added:
+
+ INLCRNL: Map NL to CR-NL on input.
+ ODELBS: Map DEL to BS on output.
+
+ Flags requested and tested by Jan Ciger (janoc).
+
+
+
+Changes since tio v1.27:
+
+ * Update README
+
+ * Update AUTHORS
+
+ * Add snap status to README.md
+
+ * Add README.md to prettify GitHub page
+
+ * Add missing header
+
+Petr Vaněk:
+
+ * Add missing header file under musl-libc
+
+ Musl's inclusion tree slightly differs from glibc, therefore TCGETS2 is
+ not reachable through sys/ioctl.h, so asm/ioctls.h needs to be included
+ too.
+
+Jakub Wilk:
+
+ * Fix grammar and typos
+
+
+
+Changes since tio v1.26:
+
+ * Update man page
+
+ * Add support for setting non-standard baudrates
+
+ Support for non-standard baudrate settings will be automatically enabled
+ if the termios2 interface is detected available. However, to play it
+ safe, the old and widely supported termios interface will still be used
+ when setting standard baudrates.
+
+ * Cleanup
+
+ * Update AUTHORS
+
Changes since tio v1.25:
* Add special character map feature
- Add a --map option which allows to map special characters, in particular CR and
- NL characters which are used in various combinations on varios platforms.
+ Add a --map option which allows mapping special characters, in particular CR and
+ NL characters which are used in various combinations on various platforms.
* Cleanup
"Error: Could not apply new stdout settings (Invalid argument)"
In case of Fedora, it turns out that the new stdout settings used are a
- bit too agressive because an empty termios structure is used. To remedy
+ bit too aggressive because an empty termios structure is used. To remedy
this we reuse the existing stdout settings and only reconfigure the
specific options we need to make a "raw" stdout configuration.
* Fix typos
+
Changes since tio v1.21:
* Update man page date
* Fixed silly "tio or tio" in man page
* Fixed typo
+
-################################################################################
-################# tio - a simple TTY terminal I/O application ##################
-################################################################################
+=== tio - a simple TTY terminal I/O application ===
1. Introduction
- "tio" is a simple TTY terminal application which features a straightforward
+ tio is a simple TTY terminal application which features a straightforward
commandline interface to easily connect to TTY devices for basic
input/output.
- It was created because the author needed a simple no-nonsense TTY
- terminal application to easily connect to various terminal TTY devices.
+ It was created because the author needed a simple no-nonsense TTY terminal
+ application to easily connect to various terminal TTY devices.
2. Usage
By default tio automatically connects to the provided device if present.
If the device is not present, it will wait for it to appear and then
- connect. If the connection is lost (eg. device disconnects), it will wait
- for the device to reappear and then reconnect.
-
- However, if the --no-autoconnect option is provided, tio will exit if the
- device is not present or an established connection is lost.
+ connect. If the connection is lost (eg. device is unplugged), it will wait
+ for the device to reappear and then reconnect. However, if the
+ --no-autoconnect option is provided, tio will exit if the device is not
+ present or an established connection is lost.
Tio features full bash autocompletion support.
See the tio man page for more details.
-3. Download
-
- The latest release tarball is available at https://tio.github.io
+3. Installation
+ The latest release version is available at https://tio.github.io
-4. Installation
+3.1 Installation using release tarball
-4.1 Installation from source:
+ Install steps:
- $ ./configure
- $ make
- $ make install
+ $ ./configure
+ $ make
+ $ make install
See INSTALL file for more installation details.
-
-4.2 Installation using package:
+3.2 Installation using package
Tio comes prepackaged for various GNU/Linux distributions. Visit
https://tio.github.io for package installation details.
-5. Contributing
+4. Contributing
- Tio is open source. Any contributions (bug fixes, doc, ideas, etc.) are
+ Tio is open source. All contributions (bug fixes, doc, ideas, etc.) are
welcome. Visit the tio GitHub page to access latest source code, create
pull requests, add issues etc..
GitHub: https://github.com/tio/tio
+ Also, if you find this free open source software useful please consider
+ making a donation: https://www.paypal.me/lundmar
+
-6. Support
+5. Support
Submit bug reports via GitHub: https://github.com/tio/tio/issues
-7. Website
+6. Website
Visit https://tio.github.io
-8. License
+7. License
Tio is GPLv2+. See COPYING file for license details.
-9. Authors
+8. Authors
Created by Martin Lund <martin.lund@keep-it-simple.com>
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for tio 1.26.
+# Generated by GNU Autoconf 2.69 for tio 1.29.
#
#
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
# Identity of this package.
PACKAGE_NAME='tio'
PACKAGE_TARNAME='tio'
-PACKAGE_VERSION='1.26'
-PACKAGE_STRING='tio 1.26'
+PACKAGE_VERSION='1.29'
+PACKAGE_STRING='tio 1.29'
PACKAGE_BUGREPORT=''
PACKAGE_URL='https://tio.github.io'
am__EXEEXT_TRUE
LTLIBOBJS
LIBOBJS
+ADD_SETSPEED2_FALSE
+ADD_SETSPEED2_TRUE
BAUDRATE_CASES
BAUDRATES
ENABLE_BASH_COMPLETION_FALSE
# 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.26 to adapt to many kinds of systems.
+\`configure' configures tio 1.29 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of tio 1.26:";;
+ short | recursive ) echo "Configuration of tio 1.29:";;
esac
cat <<\_ACEOF
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-tio configure 1.26
+tio configure 1.29
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
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.26, which was
+It was created by tio $as_me 1.29, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
# Define the identity of the package.
PACKAGE='tio'
- VERSION='1.26'
+ VERSION='1.29'
cat >>confdefs.h <<_ACEOF
_ACEOF
+# Check for interface for setting arbitrary I/O speeds
+ac_fn_c_check_decl "$LINENO" "TCGETS2" "ac_cv_have_decl_TCGETS2" "#include <asm/termios.h>
+"
+if test "x$ac_cv_have_decl_TCGETS2" = xyes; then :
+
+$as_echo "#define HAVE_TERMIOS2 1" >>confdefs.h
+ have_termios2=yes
+fi
+
+ if test "x$have_termios2" == "xyes"; then
+ ADD_SETSPEED2_TRUE=
+ ADD_SETSPEED2_FALSE='#'
+else
+ ADD_SETSPEED2_TRUE='#'
+ ADD_SETSPEED2_FALSE=
+fi
+
+
ac_config_files="$ac_config_files Makefile"
ac_config_files="$ac_config_files src/Makefile"
as_fn_error $? "conditional \"ENABLE_BASH_COMPLETION\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
+if test -z "${ADD_SETSPEED2_TRUE}" && test -z "${ADD_SETSPEED2_FALSE}"; then
+ as_fn_error $? "conditional \"ADD_SETSPEED2\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
: "${CONFIG_STATUS=./config.status}"
ac_write_fail=0
# 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.26, which was
+This file was extended by tio $as_me 1.29, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
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.26
+tio config.status 1.29
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
AC_PREREQ([2.68])
-AC_INIT([tio], [1.26], [], [tio], [https://tio.github.io])
+AC_INIT([tio], [1.29], [], [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])
AC_DEFINE_UNQUOTED([AUTOCONF_BAUDRATE_CASES],[$BAUDRATE_CASES],[Switch cases for detected baud rates])
+# Check for interface for setting arbitrary I/O speeds
+AC_CHECK_DECL([TCGETS2], [AC_DEFINE([HAVE_TERMIOS2],[1],[Define if termios2 exists.]) have_termios2=yes], , [[#include <asm/termios.h>]])
+AM_CONDITIONAL([ADD_SETSPEED2],[test "x$have_termios2" == "xyes"])
+
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([src/Makefile])
AC_CONFIG_FILES([src/bash-completion/tio])
-.TH "tio" "1" "October 2017"
+.TH "tio" "1" "November 2017"
.SH "NAME"
tio \- a simple TTY terminal I/O application
.TP
.BR \-o ", " "\-\-output\-delay " \fI<ms>
-Set output delay [ms] inserted between each transmitted character (default: 0).
+Set output delay [ms] inserted between each sent character (default: 0).
.TP
.BR \-n ", " \-\-no\-autoconnect
Map (replace, translate) special characters on input or output. The following mapping flags are supported:
.RS
-.TP 8n
+.TP 12n
.IP "\fBINLCR"
-Translate NL to CR on input.
+Map NL to CR on input.
+.IP "\fBINLCRNL"
+Map NL to CR-NL on input.
.IP "\fBIGNCR"
-Ignore carriage return on input.
+Ignore CR on input.
.IP "\fBICRNL"
-Translate carriage return to newline on input (unless IGNCR is set).
-.IP "\fBONLCR"
+Map CR to NL on input (unless IGNCR is set).
+.IP "\fBONLCRNL"
Map NL to CR-NL on output.
.IP "\fBOCRNL"
Map CR to NL on output.
+.IP "\fBODELBS"
+Map DEL to BS on output.
.P
If defining more than one flag, the flags must be comma separated.
.RE
.IP "\fBctrl-t q"
Quit
.IP "\fBctrl-t s"
-Show statistics (total number of bytes transmitted/received)
+Show TX/RX statistics
.IP "\fBctrl-t t"
Send ctrl-t key code
tio \-b 115200 \-d 8 \-f none \-s 1 \-p none /dev/ttyUSB0
.TP
-It is recommended to connect serial tty devices by id. For example:
+It is recommended to connect serial tty devices by ID. For example:
tio /dev/serial/by\-id/usb\-FTDI_TTL232R-3V3_FTGQVXBL\-if00\-port0
.PP
-Using serial devices by id ensures that tio automatically reconnects to the
+Using serial devices by ID ensures that tio automatically reconnects to the
correct serial device if the device is disconnected and then reconnected.
.SH "WEBSITE"
include/tio/log.h \
include/tio/error.h
+if ADD_SETSPEED2
+tio_SOURCES += setspeed2.c
+endif
+
if ENABLE_BASH_COMPLETION
bashcompletiondir=@BASH_COMPLETION_DIR@
bashcompletion_DATA=bash-completion/tio
PRE_UNINSTALL = :
POST_UNINSTALL = :
bin_PROGRAMS = tio$(EXEEXT)
+@ADD_SETSPEED2_TRUE@am__append_1 = setspeed2.c
subdir = src
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__installdirs = "$(DESTDIR)$(bindir)" \
"$(DESTDIR)$(bashcompletiondir)"
PROGRAMS = $(bin_PROGRAMS)
+am__tio_SOURCES_DIST = tty.c options.c time.c main.c log.c error.c \
+ include/tio/tty.h include/tio/options.h include/tio/time.h \
+ include/tio/print.h include/tio/log.h include/tio/error.h \
+ setspeed2.c
+@ADD_SETSPEED2_TRUE@am__objects_1 = setspeed2.$(OBJEXT)
am_tio_OBJECTS = tty.$(OBJEXT) options.$(OBJEXT) time.$(OBJEXT) \
- main.$(OBJEXT) log.$(OBJEXT) error.$(OBJEXT)
+ main.$(OBJEXT) log.$(OBJEXT) error.$(OBJEXT) $(am__objects_1)
tio_OBJECTS = $(am_tio_OBJECTS)
tio_LDADD = $(LDADD)
AM_V_P = $(am__v_P_@AM_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(tio_SOURCES)
-DIST_SOURCES = $(tio_SOURCES)
+DIST_SOURCES = $(am__tio_SOURCES_DIST)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AM_CFLAGS = -Wall
-tio_SOURCES = tty.c \
- options.c \
- time.c \
- main.c \
- log.c \
- error.c \
- include/tio/tty.h \
- include/tio/options.h \
- include/tio/time.h \
- include/tio/print.h \
- include/tio/log.h \
- include/tio/error.h
-
+tio_SOURCES = tty.c options.c time.c main.c log.c error.c \
+ include/tio/tty.h include/tio/options.h include/tio/time.h \
+ include/tio/print.h include/tio/log.h include/tio/error.h \
+ $(am__append_1)
@ENABLE_BASH_COMPLETION_TRUE@bashcompletiondir = @BASH_COMPLETION_DIR@
@ENABLE_BASH_COMPLETION_TRUE@bashcompletion_DATA = bash-completion/tio
all: all-am
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/options.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/setspeed2.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/time.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tty.Po@am__quote@
/* Switch cases for detected baud rates */
#undef AUTOCONF_BAUDRATE_CASES
+/* Define if termios2 exists. */
+#undef HAVE_TERMIOS2
+
/* Name of package */
#undef PACKAGE
void print_help(char *argv[])
{
- printf("Usage: %s [<options>] <tty device>\n", argv[0]);
+ printf("Usage: %s [<options>] <tty-device>\n", argv[0]);
printf("\n");
printf("Options:\n");
printf(" -b, --baudrate <bps> Baud rate (default: 115200)\n");
printf(" -v, --version Display version\n");
printf(" -h, --help Display help\n");
printf("\n");
+ printf("See the man page for list of supported mapping flags.\n");
+ printf("\n");
printf("In session, press ctrl-t q to quit.\n");
printf("\n");
}
--- /dev/null
+/*
+ * tio - a simple TTY terminal I/O application
+ *
+ * Copyright (c) 2017 Martin Lund
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include <sys/ioctl.h>
+#include <asm/ioctls.h>
+#include <asm/termbits.h>
+
+int setspeed2(int fd, int baudrate)
+{
+ struct termios2 tio;
+ int status;
+
+ status = ioctl(fd, TCGETS2, &tio);
+
+ // Set baudrate speed using termios2 interface
+ tio.c_cflag &= ~CBAUD;
+ tio.c_cflag |= BOTHER;
+ tio.c_ispeed = baudrate;
+ tio.c_ospeed = baudrate;
+
+ status = ioctl(fd, TCSETS2, &tio);
+
+ return status;
+}
#include "tio/log.h"
#include "tio/error.h"
+#ifdef HAVE_TERMIOS2
+extern int setspeed2(int fd, int baudrate);
+#endif
+
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;
static bool tainted = false;
-static int fd;
static bool print_mode = NORMAL;
+static bool standard_baudrate = true;
static void (*print)(char c);
+static int fd;
+static bool map_inlcrnl = false;
+static bool map_odelbs = false;
#define tio_printf(format, args...) \
{ \
AUTOCONF_BAUDRATE_CASES
default:
+#ifdef HAVE_TERMIOS2
+ standard_baudrate = false;
+ break;
+#else
error_printf("Invalid baud rate");
exit(EXIT_FAILURE);
+#endif
}
- // Set input speed
- status = cfsetispeed(&tio, baudrate);
- if (status == -1)
+ if (standard_baudrate)
{
- error_printf("Could not configure input speed (%s)", strerror(errno));
- exit(EXIT_FAILURE);
- }
+ // Set input speed
+ status = cfsetispeed(&tio, baudrate);
+ if (status == -1)
+ {
+ error_printf("Could not configure input speed (%s)", strerror(errno));
+ exit(EXIT_FAILURE);
+ }
- // Set output speed
- cfsetospeed(&tio, baudrate);
- if (status == -1)
- {
- error_printf("Could not configure output speed (%s)", strerror(errno));
- exit(EXIT_FAILURE);
+ // Set output speed
+ cfsetospeed(&tio, baudrate);
+ if (status == -1)
+ {
+ error_printf("Could not configure output speed (%s)", strerror(errno));
+ exit(EXIT_FAILURE);
+ }
}
/* Set databits */
tio.c_cc[VMIN] = 1; // Blocking read until 1 character received
/* Configure any specified input or output mappings */
-
buffer = strdup(option.map);
while (token_found == true)
{
tio.c_iflag |= IGNCR;
else if (strcmp(token,"ICRNL") == 0)
tio.c_iflag |= ICRNL;
- else if (strcmp(token,"ONLCR") == 0)
+ else if (strcmp(token,"ONLCRNL") == 0)
tio.c_oflag |= ONLCR;
else if (strcmp(token,"OCRNL") == 0)
tio.c_oflag |= OCRNL;
+ else if (strcmp(token,"ODELBS") == 0)
+ map_odelbs = true;
+ else if (strcmp(token,"INLCRNL") == 0)
+ map_inlcrnl = true;
else
{
printf("Error: Unknown mapping flag %s\n", token);
goto error_tcsetattr;
}
+#ifdef HAVE_TERMIOS2
+ if (!standard_baudrate)
+ {
+ if (setspeed2(fd, option.baudrate) != 0)
+ {
+ error_printf_silent("Could not set baudrate speed (%s)", strerror(errno));
+ goto error_setspeed2;
+ }
+ }
+#endif
+
maxfd = MAX(fd, STDIN_FILENO) + 1; /* Maximum bit entry (fd) to test */
/* Input loop */
/* Update receive statistics */
rx_total++;
- /* Print received tty character to stdout */
- print(input_char);
+ /* Map input character */
+ if ((input_char == '\n') && (map_inlcrnl))
+ {
+ print('\r');
+ print('\n');
+ } else
+ {
+ /* Print received tty character to stdout */
+ print(input_char);
+ }
fflush(stdout);
/* Write to log */
if (forward)
{
+ /* Map output character */
+ if ((output_char == 127) && (map_odelbs))
+ output_char = '\b';
+
/* Send output to tty device */
status = write(fd, &output_char, 1);
if (status < 0)
return TIO_SUCCESS;
+#ifdef HAVE_TERMIOS2
+error_setspeed2:
+#endif
error_tcsetattr:
error_tcgetattr:
error_read: