modbus_set_response_timeout.txt 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. modbus_set_response_timeout(3)
  2. ==============================
  3. NAME
  4. ----
  5. modbus_set_response_timeout - set timeout for response
  6. SYNOPSIS
  7. --------
  8. *int modbus_set_response_timeout(modbus_t *'ctx', uint32_t 'to_sec', uint32_t 'to_usec');*
  9. DESCRIPTION
  10. -----------
  11. The *modbus_set_response_timeout()* function shall set the timeout interval used
  12. to wait for a response. When a byte timeout is set, if elapsed time for the
  13. first byte of response is longer than the given timeout, an `ETIMEDOUT` error
  14. will be raised by the function waiting for a response. When byte timeout is
  15. disabled, the full confirmation response must be received before expiration of
  16. the response timeout.
  17. The value of _to_usec_ argument must be in the range 0 to 999999.
  18. RETURN VALUE
  19. ------------
  20. The function shall return 0 if successful. Otherwise it shall return -1 and set
  21. errno.
  22. ERRORS
  23. ------
  24. *EINVAL*::
  25. The argument _ctx_ is NULL, or both _to_sec_ and _to_usec_ are zero, or _to_usec_
  26. is larger than 1000000.
  27. EXAMPLE
  28. -------
  29. [source,c]
  30. -------------------
  31. uint32_t old_response_to_sec;
  32. uint32_t old_response_to_usec;
  33. /* Save original timeout */
  34. modbus_get_response_timeout(ctx, &old_response_to_sec, &old_response_to_usec);
  35. /* Define a new timeout of 200ms */
  36. modbus_set_response_timeout(ctx, 0, 200000);
  37. -------------------
  38. SEE ALSO
  39. --------
  40. linkmb:modbus_get_response_timeout[3]
  41. linkmb:modbus_get_byte_timeout[3]
  42. linkmb:modbus_set_byte_timeout[3]
  43. AUTHORS
  44. -------
  45. The libmodbus documentation was written by Stéphane Raimbault
  46. <stephane.raimbault@gmail.com>