Fixed input getting dropped if buffer is full.
This commit is contained in:
@@ -65,10 +65,8 @@ public final class Main {
|
||||
System.out.print((char) value);
|
||||
}
|
||||
|
||||
while (br.ready()) {
|
||||
if (!board.putValue((byte) br.read())) {
|
||||
break;
|
||||
}
|
||||
while (br.ready() && board.canPutValue()) {
|
||||
board.putValue((byte) br.read());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -184,18 +184,17 @@ public final class R5Board {
|
||||
return uart.getByte();
|
||||
}
|
||||
|
||||
public boolean putValue(final byte b) {
|
||||
if (!uart.canReceive()) {
|
||||
return false;
|
||||
}
|
||||
public boolean canPutValue() {
|
||||
return uart.canReceive();
|
||||
}
|
||||
|
||||
public void putValue(final byte b) {
|
||||
uart.putByte(b);
|
||||
if ((char) b == '\n') {
|
||||
while (uart.canReceive()) {
|
||||
uart.putByte((byte) 0); // HACK? Ensure we reach FIFO trigger level.
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private DeviceTree buildDeviceTree() {
|
||||
|
||||
Reference in New Issue
Block a user