Commit 3803f89e6e8aac951a24fd2b3f0df455494ef63b
1 parent
76284c17
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.
Showing
2 changed files
with
5 additions
and
0 deletions
src/modbus-rtu-private.h
| @@ -77,6 +77,8 @@ typedef struct _modbus_rtu { | @@ -77,6 +77,8 @@ typedef struct _modbus_rtu { | ||
| 77 | #else | 77 | #else |
| 78 | /* Save old termios settings */ | 78 | /* Save old termios settings */ |
| 79 | struct termios old_tios; | 79 | struct termios old_tios; |
| 80 | +#endif | ||
| 81 | +#if HAVE_DECL_TIOCSRS485 | ||
| 80 | int serial_mode; | 82 | int serial_mode; |
| 81 | #endif | 83 | #endif |
| 82 | } modbus_rtu_t; | 84 | } modbus_rtu_t; |
src/modbus-rtu.c
| @@ -698,10 +698,13 @@ static int _modbus_rtu_connect(modbus_t *ctx) | @@ -698,10 +698,13 @@ static int _modbus_rtu_connect(modbus_t *ctx) | ||
| 698 | if (tcsetattr(ctx->s, TCSANOW, &tios) < 0) { | 698 | if (tcsetattr(ctx->s, TCSANOW, &tios) < 0) { |
| 699 | return -1; | 699 | return -1; |
| 700 | } | 700 | } |
| 701 | +#endif | ||
| 701 | 702 | ||
| 703 | +#if HAVE_DECL_TIOCSRS485 | ||
| 702 | /* The RS232 mode has been set by default */ | 704 | /* The RS232 mode has been set by default */ |
| 703 | ctx_rtu->serial_mode = MODBUS_RTU_RS232; | 705 | ctx_rtu->serial_mode = MODBUS_RTU_RS232; |
| 704 | #endif | 706 | #endif |
| 707 | + | ||
| 705 | return 0; | 708 | return 0; |
| 706 | } | 709 | } |
| 707 | 710 |