t-crest / patmos-simulator

Host the Patmos ISA simulator
2 stars 2 forks source link

Corrected how uart checks for more input. #3

Closed Emoun closed 4 years ago

Emoun commented 4 years ago

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.