Using the Host API how are you meant to know how many bytes have been
returned from a UsbRequest.queue() function? In the
UsbConnection.requestWait() function we return the request that was issued
but we don't return the number of bytes. Asynchronous USB transfers can't
work if we don't know this value.
request = new UsbRequest();
request.setClientData(bufferIndex);
request.initialize(usbConnection, bulkInEndpoint);
request.queue(buffer, MAX_TRANSFER_SIZE);
UsbRequest request = usbConnection.requestWait();
if (request != null) { // process the data....
In the native code I can see that we know how many bytes were read but this
information isn't passed back up into our Java application:
struct usb_request *usb_request_wait(struct usb_device *dev) // Native code....{
struct usbdevfs_urb *urb = NULL;
struct usb_request *req = NULL;
int res;
while (1) {
int res = ioctl(dev->fd, USBDEVFS_REAPURB, &urb);
D("USBDEVFS_REAPURB returned %d\n", res);
if (res < 0) {
if(errno == EINTR) {
continue;
}
D("[ reap urb - error ]\n");
return NULL;
} else {
D("[ urb @%p status = %d, actual = %d ]\n",
urb, urb->status, urb->actual_length);
req = (struct usb_request*)urb->usercontext;
req->actual_length = urb->actual_length;
}
break;
}
return req;}
static jobjectandroid_hardware_UsbDeviceConnection_request_wait(JNIEnv *env,
jobject thiz) // Java wrapper...{
struct usb_device* device = get_device_from_object(env, thiz);
if (!device) {
LOGE("device is closed in native_request_wait");
return NULL;
}
struct usb_request* request = usb_request_wait(device);
if (request)
return (jobject)request->client_data; // Ignores the actual_length
field?!?!?
else
return NULL;}
--
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