kopia lustrzana https://github.com/felHR85/UsbSerial
returning a 0 length array when position -1
rodzic
09a3f869ec
commit
e9d27bbba0
|
@ -3,7 +3,7 @@ buildscript {
|
|||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.2.0'
|
||||
classpath 'com.android.tools.build:gradle:2.2.3'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ public class SerialBuffer
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if(position <= -1 ) return new byte[DEFAULT_READ_BUFFER_SIZE];
|
||||
if(position <= -1 ) return new byte[0];
|
||||
byte[] dst = Arrays.copyOfRange(buffer, 0, position);
|
||||
if(debugging)
|
||||
UsbSerialDebugger.printLogGet(dst, true);
|
||||
|
|
|
@ -304,7 +304,8 @@ public abstract class UsbSerialDevice implements UsbSerialInterface
|
|||
while(working.get())
|
||||
{
|
||||
byte[] data = serialBuffer.getWriteBuffer();
|
||||
connection.bulkTransfer(outEndpoint, data, data.length, USB_TIMEOUT);
|
||||
if(data.length > 0)
|
||||
connection.bulkTransfer(outEndpoint, data, data.length, USB_TIMEOUT);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -99,7 +99,8 @@ public abstract class UsbSpiDevice implements UsbSpiInterface
|
|||
while(working.get())
|
||||
{
|
||||
byte[] data = serialBuffer.getWriteBuffer();
|
||||
connection.bulkTransfer(outEndpoint, data, data.length, USB_TIMEOUT);
|
||||
if(data.length > 0)
|
||||
connection.bulkTransfer(outEndpoint, data, data.length, USB_TIMEOUT);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue