Commit e02f0a43244c46bc6695b16dc66e1fe596eb0f84

Authored by Stéphane Raimbault
1 parent c1a01312

Add check to enable RS485 functions only when available

configure.ac
... ... @@ -127,6 +127,9 @@ if test "x$HAVE_WINSOCK2_H" = "xyes"; then
127 127 AC_SUBST(LIBS)
128 128 fi
129 129  
  130 +# Check for RS485 support (recent Linux kernels)
  131 +AC_CHECK_DECLS([TIOCSRS485], [], [], [[#include <sys/ioctl.h>]])
  132 +
130 133 AC_CONFIG_FILES([
131 134 Makefile
132 135 src/Makefile
... ...
src/modbus-rtu.c
... ... @@ -30,7 +30,7 @@
30 30 #include "modbus-rtu.h"
31 31 #include "modbus-rtu-private.h"
32 32  
33   -#if defined(linux)
  33 +#if defined(HAVE_TIOCSRS485)
34 34 #include <sys/ioctl.h>
35 35 #include <linux/serial.h>
36 36 #endif
... ... @@ -704,7 +704,8 @@ static int _modbus_rtu_connect(modbus_t *ctx)
704 704 return 0;
705 705 }
706 706  
707   -#if defined(linux)
  707 +#if defined(HAVE_TIOCSRS485)
  708 +d
708 709 int modbus_rtu_set_serial_mode(modbus_t *ctx, int mode)
709 710 {
710 711 if (ctx->backend->backend_type == _MODBUS_BACKEND_TYPE_RTU) {
... ...