Thanks for replying.

Yes i do want to talk directly to the device using javax-usb instead of
using the pcscd daemon.

I also tried by stooping the pcsc daemon, as expected nothing happened even
the OS didn't
read anything(i.e. no entry found in sys log).

Here is the code i'm using,the idea is to just see if my code interacts with
the device
by reading the event data on flashing a card.

public static String getID(UsbDevice d) throws Exception
{
    UsbPipeListener upl = null;

    UsbEndpoint wep=null;
    UsbEndpoint rep=null;
    UsbEndpoint repI=null;
    UsbInterface interf=null;

    List intf=d.getActiveUsbConfiguration().getUsbInterfaces();  //d is the
smart card reader

    System.out.println("Num of Interfaces: " + intf.size());  // one in my
case

    for (int i=0;i<intf.size();i++)
    {
        interf=(UsbInterface)intf.get(i);
        interf.claim(new UsbInterfacePolicy() {
             public boolean forceClaim(UsbInterface usbInterfaceR){
                return true;
            }
        });
        System.out.println("interf isActive :: " + interf.isActive());
        System.out.println("interf isClaimed :: " + interf.isClaimed());
        List eps=interf.getUsbEndpoints();
        System.out.println("Num of Endpoints: " + eps.size());
        for (int j=0;j<eps.size();j++)
        {
            UsbEndpoint ep = (UsbEndpoint)eps.get(j);
            int direction = (int)(ep.getDirection() & 0xFF);
            int type = (int)(ep.getType() & 0xFF);
            System.out.println("Direction " + direction);
            System.out.println("Type " + type);
            int epid=((int)(ep.getUsbEndpointDescriptor().bEndpointAddress()
& 0xFF));
            System.out.println("epid " + j + " : " + epid);
             if(epid == 0x01)
            {
                wep=ep;
            }
            if(epid == 0x82)
            {
                rep=ep;
            }
        }
    }

    if ((wep!=null) && (rep!=null))
    {
        int outmaxPs = wep.getUsbEndpointDescriptor().wMaxPacketSize();
        int inmaxPs= rep.getUsbEndpointDescriptor().wMaxPacketSize();
        System.out.println("outmaxPs " + outmaxPs);
        System.out.println("inmaxPs " + inmaxPs);
        UsbPipe rp=rep.getUsbPipe();
        rp.open();
        rp.addUsbPipeListener(new myUsbListener());
        // For reading device input
        UsbIrp rrp=rp.createUsbIrp();
        byte indata[]=new byte[inmaxPs];
        rrp.setData(indata);
        rrp.setUsbException(null);
        //rrp.waitUntilComplete(); not required for syncSubmit
        //rp.open();
        rp.syncSubmit(rrp);
        rp.abortAllSubmissions();
        rp.close();
        interf.release();
     }
}

// MyUSBListener

public class myUsbListener implements UsbPipeListener {

  public void errorEventOccurred(UsbPipeErrorEvent event) {

        UsbException ex =  event.getUsbException();
        System.out.println(" Error info " + ex.getMessage());
  }
  public void dataEventOccurred(UsbPipeDataEvent event) {

      //event.getData();
      System.out.println("Recieved data : " + new String(event.getData()) +
" with length "
              + event.getActualLength());
  }
}

Hope this helps.
Thanks
ratish


On Thu, Feb 26, 2009 at 7:42 PM, Dan Streetman <[email protected]> wrote:

> It looks like your native pcscd daemon is trying to talk to the
> device.  Are you sure you want to talk directly to the device instead
> of using the pcscd daemon?
>
> On Wed, Feb 25, 2009 at 5:53 AM, ratish nair <[email protected]>
> wrote:
> >
> > Hello everyone,
> >
> >
> > I have written a UsbPipeListener just to print the error/data event.
>
> You have to actually submit a data buffer to send or receive data
> to/from the device.  You do realize that with javax.usb you have to
> implement the full device driver protocol yourself, right?
>
> >
> > Now the problem is when i execute the code as root ,the interface is
> claimed successfully
> > ,but nothing happens when i flash a card.Once the execution is stopped
> the reader reads
> > card details and displays it.I got to know this by going through the
> System Log of linux(Ubuntu 7.04 & 8.04).
>
> As you didn't show any code here, I don't think anyone can really tell
> you if it's correct or not.
>
> > This is the output in sys log when my code is not running(i.e. reading
> the card info) :
> >
> > Feb 24 19:17:04  pcscd: ifdhandler.c:841:IFDHPowerICC(
> > ) lun: 1, action: PowerUp
> > Feb 24 19:17:04  pcscd: eventhandler.c:419:EHStatusHandlerThread() Card
> inserted into SCM SDI 010 (21120706201272) 00 01
> > Feb 24 19:17:04  pcscd: Card ATR: 3B F5 91 00 FF 91 81 71 FE 40 00 41 08
> 00 00 00 0D
> > Feb 24 19:17:04  pcscd: eventhandler.c:350:EHStatusHandlerThread() Card
> Removed From SCM SDI 010 (21120706201272) 00 00
> > Feb 24 19:17:14  pcscd: eventhandler.c:350:EHStatusHandlerThread() Card
> Removed From SCM SDI 010 (21120706201272) 00 01
> >
> > and once i run my code below is the result:
> >
> > Feb 24 19:17:00 kernel: [ 6835.736000] usb 1-3: usbfs: process 6705
> (pcscd) did not claim interface 0 before use
> > Feb 24 19:17:02 pcscd: ccid_usb.c:507:ReadUSB() usb_bulk_read(001/005):
> Resource temporarily unavailable
> > Feb 24 19:17:02 pcscd: ifdwrapper.c:493:IFDStatusICC() Card not
> transacted: 612
> > Feb 24 19:17:02 pcscd: eventhandler.c:301:EHStatusHandlerThread() Error
> communicating to: SCM SDI 010 (21120706201272) 00 01
> > Feb 24 19:17:04 pcscd: ccid_usb.c:507:ReadUSB() usb_bulk_read(001/005):
> Resource temporarily unavailable
> > Feb 24 19:17:04 pcscd: ifdwrapper.c:493:IFDStatusICC() Card not
> transacted: 612
> > Feb 24 19:17:04 pcscd: eventhandler.c:301:EHStatusHandlerThread() Error
> communicating to: SCM SDI 010 (21120706201272) 00 00
> >
> > as is visible that interface was not claimed before use but as i said
> that my java code shows true for interface.isClaimed().
>
> Is "pcscd" your process?  I think that is also a local system smart
> card reader daemon.  And as I said, without you showing us your code,
> how can we say if it's right or not?
>
>
> >
> > Any help will be really great full.
> >
> > Thanks
> > ratish
> >
> ------------------------------------------------------------------------------
> > Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco,
> CA
> > -OSBC tackles the biggest issue in open source: Open Sourcing the
> Enterprise
> > -Strategies to boost innovation and cut costs with open source
> participation
> > -Receive a $600 discount off the registration fee with the source code:
> SFAD
> > http://p.sf.net/sfu/XcvMzF8H
> > _______________________________________________
> > javax-usb-devel mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
> >
>



-- 
Regards,
Ratish Nair
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
javax-usb-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/javax-usb-devel

Reply via email to