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


Java UsbDevice.getUsbDeviceDescriptor方法代码示例

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


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

示例1: find

import javax.usb.UsbDevice; //导入方法依赖的package包/类
/**
 * Find the device with vendorId and productId
 * 
 * @param hub
 * @param vendorId
 * @param productId
 * @return USB device or null if not found.
 */
private static UsbDevice find(UsbHub hub, short vendorId, short productId) {
	UsbDevice launcher = null;

	for (UsbDevice device : (List<UsbDevice>) hub.getAttachedUsbDevices()) {
		if (device.isUsbHub()) {
			launcher = find((UsbHub) device, vendorId, productId);
			if (launcher != null)
				return launcher;
		} else {
			UsbDeviceDescriptor desc = device.getUsbDeviceDescriptor();
			if (desc.idVendor() == vendorId && desc.idProduct() == productId)
				return device;
		}
	}
	return null;
}
 
开发者ID:loreii,项目名称:jLedStripe,代码行数:25,代码来源:LedStripe.java

示例2: findUsbDevices

import javax.usb.UsbDevice; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static List<UsbDevice> findUsbDevices(UsbHub hub, short vendorId, short productId) {
    List<UsbDevice> usbDeviceList = new ArrayList<UsbDevice>();
    if (hub != null) {
        for (UsbDevice device : (List<UsbDevice>) hub.getAttachedUsbDevices()) {
            UsbDeviceDescriptor desc = device.getUsbDeviceDescriptor();
            if (desc.idVendor() == vendorId && desc.idProduct() == productId){
                mLogger.debug("Found USB device!");
                usbDeviceList.add(device);
            }
            if (device.isUsbHub()) {
                usbDeviceList.addAll(findUsbDevices((UsbHub) device, vendorId, productId));
            }
        }
    }
    return usbDeviceList;
}
 
开发者ID:fredg02,项目名称:se.bitcraze.crazyflie.lib,代码行数:18,代码来源:UsbLinkJava.java

示例3: findUsb

import javax.usb.UsbDevice; //导入方法依赖的package包/类
private static UsbDevice findUsb(UsbHub hub) {
	UsbDevice launcher = null;

	for (UsbDevice device: (List<UsbDevice>) hub.getAttachedUsbDevices()) {
		if (device.isUsbHub()) {
			launcher = findUsb((UsbHub) device);
			if (launcher != null) return launcher;
		} else {
			UsbDeviceDescriptor desc = device.getUsbDeviceDescriptor();
			System.out.println("Found on USB: idVendor: "+desc.idVendor()+", idProduct: "+desc.idProduct());
			if (desc.idVendor() == VENDOR_ID && desc.idProduct() == product_id) {
				System.out.println("Got our printer.");
				return device;
			}
		}
	}
	return null;
}
 
开发者ID:pierre-muth,项目名称:selfpi,代码行数:19,代码来源:EpsonESCPOSPrinter.java

示例4: dump

import javax.usb.UsbDevice; //导入方法依赖的package包/类
/**
 *
 *
 * @param device
 */
public static void dump(UsbDevice device)
{
    UsbDeviceDescriptor desc = device.getUsbDeviceDescriptor();
    System.out.format("%04x:%04x%n", desc.idVendor() & 0xffff,
            desc.idProduct() & 0xffff);

    if (device.isUsbHub())
    {
        UsbHub hub = (UsbHub) device;

        for (UsbDevice child : (List<UsbDevice>) hub.getAttachedUsbDevices())
        {
            dump(child);
        }
    }
}
 
开发者ID:swordmaster2k,项目名称:robotarmedge,代码行数:22,代码来源:DeviceManager.java

示例5: findDevice

import javax.usb.UsbDevice; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private UsbDevice findDevice(UsbHub usbHub, Module definition) throws UsbException {
	List<UsbDevice> attachedUsbDevices = usbHub.getAttachedUsbDevices();
	for (UsbDevice usbDevice : attachedUsbDevices) {
		UsbDeviceDescriptor desc = usbDevice.getUsbDeviceDescriptor();
		if (definition.isBasedOn(desc.idVendor(), desc.idProduct())) {
			LOGGER.info("found device: {}", definition);
			return usbDevice;
		}
		if (usbDevice.isUsbHub()) {
			usbDevice = findDevice((UsbHub) usbDevice, definition);
			if (usbDevice != null) {
				return usbDevice;
			}
		}
	}
	return null;
}
 
开发者ID:quirinobrizi,项目名称:jax10,代码行数:19,代码来源:X10UsbControllerProvider.java

示例6: findMissileLauncher

import javax.usb.UsbDevice; //导入方法依赖的package包/类
/**
 * Recursively searches for the missile launcher device on the specified USB
 * hub and returns it. If there are multiple missile launchers attached then
 * this simple demo only returns the first one.
 * 
 * @param hub
 *            The USB hub to search on.
 * @return The missile launcher USB device or null if not found.
 */
public static UsbDevice findMissileLauncher(UsbHub hub)
{
    UsbDevice launcher = null;

    for (UsbDevice device: (List<UsbDevice>) hub.getAttachedUsbDevices())
    {
        if (device.isUsbHub())
        {
            launcher = findMissileLauncher((UsbHub) device);
            if (launcher != null) return launcher;
        }
        else
        {
            UsbDeviceDescriptor desc = device.getUsbDeviceDescriptor();
            if (desc.idVendor() == VENDOR_ID &&
                desc.idProduct() == PRODUCT_ID) return device;
        }
    }
    return null;
}
 
开发者ID:usb4java,项目名称:usb4java-javax-examples,代码行数:30,代码来源:MissileLauncher.java

示例7: findUsb

import javax.usb.UsbDevice; //导入方法依赖的package包/类
public static UsbDevice findUsb(UsbHub hub) {
	UsbDevice launcher = null;

	for (UsbDevice device: (List<UsbDevice>) hub.getAttachedUsbDevices()) {
		if (device.isUsbHub()) {
			launcher = findUsb((UsbHub) device);
			if (launcher != null) return launcher;
		} else {
			UsbDeviceDescriptor desc = device.getUsbDeviceDescriptor();
			System.out.println("idVendor: "+desc.idVendor()+", idProduct: "+desc.idProduct());
			if (desc.idVendor() == VENDOR_ID && desc.idProduct() == PRODUCT_ID) return device;
		}
	}
	return null;
}
 
开发者ID:pierre-muth,项目名称:selfpi,代码行数:16,代码来源:TMT20.java

示例8: findDevice

import javax.usb.UsbDevice; //导入方法依赖的package包/类
private static UsbDevice findDevice(UsbHub hub, short vendorId, short productId) {
  for (UsbDevice device : (List<UsbDevice>) hub.getAttachedUsbDevices()) {
    UsbDeviceDescriptor desc = device.getUsbDeviceDescriptor();
    if (desc.idVendor() == vendorId && desc.idProduct() == productId) {
      return device;
    }
    if (device.isUsbHub()) {
      device = findDevice((UsbHub) device, vendorId, productId);
      if (device != null) {
        return device;
      }
    }
  }
  return null;
}
 
开发者ID:RaspberryPiWithJava,项目名称:JavaScale,代码行数:16,代码来源:UsbScaleTest.java

示例9: findDevice

import javax.usb.UsbDevice; //导入方法依赖的package包/类
/**
 *
 *
 * @param hub
 * @param vendorId
 * @param productId
 * @return
 */
public static UsbDevice findDevice(UsbHub hub, int vendorId, int productId)
{
    for (UsbDevice device : (List<UsbDevice>) hub.getAttachedUsbDevices())
    {
        if (device == null)
        {
            continue;
        }

        UsbDeviceDescriptor descriptor;

        descriptor = device.getUsbDeviceDescriptor();

        if (descriptor.idVendor() == vendorId
                && descriptor.idProduct() == productId)
        {
            return device;
        }

        if (device.isUsbHub())
        {
            device = findDevice((UsbHub) device, vendorId, productId);

            if (device != null)
            {
                return device;
            }
        }
    }

    return null;
}
 
开发者ID:swordmaster2k,项目名称:robotarmedge,代码行数:41,代码来源:DeviceManager.java

示例10: dumpName

import javax.usb.UsbDevice; //导入方法依赖的package包/类
/**
 * Dumps the name of the specified device to stdout.
 * 
 * @param device
 *            The USB device.
 * @throws UnsupportedEncodingException
 *             When string descriptor could not be parsed.
 * @throws UsbException
 *             When string descriptor could not be read.
 */
private static void dumpName(final UsbDevice device)
    throws UnsupportedEncodingException, UsbException
{
    // Read the string descriptor indices from the device descriptor.
    // If they are missing then ignore the device.
    final UsbDeviceDescriptor desc = device.getUsbDeviceDescriptor();
    final byte iManufacturer = desc.iManufacturer();
    final byte iProduct = desc.iProduct();
    if (iManufacturer == 0 || iProduct == 0) return;

    // Dump the device name
    System.out.println(device.getString(iManufacturer) + " "
        + device.getString(iProduct));
}
 
开发者ID:usb4java,项目名称:usb4java-javax-examples,代码行数:25,代码来源:DumpNames.java

示例11: isGeneratedByAKnownDevice

import javax.usb.UsbDevice; //导入方法依赖的package包/类
protected Boolean isGeneratedByAKnownDevice(UsbDevice device) {
	UsbDeviceDescriptor descriptor = device.getUsbDeviceDescriptor();
	return Module.isValidDevice(descriptor.idVendor(), descriptor.idProduct());
}
 
开发者ID:quirinobrizi,项目名称:jax10,代码行数:5,代码来源:AbstractX10Listener.java

示例12: checkDevice

import javax.usb.UsbDevice; //导入方法依赖的package包/类
/**
 * Checks if the specified USB device is a ADB device and adds it to the
 * list if it is.
 * 
 * @param usbDevice
 *            The USB device to check.
 * @param adbDevices
 *            The list of ADB devices to add the USB device to when it is an
 *            ADB device.
 */
private static void checkDevice(UsbDevice usbDevice,
    List<AdbDevice> adbDevices)
{
    UsbDeviceDescriptor deviceDesc = usbDevice.getUsbDeviceDescriptor();

    // Ignore devices from Non-ADB vendors
    if (!isAdbVendor(deviceDesc.idVendor())) return;

    // Check interfaces of device
    UsbConfiguration config = usbDevice.getActiveUsbConfiguration();
    for (UsbInterface iface: (List<UsbInterface>) config.getUsbInterfaces())
    {
        List<UsbEndpoint> endpoints = iface.getUsbEndpoints();

        // Ignore interface if it does not have two endpoints
        if (endpoints.size() != 2) continue;

        // Ignore interface if it does not match the ADB specs
        if (!isAdbInterface(iface)) continue;

        UsbEndpointDescriptor ed1 =
            endpoints.get(0).getUsbEndpointDescriptor();
        UsbEndpointDescriptor ed2 =
            endpoints.get(1).getUsbEndpointDescriptor();

        // Ignore interface if endpoints are not bulk endpoints
        if (((ed1.bmAttributes() & UsbConst.ENDPOINT_TYPE_BULK) == 0) ||
            ((ed2.bmAttributes() & UsbConst.ENDPOINT_TYPE_BULK) == 0))
            continue;
        
        // Determine which endpoint is in and which is out. If both
        // endpoints are in or out then ignore the interface
        byte a1 = ed1.bEndpointAddress();
        byte a2 = ed2.bEndpointAddress();
        byte in, out;
        if (((a1 & UsbConst.ENDPOINT_DIRECTION_IN) != 0) &&
            ((a2 & UsbConst.ENDPOINT_DIRECTION_IN) == 0))
        {
            in = a1;
            out = a2;
        }
        else if (((a2 & UsbConst.ENDPOINT_DIRECTION_IN) != 0) &&
            ((a1 & UsbConst.ENDPOINT_DIRECTION_IN) == 0))
        {
            out = a1;
            in = a2;
        }
        else continue;                
        
        // Create ADB device and add it to the list
        AdbDevice adbDevice = new AdbDevice(iface, in, out);
        adbDevices.add(adbDevice);
    }
}
 
开发者ID:usb4java,项目名称:usb4java-javax-examples,代码行数:65,代码来源:Adb.java


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