modbus_set_error_recovery.txt 2.2 KB

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