我正在使用http://www.ftdichip.com/Android.htm
中的官方驱动程序03-20 13:37:52.359:WARN / FTDI(4453):开始阅读
03-20 13:37:52.359:WARN / FTDI(4453):6个字节可用
03-20 13:37:57.960:WARN / FTDI(4453):0字节读取
03-20 13:37:57.960:WARN / FTDI(4453):读完了
这方面的源代码很简单:
public int read(byte[] buffer, int timeout) throws IOException {
Log.w(TAG, "read starting");
try {
Log.w(TAG, device.getQueueStatus() + " bytes available");
int read = device.read(buffer);
Log.w(TAG, read + " bytes read");
return read;
} finally {
Log.w(TAG, "read finished");
}
}
他们的支持部门即使在一周后也没有回复我。我在Android 4.0.4上,有一个基于Arduino Duemilanove ftdi的主板。
答案 0 :(得分:3)
是的,我做到了..
您 要遵循此操作以便读取传入数据:
工作代码段:
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");
}
}