本文整理汇总了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);
}
}
示例2: getParentUsbPort
import javax.usb.UsbPort; //导入依赖的package包/类
@Override
public UsbPort getParentUsbPort() {
return device.getParentUsbPort();
}
示例3: getParentUsbPort
import javax.usb.UsbPort; //导入依赖的package包/类
@Override
public final UsbPort getParentUsbPort()
{
checkConnected();
return this.port;
}
示例4: getParentUsbPort
import javax.usb.UsbPort; //导入依赖的package包/类
@Override
public UsbPort getParentUsbPort()
{
return null;
}
示例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);
}
}
}