Commit 602a7f3859091516b034b6bf18ba6294f91162ce

Authored by Alex Stapleton
Committed by Stéphane Raimbault
1 parent 7ecfd411

Provides a way to disable the byte timeout.

doc/modbus_set_byte_timeout.txt
@@ -18,6 +18,9 @@ The _modbus_set_byte_timeout()_ function shall set the timeout interval between @@ -18,6 +18,9 @@ The _modbus_set_byte_timeout()_ function shall set the timeout interval between
18 two consecutive bytes of the same message. If the delay between is longer than 18 two consecutive bytes of the same message. If the delay between is longer than
19 the given timeout, an error will be raised. 19 the given timeout, an error will be raised.
20 20
  21 +If the timeout value has a tv_sec of -1 then this timeout will not be used at
  22 +all. This results in modbus_set_response_timeout governing the entire timeout
  23 +duration of an operation.
21 24
22 RETURN VALUE 25 RETURN VALUE
23 ------------ 26 ------------
src/modbus.c
@@ -442,7 +442,7 @@ static int receive_msg(modbus_t *ctx, uint8_t *msg, msg_type_t msg_type) @@ -442,7 +442,7 @@ static int receive_msg(modbus_t *ctx, uint8_t *msg, msg_type_t msg_type)
442 } 442 }
443 } 443 }
444 444
445 - if (length_to_read > 0) { 445 + if (length_to_read > 0 && ctx->byte_timeout.tv_sec != -1) {
446 /* If there is no character in the buffer, the allowed timeout 446 /* If there is no character in the buffer, the allowed timeout
447 interval between two consecutive bytes is defined by 447 interval between two consecutive bytes is defined by
448 byte_timeout */ 448 byte_timeout */