Yes, i did it..
You have to follow this in order to read incoming data:
- invoke restartInTask() after opening
- get available input bytes before reading
- read only if available bytes count > 0
working code snippet:
public int read(byte[] buffer, int timeout) throws IOException {
params.setReadTimeout(timeout);
Log.w(TAG, "read starting");
try {
int available = device.getQueueStatus();
Log.w(TAG, available + " bytes available");
if (available <= 0)
return 0;
int read = device.read(buffer, available, timeout);
Log.w(TAG, read + " bytes read");
return read;
} finally {
Log.w(TAG, "read finished");
}
}