Przeglądaj źródła

Provides a way to disable the byte timeout.

Alex Stapleton 13 lat temu
rodzic
commit
602a7f3859
2 zmienionych plików z 4 dodań i 1 usunięć
  1. 3 0
      doc/modbus_set_byte_timeout.txt
  2. 1 1
      src/modbus.c

+ 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
 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
 ------------

+ 1 - 1
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 */