问题相关代码,请勿粘贴截图
UsbConfiguration configuration = device.getActiveUsbConfiguration();//获取配置信息
UsbInterface iface = configuration.getUsbInterface((byte) 0);//接口
iface.claim(new UsbInterfacePolicy() {
@Override
public boolean forceClaim(UsbInterface arg0) {
// TODO Auto-generated method stub
return true;
}
});
运行结果及报错内容
找到设备:Bus 001 Device 010: ID 1cbe:0003
以下报错内容
javax.usb.UsbPlatformException: USB error 3: Unable to claim interface: Access denied (insufficient permissions)
at org.usb4java.javax.ExceptionUtils.createPlatformException(ExceptionUtils.java:39)
at org.usb4java.javax.AbstractDevice.claimInterface(AbstractDevice.java:430)
at org.usb4java.javax.Interface.claim(Interface.java:102)
错误代码定位为
iface.claim(new UsbInterfacePolicy() {...});