|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--usb.core.Device | +--usb.windows.DeviceImpl
Provides access to a USB device. To use a device, first make sure that you can use the selected configuration. (Don't use the change-configuration functionality yet.)
Fields inherited from class usb.core.Device |
DEVICE_REMOTE_WAKEUP, DEVICE_SELFPOWERED |
Method Summary | |
void |
claimInterface(int ifno)
Claims this interface, so that no other driver can. |
int |
clearHalt(byte ep)
Clears halt/stall status on an endpoint. |
int |
cyclePort()
|
boolean |
cyclePortWorks()
|
protected void |
finalize()
Releases any unreleased system resources. |
Device |
getChild(int port)
Returns children of a hub device. |
java.lang.String |
getClaimer(int ifno)
Returns a system-specific string providing information about the driver claiming this interface, or null. |
byte[] |
getConfigBuf(int n)
Returns a buffer holding the entire set of configuration descriptors for the specified configuration. |
Configuration |
getConfiguration()
Returns the current device configuration's descriptor. |
Configuration |
getConfiguration(int index)
Returns the specified configuration. |
DeviceDescriptor |
getDeviceDescriptor()
Returns the device descriptor. |
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. |
int |
getHubPortNum()
Returns the number of the hub port to which this device is connected. |
int[] |
getLanguages()
|
int |
getNumPorts()
Returns the number of ports in this hub; or zero. |
java.lang.String |
getPath()
Returns the filesystem name for this file. |
java.lang.String |
getSpeed()
Returns the speed of the connection the device is using. |
java.lang.String |
getString(int id)
Returns the string indexed with the specified ID in the default language, or null if there is no such string. |
java.lang.String |
getString(int id,
int language)
Implementation of Device.getString
which can cache strings in the device's default language. |
int |
readBulk(int ep,
byte[] buf,
int off,
int length)
|
byte[] |
readBulk(int ep,
int length)
Assigns the specified configuration as current. |
byte[] |
readControl(byte type,
byte request,
short value,
short index,
short length)
Issues a control IN request with an optional data READ phase. |
byte[] |
readIntr(int ep,
int length)
Reads a specified number of bytes from a INTERRUPT IN endpoint. |
void |
releaseInterface(int ifno)
Releases an interface claim. |
void |
setConfiguration(int index)
Deprecated. Consider this dangerous. |
void |
setInterface(int ifno,
int alt)
Assigns an interface to an alternate setting. |
java.lang.String |
toString()
|
void |
writeBulk(int ep,
byte[] buf)
Writes a specified number of bytes to a BULK OUT endpoint. |
void |
writeBulk(int ep,
byte[] buf,
int off,
int length)
|
void |
writeControl(byte type,
byte request,
short value,
short index,
byte[] buf)
Issues a control OUT request with an optional data WRITE phase. |
void |
writeIntr(int ep,
byte[] buf)
Writes a specified number of bytes to a INTERRUPT OUT endpoint. |
Methods inherited from class usb.core.Device |
control, getAddress, getBus, getPortIdentifier, getSPI |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
public java.lang.String toString()
toString
in class java.lang.Object
protected void finalize() throws usb.windows.USBException
finalize
in class java.lang.Object
public Device getHub()
Device
getHub
in class Device
public int getHubPortNum()
Device
getHubPortNum
in class Device
public java.lang.String getSpeed()
Device
getSpeed
in class Device
public int getNumPorts()
Device
Hub.getNumPorts()
.getNumPorts
in class Device
public DeviceDescriptor getDeviceDescriptor()
Device
getDeviceDescriptor
in class Device
public Configuration getConfiguration() throws java.io.IOException
Device
getConfiguration
in class Device
public Device getChild(int port)
DeviceSPI
getChild
in interface DeviceSPI
getChild
in class Device
usb.core.DeviceSPI
port
- Number of the hub port of interest, from one to the
Hub.getNumPorts()
.public java.lang.String getPath()
public java.lang.String getString(int id) throws java.io.IOException
The default language is the one that is being cached. If this is the first request, then the language of the default locale is used if it is supported, else the first supported language is chosen as a fallback.
public java.lang.String getString(int id, int language) throws java.io.IOException
Device.getString
which can cache strings in the device's default language.getString
in class Device
public int[] getLanguages() throws java.io.IOException
public Configuration getConfiguration(int index) throws java.io.IOException
getConfiguration
in class Device
public void setConfiguration(int index) throws usb.windows.USBException
public byte[] readControl(byte type, byte request, short value, short index, short length) throws java.io.IOException
DeviceSPI
Most of the parameters here are used to build the SETUP packet for the control request, which is always written to the device. Note an OUT control request with only a setup packet is different from the IN request with the same bits in the setup packet data; it goes to a different endpoint.
readControl
in interface DeviceSPI
usb.core.DeviceSPI
type
- Masked together using three constants from
ControlMessage
: DIR_TO_HOST, a TYPE_*, and a RECIP_*.request
- bRequest field, either standard (from table 9-3 in
the USB 2.0 specification) for TYPE_STANDARD, or else as specified
in the class or vendor device type specification.value
- sixteen bit field associated with requestindex
- sixteen bit field associated with requestlength
- How much data should be read; may be zero to indicate
that no READ phase follows the SETUP packet.public void writeControl(byte type, byte request, short value, short index, byte[] buf) throws java.io.IOException
DeviceSPI
Most of the parameters here are used to build the SETUP packet for the control request, which is always written to the device. Note an OUT control request with only a setup packet is different from the IN request with the same bits in the setup packet data; it goes to a different endpoint.
writeControl
in interface DeviceSPI
usb.core.DeviceSPI
type
- Masked together using three constants from
ControlMessage
: DIR_TO_DEVICE, a TYPE_*, and a RECIP_*.request
- bRequest field, either standard (from table 9-3 in
the USB 2.0 specification) for TYPE_STANDARD, or else as specified
in the class or vendor device type specification.value
- sixteen bit field associated with requestindex
- sixteen bit field associated with requestbuf
- The data to be written. Length may be zero to indicate
that no WRITe phase follows the SETUP packet.public byte[] getConfigBuf(int n) throws java.io.IOException
DeviceSPI
getConfigBuf
in interface DeviceSPI
usb.core.DeviceSPI
config
- Number of the configuration, from zero to the limit
specified by DeviceDescriptor.getNumConfigurations()
public boolean cyclePortWorks()
public int cyclePort()
public byte[] readBulk(int ep, int length) throws java.io.IOException
readBulk
in interface DeviceSPI
usb.core.DeviceSPI
ep
- Endpoint direction and address, as specified in an
endpoint descriptor by Endpoint.getEndpoint()
.length
- How many bytes to read.public int readBulk(int ep, byte[] buf, int off, int length)
public void writeBulk(int ep, byte[] buf) throws usb.windows.USBException
DeviceSPI
Endpoint.getMaxPacketSize()
then the last packet is "short". To write such an exact multiple
with a "short" last packet, explicitly follow this write by another,
using a buffer with length zero.
An endpoint's interface should be claimed before it is used for bulk I/O.
writeBulk
in interface DeviceSPI
usb.core.DeviceSPI
ep
- Endpoint direction and address, as specified in an
endpoint descriptor by Endpoint.getEndpoint()
.buf
- The bytes to write.public void writeBulk(int ep, byte[] buf, int off, int length) throws usb.windows.USBException
public byte[] readIntr(int ep, int length)
DeviceSPI
This blocks until an interrupt transfer completes. It's the
caller's responsibility to ensure that the endpoint is polled
often enough to meet Endpoint.getInterval()
requirements
after a transfer completes.
An endpoint's interface should be claimed before it is used for interrupt I/O.
readIntr
in interface DeviceSPI
usb.core.DeviceSPI
ep
- Endpoint direction and address, as specified in an
endpoint descriptor by Endpoint.getEndpoint()
.length
- How many bytes to read.public void writeIntr(int ep, byte[] buf) throws usb.windows.USBException
DeviceSPI
Endpoint.getMaxPacketSize()
then the last packet is "short". To write such an exact multiple
with a "short" last packet, explicitly follow this write with a
write of a buffer with length zero.
This blocks until an interrupt transfer completes. It's the
caller's responsibility to ensure that the endpoint is polled
often enough to meet Endpoint.getInterval()
requirements
after a transfer completes.
An endpoint's interface should be claimed before it is used for interrupt I/O.
writeIntr
in interface DeviceSPI
usb.core.DeviceSPI
ep
- Endpoint direction and address, as specified in an
endpoint descriptor by Endpoint.getEndpoint()
.buf
- The bytes to write.public int clearHalt(byte ep)
DeviceSPI
The endpoint's interface should be claimed before clearing its halt status.
clearHalt
in interface DeviceSPI
usb.core.DeviceSPI
ep
- Endpoint address and direction, as returned by
Endpoint.getEndpoint()
.public void claimInterface(int ifno) throws java.io.IOException
claimInterface
in interface DeviceSPI
usb.core.DeviceSPI
ifnum
- Number from the descriptor, returned by
Interface.getNumber()
.DeviceSPI.releaseInterface(int)
public void releaseInterface(int ifno) throws java.io.IOException
releaseInterface
in interface DeviceSPI
usb.core.DeviceSPI
ifnum
- Number from the descriptor, returned by
Interface.getNumber()
.DeviceSPI.claimInterface(int)
public void setInterface(int ifno, int alt) throws java.io.IOException
setInterface
in interface DeviceSPI
usb.core.DeviceSPI
ifnum
- Number from the descriptor, returned by
Interface.getNumber()
.alt
- Number from the descriptor, returned by
Interface.getAlternateSetting()
.public java.lang.String getClaimer(int ifno)
getClaimer
in interface DeviceSPI
usb.core.DeviceSPI
ifnum
- Number from the descriptor, returned by
Interface.getNumber()
.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |