本文整理汇总了Java中org.usb4java.LibUsb.detachKernelDriver方法的典型用法代码示例。如果您正苦于以下问题:Java LibUsb.detachKernelDriver方法的具体用法?Java LibUsb.detachKernelDriver怎么用?Java LibUsb.detachKernelDriver使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.usb4java.LibUsb
的用法示例。
在下文中一共展示了LibUsb.detachKernelDriver方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: claimInterface
import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
* Claims the USB interface. Attempts to detach the active kernel driver
* if one is currently attached.
*/
public static void claimInterface(DeviceHandle handle) throws SourceException
{
if(handle != null)
{
int result = LibUsb.kernelDriverActive(handle, USB_INTERFACE);
if(result == 1)
{
result = LibUsb.detachKernelDriver(handle, USB_INTERFACE);
if(result != LibUsb.SUCCESS)
{
mLog.error("failed attempt to detach kernel driver [" +
LibUsb.errorName(result) + "]");
throw new SourceException("couldn't detach kernel driver "
+ "from device");
}
}
result = LibUsb.claimInterface(handle, USB_INTERFACE);
if(result != LibUsb.SUCCESS)
{
throw new SourceException("couldn't claim usb interface [" +
LibUsb.errorName(result) + "]");
}
}
else
{
throw new SourceException("couldn't claim usb interface - no "
+ "device handle");
}
}
示例2: claimInterface
import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
* Claims the USB interface. Attempts to detach the active kernel driver if
* one is currently attached.
*/
private void claimInterface() throws SourceException
{
if(mDeviceHandle != null)
{
int result = LibUsb.kernelDriverActive(mDeviceHandle, FCD_INTERFACE);
if(result == 1)
{
result = LibUsb.detachKernelDriver(mDeviceHandle, FCD_INTERFACE);
if(result != LibUsb.SUCCESS)
{
mLog.error("failed attempt to detach kernel driver [" + LibUsb.errorName(result) + "]");
}
}
result = LibUsb.claimInterface(mDeviceHandle, FCD_INTERFACE);
if(result != LibUsb.SUCCESS)
{
throw new SourceException("couldn't claim usb interface [" + LibUsb.errorName(result) + "]");
}
}
else
{
throw new SourceException("couldn't claim usb hid interface - no device handle");
}
}
示例3: claimInterface
import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
* Claims the USB interface. If another application currently has
* the interface claimed, the USB_FORCE_CLAIM_INTERFACE setting
* will dictate if the interface is forcibly claimed from the other
* application
*/
private void claimInterface() throws SourceException
{
if(mDeviceHandle != null)
{
int result = LibUsb.kernelDriverActive(mDeviceHandle, USB_INTERFACE);
if(result == 1)
{
result = LibUsb.detachKernelDriver(mDeviceHandle, USB_INTERFACE);
if(result != LibUsb.SUCCESS)
{
mLog.error("failed attempt to detach kernel driver [" +
LibUsb.errorName(result) + "]");
throw new SourceException("couldn't detach kernel driver "
+ "from device");
}
}
result = LibUsb.claimInterface(mDeviceHandle, USB_INTERFACE);
if(result != LibUsb.SUCCESS)
{
throw new SourceException("couldn't claim usb interface [" +
LibUsb.errorName(result) + "]");
}
}
else
{
throw new SourceException("couldn't claim usb interface - no "
+ "device handle");
}
}
示例4: claimInterface
import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
* Claims the USB interface. Attempts to detach the active kernel driver
* if one is currently attached.
*/
public static void claimInterface( DeviceHandle handle ) throws DeviceException
{
if( handle != null )
{
int result = LibUsb.kernelDriverActive( handle, USB_INTERFACE );
if( result == 1 )
{
result = LibUsb.detachKernelDriver( handle, USB_INTERFACE );
if( result != LibUsb.SUCCESS )
{
Log.errorDialog( "ERROR", "failed attempt to detach kernel driver [" +
LibUsb.errorName( result ) + "]" );
throw new DeviceException( "couldn't detach kernel driver "
+ "from device" );
}
}
result = LibUsb.claimInterface( handle, USB_INTERFACE );
if( result != LibUsb.SUCCESS )
{
throw new DeviceException( "couldn't claim usb interface [" +
LibUsb.errorName( result ) + "]" );
}
}
else
{
throw new DeviceException( "couldn't claim usb interface - no "
+ "device handle" );
}
}
示例5: TMT20low
import org.usb4java.LibUsb; //导入方法依赖的package包/类
public TMT20low() throws SecurityException, UsbException {
// Search for epson TM-T20
context = new Context();
int result = LibUsb.init(context);
if (result != LibUsb.SUCCESS) throw new LibUsbException("Unable to initialize libusb.", result);
device = findDevice(VENDOR_ID, PRODUCT_ID);
if (device == null) {
System.err.println("not found.");
System.exit(1);
return;
}
handle = new DeviceHandle();
result = LibUsb.open(device, handle);
if (result != LibUsb.SUCCESS) throw new LibUsbException("Unable to open USB device", result);
// Check if kernel driver must be detached
boolean detach = LibUsb.hasCapability(LibUsb.CAP_SUPPORTS_DETACH_KERNEL_DRIVER) && (LibUsb.kernelDriverActive(handle, 0) > 0);
System.out.println("hasCapability: "+LibUsb.hasCapability(LibUsb.CAP_SUPPORTS_DETACH_KERNEL_DRIVER)+
", kernelDriverActive: "+LibUsb.kernelDriverActive(handle, 0));
// Detach the kernel driver
if (detach) {
result = LibUsb.detachKernelDriver(handle, 0);
if (result != LibUsb.SUCCESS) throw new LibUsbException("Unable to detach kernel driver", result);
}
result = LibUsb.claimInterface(handle, 0);
if (result != LibUsb.SUCCESS) throw new LibUsbException("Unable to claim interface", result);
}
示例6: claimInterface
import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
* Claims the USB interface. If another application currently has
* the interface claimed, the USB_FORCE_CLAIM_INTERFACE setting
* will dictate if the interface is forcibly claimed from the other
* application
*/
private void claimInterface() throws SourceException
{
if(mDeviceHandle != null)
{
int result = LibUsb.kernelDriverActive(mDeviceHandle, USB_INTERFACE);
if(result == 1)
{
result = LibUsb.detachKernelDriver(mDeviceHandle, USB_INTERFACE);
if(result != LibUsb.SUCCESS)
{
mLog.error("failed attempt to detach kernel driver [" +
LibUsb.errorName(result) + "]");
throw new SourceException("couldn't detach kernel driver "
+ "from device");
}
}
result = LibUsb.setConfiguration(mDeviceHandle, 1);
if(result != LibUsb.SUCCESS)
{
throw new SourceException("couldn't set USB configuration 1 [" +
LibUsb.errorName(result) + "]");
}
result = LibUsb.claimInterface(mDeviceHandle, USB_INTERFACE);
if(result != LibUsb.SUCCESS)
{
throw new SourceException("couldn't claim usb interface [" +
LibUsb.errorName(result) + "]");
}
}
else
{
throw new SourceException("couldn't claim usb interface - no "
+ "device handle");
}
}
示例7: claimInterface
import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
* Claims the USB interface. If another application currently has
* the interface claimed, the USB_FORCE_CLAIM_INTERFACE setting
* will dictate if the interface is forcibly claimed from the other
* application
*/
private void claimInterface() throws DeviceException
{
if( mDeviceHandle != null )
{
int result = LibUsb.kernelDriverActive( mDeviceHandle, USB_INTERFACE );
if( result == 1 )
{
result = LibUsb.detachKernelDriver( mDeviceHandle, USB_INTERFACE );
if( result != LibUsb.SUCCESS )
{
Log.errorDialog("ERROR", "failed attempt to detach kernel driver [" +
LibUsb.errorName( result ) + "]" );
throw new DeviceException( "couldn't detach kernel driver "
+ "from device" );
}
}
result = LibUsb.setConfiguration( mDeviceHandle, 1 );
if( result != LibUsb.SUCCESS )
{
throw new DeviceException( "couldn't set USB configuration 1 [" +
LibUsb.errorName( result ) + "]" );
}
result = LibUsb.claimInterface( mDeviceHandle, USB_INTERFACE );
if( result != LibUsb.SUCCESS )
{
throw new DeviceException( "couldn't claim usb interface [" +
LibUsb.errorName( result ) + "]" );
}
}
else
{
throw new DeviceException( "couldn't claim usb interface - no "
+ "device handle" );
}
}