2008-02-07 1.1.0

org.eclipse.soda.dk.serial.connection
Class SerialConnection

java.lang.Object
  extended by org.eclipse.soda.dk.core.EscObject
      extended by org.eclipse.soda.dk.connection.Connection
          extended by org.eclipse.soda.dk.connection.StreamConnection
              extended by org.eclipse.soda.dk.serial.connection.SerialConnection
All Implemented Interfaces:
ConnectionService, SerialConnectionService

public class SerialConnection
extends StreamConnection
implements SerialConnectionService, ConnectionService

The SerialConnection class implements the ConnectionService interface to support reading and writing to the serial port.

Version:
1.1.0
See Also:
ConnectionService, String

Field Summary
protected static char[] TOSTRING_NAME
          Define the tostring name (char[]) constant.
 
Fields inherited from class org.eclipse.soda.dk.connection.Connection
CLIENT_WAIT_RESOURCE, CLOSE_RESOURCE, CLOSED_RESOURCE, configurationService, OPEN_RESOURCE, OPENFAILED_RESOURCE, READ_BYTES_RESOURCE, readByteCount, WRITE_BYTES_RESOURCE, writeByteCount
 
Fields inherited from class org.eclipse.soda.dk.core.EscObject
CLONE_EXCEPTION_RESOURCE, EMPTY_BYTES, EMPTY_STRING, ERROR_OCCURRED_EXCEPTION_RESOURCE, ID_FILTER_KEY, ID_KEY, ID_KEY_ANY, INTEGER_TABLE, INTEGER_TABLE_SIZE, KEY_KEY, LOG_DEBUG, LOG_ERROR, LOG_INFO, LOG_TRACE, LOG_WARNING, PREFIX_KEY, RESOURCE_BUNDLE, SLEEP_EXCEPTION_RESOURCE, SYSTEM_INFO_RESOURCE, TO_STRING_CONFIGURATION_KEYS, TRACE_LEVEL_HIGH, TRACE_LEVEL_LOW, TRACE_LEVEL_MAX, TRACE_LEVEL_MIN, TRACE_LEVEL_NONE, TRACE_LEVEL_NORMAL, TRACELEVEL_KEY, UNKNOWN_ERROR_RESOURCE
 
Fields inherited from interface org.eclipse.soda.dk.serial.connection.service.SerialConnectionService
BAUDRATE_KEY, COMPORT_KEY, CONNECTION_TYPE, DATABITS_5, DATABITS_6, DATABITS_7, DATABITS_8, DATABITS_KEY, DEFAULT_BAUDRATE, DEFAULT_COMPORT, DEFAULT_DATABITS, DEFAULT_HARDWAREFLOWCONTROL, DEFAULT_PARITY, DEFAULT_READINTERVALTIMEOUT, DEFAULT_READTOTALTIMEOUT, DEFAULT_SOFTWAREFLOWCONTROL, DEFAULT_STOPBITS, DEFAULT_WRITETOTALTIMEOUT, FACTORY_SERVICE_NAME, HARDWAREFLOWCONTROL_KEY, PARITY_EVEN, PARITY_KEY, PARITY_MARK, PARITY_NONE, PARITY_ODD, PARITY_SPACE, READINTERVALTIMEOUT_KEY, READTOTALTIMEOUT_KEY, SERVICE_NAME, SOFTWAREFLOWCONTROL_KEY, STOPBITS_1, STOPBITS_1_5, STOPBITS_2, STOPBITS_KEY, WRITETOTALTIMEOUT_KEY
 
Fields inherited from interface org.eclipse.soda.dk.connection.service.ConnectionService
CONNECTION_KEY, DEFAULT_CONNECTION
 
Constructor Summary
SerialConnection(ConfigurationService configuration)
          Constructs an instance of this class from the specified configuration parameter.
SerialConnection(java.util.Dictionary properties)
           
SerialConnection(int portNumber, int baudRate, int dataBits, int parity, int stopBits, int hardwareFlowControl, int softwareFlowControl, int readTotalTimeout, int readIntervalTimeout, int writeTotalTimeout)
          Constructs an SerialConnection object using the input parameter(s).
SerialConnection(java.lang.String portName, int baudRate, int dataBits, int parity, int stopBits, int hardwareFlowControl, int softwareFlowControl, int readTotalTimeout, int readIntervalTimeout, int writeTotalTimeout)
          Constructs an instance of this class from the specified port name, baud rate, data bits, parity, stop bits, hardware flow control, software flow control, read total timeout, read interval timeout and write total timeout parameters.
 
Method Summary
 void changeBaudRate(int baudRate)
          Perform the changeBaudRate action method.
 void close()
          Perform the close action method.
 java.lang.String getOutputName()
          Gets the output name (String) value.
static java.lang.String getPortName(int portNumber)
           
 long getReceivedTotalTimeout()
          Gets the received total timeout (long) value.
 java.lang.String getType()
          Gets the String type property value.
 void open()
          Perform the open action method.
 int read(byte[] bytes)
          Read bytes.
 int read(byte[] bytes, int offset, int length)
          Read bytes.
 void setReceivedTotalTimeout(long timeout)
           
 
Methods inherited from class org.eclipse.soda.dk.connection.StreamConnection
flush, getInputStream, getOutputStream, setInputStream, setOutputStream, write, write
 
Methods inherited from class org.eclipse.soda.dk.connection.Connection
attemptRecoveryFromError, exit, finalize, getConfigurationService, getDefaultResource, getErrorSeverity, getLogDetails4, getLogDetails5, getReadByteCount, getResource, getWriteByteCount, isOpen, setConfigurationService, setOpen, setReadByteCount, setWriteByteCount, toStringInfo, updateReadByteCount, updateWriteByteCount
 
Methods inherited from class org.eclipse.soda.dk.core.EscObject
createDefaultLogService, createException, createException, createInteger, createIntegerTable, createNumber, format, getBoolean, getCurrentTimestamp, getDefaultLogService, getFloat, getInt, getLoadLibraryName, getLogDetails, getLogDetails0, getLogDetails1, getLogDetails2, getLogDetails3, getLogDetails6, getLogDetails7, getLogService, getLong, getObject, getSimpleClassName, getStaticBoolean, getStaticFloat, getStaticInt, getStaticLong, getStaticObject, getStaticString, getString, getTraceLevel, getVmLibraryVersion, handleError, handleError, handleError, handleErrorInternal, handleStaticError, handleStaticException, isDebug, isTrace, loadService, log, log, report, report, report, report, report, report, reportError, reportSystemInfo, setDebug, setDefaultLogService, setLogService, setTraceLevel, shouldLog, sleep, startupEscStatic, toString, toStringConfigurationKeys
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.soda.dk.connection.service.ConnectionService
exit, flush, isOpen, write, write
 

Field Detail

TOSTRING_NAME

protected static final char[] TOSTRING_NAME
Define the tostring name (char[]) constant.

Constructor Detail

SerialConnection

public SerialConnection(int portNumber,
                        int baudRate,
                        int dataBits,
                        int parity,
                        int stopBits,
                        int hardwareFlowControl,
                        int softwareFlowControl,
                        int readTotalTimeout,
                        int readIntervalTimeout,
                        int writeTotalTimeout)
                 throws java.lang.IllegalArgumentException
Constructs an SerialConnection object using the input parameter(s). int int int int int int int int int int The exception description.

Parameters:
portNumber - The port number (int) parameter.
baudRate - The baud rate (int) parameter.
dataBits - The data bits (int) parameter.
parity - The parity (int) parameter.
stopBits - The stop bits (int) parameter.
hardwareFlowControl - The hardware flow control (int) parameter.
softwareFlowControl - The software flow control (int) parameter.
readTotalTimeout - The read total timeout (int) parameter.
readIntervalTimeout - The read interval timeout (int) parameter.
writeTotalTimeout - The write total timeout (int) parameter.
Throws:
java.lang.IllegalArgumentException - Illegal Argument Exception.
See Also:
SerialConnection(String,int,int,int,int,int,int,int,int,int), SerialConnection(Dictionary), SerialConnection(ConfigurationService)

SerialConnection

public SerialConnection(java.lang.String portName,
                        int baudRate,
                        int dataBits,
                        int parity,
                        int stopBits,
                        int hardwareFlowControl,
                        int softwareFlowControl,
                        int readTotalTimeout,
                        int readIntervalTimeout,
                        int writeTotalTimeout)
                 throws java.lang.IllegalArgumentException
Constructs an instance of this class from the specified port name, baud rate, data bits, parity, stop bits, hardware flow control, software flow control, read total timeout, read interval timeout and write total timeout parameters. The port name (String) parameter. The baud rate (int) parameter. The data bits (int) parameter. The parity (int) parameter. The stop bits (int) parameter. The hardware flow control (int) parameter. The software flow control (int) parameter. The read total timeout (int) parameter. The read interval timeout (int) parameter. The write total timeout (int) parameter. Illegal Argument Exception.

Parameters:
portName - The port name (String) parameter.
baudRate - The baud rate (int) parameter.
dataBits - The data bits (int) parameter.
parity - The parity (int) parameter.
stopBits - The stop bits (int) parameter.
hardwareFlowControl - The hardware flow control (int) parameter.
softwareFlowControl - The software flow control (int) parameter.
readTotalTimeout - The read total timeout (int) parameter.
readIntervalTimeout - The read interval timeout (int) parameter.
writeTotalTimeout - The write total timeout (int) parameter.
Throws:
java.lang.IllegalArgumentException - Illegal Argument Exception.
See Also:
SerialConnection(int,int,int,int,int,int,int,int,int,int), SerialConnection(Dictionary), SerialConnection(ConfigurationService)

SerialConnection

public SerialConnection(java.util.Dictionary properties)
Parameters:
properties - The properties (Dictionary) parameter.
See Also:
SerialConnection(int,int,int,int,int,int,int,int,int,int), SerialConnection(String,int,int,int,int,int,int,int,int,int), SerialConnection(ConfigurationService)

SerialConnection

public SerialConnection(ConfigurationService configuration)
Constructs an instance of this class from the specified configuration parameter. The configuration (ConfigurationService) parameter.

Parameters:
configuration - The configuration (ConfigurationService) parameter.
See Also:
SerialConnection(int,int,int,int,int,int,int,int,int,int), SerialConnection(String,int,int,int,int,int,int,int,int,int), SerialConnection(Dictionary)
Method Detail

getPortName

public static java.lang.String getPortName(int portNumber)
Parameters:
portNumber - The port number (int) parameter.
Returns:
Results of the get port name (String) value.

changeBaudRate

public void changeBaudRate(int baudRate)
                    throws java.lang.RuntimeException
Perform the changeBaudRate action method. int Runtime Exception.

Parameters:
baudRate - The baud rate (int) parameter.
Throws:
java.lang.RuntimeException - Runtime Exception.

close

public void close()
           throws java.io.IOException
Perform the close action method. href="java.io.IOException.html">IOException Thrown if the IOException exception condition occurs.

Specified by:
close in interface ConnectionService
Overrides:
close in class StreamConnection
Throws:
java.io.IOException - IOException.
See Also:
ConnectionService.close()

getOutputName

public java.lang.String getOutputName()
Gets the output name (String) value.

Overrides:
getOutputName in class EscObject
Returns:
The output name (String) value.

getReceivedTotalTimeout

public long getReceivedTotalTimeout()
Gets the received total timeout (long) value.

Returns:
The received total timeout (long) value.
See Also:
setReceivedTotalTimeout(long)

getType

public java.lang.String getType()
Gets the String type property value.

Returns:
Results of the get type (String) value.

open

public void open()
          throws java.io.IOException
Perform the open action method. href="java.io.IOException.html">IOException Thrown if the IOException exception condition occurs.

Specified by:
open in interface ConnectionService
Overrides:
open in class Connection
Throws:
java.io.IOException - IOException.
See Also:
ConnectionService.open()

read

public int read(byte[] bytes)
         throws java.io.IOException
Description copied from class: StreamConnection
Read bytes. the byte array in which to store the read bytes.

Specified by:
read in interface ConnectionService
Overrides:
read in class StreamConnection
Parameters:
bytes - The bytes (byte[]) parameter.
Returns:
Results of the read (int) value.
Throws:
java.io.IOException - IOException.
See Also:
read(byte[],int,int)

read

public int read(byte[] bytes,
                int offset,
                int length)
         throws java.io.IOException
Description copied from class: StreamConnection
Read bytes. the byte array in which to store the read bytes. the offset in b to store the read bytes. the maximum number of bytes to store in b.

Specified by:
read in interface ConnectionService
Overrides:
read in class StreamConnection
Parameters:
bytes - The bytes (byte[]) parameter.
offset - The offset (int) parameter.
length - The length (int) parameter.
Returns:
Results of the read (int) value.
Throws:
java.io.IOException - IOException.
See Also:
read(byte[])

setReceivedTotalTimeout

public void setReceivedTotalTimeout(long timeout)
Parameters:
timeout - The timeout (long) parameter.
See Also:
getReceivedTotalTimeout()

2008-02-07 1.1.0

Copyright (c) 1999, 2008 IBM and others. See license in Legal section. OSGi Framework Version 3.3.1.R33x_v20070828