'\" t .\" Title: modbus_set_error_recovery .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.78.1 .\" Date: 10/18/2014 .\" Manual: Libmodbus Manual .\" Source: libmodbus 3.0.6 .\" Language: English .\" .TH "MODBUS_SET_ERROR_REC" "3" "10/18/2014" "libmodbus 3\&.0\&.6" "Libmodbus Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" modbus_set_error_recovery \- set the error recovery mode .SH "SYNOPSIS" .sp \fBint modbus_set_error_recovery(modbus_t *\fR\fB\fIctx\fR\fR\fB, modbus_error_recovery_mode \fR\fB\fIerror_recovery\fR\fR\fB);\fR .SH "DESCRIPTION" .sp The \fImodbus_set_error_recovery()\fR function shall set the error recovery mode to apply when the connection fails or the byte received is not expected\&. The argument \fIerror_recovery\fR may be bitwise\-or\(cqed with zero or more of the following constants\&. .sp By default there is no error recovery (\fIMODBUS_ERROR_RECOVERY_NONE\fR) so the application is responsible for controlling the error values returned by libmodbus functions and for handling them if necessary\&. .sp When \fIMODBUS_ERROR_RECOVERY_LINK\fR is set, the library will attempt an immediate reconnection (which may hang for several seconds if the network to the remote target unit is down)\&. This mode will try a infinite close/connect loop until success on send call and will just try one time to retablish the connection on select/read calls (if the connecton was down, the values to read are certainly not available anymore after reconnection, except for slave/server)\&. This mode will also run flush requests after a delay based on the current response timeout in some situations (eg\&. timeout of select call)\&. .sp When \fIMODBUS_ERROR_RECOVERY_PROTOCOL\fR is set, a sleep and flush sequence will be used to cleanup the ongoing communication, this can occurs when the message length is invalid, the TID is wrong or the received function code is not the expected one\&. .sp The modes are mask values and so they are complementary\&. .sp It\(cqs not recommended to enable error recovery for slave/server\&. .SH "RETURN VALUE" .sp The \fImodbus_set_error_recovery()\fR function shall return 0 if successful\&. Otherwise it shall return \-1 and set errno to one of the values defined below\&. .SH "ERRORS" .PP \fBEINVAL\fR .RS 4 The value of the argument \fIerror_recovery\fR is not positive\&. .RE .SH "EXAMPLE" .sp .if n \{\ .RS 4 .\} .nf modbus_set_error_recovery(ctx, MODBUS_ERROR_RECOVERY_LINK | MODBUS_ERROR_RECOVERY_PROTOCOL); .fi .if n \{\ .RE .\} .SH "AUTHORS" .sp The libmodbus documentation was written by St\('ephane Raimbault <\m[blue]\fBstephane\&.raimbault@gmail\&.com\fR\m[]\&\s-2\u[1]\d\s+2> .SH "NOTES" .IP " 1." 4 stephane.raimbault@gmail.com .RS 4 \%mailto:stephane.raimbault@gmail.com .RE