com.adventnet.cli.serial
Class SerialCommProviderImpl

java.lang.Object
  |
  +--com.adventnet.cli.serial.SerialCommProviderImpl

public class SerialCommProviderImpl
extends java.lang.Object
implements CLITransportProvider

The Serial Port transport implementation for the CLITransportProvider for communicating with the CLI device through Serial Port (or RS232 interface).


Fields inherited from interface com.adventnet.cli.transport.CLITransportProvider
STREAM_CLOSED
 
Constructor Summary
SerialCommProviderImpl()
          Creates an Instance of Serial Communications provider.
 
Method Summary
 void close()
          This closes the Serial port connection to device.
 void open(CLIProtocolOptions options)
          Opens a connection through the serial port with the device.
 CLIMessage read()
          Receives the CLI message from the opened Serial Port connection.
 void write(CLIMessage msg)
          Sends the command in the CLIMessage using the opened Serial Port connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SerialCommProviderImpl

public SerialCommProviderImpl()
Creates an Instance of Serial Communications provider. API users need not instantiate this class since it is instantiated internally by the CLIResourceManager.
Method Detail

open

public void open(CLIProtocolOptions options)
          throws java.lang.Exception
Opens a connection through the serial port with the device. Parameters like the Baud rate, stop bits, parity are taken from the CLIProtocolOptions parameter that is passed to the method.
Specified by:
open in interface CLITransportProvider
Parameters:
cliProtOpt - the CLIProtocolOptions with the Serial port parameters.
Throws:
java.lang.Exception - thrown when an error occurs while trying to open the connection to the device. This could be a result of an incorrect Serial Port parameter.

close

public void close()
           throws java.lang.Exception
This closes the Serial port connection to device.
Specified by:
close in interface CLITransportProvider
Throws:
java.lang.Exception - if any error occurs during the closing of the Serial connection.

write

public void write(CLIMessage msg)
           throws java.io.IOException
Sends the command in the CLIMessage using the opened Serial Port connection. The CLI command to be sent will be present in a byte array in the CLIMessage argument.
Specified by:
write in interface CLITransportProvider
Parameters:
cliMsg - the CLIMessage that has to be sent. The CLI command (as a string) is obtained by calling cliMsg.getData().
Throws:
java.io.IOException - if error occurs while writing the data.

read

public CLIMessage read()
                throws java.io.IOException
Receives the CLI message from the opened Serial Port connection. The CLI response is read into the CLIMessage and returned.
Specified by:
read in interface CLITransportProvider
Returns:
CLIMessage that is read.
Throws:
java.io.IOException - if error occurs while reading the data through the telnet connection.


Copyright (c)AdventNet Inc., 1996-2003