传输较大的数据USB量 [英] Transferring larger amounts of data USB

查看:100
本文介绍了传输较大的数据USB量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我一直在努力工作了一段时间,但我只是没有得到其中

我想获得字节从USB设备,这工作正常的一两行进来的,但是当它到达了不少这是行不通的。

我用这行code引入数据:

  conn.bulkTransfer(亿品,缓冲,57600,500);
 

有没有什么办法了一遍又一遍,直到有进来的没有更多的数据做了一个USB传输?因为数据进来的量可以是从8个字节任何一个几MB


在回答user387184

可否像这样的工作来传输数据,大量的?

 而(conn.bulkTransfer(亿品,缓冲,57600,500)0){
    \\做一些东西
}
 

解决方案

如果您的USB连接真正停止接收数据,如果没有更多的数据,那么所有你需要做的就是把一段时间receivedBufferIsNotEmpty在你的说法,因为:

  lenOfReceivedBuffer = conn.bulkTransfer(亿品,缓冲,57600,500);
 

获得 0 lenOfReceivedBuffer 如果没有更多的数据可以使用500毫秒超时的端口上找到。

您也可以增加超时了一下,如果你的发送端是太慢了。

Hey I have been trying to work on this for some time but I am just getting no where

I am trying to get bytes in from a USB device, this works fine for one or two lines coming in but when it gets to quite a few it just doesn't work.

I am using this line of code to bring in data:

conn.bulkTransfer(epIN, buffer, 57600, 500);

is there any way to do a USB transfer over and over again until there is no more data coming in? Because the amount of data coming in can be anything from 8 bytes to a few MB


In reply to user387184

Would something like this work to transfer large amounts of data?

while ( conn.bulkTransfer(epIN, buffer, 57600, 500) > 0 ){
    \\do some stuff
}

解决方案

If your USB connection really stops receiving data if there is no more data then all you need to do is to put a while receivedBufferIsNotEmpty around your statement since:

lenOfReceivedBuffer = conn.bulkTransfer(epIN, buffer, 57600, 500);

gets 0 in lenOfReceivedBuffer if no more data can be found on the port using 500ms timeout.

You may also increase the timeout a bit, if your sending side is too slow.

这篇关于传输较大的数据USB量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆