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


Java UsbPort类代码示例

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


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

示例1: setParentUsbPort

import javax.usb.UsbPort; //导入依赖的package包/类
/**
 * Sets the parent USB port. If port is unset then a usbDeviceDetached event
 * is send.
 * 
 * @param port
 *            The port to set. Null to unset.
 */
final void setParentUsbPort(final UsbPort port)
{
    if (this.port == null && port == null)
        throw new IllegalStateException("Device already detached");
    if (this.port != null && port != null)
        throw new IllegalStateException("Device already attached");

    // Disconnect client devices
    if (port == null && isUsbHub())
    {
        final Hub hub = (Hub) this;
        for (final AbstractDevice device: hub.getAttachedUsbDevices())
        {
            hub.disconnectUsbDevice(device);
        }
    }

    this.port = port;

    final Services services = Services.getInstance();

    if (port == null)
    {
        this.listeners.usbDeviceDetached(new UsbDeviceEvent(this));
        services.usbDeviceDetached(this);
    }
    else
    {
        services.usbDeviceAttached(this);
    }
}
 
开发者ID:usb4java,项目名称:usb4java-javax,代码行数:39,代码来源:AbstractDevice.java

示例2: getParentUsbPort

import javax.usb.UsbPort; //导入依赖的package包/类
@Override
public UsbPort getParentUsbPort() {
	return device.getParentUsbPort();
}
 
开发者ID:IAmContent,项目名称:public,代码行数:5,代码来源:EasedUsbDevice.java

示例3: getParentUsbPort

import javax.usb.UsbPort; //导入依赖的package包/类
@Override
public final UsbPort getParentUsbPort()
{
    checkConnected();
    return this.port;
}
 
开发者ID:usb4java,项目名称:usb4java-javax,代码行数:7,代码来源:AbstractDevice.java

示例4: getParentUsbPort

import javax.usb.UsbPort; //导入依赖的package包/类
@Override
public UsbPort getParentUsbPort()
{
    return null;
}
 
开发者ID:usb4java,项目名称:usb4java-javax,代码行数:6,代码来源:RootHub.java

示例5: dumpDevice

import javax.usb.UsbPort; //导入依赖的package包/类
/**
 * Dumps the specified USB device to stdout.
 * 
 * @param device
 *            The USB device to dump.
 */
private static void dumpDevice(final UsbDevice device)
{
    // Dump information about the device itself
    System.out.println(device);
    final UsbPort port = device.getParentUsbPort();
    if (port != null)
    {
        System.out.println("Connected to port: " + port.getPortNumber());
        System.out.println("Parent: " + port.getUsbHub());
    }

    // Dump device descriptor
    System.out.println(device.getUsbDeviceDescriptor());

    // Process all configurations
    for (UsbConfiguration configuration: (List<UsbConfiguration>) device
        .getUsbConfigurations())
    {
        // Dump configuration descriptor
        System.out.println(configuration.getUsbConfigurationDescriptor());

        // Process all interfaces
        for (UsbInterface iface: (List<UsbInterface>) configuration
            .getUsbInterfaces())
        {
            // Dump the interface descriptor
            System.out.println(iface.getUsbInterfaceDescriptor());

            // Process all endpoints
            for (UsbEndpoint endpoint: (List<UsbEndpoint>) iface
                .getUsbEndpoints())
            {
                // Dump the endpoint descriptor
                System.out.println(endpoint.getUsbEndpointDescriptor());
            }
        }
    }

    System.out.println();

    // Dump child devices if device is a hub
    if (device.isUsbHub())
    {
        final UsbHub hub = (UsbHub) device;
        for (UsbDevice child: (List<UsbDevice>) hub.getAttachedUsbDevices())
        {
            dumpDevice(child);
        }
    }
}
 
开发者ID:usb4java,项目名称:usb4java-javax-examples,代码行数:57,代码来源:DumpDevices.java


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