Top Description Methods
javax.usb

public Interface UsbInterface

Imports
java.io.UnsupportedEncodingException, java.util.*

Interface for a USB interface.

This object actually represents a specific 'alternate' setting for a USB interface. Interfaces must have at least one alternate setting, and one and only one setting is active per interface. All settings share the same interface number. If this interface setting is not active, it cannot be claimed or released; the active interface setting should be used for claiming and releasing ownership of the interface; also no action may be taken on any parts of this interface setting, if the setting is not active. Any attempt to perform action on objects belonging to an inactive interface setting will throw a UsbNotActiveException.

Author
Dan Streetman

Method Summary

Modifier and TypeMethod and Description
public void
claim()

Claim this interface.

public void
claim(UsbInterfacePolicy
The UsbInterfacePolicy to use.
policy
)

Claim this interface using a UsbInterfacePolicy.

public boolean

Returns:

If the alternate setting exists.
containsSetting
(byte
The alternate setting number.
number
)

If the specified alternate setting exists.

public boolean

Returns:

If this UsbInterface contains the specified UsbEndpoint.
containsUsbEndpoint
(byte
The endpoint address.
address
)

If the specified UsbEndpoint is contained in this UsbInterface.

public UsbInterface

Returns:

The active setting for this interface.
getActiveSetting
()

Get the active alternate setting.

public byte

Returns:

The active setting number for this interface.
getActiveSettingNumber
()

Get the number of the active alternate setting.

public String

Returns:

The interface String, or null.
getInterfaceString
()

Get the interface String.

public int

Returns:

the number of alternate settings for this interface.
getNumSettings
()

Get the number of alternate settings for this interface.

public UsbInterface

Returns:

The specified alternate setting, or null.
getSetting
(byte number)

Get the specified alternate setting.

public List<E>

Returns:

All alternate settings for this interface.
getSettings
()

Get all alternate settings for this interface.

public UsbConfiguration

Returns:

The UsbConfiguration that this interface belongs to.
getUsbConfiguration
()

Get the parent UsbConfiguration that this UsbInterface belongs to.

public UsbEndpoint

Returns:

The specified UsbEndpoint, or null.
getUsbEndpoint
(byte
The address of the UsbEndpoint to get.
address
)

Get a specific UsbEndpoint.

public List<E>

Returns:

All endpoints for this setting.
getUsbEndpoints
()

Get all endpoints for this interface setting.

public UsbInterfaceDescriptor

Returns:

The interface descriptor.
getUsbInterfaceDescriptor
()

Get the interface descriptor.

public boolean

Returns:

if this interface alternate setting is active.
isActive
()

If this interface alternate setting is active.

public boolean

Returns:

If this interface is claimed (in Java).
isClaimed
()

If this interface is claimed.

public void
release()

Release this interface.

Method Detail

claimback to summary
public void claim() throws UsbClaimException, UsbException, UsbNotActiveException, UsbDisconnectedException

Claim this interface.

This will attempt whatever claiming the native implementation provides, if any. If the interface is already claimed, or the native claim fails, this will fail.

This must be done before opening and/or using any UsbPipes.

Exceptions
UsbClaimException:
If the interface is already claimed.
UsbException:
If the interface could not be claimed.
UsbNotActiveException:
If this interface setting is not active.
UsbDisconnectedException:
If this interface (device) has been disconnected.
claimback to summary
public void claim(UsbInterfacePolicy policy) throws UsbClaimException, UsbException, UsbNotActiveException, UsbDisconnectedException

Claim this interface using a UsbInterfacePolicy.

This will attempt whatever claiming the native implementation provides, if any. If the native claim fails, this will fail. If the interface is already claimed, this may fail depending on the value of the UsbInterfacePolicy.forceClaim().

Parameters
policy:UsbInterfacePolicy

The UsbInterfacePolicy to use.

Exceptions
UsbClaimException:
If the interface is already claimed.
UsbException:
If the interface could not be claimed.
UsbNotActiveException:
If this interface setting is not active.
UsbDisconnectedException:
If this interface (device) has been disconnected.
containsSettingback to summary
public boolean containsSetting(byte number)

If the specified alternate setting exists.

Parameters
number:byte

The alternate setting number.

Returns:boolean

If the alternate setting exists.

containsUsbEndpointback to summary
public boolean containsUsbEndpoint(byte address)

If the specified UsbEndpoint is contained in this UsbInterface.

Parameters
address:byte

The endpoint address.

Returns:boolean

If this UsbInterface contains the specified UsbEndpoint.

getActiveSettingback to summary
public UsbInterface getActiveSetting() throws UsbNotActiveException

Get the active alternate setting.

Returns:UsbInterface

The active setting for this interface.

Exceptions
UsbNotActiveException:
If this interface (and parent config) is not active.
getActiveSettingNumberback to summary
public byte getActiveSettingNumber() throws UsbNotActiveException

Get the number of the active alternate setting.

Returns:byte

The active setting number for this interface.

Exceptions
UsbNotActiveException:
If the interface (and parent config) is not active.
getInterfaceStringback to summary
public String getInterfaceString() throws UsbException, UnsupportedEncodingException, UsbDisconnectedException

Get the interface String.

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

Returns:String

The interface String, or null.

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

Get the number of alternate settings for this interface.

Returns:int

the number of alternate settings for this interface.

getSettingback to summary
public UsbInterface getSetting(byte number)

Get the specified alternate setting.

If the specified setting does not exist, this returns null.

Returns:UsbInterface

The specified alternate setting, or null.

getSettingsback to summary
public List<E> getSettings()

Get all alternate settings for this interface.

This returns all alternate settings, including this one.

Returns:List<E>

All alternate settings for this interface.

getUsbConfigurationback to summary
public UsbConfiguration getUsbConfiguration()

Get the parent UsbConfiguration that this UsbInterface belongs to.

Returns:UsbConfiguration

The UsbConfiguration that this interface belongs to.

getUsbEndpointback to summary
public UsbEndpoint getUsbEndpoint(byte address)

Get a specific UsbEndpoint.

If this does not contain the specified endpoint, this returns null.

Parameters
address:byte

The address of the UsbEndpoint to get.

Returns:UsbEndpoint

The specified UsbEndpoint, or null.

getUsbEndpointsback to summary
public List<E> getUsbEndpoints()

Get all endpoints for this interface setting.

Returns:List<E>

All endpoints for this setting.

getUsbInterfaceDescriptorback to summary
public UsbInterfaceDescriptor getUsbInterfaceDescriptor()

Get the interface descriptor.

The descriptor may be cached.

Returns:UsbInterfaceDescriptor

The interface descriptor.

isActiveback to summary
public boolean isActive()

If this interface alternate setting is active.

The interface itself is active if and only if its parent configuration is active. If the interface itself is not active, none of its alternate settings are active.

Returns:boolean

if this interface alternate setting is active.

isClaimedback to summary
public boolean isClaimed()

If this interface is claimed.

This will return true if claimed in Java. This may, depending on implementation, return true if claimed natively (outside of Java)

If this UsbInterface is not active, this will return if the active alternate setting is active.

Returns:boolean

If this interface is claimed (in Java).

releaseback to summary
public void release() throws UsbClaimException, UsbException, UsbNotActiveException, UsbDisconnectedException

Release this interface.

This will only succeed if the interface has been properly claimed. If the native release fails, this will fail.

This should be done after the interface is no longer being used. All pipes must be closed before this can be released.

Exceptions
UsbClaimException:
If the interface is not claimed.
UsbException:
If the interface could not be released.
UsbNotActiveException:
If this interface setting is not active.
UsbDisconnectedException:
If this interface (device) has been disconnected.