Browse Source

Extract serial_mode attribute from platform tests

Bonus side effect: the integer isn't present anymore when TIOCSRS485
isn't supported on non Win32 platforms.
Stéphane Raimbault 13 năm trước cách đây
mục cha
commit
3803f89e6e
2 tập tin đã thay đổi với 5 bổ sung0 xóa
  1. 2 0
      src/modbus-rtu-private.h
  2. 3 0
      src/modbus-rtu.c

+ 2 - 0
src/modbus-rtu-private.h

@@ -77,6 +77,8 @@ typedef struct _modbus_rtu {
 #else
     /* Save old termios settings */
     struct termios old_tios;
+#endif
+#if HAVE_DECL_TIOCSRS485
     int serial_mode;
 #endif
 } modbus_rtu_t;

+ 3 - 0
src/modbus-rtu.c

@@ -698,10 +698,13 @@ static int _modbus_rtu_connect(modbus_t *ctx)
     if (tcsetattr(ctx->s, TCSANOW, &tios) < 0) {
         return -1;
     }
+#endif
 
+#if HAVE_DECL_TIOCSRS485
     /* The RS232 mode has been set by default */
     ctx_rtu->serial_mode = MODBUS_RTU_RS232;
 #endif
+
     return 0;
 }