Commit ddbd7266bec465d6293f46de9c8c2f669f238613
1 parent
4ac3cc37
Fix to allow the setting of the broadcast address
Showing
3 changed files
with
5 additions
and
2 deletions
NEWS
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 | ... | ... |