本文整理匯總了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);
}
}
}