you have multiple submits in there, so which syncSubmit does it freeze on? You know, control submissions are expected to finish immediately, but interrupt-in (and bulk-in) submissions will remain pending indefinitely until the device has something to send, so if you do a syncSubmit on an interrupt-in pipe then your Thread will hang until the device sends you data. Probably not what you want to do...
On Thu, 13 Oct 2005, Noel O'Brien wrote: >Hi, I am very new to usb programming and I am trying >to create a Java frontend to the Creative Nomad >Jukebox (independant of libnjb). I have viewed the >protocol for the jukebox here: >(https://sourceforge.net/project/showfiles.php?group_id=32528&package_id=24703). >According to it, for example, to get the library >counter (page 33), it says the following data is to be >sent to the control endpoint: > >begin quote > > Get Library Counter >The get library counter request is sent by the host, >and the count is returned in the data phase of the USB >request > >Setup Phase > >Request Type > 0xC3 > >Request > 0x43 > >Value > 0x0000 > >Index > 0x0000 > >Data Length > 0x0019 > > > > >Data Phase > >Host << NJB > >status > 1 byte > >JukeBox ID > 16 bytes > >library count MSDW > 4 bytes > >library count LSDW > 4 bytes > > > > >The library count is stored as a 64-bit integer, >broken up into an MSDW and LSDW. See the get disk >usage command for more information. > > > >end quote > > > >I am using the following code (which I dont think is >correct) > > > >public static void testIO(UsbDevice jukebox) > { > try > { > System.out.println("Configured: >"+jukebox.isConfigured()); > List configs = >jukebox.getUsbConfigurations(); > > System.out.println("Number of >configurations: "+configs.size()); > System.out.println("Product: >"+jukebox.getProductString()); > System.out.println("Manufacturer: >"+jukebox.getManufacturerString()); > System.out.println("Serial num.: >"+jukebox.getSerialNumberString()); > > UsbConfiguration config = >jukebox.getActiveUsbConfiguration(); > System.out.println("Configuration active: >"+config.isActive()); > System.out.println("Configuration String: >"+config.getConfigurationString()); > > List totalInterfaces = >config.getUsbInterfaces(); > System.out.println("Number of interfaces: >"+totalInterfaces.size()); > > for (int i=0; i<totalInterfaces.size(); >i++) > { > UsbInterface interf = (UsbInterface) >totalInterfaces.get(i); > System.out.println("Interface "+i+" >Active: "+interf.isActive()); > System.out.println("Interface "+i+" >Claimed... "+interf.isClaimed()); > try > { > interf.claim(); > System.out.println("Interface >claimed"); > } > catch(UsbClaimException >u1){System.out.println("Claim Exception");} > catch(UsbException >u2){System.out.println("Usb Exception");} > catch(UsbNotActiveException >u3){System.out.println("Not Active Exception");} > > byte[] b = new byte[25]; > UsbControlIrp controlIrp = >jukebox.createUsbControlIrp((byte)0xC3, (byte)0x43, >(byte)0x0000, (byte)0x0000); > controlIrp.setLength(25); > controlIrp.setData(b); > System.out.println("Going to submit >device IRP.."); > jukebox.syncSubmit(controlIrp); > > > List totalEndpoints = >interf.getUsbEndpoints(); > >System.out.println(totalEndpoints.size()+" Endpoints >got from interface "+i); > > for (int j=0; j<totalEndpoints.size(); >j++) > { > UsbEndpoint ep = (UsbEndpoint) >totalEndpoints.get(j); > System.out.println("Direction: >"+getDirectionString(ep.getDirection())); > System.out.println("Type: >"+getTypeString(ep.getType())); > > UsbPipe pipe = ep.getUsbPipe(); > pipe.open(); > System.out.println("Pipe opened: >"+pipe.isOpen()); > System.out.println("Pipe active: >"+pipe.isActive()); > byte[] data = new byte[256]; > > if(ep.getDirection() == >UsbConst.ENDPOINT_DIRECTION_IN) > { >// // Perform I/O through the >USB pipe here. >// UsbControlIrp ctlirp = >pipe.createUsbControlIrp((byte)0xC3, (byte)0x04, >(short)0x0000, (short)0x0000); >// ctlirp.setData(data); >// ctlirp.setLength(17); >// pipe.syncSubmit(ctlirp); >// System.out.println("IRP >submitted"); > } > else System.out.println("Out >endpoint detected"); > > pipe.close(); > System.out.println("Pipe closed"); > } > interf.release(); > System.out.println("Interface >released"); > } > } > catch (Exception e) > { > System.out.println("Caught Exception"); > e.printStackTrace(); > } > } > > public static String getDirectionString(int >direction) > { > if(direction == >UsbConst.ENDPOINT_DIRECTION_IN) return >"ENDPOINT_DIRECTION_IN"; > else if(direction == >UsbConst.ENDPOINT_DIRECTION_OUT) return >"ENDPOINT_DIRECTION_OUT"; > else if(direction == >UsbConst.ENDPOINT_DIRECTION_MASK) return >"ENDPOINT_DIRECTION_MASK"; > else return null; > } > > public static String getTypeString(int type) > { > if(type == UsbConst.ENDPOINT_TYPE_BULK) return >"ENDPOINT_TYPE_BULK"; > else if(type == >UsbConst.ENDPOINT_TYPE_CONTROL) return >"ENDPOINT_TYPE_CONTROL"; > else if(type == >UsbConst.ENDPOINT_TYPE_INTERRUPT) return >"ENDPOINT_TYPE_INTERRUPT"; > else if(type == >UsbConst.ENDPOINT_TYPE_ISOCHRONOUS) return >"ENDPOINT_TYPE_ISOCHRONOUS"; > else if(type == UsbConst.ENDPOINT_TYPE_MASK) >return "ENDPOINT_TYPE_MASK"; > else return null; > } > > > >When i run the code everything goes ok until >syncSubmit is called and the whole program freezes, >requiring me to unplug the usb cable before i can >attempt another connection. I suppose what I really >want to know is: > > > >Am I sending the setup packet correctly? > >Am I sending it from the correct place in the code, >i.e. do I use jukebox.createUsbControlIrp(..) of do i >have to open an in- or out-endpoint (although i think >these are bulk type) > >How do i send a setup packet that sends its data back >on a bulk endpoint, i.e. what code is necessary to >send a control IRP and to capture the bulk data? > > > >Any help with this matter would be gratefully >appreciated. > > > >Thanks, > >Noel > > > > >__________________________________ >Yahoo! Music Unlimited >Access over 1 million songs. Try it free. >http://music.yahoo.com/unlimited/ > > >------------------------------------------------------- >This SF.Net email is sponsored by: >Power Architecture Resource Center: Free content, downloads, discussions, >and more. http://solutions.newsforge.com/ibmarch.tmpl >_______________________________________________ >javax-usb-devel mailing list >javax-usb-devel@lists.sourceforge.net >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 the JBoss Inc. Get Certified Today * Register for a JBoss Training Course Free Certification Exam for All Training Attendees Through End of 2005 Visit http://www.jboss.com/services/certification for more information _______________________________________________ javax-usb-devel mailing list javax-usb-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/javax-usb-devel