This commit is contained in:
@@ -317,7 +317,7 @@ public class CDCSerialPort extends AbstractSerialPort {
|
||||
|
||||
@Override
|
||||
public int read(byte[] buffer, int offset, int length) throws IOException {
|
||||
int read = connection.bulkTransfer(in, buffer, length, 0);
|
||||
int read = connection.bulkTransfer(in, buffer, offset, length, 0);
|
||||
if (read < 0) return read;
|
||||
throwIfNegative(receiveControlTransfer(SERIAL_STATE, 0, statusBuffer), "Failed to read modem status (error: %s).");
|
||||
interpretModemData(statusBuffer[0], statusBuffer[1]);
|
||||
@@ -343,7 +343,7 @@ public class CDCSerialPort extends AbstractSerialPort {
|
||||
@Override
|
||||
public void write(byte[] buffer, int offset, int length) throws IOException {
|
||||
while (length > 0) {
|
||||
int res = connection.bulkTransfer(out, buffer, offset, buffer.length, 0);
|
||||
int res = connection.bulkTransfer(out, buffer, offset, length, 0);
|
||||
if (res < 0) throw new IOException(String.format("Failed to write bytes (error: %d)", res));
|
||||
offset += res;
|
||||
length -= res;
|
||||
|
||||
@@ -376,7 +376,7 @@ public class CP210XSerialPort extends AbstractSerialPort {
|
||||
|
||||
@Override
|
||||
public int read(byte[] buffer, int offset, int length) throws IOException {
|
||||
int read = connection.bulkTransfer(in, buffer, length, 0);
|
||||
int read = connection.bulkTransfer(in, buffer, offset, length, 0);
|
||||
if (read < 0) return read;
|
||||
interpretModemData(getModemState()[0], getCommStatus()[0]);
|
||||
return read;
|
||||
@@ -401,7 +401,7 @@ public class CP210XSerialPort extends AbstractSerialPort {
|
||||
@Override
|
||||
public void write(byte[] buffer, int offset, int length) throws IOException {
|
||||
while (length > 0) {
|
||||
int res = connection.bulkTransfer(out, buffer, offset, buffer.length, 0);
|
||||
int res = connection.bulkTransfer(out, buffer, offset, length, 0);
|
||||
if (res < 0) throw new IOException(String.format("Failed to write bytes (error: %d)", res));
|
||||
offset += res;
|
||||
length -= res;
|
||||
|
||||
@@ -383,7 +383,7 @@ public class FTDISerialPort extends AbstractSerialPort {
|
||||
@Override
|
||||
public void write(byte[] buffer, int offset, int length) throws IOException {
|
||||
while (length > 0) {
|
||||
int res = connection.bulkTransfer(out, buffer, offset, buffer.length, 0);
|
||||
int res = connection.bulkTransfer(out, buffer, offset, length, 0);
|
||||
if (res < 0) throw new IOException(String.format("Failed to write bytes (error: %d)", res));
|
||||
offset += res;
|
||||
length -= res;
|
||||
|
||||
Reference in New Issue
Block a user