1
0
mirror of https://github.com/UzixLS/picocom.git synced 2025-07-19 07:21:18 +03:00

Merge pull request #51 from Joe-Merten/osx-baudrates

Improved baudrate support for OSX
This commit is contained in:
Nick Patavalis
2016-12-07 01:32:54 +02:00
committed by GitHub
2 changed files with 67 additions and 3 deletions

View File

@ -36,8 +36,10 @@ CPPFLAGS += -DHISTFILE=\"$(HISTFILE)\" \
OBJS += linenoise-1.0/linenoise.o
linenoise-1.0/linenoise.o : linenoise-1.0/linenoise.c linenoise-1.0/linenoise.h
## Comment these IN to enable custom baudrate support.
## Currently works *only* with Linux (kernels > 2.6).
## Comment this in to enable custom baudrate support for OSX (Tiger and above)
#CPPFLAGS += -DUSE_CUSTOM_BAUD
## Comment this in to enable custom baudrate support for Linux (kernels > 2.6)
#CPPFLAGS += -DUSE_CUSTOM_BAUD
#OBJS += termios2.o
#termios2.o : termios2.c termios2.h termbits2.h

64
term.c
View File

@ -56,7 +56,7 @@
#include <sys/ioctl.h>
#endif
#ifdef USE_CUSTOM_BAUD
#if defined(__linux__) && defined(USE_CUSTOM_BAUD)
/* only works for linux, recent kernels */
#include "termios2.h"
#endif
@ -160,6 +160,68 @@ term_perror (const char *prefix)
prefix, term_strerror(term_errno, errno));
}
/***************************************************************************/
/* OSX termios.h unfortunately just provides constants for
* baudrates up to 230k, so we add the missing constants here. */
#if defined(__APPLE__)
#ifndef B460800
#define B460800 460800
#endif
#ifndef B500000
#define B500000 500000
#endif
#ifndef B576000
#define B576000 576000
#endif
#ifndef B921600
#define B921600 921600
#endif
#ifndef B1000000
#define B1000000 1000000
#endif
#ifndef B1152000
#define B1152000 1152000
#endif
#ifndef B1500000
#define B1500000 1500000
#endif
#ifndef B2000000
#define B2000000 2000000
#endif
#ifndef B2500000
#define B2500000 2500000
#endif
#ifndef B3000000
#define B3000000 3000000
#endif
#ifndef B3500000
#define B3500000 3500000
#endif
#ifndef B4000000
#define B4000000 4000000
#endif
#endif /* __APPLE__ */
/***************************************************************************/
/* Custom baudrates support for OSX */
#if defined(__APPLE__) && defined (USE_CUSTOM_BAUD)
int cfsetospeed_custom(struct termios *tiop, int speed) {
return cfsetospeed(tiop, speed);
}
int cfsetispeed_custom(struct termios *tiop, int speed) {
return cfsetispeed(tiop, speed);
}
int cfgetospeed_custom(struct termios *tiop) {
return cfgetospeed(tiop);
}
int cfgetispeed_custom(struct termios *tiop) {
return cfgetispeed(tiop);
}
#endif /* __APPLE__ && USE_CUSTOM_BAUD */
/***************************************************************************/
#define BNONE 0xFFFFFFFF