Android的USB主机 - bulkTransfer()是丢失数据主机、数据、Android、USB

2023-09-05 10:38:18 作者:思戀知幻即離

我想要一个基于FTDI 2232H芯片上从自定义设备接收数据。

I'm trying to receive data from a custom device based on an FTDI 2232H chip.

我使用的是简单的异步FIFO模式,输入数据速率为3.2MB /秒。

I am using a simple Async FIFO mode, and the incoming data rate is 3.2MB/sec.

一切都可以完美地与测试code我的电脑上,但我接受对我的东芝茁壮成长的数据有问题。

Everything works perfectly with test code on my PC, but I'm having problems receiving data on my Toshiba Thrive.

TDI的Andr​​oid驱动程序出现故障,所以我用Java编码。

TDI's Android driver fails, so I am coding using Java.

我可以接收数据的95%+完美的,但每过一段时间的数据溅射,我得到的数据同4-5K的部分两次或三次,然后再返回到良好的数据。

I can receive 95%+ of the data perfectly, but every once in a while the data 'sputters' and I get portions of the same 4-5K of data two or three times, then back to good data.

我不会太快茁壮成长还是Android,因为我previously了未来在双(6.4MB /秒)的数据,并得到了约95%这一点。 (因此,应该没有问题的一半。)

I am not going too fast for the Thrive or Android, because I previously had the data coming in at double (6.4MB/sec) and it got about 95% of that as well. (So it should have no problem at half the rate.)

好像有某种的缓冲(或双缓冲)的bug在Android的碰巧。 (它不是FTDI 2232H,因为重复的数据是比芯片的4K内部缓冲区大内的缓冲区。)

It seems like there is some sort of bug in the buffering (or double-buffering) that happens within Android. (It is not the buffer within the FTDI 2232H because the repeated data is larger than the chip's 4K internal buffer.)

的设置code是简单的,并再次它的工作〜差不多〜完美。

The setup code is simple, and again it's working ~almost~ perfectly.

在数据抓取时的循环是非常简单的:

The loop where the data grab occurs is very simple:

while(!fStop)
  if(totalLen < BIG_BUFF_LEN-IN_BUFF_LEN)
  {
    len=conn.bulkTransfer(epIN, inBuff, IN_BUFF_LEN, 0);
    System.arraycopy(inBuff, 0, bigBuff, totalLen, len);
    totalLen+=len;
  }

在情况下,你认为它的时间延迟了arraycopy - 我还是失去了数据,即使我评论这一行了。

In case you think it's the time delay for the arraycopy - I still lose the data even if I comment that line out.

该IN_BUFF_LEN为16384(bulkTransfer不会返回超过,即使我增加inBuff的大小)。

The IN_BUFF_LEN is 16384 (bulkTransfer won't return more than that even if I increase the size of the inBuff).

该bigBuff是几兆。

The bigBuff is several megabytes.

作为一个次要的问题 - 没有人知道如何传递一个指向bulkTransfer,这将直接填充bigBuff ---在一个偏移量(不从位置0

As a secondary question - does anyone know how to pass a pointer to bulkTransfer that will populate bigBuff directly --- at an offset (not starting at position '0'?

推荐答案

@Greg我有同样的问题,一个全速USB设备和修复程序是包括50毫秒每个轮询之间的延迟到Android内部USB缓冲区

@Greg I am having the same problem with a full speed usb device and the fix was to include a delay of 50ms between each polling to the ANdroid internal usb buffer.

 
精彩推荐