android - 官方 FTDI android 驱动程序 read() 不工作

标签 android driver ftdi

我正在使用来自 http://www.ftdichip.com/Android.htm 的官方驱动程序

03-20 13:37:52.359: WARN/FTDI(4453): read starting

03-20 13:37:52.359: WARN/FTDI(4453): 6 bytes available

03-20 13:37:57.960:WARN/FTDI(4453): 0 bytes read

03-20 13:37:57.960: WARN/FTDI(4453): read finished

这个的源代码很简单:

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 的开发板。

最佳答案

是的,我做到了..

必须遵循此以读取传入数据:

  1. 打开后调用restartInTask()
  2. 在读取之前获取可用的输入字节
  3. 只读可用字节数> 0

工作代码 fragment :

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");
        }
    }

关于android - 官方 FTDI android 驱动程序 read() 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15518214/

相关文章:

Android Jetpack 撰写文档

java - 使用从 Jackson 创建的对象在 Android 上使用 OrmLite 保存子集合

ListView 中的Android动画: create translation from bottom to top like Google Plus app

mysql - mySQL 的包装器使其看起来像 SQL Server?

c - 如何在 C 中将数据包写入 TAP 接口(interface)?

c# - 是否可以模拟 FTDI USB 设备?

android - Android 中是否可以在 ScrollView 的底部设置 TextView ?

driver - 在 NSIS 脚本中安装驱动程序

android - 传输数据 USB

ftdi - FTDI 的 libMPSSE 上的 "NULL expression encountered"