Skip to content

Commit 538e2e0

Browse files
committed
using syncWrite and syncRead new methods in Streams
1 parent 90396ab commit 538e2e0

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

usbserial/src/main/java/com/felhr/usbserial/SerialInputStream.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,7 @@ public int read(byte b[], int off, int len)
7373
return read(b);
7474
}
7575

76-
byte[] slice = new byte[len];
77-
int ret = device.syncRead(slice, timeout);
78-
System.arraycopy(slice, 0, b, off, ret);
79-
return ret;
76+
return device.syncRead(b, off, len, timeout);
8077
}
8178

8279
@Override

usbserial/src/main/java/com/felhr/usbserial/SerialOutputStream.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ public void write(byte b[], int off, int len)
4545
return;
4646
}
4747

48-
byte[] slice = new byte[len];
49-
System.arraycopy(b, off, slice, 0, len);
50-
device.syncWrite(slice, timeout);
48+
device.syncWrite(b, off, len, timeout);
5149
}
5250

5351
public void setTimeout(int timeout) {

0 commit comments

Comments
 (0)