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


Java LibUsb.close方法代码示例

本文整理汇总了Java中org.usb4java.LibUsb.close方法的典型用法代码示例。如果您正苦于以下问题:Java LibUsb.close方法的具体用法?Java LibUsb.close怎么用?Java LibUsb.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.usb4java.LibUsb的用法示例。


在下文中一共展示了LibUsb.close方法的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: dispose

import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
 * Disposes of resources.  Closes the USB device and interface.
 */
public void dispose()
{
    if(mDeviceHandle != null)
    {
        try
        {
            LibUsb.close(mDeviceHandle);
        }
        catch(Exception e)
        {
            mLog.error("error while closing device handle", e);
        }

        mDeviceHandle = null;
    }

    mDeviceDescriptor = null;
    mDevice = null;
}
 
开发者ID:DSheirer,项目名称:sdrtrunk,代码行数:23,代码来源:FCDTunerController.java

示例4: getDevices

import org.usb4java.LibUsb; //导入方法依赖的package包/类
public Device[] getDevices(int vendor_id, int product_id){
  
  DeviceList usb_device_list = new DeviceList();
  int result = LibUsb.getDeviceList(context, usb_device_list);
  if (result < 0){
    throw new LibUsbException("Unable to get device list", result);
  }
  
  ArrayList<Device> ps3_device_list = new ArrayList<Device>();
  
  try {

    for (Device usb_device : usb_device_list) {
      DeviceDescriptor descriptor = new DeviceDescriptor();
      result = LibUsb.getDeviceDescriptor(usb_device, descriptor);
      if (result != LibUsb.SUCCESS){
        throw new LibUsbException("Unable to read device descriptor", result);
      }

      if(descriptor.idVendor() == vendor_id && descriptor.idProduct() == product_id){
        DeviceHandle handle = new DeviceHandle();
        result = LibUsb.open(usb_device, handle);
        if (result != LibUsb.SUCCESS){
          throw new LibUsbException("Unable to open USB device", result);
        }
        
        LibUsb.close(handle);
        LibUsb.refDevice(usb_device);
        ps3_device_list.add(usb_device);
      }

    }
  } finally {
    LibUsb.freeDeviceList(usb_device_list, true);
  }
  
  return ps3_device_list.toArray(new Device[ps3_device_list.size()]);
}
 
开发者ID:diwi,项目名称:PS3Eye,代码行数:39,代码来源:USB.java

示例5: closeUSB

import org.usb4java.LibUsb; //导入方法依赖的package包/类
private void closeUSB(){
  if(usb_device_handle != null){
    LibUsb.releaseInterface(usb_device_handle, 0);
    LibUsb.close(usb_device_handle);
    usb_device_handle = null;
  }

  if(usb_device != null){
    LibUsb.unrefDevice(usb_device);
    usb_device = null;
  }
}
 
开发者ID:diwi,项目名称:PS3Eye,代码行数:13,代码来源:PS3Eye.java

示例6: close

import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
 * Closes the device. Never throws an exception.
 */
@Override
synchronized public void close() {
	if (!isOpen()) {
		return;
	}

	try {
		setEventAcquisitionEnabled(false);

		if (asyncStatusThread != null) {
			asyncStatusThread.stopThread();
		}
	}
	catch (final HardwareInterfaceException e) {
		e.printStackTrace();
	}

	LibUsb.releaseInterface(deviceHandle, 0);
	LibUsb.close(deviceHandle);

	deviceHandle = null;
	deviceDescriptor = null;

	inEndpointEnabled = false;
	isOpened = false;
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:30,代码来源:CypressFX2.java

示例7: buildCompatibleDevicesList

import org.usb4java.LibUsb; //导入方法依赖的package包/类
private List<Device> buildCompatibleDevicesList() {
	final List<Device> compatibleDevicesListLocal = new ArrayList<>();

	final DeviceList devList = new DeviceList();
	LibUsb.getDeviceList(null, devList);

	final DeviceDescriptor devDesc = new DeviceDescriptor();

	for (final Device dev : devList) {

		LibUsb.getDeviceDescriptor(dev, devDesc);

		final ImmutablePair<Short, Short> vidPid = new ImmutablePair<>(devDesc.idVendor(), devDesc.idProduct());


		// Check that the device is not already bound to any other driver.
		final DeviceHandle devHandle = new DeviceHandle();
		int status = LibUsb.open(dev, devHandle);
		if (status != LibUsb.SUCCESS) {
			continue; // Skip device.
		}

		status = LibUsb.kernelDriverActive(devHandle, 0);

		LibUsb.close(devHandle);

		if (((status == LibUsb.ERROR_NOT_SUPPORTED) || (status == LibUsb.SUCCESS))
			&& vidPidToClassMap.containsKey(vidPid)) {
			// This is a VID/PID combination we support, so let's add the
			// device to the compatible
			// devices list and increase its reference count.
			compatibleDevicesListLocal.add(LibUsb.refDevice(dev));
		}
	}

	LibUsb.freeDeviceList(devList, true);

	return compatibleDevicesListLocal;
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:40,代码来源:LibUsbHardwareInterfaceFactory.java

示例8: buildCompatibleDevicesList

import org.usb4java.LibUsb; //导入方法依赖的package包/类
private List<Device> buildCompatibleDevicesList() {
	final List<Device> compatibleDevicesListLocal = new ArrayList<>();

	final DeviceList devList = new DeviceList();
	LibUsb.getDeviceList(null, devList);

	final DeviceDescriptor devDesc = new DeviceDescriptor();

	for (final Device dev : devList) {
		LibUsb.getDeviceDescriptor(dev, devDesc);

		final ImmutablePair<Short, Short> vidPid = new ImmutablePair<>(devDesc.idVendor(), devDesc.idProduct());

		// Check that the device is not already bound to any other driver.
		final DeviceHandle devHandle = new DeviceHandle();
		int status = LibUsb.open(dev, devHandle);
		if (status != LibUsb.SUCCESS) {
			continue; // Skip device.
		}

		status = LibUsb.kernelDriverActive(devHandle, 0);

		LibUsb.close(devHandle);

		if (((status == LibUsb.ERROR_NOT_SUPPORTED) || (status == LibUsb.SUCCESS)) && vidPidToClassMap.containsKey(vidPid)) {
			// This is a VID/PID combination we support, so let's add the
			// device to the compatible
			// devices list and increase its reference count.
			compatibleDevicesListLocal.add(LibUsb.refDevice(dev));
		}
	}

	LibUsb.freeDeviceList(devList, true);

	return compatibleDevicesListLocal;
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:37,代码来源:LibUsb3HardwareInterfaceFactory.java

示例9: close

import org.usb4java.LibUsb; //导入方法依赖的package包/类
@Override
synchronized public void close() {
    if (!isOpen()) {
        return;
    }

    this.setAEReaderEnabled(false);

    /*if (asyncStatusThread != null) {
     asyncStatusThread.stopThread();
     }*/
    try {
        this.releaseDevice();
    } catch (HardwareInterfaceException ex) {
        SiLabsC8051F320_LibUsb.log.warning("could not release device");
    }

    LibUsb.close(retinahandle);

    retinahandle = null;

    deviceDescriptor = null;

    aePacketRawPool.reset();

    isOpened = false;
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:28,代码来源:SiLabsC8051F320_LibUsb.java

示例10: 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

示例11: close

import org.usb4java.LibUsb; //导入方法依赖的package包/类
public synchronized void close() {
	// Execute cleanup tasks.
	for (final Runnable r : cleanupTasks) {
		r.run();
	}

	// Clear cleanup tasks list, will be readded as needed.
	cleanupTasks.clear();

	if (devHandle != null) {
		LibUsb.releaseInterface(devHandle, 0);
		LibUsb.close(devHandle);
		devHandle = null;
	}
}
 
开发者ID:inilabs,项目名称:flashy,代码行数:16,代码来源:UsbDevice.java

示例12: uninitDevice

import org.usb4java.LibUsb; //导入方法依赖的package包/类
public void uninitDevice(DeviceHandle handle, byte iface) throws LibUsbException {
    int result = LibUsb.releaseInterface(handle, iface);
    if (result < 0) {
        System.err.println(String.format("failed to release interface %d.", iface));
        throw new LibUsbException("Failed to release interface", result);
    }
    LibUsb.close(handle);
}
 
开发者ID:kairyu,项目名称:flop,代码行数:9,代码来源:Dfu.java

示例13: close

import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
 * Closes the device. If device is not open then nothing is done.
 */
public final void close()
{
    if (this.handle != null)
    {
        LibUsb.close(this.handle);
        this.handle = null;
    }
}
 
开发者ID:usb4java,项目名称:usb4java-javax,代码行数:12,代码来源:AbstractDevice.java

示例14: 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

示例15: 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


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