Hello,
Thanks for the reply. I tried calling bulkTransfer multiple times, but
I get the same values again. The code is as follows:
byte[] buffer =new byte[2];
int length= 2;
int TIMEOUT= 0;
UsbDeviceConnection connection= ourUsbManager.openDevice(device);
connection.claimInterface(intf, true);
ep= intf.getEndpoint(0);
for (int j= 0; j<32; j++){
connection.bulkTransfer(ep, buffer, length, TIMEOUT);
for(int i= 0; i<buffer.length; i++){
dataTextView.append(String.valueOf(buffer[i]));
dataTextView.append(" ");
}
}
The bytes that I see in Log is: [B@406bda38 and the corresponding Hex
string 1 60 or sometimes 1 61. Any suggestions in the implementation
part?
Thanks.
On Apr 4, 10:09 am, al <[email protected]> wrote:
> 64 is the _max_ packet size. A single transfer may be shorter; it does not
> matter if the rest of the buffer is filled with zeros or some garbage since
> the "data" transfered is contained in just the first x bytes of the buffer
> where x is the return value from bulkTransfer. For continuous transfer,
> just call bulkTransfer multiple times. I don't know why you want to set a
> baud rate. You don't do this with usb transfers.
>
> Am Dienstag, 3. April 2012 20:14:30 UTC+2 schrieb ashish sharma:
>
>
>
>
>
>
>
>
>
> > Hello,
>
> > I am working with Lenovo tablet (Android 3.1) and I want to fetch data
> > from Telosb sensor. The sensor has following interface and endpoint
>
> > Interface 0
> > Endpoint 0: Inbound, type- bulk, max packet size- 64
> > Endpoint 1: Outbound, type- bulk, max packet size- 64
>
> > I want to read the data from sensor and I used UsbDeviceConnection and
> > bulkTransfer(endpoint, buffer, length, timeout) method to get the data. The
> > "byte[] buffer" field in the method must have the data from the sensor at
> > endpoint 0 is what I understand from the documentation. When I read in this
> > way, only 2 bytes (length= 64) are read and rest are zeros. Can anyone
> > explain what might be the cause for this? Also, how do I set the baud rate?
> > How do I read data from the sensor continuously?
>
> > Thanks,
> > Ashish.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en