|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.usb.util.StandardRequest
public class StandardRequest
Utility to easily allow Standard Device Requests.
These methods are defined in the USB 1.1 specification section 9.4. The table 9.4 lists all Standard Requests.
Many of these methods have parameters whose type is short, but should never be passed more than a byte; e.g. all the interface number and endpoint address parameters have a type of short, but interface numbers and endpoint addresses are byte-sized.
Constructor Summary | |
---|---|
StandardRequest(UsbDevice usbDevice)
Constructor. |
Method Summary | |
---|---|
void |
clearFeature(byte recipient,
short featureSelector,
short target)
Clear Feature. |
static void |
clearFeature(UsbDevice usbDevice,
byte recipient,
short featureSelector,
short target)
Clear Feature. |
byte |
getConfiguration()
Get Configuration. |
static byte |
getConfiguration(UsbDevice usbDevice)
Get Configuration. |
int |
getDescriptor(byte type,
byte index,
short langid,
byte[] data)
Get Descriptor. |
static int |
getDescriptor(UsbDevice usbDevice,
byte type,
byte index,
short langid,
byte[] data)
Get Descriptor. |
byte |
getInterface(short interfaceNumber)
Get Interface. |
static byte |
getInterface(UsbDevice usbDevice,
short interfaceNumber)
Get Interface. |
short |
getStatus(byte recipient,
short target)
Get Status. |
static short |
getStatus(UsbDevice usbDevice,
byte recipient,
short target)
Get Status. |
void |
setAddress(short deviceAddress)
Set Address. |
static void |
setAddress(UsbDevice usbDevice,
short deviceAddress)
Set Address. |
void |
setConfiguration(short configurationValue)
Set Configuration. |
static void |
setConfiguration(UsbDevice usbDevice,
short configurationValue)
Set Configuration. |
int |
setDescriptor(byte type,
byte index,
short langid,
byte[] data)
Set Descriptor. |
static int |
setDescriptor(UsbDevice usbDevice,
byte type,
byte index,
short langid,
byte[] data)
Set Descriptor. |
void |
setFeature(byte recipient,
short featureSelector,
short target)
Set Feature. |
static void |
setFeature(UsbDevice usbDevice,
byte recipient,
short featureSelector,
short target)
Set Feature. |
void |
setInterface(short interfaceNumber,
short alternateSetting)
Set Interface. |
static void |
setInterface(UsbDevice usbDevice,
short interfaceNumber,
short alternateSetting)
Set Interface. |
short |
synchFrame(short endpointAddress)
Synch Frame. |
static short |
synchFrame(UsbDevice usbDevice,
short endpointAddress)
Synch Frame. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StandardRequest(UsbDevice usbDevice)
The specified UsbDevice will be used on the instance methods which do not include a UsbDevice parameter. The class methods which do include a UsbDevice parameter will use that UsbDevice.
usbDevice
- The UsbDevice to use.Method Detail |
---|
public void clearFeature(byte recipient, short featureSelector, short target) throws UsbException, java.lang.IllegalArgumentException
This only calls the corresponding class method using the UsbDevice specified in the constructor.
recipient
- The recipient.featureSelector
- The Feature Selector.target
- The target interface number or endpoint address.
UsbException
- If unsuccessful.
java.lang.IllegalArgumentException
- If the recipient or target is invalid.public byte getConfiguration() throws UsbException
This only calls the corresponding class method using the UsbDevice specified in the constructor.
UsbException
- If unsuccessful.public int getDescriptor(byte type, byte index, short langid, byte[] data) throws UsbException
This only calls the corresponding class method using the UsbDevice specified in the constructor.
type
- The Descriptor Type.index
- The Descriptor Index.langid
- The String Descriptor Language ID.data
- The data to fill with the Descriptor.
UsbException
- If unsuccessful.public byte getInterface(short interfaceNumber) throws UsbException
This only calls the corresponding class method using the UsbDevice specified in the constructor.
interfaceNumber
- The interface number.
UsbException
- If unsuccessful.public short getStatus(byte recipient, short target) throws UsbException, java.lang.IllegalArgumentException
This only calls the corresponding class method using the UsbDevice specified in the constructor.
recipient
- The recipient.target
- The target interface number or endpoint address.
UsbException
- If unsuccessful.
java.lang.IllegalArgumentException
- If the recipient or target is invalid.public void setAddress(short deviceAddress) throws UsbException
This only calls the corresponding class method using the UsbDevice specified in the constructor.
deviceAddress
- The new device address.
UsbException
- If unsuccessful.public void setConfiguration(short configurationValue) throws UsbException
This only calls the corresponding class method using the UsbDevice specified in the constructor.
configurationValue
- The new configuration value.
UsbException
- If unsuccessful.public int setDescriptor(byte type, byte index, short langid, byte[] data) throws UsbException
This only calls the corresponding class method using the UsbDevice specified in the constructor.
type
- The Descriptor Type.index
- The Descriptor Index.langid
- The String Descriptor Language ID.data
- The Descriptor.
UsbException
- If unsuccessful.public void setFeature(byte recipient, short featureSelector, short target) throws UsbException, java.lang.IllegalArgumentException
This only calls the corresponding class method using the UsbDevice specified in the constructor.
recipient
- The recipient.featureSelector
- The Feature Selector.target
- The target interface number or endpoint address.
UsbException
- If unsuccessful.
java.lang.IllegalArgumentException
- If the recipient or target is invalid.public void setInterface(short interfaceNumber, short alternateSetting) throws UsbException
This only calls the corresponding class method using the UsbDevice specified in the constructor.
interfaceNumber
- The interface number.alternateSetting
- The alternate setting number.
UsbException
- If unsuccessful.public short synchFrame(short endpointAddress) throws UsbException
This only calls the corresponding class method using the UsbDevice specified in the constructor.
endpointAddress
- The endpoint address.
UsbException
- If unsuccessful.public static void clearFeature(UsbDevice usbDevice, byte recipient, short featureSelector, short target) throws UsbException, java.lang.IllegalArgumentException
Valid recipients are
device
,
interface
, and
endpoint
.
If the recipient is device, the target must be 0. If the recipient is
interface or endpoint, the target is the interface number or endpoint address,
respectively.
usbDevice
- The UsbDevice.recipient
- The recipient.featureSelector
- The Feature Selector.target
- The target interface number or endpoint address.
UsbException
- If unsuccessful.
java.lang.IllegalArgumentException
- If the recipient or target is invalid.public static byte getConfiguration(UsbDevice usbDevice) throws UsbException
usbDevice
- The UsbDevice.
UsbException
- If unsuccessful.public static int getDescriptor(UsbDevice usbDevice, byte type, byte index, short langid, byte[] data) throws UsbException
The parameters correspond to the setup packet:
This method does not restrict the Descriptor type, but
the device is only required to support those Descriptors defined
in the USB 1.1 specification table 9.5, which includes
device
,
configuration
, and
string
descriptor types.
Note that devices normally do not support requests for interface or endpoint
descriptors; the configuration descriptor contains all its interface and endpoint
descriptors.
If the type is string or configuration, the index is used to select the specific descriptor; for other descriptor types is should be 0 (this implementation does not enforce this).
If the type is string, the langid indicates what language to use. For other types it should be 0 (but this is not enforced).
The data is filled with the actual descriptor.
usbDevice
- The UsbDevice.type
- The Descriptor Type.index
- The Descriptor Index.langid
- The String Descriptor Language ID.data
- The data to fill with the Descriptor.
UsbException
- If unsuccessful.public static byte getInterface(UsbDevice usbDevice, short interfaceNumber) throws UsbException
usbDevice
- The UsbDevice.interfaceNumber
- The interface number.
UsbException
- If unsuccessful.public static short getStatus(UsbDevice usbDevice, byte recipient, short target) throws UsbException, java.lang.IllegalArgumentException
Valid recipients are
device
,
interface
, and
endpoint
.
If the recipient is device, the target must be 0. If the recipient is
interface or endpoint, the target is the interface number or endpoint address,
respectively.
usbDevice
- The UsbDevice.recipient
- The recipient.target
- The target interface number or endpoint address.
UsbException
- If unsuccessful.
java.lang.IllegalArgumentException
- If the recipient or target are invalid.public static void setAddress(UsbDevice usbDevice, short deviceAddress) throws UsbException
Since this is normally only used by the low-level Host Controller Driver, this quite likely will either fail or cause serious problems. This should not be used unless you know what you are doing and know that the Operating System's Host Controller Driver can handle this.
usbDevice
- The UsbDevice.deviceAddress
- The new device address.
UsbException
- If unsuccessful.public static void setConfiguration(UsbDevice usbDevice, short configurationValue) throws UsbException
usbDevice
- The UsbDevice.configurationValue
- The new configuration value.
UsbException
- If unsuccessful.public static int setDescriptor(UsbDevice usbDevice, byte type, byte index, short langid, byte[] data) throws UsbException
The parameters correspond to the setup packet:
This method does not restrict the Descriptor type, but
the device is only required to support those Descriptors defined
in the USB 1.1 specification table 9.5, which includes
device
,
configuration
, and
string
descriptor types.
Note that devices normally do not support requests for interface or endpoint
descriptors; the configuration descriptor contains all its interface and endpoint
descriptors.
If the type is string or configuration, the index is used to select the specific descriptor; for other descriptor types is should be 0 (this implementation does not enforce this).
If the type is string, the langid indicates what language to use. For other types it should be 0 (but this is not enforced).
The data should contain the actual Descriptor. The entire length is used, i.e. wLength is set to data.length.
usbDevice
- The UsbDevice.type
- The Descriptor Type.index
- The Descriptor Index.langid
- The String Descriptor Language ID.data
- The Descriptor.
UsbException
- If unsuccessful.public static void setFeature(UsbDevice usbDevice, byte recipient, short featureSelector, short target) throws UsbException, java.lang.IllegalArgumentException
Valid recipients are
device
,
interface
, and
endpoint
.
If the recipient is device, the target is either 0 or the Test Selector.
If the recipient is interface or endpoint, the target is the interface
number or endpoint address, respectively.
usbDevice
- The UsbDevice.recipient
- The recipient.featureSelector
- The Feature Selector.target
- The target interface number or endpoint address.
UsbException
- If unsuccessful.
java.lang.IllegalArgumentException
- If the recipient or target is invalid.public static void setInterface(UsbDevice usbDevice, short interfaceNumber, short alternateSetting) throws UsbException
usbDevice
- The UsbDevice.interfaceNumber
- The interface number.alternateSetting
- The alternate setting number.
UsbException
- If unsuccessful.public static short synchFrame(UsbDevice usbDevice, short endpointAddress) throws UsbException
usbDevice
- The UsbDevice.endpointAddress
- The endpoint address.
UsbException
- If unsuccessful.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |