Pārlūkot izejas kodu

Add check to enable RS485 functions only when available

Stéphane Raimbault 14 gadi atpakaļ
vecāks
revīzija
e02f0a4324
2 mainītis faili ar 6 papildinājumiem un 2 dzēšanām
  1. 3 0
      configure.ac
  2. 3 2
      src/modbus-rtu.c

+ 3 - 0
configure.ac

@@ -127,6 +127,9 @@ if test "x$HAVE_WINSOCK2_H" = "xyes"; then
    AC_SUBST(LIBS)
 fi
 
+# Check for RS485 support (recent Linux kernels)
+AC_CHECK_DECLS([TIOCSRS485], [], [], [[#include <sys/ioctl.h>]])
+
 AC_CONFIG_FILES([
         Makefile
         src/Makefile

+ 3 - 2
src/modbus-rtu.c

@@ -30,7 +30,7 @@
 #include "modbus-rtu.h"
 #include "modbus-rtu-private.h"
 
-#if defined(linux)
+#if defined(HAVE_TIOCSRS485)
 #include <sys/ioctl.h>
 #include <linux/serial.h>
 #endif
@@ -704,7 +704,8 @@ static int _modbus_rtu_connect(modbus_t *ctx)
     return 0;
 }
 
-#if defined(linux)
+#if defined(HAVE_TIOCSRS485)
+d
 int modbus_rtu_set_serial_mode(modbus_t *ctx, int mode)
 {
     if (ctx->backend->backend_type == _MODBUS_BACKEND_TYPE_RTU) {