public class ZtexUsbWriter
extends java.lang.Object
Constructor and Description |
---|
ZtexUsbWriter(org.usb4java.DeviceHandle p_handle,
int p_ep,
boolean p_isInt,
int p_bufNum,
int p_bufSize)
Creates the writer for a given USB device and endpoint number.
|
ZtexUsbWriter(Ztex1 ztex,
int p_ep,
boolean p_isInt,
int p_bufNum,
int p_bufSize)
Creates the writer from a given ZTEX device and endpoint number.
|
ZtexUsbWriter(Ztex1v1 ztex,
int p_bufNum,
int p_bufSize)
Creates the writer for the input endpoint of the default interface of a ZTEX device.
|
Modifier and Type | Method and Description |
---|---|
int |
bufSize()
Return the buffer size.
|
long |
byteCount()
Return the number of bytes transmitted.
|
void |
cancel()
Cancels all pending transfers, also see
cancelWait(int) . |
boolean |
cancelWait(int timeout)
Cancels all pending transfers and waits until transfers are canceled.
|
int |
transmitBuffer(byte[] buf,
int timeout)
Transmit the next buffer.
|
int |
transmitBuffer(byte[] buf,
int maxLen,
int timeout)
Transmit the next buffer.
|
boolean |
wait(int timeout)
Waits until all pending transfers are finished or canceled.
|
public ZtexUsbWriter(org.usb4java.DeviceHandle p_handle, int p_ep, boolean p_isInt, int p_bufNum, int p_bufSize)
p_handle
- The device handle used for communication (must be opened).p_ep
- The input endpoint.p_isInt
- True if it is an interrupt transfer.p_bufSize
- size of each buffer. Typical values are 64KByte to 512KBytep_bufNum
- number of buffer. Recommended queue size are 2MByte to 8MByte.public ZtexUsbWriter(Ztex1 ztex, int p_ep, boolean p_isInt, int p_bufNum, int p_bufSize)
ztex
- The ZTEX device.p_ep
- The number of the input endpointp_isInt
- True if it is an interrupt transfer.p_bufSize
- size of each buffer. Typical values are 64KByte to 512KBytep_bufNum
- number of buffer. Recommended queue size is 2MByte to 8MByte.public ZtexUsbWriter(Ztex1v1 ztex, int p_bufNum, int p_bufSize) throws InvalidFirmwareException, UsbException, CapabilityException
ztex
- The ZTEX device.p_bufSize
- size of each buffer. Typical values are 64KByte to 512KBytep_bufNum
- number of buffer. Recommended queue size is 2MByte to 8MByte.InvalidFirmwareException
- if interface 1 is not supported.CapabilityException
- if default interface if not present or version number is lower than requiredUsbException
- if an error occurred while attempting to read default interface information.public int transmitBuffer(byte[] buf, int maxLen, int timeout) throws UsbException
buf
- The byte array which contains the data.maxLen
- Maximum amount of data to transmit. If it is larger than the buffer size the last bytes are ignored.timeout
- Timeout in ms. If timeout occurs the function returns -1.UsbException
- if an error occurred.public int transmitBuffer(byte[] buf, int timeout) throws UsbException
buf
- The byte array which contains the data. If the array is larger than the buffer size the last bytes are ignored.timeout
- Timeout in ms. If timeout occurs the function returns -1.UsbException
- if an error occurred.public long byteCount()
public int bufSize()
public void cancel() throws UsbException
cancelWait(int)
.UsbException
- if an error occurred.public boolean wait(int timeout) throws UsbException
timeout
- Timeout in msUsbException
- if an error occurred.public boolean cancelWait(int timeout) throws UsbException
timeout
- Timeout in msUsbException
- if an error occurred.