modbus_set_response_timeout.txt 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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', long 'to_sec', long '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 the waiting before
  13. receiving the first byte of response is longer than the given timeout, the
  14. 'ETIMEDOUT' error will be raised by the function waiting for a response. When
  15. byte timeout is disabled, the full confirmation response must be received before
  16. expiration of 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 _to_sec_/_to_usec_ aren't equal or greater than 0 or
  26. _to_usec_ is not smaller than 1000000.
  27. EXAMPLE
  28. -------
  29. [source,c]
  30. -------------------
  31. long old_response_to_sec;
  32. long 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 and too short timeout! */
  36. modbus_set_response_timeout(ctx, 0, 0);
  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>