public class FT_Device extends Object
D2xxManager.getInstance(Context)
to get a copy of D2xxManager first; use
D2xxManager.createDeviceInfoList(Context)
method to scan current connected
FTDI devices, then open target device to get FT_Device instance
via a suitable open API.Constructor and Description |
---|
FT_Device(Context parentContext,
UsbManager usbManager,
UsbDevice dev,
UsbInterface itf)
FT_Device constructor
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes a device opened with a previous call to
D2xxManager.openByIndex(Context, int, com.ftdi.j2xx.D2xxManager.DriverParameters) , D2xxManager.openBySerialNumber(Context, java.lang.String, com.ftdi.j2xx.D2xxManager.DriverParameters) , D2xxManager.openByDescription(Context, java.lang.String, com.ftdi.j2xx.D2xxManager.DriverParameters) or
D2xxManager.openByLocation(Context, int, com.ftdi.j2xx.D2xxManager.DriverParameters) . |
boolean |
clrDtr()
Allows the DTR modem control line to be manually de-asserted.
|
boolean |
clrRts()
Allows the RTS modem control line to be manually de-asserted.
|
boolean |
eepromErase()
Erases the device EEPROM.
|
int |
eepromGetUserAreaSize()
Retrieves the amount of additional space available in the device EEPROM.
|
FT_EEPROM |
eepromRead()
This method reads the entire device EEPROM and decodes its settings in to fields in
a
FT_EEPROM object.
remarks:
FT_EEPROM : For FT_232A , FT_232B.
FT_EEPROM_2232H : For FT_2232H.
FT_EEPROM_2232D : For FT_2232.
FT_EEPROM_4232H : For FT_4232H.
FT_EEPROM_232R : For FT_232R.
FT_EEPROM_245R : For FT_245R.
FT_EEPROM_232H : For FT_232H.
FT_EEPROM_X : For FT_X_Series. |
byte[] |
eepromReadUserArea(int length)
Retrieves the contents of the device EEPROM user area.
|
int |
eepromReadWord(short offset)
This method reads a WORD from the device EEPROM at the specified address.
|
short |
eepromWrite(FT_EEPROM eeData)
This method encodes the settings from a
FT_EEPROM object and writes
them to the device EEPROM.
remarks:
FT_EEPROM : For FT_232A , FT_232B.
FT_EEPROM_2232H : For FT_2232H.
FT_EEPROM_2232D : For FT_2232.
FT_EEPROM_4232H : For FT_4232H.
FT_EEPROM_232R : For FT_232R.
FT_EEPROM_245R : For FT_245R.
FT_EEPROM_232H : For FT_232H.
FT_EEPROM_X : For FT_X_Series. |
int |
eepromWriteUserArea(byte[] data)
Writes data to the device EEPROM user area.
|
boolean |
eepromWriteWord(short address,
short data)
This method writes a WORD to the device EEPROM at the specified address.
|
byte |
getBitMode()
Gets the instantaneous value of the data bus.
Remarks:
For a description of available bit modes for the FT232R, see the application note "Bit Bang Modes for the
FT232R and FT245R".
For a description of available bit modes for the FT2232, see the application note "Bit Mode Functions for
the FT2232".
|
D2xxManager.FtDeviceInfoListNode |
getDeviceInfo()
Retrieves information on the device that is currently open.
|
long |
getEventStatus()
This method retrieves the event status
|
byte |
getLatencyTimer()
This method retrieves the current latency timer value from the device.
|
short |
getLineStatus()
This method retrieves the current modem line status values for the device.
|
short |
getModemStatus()
Retrieves the current modem status values for the device.
|
int |
getQueueStatus()
Retrieves the number of bytes available to read from the driver Rx buffer.
|
boolean |
isOpen()
Returns the open status of the device.
|
boolean |
purge(byte flags)
Discards any data form the specified driver buffer and also flushes data
from the device.
|
int |
read(byte[] data)
This method reads data from the device in to the Java application buffer.
|
int |
read(byte[] data,
int length)
This method reads data from the device in to the Java application buffer.
|
int |
read(byte[] data,
int length,
long wait_ms)
This method reads data from the device in to the Java application buffer.
|
boolean |
readBufferFull()
This method return if the Rx buffer was full with data, if true, Rx would be pending until the data
is read by user.
|
boolean |
resetDevice()
This method sends a vendor command to the device to cause a reset and flush any data
from the device buffers.
|
void |
restartInTask()
Restarts the driver's IN thread following a successful call
to
stopInTask()
Remarks:
This function is used to restart the driver's IN task (read) after it has been stopped by a call to
stopInTask() . |
boolean |
setBaudRate(int baudRate)
This method sends a vendor command to the device to change the baud rate generator
value.
|
boolean |
setBitMode(byte mask,
byte bitMode)
This method allows the device to use alternative interface modes such as bit-bang,
MPSSE and CPU target mode.
|
boolean |
setBreakOff()
This method resets the BREAK condition on the device UART.
|
boolean |
setBreakOn()
This method generates a BREAK condition on the device UART.
|
boolean |
setChars(byte eventChar,
byte eventCharEnable,
byte errorChar,
byte errorCharEnable)
Specifies the event character and error replacement characters for the device
to use.
|
boolean |
setDataCharacteristics(byte dataBits,
byte stopBits,
byte parity)
This method dictates the data format that the device will use.
|
boolean |
setDtr()
Allows the DTR modem control line to be manually asserted.
|
boolean |
setEventNotification(long Mask)
This method specifies events for the java driver to signal that they have occurred.
|
boolean |
setFlowControl(short flowControl,
byte xon,
byte xoff)
Specifies the flow control method that the device should use to prevent data loss.
|
boolean |
setLatencyTimer(byte latency)
This method allows the latency timer value for the device to be specified.
|
boolean |
setRts()
Allows the RTS modem control line to be manually asserted.
|
void |
stopInTask()
This method stops the driver's IN thread and prevents USB IN requests
being issued to the device.
|
boolean |
stoppedInTask()
This method return the running status of starts the driver's IN thread.
|
int |
write(byte[] data)
This method writes data to the device from the Java application buffer.
|
int |
write(byte[] data,
int length)
This method writes data to the device from the Java application buffer.
|
int |
write(byte[] data,
int length,
boolean wait)
This method writes data to the device from the Java application buffer.
|
public FT_Device(Context parentContext, UsbManager usbManager, UsbDevice dev, UsbInterface itf)
public boolean isOpen()
public void close()
D2xxManager.openByIndex(Context, int, com.ftdi.j2xx.D2xxManager.DriverParameters)
, D2xxManager.openBySerialNumber(Context, java.lang.String, com.ftdi.j2xx.D2xxManager.DriverParameters)
, D2xxManager.openByDescription(Context, java.lang.String, com.ftdi.j2xx.D2xxManager.DriverParameters)
or
D2xxManager.openByLocation(Context, int, com.ftdi.j2xx.D2xxManager.DriverParameters)
.public D2xxManager.FtDeviceInfoListNode getDeviceInfo()
D2xxManager.FtDeviceInfoListNode
object containing the information
available for the device. Note that the flags and location
fields are not used by this method.public int read(byte[] data, int length, long wait_ms)
data
- A data buffer containing the bytes read from the device.length
- The number of bytes that the application is requesting
to be read from the device.wait_ms
- A custom wait timeout value in ms.public int read(byte[] data, int length)
data
- A data buffer containing the bytes read from the device.length
- The number of bytes that the application is requesting
to be read from the device.public int read(byte[] data)
data
- A data buffer containing the bytes read from the device.public int write(byte[] data, int length)
data
- A data buffer containing the bytes to write to the device.length
- The number of bytes that the application is requesting
to write to the device.public int write(byte[] data, int length, boolean wait)
data
- A data buffer containing the bytes to write to the device.length
- The number of bytes that the application is requesting
to write to the device.wait
- Should I wait until request sent?public int write(byte[] data)
data
- A data buffer containing the bytes to write to the device.public short getModemStatus()
D2xxManager.FT_CTS
, D2xxManager.FT_DSR
,
D2xxManager.FT_RI
and D2xxManager.FT_DCD
. Negative value for error.public short getLineStatus()
D2xxManager.FT_OE
, D2xxManager.FT_PE
,
D2xxManager.FT_FE
and D2xxManager.FT_BI
. Negative value for error.public int getQueueStatus()
read(byte[], int, long)
requesting up to this number of bytes
will return with the data immediately. Return negative number for
error.public boolean readBufferFull()
public long getEventStatus()
public boolean setBaudRate(int baudRate)
baudRate
- The baud rate value to set for the device. This must be a
value >184 baud. The maximum baud rate for full speed devices
is 3Mbaud, for hi-speed devices it is 12Mbaud.public boolean setDataCharacteristics(byte dataBits, byte stopBits, byte parity)
dataBits
- Valid data bit values are D2xxManager.FT_DATA_BITS_7
or
D2xxManager.FT_DATA_BITS_8
.stopBits
- Valid stop bit values are D2xxManager.FT_STOP_BITS_1
or
D2xxManager.FT_STOP_BITS_2
.parity
- Valid parity values are D2xxManager.FT_PARITY_NONE
, D2xxManager.FT_PARITY_ODD
,
D2xxManager.FT_PARITY_EVEN
, D2xxManager.FT_PARITY_MARK
or
D2xxManager.FT_PARITY_SPACE
.public boolean setBreakOn()
public boolean setBreakOff()
public boolean setFlowControl(short flowControl, byte xon, byte xoff)
flowControl
- Valid flow control values are D2xxManager.FT_FLOW_NONE
, D2xxManager.FT_FLOW_RTS_CTS
,
D2xxManager.FT_FLOW_DTR_DSR
or D2xxManager.FT_FLOW_XON_XOFF
.xon
- Specifies the character to use for XOn if D2xxManager.FT_FLOW_XON_XOFF
is enabled.xoff
- Specifies the character to use for XOff if D2xxManager.FT_FLOW_XON_XOFF
is enabled.public boolean setRts()
public boolean clrRts()
public boolean setDtr()
public boolean clrDtr()
public boolean setChars(byte eventChar, byte eventCharEnable, byte errorChar, byte errorCharEnable)
D2xxManager.FT_OE
, D2xxManager.FT_PE
, D2xxManager.FT_FE
or
D2xxManager.FT_BI
), the error character will be inserted in to the data stream to the
USB host.eventChar
- The character for which the device to trigger an IN.eventCharEnable
- Enable or disable the use of the event character.errorChar
- The character that will be inserted in the data stream
on the detection of an error.errorCharEnable
- Enable or disable the use of the error replacement character.public boolean setBitMode(byte mask, byte bitMode)
mask
- Bit-mask that specifies which pins are input (0) and which
are output (1). Required for bit-bang modes. In the case of
CBUS bit-bang, the upper nibble of this value controls which
pins are inputs and outputs, while the lower nibble controls
which of the outputs are high and low.bitMode
- The desired device mode. This can be one of the following:
D2xxManager.FT_BITMODE_RESET
, D2xxManager.FT_BITMODE_ASYNC_BITBANG
,
D2xxManager.FT_BITMODE_MPSSE
, D2xxManager.FT_BITMODE_SYNC_BITBANG
,
D2xxManager.FT_BITMODE_MCU_HOST
, D2xxManager.FT_BITMODE_FAST_SERIAL
,
D2xxManager.FT_BITMODE_CBUS_BITBANG
or D2xxManager.FT_BITMODE_SYNC_FIFO
.public byte getBitMode()
public boolean resetDevice()
public void stopInTask()
restartInTask()
which sets the IN task running again.public void restartInTask()
stopInTask()
Remarks:
This function is used to restart the driver's IN task (read) after it has been stopped by a call to
stopInTask()
.public boolean stoppedInTask()
public boolean purge(byte flags)
flags
- Specifies the queue to purge. flags is a bit-mask of
D2xxManager.FT_PURGE_RX
and D2xxManager.FT_PURGE_TX
.public boolean setLatencyTimer(byte latency)
latency
- The new value to use for the latency timer. The valid
range for this is 2ms - 255ms.public byte getLatencyTimer()
public boolean setEventNotification(long Mask)
mask
- Specifies the events to wait on. This is a bit-mask of
D2xxManager.FT_EVENT_RXCHAR
, D2xxManager.FT_EVENT_MODEM_STATUS
and D2xxManager.FT_EVENT_LINE_STATUS
.public FT_EEPROM eepromRead()
FT_EEPROM
object.
remarks:
FT_EEPROM
: For FT_232A , FT_232B.
FT_EEPROM_2232H
: For FT_2232H.
FT_EEPROM_2232D
: For FT_2232.
FT_EEPROM_4232H
: For FT_4232H.
FT_EEPROM_232R
: For FT_232R.
FT_EEPROM_245R
: For FT_245R.
FT_EEPROM_232H
: For FT_232H.
FT_EEPROM_X
: For FT_X_Series.FT_EEPROM
object containing the parsed EEPROM
settings for the device. NULL for error. FT_EEPROM can be cast
to a actual device type.public short eepromWrite(FT_EEPROM eeData)
FT_EEPROM
object and writes
them to the device EEPROM.
remarks:
FT_EEPROM
: For FT_232A , FT_232B.
FT_EEPROM_2232H
: For FT_2232H.
FT_EEPROM_2232D
: For FT_2232.
FT_EEPROM_4232H
: For FT_4232H.
FT_EEPROM_232R
: For FT_232R.
FT_EEPROM_245R
: For FT_245R.
FT_EEPROM_232H
: For FT_232H.
FT_EEPROM_X
: For FT_X_Series.eeData
- A FT_EEPROM
object containing the EEPROM
settings to be written to the device. FT_EEPROM can be cast
to a actual device type.public boolean eepromErase()
public int eepromWriteUserArea(byte[] data)
eepromReadUserArea(int)
.data
- The data to be written to the device EEPROM user area. If
the amount of data being written is larger than the available
space in the device EEPROM user area, the data will be
truncated to the user area size.public byte[] eepromReadUserArea(int length)
eepromGetUserAreaSize()
length
- The length of word will be readpublic int eepromGetUserAreaSize()
public int eepromReadWord(short offset)
address
- The EEPROM address to read from.public boolean eepromWriteWord(short address, short data)
address
- The EEPROM address to write the new data to.data
- The data WORD to write to the EEPROM at the address specified.