On Thu, Oct 3, 2013 at 10:29 PM, SANJAY GUPTA <gupta.san...@samsung.com> wrote:
>
> Thanks for your reply.
>
> I am not interested in default control endpoint.
>
> I know the endpoing with address 0x00 is a default control endpoint with 
> which I am able to do control operations using UsbControlIrp.
>
> But I want to get other endpoint provided by currently active configuration 
> and interface which has type ENDPOINT_TYPE_CONTROL.
>
> For your information, the UsbDevice is a mass-storage device.


That's definitely unusual, it's rare to see a mass storage device with
non-default control endpoints.  But if you're sure it has one, see
below for suggestions.

>
>
>
> On Wed, Oct 2, 2013 at 6:30 AM, SANJAY GUPTA <gupta.san...@samsung.com> wrote:
> > Hi All,
> >
> > I am trying to find the Control type UsbEndpoint using below method 
> > expecting that each UsbDevice has atlease one control endpoint. But this is 
> > unable to find the desired endpoint and returns null.
>
> You're probably talking about endpoint 0, or the "default control
> pipe", which is a special endpoint that doesn't belong to any
> configuration or interface (or, depending on how you read the spec, it
> belongs to all configurations and interfaces, but that is not the
> interpretation used by javax.usb).  You can use it via the UsbDevice
> interface methods createUsbControlIrp(), asyncSubmit() or
> syncSubmit(), etc.
>
> >
> > private UsbEndpoint getControlEndpoint(final UsbDevice usbDevice) {
> >         final UsbDeviceDescriptor usbDeviceDescriptor = 
> > usbDevice.getUsbDeviceDescriptor();
> >         for ( int i=0; i<usbDeviceDescriptor.bNumConfigurations(); i++ )
> >         {
> >                 final UsbConfiguration usbCurrentConfig = 
> > usbDevice.getUsbConfiguration((byte) (i+1));
> >                 if ( usbCurrentConfig == null) {
> >                         continue;
> >                 }
> >
> >                 final UsbConfigurationDescriptor usbCurrentConfigDescriptor 
> > = usbCurrentConfig.getUsbConfigurationDescriptor();
> >                 for ( int j=0; 
> > j<usbCurrentConfigDescriptor.bNumInterfaces(); j++ )
> >                 {
> >                         UsbInterface usbCurrentInterface = 
> > usbCurrentConfig.getUsbInterface((byte) j);
> >                         for ( int k=0; 
> > k<usbCurrentInterface.getNumSettings(); k++ )
> >                         {
> >                                 usbCurrentInterface = 
> > usbCurrentInterface.getSetting((byte) k);
> >                                 final List<?> usbEndpoints = 
> > usbCurrentInterface.getUsbEndpoints();
> >                                 for ( int l = 0; l<usbEndpoints.size(); l++ 
> > )
> >                                 {
> >                                         final UsbEndpoint 
> > usbCurrentEndpoint = (UsbEndpoint) usbEndpoints.get(l);
> >                                         if ( usbCurrentEndpoint.getType() 
> > == UsbConst.ENDPOINT_TYPE_CONTROL & 
> > usbCurrentEndpoint.getUsbEndpointDescriptor().bEndpointAddress() != (byte) 
> > 0x00 )
> >                                         {
> >                                                 return usbCurrentEndpoint;
> >                                         }
> >                                 }
> >                         }
> >                 }
> >         }
> >         return null;
> > }
> >
> > Any suggestion would be of great help.

First, just use the methods that return all existing objects instead
of assuming they are in sequentially numbered order and getting each
one.  Like:

Iterator configs = usbDevice.getUsbConfigurations().iterator();
while (configs.hasNext()) {
  UsbConfiguration config = (UsbConfiguration)configs.next();


Also, iterating through all the configs and interface alternate
settings is only required if your non-default control endpoint isn't
active.  Assuming the current active config (and interface alternate
setting) contains the non-default control ep, just get the current
config, iterate through each interface (don't iterate the alternate
settings), iterate through each endpoint in each interface, and check
its type.  You don't need to bother checking the address != 0, because
it will never be.

If your control ep isn't active (i.e. in a non-active config or
non-active interface alternate setting) then once you find it you'll
also need to change the device's current config or interface alternate
setting; you can't just use it, since it's won't be active.


> >
> > Thanks in Advance..
> > Sanjay Gupta
> >
> > ------------------------------------------------------------------------------
> > October Webinars: Code for Performance
> > Free Intel webinars can help you accelerate application performance.
> > Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most 
> > from
> > the latest Intel processors and coprocessors. See abstracts and register >
> > http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
> > _______________________________________________
> > javax-usb-devel mailing list
> > javax-usb-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
>
>
> ------------------------------------------------------------------------------
> October Webinars: Code for Performance
> Free Intel webinars can help you accelerate application performance.
> Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
> the latest Intel processors and coprocessors. See abstracts and register >
> http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
> _______________________________________________
> javax-usb-devel mailing list
> javax-usb-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
>

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
javax-usb-devel mailing list
javax-usb-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/javax-usb-devel

Reply via email to