Sorry, I misread your code - you can call isComplete() and then
submit. But, you have to check and act on the result of isComplete()
- the method does not _do_ anything, just tells you status. If it is
not complete you should not do anything with it, wait for it to
complete.
You also need to implement a pipe listener to get notification of all
these async-submitted irps coming back, or use a seperate thread.
On Feb 18, 2008 9:56 AM, Dan Streetman <[EMAIL PROTECTED]> wrote:
> Please copy the mailing list.
>
> You clearly cannot do irp.setComplete() and then try to submit it.
> What are you trying to accomplish by trying to do that?
>
> If you want to re-use irps, you need to reset the fields before
> re-submitting it (and obviously you have to be sure the irp is
> complete before trying to re-submit). See the pipe and irp
> documentation.
>
> The easiest thing for you to do it just create a new irp each time you
> want to submit one. The Java GC and memory manager is really quite
> good so you might as well just do this.
>
>
> On Feb 17, 2008 6:25 PM, Christoph Ott <[EMAIL PROTECTED]> wrote:
> > Now I got another Problem :(
> >
> > I have to send a Packet which give the device the Information that a new
> > Packet will come (bytesToSend2) - I have to send it twice (dont know why
> > but It works with the second one *G*)
> >
> > after that I get from the device a Packet that It will be ready to
> > receive(bytesToRead2)
> >
> > Now I want to send the Packet with the Product_Request but I get this
> > Exception:
> >
> > javax.usb.UsbException: UsbIrp cannot be used while isComplete() is
> > true.
> > at com.ibm.jusb.UsbIrpImp.checkUsbIrp(UsbIrpImp.java:160)
> > at
> > com.ibm.jusb.UsbPipeImp.usbIrpToUsbIrpImp(UsbPipeImp.java:435)
> > at com.ibm.jusb.UsbPipeImp.asyncSubmit(UsbPipeImp.java:208)
> > at USBLister.IODevices(USBLister.java:191)
> > at USBLister.main(USBLister.java:239)
> >
> >
> > I tried isComplete, WaitUntilComplete and I closed it and re-open the
> > UsbIrp.
> >
> > Here is my Code:
> > --------------------------------------------------------------------------------
> > public void IODevices(UsbDevice device){
> > try{
> > device.getActiveUsbConfiguration();
> > UsbConfiguration config = device.getActiveUsbConfiguration();
> > UsbInterface interf = config.getUsbInterface((byte)0);
> > interf.claim(new UsbInterfacePolicy() {
> > public boolean forceClaim(UsbInterface usbInterface) {
> > return true;
> > }
> > });
> > List totalEndpoints = interf.getUsbEndpoints();
> > UsbEndpoint ep = null;
> >
> > //Endpoints
> > UsbEndpoint pipeInEndP = (UsbEndpoint) totalEndpoints.get(0);
> > UsbEndpoint pipeOutEndP = (UsbEndpoint) totalEndpoints.get(2);
> > UsbEndpoint pipeInterruptP = (UsbEndpoint) totalEndpoints.get(1);
> >
> > //Pipes
> > UsbPipe pipeIn = pipeInEndP.getUsbPipe();
> > pipeIn.open();
> > UsbPipe pipeOut = pipeOutEndP.getUsbPipe();
> > pipeOut.open();
> > UsbPipe pipeInterrupt = pipeInterruptP.getUsbPipe();
> > pipeInterrupt.open();
> >
> >
> > byte[] bytesToSend = new byte[12];
> > //Application
> > bytesToSend[0] = (byte) 0x00;
> > //Reserved
> > bytesToSend[1] = (byte) 0x00;
> > bytesToSend[2] = (byte) 0x00;
> > bytesToSend[3] = (byte) 0x00;
> > //PacketId
> > short s = (byte) 0x05;
> > bytesToSend[4] = (byte) (((byte) s) & 0xff);
> > bytesToSend[5] = (byte) ((((byte) s) & 0xff00) >> 8);
> > //Reserved2
> > bytesToSend[6] = (byte) 0x00;
> > bytesToSend[7] = (byte) 0x00;
> > //DataSize
> > int i = 0;
> > bytesToSend[8] = (byte) (i & 0xff);
> > bytesToSend[9] = (byte) ((i & 0xff00) >> 8);
> > bytesToSend[10] = (byte) ((i & 0xff0000) >> 16);
> > bytesToSend[11] = (byte) ((i & 0xff000000) >> 24);
> >
> > byte[] bytesToSend2 = new byte[12];
> > //Application
> > bytesToSend2[0] = (byte) 0x14;
> > //Reserved
> > bytesToSend2[1] = (byte) 0x00;
> > bytesToSend2[2] = (byte) 0x00;
> > bytesToSend2[3] = (byte) 0x00;
> > //PacketId
> > short s2 = (byte) 0xfe;
> > bytesToSend2[4] = (byte) (((byte) s2) & 0xff);
> > bytesToSend2[5] = (byte) ((((byte) s2) & 0xff00) >> 8);
> > //Reserved2
> > bytesToSend2[6] = (byte) 0x00;
> > bytesToSend2[7] = (byte) 0x00;
> > //DataSize
> > int i2 = 0;
> > bytesToSend2[8] = (byte) (i2 & 0xff);
> > bytesToSend2[9] = (byte) ((i2 & 0xff00) >> 8);
> > bytesToSend2[10] = (byte) ((i2 & 0xff0000) >> 16);
> > bytesToSend2[11] = (byte) ((i2 & 0xff000000) >> 24);
> >
> > //I have to send the Datapacket twice
> > UsbIrp irpSend = pipeOut.createUsbIrp();
> > irpSend.setData(bytesToSend);
> > pipeOut.asyncSubmit(irpSend);
> > irpSend.isComplete();
> > pipeOut.asyncSubmit(irpSend);
> >
> > byte[] bytesToRead2 = new byte[255];
> >
> > UsbIrp irpInterrupt = pipeInterrupt.createUsbIrp();
> > irpInterrupt.setData(bytesToRead2);
> > pipeInterrupt.asyncSubmit(irpInterrupt);
> > irpInterrupt.waitUntilComplete(1000);
> >
> > System.out.println("Interrupt-Bulk");
> > System.out.println("-----------------------");
> > for (int x = 0; x < 20; x++){
> > System.out.print(bytesToRead2[x]+" ");
> > }
> > System.out.println();
> >
> > irpSend.setData(bytesToSend2);
> > pipeOut.asyncSubmit(irpSend); //Here is the Error
> > irpSend.isComplete();
> >
> > byte[] bytesToRead = new byte[255];
> >
> > UsbIrp irpRead = pipeIn.createUsbIrp();
> > irpRead.setData(bytesToRead2);
> > pipeIn.asyncSubmit(irpRead);
> > irpRead.waitUntilComplete(1000);
> >
> > System.out.println("In-Bulk: ");
> > System.out.println("-----------------------");
> > for (int x = 0; x < 255; x++){
> > System.out.print(bytesToRead[x]+" ");
> > }
> > System.out.println();
> >
> > pipeIn.abortAllSubmissions();
> > pipeOut.abortAllSubmissions();
> > pipeInterrupt.abortAllSubmissions();
> > pipeIn.close();
> > pipeOut.close();
> > pipeInterrupt.close();
> > interf.release();
> >
> > }catch(Exception ex){
> > ex.printStackTrace();
> > }
> >
> > }
> >
> >
> >
> > ----------------------------------------------------------------------------------------------------------
> >
> >
> > Am Donnerstag, den 14.02.2008, 17:19 -0500 schrieb Dan Streetman:
> >
> > > According to the brief part of the spec I read, you have to listen on
> > > the interrupt pipe also as the device can send responses on either
> > > pipe. You should either asynchronously submit multiple IRPs on the
> > > interrupt-in pipe and have the pipe listener handle and then resubmit
> > > each one, or you should create a dedicated thread to just manage IRPs
> > > on the interrupt-in pipe. In any case you need to listen to it.
> > >
> > > As far as if you are sending the right commands to the device or not,
> > > i don't have the time to get into the garmin spec to tell you if you
> > > are or not...
> > >
> > > On Thu, Feb 14, 2008 at 7:51 AM, Christoph Ott <[EMAIL PROTECTED]> wrote:
> > > > Hi maybe anyone can read he garmin sdk :
> > > > http://www8.garmin.com/support/pdf/IOSDK.zip
> > > >
> > > > I don't know what I do wrong but I only get zeros :(
> > > >
> > > > Here is my Code:
> > > >
> > > > public void IODevices(UsbDevice device){
> > > > try{
> > > > device.getActiveUsbConfiguration();
> > > > UsbConfiguration config =
> > > > device.getActiveUsbConfiguration();
> > > > UsbInterface interf = config.getUsbInterface((byte)0);
> > > > interf.claim(new UsbInterfacePolicy() {
> > > > public boolean forceClaim(UsbInterface
> > > > usbInterface) {
> > > > return true;
> > > > }
> > > > });
> > > > List totalEndpoints = interf.getUsbEndpoints();
> > > > UsbEndpoint ep = null;
> > > > //Endpoints
> > > > UsbEndpoint pipeInEndP = (UsbEndpoint)
> > > > totalEndpoints.get(0);
> > > > UsbEndpoint pipeOutEndP = (UsbEndpoint)
> > > > totalEndpoints.get(2);
> > > >
> > > > //Pipes
> > > > UsbPipe pipeIn = pipeInEndP.getUsbPipe();
> > > > pipeIn.open();
> > > > UsbPipe pipeOut = pipeOutEndP.getUsbPipe();
> > > > pipeOut.open();
> > > >
> > > > short mReserved2 = 0;
> > > > short mPacketId = 254;
> > > > int mDataSize = 0;
> > > > byte[] bytesToSend = new byte[12];
> > > > bytesToSend[0] = 20;
> > > > bytesToSend[1] = 0;
> > > > bytesToSend[2] = (byte) (mReserved2 & 0xFF); //Short to
> > > > Byte
> > > > bytesToSend[3] = (byte) ((mReserved2 & 0xff00 ) >> 8);
> > > > //Short to Byte
> > > > bytesToSend[4] = (byte) (mPacketId & 0xFF); //Short to
> > > > Byte
> > > > bytesToSend[5] = (byte) ((mPacketId & 0xff00 ) >> 8);
> > > > //Short to Byte
> > > > bytesToSend[6] = (byte) (mReserved2 & 0xFF); //Short to
> > > > Byte
> > > > bytesToSend[7] = (byte) ((mReserved2 & 0xff00 ) >> 8);
> > > > //Short to Byte
> > > > bytesToSend[8] = (byte) (mDataSize >>24); //unsigned
> > > > long to Byte
> > > > BytesToSend[9] = (byte) ((mDataSize << 8) >> 24);
> > > > BytesToSend[10] = (byte) ((mDataSize << 16) >> 24);
> > > > bytesToSend[11] = (byte) ((mDataSize << 24) >> 24);
> > > >
> > > > UsbIrp irpSend = pipeOut.createUsbIrp();
> > > > IrpSend.setData(bytesToSend);
> > > > pipeOut.asyncSubmit(irpSend);
> > > > irpSend.waitUntilComplete(1000);
> > > >
> > > > byte[] bytesToRead = new byte[255];
> > > > UsbIrp irpRead = pipeIn.createUsbIrp();
> > > > irpRead.setData(bytesToRead);
> > > > pipeIn.asyncSubmit(irpRead);
> > > > irpRead.waitUntilComplete(1000);
> > > > pipeIn.abortAllSubmissions();
> > > > pipeOut.abortAllSubmissions();
> > > > pipeIn.close();
> > > > pipeOut.close();
> > > > interf.release();
> > > >
> > > > int pid,sv;
> > > > pid =(bytesToRead[0] & 0xff);
> > > > sv =(bytesToRead[1] & 0xff);
> > > > pid= bytes_to_int(bytesToRead);
> > > > sv= bytes_to_int(bytesToRead, 4);
> > > > System.out.println("pid: " + pid + "; sv: " + sv);
> > > >
> > > > System.out.println(bytesToRead);
> > > > }catch(Exception ex){
> > > > ex.printStackTrace();
> > > > }
> > > > }
> > > >
> > > > int bytes_to_int(byte b[], int start) {
> > > > int i = ((b[start + 3] & 0xff) << 24) + ((b[start + 2] & 0xff)
> > > > << 16) +
> > > > ((b[start + 1] & 0xff) << 8) + (b[start] & 0xff);
> > > > return i;
> > > > }
> > > > int bytes_to_int(byte b[]) {
> > > > /* as above, but start == 0 */
> > > > return bytes_to_int(b, 0);
> > > > }
> > > >
> > > >
> > > >
> > > > -------------------------------------------------------------------------
> > > > This SF.net email is sponsored by: Microsoft
> > > > Defy all challenges. Microsoft(R) Visual Studio 2008.
> > > > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> > > > _______________________________________________
> > > > javax-usb-devel mailing list
> > > > [email protected]
> > > > https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
> > > >
> >
> >
>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
javax-usb-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/javax-usb-devel