當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。