|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--usb.core.Device
Provides access to a USB device.
To use a device, first make sure that you can use its current configuration. Then get the interfaces for that configuration and claim the ones you want to use. Then just use the endpoints from those interfaces. You might want to switch some interfaces to their alternate settings before you start using endpoints.
To provide behaviors specific to a device, or type of device, wrap one of these Device objects in a class that understands how to perform device-specific operations.
Except for a root hub, or when interrupted by disconnection,
dev.getHub().getChild(dev.getHubPortNum()
is equal to dev
. However, it is good to avoid
assuming that disconnects don't happen; they can be caused just by
surge currents through hubs.
Somewhat related: the best available view of hub parent/child
relationships may not always match physical reality because of an
inherent scheduling lag, and sometimes event reordering, that also
affects USBListener
.
Bus.getDevice(int)
,
USBListener
,
getHub()
,
getChild(int)
, Serialized FormField Summary | |
static int |
DEVICE_REMOTE_WAKEUP
Device status bit used to enable and disable remote wakeup; this feature may be set and cleared. |
static int |
DEVICE_SELFPOWERED
Device status bit that reports the device is self powered. |
Constructor Summary | |
protected |
Device()
Used when deserializing. |
protected |
Device(DeviceSPI spi,
Bus bus,
int address)
Used by implementations of Host and Bus . |
Method Summary | |
void |
control(ControlMessage msg)
Sends a control message to the device, optionally sending or receiving associated data. |
int |
getAddress()
Returns address assigned to this device on its USB Bus . |
Bus |
getBus()
Returns the bus with which the device is associated. |
abstract Device |
getChild(int port)
Returns the device connected to this hub's specified port (origin one), or null. |
abstract Configuration |
getConfiguration()
Returns the current device configuration's descriptor. |
abstract Configuration |
getConfiguration(int index)
Returns the specified configuration descriptor. |
abstract DeviceDescriptor |
getDeviceDescriptor()
Returns the device descriptor. |
abstract Device |
getHub()
Returns the hub to which this device is connected, or null if this device is disconnected or is the root hub for its bus. |
abstract int |
getHubPortNum()
Returns the number of the hub port to which this device is connected. |
abstract int |
getNumPorts()
Returns the number of ports in this hub; or zero. |
java.lang.String |
getPortIdentifier()
Returns port identifier associated with this device. |
abstract java.lang.String |
getSpeed()
Returns the speed of the connection the device is using. |
protected DeviceSPI |
getSPI()
|
java.lang.String |
getString(int id,
int language)
Returns the string index with the specified ID and language, or null if there is no such string. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int DEVICE_SELFPOWERED
public static final int DEVICE_REMOTE_WAKEUP
Constructor Detail |
protected Device()
protected Device(DeviceSPI spi, Bus bus, int address)
Host
and Bus
.Method Detail |
protected DeviceSPI getSPI()
public final Bus getBus()
public final java.lang.String getPortIdentifier()
public final int getAddress()
Bus
.
Addresses are established when the device is connected, get reused
after devices disconnect, and don't correspond to anything that
users can affect. In short, avoid using these.getPortIdentifier()
,
Bus.getDevice(int)
public abstract Device getHub()
public abstract int getHubPortNum()
public abstract java.lang.String getSpeed()
public abstract int getNumPorts()
Hub.getNumPorts()
.public abstract DeviceDescriptor getDeviceDescriptor()
public abstract Configuration getConfiguration() throws java.io.IOException
public abstract Device getChild(int port) throws java.io.IOException
public abstract Configuration getConfiguration(int index) throws java.io.IOException
public java.lang.String getString(int id, int language) throws java.io.IOException
public void control(ControlMessage msg) throws java.io.IOException
USBException
- if exchanging a control message
with an interface or endpoint some other driver has claimed
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |