Commit ddbd7266bec465d6293f46de9c8c2f669f238613

Authored by Stéphane Raimbault
1 parent 4ac3cc37

Fix to allow the setting of the broadcast address

1 1 libmodbus 2.9.2 (2010-10-XX)
2 2 ============================
3 3  
  4 +- Fix setting of the broadcast address
4 5 - Remove slave argument from modbus_new_rtu()
5 6 - Win32 support by Tobias Doerffel
6 7 - Split source code around RTU and TCP (backends)
... ...
src/modbus-rtu.c
... ... @@ -92,7 +92,8 @@ static const uint8_t table_crc_lo[] = {
92 92 * internal slave ID in slave mode */
93 93 static int _modbus_set_slave(modbus_t *ctx, int slave)
94 94 {
95   - if (slave >= 1 && slave <= 247) {
  95 + /* Broadcast address is 0 (MODBUS_BROADCAST_ADDRESS) */
  96 + if (slave >= 0 && slave <= 247) {
96 97 ctx->slave = slave;
97 98 } else {
98 99 errno = EINVAL;
... ...
src/modbus-tcp.c
... ... @@ -72,7 +72,8 @@ static int _modbus_tcp_init_win32(void)
72 72  
73 73 static int _modbus_set_slave(modbus_t *ctx, int slave)
74 74 {
75   - if (slave >= 1 && slave <= 247) {
  75 + /* Broadcast address is 0 (MODBUS_BROADCAST_ADDRESS) */
  76 + if (slave >= 0 && slave <= 247) {
76 77 ctx->slave = slave;
77 78 } else if (slave == MODBUS_TCP_SLAVE) {
78 79 /* The special value MODBUS_TCP_SLAVE (0xFF) can be used in TCP mode to
... ...