com.ibm.manplato.Transport
Class ModemTransport

java.lang.Object
  |
  +--com.ibm.manplato.Transport.SLPTransportInterface
        |
        +--com.ibm.manplato.Transport.ModemTransport

public class ModemTransport
extends SLPTransportInterface

Modem Communications Transport. This transport, based on the Sun Communications API provides additional connection and configuration methods required for synchronizing through a modem connection. It assumes a modem with a standard response set.

Version:
$Rev$-$Date: 2001/03/15 16:55:33 $$State: Exp $
Author:
File Created By: Brad BARCLAY <bbarclay@ca.ibm.com>, Last Modified By: $Author: Yaztromo $

Field Summary
protected  boolean connected
           
protected  java.io.DataInputStream dis
           
protected  java.io.DataOutputStream dos
           
protected static int fixedSpeed
           
protected  java.lang.String initString
           
protected  boolean modemConnected
           
protected  javax.comm.CommPortIdentifier port
           
protected  javax.comm.SerialPort ser
           
 
Fields inherited from class com.ibm.manplato.Transport.SLPTransportInterface
portName
 
Constructor Summary
ModemTransport(java.lang.String portName, java.lang.String init)
          Creates a new instance of the ModemTransport class.
 
Method Summary
 void close()
          Closes the Java COMM API port.
 void disconnect()
          This method is used to flag that the modem is disconnected.
protected  void finalize()
          Finalizes this ModemTransport object by closing it's connection.
 void flush()
          Flushes the input buffer of any remaining data.
 int getFixedSpeed()
          Returns the fixed serial port speed being used to interface between the host and the modem.
 java.lang.String getInitString()
          Returns the initialization string being used by this transport.
static java.lang.String getName()
          Returns the name of this Transport Interface.
static java.lang.String[] getPortNames()
          Returns an array of Strings representing the names of available ports.
 void open()
          Opens a read/write connection to the implemented transport.
 byte readByte()
          Read a single byte from the Java COMM API port.
static void setFixedSpeed(int newValue)
          Sets the fixed serial speed.
 void setInitString(java.lang.String newValue)
          Sets the modem init string to use with this transport.
 void setSpeed(int speed)
          Sets the speed of the underlying Java COMM API port.
 void writeBytes(byte[] data)
          Writes an array of bytes to the Java COMM API port.
 
Methods inherited from class com.ibm.manplato.Transport.SLPTransportInterface
getSelectedPortName
 
Methods inherited from class java.lang.Object
, clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

port

protected javax.comm.CommPortIdentifier port

ser

protected javax.comm.SerialPort ser

dis

protected java.io.DataInputStream dis

dos

protected java.io.DataOutputStream dos

connected

protected boolean connected

modemConnected

protected boolean modemConnected

initString

protected java.lang.String initString

fixedSpeed

protected static int fixedSpeed
Constructor Detail

ModemTransport

public ModemTransport(java.lang.String portName,
                      java.lang.String init)
               throws java.lang.Exception
Creates a new instance of the ModemTransport class.
Parameters:
portName - the name of the port to open.
init - the modem initialization string. If null, this string defaults to "ATZ".
Throws:
java.lang.Exception - any exception thrown by the underlying serial handler.
Method Detail

close

public void close()
           throws java.lang.Exception
Closes the Java COMM API port.
Overrides:
close in class SLPTransportInterface
Throws:
java.lang.Exception - any exception encountered is rethrown.

disconnect

public void disconnect()
This method is used to flag that the modem is disconnected. NOTE: this method does not actually cause the modem to hang up. It is currently assumed that the Palm will drop the connection, and that the modem hardware will automatically hangup in response.

finalize

protected void finalize()
                 throws java.lang.Throwable
Finalizes this ModemTransport object by closing it's connection.
Overrides:
finalize in class java.lang.Object

flush

public void flush()
           throws java.io.IOException
Flushes the input buffer of any remaining data.
Overrides:
flush in class SLPTransportInterface
Throws:
java.io.IOException - thrown when a problem occurs with flushing the stream.

getFixedSpeed

public int getFixedSpeed()
Returns the fixed serial port speed being used to interface between the host and the modem.
Returns:
the serial speed used between the host and the modem.

getInitString

public java.lang.String getInitString()
Returns the initialization string being used by this transport.
Returns:
The init string being used by this transport.

getName

public static java.lang.String getName()
Returns the name of this Transport Interface. This method will return a string containing the name of this transport interface. This is used when searching for and selecting from one of many available transport interfaces that are installed on the system.
Returns:
the name of this transport interface.

getPortNames

public static java.lang.String[] getPortNames()
Returns an array of Strings representing the names of available ports. This method will return to the caller an array of strings representing the serial ports available on this system.
Returns:
an array of String representing the names of the available ports.

open

public void open()
          throws java.lang.Exception
Opens a read/write connection to the implemented transport. This method should open the transport device being implemented using default parameters.
Overrides:
open in class SLPTransportInterface
Throws:
java.io.IOException - thrown when a problem occurs with flushing the stream.

readByte

public byte readByte()
Read a single byte from the Java COMM API port.
Overrides:
readByte in class SLPTransportInterface

setFixedSpeed

public static void setFixedSpeed(int newValue)
Sets the fixed serial speed.
Parameters:
newValue - the serial speed to fix the port to.

setInitString

public void setInitString(java.lang.String newValue)
Sets the modem init string to use with this transport.
Parameters:
newValue - the init string to use with this transport object.

setSpeed

public void setSpeed(int speed)
              throws java.lang.Exception
Sets the speed of the underlying Java COMM API port.
Overrides:
setSpeed in class SLPTransportInterface
Parameters:
speed - The speed to set the transport to.
Throws:
java.io.IOException - thrown when a problem occurs with flushing the stream.

writeBytes

public void writeBytes(byte[] data)
Writes an array of bytes to the Java COMM API port.
Overrides:
writeBytes in class SLPTransportInterface
Parameters:
data - the bytes to be written to the serial port.