Serialio
Class SerialConfig

java.lang.Object
  extended bySerialio.SerialConfig
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class SerialConfig
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

Serial port configuration class. A SerialConfig object is passed to a SerialPort class when the SerialPort class in created.

  • Copyright (c) 1996-2005 Serialio.com, All Rights Reserved.

    See Also:
    Serialized Form

    Field Summary
    static int BR_110
               
    static int BR_115200
               
    static int BR_1200
               
    static int BR_150
               
    static int BR_19200
               
    static int BR_230400
               
    static int BR_2400
               
    static int BR_300
               
    static int BR_38400
               
    static int BR_460800
               
    static int BR_4800
               
    static int BR_57600
               
    static int BR_600
               
    static int BR_921600
               
    static int BR_9600
               
    static int HS_CTSDTR
               
    static int HS_CTSRTS
               
    static int HS_DSRDTR
               
    static int HS_HARD_IN
               
    static int HS_HARD_OUT
               
    static int HS_NONE
               
    static int HS_SOFT_IN
               
    static int HS_SOFT_OUT
               
    static int HS_SPLIT_MASK
               
    static int HS_XONXOFF
               
    static int LN_5BITS
               
    static int LN_6BITS
               
    static int LN_7BITS
               
    static int LN_8BITS
               
    static int PWR_ACTIVE
               
    static int PWR_STANDBY
               
    static int PY_EVEN
               
    static int PY_MARK
               
    static int PY_NONE
               
    static int PY_ODD
               
    static int PY_SPACE
               
    static int ST_1BITS
               
    static int ST_2BITS
               
     
    Constructor Summary
    SerialConfig()
              Create a default SerialConfig object.
    SerialConfig(int serPort)
              Deprecated. The preferred way to construct a SerialConfig object is 'by-name'
      SerialConfig cfg = new SerialConfig("COM1");
      SerialConfig cfg = new SerialConfig("/dev/ttyS0");
      SerialConfig cfg = new SerialConfig("Modem Port");
    SerialConfig(int serPort, int txBufLen, int rxBufLen)
              Deprecated. The preferred way to construct a SerialConfig object is 'by-name'
      SerialConfig cfg = new SerialConfig("COM1");
      SerialConfig cfg = new SerialConfig("/dev/ttyS0");
      SerialConfig cfg = new SerialConfig("Modem Port");
    Then set the buffer length(s) if setting them is supported

    Note: Buffer size control not supported on all platforms.
    SerialConfig(java.lang.String pName)
              Create a SerialConfig object 'by-name' with default port parameters
     
    Method Summary
     SerialConfig copy()
              Return a copy (clone) of this object.
     byte[] getBaseName()
              Get the device base name
     int getBitRate()
              Get the bit rate index
     int getBitRateIndex(int rate)
              Get the bit rate as index value.
     int getBitRateNumber(int ndx)
              Get the bit rate as a number
     int getDataBits()
              Get the number of data bits for each character
     boolean getDisableActiveLink()
              Get the state of the 'active link' control for EPOC This is EPOC specific
     int getHandshake()
              Get the handshake protocol
     boolean getHardFlow()
              Get the state of the 'manual' flow control setting This is Windows specific (to Fix Microsoft driver bugs)
     int getParity()
              Get the parity
     int getPort()
              Get the port number This number may be meaningless if the port was opened using a name.
     byte[] getPortName()
              Get the port name
     java.lang.String getPortNameString()
              Get the port name
     int getRxLen()
              Get the receive buffer length
     java.lang.String getSettingsString()
              Get a string representing the current port settings
     int getStopBits()
              Get the number of stop bits for each character
     int getTxLen()
              Get the transmit buffer length
     void setBaseName(java.lang.String devBaseName)
              Set the base device name.
     void setBitRate(int newBitRate)
              Set the bit rate
     void setDataBits(int newDataBits)
              Set the number of data bits
     void setDisableActiveLink(boolean s)
              Set the state of the 'active link' control for EPOC.
     void setHandshake(int newShake)
              Set the handshake protocol
     void setHardFlow(boolean state)
              Set the flag that controls if we do hardware flow control for the receive buffer.
     void setParity(int newParity)
              Set the parity Note: MARK & SPACE parity may not be supported on all platforms
     void setPortName(java.lang.String pName)
              Set the port name
     void setPortNum(int pNum)
              Set the port number
     void setRxLen(int rxBufLen)
              Set the value that *maybe* used by the driver to set the queue sizes when the port is opened.
     void setStopBits(int newStopBits)
              Set the number of stop bits
     void setTxLen(int txBufLen)
              Set the value that *maybe* used by the driver to set the queue sizes when the port is opened.
    protected  boolean validBitRateIndex()
              Checks for valid bit rate index.
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    HS_NONE

    public static final int HS_NONE
    See Also:
    Constant Field Values

    HS_XONXOFF

    public static final int HS_XONXOFF
    See Also:
    Constant Field Values

    HS_CTSRTS

    public static final int HS_CTSRTS
    See Also:
    Constant Field Values

    HS_CTSDTR

    public static final int HS_CTSDTR
    See Also:
    Constant Field Values

    HS_DSRDTR

    public static final int HS_DSRDTR
    See Also:
    Constant Field Values

    HS_HARD_IN

    public static final int HS_HARD_IN
    See Also:
    Constant Field Values

    HS_HARD_OUT

    public static final int HS_HARD_OUT
    See Also:
    Constant Field Values

    HS_SOFT_IN

    public static final int HS_SOFT_IN
    See Also:
    Constant Field Values

    HS_SOFT_OUT

    public static final int HS_SOFT_OUT
    See Also:
    Constant Field Values

    HS_SPLIT_MASK

    public static final int HS_SPLIT_MASK
    See Also:
    Constant Field Values

    BR_110

    public static final int BR_110
    See Also:
    Constant Field Values

    BR_150

    public static final int BR_150
    See Also:
    Constant Field Values

    BR_300

    public static final int BR_300
    See Also:
    Constant Field Values

    BR_600

    public static final int BR_600
    See Also:
    Constant Field Values

    BR_1200

    public static final int BR_1200
    See Also:
    Constant Field Values

    BR_2400

    public static final int BR_2400
    See Also:
    Constant Field Values

    BR_4800

    public static final int BR_4800
    See Also:
    Constant Field Values

    BR_9600

    public static final int BR_9600
    See Also:
    Constant Field Values

    BR_19200

    public static final int BR_19200
    See Also:
    Constant Field Values

    BR_38400

    public static final int BR_38400
    See Also:
    Constant Field Values

    BR_57600

    public static final int BR_57600
    See Also:
    Constant Field Values

    BR_115200

    public static final int BR_115200
    See Also:
    Constant Field Values

    BR_230400

    public static final int BR_230400
    See Also:
    Constant Field Values

    BR_460800

    public static final int BR_460800
    See Also:
    Constant Field Values

    BR_921600

    public static final int BR_921600
    See Also:
    Constant Field Values

    PY_NONE

    public static final int PY_NONE
    See Also:
    Constant Field Values

    PY_ODD

    public static final int PY_ODD
    See Also:
    Constant Field Values

    PY_EVEN

    public static final int PY_EVEN
    See Also:
    Constant Field Values

    PY_MARK

    public static final int PY_MARK
    See Also:
    Constant Field Values

    PY_SPACE

    public static final int PY_SPACE
    See Also:
    Constant Field Values

    LN_5BITS

    public static final int LN_5BITS
    See Also:
    Constant Field Values

    LN_6BITS

    public static final int LN_6BITS
    See Also:
    Constant Field Values

    LN_7BITS

    public static final int LN_7BITS
    See Also:
    Constant Field Values

    LN_8BITS

    public static final int LN_8BITS
    See Also:
    Constant Field Values

    ST_1BITS

    public static final int ST_1BITS
    See Also:
    Constant Field Values

    ST_2BITS

    public static final int ST_2BITS
    See Also:
    Constant Field Values

    PWR_STANDBY

    public static final int PWR_STANDBY
    See Also:
    Constant Field Values

    PWR_ACTIVE

    public static final int PWR_ACTIVE
    See Also:
    Constant Field Values
    Constructor Detail

    SerialConfig

    public SerialConfig(int serPort)
    Deprecated. The preferred way to construct a SerialConfig object is 'by-name'
      SerialConfig cfg = new SerialConfig("COM1");
      SerialConfig cfg = new SerialConfig("/dev/ttyS0");
      SerialConfig cfg = new SerialConfig("Modem Port");

    Create a SerialConfig object with default port parameters

    Parameters:
    serPort - The serial port number e.g. use 1 for COM1

    SerialConfig

    public SerialConfig(int serPort,
                        int txBufLen,
                        int rxBufLen)
    Deprecated. The preferred way to construct a SerialConfig object is 'by-name'
      SerialConfig cfg = new SerialConfig("COM1");
      SerialConfig cfg = new SerialConfig("/dev/ttyS0");
      SerialConfig cfg = new SerialConfig("Modem Port");
    Then set the buffer length(s) if setting them is supported

    Note: Buffer size control not supported on all platforms.

    Create a SerialConfig object with default port parameters

    Parameters:
    serPort - Serial port number e.g. use 1 for COM1
    txBufLen - Transmit buffer length (in bytes) for the port
    rxBufLen - Receive buffer length (in bytes) for the port

    SerialConfig

    public SerialConfig(java.lang.String pName)
    Create a SerialConfig object 'by-name' with default port parameters

    Parameters:
    pName - The port/device name for the serial port example names: "COM1" or "/dev/ttyS0" Only UTF8 strings are currently valid When a device is opened by name it is assigned an index by the native code that may not correlate to the port number. i.e. if you open COM5 and check the port number in SerialConfig or SerialPort it may not be 5.

    SerialConfig

    public SerialConfig()
    Create a default SerialConfig object. For bean friendliness.

    Method Detail

    setPortNum

    public void setPortNum(int pNum)
                    throws java.lang.IllegalArgumentException
    Set the port number

    Throws:
    java.lang.IllegalArgumentException - if port number negative.

    setPortName

    public void setPortName(java.lang.String pName)
    Set the port name


    setBitRate

    public void setBitRate(int newBitRate)
                    throws java.lang.IllegalArgumentException
    Set the bit rate

    Throws:
    java.lang.IllegalArgumentException - If bit rate is out of range.

    validBitRateIndex

    protected boolean validBitRateIndex()
    Checks for valid bit rate index.


    setParity

    public void setParity(int newParity)
                   throws java.lang.IllegalArgumentException
    Set the parity Note: MARK & SPACE parity may not be supported on all platforms

    Throws:
    java.lang.IllegalArgumentException - If parity is out of range.

    setDataBits

    public void setDataBits(int newDataBits)
                     throws java.lang.IllegalArgumentException
    Set the number of data bits

    Throws:
    java.lang.IllegalArgumentException - If number of data bits is out of range.

    setStopBits

    public void setStopBits(int newStopBits)
                     throws java.lang.IllegalArgumentException
    Set the number of stop bits

    Throws:
    java.lang.IllegalArgumentException - If number of stop bits is out of range.

    setHandshake

    public void setHandshake(int newShake)
                      throws java.lang.IllegalArgumentException
    Set the handshake protocol

    Throws:
    java.lang.IllegalArgumentException - If handshake protocol is out of range.

    setBaseName

    public void setBaseName(java.lang.String devBaseName)
                     throws java.lang.IllegalArgumentException
    Set the base device name. This is used when selecting devices via port numbers.

    Throws:
    java.lang.IllegalArgumentException

    setHardFlow

    public void setHardFlow(boolean state)
    Set the flag that controls if we do hardware flow control for the receive buffer. This is used to compensate for a Win95 VCOMM driver bug. The driver does not properly provide hardware flow control (RTS or DTR toggle) when running with standard PC ports. If your system uses multiport cards that come with Win95 drivers (e.g. Comtrol RockePorts), then you proably want to disable this since these drivers work and your performance will generally be better allowing the driver to control flow.


    setTxLen

    public void setTxLen(int txBufLen)
    Set the value that *maybe* used by the driver to set the queue sizes when the port is opened.


    setRxLen

    public void setRxLen(int rxBufLen)
    Set the value that *maybe* used by the driver to set the queue sizes when the port is opened.


    getPort

    public int getPort()
    Get the port number This number may be meaningless if the port was opened using a name.


    getTxLen

    public int getTxLen()
    Get the transmit buffer length


    getRxLen

    public int getRxLen()
    Get the receive buffer length


    getBitRate

    public int getBitRate()
    Get the bit rate index


    getBitRateNumber

    public int getBitRateNumber(int ndx)
    Get the bit rate as a number


    getBitRateIndex

    public int getBitRateIndex(int rate)
    Get the bit rate as index value.

    Returns:
    bitrate index or -1 if index for rate not found

    getParity

    public int getParity()
    Get the parity


    getDataBits

    public int getDataBits()
    Get the number of data bits for each character


    getStopBits

    public int getStopBits()
    Get the number of stop bits for each character


    getHandshake

    public int getHandshake()
    Get the handshake protocol


    getPortName

    public byte[] getPortName()
    Get the port name


    getPortNameString

    public java.lang.String getPortNameString()
    Get the port name


    getBaseName

    public byte[] getBaseName()
    Get the device base name


    getHardFlow

    public boolean getHardFlow()
    Get the state of the 'manual' flow control setting This is Windows specific (to Fix Microsoft driver bugs)


    getDisableActiveLink

    public boolean getDisableActiveLink()
    Get the state of the 'active link' control for EPOC This is EPOC specific


    setDisableActiveLink

    public void setDisableActiveLink(boolean s)
    Set the state of the 'active link' control for EPOC. true=port open will disable an active PSP link ('Link to desktop') false=port open will throw an exception if link is active Note: active and enabled are two different states This is EPOC specific


    getSettingsString

    public java.lang.String getSettingsString()
    Get a string representing the current port settings


    copy

    public SerialConfig copy()
                      throws java.lang.CloneNotSupportedException
    Return a copy (clone) of this object.

    Throws:
    java.lang.CloneNotSupportedException - if super.clone fails