本文整理汇总了Java中org.usb4java.LibUsb.exit方法的典型用法代码示例。如果您正苦于以下问题:Java LibUsb.exit方法的具体用法?Java LibUsb.exit怎么用?Java LibUsb.exit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.usb4java.LibUsb
的用法示例。
在下文中一共展示了LibUsb.exit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: detach
import org.usb4java.LibUsb; //导入方法依赖的package包/类
boolean detach() {
if (m_isAttached == false) {
return false;
}
int r;
r = LibUsb.releaseInterface(dev_handle, 1);
if (r != 0) {
return false;
}
if (m_isKernellDetached == true) {
LibUsb.attachKernelDriver(dev_handle, 1);
m_isKernellDetached = false;
}
LibUsb.close(dev_handle);
dev_handle = null;
LibUsb.exit(ctx);
ctx = null;
m_isAttached = false;
return true;
}
示例2: disconnect
import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
* Disconnect from the USB device.
*/
public void disconnect ()
{
if (this.handle == null)
return;
// Prevent further sending
final DeviceHandle h = this.handle;
this.handle = null;
final int result = LibUsb.releaseInterface (h, INTERFACE_NUMBER);
if (result != LibUsb.SUCCESS)
throw new LibUsbException ("Unable to release interface", result);
LibUsb.close (h);
LibUsb.exit (null);
}
示例3: release
import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
* Releases the USB interface
*/
public void release()
{
try
{
if( mBufferProcessor.isRunning() )
{
mBufferProcessor.stop();
}
LibUsb.releaseInterface( mDeviceHandle, USB_INTERFACE );
LibUsb.exit( null );
}
catch ( Exception e )
{
Log.errorDialog( "attempt to release USB interface failed", e.getMessage() );
}
}
示例4: main
import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
* Main method.
*
* @param args
* Command-line arguments (Ignored)
* @throws Exception
* When something goes wrong.
*/
public static void main(String[] args) throws Exception
{
// Initialize the libusb context
int result = LibUsb.init(null);
if (result != LibUsb.SUCCESS)
{
throw new LibUsbException("Unable to initialize libusb", result);
}
// Check if hotplug is available
if (!LibUsb.hasCapability(LibUsb.CAP_HAS_HOTPLUG))
{
System.err.println("libusb doesn't support hotplug on this system");
System.exit(1);
}
// Start the event handling thread
EventHandlingThread thread = new EventHandlingThread();
thread.start();
// Register the hotplug callback
HotplugCallbackHandle callbackHandle = new HotplugCallbackHandle();
result = LibUsb.hotplugRegisterCallback(null,
LibUsb.HOTPLUG_EVENT_DEVICE_ARRIVED
| LibUsb.HOTPLUG_EVENT_DEVICE_LEFT,
LibUsb.HOTPLUG_ENUMERATE,
LibUsb.HOTPLUG_MATCH_ANY,
LibUsb.HOTPLUG_MATCH_ANY,
LibUsb.HOTPLUG_MATCH_ANY,
new Callback(), null, callbackHandle);
if (result != LibUsb.SUCCESS)
{
throw new LibUsbException("Unable to register hotplug callback",
result);
}
// Our faked application. Hit enter key to exit the application.
System.out.println("Hit enter to exit the demo");
System.in.read();
// Unregister the hotplug callback and stop the event handling thread
thread.abort();
LibUsb.hotplugDeregisterCallback(null, callbackHandle);
thread.join();
// Deinitialize the libusb context
LibUsb.exit(null);
}
示例5: closeDevice
import org.usb4java.LibUsb; //导入方法依赖的package包/类
private void closeDevice() {
System.out.println("Shutting down device.");
// Use reset to close connection.
if (devHandle != null) {
LibUsb.releaseInterface(devHandle, 0);
LibUsb.close(devHandle);
devHandle = null;
LibUsb.exit(null);
}
}
示例6: main
import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
* Main method.
*
* @param args
* Command-line arguments (Ignored)
* @throws Exception
* When something goes wrong.
*/
public static void main(String[] args) throws Exception
{
// Initialize the libusb context
int result = LibUsb.init(null);
if (result != LibUsb.SUCCESS)
{
throw new LibUsbException("Unable to initialize libusb", result);
}
// Open test device (Samsung Galaxy Nexus)
DeviceHandle handle = LibUsb.openDeviceWithVidPid(null, VENDOR_ID,
PRODUCT_ID);
if (handle == null)
{
System.err.println("Test device not found.");
System.exit(1);
}
// Claim the ADB interface
result = LibUsb.claimInterface(handle, INTERFACE);
if (result != LibUsb.SUCCESS)
{
throw new LibUsbException("Unable to claim interface", result);
}
// Send ADB CONNECT message
write(handle, CONNECT_HEADER);
write(handle, CONNECT_BODY);
// Receive the header of the ADB answer (Most likely an AUTH message)
ByteBuffer header = read(handle, 24);
header.position(12);
int dataSize = header.asIntBuffer().get();
// Receive the body of the ADB answer
@SuppressWarnings("unused")
ByteBuffer data = read(handle, dataSize);
// Release the ADB interface
result = LibUsb.releaseInterface(handle, INTERFACE);
if (result != LibUsb.SUCCESS)
{
throw new LibUsbException("Unable to release interface", result);
}
// Close the device
LibUsb.close(handle);
// Deinitialize the libusb context
LibUsb.exit(null);
}
示例7: main
import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
* Main method.
*
* @param args
* Command-line arguments (Ignored)
*/
public static void main(final String[] args)
{
// Create the libusb context
final Context context = new Context();
// Initialize the libusb context
int result = LibUsb.init(context);
if (result < 0)
{
throw new LibUsbException("Unable to initialize libusb", result);
}
// Read the USB device list
final DeviceList list = new DeviceList();
result = LibUsb.getDeviceList(context, list);
if (result < 0)
{
throw new LibUsbException("Unable to get device list", result);
}
try
{
// Iterate over all devices and dump them
for (Device device: list)
{
dumpDevice(device);
}
}
finally
{
// Ensure the allocated device list is freed
LibUsb.freeDeviceList(list, true);
}
// Deinitialize the libusb context
LibUsb.exit(context);
}
示例8: release
import org.usb4java.LibUsb; //导入方法依赖的package包/类
public void release(){
if(context != null){
LibUsb.exit(context);
context = null;
}
}
示例9: dispose
import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
* Performs cleanup of USB related issues
*/
public void dispose()
{
LibUsb.exit(null);
}
示例10: dispose
import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
* Performs cleanup of USB related issues
*/
public void dispose()
{
LibUsb.exit( null );
}
示例11: uninit
import org.usb4java.LibUsb; //导入方法依赖的package包/类
public void uninit() {
LibUsb.exit(this.context);
}
示例12: close
import org.usb4java.LibUsb; //导入方法依赖的package包/类
public void close() {
LibUsb.releaseInterface(handle, 0);
LibUsb.attachKernelDriver(handle, 0);
LibUsb.close(handle);
LibUsb.exit(context);
}
示例13: dispose
import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
* Dispose the USB device manager. This exits the USB context opened by the
* constructor.
*/
public void dispose()
{
LibUsb.exit(this.context);
}
示例14: main
import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
* Main method.
*
* @param args
* Command-line arguments (Ignored)
*/
public static void main(String[] args)
{
// Create the libusb context
Context context = new Context();
// Initialize the libusb context
int result = LibUsb.init(context);
if (result < 0)
{
throw new LibUsbException("Unable to initialize libusb", result);
}
// Read the USB device list
DeviceList list = new DeviceList();
result = LibUsb.getDeviceList(context, list);
if (result < 0)
{
throw new LibUsbException("Unable to get device list", result);
}
try
{
// Iterate over all devices and list them
for (Device device: list)
{
int address = LibUsb.getDeviceAddress(device);
int busNumber = LibUsb.getBusNumber(device);
DeviceDescriptor descriptor = new DeviceDescriptor();
result = LibUsb.getDeviceDescriptor(device, descriptor);
if (result < 0)
{
throw new LibUsbException(
"Unable to read device descriptor", result);
}
System.out.format(
"Bus %03d, Device %03d: Vendor %04x, Product %04x%n",
busNumber, address, descriptor.idVendor(),
descriptor.idProduct());
}
}
finally
{
// Ensure the allocated device list is freed
LibUsb.freeDeviceList(list, true);
}
// Deinitialize the libusb context
LibUsb.exit(context);
}
示例15: CloseContext
import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
* free the Winusb C++ struct According to usb4java documentation
*
* @author yassir
*/
public void CloseContext() {
LibUsb.exit(this.context);
}