1 # modbus_set_response_timeout
5 modbus_set_response_timeout - set timeout for response
10 int modbus_set_response_timeout(modbus_t *ctx, uint32_t to_sec, uint32_t to_usec);
15 The *modbus_set_response_timeout()* function shall set the timeout interval used
16 to wait for a response. When a byte timeout is set, if elapsed time for the
17 first byte of response is longer than the given timeout, an `ETIMEDOUT` error
18 will be raised by the function waiting for a response. When byte timeout is
19 disabled, the full confirmation response must be received before expiration of
22 The value of `to_usec` argument must be in the range 0 to 999999.
26 The function shall return 0 if successful. Otherwise it shall return -1 and set
31 - *EINVAL*, the argument `ctx` is NULL, or both `to_sec` and `to_usec` are zero,
32 or `to_usec` is larger than 999999.
37 uint32_t old_response_to_sec;
38 uint32_t old_response_to_usec;
40 /* Save original timeout */
41 modbus_get_response_timeout(ctx, &old_response_to_sec, &old_response_to_usec);
43 /* Define a new timeout of 200ms */
44 modbus_set_response_timeout(ctx, 0, 200000);
49 - [modbus_get_response_timeout](modbus_get_response_timeout.md)
50 - [modbus_get_byte_timeout](modbus_get_byte_timeout.md)
51 - [modbus_set_byte_timeout](modbus_set_byte_timeout.md)