Top Description Methods
javax.usb

public Interface UsbDevice

Known Direct Subinterfaces
javax.usb.UsbHub
Known Direct Implementers
javax.usb.util.UsbUtil.SynchronizedUsbDevice
Imports
java.io.UnsupportedEncodingException, java.util.*, javax.usb.event.*

Interface for a USB device.

The submission methods contained in this UsbDevice operate on the device's Default Control Pipe. The device does not have to be configured to use the Default Control Pipe.

The implementation is not required to be Thread-safe. If a Thread-safe UsbDevice is required, use a synchronizedUsbDevice.

Authors
Dan Streetman, E. Michael Maximilien

Method Summary

Modifier and TypeMethod and Description
public void
addUsbDeviceListener(UsbDeviceListener
The UsbDeviceListener to add.
listener
)

Add a UsbDeviceListener to this UsbDevice.

public void
asyncSubmit(UsbControlIrp
The UsbControlIrp.
irp
)

Submit a UsbControlIrp asynchronously to the Default Control Pipe.

public void
asyncSubmit(List<E>
The List of UsbControlIrps.
list
)

Submit a List of UsbControlIrps asynchronously to the Default Control Pipe.

public boolean

Returns:

If the specified UsbConfiguration is contained in this UsbDevice.
containsUsbConfiguration
(byte number)

If this UsbDevice contains the specified UsbConfiguration.

public UsbControlIrp

Returns:

A UsbControlIrp ready for use.
createUsbControlIrp
(byte
The bmRequestType.
bmRequestType
,
byte
The bRequest.
bRequest
,
short
The wValue.
wValue
,
short
The wIndex.
wIndex
)

Create a UsbControlIrp.

public UsbConfiguration

Returns:

The active UsbConfiguration, or null.
getActiveUsbConfiguration
()

Get the active UsbConfiguration.

public byte

Returns:

The active config number.
getActiveUsbConfigurationNumber
()

Get the number of the active UsbConfiguration.

public String

Returns:

The manufacturer String, or null.
getManufacturerString
()

Get the manufacturer String.

public UsbPort

Returns:

The port on the parent UsbHub that this is attached to.
getParentUsbPort
()

Get the UsbPort on the parent UsbHub that this device is connected to.

public String

Returns:

The product String, or null.
getProductString
()

Get the product String.

public String

Returns:

The serial number String, or null.
getSerialNumberString
()

Get the serial number String.

public Object

Returns:

The speed of this device.
getSpeed
()

Get the speed of the device.

public String

Returns:

The specified String.
getString
(byte
The index of the string to get.
index
)

Get the String from the specified string descriptor.

public UsbConfiguration

Returns:

The specified UsbConfiguration, or null.
getUsbConfiguration
(byte number)

Get the specified UsbConfiguration.

public List<E>

Returns:

All UsbConfigurations for this device.
getUsbConfigurations
()

Get all UsbConfigurations for this device.

public UsbDeviceDescriptor

Returns:

The device descriptor.
getUsbDeviceDescriptor
()

Get the device descriptor.

public UsbStringDescriptor

Returns:

The specified string descriptor.
getUsbStringDescriptor
(byte
The index of the string descriptor to get.
index
)

Get the specified string descriptor.

public boolean

Returns:

If this is in the Configured state.
isConfigured
()

If this UsbDevice is configured.

public boolean

Returns:

true if this is a UsbHub.
isUsbHub
()

If this is a UsbHub.

public void
removeUsbDeviceListener(UsbDeviceListener
The listener to remove.
listener
)

Remove a UsbDeviceListener from this UsbDevice.

public void
syncSubmit(UsbControlIrp
The UsbControlIrp.
irp
)

Submit a UsbControlIrp synchronously to the Default Control Pipe.

public void
syncSubmit(List<E>
The List of UsbControlIrps.
list
)

Submit a List of UsbControlIrps synchronously to the Default Control Pipe.

Method Detail

addUsbDeviceListenerback to summary
public void addUsbDeviceListener(UsbDeviceListener listener)

Add a UsbDeviceListener to this UsbDevice.

Parameters
listener:UsbDeviceListener

The UsbDeviceListener to add.

asyncSubmitback to summary
public void asyncSubmit(UsbControlIrp irp) throws UsbException, IllegalArgumentException, UsbDisconnectedException

Submit a UsbControlIrp asynchronously to the Default Control Pipe.

Parameters
irp:UsbControlIrp

The UsbControlIrp.

Exceptions
UsbException:
If an error occurrs.
IllegalArgumentException:
If the UsbControlIrp is not valid.
UsbDisconnectedException:
If this device has been disconnected.
asyncSubmitback to summary
public void asyncSubmit(List<E> list) throws UsbException, IllegalArgumentException, UsbDisconnectedException

Submit a List of UsbControlIrps asynchronously to the Default Control Pipe.

All UsbControlIrps are guaranteed to be atomically (with respect to other clients of this API) submitted to the Default Control Pipe. Atomicity on a native level is implementation-dependent.

Parameters
list:List<E>

The List of UsbControlIrps.

Exceptions
UsbException:
If an error occurrs.
IllegalArgumentException:
If the List contains non-UsbControlIrp objects or those UsbIrp(s) are invalid.
UsbDisconnectedException:
If this device has been disconnected.
containsUsbConfigurationback to summary
public boolean containsUsbConfiguration(byte number)

If this UsbDevice contains the specified UsbConfiguration.

This will return false for zero (the Not Configured state).

Returns:boolean

If the specified UsbConfiguration is contained in this UsbDevice.

createUsbControlIrpback to summary
public UsbControlIrp createUsbControlIrp(byte bmRequestType, byte bRequest, short wValue, short wIndex)

Create a UsbControlIrp.

This creates a UsbControlIrp that may be optimized for use on this UsbDevice. Using this UsbIrp instead of a DefaultUsbControlIrp may increase performance or decrease memory requirements.

The UsbDevice cannot require this UsbControlIrp to be used, all submit methods must accept any UsbControlIrp implementation.

Parameters
bmRequestType:byte

The bmRequestType.

bRequest:byte

The bRequest.

wValue:short

The wValue.

wIndex:short

The wIndex.

Returns:UsbControlIrp

A UsbControlIrp ready for use.

getActiveUsbConfigurationback to summary
public UsbConfiguration getActiveUsbConfiguration()

Get the active UsbConfiguration.

If this device is Not Configured, this returns null.

Returns:UsbConfiguration

The active UsbConfiguration, or null.

getActiveUsbConfigurationNumberback to summary
public byte getActiveUsbConfigurationNumber()

Get the number of the active UsbConfiguration.

If the device is in a Not Configured state, this will return zero.

Returns:byte

The active config number.

getManufacturerStringback to summary
public String getManufacturerString() throws UsbException, UnsupportedEncodingException, UsbDisconnectedException

Get the manufacturer String.

This is a convienence method, which uses getString.

Returns:String

The manufacturer String, or null.

Exceptions
UsbException:
If there was an error getting the UsbStringDescriptor.
UnsupportedEncodingException:
If the string encoding is not supported.
UsbDisconnectedException:
If this device has been disconnected.
getParentUsbPortback to summary
public UsbPort getParentUsbPort() throws UsbDisconnectedException

Get the UsbPort on the parent UsbHub that this device is connected to.

Returns:UsbPort

The port on the parent UsbHub that this is attached to.

Exceptions
UsbDisconnectedException:
If this device has been disconnected.
getProductStringback to summary
public String getProductString() throws UsbException, UnsupportedEncodingException, UsbDisconnectedException

Get the product String.

This is a convienence method, which uses getString.

Returns:String

The product String, or null.

Exceptions
UsbException:
If there was an error getting the UsbStringDescriptor.
UnsupportedEncodingException:
If the string encoding is not supported.
UsbDisconnectedException:
If this device has been disconnected.
getSerialNumberStringback to summary
public String getSerialNumberString() throws UsbException, UnsupportedEncodingException, UsbDisconnectedException

Get the serial number String.

This is a convienence method, which uses getString.

Returns:String

The serial number String, or null.

Exceptions
UsbException:
If there was an error getting the UsbStringDescriptor.
UnsupportedEncodingException:
If the string encoding is not supported.
UsbDisconnectedException:
If this device has been disconnected.
getSpeedback to summary
public Object getSpeed()

Get the speed of the device.

The speed will be one of:

Returns:Object

The speed of this device.

getStringback to summary
public String getString(byte index) throws UsbException, UnsupportedEncodingException, UsbDisconnectedException

Get the String from the specified string descriptor.

This is a convienence method, which uses getUsbStringDescriptor(). getString().

Parameters
index:byte

The index of the string to get.

Returns:String

The specified String.

Exceptions
UsbException:
If an error occurred while getting the String.
UnsupportedEncodingException:
If the string encoding is not supported.
UsbDisconnectedException:
If this device has been disconnected.
getUsbConfigurationback to summary
public UsbConfiguration getUsbConfiguration(byte number)

Get the specified UsbConfiguration.

If the specified UsbConfiguration does not exist, null is returned. Config number 0 is reserved for the Not Configured state (see the USB 1.1 specification section 9.4.2). Obviously, no UsbConfiguration exists for the Not Configured state.

Returns:UsbConfiguration

The specified UsbConfiguration, or null.

getUsbConfigurationsback to summary
public List<E> getUsbConfigurations()

Get all UsbConfigurations for this device.

The List is unmodifiable.

Returns:List<E>

All UsbConfigurations for this device.

getUsbDeviceDescriptorback to summary
public UsbDeviceDescriptor getUsbDeviceDescriptor()

Get the device descriptor.

The descriptor may be cached.

Returns:UsbDeviceDescriptor

The device descriptor.

getUsbStringDescriptorback to summary
public UsbStringDescriptor getUsbStringDescriptor(byte index) throws UsbException, UsbDisconnectedException

Get the specified string descriptor.

This is a convienence method. The UsbStringDescriptor may be cached. If the device does not support strings or does not define the specified string descriptor, this returns null.

Parameters
index:byte

The index of the string descriptor to get.

Returns:UsbStringDescriptor

The specified string descriptor.

Exceptions
UsbException:
If an error occurred while getting the string descriptor.
UsbDisconnectedException:
If this device has been disconnected.
isConfiguredback to summary
public boolean isConfigured()

If this UsbDevice is configured.

This returns true if the device is in the configured state as shown in the USB 1.1 specification table 9.1.

Returns:boolean

If this is in the Configured state.

isUsbHubback to summary
public boolean isUsbHub()

If this is a UsbHub.

Returns:boolean

true if this is a UsbHub.

removeUsbDeviceListenerback to summary
public void removeUsbDeviceListener(UsbDeviceListener listener)

Remove a UsbDeviceListener from this UsbDevice.

Parameters
listener:UsbDeviceListener

The listener to remove.

syncSubmitback to summary
public void syncSubmit(UsbControlIrp irp) throws UsbException, IllegalArgumentException, UsbDisconnectedException

Submit a UsbControlIrp synchronously to the Default Control Pipe.

Parameters
irp:UsbControlIrp

The UsbControlIrp.

Exceptions
UsbException:
If an error occurrs.
IllegalArgumentException:
If the UsbControlIrp is not valid.
UsbDisconnectedException:
If this device has been disconnected.
syncSubmitback to summary
public void syncSubmit(List<E> list) throws UsbException, IllegalArgumentException, UsbDisconnectedException

Submit a List of UsbControlIrps synchronously to the Default Control Pipe.

All UsbControlIrps are guaranteed to be atomically (with respect to other clients of this API) submitted to the Default Control Pipe. Atomicity on a native level is implementation-dependent.

Parameters
list:List<E>

The List of UsbControlIrps.

Exceptions
UsbException:
If an error occurrs.
IllegalArgumentException:
If the List contains non-UsbControlIrp objects or those UsbIrp(s) are invalid.
UsbDisconnectedException:
If this device has been disconnected.