From 18dd9908f17a0af378ded44075d266acf77c7730 Mon Sep 17 00:00:00 2001 From: Michał Łyszczek Date: Mon, 25 Jan 2021 00:45:29 +0100 Subject: examples/print-tty.c: use termios conditionally MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some systems might now have termios enabled, so let's not force it. Signed-off-by: Michał Łyszczek --- examples/print-tty.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/examples/print-tty.c b/examples/print-tty.c index 889afe3..193e6e7 100644 --- a/examples/print-tty.c +++ b/examples/print-tty.c @@ -4,7 +4,14 @@ ========================================================================== */ #include "embedlog.h" -#include + +#if HAVE_CONFIG_H +# include "config.h" +#endif + +#if HAVE_TERMIOS_H +# include +#endif #ifdef EMBEDLOG_DEMO_LIBRARY int el_demo_print_tty(void) @@ -20,11 +27,19 @@ int main(void) * output to serial device. */ el_option(EL_OUT, EL_OUT_TTY); +#if HAVE_TERMIOS_H /* enbaling tty output is not enough, we still need to * configure which device we want to use and at what speed. * Transmission parameters are 8N1 by default. Baudrate should * be taken from termios (3). */ if (el_option(EL_TTY_DEV, "/dev/ttyUSB1", B9600) != 0) +#else + /* if termios is not available on your system, you can specify + * 0 as baund rate, this will tell embedlog not to configure + * serial port and use it as is - ie. it can be configured + * at system startup or even during compile time */ + if (el_option(EL_TTY_DEV, "/dev/ttyUSB1", 0) != 0) +#endif { perror("tty set failed"); el_cleanup(); -- cgit v1.2.3-8-gadcc