当前位置: 首页>>代码示例>>Java>>正文


Java LibUsb.exit方法代码示例

本文整理汇总了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;
}
 
开发者ID:MohamadSaada,项目名称:LogiGSK,代码行数:22,代码来源:Keyboard.java

示例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);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:20,代码来源:USBDisplay.java

示例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() );
      }
  }
 
开发者ID:ac2cz,项目名称:FoxTelem,代码行数:22,代码来源:RTL2832TunerController.java

示例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);
}
 
开发者ID:usb4java,项目名称:usb4java-examples,代码行数:57,代码来源:HotPlug.java

示例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);
    }
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:13,代码来源:ATCFpgaConfig.java

示例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);
}
 
开发者ID:usb4java,项目名称:usb4java-examples,代码行数:60,代码来源:SyncBulkTransfer.java

示例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);
}
 
开发者ID:usb4java,项目名称:usb4java-examples,代码行数:44,代码来源:DumpDevices.java

示例8: release

import org.usb4java.LibUsb; //导入方法依赖的package包/类
public void release(){
  if(context != null){
    LibUsb.exit(context);
    context = null;
  }
}
 
开发者ID:diwi,项目名称:PS3Eye,代码行数:7,代码来源:USB.java

示例9: dispose

import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
 * Performs cleanup of USB related issues
 */
public void dispose()
{
    LibUsb.exit(null);
}
 
开发者ID:DSheirer,项目名称:sdrtrunk,代码行数:8,代码来源:TunerManager.java

示例10: dispose

import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
 * Performs cleanup of USB related issues
 */
public void dispose()
{
	LibUsb.exit( null );
}
 
开发者ID:ac2cz,项目名称:FoxTelem,代码行数:8,代码来源:TunerManager.java

示例11: uninit

import org.usb4java.LibUsb; //导入方法依赖的package包/类
public void uninit() {
    LibUsb.exit(this.context);
}
 
开发者ID:kairyu,项目名称:flop,代码行数:4,代码来源:Dfu.java

示例12: close

import org.usb4java.LibUsb; //导入方法依赖的package包/类
public void close() {
	LibUsb.releaseInterface(handle, 0);
	LibUsb.attachKernelDriver(handle,  0);
	LibUsb.close(handle);
	LibUsb.exit(context);
}
 
开发者ID:pierre-muth,项目名称:selfpi,代码行数:7,代码来源:TMT20low.java

示例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);
}
 
开发者ID:usb4java,项目名称:usb4java-javax,代码行数:9,代码来源:DeviceManager.java

示例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);
}
 
开发者ID:usb4java,项目名称:usb4java-examples,代码行数:56,代码来源:ListDevices.java

示例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);
}
 
开发者ID:Plug-up,项目名称:daplug-java,代码行数:9,代码来源:DaplugDongleWinusb.java


注:本文中的org.usb4java.LibUsb.exit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。