Ok, I think I see what's going on here (I didn't look thru the usbsnoop 
trace, yet, as I think the input-before-output issue is the problem).

Also, besides the comments below, you shouldn't extend Thread.  You should 
extend Runnable and create a new Thread and pass your Runnable as the 
constructor's parameter.

On Thu, 12 Jun 2003, Benjamin Milde wrote:

>    List myConfigs = dev.getUsbConfigurations();
>    UsbConfiguration myConfig = (UsbConfiguration)myConfigs.get(0);
>    myInterface = (UsbInterface)(myConfig.getUsbInterfaces().get(0));
>    myInterface.claim();
>    List myEndpoints = myInterface.getUsbEndpoints();
>    UsbEndpoint myEndpointIn = (UsbEndpoint)myEndpoints.get(0);

I would suggest taking a more direct, and much more reliable, approach.  
Instead of using the List methods, ask for each object directly by its 
number or addresss, like this:

UsbConfiguration myConfig = dev.getUsbConfiguration((byte)1);
UsbInterface myInterface = myConfig.getUsbInterface((byte)0);
myInterface.claim();
UsbEndpoint myEndpointIn = myInterface.getUsbEndpoint((byte)0x82);
UsbEndpoint myEndpointOut = myInterface.getUsbEndpoint((byte)0x02);

that assumes your config is numbered 1, interface 0, and endpoints 0x82 
and 0x02.

>System.out.println(myEndpointIn.getUsbEndpointDescriptor().wMaxPacketSize()); 
><-- why is wMaxPacketSize = 64 and 
>    dev.getUsbDeviceDescriptor().bMaxPacketSize0() = 16?

because dev.getUsbDeviceDescriptor().bMaxPacketSize() refers to the 
Default Control Pipe's max packet size, just as the USB spec states.

>    myInputThread.start(); //start the thread, and submit a buffer to input 
>pipe, before send command to output.
>    //response = new byte[myLib.getbMaxPacketSize()];
>
>    myLib.send(Frame);

here is your problem.  You are starting the input-listening Thread, and 
then immediately submitting your output data.  Since Threads take time to 
start, your output is still going to happen before your input buffer is 
submitted (unless your output Thread gets scheduled out at exactly the 
right point).

What you need to do is add a delay so the input Thread has time to start 
and submit its buffer.  Try this:

myInputThread.start();
try { Thread.sleep(1000); } catch ( Exception e ) { }
myLib.send(Frame);

Of course a 1 second delay is quite generous.  10 or 20 milliseconds 
should do.

>javax.usb.UsbException: Error submitting IRP : Illegal byte sequence <-- 
>perhaps you can say what must happen for javaxusb to throw that exeption.

I am pretty sure this is because of the buffer being less than the 
bMaxPacketSize (64, in this case).  The system HCD has a 2-byte buffer, 
but the device sends all 64 bytes; and the HCD doesn't like it and 
generates this error.

Try using a bMaxPacketSized buffer (64 bytes).

>and I could't anymore connect to that device without a reboot.
>Strange.

sounds like the Linux USB subsystem died or thought the device was dead 
or unresponsive...hopefully shouldn't happen if your communication goes 
ok.

>To complet that mail, I give you a part of the usbsnooplog from windows, 
>perhaps you can read something in it that i can't....
>here it is:

if using a 64-byte buffer doesn't work, I'll look at it...

-- 
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: eBay
Great deals on office technology -- on eBay now! Click here:
http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5
_______________________________________________
javax-usb-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/javax-usb-devel

Reply via email to