| 1 | # modbus_set_byte_timeout |
| 2 | |
| 3 | ## Name |
| 4 | |
| 5 | modbus_set_byte_timeout - set timeout between bytes |
| 6 | |
| 7 | ## Synopsis |
| 8 | |
| 9 | ```c |
| 10 | int modbus_set_byte_timeout(modbus_t *ctx, uint32_t to_sec, uint32_t to_usec); |
| 11 | ``` |
| 12 | |
| 13 | ## Description |
| 14 | |
| 15 | The *modbus_set_byte_timeout()* function shall set the timeout interval between |
| 16 | two consecutive bytes of the same message. The timeout is an upper bound on the |
| 17 | amount of time elapsed before *select()* returns, if the time elapsed is longer |
| 18 | than the defined timeout, an `ETIMEDOUT` error will be raised by the |
| 19 | function waiting for a response. |
| 20 | |
| 21 | The value of `to_usec` argument must be in the range 0 to 999999. |
| 22 | |
| 23 | If both `to_sec` and `to_usec` are zero, this timeout will not be used at all. |
| 24 | In this case, *modbus_set_response_timeout()* governs the entire handling of the |
| 25 | response, the full confirmation response must be received before expiration of |
| 26 | the response timeout. When a byte timeout is set, the response timeout is only |
| 27 | used to wait for until the first byte of the response. |
| 28 | |
| 29 | ## Return value |
| 30 | |
| 31 | The function shall return 0 if successful. Otherwise it shall return -1 and set |
| 32 | errno. |
| 33 | |
| 34 | ## Errors |
| 35 | |
| 36 | - *EINVAL*, The argument `ctx` is NULL or `to_usec` is larger than 999999. |
| 37 | |
| 38 | ## See also |
| 39 | |
| 40 | - [modbus_get_byte_timeout](modbus_get_byte_timeout.md) |
| 41 | - [modbus_get_response_timeout](modbus_get_response_timeout.md) |
| 42 | - [modbus_set_response_timeout](modbus_set_response_timeout.md) |