aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichał Łyszczek <michal.lyszczek@bofc.pl>2021-01-25 00:45:29 +0100
committerMichał Łyszczek <michal.lyszczek@bofc.pl>2021-01-25 00:52:25 +0100
commit18dd9908f17a0af378ded44075d266acf77c7730 (patch)
treee9209d028eb2edb61d8917ef182c2b090ba46c30
parentb5682c57099c285ccc7cabdf59b00d431981ea6a (diff)
downloadembedlog-18dd9908f17a0af378ded44075d266acf77c7730.tar.gz
embedlog-18dd9908f17a0af378ded44075d266acf77c7730.tar.bz2
embedlog-18dd9908f17a0af378ded44075d266acf77c7730.zip
examples/print-tty.c: use termios conditionally
Some systems might now have termios enabled, so let's not force it. Signed-off-by: Michał Łyszczek <michal.lyszczek@bofc.pl>
-rw-r--r--examples/print-tty.c17
1 files changed, 16 insertions, 1 deletions
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 <termios.h>
+
+#if HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#if HAVE_TERMIOS_H
+# include <termios.h>
+#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();