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


Java DeviceDescriptor.idProduct方法代码示例

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


在下文中一共展示了DeviceDescriptor.idProduct方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findDevice

import org.usb4java.DeviceDescriptor; //导入方法依赖的package包/类
public Device findDevice(short vendorId, short productId) {
    // Read the USB device list
    DeviceList list = new DeviceList();
    int result = LibUsb.getDeviceList(null, list);
    if (result < 0) throw new LibUsbException("Unable to get device list", result);

    try {
        // Iterate over all devices and scan for the right one
        for (Device device: list) {
            DeviceDescriptor descriptor = new DeviceDescriptor();
            result = LibUsb.getDeviceDescriptor(device, descriptor);
            if (result != LibUsb.SUCCESS) throw new LibUsbException("Unable to read device descriptor", result);
            if (descriptor.idVendor() == vendorId && descriptor.idProduct() == productId) return device;
        }
    } finally {
        // Ensure the allocated device list is freed
        LibUsb.freeDeviceList(list, true);
    }

    // Device not found
    return null;
}
 
开发者ID:pierre-muth,项目名称:selfpi,代码行数:23,代码来源:TMT20low.java

示例2: SimpleUsbDeviceDescriptor

import org.usb4java.DeviceDescriptor; //导入方法依赖的package包/类
/**
 * Construct from a libusb4java device descriptor.
 * 
 * @param descriptor
 *            The descriptor from which to copy the data.
 */
public SimpleUsbDeviceDescriptor(final DeviceDescriptor descriptor)
{
    this(descriptor.bLength(),
        descriptor.bDescriptorType(),
        descriptor.bcdUSB(),
        descriptor.bDeviceClass(),
        descriptor.bDeviceSubClass(),
        descriptor.bDeviceProtocol(),
        descriptor.bMaxPacketSize0(),
        descriptor.idVendor(),
        descriptor.idProduct(),
        descriptor.bcdDevice(),
        descriptor.iManufacturer(),
        descriptor.iProduct(),
        descriptor.iSerialNumber(),
        descriptor.bNumConfigurations());
}
 
开发者ID:usb4java,项目名称:usb4java-javax,代码行数:24,代码来源:SimpleUsbDeviceDescriptor.java

示例3: findAllDevices

import org.usb4java.DeviceDescriptor; //导入方法依赖的package包/类
/**
 * List all Devices on the Computer with a specific vid and pid value
 * 
 * @param vid short
 * @param pid short
 * @return Vector<Device> 
     * @author yassir
     */
private Vector<Device> findAllDevices(short vid, short pid) {
    Vector<Device> v_dev = new Vector<Device>();
    try {
        // Iterate over all devices and scan for the right one
        for (Device device : allDevices) {
            DeviceDescriptor descriptor = new DeviceDescriptor();
            int result = LibUsb.getDeviceDescriptor(device, descriptor);
            if (result != LibUsb.SUCCESS)
                throw new LibUsbException(
                        "Unable to read device descriptor", result);
            if (descriptor.idVendor() == vid
                    && descriptor.idProduct() == pid)
                v_dev.add(device); // return device;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return v_dev;
}
 
开发者ID:Plug-up,项目名称:daplug-java,代码行数:28,代码来源:DaplugDongleWinusb.java

示例4: dumpDaplugWinUSB

import org.usb4java.DeviceDescriptor; //导入方法依赖的package包/类
/**
 * Get All informations and print it to screen form a specific Device
 * @param device Device
 * @return String
 * @author yassir
 */
public static String dumpDaplugWinUSB(Device device) {
    DeviceDescriptor des = new DeviceDescriptor();
    LibUsb.getDeviceDescriptor(device, des);
    String res = " vid                    : " + des.idVendor()
            + "\n pid                    : " + des.idProduct()
            + "\n Manufacturer           : " + des.iManufacturer()
            + "\n bcdevice               : " + des.bcdDevice()
            + "\n bcdUSB                 : " + des.bcdUSB()
            + "\n serial                 : " + des.iSerialNumber()
            + "\n bDescriptorType        : " + des.bDescriptorType()
            + "\n bDeviceClass           : " + des.bDeviceClass()
            + "\n bDeviceProtocol        : " + des.bDeviceProtocol()
            + "\n bDeviceSubClass        : " + des.bDeviceSubClass()
            + "\n bLength                : " + des.bLength()
            + "\n bMaxPacketSize0        : " + des.bMaxPacketSize0()
            + "\n bNumConfigurations     : " + des.bNumConfigurations()
            + "\n getBuffer              : " + des.getBuffer()
            + "\n getPointer             : " + device.getPointer()
            + "\n hashCode               : " + des.hashCode();
    return res;
}
 
开发者ID:Plug-up,项目名称:daplug-java,代码行数:28,代码来源:DaplugDongleWinusb.java

示例5: getPath

import org.usb4java.DeviceDescriptor; //导入方法依赖的package包/类
/**
 * Create List all Device with their path. It's an other way to list devices by their path.
 * Please Notice that this path is something created specifically for this case.
 * 
 * @return Vector<String> List of all device path
 * @author yassir
 */
public Vector<String> getPath() {
    Vector<String> v_res = new Vector<String>(); 
    for(Device device : allDevices) {
        DeviceDescriptor des = new DeviceDescriptor();
        LibUsb.getDeviceDescriptor(device, des);
        int i = 0;
        if (PRODUCT_ID == des.idProduct() && VENDOR_ID == des.idVendor()) {
            StringBuilder sb = new StringBuilder();
            sb.append("Dongle ").append(i).append(",WINUSB").append(",").append(device.getPointer()).append(",").append("Plug-up");
            v_res.addElement(sb.toString());
            i++;
        }
    }
    return v_res;
}
 
开发者ID:Plug-up,项目名称:daplug-java,代码行数:23,代码来源:DaplugDongleWinusb.java

示例6: openDaplugWinusb

import org.usb4java.DeviceDescriptor; //导入方法依赖的package包/类
/**
 * Open DaplugDongle with a specific vendor_id and product_id
 * @param vid short the product vendor_id
 * @param pid short the product product_id
 * @return Vector<String> open Daplug Dongle
 * @author yassir
 */
private Vector<Device> openDaplugWinusb(short vid, short pid) {
    Vector<Device> v_dev = new Vector<Device>();
    for (Device device : allDevices) {
        DeviceDescriptor descriptor = new DeviceDescriptor();
        int result = LibUsb.getDeviceDescriptor(device, descriptor);
        if (result != LibUsb.SUCCESS)
            throw new LibUsbException(
                    "Unable to read device descriptor", result);
        if (descriptor.idVendor() == vid
                && descriptor.idProduct() == pid) {
            v_dev.add(device);
        }
    }
    return v_dev;
}
 
开发者ID:Plug-up,项目名称:daplug-java,代码行数:23,代码来源:DaplugDongleWinusb.java

示例7: getDevices

import org.usb4java.DeviceDescriptor; //导入方法依赖的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

示例8: buildCompatibleDevicesList

import org.usb4java.DeviceDescriptor; //导入方法依赖的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

示例9: buildCompatibleDevicesList

import org.usb4java.DeviceDescriptor; //导入方法依赖的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

示例10: UsbDevice

import org.usb4java.DeviceDescriptor; //导入方法依赖的package包/类
public UsbDevice(final Device device) {
    dev = LibUsb.refDevice(device);

    devDesc = new DeviceDescriptor();
    LibUsb.getDeviceDescriptor(dev, devDesc);

    devVID = devDesc.idVendor();
    devPID = devDesc.idProduct();
    devDID = devDesc.bcdDevice();

    busAddr = LibUsb.getBusNumber(dev);
    devAddr = LibUsb.getDeviceAddress(dev);
}
 
开发者ID:inilabs,项目名称:flashy,代码行数:14,代码来源:UsbDevice.java

示例11: findMissileLauncher

import org.usb4java.DeviceDescriptor; //导入方法依赖的package包/类
/**
 * Searches for the missile launcher device and returns it. If there are
 * multiple missile launchers attached then this simple demo only returns
 * the first one.
 * 
 * @return The missile launcher USB device or null if not found.
 */
public static Device findMissileLauncher()
{
    // Read the USB device list
    DeviceList list = new DeviceList();
    int result = LibUsb.getDeviceList(null, list);
    if (result < 0)
    {
        throw new RuntimeException(
            "Unable to get device list. Result=" + result);
    }

    try
    {
        // Iterate over all devices and scan for the missile launcher
        for (Device device: list)
        {
            DeviceDescriptor descriptor = new DeviceDescriptor();
            result = LibUsb.getDeviceDescriptor(device, descriptor);
            if (result < 0)
            {
                throw new RuntimeException(
                    "Unable to read device descriptor. Result=" + result);
            }
            if (descriptor.idVendor() == VENDOR_ID
                && descriptor.idProduct() == PRODUCT_ID) return device;
        }
    }
    finally
    {
        // Ensure the allocated device list is freed
        LibUsb.freeDeviceList(list, true);
    }

    // No missile launcher found
    return null;
}
 
开发者ID:usb4java,项目名称:usb4java-examples,代码行数:44,代码来源:MissileLauncher.java


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