mirror of
https://github.com/UzixLS/picocom.git
synced 2025-07-19 07:21:18 +03:00
Better build support for custom baudrates
For some systems (OSes, versions, architectures) custom-baudrate support is enabled by default. For others, support may work, but must be enabled by defining USE_CUSTOM_BAUD in the Makefile You can also disable custom baudrate support altogether (even for systems where it's enabled by default), by defining NO_CUSTOM_BAUD in the Makefile
This commit is contained in:
17
Makefile
17
Makefile
@ -37,11 +37,14 @@ 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 this in to enable custom baudrate support.
|
||||
## Works with: Linux (kernels > 2.6), FreeBSD, OpenBSD, DragonFly,
|
||||
## macOS (Tiger and above)
|
||||
## Comment this in to enable (force) custom baudrate support
|
||||
## even on systems not enabled by default.
|
||||
#CPPFLAGS += -DUSE_CUSTOM_BAUD
|
||||
|
||||
## Comment this in to disable custom baudrate support
|
||||
## on ALL systems (even on these enabled by default).
|
||||
#CPPFLAGS += -DNO_CUSTOM_BAUD
|
||||
|
||||
## Comment this IN to remove help strings (saves ~ 4-6 Kb).
|
||||
#CPPFLAGS += -DNO_HELP
|
||||
|
||||
@ -50,12 +53,12 @@ OBJS += picocom.o term.o fdio.o split.o termios2.o custbaud_bsd.o
|
||||
picocom : $(OBJS)
|
||||
$(LD) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
|
||||
|
||||
picocom.o : picocom.c term.h
|
||||
term.o : term.c term.h
|
||||
picocom.o : picocom.c term.h fdio.h split.h custbaud.h
|
||||
term.o : term.c term.h termios2.h custbaud_bsd.h custbaud.h
|
||||
split.o : split.c split.h
|
||||
fdio.o : fdio.c fdio.h
|
||||
termios2.o : termios2.c termios2.h termbits2.h
|
||||
custbaud_bsd.o : custbaud_bsd.c custbaud_bsd.h
|
||||
termios2.o : termios2.c termios2.h termbits2.h custbaud.h
|
||||
custbaud_bsd.o : custbaud_bsd.c custbaud_bsd.h custbaud.h
|
||||
|
||||
.c.o :
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
|
||||
|
75
custbaud.h
Normal file
75
custbaud.h
Normal file
@ -0,0 +1,75 @@
|
||||
/* vi: set sw=4 ts=4:
|
||||
*
|
||||
* custbaud.h
|
||||
*
|
||||
* Automatically enable custom baudrate support for systems (OS /
|
||||
* version / architecture combinations) we know it works.
|
||||
*
|
||||
* by Nick Patavalis (npat@inaccessnetworks.com)
|
||||
*
|
||||
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*/
|
||||
|
||||
#ifndef CUSTBAUD_H
|
||||
#define CUSTBAUD_H
|
||||
|
||||
#ifndef NO_CUSTOM_BAUD
|
||||
|
||||
#if defined (__linux__)
|
||||
|
||||
#include <linux/version.h>
|
||||
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0)
|
||||
#if defined (__x86__) || defined (__x86_64__) || defined (USE_CUSTOM_BAUD)
|
||||
#ifndef USE_CUSTOM_BAUD
|
||||
#define USE_CUSTOM_BAUD
|
||||
#endif
|
||||
#define CUSTOM_BAUD_HEAD "termios2.h"
|
||||
#endif /* of arch */
|
||||
#endif /* of version */
|
||||
|
||||
#elif defined (__FreeBSD__) || defined (__OpenBSD__) || \
|
||||
defined (__DragonFly__) || defined (__APPLE__)
|
||||
|
||||
#ifndef USE_CUSTOM_BAUD
|
||||
#define USE_CUSTOM_BAUD
|
||||
#endif
|
||||
#define CUSTOM_BAUD_HEAD "custbaud_bsd.h"
|
||||
|
||||
#elif defined (USE_CUSTOM_BAUD)
|
||||
|
||||
#error "USE_CUSTOM_BAUD not supported on this system!"
|
||||
|
||||
#endif /* of platforms */
|
||||
|
||||
#else /* of ndef NO_CUSTOM_BAUD */
|
||||
|
||||
#ifdef USE_CUSTOM_BAUD
|
||||
#undef USE_CUSTOM_BAUD
|
||||
#endif
|
||||
|
||||
#endif /* of ndef NO_CUSTOM_BAUD else */
|
||||
|
||||
#endif /* CUSTBAUD_H */
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
@ -38,6 +38,8 @@
|
||||
* - Have not tested with more recent macOS or Ftdi driver until now.
|
||||
*/
|
||||
|
||||
#include "custbaud.h"
|
||||
|
||||
/* Note that this code might also work with other BSD variants, but I have only
|
||||
* tested with those listed below. Also tested __NetBSD__ but won't work. */
|
||||
#if (defined (__FreeBSD__) || defined (__OpenBSD__) || \
|
||||
|
@ -55,6 +55,8 @@
|
||||
#include "linenoise-1.0/linenoise.h"
|
||||
#endif
|
||||
|
||||
#include "custbaud.h"
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
/* parity modes names */
|
||||
|
18
term.c
18
term.c
@ -52,6 +52,8 @@
|
||||
#define CMSPAR 0
|
||||
#endif
|
||||
|
||||
/* On these systems, use the TIOCM[BIS|BIC|GET] ioctls to manipulate
|
||||
* the modem control lines (DTR / RTS) */
|
||||
#if defined(__linux__) || \
|
||||
defined(__FreeBSD__) || defined(__OpenBSD__) || \
|
||||
defined(__NetBSD__) || defined(__DragonFly__) || \
|
||||
@ -62,22 +64,10 @@
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "custbaud.h"
|
||||
#ifdef USE_CUSTOM_BAUD
|
||||
#if defined (__linux__)
|
||||
/* only works for linux, recent kernels */
|
||||
#include "termios2.h"
|
||||
#elif defined (__FreeBSD__) || defined (__OpenBSD__) || \
|
||||
defined (__DragonFly__) || defined (__APPLE__)
|
||||
/* only for some BSD and macOS (Tiger and above)
|
||||
* Note that this code might also work other BSD variants, but I have only
|
||||
* tested with those listed below. Also tested __NetBSD__ but won't work. */
|
||||
#include "custbaud_bsd.h"
|
||||
#else
|
||||
#error "USE_CUSTOM_BAUD not supported in this system"
|
||||
#include CUSTOM_BAUD_HEAD
|
||||
#endif
|
||||
#endif /* of USE_CUSTOM_BAUD */
|
||||
|
||||
|
||||
/* Time to wait for UART to clear after a drain (in usec). */
|
||||
#define DRAIN_DELAY 200000
|
||||
|
@ -23,6 +23,8 @@
|
||||
* USA
|
||||
*/
|
||||
|
||||
#include "custbaud.h"
|
||||
|
||||
#if defined(__linux__) && defined(USE_CUSTOM_BAUD)
|
||||
|
||||
#include <linux/version.h>
|
||||
|
Reference in New Issue
Block a user