Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/com/ftdi/FTDevice.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class FTDevice {
private final String devSerialNumber, devDescription;
private FTDeviceInputStream fTDeviceInputStream = null;
private FTDeviceOutputStream fTDeviceOutputStream = null;
private boolean open = false;

private FTDevice(DeviceType devType, int devID, int devLocationID,
String devSerialNumber, String devDescription, int ftHandle,
Expand All @@ -59,6 +60,7 @@ private FTDevice(DeviceType devType, int devID, int devLocationID,
this.devDescription = devDescription;
this.ftHandle = ftHandle;
this.flag = flag;
this.open = false;
}

/**
Expand Down Expand Up @@ -304,13 +306,16 @@ public void open() throws FTD2XXException {
ensureFTStatus(ftd2xx.FT_OpenEx(memory, FTD2XX.FT_OPEN_BY_SERIAL_NUMBER,
handle));
this.ftHandle = handle.getValue();
open = true;
}

/**
* Close connection with device.
* @throws FTD2XXException If something goes wrong.
*/
public void close() throws FTD2XXException {
if (!open) return;
open = false;
ensureFTStatus(ftd2xx.FT_Close(ftHandle));
}

Expand Down Expand Up @@ -451,14 +456,14 @@ public void resetDevice() throws FTD2XXException {
/**
* Set the latency timer value.
* @param timer Latency timer value in milliseconds.
* Valid range is 2 255.
* Valid range is 2 - 255.
* @throws FTD2XXException If something goes wrong.
* @throws IllegalArgumentException If timer was not in range 2 - 255.
*/
public void setLatencyTimer(short timer) throws FTD2XXException,
IllegalArgumentException {
if (!((timer > 2) && (timer < 255))) {
throw new IllegalArgumentException("Valid range is 2 255!");
throw new IllegalArgumentException("Valid range is 2 - 255!");
}
ensureFTStatus(ftd2xx.FT_SetLatencyTimer(ftHandle, (byte) timer));
}
Expand Down