Automatically calculate proper read timeout for instructions. #12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR removes the manually provided
read_timeout
parameter, and instead uses the baud rate of the serial port and the message length to compute the expected response time.The timing is based on the fact that each byte going over the serial line takes 1 start bit, 8 data bits and 1 stop bit.
The downside is that we now need to query the serial port for the baud rate in
Bus::new()
andBus::with_buffers()
, so they can return an error.@omelia-iliffe: As part of this PR I removed
serial_port_mut()
again. It would allow to change the baud rate of the port, which makes the timeout computation inaccurate. Do you think there is an important enough use case for mutable access to the serial port that we should support it? Note that you don't need mutable access to read/write, only to configure the port.