I don't know specifically why you never get data from your device, it probably is actually not sending anything. If you think it is, you should enable the Linux usb monitor to see if anything is coming in from your device.
As far as your code, it looks basically ok, except for this part: byte outdata[]=new byte[outmaxPs]; outdata[0]=2; outdata[1]='S'; outdata[2]='N'; outdata[3]=3; wrp.setLength(4); wrp.setData(outdata); that is not doing what you want it to do. You set the data length to 4 but the call to setData resets it to outmaxPs. Read the API javadoc interface specification for UsbIrp.setData(): http://javax-usb.org/jdoc/javax/usb/UsbIrp.html#setData(byte[]) You instead should do either this: byte outdata[]=new byte[4]; outdata[0]=2; outdata[1]='S'; outdata[2]='N'; outdata[3]=3; wrp.setData(outdata); or this: byte outdata[]=new byte[outmaxPs]; outdata[0]=2; outdata[1]='S'; outdata[2]='N'; outdata[3]=3; wrp.setData(outdata, 0, 4); or, this: byte outdata[]=new byte[outmaxPs]; outdata[0]=2; outdata[1]='S'; outdata[2]='N'; outdata[3]=3; wrp.setData(outdata); wrp.setLength(4); It's possible that is causing your problem, since your device is getting extra garbage bytes sent to it which may confuse it. On 8/27/07, Emanuele Maiarelli <[EMAIL PROTECTED]> wrote: > im running the code below, what happen is that out packet seems to work( > it returns from wp.asyncSubmit(wrp); wrp.waitUntilComplete(); // i've > tried > wp.asyncSubmit(wrp) before) but unless wp.abortAllSubmissions(); i got > exception trying wp.close();). > The real problem is that i cannot recive data from the IN endpoint and > rrp.waitUntilComplete(); waits forever. > > I've tested the USB protocol and the data sent in ep1 (OUT) are correct, > in anycase i'll get a answer for errors. > > Thanks in advice, > > import java.util.Hashtable; > import java.util.Iterator; > import java.util.List; > import javax.usb.UsbDevice; > import javax.usb.UsbEndpoint; > import javax.usb.UsbHub; > import javax.usb.UsbInterface; > import javax.usb.UsbIrp; > import javax.usb.UsbPipe; > import javax.usb.util.UsbUtil; > > > /** > * > * @author root > */ > public class DevScan extends javax.swing.JInternalFrame implements FmkChild > { > static final int cmdEPw=0x01; > static final int cmdEPr=0x81; > > FmkFather Father; > /** Creates new form DevScan */ > public DevScan() { > initComponents(); > } > > public static String getID(UsbDevice d) throws Exception > { > String SID=null; > UsbEndpoint wep=null; > > UsbEndpoint rep=null; > List intf=d.getActiveUsbConfiguration().getUsbInterfaces(); > for (int i=0;i<intf.size();i++) > { > UsbInterface interf=(UsbInterface) intf.get(i); > List eps=interf.getUsbEndpoints(); > for (int j=0;j<eps.size();j++) > { > UsbEndpoint ep = (UsbEndpoint) eps.get(j); > int > epid=((int)(ep.getUsbEndpointDescriptor().bEndpointAddress() > & 0xFF)); > if (epid == DevScan.cmdEPw) > { > wep=ep; > } > if (epid == DevScan.cmdEPr) > { > rep=ep; > } > > } > } > if ((wep!=null) && (rep!=null)) > { > int outmaxPs = wep.getUsbEndpointDescriptor().wMaxPacketSize(); > int inmaxPs= rep.getUsbEndpointDescriptor().wMaxPacketSize(); > wep.getUsbInterface().claim(); > > //rep.getUsbInterface().claim(); > > System.out.println(wep.getUsbEndpointDescriptor().bEndpointAddress()); > > System.out.println(rep.getUsbEndpointDescriptor().bEndpointAddress()); > > UsbPipe wp=wep.getUsbPipe(); > UsbIrp wrp=wp.createUsbIrp(); > > UsbPipe rp=rep.getUsbPipe(); > > > byte indata[]=new byte[inmaxPs]; > > rp.open(); > UsbIrp rrp=rp.createUsbIrp(); > rrp.setData(indata); > rrp.setUsbException(null); > > rp.asyncSubmit(rrp); > > > wp.open(); > > byte outdata[]=new byte[outmaxPs]; > outdata[0]=2; > outdata[1]='S'; > outdata[2]='N'; > outdata[3]=3; > wrp.setLength(4); > wrp.setData(outdata); > wrp.setUsbException(null); > > wp.asyncSubmit(wrp); > > wrp.waitUntilComplete(); > wrp.setComplete(false); > wp.abortAllSubmissions(); > wp.close(); > System.out.println("invio"); > > rrp.waitUntilComplete(); > rp.abortAllSubmissions(); > rp.close(); > wep.getUsbInterface().release(); > rep.getUsbInterface().release(); > char[] ss=new char[rrp.getLength()]; > for (int i=0;i<ss.length;i++) > { > System.out.println(UsbUtil.toHexString(indata[i])); > > } > } > return SID; > } > > public static void FillUsbTable(Hashtable t,UsbHub hub) throws Exception > { > > List usbdevs=hub.getAttachedUsbDevices(); > Iterator it=usbdevs.iterator(); > t.clear(); > while (it.hasNext()) > { > UsbDevice d=(UsbDevice) it.next(); > if (d.isUsbHub()) > { > DevScan.FillUsbTable(t,(UsbHub)d); > } else > { > if(d.getProductString().equals("MY-USB")) > { > DevScan.getID(d); > } > } > } > } > > > -- > Emanuele Maiarelli > > > > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > javax-usb-devel mailing list > javax-usb-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/javax-usb-devel > ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ javax-usb-devel mailing list javax-usb-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/javax-usb-devel