Skip to content
Snippets Groups Projects
Commit f94e47e1 authored by Lennart Goedhart's avatar Lennart Goedhart
Browse files

Distinguish a HID timeout from no data received.

parent 80f4b781
No related branches found
No related tags found
No related merge requests found
...@@ -9,8 +9,6 @@ import android.util.Log; ...@@ -9,8 +9,6 @@ import android.util.Log;
import java.io.IOException; import java.io.IOException;
//import com.hoho.android.usbserial.driver.UsbId;
/** /**
* USB HID Driver implementation. * USB HID Driver implementation.
* *
...@@ -89,14 +87,10 @@ public class UsbHidDriver extends CommonUsbDriver { ...@@ -89,14 +87,10 @@ public class UsbHidDriver extends CommonUsbDriver {
int readAmt = Math.min(dest.length, mReadBuffer.length); int readAmt = Math.min(dest.length, mReadBuffer.length);
numBytesRead = mConnection.bulkTransfer(mReadEndpoint, mReadBuffer, readAmt, numBytesRead = mConnection.bulkTransfer(mReadEndpoint, mReadBuffer, readAmt,
timeoutMillis); timeoutMillis);
if (numBytesRead < 0) { if (numBytesRead > 0) {
// This sucks: we get -1 on timeout, not 0 as preferred. System.arraycopy(mReadBuffer, 0, dest, 0, numBytesRead);
// We *should* use UsbRequest, except it has a bug/api oversight
// where there is no way to determine the number of bytes read
// in response :\ -- http://b.android.com/28023
return 0;
} }
System.arraycopy(mReadBuffer, 0, dest, 0, numBytesRead);
mConnection.releaseInterface(mInterface); mConnection.releaseInterface(mInterface);
} }
return numBytesRead; return numBytesRead;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment