proxy progress

This commit is contained in:
rusefi 2020-07-09 23:04:46 -04:00
parent af270cd164
commit de9fc7ea43
2 changed files with 12 additions and 0 deletions

View File

@ -155,6 +155,13 @@ public class IncomingDataBuffer {
return swap32(getInt()); return swap32(getInt());
} }
public short readShort() throws EOFException, InterruptedException {
boolean timeout = waitForBytes("readShort", System.currentTimeMillis(), 2);
if (timeout)
throw new IllegalStateException("Timeout in readShort");
return (short) swap16(getShort());
}
public int read(byte[] packet) throws InterruptedException { public int read(byte[] packet) throws InterruptedException {
boolean timeout = waitForBytes("read", System.currentTimeMillis(), packet.length); boolean timeout = waitForBytes("read", System.currentTimeMillis(), packet.length);
if (timeout) if (timeout)

View File

@ -7,6 +7,7 @@ import com.rusefi.binaryprotocol.BinaryProtocol;
import com.rusefi.binaryprotocol.IncomingDataBuffer; import com.rusefi.binaryprotocol.IncomingDataBuffer;
import com.rusefi.binaryprotocol.IoHelper; import com.rusefi.binaryprotocol.IoHelper;
import java.io.EOFException;
import java.io.IOException; import java.io.IOException;
/** /**
@ -51,4 +52,8 @@ public interface IoStream extends WriteStream {
void close(); void close();
IncomingDataBuffer getDataBuffer(); IncomingDataBuffer getDataBuffer();
default short readShort() throws EOFException, InterruptedException {
return getDataBuffer().readShort();
}
} }