modbus_set_error_recovery.txt 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. modbus_set_error_recovery(3)
  2. ============================
  3. NAME
  4. ----
  5. modbus_set_error_recovery - set the error recovery mode
  6. SYNOPSIS
  7. --------
  8. *int modbus_set_error_recovery(modbus_t *'ctx', modbus_error_recovery_mode 'error_recovery');*
  9. DESCRIPTION
  10. -----------
  11. The _modbus_set_error_recovery()_ function shall set the error recovery mode to
  12. apply when the connection fails or the date received are not expected.
  13. By default there is no error recovery ('MODBUS_ERROR_RECOVERY_NONE') so the
  14. application is responsible for controlling the error values returned by
  15. libmodbus functions and for handling them if necessary.
  16. When 'MODBUS_ERROR_RECOVERY_LINK' is set, the library will attempt an immediate
  17. reconnection (which may hang for several seconds if the network to the remote
  18. target unit is down). This mode will try a infinite close/connect loop until
  19. success on send call and will just try one time to retablish the connection on
  20. select/read calls (if the connecton was down, the values to read are certainly
  21. not available anymore after reconnection, except for slave/server). This mode
  22. will also run flush requests after a delay based on the current response timeout
  23. in some situations (eg. timeout of select call).
  24. When 'MODBUS_ERROR_RECOVERY_PROTOCOL' is set, a sleep and flush sequence will be
  25. used to cleanup the ongoing communication, this can occurs when the message
  26. length is invalid, the TID is wrong or the received function code is not the
  27. expected one.
  28. The modes are mask values and so they are complementary.
  29. It's not recommended to enable error recovery for slave/server.
  30. RETURN VALUE
  31. ------------
  32. The _modbus_set_error_recovery()_ function shall return 0 if
  33. successful. Otherwise it shall return -1 and set errno to one of the values
  34. defined below.
  35. ERRORS
  36. ------
  37. *EINVAL*::
  38. The value of the argument 'error_recovery' is not positive.
  39. EXAMPLE
  40. -------
  41. [source,c]
  42. -------------------
  43. modbus_set_error_recovery(ctx,
  44. MODBUS_ERROR_RECOVERY_LINK |
  45. MODBUS_ERROR_RECOVERY_PROTOCOL);
  46. -------------------
  47. AUTHORS
  48. -------
  49. The libmodbus documentation was written by Stéphane Raimbault
  50. <stephane.raimbault@gmail.com>