|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface UsbIrp
Interface for a USB IRP (I/O Request Packet).
Some USB communication requires addiitonal metadata that describes how the actual data should be handled when being transferred. This UsbIrp encapsulates the actual data buffer, as well as other metadata that gives the user more control and knowledge over how the data is handled.
Before submitting this, at least some of these (depending on UsbIrp implementation) must be performed:
data
must be set
.data offset
, may be set
.data length
may be set
.Short Packet policy
may be set
.UsbException
must be null (and isUsbException
must be false).complete state
must be false.setData
also sets the offset to 0 and the length to data.length; if other
values should be used, use the 3-parameter setData
or set the
offset
and length
with their setters after setting
the data.
The javax.usb implementation will set the data length
or, if unsuccessful, the
UsbException
, after processing. Finally, it will call complete
.
See the USB 1.1 specification section 5.3.2 for details on USB IRPs. The IRP defined in this API has more than is mentioned in the USB 1.1 specification.
Method Summary | |
---|---|
void |
complete()
Set this as complete. |
boolean |
getAcceptShortPacket()
If short packets should be accepted. |
int |
getActualLength()
The amount of data that was transferred. |
byte[] |
getData()
Get the data. |
int |
getLength()
The amount of data to transfer. |
int |
getOffset()
Get the starting offset of the data. |
UsbException |
getUsbException()
Get the UsbException. |
boolean |
isComplete()
If this has completed. |
boolean |
isUsbException()
If a UsbException occured. |
void |
setAcceptShortPacket(boolean accept)
Set if short packets should be accepted. |
void |
setActualLength(int length)
Set the amount of data that was transferred. |
void |
setComplete(boolean complete)
Set this as complete or not. |
void |
setData(byte[] data)
Set the data. |
void |
setData(byte[] data,
int offset,
int length)
Set the data. |
void |
setLength(int length)
Set the amount of data to transfer. |
void |
setOffset(int offset)
Set the offset. |
void |
setUsbException(UsbException usbException)
Set the UsbException. |
void |
waitUntilComplete()
Wait until complete . |
void |
waitUntilComplete(long timeout)
Wait until complete , or the timeout has expired. |
Method Detail |
---|
byte[] getData()
This defaults to an empty byte[]. This will never be null.
int getOffset()
This indicates the starting byte in the data.
This defaults to 0, and this is set to 0 by the 1-parameter setData
.
This will never be negative.
int getLength()
This indicates the amount of data to transfer.
This defaults to 0, and this is set to data.length by the 1-parameter setData
.
This will never be negative.
int getActualLength()
This defaults to 0, and is set by the implementation during/after submission (if successful).
This will never be negative. If isUsbException
is true,
this value is undefined.
void setData(byte[] data)
This sets the offset
to 0,
and sets the length
to data.length;
if those values are inappropriate, use the
other setData
.
data
- The data.
java.lang.IllegalArgumentException
- If the data is null.void setData(byte[] data, int offset, int length)
This sets the data, offset, and length to the specified values.
data
- The data.offset
- The offset.length
- The length.
java.lang.IllegalArgumentException
- If the data is null, or offset and/or length is negative.void setOffset(int offset)
offset
- The offset.
java.lang.IllegalArgumentException
- If the offset is negative.void setLength(int length)
length
- The amount of data to transfer.
java.lang.IllegalArgumentException
- If the length is negative.void setActualLength(int length)
The implementation will set this to the amount of data
actually transferred. The implementation will set this
before calling complete
, regardless of
whether the submission was successful or not.
length
- The amount of data that was transferred.
java.lang.IllegalArgumentException
- If the length is negative.boolean isUsbException()
If this is true, the actual length
is undefined.
UsbException getUsbException()
If no UsbException occurred, this returns null.
void setUsbException(UsbException usbException)
usbException
- The UsbException.boolean getAcceptShortPacket()
See the USB 1.1 specification sec 5.3.2 for details on short packets and short packet detection. If short packets are accepted (true), a short packet indicates the end of data. If short packets are not accepted (false), a short packet will generate an UsbException. The default is true.
void setAcceptShortPacket(boolean accept)
This should be set by the application.
accept
- If short packets should be accepted.boolean isComplete()
This must be false before use.
void setComplete(boolean complete)
This is what isComplete
returns.
complete
- If this is complete or not.void complete()
This is the last method the implementation calls; it indicates the UsbIrp has completed.
The implementation will set the actual length
,
even if the submission was unsuccessful, before calling this.
The implementation will set the UsbException
,
if appropriate, before calling this.
After calling this isComplete
will return true.
void waitUntilComplete()
complete
.
This will block until this is complete
.
void waitUntilComplete(long timeout)
complete
, or the timeout has expired.
This will block until this is complete
,
or the timeout has expired. The timeout is ignored if it is
0 or less, i.e. this will behave as the no-timeout method
.
timeout
- The maximum number of milliseconds to wait.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |