public class ZtexUsbReader
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
int |
usbTimeOut |
Constructor and Description |
---|
ZtexUsbReader(org.usb4java.DeviceHandle p_handle,
int p_ep,
boolean p_isInt,
int p_bufNum,
int p_bufSize)
Creates the reader for a given USB device and endpoint number.
|
ZtexUsbReader(Ztex1 ztex,
int p_ep,
boolean p_isInt,
int p_bufNum,
int p_bufSize)
Creates the reader from a given ZTEX device and endpoint number.
|
ZtexUsbReader(Ztex1v1 ztex,
int p_bufNum,
int p_bufSize)
Creates the reader 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 read since last
start(long) . |
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 |
getBuffer(byte[] buf,
int timeout)
Get the next buffer.
|
void |
start(long maxCount)
Start the reader.
|
int |
transferStatus()
Return status of current transfer (see LibUsb.TRANSFER_*), -1 if transfer is pending or -2 if transfer has not been started.
|
public ZtexUsbReader(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 buffers. Recommended queue size is 2MByte to 8MByte.public ZtexUsbReader(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 ZtexUsbReader(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 a communication error occurred.public int getBuffer(byte[] buf, int timeout) throws UsbException
start(long)
.buf
- The byte array where to store the data.timeout
- Timeout in ms. If timeout occurs the function returns -1.UsbException
- if an error occurred.public int transferStatus()
public long byteCount()
start(long)
.start(long)
.public int bufSize()
public void cancel() throws UsbException
cancelWait(int)
,UsbException
- if an error occurred.public boolean cancelWait(int timeout) throws UsbException
timeout
- Timeout in msUsbException
- if an error occurred.public void start(long maxCount) throws UsbException
maxCount
- Maximum amount of bytes to read or 0 for infinite transfers or <0 for speed test mode.UsbException
- if an error occurred.