That really depends entirely on your device.  USB does not specify any 
higher-level protocol such as that, the only protocol specified by USB is 
a per-packet protocol, which is essentially at the UsbIrp level (actually, 
that breaks down to the on-the-wire max-packet-sized packets).  So there 
is no way I, or javax-usb, can know when your device has no more data to 
send.  It is possible it might send a short packet (e.g. either the last 
packet of data is short, and/or the next packet contains no data 
transferred).  However USB doesn't require it to.  For bulk and interrupt 
pipes, the device could NAK all day long (i.e. send no respose at all, and 
the UsbIrp waits forever).  Isochronous pipes are different but you 
probably aren't using them for a scanner.  Control pipes (e.g. the DCP) 
are different too and can't block forever, however control pipes are 
rarely used for an unknown amount of data, since some device-specific 
protocol is usually involved in control transfers.

Basically, it's device-specific.  Do you have your device spec and/or know 
the specifics of the device protocol?


On Mon, 12 Apr 2004, Francisco Fernandez Velasco wrote:

>Hi there,
>
>I've a doubt related to a scanner device I'm accessing to through the
>javax-usb API. To send to device the bytes that order it starts image
>scanning works fine. I use syncSubmit in its OUT PIPE and the scanner
>works fine!!
>The matter is that, when retrieving the image, I use different UsbIrps
>(one per image chunk I retrieve), but the problem is that I have NO way
>to know when to stop requesting bytes. Is there any way to resolve when
>the device has no data to send? Is it correct to assume that an UsbIrp
>with actualLenght set as zero would mean that there's nothing else to
>send?
>
>Is this piece of code correct?
>
>       do {
>           //IN PIPE (device to host)
>            UsbIrp usbIrp = inPipe.createUsbIrp();
>            usbIrp.setAcceptShortPacket( true );
>            usbIrp.setLength( 1024 );
>            usbIrp.setOffset( 0 );
>            usbIrp.setData  ( new byte[ 1024 ] );
>
>            try {
>               //SYNC REQUEST: Locked till device response!!
>                inPipe.syncSubmit( usbIrp );
>            } catch ( Exception e ) {
>                printStackTrace( e );
>            }
>            //Storing image data for later use!!
>            buffer.append ( usbIrp.getData() );
>       } while (  usbIrp.getActualLength () != 0);
>
>
>Thanks in advance
>
>
>
>
>-------------------------------------------------------
>This SF.Net email is sponsored by: IBM Linux Tutorials
>Free Linux tutorial presented by Daniel Robbins, President and CEO of
>GenToo technologies. Learn everything from fundamentals to system
>administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
>_______________________________________________
>javax-usb-devel mailing list
>[EMAIL PROTECTED]
>https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
>

-- 
Dan Streetman
[EMAIL PROTECTED]
---------------------
186,272 miles per second:
It isn't just a good idea, it's the law!


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
javax-usb-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/javax-usb-devel

Reply via email to