: Class TINISerialPort

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.dalsemi.comm
Class TINISerialPort

    java.lang.Object
      |
      +--javax.comm.CommPort
            |
            +--javax.comm.SerialPort
                  |
                  +--com.dalsemi.comm.TINISerialPort

public class TINISerialPort
extends javax.comm.SerialPort

This class is the actual serial port implementation used by `javax.comm.SerialPort` and should be used directly only if portability is not required and if `javax.comm.SerialPort` does not implement a method that is supported in this class.

One potentially useful method in this class is `setDivisor`. This method allows an application to set the divisor register on the 16552 DUART (serial2 and serial3 only). This will allow the hardware designer to choose the crystal frequency used by the DUART and giving full control over the baud rates (see the data sheet for the 16552 for formulas to calculate the buad rate using the divisor value and crystal frequency).

The serial port is opened automatically when a `TINISerialPort` object is constructed. `serial0`, by default, is owned by the shell's SerialServer. The shell command "downserver -s" must be called if an application, running from the shell, wishes to take ownership of the port. `serial1`, by default, is owned by the external 1-Wire adapter. The DS2480 chip must be removed and level shifters must be added to make this an RS-232 compatible port. `com.dalsemi.system.TINIOS.enableSerialPort1` must be called to enable this port after the system is booted. `serial2` and `serial3` require external hardware support (16552 Dual UART) on a socket board to make use of these ports. The class `com.dalsemi.system.TINIOS` contains methods for enabling and setting the address of the external serial ports. These methods need to be called only one time after TINI's heap is cleared.

National Semiconductor PC16552 data sheet

See Also:
  `TINIOS`

Fields inherited from class javax.comm.SerialPort
`DATABITS_5, DATABITS_6, DATABITS_7, DATABITS_8, FLOWCONTROL_NONE, FLOWCONTROL_RTSCTS_IN, FLOWCONTROL_RTSCTS_OUT, FLOWCONTROL_XONXOFF_IN, FLOWCONTROL_XONXOFF_OUT, PARITY_EVEN, PARITY_MARK, PARITY_NONE, PARITY_ODD, PARITY_SPACE, STOPBITS_1, STOPBITS_1_5, STOPBITS_2`

Fields inherited from class javax.comm.CommPort
`name`

Constructor Summary
`TINISerialPort(String name)` Constructor - Attempts to open the requested serial port specified by the parameter `name`.

Method Summary
`void` | `addEventListener(javax.comm.SerialPortEventListener eventListener)` Adds an event listener for the port.
`void` | `close()` Closes the serial port and associated streams.
`void` | `disableReceiveFraming()` Disables the port's receive framing.
`void` | `disableReceiveThreshold()` Disables the port's receive threshold.
`void` | `disableReceiveTimeout()` Disables the port's receive timeout.
`void` | `enableReceiveFraming(int framingByte)` Enables the port's receive framing.
`void` | `enableReceiveThreshold(int thresh)` Enables the port's receive threshold.
`void` | `enableReceiveTimeout(int rcvTimeout)` Enables the port's receive timeout.
`int` | `getBaudRate()` Returns the port's current baud rate in bits per second.
`boolean` | `getCD()` Returns the current state of CD at the exact time it was sampled by the native driver.
`boolean` | `getCTS()` Returns the current state of CTS at the exact time it was sampled by the native driver.
`int` | `getDataBits()` Returns the port's current the data bit (word size) setting.
`boolean` | `getDSR()` Returns the current state of DSR at the exact time it was sampled by the native driver.
`boolean` | `getDTR()` Returns the current state of DTR at the exact time it was sampled by the native driver.
`int` | `getFlowControlMode()` Returns the port's current flow control mode.
`int` | `getInputBufferSize()` Returns the port's input buffer size.
`InputStream` | `getInputStream()` Returns the InputStream associated with this port.
`int` | `getOutputBufferSize()` Returns the port's current output buffer size.
`OutputStream` | `getOutputStream()` Returns the OutputStream associated with this port.
`int` | `getParity()` Returns the port's current parity setting.
`protected static int` | `getPortNumByName(String name)`
`int` | `getReceiveFramingByte()` Returns the port's receive framing byte.
`int` | `getReceiveThreshold()` Returns the port's threshold enable state.
`int` | `getReceiveTimeout()` Returns the port's current receive timeout.
`boolean` | `getRI()` Returns the current state of RI at the exact time it was sampled by the native driver.
`boolean` | `getRTS()` Returns the current state of RTS at the exact time it was sampled by the native driver.
`int` | `getStopBits()` Returns the port's current stop bits setting.
`boolean` | `isCD()` Returns the current state of CD at the exact time it was sampled by the native driver.
`boolean` | `isCTS()` Returns the current state of CTS at the exact time it was sampled by the native driver.
`boolean` | `isDSR()` Returns the current state of DSR at the exact time it was sampled by the native driver.
`boolean` | `isDTR()` Returns the current state of DTR at the exact time it was sampled by the native driver.
`boolean` | `isReceiveFramingEnabled()` Returns the port's receive framing enable state.
`boolean` | `isReceiveThresholdEnabled()` Returns the port's threshold enable state.
`boolean` | `isReceiveTimeoutEnabled()` Returns the port's receive timeout enable state.
`boolean` | `isRI()` Returns the current state of RI at the exact time it was sampled by the native driver.
`boolean` | `isRTS()` Returns the current state of RTS at the exact time it was sampled by the native driver.
`void` | `notifyOnBreakInterrupt(boolean enable)` Requests notification when break interrupt occurs.
`void` | `notifyOnCarrierDetect(boolean enable)` Requests notification when carrier detect changes state.
`void` | `notifyOnCTS(boolean enable)` Requests notification when CTS changes state.
`void` | `notifyOnDataAvailable(boolean enable)` Requests notification when data is available to read.
`void` | `notifyOnDSR(boolean enable)` Requests notification when DSR changes state.
`void` | `notifyOnFramingError(boolean enable)` Requests notification when framing error occurs.
`void` | `notifyOnOutputEmpty(boolean enable)` Requests notification when output buffer is empty.
`void` | `notifyOnOverrunError(boolean enable)` Requests notification when overrun error occurs.
`void` | `notifyOnParityError(boolean enable)` Requests notification when parity error occurs.
`void` | `notifyOnRingIndicator(boolean enable)` Requests notification when ring indicator changes state.
`void` | `removeEventListener()` Removes an event listener.
`void` | `sendBreak(int millis)` Sends a break on the serial port.
`void` | `setBaudRate(int baudRate)` Sets the port's baud rate assuming the default crystal frequency.
`void` | `setBitParameters(int dataBits, int stopBits, int parity)` Sets the serial port's word size, stop bits and parity parameters.
`void` | `setDivisor(int divisor)` Sets the baud rate divisor register on the 16552 DUART.
`void` | `setDTR(boolean dtr)` Sets the state of DTR.
`void` | `setFlowControlMode(int flowC)` Sets the port's flow control mode.
`void` | `setInputBufferSize(int size)` Sets the port's input buffer size.
`protected void` | `setInternalBaudRate(int speed)` Sets the baud rate for the port.
`void` | `setOutputBufferSize(int size)` Sets the port's output buffer size.
`void` | `setRcvFifoTrigger(int trigger)` Sets the receive FIFO trigger level for the external serial ports.
`void` | `setRTS(boolean rts)` Sets the state of RTS.
`void` | `setSerialPortParams(int baudRate, int dataBits, int stopBits, int parity)` Sets serial port parameters including baud rate, data bits, stop bits and parity.

Methods inherited from class javax.comm.CommPort
`getName, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### TINISerialPort

    public TINISerialPort(String name)

  Constructor - Attempts to open the requested serial port specified by the parameter `name`.
  Parameters:
    `name` - the name of the serial port that is to be opened
  Throws:
    IllegalArgumentException - if the specified port name is not supported on TINI. Valid port names include `serial0` through `serial3`

Method Detail

### setRcvFifoTrigger

    public void setRcvFifoTrigger(int trigger)

  Sets the receive FIFO trigger level for the external serial ports. Valid trigger levels are 14, 8, 4 and 1. Invalid levels will be rounded down to the next valid level. A 0 level will be adjusted to 1. Attempts to set the trigger level for the internal ports will fail silently.
  Overrides:
    setRcvFifoTrigger in class javax.comm.SerialPort
  Parameters:
    `trigger` - number of bytes in the receive FIFO that will cause a receive interrupt

### close

    public void close()

  Closes the serial port and associated streams.
  Overrides:
    close in class javax.comm.CommPort

### getBaudRate

    public int getBaudRate()

  Returns the port's current baud rate in bits per second.
  Overrides:
    getBaudRate in class javax.comm.SerialPort
  Returns:
    the current baud rate

### getDataBits

    public int getDataBits()

  Returns the port's current the data bit (word size) setting.
  Overrides:
    getDataBits in class javax.comm.SerialPort
  Returns:
    the current word size

### getStopBits

    public int getStopBits()

  Returns the port's current stop bits setting.
  Overrides:
    getStopBits in class javax.comm.SerialPort
  Returns:
    the current stop bits

### getParity

    public int getParity()

  Returns the port's current parity setting.
  Overrides:
    getParity in class javax.comm.SerialPort
  Returns:
    the current parity

### setBitParameters

    public void setBitParameters(int dataBits,
                                 int stopBits,
                                 int parity)
                          throws javax.comm.UnsupportedCommOperationException

  Sets the serial port's word size, stop bits and parity parameters.
  Parameters:
    `dataBits` - desired word size
    `stopBits` - desired stop bits
    `parity` - desired parity
  Throws:
    IllegalStateException - if the port is not open

### sendBreak

    public void sendBreak(int millis)

  Sends a break on the serial port.
  Overrides:
    sendBreak in class javax.comm.SerialPort
  Parameters:
    `millis` - desired duration of the break in milliseconds
  Throws:
    IllegalStateException - if the port is not open

### setFlowControlMode

    public void setFlowControlMode(int flowC)
                            throws javax.comm.UnsupportedCommOperationException

  Sets the port's flow control mode. Valid modes include the `javax.comm.SerialPort` values `FLOWCONTROL_NONE`, `FLOWCONTROL_RTSCTS_IN`, `FLOWCONTROL_RTSCTS_OUT`, `FLOWCONTROL_XONXOFF_IN` and `FLOWCONTROL_XONXOFF_OUT`
  Overrides:
    setFlowControlMode in class javax.comm.SerialPort
  Throws:
    IllegalStateException - if the port is not open

### getFlowControlMode

    public int getFlowControlMode()

  Returns the port's current flow control mode.
  Overrides:
    getFlowControlMode in class javax.comm.SerialPort
  Returns:
    the current flow control mode
  See Also:
    `setFlowControlMode(int flowc)`

### setSerialPortParams

    public void setSerialPortParams(int baudRate,
                                    int dataBits,
                                    int stopBits,
                                    int parity)
                             throws javax.comm.UnsupportedCommOperationException

  Sets serial port parameters including baud rate, data bits, stop bits and parity.
  Overrides:
    setSerialPortParams in class javax.comm.SerialPort
  Parameters:
    `baudRate` - the desired baud rate
    `dataBits` - the desired word size
    `stopBits` - the desired stop bits
    `parity` - the desired parity
  Throws:
    javax.comm.UnsupportedCommOperationException - never
    IllegalStateException - if the port is not open

### setDivisor

    public void setDivisor(int divisor)

  Sets the baud rate divisor register on the 16552 DUART.
  Parameters:
    `divisor` - the value to be loaded into the port's divisor register

### setInternalBaudRate

    protected void setInternalBaudRate(int speed)
                                throws javax.comm.UnsupportedCommOperationException

  Sets the baud rate for the port.
  Parameters:
    `speed` - use the static final ints
  Throws:
    javax.comm.UnsupportedCommOperationException -
  See Also:

### setBaudRate

    public void setBaudRate(int baudRate)

  Sets the port's baud rate assuming the default crystal frequency.
  Parameters:
    `desired` - baud rate in bits per second

### setDTR

    public void setDTR(boolean dtr)

  Sets the state of DTR.
  Overrides:
    setDTR in class javax.comm.SerialPort
  Parameters:
    `dtr` - set to true to enable DTR
  Throws:
    IllegalStateException - if the port is not open

### isDTR

    public boolean isDTR()

  Returns the current state of DTR at the exact time it was sampled by the native driver. Same as getDTR. Used by `javax.comm.SerialPort`.
  Overrides:
    isDTR in class javax.comm.SerialPort
  Returns:
    true if DTR is currently asserted
  Throws:
    IllegalStateException - if the port is not open
  See Also:
    `getDTR()`

### getDTR

    public boolean getDTR()

  Returns the current state of DTR at the exact time it was sampled by the native driver.
  Returns:
    true if DTR is currently asserted
  Throws:
    IllegalStateException - if the port is not open

### setRTS

    public void setRTS(boolean rts)

  Sets the state of RTS.
  Overrides:
    setRTS in class javax.comm.SerialPort
  Parameters:
    `desired` - set to true to enable RTS
  Throws:
    IllegalStateException - if the port is not open

### isRTS

    public boolean isRTS()

  Returns the current state of RTS at the exact time it was sampled by the native driver. Same as getRTS. Used by `javax.comm.SerialPort`.
  Overrides:
    isRTS in class javax.comm.SerialPort
  Returns:
    true if RTS is asserted
  Throws:
    IllegalStateException - if the port is not open
  See Also:
    `getRTS()`

### getRTS

    public boolean getRTS()

  Returns the current state of RTS at the exact time it was sampled by the native driver.
  Returns:
    true if RTS is asserted
  Throws:
    IllegalStateException - if the port is not open

### isCTS

    public boolean isCTS()

  Returns the current state of CTS at the exact time it was sampled by the native driver. Same as getCTS. Used by `javax.comm.SerialPort`.
  Overrides:
    isCTS in class javax.comm.SerialPort
  Returns:
    true if CTS is asserted
  Throws:
    IllegalStateException - if the port is not open
  See Also:
    `getCTS()`

### getCTS

    public boolean getCTS()

  Returns the current state of CTS at the exact time it was sampled by the native driver.
  Returns:
    true if CTS is asserted
  Throws:
    IllegalStateException - if the port is not open

### isDSR

    public boolean isDSR()

  Returns the current state of DSR at the exact time it was sampled by the native driver. Same as getDSR. Used by `javax.comm.SerialPort`.
  Overrides:
    isDSR in class javax.comm.SerialPort
  Returns:
    true if DSR is asserted
  Throws:
    IllegalStateException - if the port is not open
  See Also:
    `getDSR()`

### getDSR

    public boolean getDSR()

  Returns the current state of DSR at the exact time it was sampled by the native driver.
  Returns:
    true if DSR is asserted
  Throws:
    IllegalStateException - if the port is not open

### isRI

    public boolean isRI()

  Returns the current state of RI at the exact time it was sampled by the native driver. Same as getRI. Used by `javax.comm.SerialPort`.
  Overrides:
    isRI in class javax.comm.SerialPort
  Returns:
    true if RI is asserted
  Throws:
    IllegalStateException - if the port is not open
  See Also:
    `getRI()`

### getRI

    public boolean getRI()

  Returns the current state of RI at the exact time it was sampled by the native driver.
  Returns:
    true if RI is asserted
  Throws:
    IllegalStateException - if the port is not open

### isCD

    public boolean isCD()

  Returns the current state of CD at the exact time it was sampled by the native driver. Same as getCD. Used by `javax.comm.SerialPort`.
  Overrides:
    isCD in class javax.comm.SerialPort
  Returns:
    true if RI is asserted
  Throws:
    IllegalStateException - if the port is not open
  See Also:
    `getCD()`

### getCD

    public boolean getCD()

  Returns the current state of CD at the exact time it was sampled by the native driver.
  Returns:
    true if CD is asserted
  Throws:
    IllegalStateException - if the port is not open

### addEventListener

    public void addEventListener(javax.comm.SerialPortEventListener eventListener)
                          throws TooManyListenersException

  Adds an event listener for the port. A new Thread will be created to manage events as soon as one of the notifyOn methods are called.
  Overrides:
    addEventListener in class javax.comm.SerialPort
  Parameters:
    `eventListener` - listener class to be installed
  Throws:
    IllegalStateException - if the port is not open
    TooManyListenersException - if the maximum number of listeners has been installed

### removeEventListener

    public void removeEventListener()

  Removes an event listener. This method removes all threads associated with event listeners when the last listener is removed.
  Overrides:
    removeEventListener in class javax.comm.SerialPort

### notifyOnDataAvailable

    public void notifyOnDataAvailable(boolean enable)

  Requests notification when data is available to read. This method will create a new Thread to manage events if one has not already been created.
  Overrides:
    notifyOnDataAvailable in class javax.comm.SerialPort
  Parameters:
    `enable` - set to true to enable

### notifyOnOutputEmpty

    public void notifyOnOutputEmpty(boolean enable)

  Requests notification when output buffer is empty. This method will create a new Thread to manage events if one has not already been created.
  Overrides:
    notifyOnOutputEmpty in class javax.comm.SerialPort
  Parameters:
    `enable` - set to true to enable

### notifyOnCTS

    public void notifyOnCTS(boolean enable)

  Requests notification when CTS changes state. This method will create a new Thread to manage events if one has not already been created.
  Overrides:
    notifyOnCTS in class javax.comm.SerialPort
  Parameters:
    `enable` - set to true to enable

### notifyOnDSR

    public void notifyOnDSR(boolean enable)

  Requests notification when DSR changes state. This method will create a new Thread to manage events if one has not already been created.
  Overrides:
    notifyOnDSR in class javax.comm.SerialPort
  Parameters:
    `enable` - set to true to enable

### notifyOnRingIndicator

    public void notifyOnRingIndicator(boolean enable)

  Requests notification when ring indicator changes state. This method will create a new Thread to manage events if one has not already been created.
  Overrides:
    notifyOnRingIndicator in class javax.comm.SerialPort
  Parameters:
    `enable` - set to true to enable

### notifyOnCarrierDetect

    public void notifyOnCarrierDetect(boolean enable)

  Requests notification when carrier detect changes state. This method will create a new Thread to manage events if one has not already been created.
  Overrides:
    notifyOnCarrierDetect in class javax.comm.SerialPort
  Parameters:
    `enable` - set to true to enable

### notifyOnOverrunError

    public void notifyOnOverrunError(boolean enable)

  Requests notification when overrun error occurs. This method will create a new Thread to manage events if one has not already been created.
  Overrides:
    notifyOnOverrunError in class javax.comm.SerialPort
  Parameters:
    `enable` - set to true to enable

### notifyOnParityError

    public void notifyOnParityError(boolean enable)

  Requests notification when parity error occurs. This method will create a new Thread to manage events if one has not already been created.
  Overrides:
    notifyOnParityError in class javax.comm.SerialPort
  Parameters:
    `enable` - set to true to enable

### notifyOnFramingError

    public void notifyOnFramingError(boolean enable)

  Requests notification when framing error occurs. This method will create a new Thread to manage events if one has not already been created.
  Overrides:
    notifyOnFramingError in class javax.comm.SerialPort
  Parameters:
    `enable` - set to true to enable

### notifyOnBreakInterrupt

    public void notifyOnBreakInterrupt(boolean enable)

  Requests notification when break interrupt occurs. This method will create a new Thread to manage events if one has not already been created.
  Overrides:
    notifyOnBreakInterrupt in class javax.comm.SerialPort
  Parameters:
    `enable` - set to true to enable

### getInputStream

    public InputStream getInputStream()
                               throws IOException

  Returns the InputStream associated with this port.
  Overrides:
    getInputStream in class javax.comm.CommPort
  Returns:
    the InputStream associated with this port
  Throws:
    IOException - if the stream is not available
    IllegalStateException - if the port is not open

### getOutputStream

    public OutputStream getOutputStream()
                                 throws IOException

  Returns the OutputStream associated with this port.
  Overrides:
    getOutputStream in class javax.comm.CommPort
  Returns:
    the OutputStream associated with this port
  Throws:
    IOException - if the stream is not available
    IllegalStateException - if the port is not open

### enableReceiveThreshold

    public void enableReceiveThreshold(int thresh)
                                throws javax.comm.UnsupportedCommOperationException

  Enables the port's receive threshold.
  Overrides:
    enableReceiveThreshold in class javax.comm.CommPort
  Parameters:
    `thresh` - threshold in milliseconds
  Throws:
    javax.comm.UnsupportedCommOperationException - never
    IllegalStateException - if the InputStream is not accessable

### disableReceiveThreshold

    public void disableReceiveThreshold()

  Disables the port's receive threshold.
  Overrides:
    disableReceiveThreshold in class javax.comm.CommPort

### isReceiveThresholdEnabled

    public boolean isReceiveThresholdEnabled()

  Returns the port's threshold enable state. Used by `javax.comm.SerialPort`.
  Overrides:
    isReceiveThresholdEnabled in class javax.comm.CommPort
  Returns:
    true if receive threshold is enabled

### getReceiveThreshold

    public int getReceiveThreshold()

  Returns the port's threshold enable state.
  Overrides:
    getReceiveThreshold in class javax.comm.CommPort
  Returns:
    true if receive threshold is enabled

### enableReceiveTimeout

    public void enableReceiveTimeout(int rcvTimeout)
                              throws javax.comm.UnsupportedCommOperationException

  Enables the port's receive timeout.
  Overrides:
    enableReceiveTimeout in class javax.comm.CommPort
  Parameters:
    `rcvTimeout` - timeout in milliseconds
  Throws:
    javax.comm.UnsupportedCommOperationException - never
    IllegalStateException - if the port is closed

### disableReceiveTimeout

    public void disableReceiveTimeout()

  Disables the port's receive timeout.
  Overrides:
    disableReceiveTimeout in class javax.comm.CommPort
  Throws:
    IllegalStateException - if the port is closed

### isReceiveTimeoutEnabled

    public boolean isReceiveTimeoutEnabled()

  Returns the port's receive timeout enable state.
  Overrides:
    isReceiveTimeoutEnabled in class javax.comm.CommPort
  Returns:
    true if receive timeout is enabled

### getReceiveTimeout

    public int getReceiveTimeout()

  Returns the port's current receive timeout.
  Overrides:
    getReceiveTimeout in class javax.comm.CommPort
  Returns:
    the current timeout value

### enableReceiveFraming

    public void enableReceiveFraming(int framingByte)
                              throws javax.comm.UnsupportedCommOperationException

  Enables the port's receive framing. This method is not implemented on TINI.
  Overrides:
    enableReceiveFraming in class javax.comm.CommPort
  Throws:
    javax.comm.UnsupportedCommOperationException - always

### disableReceiveFraming

    public void disableReceiveFraming()

  Disables the port's receive framing.
  Overrides:
    disableReceiveFraming in class javax.comm.CommPort

### isReceiveFramingEnabled

    public boolean isReceiveFramingEnabled()

  Returns the port's receive framing enable state.
  Overrides:
    isReceiveFramingEnabled in class javax.comm.CommPort
  Returns:
    false always

### getReceiveFramingByte

    public int getReceiveFramingByte()

  Returns the port's receive framing byte.
  Overrides:
    getReceiveFramingByte in class javax.comm.CommPort
  Returns:
    -1 always

### setInputBufferSize

    public void setInputBufferSize(int size)

  Sets the port's input buffer size.
  Overrides:
    setInputBufferSize in class javax.comm.CommPort
  Parameters:
    `size` - number of bytes to use for the input receive buffer

### getInputBufferSize

    public int getInputBufferSize()

  Returns the port's input buffer size.
  Overrides:
    getInputBufferSize in class javax.comm.CommPort
  Returns:
    the current input buffer size

### setOutputBufferSize

    public void setOutputBufferSize(int size)

  Sets the port's output buffer size.
  Overrides:
    setOutputBufferSize in class javax.comm.CommPort
  Parameters:
    `size` - number of bytes to use for the output transmit buffer

### getOutputBufferSize

    public int getOutputBufferSize()

  Returns the port's current output buffer size.
  Overrides:
    getOutputBufferSize in class javax.comm.CommPort
  Returns:
    the current output buffer size

### getPortNumByName

    protected static int getPortNumByName(String name)

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD