|
From: Dan S. <dds...@ie...> - 2013-10-04 17:58:33
|
On Thu, Oct 3, 2013 at 11:01 PM, SANJAY GUPTA <gup...@sa...> wrote:
>
> Thanks,
> Sanjay Gupta<p> </p><p> </p>
>
> ------- Original Message -------
> Sender : Dan Streetman<dds...@ie...>
> Date : Oct 02, 2013 22:31 (GMT+09:00)
> Title : Re: [javax-usb-devel] Hang problem with UsbPipe.syncSubmit(byte[])
>
>
>
> On Wed, Oct 2, 2013 at 6:23 AM, SANJAY GUPTA <gup...@sa...> wrote:
> > Hi All,
> >
> > Please look below the sample scenario:-
> >
> > final byte[] outData = new byte[] {
> > (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03,
> > (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07,
> > (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
> > (byte) 0x08, (byte) 0x09, (byte) 0x0A, (byte) 0x01B,
> > (byte) 0x0C, (byte) 0x0D, (byte) 0x0E, (byte) 0x0F,
> > (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03,
> > (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07,
> > (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 }
> > final byte[] inData = new byte[13];
> >
> > log("Synchronously submitting the byte[] to UsbPipe ...");
> > outUsbPipe.syncSubmit(data);
> >
> > //Synchronously read the status from IN UsbPipe
> > log("Synchronously reading the status from IN UsbPipe ...");
> > inUsbPipe.syncSubmit(inData);
> >
> > This code is working fine but I am facing problem if I want to change (reduce/reduce/modify) the outData.
> > The control gets hang on reading the status data from the Input UsbPipe.
> > Any suggestion on below points will be helpful:-
> > 1. Is there any specific data format (may be starting header) in the actual data being transferred?
>
> Data formats are entirely up to the device, unless the device
> implements a higher level spec (like HID, mass storage, etc) that
> itself contains the API for the data format. USB doesn't specify any
> data format at all, except for the control pipe 8-byte setup packet
> that must preface each control transfer, and the various default
> control pipe standard requests (set interface, clear stall, etc).
>
> ===> Thanks A lot. I am using a mass-storage device and BULK type UsbEndpoint for data transfer.
>
> But the problem is, suppose I keep the value of outData[8] as non-zero with all other things intact, the submission gets hanged which never completes.
>
> And then I have no choice but the unplug the device.
Sorry, I don't understand what you are talking about.
>
>
>
> > 2. What is the data size which can be transferred using single invocation of syncSubmit()?
>
> it's been a while, but IIRC there's no limit in java, although I think
> the platform may enforce limits. I don't really remember the details
> though. For interrupt pipes, you of course should usually submit
> exactly the pipe size (wMaxPacketSize).
>
> ===> Mass-storage device and BULK type UsbEndpoint.
I believe the only restriction on size is from the platform (i.e. OS),
for which you should get a UsbPlatformException if you exceed it (I
think). Last I checked (a long time ago) I believe it was around 16k
max for bulk. But remember that no more than the device's max packet
size will be transferred at once; the OS will break up your larger
buffer into max packet sized chunks and transfer those. So really,
you do not need to transfer gigantic buffers - just break it up into
reasonably-sized buffers and submit them; you can asyncSubmit()
multiple buffers at once which will queue up and transfer as fast as
one giant buffer would.
>
> > 3. What is the status data size which is received on Input Pipe as a result of out data transfer?
>
> it's entirely dependent on your device. although if your input pipe
> is an interrupt pipe, it should be the wMaxPacketSize from the
> endpoint descriptor.
>
> Also, assuming your input pipe is interrupt type, it's probably better
> for you to keep a buffer on it, which will cause continuous polling of
> the device, as required by spec when the device is in use. You can do
> that either with a separate Thread that does nothing except
> syncSubmit() a buffer or irp to the pipe, then passes the returned
> data off somewhere else to process and immediately syncSubmit() a new
> buffer, or you can use asyncSubmit() with either a listener on the
> pipe or a separate Thread to waitUntilComplete() for the irp, and then
> also hand off the returned data to process somewhere else and
> immediately sync or async submit again a new buffer. With
> asyncSubmit(), you can submit multiple buffers, which is better
> because it keeps the low level platform queued up with buffers so that
> the device polling never stops, and you don't have to try to be quite
> so fast at resubmitting a new buffer.
>
> ===> Mass-storage device and BULK type UsbEndpoint.
The size on an input bulk pipe is entirely up to the device; but
again, it's transferred at the low level in max packet sized chunks.
So just asyncSubmit multiple buffers that are a sized as a multiple of
the max packet size, or even just buffers that are exactly the max
packet size.
>
>
>
> >
> > Thanks in Advance..
> > Sanjay Gupta
> >
> > ------------------------------------------------------------------------------
> > October Webinars: Code for Performance
> > Free Intel webinars can help you accelerate application performance.
> > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
> > the latest Intel processors and coprocessors. See abstracts and register >
> > http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
> > _______________________________________________
> > javax-usb-devel mailing list
> > jav...@li...
> > https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
>
>
> ------------------------------------------------------------------------------
> October Webinars: Code for Performance
> Free Intel webinars can help you accelerate application performance.
> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
> the latest Intel processors and coprocessors. See abstracts and register >
> http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
> _______________________________________________
> javax-usb-devel mailing list
> jav...@li...
> https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
>
|