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.
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public boolean | Returns: If short packects should be accepted.If short packets should be accepted. |
| public int | Returns: The amount of data that was transferred.The amount of data that was transferred. |
| public byte[] | |
| public int | |
| public int | |
| public UsbException | |
| public boolean | |
| public boolean | |
| public void | setAcceptShortPacket(boolean
If short packets should be accepted. accept)Set if short packets should be accepted. |
| public void | setActualLength(int
The amount of data that was transferred. length)Set the amount of data that was transferred. |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | waitUntilComplete(long
The maximum number of milliseconds to wait. timeout)Wait until |
| complete | back to summary |
|---|---|
| public void complete() Set this as complete.
This is the last method the implementation calls; it indicates the UsbIrp has completed.
The implementation will
After calling this | |
| getAcceptShortPacket | back to summary |
|---|---|
| public boolean getAcceptShortPacket() If short packets should be accepted. 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.
| |
| getActualLength | back to summary |
|---|---|
| public int getActualLength() The amount of data that was transferred.
This defaults to 0, and is set by the implementation during/after submission (if successful).
This will never be negative. If
| |
| getData | back to summary |
|---|---|
| public byte[] getData() Get the data. This defaults to an empty byte[]. This will never be null.
| |
| getLength | back to summary |
|---|---|
| public int getLength() The amount of data to transfer. This indicates the amount of data to transfer.
This defaults to 0, and this is set to data.length by
| |
| getOffset | back to summary |
|---|---|
| public int getOffset() Get the starting offset of the data. This indicates the starting byte in the data.
This defaults to 0, and this is set to 0 by
| |
| getUsbException | back to summary |
|---|---|
| public UsbException getUsbException() Get the UsbException. If no UsbException occurred, this returns null.
| |
| isComplete | back to summary |
|---|---|
| public boolean isComplete() If this has completed. This must be false before use.
| |
| isUsbException | back to summary |
|---|---|
| public boolean isUsbException() If a UsbException occured.
If this is true, the
| |
| setAcceptShortPacket | back to summary |
|---|---|
| public void setAcceptShortPacket(boolean accept) Set if short packets should be accepted. This should be set by the application.
| |
| setActualLength | back to summary |
|---|---|
| public void setActualLength(int length) Set the amount of data that was transferred.
The implementation will set this to the amount of data
actually transferred. The implementation will set this
before calling
| |
| setComplete | back to summary |
|---|---|
| public void setComplete(boolean complete) Set this as complete or not.
This is what
| |
| setData | back to summary |
|---|---|
| public void setData(byte[] data) Set the data.
This
| |
| setData | back to summary |
|---|---|
| public void setData(byte[] data, int offset, int length) Set the data. This sets the data, offset, and length to the specified values.
| |
| setLength | back to summary |
|---|---|
| public void setLength(int length) Set the amount of data to transfer.
| |
| setOffset | back to summary |
|---|---|
| public void setOffset(int offset) Set the offset.
| |
| setUsbException | back to summary |
|---|---|
| public void setUsbException(UsbException usbException) Set the UsbException.
| |
| waitUntilComplete | back to summary |
|---|---|
| public void waitUntilComplete() Wait until
This will block until this is | |
| waitUntilComplete | back to summary |
|---|---|
| public void waitUntilComplete(long timeout) Wait until
This will block until this is
| |