org.lsst.ccs.drivers.ftdi
Class FtdiClient

java.lang.Object
  extended by org.lsst.ccs.drivers.ftdi.FtdiClient
All Implemented Interfaces:
FtdiInterface

public class FtdiClient
extends Object
implements FtdiInterface

Remotely accesses a device which uses the FTDI chip.

Author:
Owen Saxton

Constructor Summary
FtdiClient()
           
 
Method Summary
 void close()
          Closes the device.
 int getModemStatus()
          Gets the modem status.
 int getQueueStatus()
          Gets the read queue status.
 void open(int index, String serial)
          Opens a local device.
 void open(String node, int index, String serial)
          Opens a remote device.
 int read(byte[] data)
          Reads data.
 int read(byte[] data, int offset, int count)
          Reads data.
 void setBaudrate(int baudrate)
          Sets the baud rate.
 void setDataCharacteristics(int wordLength, int stopBits, int parity)
          Sets the data characteristics.
 void setTimeouts(int rcveTimeout, int xmitTimeout)
          Sets the timeouts.
 int write(byte[] data)
          Writes data.
 int write(byte[] data, int offset, int count)
          Writes data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FtdiClient

public FtdiClient()
Method Detail

open

public void open(int index,
                 String serial)
          throws FtdiException
Opens a local device. This is an invalid operation.

Specified by:
open in interface FtdiInterface
Parameters:
index - The zero-based index of the FTDI device within the list selected by the serial argument.
serial - A string which, if non-null and non-empty, restricts the list of available devices to those with a serial number containing this string.
Throws:
FtdiException

open

public void open(String node,
                 int index,
                 String serial)
          throws FtdiException
Opens a remote device.

Specified by:
open in interface FtdiInterface
Parameters:
node - The name of the node where the device is located.
index - The zero-based index of the FTDI device within the list selected by the serial argument.
serial - A string which, if non-null and non-empty, restricts the list of available devices to those with a serial number containing this string.
Throws:
FtdiException

close

public void close()
           throws FtdiException
Closes the device.

Specified by:
close in interface FtdiInterface
Throws:
FtdiException

setBaudrate

public void setBaudrate(int baudrate)
                 throws FtdiException
Sets the baud rate.

Specified by:
setBaudrate in interface FtdiInterface
Parameters:
baudrate - The baud rate ro set
Throws:
FtdiException

setDataCharacteristics

public void setDataCharacteristics(int wordLength,
                                   int stopBits,
                                   int parity)
                            throws FtdiException
Sets the data characteristics.

Specified by:
setDataCharacteristics in interface FtdiInterface
Parameters:
wordLength - The encoded word length to set
stopBits - The encoded number of stop bits to set
parity - The encoded parity value to set
Throws:
FtdiException

setTimeouts

public void setTimeouts(int rcveTimeout,
                        int xmitTimeout)
                 throws FtdiException
Sets the timeouts.

Specified by:
setTimeouts in interface FtdiInterface
Parameters:
rcveTimeout - The receive timeout to set (ms)
xmitTimeout - The transmit timeout to set (ms)
Throws:
FtdiException

read

public int read(byte[] data)
         throws FtdiException
Reads data. Execution is blocked until either the byte array is filled, or a timeout occurs. In the latter case the number of bytes read will be less than the array size.

Specified by:
read in interface FtdiInterface
Parameters:
data - A byte array to receive the read data.
Returns:
The number of bytes read.
Throws:
FtdiException

read

public int read(byte[] data,
                int offset,
                int count)
         throws FtdiException
Reads data. Execution is blocked until either the requested number of bytes has been read, or a timeout occurs. In the latter case the number of bytes read will be less than the requested number.

Specified by:
read in interface FtdiInterface
Parameters:
data - A byte array to receive the read data
offset - The offset in the array to the start of the data
count - The maximum number of bytes to read
Returns:
The number of bytes read
Throws:
FtdiException

write

public int write(byte[] data)
          throws FtdiException
Writes data.

Specified by:
write in interface FtdiInterface
Parameters:
data - A byte array containing the data to write.
Returns:
The number of bytes written.
Throws:
FtdiException

write

public int write(byte[] data,
                 int offset,
                 int count)
          throws FtdiException
Writes data.

Specified by:
write in interface FtdiInterface
Parameters:
data - A byte array containing the data to write
offset - The offset in the array to the start of the data
count - The number of bytes to write
Returns:
The number of bytes written
Throws:
FtdiException

getQueueStatus

public int getQueueStatus()
                   throws FtdiException
Gets the read queue status. This is the number of bytes available for immediate read

Specified by:
getQueueStatus in interface FtdiInterface
Returns:
The number of bytes in the read queue
Throws:
FtdiException

getModemStatus

public int getModemStatus()
                   throws FtdiException
Gets the modem status.

Specified by:
getModemStatus in interface FtdiInterface
Returns:
The modem status as a set of bits
Throws:
FtdiException


Copyright © 2013 LSST. All Rights Reserved.