i've tried all solutions, but things dosen't change.
This is the the pice C of code on usb device handling EP1 (Cypres FX2LP):

...
   if(!(EP1OUTCS & bmBIT1))
    {
        char cmdbuff[10];
        int cmdsize=0;
        int i;
        int bitcount= EP1OUTBC;
        BOOL stc=FALSE;
        BOOL done=FALSE;
        int c=0;
        while ((c<bitcount) && cmdsize<10 && (!(done)))
        {
            if ((stc) && (EP1OUTBUF[c]!=0x03))
cmdbuff[cmdsize++]=EP1OUTBUF[c];
            if (EP1OUTBUF[c]==0x02) stc=TRUE;
            if (EP1OUTBUF[c]==0x03) done=TRUE;
            c++;
        }
        if (cmdsize>0)
        {
            if ((cmdbuff[0]=='S') && (cmdbuff[1]=='N'))
            {
                EP1INBUF[0]=0x02;
                for (i=0;i<9;i++)
                {
                    EP1INBUF[1+i]=_SNO[i];
                }
                EP1INBUF[10]=0x03;
                EP1INBC=11;
                SYNCDELAY;
            } else
            {
                EP1INBUF[0]=0x02;
                EP1INBUF[1]=cmdbuff[0];
                EP1INBUF[2]=cmdbuff[1];
                EP1INBUF[3]=0x03;
                EP1INBC=4;
                SYNCDELAY;
            }
        }

        EP1OUTBC = 0x40;
        SYNCDELAY;
    }
....

the device can handle garbage code, looking for a specific STX/ETX
encapsulated text.

I fear that nothing is being sent to device, dued by the fact that im
using FC7+SELinux(Disabled), anyone have never tried javax.usb on FC7 ?

Btw can you tell me what is the USB monitor you are using?

At the moment i'm using the device with a C#/Windows solution, but i
really wants to switch to a Java/Linux one.

Thanks in advice,

Emanuele Maiarelli.

> 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
>>
>


-- 
Emanuele Maiarelli




-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
javax-usb-devel mailing list
javax-usb-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/javax-usb-devel

Reply via email to