Эх сурвалжийг харах

Provides a way to disable the byte timeout.

Alex Stapleton 13 жил өмнө
parent
commit
6bb0ba4c41

+ 3 - 0
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
 two consecutive bytes of the same message. If the delay between is longer than
 the given timeout, an error will be raised.
 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
 RETURN VALUE
 ------------
 ------------

+ 1 - 1
src/modbus.c

@@ -440,7 +440,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
             /* If there is no character in the buffer, the allowed timeout
                interval between two consecutive bytes is defined by
                interval between two consecutive bytes is defined by
                byte_timeout */
                byte_timeout */