added chunked stream methods

pull/253/head
Charles Julian Knight 2019-06-26 13:39:01 -04:00
rodzic 1823f2b167
commit f52c67a134
2 zmienionych plików z 24 dodań i 0 usunięć

Wyświetl plik

@ -54,6 +54,18 @@ public class SerialInputStream extends InputStream
return device.syncRead(b, timeout);
}
@Override
public int read(byte b[], int off, int len)
{
if (off == 0 && len == b.length) {
return read(b);
}
byte[] slice = new byte[len];
int ret = device.syncRead(slice, timeout);
System.arraycopy(slice, 0, b, off, ret);
return ret;
}
@Override
public int available() throws IOException {
if(bufferSize > 0)

Wyświetl plik

@ -25,6 +25,18 @@ public class SerialOutputStream extends OutputStream
device.syncWrite(b, timeout);
}
@Override
public void write(byte b[], int off, int len)
{
if (off == 0 && len == b.length) {
write(b);
return;
}
byte[] slice = new byte[len];
System.arraycopy(b, off, slice, 0, len);
device.syncWrite(slice, timeout);
}
public void setTimeout(int timeout) {
this.timeout = timeout;
}