diff --git a/doc/modbus_set_byte_timeout.txt b/doc/modbus_set_byte_timeout.txt index c1b8297..90db5f4 100644 --- a/doc/modbus_set_byte_timeout.txt +++ b/doc/modbus_set_byte_timeout.txt @@ -18,6 +18,9 @@ The _modbus_set_byte_timeout()_ function shall set the timeout interval between two consecutive bytes of the same message. If the delay between is longer than the given timeout, an error will be raised. +If the timeout value has a tv_sec of -1 then this timeout will not be used at +all. This results in modbus_set_response_timeout governing the entire timeout +duration of an operation. RETURN VALUE ------------ diff --git a/src/modbus.c b/src/modbus.c index 684be1f..3756877 100644 --- a/src/modbus.c +++ b/src/modbus.c @@ -442,7 +442,7 @@ static int receive_msg(modbus_t *ctx, uint8_t *msg, msg_type_t msg_type) } } - if (length_to_read > 0) { + if (length_to_read > 0 && ctx->byte_timeout.tv_sec != -1) { /* If there is no character in the buffer, the allowed timeout interval between two consecutive bytes is defined by byte_timeout */