mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
add support for high bps on OS X
This commit is contained in:
parent
3a1fd79fcb
commit
aa9f121a12
4 changed files with 56 additions and 2 deletions
|
|
@ -88,6 +88,9 @@ AC_DEFINE_UNQUOTED([AUTOCONF_BAUDRATE_CASES],[$BAUDRATE_CASES],[Switch cases for
|
|||
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_CHECK_DECL([IOSSIOSPEED], [AC_DEFINE([HAVE_IOSSIOSPEED],[1],[Define if IOKit exists.]) have_iossiospeed=yes], , [[#include <IOKit/serial/ioss.h>]])
|
||||
AM_CONDITIONAL([ADD_IOSSIOSPEED],[test "x$have_iossiospeed" = "xyes"])
|
||||
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
AC_CONFIG_FILES([src/Makefile])
|
||||
AC_CONFIG_FILES([src/bash-completion/tio])
|
||||
|
|
|
|||
|
|
@ -18,6 +18,10 @@ if ADD_SETSPEED2
|
|||
tio_SOURCES += setspeed2.c
|
||||
endif
|
||||
|
||||
if ADD_IOSSIOSPEED
|
||||
tio_SOURCES += iossiospeed.c
|
||||
endif
|
||||
|
||||
if ENABLE_BASH_COMPLETION
|
||||
bashcompletiondir=@BASH_COMPLETION_DIR@
|
||||
bashcompletion_DATA=bash-completion/tio
|
||||
|
|
|
|||
28
src/iossiospeed.c
Normal file
28
src/iossiospeed.c
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* 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 <IOKit/serial/ioss.h>
|
||||
|
||||
int iossiospeed(int fd, int baudrate)
|
||||
{
|
||||
return ioctl(fd, IOSSIOSPEED, (char *)&baudrate);
|
||||
}
|
||||
23
src/tty.c
23
src/tty.c
|
|
@ -48,6 +48,10 @@
|
|||
extern int setspeed2(int fd, int baudrate);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_IOSSIOSPEED
|
||||
extern int iossiospeed(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;
|
||||
|
|
@ -366,7 +370,7 @@ void tty_configure(void)
|
|||
AUTOCONF_BAUDRATE_CASES
|
||||
|
||||
default:
|
||||
#ifdef HAVE_TERMIOS2
|
||||
#if defined(HAVE_TERMIOS2) || defined(HAVE_IOSSIOSPEED)
|
||||
standard_baudrate = false;
|
||||
break;
|
||||
#else
|
||||
|
|
@ -663,6 +667,11 @@ int tty_connect(void)
|
|||
/* Save current port settings */
|
||||
if (tcgetattr(fd, &tio_old) < 0)
|
||||
goto error_tcgetattr;
|
||||
#ifdef HAVE_IOSSIOSPEED
|
||||
/* OS X wants these fields left alone. We'll set baudrate with iossiospeed below. */
|
||||
tio.c_ispeed = tio_old.c_ispeed;
|
||||
tio.c_ospeed = tio_old.c_ospeed;
|
||||
#endif
|
||||
|
||||
/* Make sure we restore tty settings on exit */
|
||||
if (first)
|
||||
|
|
@ -689,6 +698,16 @@ int tty_connect(void)
|
|||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_IOSSIOSPEED
|
||||
if (!standard_baudrate)
|
||||
{
|
||||
if (iossiospeed(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 */
|
||||
|
||||
|
|
@ -827,7 +846,7 @@ int tty_connect(void)
|
|||
|
||||
return TIO_SUCCESS;
|
||||
|
||||
#ifdef HAVE_TERMIOS2
|
||||
#if defined(HAVE_TERMIOS2) || defined(HAVE_IOSSIOSPEED)
|
||||
error_setspeed2:
|
||||
#endif
|
||||
error_tcsetattr:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue