I am simply trying to open a device for IO. I can detect the device get
the active configuration
and then the interface but when I try to claim() it I get device is
already claimed:
e:javax.usb.UsbPlatformException: Could not claim interface : Device or
resource busy.
I checked that the interface is active and that it is indeed claimed via
isActive() and isClaimed()
prior to the call.
I skipped the claim() and of course if failed to open the pipe, saying
interface is not claimed:
e:javax.usb.UsbNotClaimedException: UsbInterface 0x00 setting 0x00 is not
claimed.
Here is what I am trying to do, I already traverse the USB topology to
obtain the device
I am looking for:
public static void testIO(UsbDevice device) {
try {
// Access to the active configuration of the USB device, obtain
// all the interfaces available in that configuration.
UsbConfiguration config = device.getActiveUsbConfiguration();
List totalInterfaces = config.getUsbInterfaces();
System.out.println(" Total interfaces: "+totalInterfaces.size());
// Traverse through all the interfaces, and access the endpoints
// available to that interface for I/O.
for (int i=0; i<totalInterfaces.size(); i++) {
UsbInterface interf = (UsbInterface) totalInterfaces.get(i);
System.out.println(" Interface: "+interf.getInterfaceString());
System.out.println(" NumStr : "+interf.getNumSettings());
System.out.println(" Active : "+interf.isActive());
System.out.println(" Claimed : "+interf.isClaimed());
interf.claim();
List totalEndpoints = interf.getUsbEndpoints();
System.out.println(" Total end points: "+totalEndpoints.size());
for (int j=0; j<totalEndpoints.size(); j++) {
// Access the particular endpoint, determine the direction
// of its data flow, and type of data transfer, and open the
// data pipe for I/O.
UsbEndpoint ep = (UsbEndpoint) totalEndpoints.get(i);
int direction = ep.getDirection();
int type = ep.getType();
UsbPipe pipe = ep.getUsbPipe();
pipe.open();
System.out.println(" Pipe opened..");
// Perform I/O through the USB pipe here.
pipe.close();
}
interf.release();
}
} catch (Exception e) {
System.out.println("Error processing USB Pipe... e:"+e);
e.printStackTrace();
}
}
Thanks in advance and best regards,
Jim Whelan
-------------------------------------------------------------------------
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