kopia lustrzana https://github.com/felHR85/UsbSerial
Merge pull request #137 from felHR85/bugfix/intermittentcrashes
Fix intermittent crashes with buffer readspull/140/head
commit
d1cea05561
|
@ -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'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -118,6 +118,7 @@ public class SerialBuffer
|
|||
|
||||
public synchronized void put(byte[] src)
|
||||
{
|
||||
if(src == null || src.length == 0) return;
|
||||
if(position == -1)
|
||||
position = 0;
|
||||
if(debugging)
|
||||
|
@ -148,6 +149,7 @@ public class SerialBuffer
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
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