Fixed #2 by correcting how UART checks whether there is more input.
Previously In_stream.rdbuf()->in_avail() was used to see if there was more input. This is not always correct as the buffer can be empty even though there is more input to be had.
The fix instead checks for whether the position we have reached in the input is the last. If it is, it means there is no more input to be had. There is no other way to do this, as all other methods might block on no input.
Also used this opportunity to remove other uses of ifstream::rdbuf() to minimize future bugs.
Fixed #2 by correcting how UART checks whether there is more input.
Previously
In_stream.rdbuf()->in_avail()
was used to see if there was more input. This is not always correct as the buffer can be empty even though there is more input to be had. The fix instead checks for whether the position we have reached in the input is the last. If it is, it means there is no more input to be had. There is no other way to do this, as all other methods might block on no input.Also used this opportunity to remove other uses of
ifstream::rdbuf()
to minimize future bugs.