com.adventnet.cli.serial
Class SerialCommOptionsImpl

java.lang.Object
  |
  +--com.adventnet.cli.serial.SerialCommOptionsImpl

public class SerialCommOptionsImpl
extends java.lang.Object
implements CLIProtocolOptions

This class provides the Serial Port options implementation of the CLIProtocolOptions Interface. It contains parameters like the Baud rate, Parity, stop bits, etc. In order to establish a CLI session over Serial Port with a particular device the appropriate parameters has to be set on an instance of this class and passed to the CLISession's constructor. A subsequent call to the open() method in CLISession will establish the Serial connection based on the parameters set here.


Field Summary
static int DATABITS_5
          5 bit Data Format
static int DATABITS_6
          6 bit Data Format
static int DATABITS_7
          7 bit Data Format
static int DATABITS_8
          8 bit Data Format
static int FLOWCONTROL_NONE
          No flow Control
static int FLOWCONTROL_RTSCTS_IN
          Hardware RTS/CTS flow Control on Input
static int FLOWCONTROL_RTSCTS_OUT
          Hardware RTS/CTS flow Control on Output
static int FLOWCONTROL_XONXOFF_IN
          Software (XON/XOFF) flow Control on Input
static int FLOWCONTROL_XONXOFF_OUT
          Software (XON/XOFF) flow Control on Output
static int PARITY_EVEN
          Even Parity
static int PARITY_MARK
          Mark Parity
static int PARITY_NONE
          No Parity
static int PARITY_ODD
          Odd Parity
static int PARITY_SPACE
          Space Parity
static int STOPBITS_1
          1 Stop Bit
static int STOPBITS_1_5
          1/2 Stop Bit
static int STOPBITS_2
          2 Stop Bit
 
Constructor Summary
SerialCommOptionsImpl()
          This default constructor can be used for setting Serial port parameters for opening a CLISession.
 
Method Summary
 java.lang.Object clone()
          Performs a clone of this object.
 int getBaudRate()
          Gets the baud rate configured for the data transfer.
 int getDataBits()
          Gets the number of data bits used.
 int getFlowControlMode()
          Gets the flow control mode set.
 java.lang.Object getID()
          This is used to generate a unique id based on a particular connection.
 java.lang.String getInitialMessage()
          Gets the initial message sent by the device after a connection is established.
 int getParity()
          Gets the parity.
 java.lang.String getPortId()
          Gets the PortId value
 java.util.Properties getProperties()
          Gets the list of properties on this CLIProperty instance.
 int getStopBits()
          Gets the no of Stop bits.
 void setBaudRate(int brate)
          Sets the baud rate for the data transfer.
 void setDataBits(int dataBits)
          Sets the no of data bits for each byte.
 void setFlowControlMode(int flowcontrol)
          Sets the flow control mode.
 void setInitialMessage(java.lang.String message)
          Sets the initial message sent by the device after a connection is established.
 void setParity(int parity)
          Sets the parity type.
 void setPortId(java.lang.String portId)
          Sets the PortId which identifies a particular serial port through which the communication has to be established.
 void setProperties(java.util.Properties properties)
          Sets a list of properties on this CLIProperty instance.
 void setSerialCommParameters(int baudRate, int dataBits, int stopBits, int parity)
          Sets the various Communication parameters.
 void setStopBits(int stopBits)
          Sets the no of Stop bits.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATABITS_5

public static final int DATABITS_5
5 bit Data Format

DATABITS_6

public static final int DATABITS_6
6 bit Data Format

DATABITS_7

public static final int DATABITS_7
7 bit Data Format

DATABITS_8

public static final int DATABITS_8
8 bit Data Format

STOPBITS_1

public static final int STOPBITS_1
1 Stop Bit

STOPBITS_2

public static final int STOPBITS_2
2 Stop Bit

STOPBITS_1_5

public static final int STOPBITS_1_5
1/2 Stop Bit

FLOWCONTROL_NONE

public static final int FLOWCONTROL_NONE
No flow Control

FLOWCONTROL_RTSCTS_IN

public static final int FLOWCONTROL_RTSCTS_IN
Hardware RTS/CTS flow Control on Input

FLOWCONTROL_RTSCTS_OUT

public static final int FLOWCONTROL_RTSCTS_OUT
Hardware RTS/CTS flow Control on Output

FLOWCONTROL_XONXOFF_IN

public static final int FLOWCONTROL_XONXOFF_IN
Software (XON/XOFF) flow Control on Input

FLOWCONTROL_XONXOFF_OUT

public static final int FLOWCONTROL_XONXOFF_OUT
Software (XON/XOFF) flow Control on Output

PARITY_NONE

public static final int PARITY_NONE
No Parity

PARITY_ODD

public static final int PARITY_ODD
Odd Parity

PARITY_EVEN

public static final int PARITY_EVEN
Even Parity

PARITY_MARK

public static final int PARITY_MARK
Mark Parity

PARITY_SPACE

public static final int PARITY_SPACE
Space Parity
Constructor Detail

SerialCommOptionsImpl

public SerialCommOptionsImpl()
This default constructor can be used for setting Serial port parameters for opening a CLISession. The various parameters that can be set on the class are the Port id, baud rate, parity and others. The following code snippet shows how to set the various paramters:

 SerialCommOptionsImpl sopt = new SerialCommOptionsImpl();
 sopt.setPortId("COM1"); // set the port id
 sopt.setBaudRate(19200); // set the baud rate
 sopt.setStopBits(SerialCommOptionsImpl.STOPBITS_1); //set the stop bits
 sopt.setDataBits(DATABITS_7); // set the no of data bits
 
This will create a SerialCommOptionsImpl class with the baud rate at 19200, with 1 stop bit and a data bits size of 7. This can be passed to the CLISession.open(CLIProtocolOptions) method to open a connection through the COM1 serial port with the above parameters.
Method Detail

setPortId

public void setPortId(java.lang.String portId)
Sets the PortId which identifies a particular serial port through which the communication has to be established. For windows this could be COM1, COM1 etc and for Unix systems it would be /dev/ttyS0, /dev/ttyS1 etc.
Parameters:
portId - The String protId value

getPortId

public java.lang.String getPortId()
Gets the PortId value
Returns:
the portId as a String

setBaudRate

public void setBaudRate(int brate)
Sets the baud rate for the data transfer. The default is 9600 bauds.
Parameters:
brate - the baudrate

getBaudRate

public int getBaudRate()
Gets the baud rate configured for the data transfer.
Returns:
the Baud Rate

setStopBits

public void setStopBits(int stopBits)
Sets the no of Stop bits. The default value is 1.
Parameters:
stopBits - the no of Stop bits.

getStopBits

public int getStopBits()
Gets the no of Stop bits.
Returns:
the no of stop bits.

setFlowControlMode

public void setFlowControlMode(int flowcontrol)
Sets the flow control mode. The default flow control is FLOWCONTROL_NONE.
Parameters:
flowcontrol - the flow control mode.

getFlowControlMode

public int getFlowControlMode()
Gets the flow control mode set.
Returns:
the flow control mode as one of the integer contstants defined.

setParity

public void setParity(int parity)
Sets the parity type. The Default is PARITY_NONE.
Parameters:
parity - the parity type.

getParity

public int getParity()
Gets the parity.
Returns:
the parity as one of the constants defined.

setDataBits

public void setDataBits(int dataBits)
Sets the no of data bits for each byte. The default is DATABITS_8 i.e 8 data bits.
Parameters:
dataBits - the number of data bits.

getDataBits

public int getDataBits()
Gets the number of data bits used.
Returns:
the number of data bits.

setSerialCommParameters

public void setSerialCommParameters(int baudRate,
                                    int dataBits,
                                    int stopBits,
                                    int parity)
Sets the various Communication parameters. The parameters that can be set using this method are the Baud rate, the no of Data bits, the no of Stop bits and parity.
Parameters:
baudRate - the baud rate
dataBits - the number of data bits to be used
stopBits - the number of stop bits to be used
parity - the parity type

getID

public java.lang.Object getID()
This is used to generate a unique id based on a particular connection. The id generated will be used to identify the connection in the CLI Transport Pool. Implementors have to generate unique Id for identifying the different connections which may have been established.
Specified by:
getID in interface CLIProtocolOptions
Returns:
the ID as an Object.

setInitialMessage

public void setInitialMessage(java.lang.String message)
Sets the initial message sent by the device after a connection is established. Implementors of this interface should set the initial message sent by the device after a successful connection establishment.
Specified by:
setInitialMessage in interface CLIProtocolOptions
Parameters:
message - the initial message from the device.

getInitialMessage

public java.lang.String getInitialMessage()
Gets the initial message sent by the device after a connection is established. This is the message that is sent by the device after a successful login/connection establishment with the device.
Specified by:
getInitialMessage in interface CLIProtocolOptions
Returns:
the initial message from the device.

clone

public java.lang.Object clone()
Performs a clone of this object. Implementors have to copy the appropriate fields in their protocol options implementation.
Specified by:
clone in interface CLIProtocolOptions
Overrides:
clone in class java.lang.Object
Returns:
the cloned instance of this object.

setProperties

public void setProperties(java.util.Properties properties)
Sets a list of properties on this CLIProperty instance.
Specified by:
setProperties in interface CLIProtocolOptions
Parameters:
props - the property object which contains the list of properties.

getProperties

public java.util.Properties getProperties()
Gets the list of properties on this CLIProperty instance.
Specified by:
getProperties in interface CLIProtocolOptions


Copyright (c)AdventNet Inc., 1996-2003