org.dinopolis.gpstool.gpsinput
Class GPSSerialDevice

java.lang.Object
  extended byorg.dinopolis.gpstool.gpsinput.GPSSerialDevice
All Implemented Interfaces:
GPSDevice

public class GPSSerialDevice
extends java.lang.Object
implements GPSDevice

Changes for J2ME implementation: Added DEFAULT_PORT_NAME_PPC Deleted include javax.comm.SerialPort Added javax.microedition.io.StreamConnection Added javax.microedition.io.Connector

Author:
Juangui Jordan Aldasoro

Field Summary
static java.lang.String PORT_NAME_KEY
           
static java.lang.String PORT_SPEED_KEY
           
static java.lang.String RAW_DATA_LOG_FILENAME_KEY
           
 
Constructor Summary
GPSSerialDevice()
           
 
Method Summary
 void close()
          Closes the connection to the GPSDevice.
 java.io.InputStream getInputStream()
          Returns an input stream from the gps device.
 java.io.OutputStream getOutputStream()
          Returns an output stream from the gps device.
 void init(java.util.Hashtable environment)
          Initialize the GPSDevice and hand over all information needed for the specific GPSDevice to opens the connection.
 void open()
          Opens the gps device (e.g. serial connection to gps-receiver or file containing logging information from a gps-receiver).
 void setSerialPortSpeed(int speed)
          Sets the speed for the serial port.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PORT_NAME_KEY

public static final java.lang.String PORT_NAME_KEY
See Also:
Constant Field Values

PORT_SPEED_KEY

public static final java.lang.String PORT_SPEED_KEY
See Also:
Constant Field Values

RAW_DATA_LOG_FILENAME_KEY

public static final java.lang.String RAW_DATA_LOG_FILENAME_KEY
See Also:
Constant Field Values
Constructor Detail

GPSSerialDevice

public GPSSerialDevice()
Method Detail

init

public void init(java.util.Hashtable environment)
          throws GPSException
Initialize the GPSDevice and hand over all information needed for the specific GPSDevice to opens the connection.

Specified by:
init in interface GPSDevice
Parameters:
environment - contains all informations needed to initialize the gps device.
Throws:
GPSException - if the initialization was not successfull, e.g. some information in the environment is missing.

open

public void open()
          throws GPSException
Opens the gps device (e.g. serial connection to gps-receiver or file containing logging information from a gps-receiver).

Specified by:
open in interface GPSDevice
Throws:
GPSException - if the opening of the device was not successfull.

close

public void close()
           throws GPSException
Closes the connection to the GPSDevice.

Specified by:
close in interface GPSDevice
Throws:
GPSException - if closing the device was not successfull.

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Returns an input stream from the gps device. If the port is unidirectional and doesn't support receiving data or open was not called before, then getInputStream returns null.

Specified by:
getInputStream in interface GPSDevice
Returns:
an input stream from the gps device.
Throws:
java.io.IOException

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Returns an output stream from the gps device. If the port is unidirectional and doesn't support receiving data or open was not called before, then getOutputStream returns null.

Specified by:
getOutputStream in interface GPSDevice
Returns:
an output stream from the gps device.
Throws:
java.io.IOException

setSerialPortSpeed

public void setSerialPortSpeed(int speed)
                        throws java.io.IOException
Sets the speed for the serial port.

Parameters:
speed - the speed to set (e.g. 4800, 9600, 19200, 38400, ...)
Throws:
java.io.IOException