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


Java UsbDevice.isUsbHub方法代码示例

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


在下文中一共展示了UsbDevice.isUsbHub方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: traverse

import javax.usb.UsbDevice; //导入方法依赖的package包/类
/**
 * Recursively traverses the USB bus, adding any labjacks to a list.
 * @param device the device to begin traversing through.
 * @param list the list of UsbDevices to add matching devices to.
 */
private void traverse(UsbDevice device, List<UsbDevice> list)
{
    if (device.isUsbHub())
    {
        // This is a USB Hub, traverse through the hub.
        List attachedDevices = ((UsbHub) device).getAttachedUsbDevices();
        for (int i=0; i<attachedDevices.size(); i++)
        {
            traverse((UsbDevice) attachedDevices.get(i), list);
        }
    }
    else
    {
        /** If the device is a Labjack, add it to the list */
        if (device.getUsbDeviceDescriptor().idVendor() == USB_VENDOR_ID 
                && device.getUsbDeviceDescriptor().idProduct() == USB_PRODUCT_ID)
        {
            list.add(device);
        }
    }
}
 
开发者ID:sahara-labs,项目名称:rig-client-commons,代码行数:27,代码来源:Labjack.java

示例8: getHubDevices

import javax.usb.UsbDevice; //导入方法依赖的package包/类
/**
 * Returns a list of devices attached to the hub
 */
public static List<UsbDevice> getHubDevices( UsbHub hub ) 
					throws UnsupportedEncodingException, UsbException
{
	ArrayList<UsbDevice> devices = new ArrayList<UsbDevice>();
	
	@SuppressWarnings( "unchecked" )
	List<UsbDevice> children = hub.getAttachedUsbDevices();
	
	Iterator<UsbDevice> it = children.iterator();
	
	while( it.hasNext() )
	{
		UsbDevice child = it.next();
		
		if( child.isUsbHub() )
		{
			devices.addAll( getHubDevices( (UsbHub)child ) );
		}
		else
		{
			devices.add( child );
		}
	}
			
	return devices;
}
 
开发者ID:DSheirer,项目名称:sdrtrunk,代码行数:30,代码来源:USBUtils.java

示例9: explore

import javax.usb.UsbDevice; //导入方法依赖的package包/类
/**
 * Explore the USB topology, starting at the given device. 
 */
public void explore(UsbDevice usbDevice) {
       if (shouldVisit(usbDevice))
           visit(usbDevice);

       if (usbDevice.isUsbHub())
       	exploreDescendants((UsbHub) usbDevice);
   }
 
开发者ID:IAmContent,项目名称:public,代码行数:11,代码来源:UsbTopologyExplorer.java

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

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

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

示例13: findDevices

import javax.usb.UsbDevice; //导入方法依赖的package包/类
/**
 * Recursively scans the specified USB hub for ADB devices and puts them
 * into the list.
 * 
 * @param hub
 *            The USB hub to scan recursively.
 * @param devices
 *            The list where to add found devices.
 */
private static void findDevices(UsbHub hub, List<AdbDevice> devices)
{
    for (UsbDevice usbDevice: (List<UsbDevice>) hub.getAttachedUsbDevices())
    {
        if (usbDevice.isUsbHub())
        {
            findDevices((UsbHub) usbDevice, devices);
        }
        else
        {
            checkDevice(usbDevice, devices);
        }
    }
}
 
开发者ID:usb4java,项目名称:usb4java-javax-examples,代码行数:24,代码来源:Adb.java

示例14: dump

import javax.usb.UsbDevice; //导入方法依赖的package包/类
/**
 * Dumps the specified device and its sub devices.
 * 
 * @param device
 *            The USB device to dump.
 * @param level
 *            The indentation level.
 */
public static void dump(UsbDevice device, int level)
{
    for (int i = 0; i < level; i += 1)
        System.out.print("  ");
    System.out.println(device);
    if (device.isUsbHub())
    {
        final UsbHub hub = (UsbHub) device;
        for (UsbDevice child: (List<UsbDevice>) hub.getAttachedUsbDevices())
        {
            dump(child, level + 1);
        }
    }
}
 
开发者ID:usb4java,项目名称:usb4java-javax-examples,代码行数:23,代码来源:DumpDeviceTree.java

示例15: processDevice

import javax.usb.UsbDevice; //导入方法依赖的package包/类
/**
 * Processes the specified USB device.
 * 
 * @param device
 *            The USB device to process.
 */
private static void processDevice(final UsbDevice device)
{
    // When device is a hub then process all child devices
    if (device.isUsbHub())
    {
        final UsbHub hub = (UsbHub) device;
        for (UsbDevice child: (List<UsbDevice>) hub.getAttachedUsbDevices())
        {
            processDevice(child);
        }
    }

    // When device is not a hub then dump its name.
    else
    {
        try
        {
            dumpName(device);
        }
        catch (Exception e)
        {
            // On Linux this can fail because user has no write permission
            // on the USB device file. On Windows it can fail because
            // no libusb device driver is installed for the device
            System.err.println("Ignoring problematic device: " + e);
        }
    }
}
 
开发者ID:usb4java,项目名称:usb4java-javax-examples,代码行数:35,代码来源:DumpNames.java


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