Serialio
Interface SerialPort

All Known Implementing Classes:
SerialPortLocal

public interface SerialPort

Interface for serial port classes. Using this interface allows a common code set for working with serial ports both locally and remotely.

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


    Field Summary
    static int RXREADYCOUNT
               
     
    Method Summary
     void close()
              Close a port object.
     void configure(SerialConfig cfgObj)
              Configures port with the parameters in the SerialConfig object See documentation for details on the SerialConfig parameters.
     int getByte()
              Get the next available byte from the receive buffer.
     SerialConfig getConfig()
              Gets the configuration object for the port.
     int getData(byte[] buf)
              Transfers bytes into the data buffer from the serial port receive buffer.
     int getData(byte[] buf, int off, int len)
              Transfers bytes into the data buffer from the serial port receive buffer.
     int getLibVer()
              Returns the version number of the current serial port DLL
     java.lang.String getName()
              Returns the name of this serial port object
     int getPortNum()
              Returns the port number for this serial port object
     int getTimeoutRx()
              Returns the receive (rx) timeout interval of serial port object.
     int getTimeoutTx()
              Returns the transmit (tx) timeout interval of serial port object.
     boolean isSupported(java.lang.String name)
              Indicates support for the requested feature.
     void putByte(byte data)
              Send byte to the serial port.
     void putData(byte[] data)
              Send byte array contents to the to the serial port.
     void putData(byte[] data, int off, int dLen)
              Send specified length of byte array contents to the serial port.
     void putString(java.lang.String s)
              Send String contents to the serial port.
     int rxFlush()
              Flushes the objects receive buffer (contents are discarded)
     boolean rxOverflow()
              Returns true if the objects receive buffer overflowed since the last call to this method.
     int rxReadyCount()
              Returns number of bytes in the objects receive buffer
     void sendBreak(int tmo)
              Send a break signal on the line
     void setConfig(SerialConfig cfgObj)
              Sets the configuration object for the port.
     void setDTR(boolean onOff)
              Set the DTR signal of objects serial port
     void setName(java.lang.String spName)
              Sets the name of this serial port object
     void setRTS(boolean onOff)
              Set the RTS signal of objects serial port
     void setTimeoutRx(int tmoRx)
              Sets the receive timeout of the serial port object.
     void setTimeoutTx(int tmoTx)
              Sets the transmit timeout of the serial port object.
     boolean sigBreak()
              Returns true if the serial port for this object detected a break on the line since the last call to this method.
     boolean sigCD()
              Returns state of serial port CD (Carrier Detect) signal
     boolean sigCTS()
              Returns state of serial port CTS (Clear To Send) signal
     boolean sigDSR()
              Returns state of serial port DSR (Data Set Ready) signal
     boolean sigFrameErr()
              Returns true if the serial port for this object had a Framing Error since last call to this method.
     boolean sigOverrun()
              Returns true if the serial port UART for this object had a was Overrun since last call to this method.
     boolean sigParityErr()
              Returns true if the serial port for this object had a Parity Error since last call to this method.
     boolean sigRing()
              Returns true if the serial port for this object detected a Ring on the line since the last call to this method.
     int txBufCount()
              Returns number of bytes in the objects transmit buffer
     int txDrain()
              Drains the objects transmit buffer (contents are sent)
     int txFlush()
              Flushes the objects transmit buffer (contents are discarded)
     

    Field Detail

    RXREADYCOUNT

    public static final int RXREADYCOUNT
    See Also:
    Constant Field Values
    Method Detail

    setConfig

    public void setConfig(SerialConfig cfgObj)
    Sets the configuration object for the port. The port may not be configured unless configure is subsequently called

    Parameters:
    cfgObj - The serial port configuration object

    getConfig

    public SerialConfig getConfig()
    Gets the configuration object for the port.


    configure

    public void configure(SerialConfig cfgObj)
                   throws java.io.IOException
    Configures port with the parameters in the SerialConfig object See documentation for details on the SerialConfig parameters.

    Parameters:
    cfgObj - The serial port configuration object
    Throws:
    java.io.IOException - if error

    close

    public void close()
               throws java.io.IOException
    Close a port object. The port should be closed when its use is no longer required

    Throws:
    java.io.IOException - if error

    putByte

    public void putByte(byte data)
                 throws java.io.IOException
    Send byte to the serial port. Returns after tx timeout if not sent.

    Parameters:
    data - The byte of data to output to the objects serial port
    Throws:
    java.io.IOException - if error

    putString

    public void putString(java.lang.String s)
                   throws java.io.IOException
    Send String contents to the serial port. This will only pass UTF8 strings (i.e. 8 bit ASCII, not 16 bit UNICODE). Returns after tx timeout if all data not sent.

    Parameters:
    s - The string to output to the objects serial port.
    Throws:
    java.io.IOException - if error

    putData

    public void putData(byte[] data)
                 throws java.io.IOException
    Send byte array contents to the to the serial port. Returns after rx timeout if all data not sent.

    Parameters:
    data - The byte array of data to output to the objects serial port are not sent to the transmit buffer
    Throws:
    java.io.IOException - if error

    putData

    public void putData(byte[] data,
                        int off,
                        int dLen)
                 throws java.io.IOException
    Send specified length of byte array contents to the serial port. Returns after tx timeout number of milliseconds if all data not sent.

    Parameters:
    data - The byte array of data to output to the objects serial port
    dLen - The length from the beginning of the byte array that will be output to the objects serial port.
    Throws:
    java.io.IOException - if error

    getByte

    public int getByte()
                throws java.io.IOException
    Get the next available byte from the receive buffer. Returns after rx timeout if data not received.

    Returns:
    byte or -1 if byte not available
    Throws:
    java.io.IOException - if error

    getData

    public int getData(byte[] buf)
                throws java.io.IOException
    Transfers bytes into the data buffer from the serial port receive buffer. Returns after rx timeout if all data not received.

    Parameters:
    buf - The byte array that will contain the data read from the objects serial port.
    Returns:
    number of bytes transferred
    Throws:
    java.io.IOException - if port not open

    getData

    public int getData(byte[] buf,
                       int off,
                       int len)
                throws java.io.IOException
    Transfers bytes into the data buffer from the serial port receive buffer. Returns after rx timeout if all data not received.

    Parameters:
    buf - the byte array buffer where data will be put when read
    off - the offset in the buffer where data will be put
    len - the length of data requested to be put in the buffer
    Returns:
    the total number of bytes read into the buffer
    Throws:
    java.io.IOException - if an error occurs.

    rxFlush

    public int rxFlush()
                throws java.io.IOException
    Flushes the objects receive buffer (contents are discarded)

    Throws:
    java.io.IOException - if error

    txFlush

    public int txFlush()
                throws java.io.IOException
    Flushes the objects transmit buffer (contents are discarded)

    Throws:
    java.io.IOException - if error

    txDrain

    public int txDrain()
                throws java.io.IOException
    Drains the objects transmit buffer (contents are sent)

    Throws:
    java.io.IOException - if error

    rxReadyCount

    public int rxReadyCount()
                     throws java.io.IOException
    Returns number of bytes in the objects receive buffer

    Throws:
    java.io.IOException - if error

    txBufCount

    public int txBufCount()
                   throws java.io.IOException
    Returns number of bytes in the objects transmit buffer

    Throws:
    java.io.IOException - if error

    rxOverflow

    public boolean rxOverflow()
                       throws java.io.IOException
    Returns true if the objects receive buffer overflowed since the last call to this method.

    Throws:
    java.io.IOException - if error

    sigDSR

    public boolean sigDSR()
                   throws java.io.IOException
    Returns state of serial port DSR (Data Set Ready) signal

    Throws:
    java.io.IOException - if error

    sigCTS

    public boolean sigCTS()
                   throws java.io.IOException
    Returns state of serial port CTS (Clear To Send) signal

    Throws:
    java.io.IOException - if error

    sigCD

    public boolean sigCD()
                  throws java.io.IOException
    Returns state of serial port CD (Carrier Detect) signal

    Throws:
    java.io.IOException - if error

    sigFrameErr

    public boolean sigFrameErr()
                        throws java.io.IOException
    Returns true if the serial port for this object had a Framing Error since last call to this method.

    Throws:
    java.io.IOException - if error

    sigOverrun

    public boolean sigOverrun()
                       throws java.io.IOException
    Returns true if the serial port UART for this object had a was Overrun since last call to this method.

    Throws:
    java.io.IOException - if error

    sigParityErr

    public boolean sigParityErr()
                         throws java.io.IOException
    Returns true if the serial port for this object had a Parity Error since last call to this method.

    Throws:
    java.io.IOException - if error

    sigRing

    public boolean sigRing()
                    throws java.io.IOException
    Returns true if the serial port for this object detected a Ring on the line since the last call to this method.

    Throws:
    java.io.IOException - if error

    sigBreak

    public boolean sigBreak()
                     throws java.io.IOException
    Returns true if the serial port for this object detected a break on the line since the last call to this method.

    Throws:
    java.io.IOException - if error

    setDTR

    public void setDTR(boolean onOff)
                throws java.io.IOException
    Set the DTR signal of objects serial port

    Parameters:
    onOff - The state that the objects DTR line will be set to.
    Throws:
    java.io.IOException - if error

    setRTS

    public void setRTS(boolean onOff)
                throws java.io.IOException
    Set the RTS signal of objects serial port

    Parameters:
    onOff - The state that the objects RTS line will be set to.
    Throws:
    java.io.IOException - if error

    sendBreak

    public void sendBreak(int tmo)
                   throws java.io.IOException
    Send a break signal on the line

    Throws:
    java.io.IOException - if error

    getTimeoutRx

    public int getTimeoutRx()
                     throws java.io.IOException
    Returns the receive (rx) timeout interval of serial port object.

    Throws:
    java.io.IOException - if error

    getTimeoutTx

    public int getTimeoutTx()
                     throws java.io.IOException
    Returns the transmit (tx) timeout interval of serial port object.

    Throws:
    java.io.IOException - if error

    setTimeoutRx

    public void setTimeoutRx(int tmoRx)
                      throws java.io.IOException
    Sets the receive timeout of the serial port object. Receive functions return after this amount of time if all data has not been received.

    Parameters:
    tmoRx - The number of milliseconds for the timeout.
    Throws:
    java.io.IOException - if error

    setTimeoutTx

    public void setTimeoutTx(int tmoTx)
                      throws java.io.IOException
    Sets the transmit timeout of the serial port object. Transmit functions return after this amount of time if all data has not been sent.

    Throws:
    java.io.IOException - if error

    getLibVer

    public int getLibVer()
                  throws java.io.IOException
    Returns the version number of the current serial port DLL

    Returns:
  • The most significant 16 bits contain the major version
  • The least significant 16 bits contain the minor version
    Throws:
    java.io.IOException - if error

  • getPortNum

    public int getPortNum()
    Returns the port number for this serial port object


    setName

    public void setName(java.lang.String spName)
    Sets the name of this serial port object


    getName

    public java.lang.String getName()
    Returns the name of this serial port object


    isSupported

    public boolean isSupported(java.lang.String name)
    Indicates support for the requested feature.