1MODBUS_SET_RESPONSE_(3)        libmodbus Manual        MODBUS_SET_RESPONSE_(3)
2
3
4

NAME

6       modbus_set_response_timeout - set timeout for response
7

SYNOPSIS

9       int modbus_set_response_timeout(modbus_t *ctx, uint32_t to_sec,
10       uint32_t to_usec);
11

DESCRIPTION

13       The modbus_set_response_timeout() function shall set the timeout
14       interval used to wait for a response. When a byte timeout is set, if
15       elapsed time for the first byte of response is longer than the given
16       timeout, an ETIMEDOUT error will be raised by the function waiting for
17       a response. When byte timeout is disabled, the full confirmation
18       response must be received before expiration of the response timeout.
19
20       The value of to_usec argument must be in the range 0 to 999999.
21

RETURN VALUE

23       The function shall return 0 if successful. Otherwise it shall return -1
24       and set errno.
25

ERRORS

27       EINVAL
28           The argument ctx is NULL, or both to_sec and to_usec are zero, or
29           to_usec is larger than 1000000.
30

EXAMPLE

32           uint32_t old_response_to_sec;
33           uint32_t old_response_to_usec;
34
35           /* Save original timeout */
36           modbus_get_response_timeout(ctx, &old_response_to_sec, &old_response_to_usec);
37
38           /* Define a new timeout of 200ms */
39           modbus_set_response_timeout(ctx, 0, 200000);
40

SEE ALSO

42       modbus_get_response_timeout(3) modbus_get_byte_timeout(3)
43       modbus_set_byte_timeout(3)
44

AUTHORS

46       The libmodbus documentation was written by Stéphane Raimbault
47       <stephane.raimbault@gmail.com>
48
49
50
51libmodbus v3.1.6                  01/19/2023           MODBUS_SET_RESPONSE_(3)
Impressum