From df2ffbeb7c09208cd34db1210a2f4e7e0f509f48 Mon Sep 17 00:00:00 2001 From: bobemoe Date: Sat, 29 Jul 2023 23:04:25 +0100 Subject: [PATCH] Update modbus.c don't wait for confirmation response if the write is a broadcast (slave==0) message --- src/libmodbus/modbus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libmodbus/modbus.c b/src/libmodbus/modbus.c index 17e36e1..5f4e1d4 100644 --- a/src/libmodbus/modbus.c +++ b/src/libmodbus/modbus.c @@ -1393,7 +1393,7 @@ int modbus_write_bits(modbus_t *ctx, int addr, int nb, const uint8_t *src) } rc = send_msg(ctx, req, req_length); - if (rc > 0) { + if (rc > 0 && ctx->slave != 0) { uint8_t rsp[MAX_MESSAGE_LENGTH]; rc = _modbus_receive_msg(ctx, rsp, MSG_CONFIRMATION); @@ -1443,7 +1443,7 @@ int modbus_write_registers(modbus_t *ctx, int addr, int nb, const uint16_t *src) } rc = send_msg(ctx, req, req_length); - if (rc > 0) { + if (rc > 0 && ctx->slave != 0) { uint8_t rsp[MAX_MESSAGE_LENGTH]; rc = _modbus_receive_msg(ctx, rsp, MSG_CONFIRMATION);