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.

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.

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

Reply via email to