本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}