mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Added support for non-standard baud rates
Only enabled when possible, that is, when the BOTHER definition is available. It is untested but it should work as described here: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=683826 Some Cypress USB<->serial devices supposedly supports arbitrary speeds.
This commit is contained in:
parent
2c53bfde96
commit
deec83a4ee
2 changed files with 28 additions and 3 deletions
|
|
@ -87,6 +87,9 @@ TIO_CHECK_BAUDRATES(
|
||||||
|
|
||||||
AC_DEFINE_UNQUOTED([AUTOCONF_BAUDRATE_CASES],[$BAUDRATE_CASES],[Switch cases for detected baud rates])
|
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 <asm/termios.h>]])
|
||||||
|
|
||||||
AC_CONFIG_FILES([Makefile])
|
AC_CONFIG_FILES([Makefile])
|
||||||
AC_CONFIG_FILES([src/Makefile])
|
AC_CONFIG_FILES([src/Makefile])
|
||||||
AC_CONFIG_FILES([src/bash-completion/tio])
|
AC_CONFIG_FILES([src/bash-completion/tio])
|
||||||
|
|
|
||||||
24
src/tty.c
24
src/tty.c
|
|
@ -45,8 +45,13 @@ static struct termios tio, new_stdout, old_stdout, old_tio;
|
||||||
static unsigned long rx_total = 0, tx_total = 0;
|
static unsigned long rx_total = 0, tx_total = 0;
|
||||||
static bool connected = false;
|
static bool connected = false;
|
||||||
static bool tainted = false;
|
static bool tainted = false;
|
||||||
|
static bool standard_baudrate = true;
|
||||||
static int fd;
|
static int fd;
|
||||||
|
|
||||||
|
#ifndef BOTHER
|
||||||
|
#define BOTHER 0010000
|
||||||
|
#endif
|
||||||
|
|
||||||
#define tio_printf(format, args...) \
|
#define tio_printf(format, args...) \
|
||||||
{ \
|
{ \
|
||||||
if (tainted) putchar('\n'); \
|
if (tainted) putchar('\n'); \
|
||||||
|
|
@ -156,7 +161,7 @@ void stdout_restore(void)
|
||||||
|
|
||||||
void tty_configure(void)
|
void tty_configure(void)
|
||||||
{
|
{
|
||||||
speed_t baudrate;
|
speed_t baudrate = 0;
|
||||||
|
|
||||||
memset(&tio, 0, sizeof(tio));
|
memset(&tio, 0, sizeof(tio));
|
||||||
|
|
||||||
|
|
@ -177,12 +182,25 @@ void tty_configure(void)
|
||||||
AUTOCONF_BAUDRATE_CASES
|
AUTOCONF_BAUDRATE_CASES
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
#if !HAVE_DECL_BOTHER
|
||||||
error_printf("Invalid baud rate");
|
error_printf("Invalid baud rate");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
#else
|
||||||
|
standard_baudrate = false;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (standard_baudrate)
|
||||||
|
{
|
||||||
cfsetispeed(&tio, baudrate);
|
cfsetispeed(&tio, baudrate);
|
||||||
cfsetospeed(&tio, baudrate);
|
cfsetospeed(&tio, baudrate);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
tio.c_ispeed = tio.c_ospeed = baudrate;
|
||||||
|
tio.c_cflag &= ~CBAUD;
|
||||||
|
tio.c_cflag |= BOTHER;
|
||||||
|
}
|
||||||
|
|
||||||
/* Set databits */
|
/* Set databits */
|
||||||
tio.c_cflag &= ~CSIZE;
|
tio.c_cflag &= ~CSIZE;
|
||||||
|
|
@ -374,6 +392,10 @@ int tty_connect(void)
|
||||||
/* Flush stale I/O data (if any) */
|
/* Flush stale I/O data (if any) */
|
||||||
tcflush(fd, TCIOFLUSH);
|
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 */
|
/* Print connect status */
|
||||||
tio_printf("Connected");
|
tio_printf("Connected");
|
||||||
connected = true;
|
connected = true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue