com.esf.device.serial.comm.service
Interface ISerialCommService


public interface ISerialCommService

This is the primary control class for a SerialComm port. An instance of this class may be operated on by more than one thread. Settings will be those of the last thread to successfully change each particular setting.

Code written to use an ISerialCommSerivce object in a shared mode should make use of syncronization blocks where exclusive transactions are wanted. In most instances, both the OutputStream and the InputStream should be syncronized on, normally with the OutputStream being syncronized first.

Author:
matt.demaree

Field Summary
static java.lang.String SERVICE_NAME
          Reports the class name representing this class.
 
Method Summary
 int getBaudRate()
          Gets the last baud rate set in the most recent setBaudRate() or setAllConfig(mode,baud,parity,stop,bitsPerByte) or setAllConfig(mode,baud,parity,stop,bitsPerByte,warmUp,warmDown).
 int getBitsPerByte()
          Gets the word size set in the most recent setBitsPerByte() or setAllConfig(mode,baud,parity,stop,bitsPerByte) or setAllConfig(mode,baud,parity,stop,bitsPerByte,warmUp,warmDown).
 boolean getCts()
          Gets the current state of the CTS signal.
 boolean getDcd()
          Gets the current state of the DCD signal.
 boolean getDsr()
          Gets the current state of the DSR signal.
 boolean getDtr()
          Gets the current state of the DTR signal.
 SerialCommInputStream getInputStream()
          Get the SerialCommInputStream, which extends the functionality of the standard InputStream.
 int getMode()
          Gets the mode set in the most recent setMode() or setAllConfig(mode,baud,parity,stop,bitsPerByte) or setAllConfig(mode,baud,parity,stop,bitsPerByte,warmUp,warmDown).
 SerialCommOutputStream getOutputStream()
          Get the SerialCommOutputSteam, which extends the functionality of the standard OutputStream.
 int getParity()
          Gets the parity set in the most recent setParity() or setAllConfig(mode,baud,parity,stop,bitsPerByte) or setAllConfig(mode,baud,parity,stop,bitsPerByte,warmUp,warmDown).
 boolean getRi()
          Gets the current state of the RI signal.
 boolean getRts()
          Gets the current state of the RTS signal.
 int getStopBits()
          Gets the stop bit count set in the most recent setStopBits() or setAllConfig(mode,baud,parity,stop,bitsPerByte) or setAllConfig(mode,baud,parity,stop,bitsPerByte,warmUp,warmDown).
 int getWarmDown()
          Gets the warmDown time set in the most recent setMode(mode,warmUp,warmDown) or setAllConfig(mode,baud,parity,stop,bitsPerByte,warmUp,warmDown).
 int getWarmUp()
          Gets the warmUp time set in the most recent setMode(mode,warmUp,warmDown) or setAllConfig(mode,baud,parity,stop,bitsPerByte,warmUp,warmDown).
 void setAllConfig(int mode, int baud, int parity, int stop, int bitsPerByte)
          Validates the passed parameters, stores them and sets the port configuration accordingly.
 void setAllConfig(int mode, int baud, int parity, int stop, int bitsPerByte, int warmUp, int warmDown)
          Validates the passed parameters, stores them and sets the port configuration accordingly.
 void setBaudRate(int baud)
          Validates against the BaudRate and sets the baud rate if valid.
 void setBitsPerByte(int bits)
          Validates against the BitsPerByte and sets the word size if valid.
 void setDtr(boolean state)
          Sets the DTR pin to the selected state.
 void setMode(int mode)
          Validates against the SerialMode and sets the selected mode if valid.
 void setMode(int mode, int warmUp, int warmDown)
          Validates against the SerialMode and sets the selected mode if valid.
 void setParity(int parity)
          Validates against the Parity and sets the parity if valid.
 void setRts(boolean state)
          Sets the RTS pin to the selected state.
 void setStopBits(int stop)
          Validates against the StopBits and sets the number of bits if valid.
 

Field Detail

SERVICE_NAME

static final java.lang.String SERVICE_NAME
Reports the class name representing this class.

Method Detail

getDsr

boolean getDsr()
Gets the current state of the DSR signal. If the DSR signal is not supported on the selected device, this method will always return false.

Returns:
true if DSR active, false inactive

getDcd

boolean getDcd()
Gets the current state of the DCD signal. If the DCD signal is not supported on the selected device, this method will always return false.

Returns:
true if DCD active, false inactive

getCts

boolean getCts()
Gets the current state of the CTS signal. If the CTS signal is not supported on the selected device, this method will always return false.

Returns:
true if CTS active, false inactive

getRi

boolean getRi()
Gets the current state of the RI signal. If the RIR signal is not supported on the selected device, this method will always return false.

Returns:
true if RI active, false inactive

getDtr

boolean getDtr()
Gets the current state of the DTR signal. If the DTR signal is not supported on the selected device, this method will always return false.

Returns:
true if DTR active, false inactive

getRts

boolean getRts()
Gets the current state of the RTS signal. If the RTS signal is not supported on the selected device, this method will always return false.

Returns:
true if RTS active, false inactive

setDtr

void setDtr(boolean state)
Sets the DTR pin to the selected state. If the DTR signal is not supported on the selected device, this method does nothing.

Parameters:
state - true sets DTR active, false inactive

setRts

void setRts(boolean state)
Sets the RTS pin to the selected state. If the RTS signal is not supported on the selected device, this method does nothing.

Note In full handshake modes, RTS may be modified automatically irrespective of the settings attempted by setRts.

Parameters:
state - true sets RTS active, false inactive

setBaudRate

void setBaudRate(int baud)
                 throws ParameterInvalidException
Validates against the BaudRate and sets the baud rate if valid.

Parameters:
baud - validated against the fields in BaudRate class
Throws:
ParameterInvalidException - validation failed

getBaudRate

int getBaudRate()
Gets the last baud rate set in the most recent setBaudRate() or setAllConfig(mode,baud,parity,stop,bitsPerByte) or setAllConfig(mode,baud,parity,stop,bitsPerByte,warmUp,warmDown).

Returns:
baud rate the port should be operating at

setParity

void setParity(int parity)
               throws ParameterInvalidException
Validates against the Parity and sets the parity if valid.

Parameters:
parity - validated against the fields in Parity class
Throws:
ParameterInvalidException - validation failed

getParity

int getParity()
Gets the parity set in the most recent setParity() or setAllConfig(mode,baud,parity,stop,bitsPerByte) or setAllConfig(mode,baud,parity,stop,bitsPerByte,warmUp,warmDown).

Returns:
parity the port should be operating with

setBitsPerByte

void setBitsPerByte(int bits)
                    throws ParameterInvalidException
Validates against the BitsPerByte and sets the word size if valid.

Parameters:
bits - validated against the fields in BitsPerByte class
Throws:
ParameterInvalidException - validation failed

getBitsPerByte

int getBitsPerByte()
Gets the word size set in the most recent setBitsPerByte() or setAllConfig(mode,baud,parity,stop,bitsPerByte) or setAllConfig(mode,baud,parity,stop,bitsPerByte,warmUp,warmDown).

Returns:
word size the port should be operating with

setStopBits

void setStopBits(int stop)
                 throws ParameterInvalidException
Validates against the StopBits and sets the number of bits if valid.

Parameters:
stop - validated against the fields in StopBits class
Throws:
ParameterInvalidException - validation failed

getStopBits

int getStopBits()
Gets the stop bit count set in the most recent setStopBits() or setAllConfig(mode,baud,parity,stop,bitsPerByte) or setAllConfig(mode,baud,parity,stop,bitsPerByte,warmUp,warmDown).

Returns:
stop bit count the port should be operating at

setMode

void setMode(int mode)
             throws ParameterInvalidException
Validates against the SerialMode and sets the selected mode if valid.

Parameters:
mode - validated against the fields in SerialMode class
Throws:
ParameterInvalidException - validation failed

setMode

void setMode(int mode,
             int warmUp,
             int warmDown)
             throws ParameterInvalidException
Validates against the SerialMode and sets the selected mode if valid.

Note This overloaded method should only be used when setting the HalfDuplexRtsExtended mode.

Parameters:
mode - validated against the fields in SerialMode class
warmUp - 0 or greater number of milliseconds to hold RTS active before starting the transmission of data.
warmDown - 0 or greater number of milliseconds to hold RTS active after finisning the data transmission.
Throws:
ParameterInvalidException - validation failed

getMode

int getMode()
Gets the mode set in the most recent setMode() or setAllConfig(mode,baud,parity,stop,bitsPerByte) or setAllConfig(mode,baud,parity,stop,bitsPerByte,warmUp,warmDown).

Returns:
mode the port should be operating in

getWarmUp

int getWarmUp()
Gets the warmUp time set in the most recent setMode(mode,warmUp,warmDown) or setAllConfig(mode,baud,parity,stop,bitsPerByte,warmUp,warmDown).

Returns:
warm up time the port should be using if operating in HalfDuplexRtsExtended mode.

getWarmDown

int getWarmDown()
Gets the warmDown time set in the most recent setMode(mode,warmUp,warmDown) or setAllConfig(mode,baud,parity,stop,bitsPerByte,warmUp,warmDown).

Returns:
warm down time the port should be using if operating in HalfDuplexRtsExtended mode.

setAllConfig

void setAllConfig(int mode,
                  int baud,
                  int parity,
                  int stop,
                  int bitsPerByte)
                  throws ParameterInvalidException
Validates the passed parameters, stores them and sets the port configuration accordingly.

For the HalfDuplexRtsExtend mode, the warmUp and warmDown values are set to 0. The open(mode,baud,parity,stop,bitsPerByte,warmUp,WarmDown) method should be used.

Parameters:
mode - see setMode(mode) or setMode(mode,warmUp,warmDown)
baud - see setBaudRate(baud)
parity - see setParity(parity)
stop - see setStopBits(stop)
bitsPerByte - see setBitsPerByte(bitsPerByte)
Throws:
ParameterInvalidException - thrown on the first invalid parameter encountered, parameter indicated in the exception

setAllConfig

void setAllConfig(int mode,
                  int baud,
                  int parity,
                  int stop,
                  int bitsPerByte,
                  int warmUp,
                  int warmDown)
                  throws ParameterInvalidException
Validates the passed parameters, stores them and sets the port configuration accordingly.

Parameters:
mode - see setMode(mode,warmUp,warmDown)
baud - see setBaudRate(baud)
parity - see setParity(parity)
stop - see setStopBits(stop)
bitsPerByte - see setBitsPerByte(bitsPerByte)
warmUp - see setMode(mode,warmUp,warmDown)
warmDown - see setMode(mode,warmUp,warmDown)
Throws:
ParameterInvalidException - thrown on the first invalid parameter encountered, parameter indicated in the exception

getInputStream

SerialCommInputStream getInputStream()
                                     throws java.io.IOException
Get the SerialCommInputStream, which extends the functionality of the standard InputStream.

Returns:
SerialCommInputStream to manage incoming data
Throws:
java.io.IOException - internal error aquiring base InputStream

getOutputStream

SerialCommOutputStream getOutputStream()
                                       throws java.io.IOException
Get the SerialCommOutputSteam, which extends the functionality of the standard OutputStream.

Returns:
SerialCommOutputStream to manage outgoing data
Throws:
java.io.IOException - internal error aquiring base InputStream