| 1 | # modbus_get_response_timeout |
| 2 | |
| 3 | ## Name |
| 4 | |
| 5 | modbus_get_response_timeout - get timeout for response |
| 6 | |
| 7 | ## Synopsis |
| 8 | |
| 9 | ```c |
| 10 | int modbus_get_response_timeout(modbus_t *ctx, uint32_t *to_sec, uint32_t *to_usec); |
| 11 | ``` |
| 12 | |
| 13 | ## Description |
| 14 | |
| 15 | The *modbus_get_response_timeout()* function shall return the timeout interval |
| 16 | used to wait for a response in the `to_sec` and `to_usec` arguments. |
| 17 | |
| 18 | ## Return value |
| 19 | |
| 20 | The function shall return 0 if successful. Otherwise it shall return -1 and set |
| 21 | errno. |
| 22 | |
| 23 | Example: |
| 24 | |
| 25 | ```c |
| 26 | uint32_t old_response_to_sec; |
| 27 | uint32_t old_response_to_usec; |
| 28 | |
| 29 | /* Save original timeout */ |
| 30 | modbus_get_response_timeout(ctx, &old_response_to_sec, &old_response_to_usec); |
| 31 | |
| 32 | /* Define a new and too short timeout! */ |
| 33 | modbus_set_response_timeout(ctx, 0, 0); |
| 34 | ``` |
| 35 | |
| 36 | ## Errors |
| 37 | |
| 38 | - *EINVAL*, the context is NULL or one of `to_sec` / `to_usec` is NULL. |
| 39 | |
| 40 | ## See also |
| 41 | |
| 42 | - [modbus_set_response_timeout](modbus_set_response_timeout.md) |
| 43 | - [modbus_get_byte_timeout](modbus_get_byte_timeout.md) |
| 44 | - [modbus_set_byte_timeout](modbus_set_byte_timeout.md) |