1MODBUS_SET_ERROR_REC(3)        Libmodbus Manual        MODBUS_SET_ERROR_REC(3)
2
3
4

NAME

6       modbus_set_error_recovery - set the error recovery mode
7

SYNOPSIS

9       int modbus_set_error_recovery(modbus_t *ctx, modbus_error_recovery_mode
10       error_recovery);
11

DESCRIPTION

13       The modbus_set_error_recovery() function shall set the error recovery
14       mode to apply when the connection fails or the byte received is not
15       expected. The argument error_recovery may be bitwise-or’ed with zero or
16       more of the following constants.
17
18       By default there is no error recovery (MODBUS_ERROR_RECOVERY_NONE) so
19       the application is responsible for controlling the error values
20       returned by libmodbus functions and for handling them if necessary.
21
22       When MODBUS_ERROR_RECOVERY_LINK is set, the library will attempt an
23       immediate reconnection (which may hang for several seconds if the
24       network to the remote target unit is down). This mode will try a
25       infinite close/connect loop until success on send call and will just
26       try one time to retablish the connection on select/read calls (if the
27       connecton was down, the values to read are certainly not available
28       anymore after reconnection, except for slave/server). This mode will
29       also run flush requests after a delay based on the current response
30       timeout in some situations (eg. timeout of select call).
31
32       When MODBUS_ERROR_RECOVERY_PROTOCOL is set, a sleep and flush sequence
33       will be used to cleanup the ongoing communication, this can occurs when
34       the message length is invalid, the TID is wrong or the received
35       function code is not the expected one.
36
37       The modes are mask values and so they are complementary.
38
39       It’s not recommended to enable error recovery for slave/server.
40

RETURN VALUE

42       The modbus_set_error_recovery() function shall return 0 if successful.
43       Otherwise it shall return -1 and set errno to one of the values defined
44       below.
45

ERRORS

47       EINVAL
48           The value of the argument error_recovery is not positive.
49

EXAMPLE

51           modbus_set_error_recovery(ctx,
52                                     MODBUS_ERROR_RECOVERY_LINK |
53                                     MODBUS_ERROR_RECOVERY_PROTOCOL);
54

AUTHORS

56       The libmodbus documentation was written by Stéphane Raimbault
57       <stephane.raimbault@gmail.com[1]>
58

NOTES

60        1. stephane.raimbault@gmail.com
61           mailto:stephane.raimbault@gmail.com
62
63
64
65libmodbus 3.0.8                   07/31/2019           MODBUS_SET_ERROR_REC(3)
Impressum