|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object courselog.gpsutils.SerialGPSConnection
public class SerialGPSConnection
Handles a GPS connected to a Serial port. Generates Measurements (MeasuredPoint) each time a new measurement is issued by the receiver. Handles a listener to the connection to receive all new points. Configuration of the device is planned but ot implemented : - enable differential measurements (WAAS or EGNOS) when available - initialize for fast re-start - power saving mode
Field Summary | |
---|---|
protected static byte[] |
bGPGGA
Identifier of a GGA NMEA sentence ("GPGGA"). |
protected static byte[] |
bGPGSV
Identifier of a GSV NMEA sentence ("GPGSV"). |
protected static byte[] |
bGPRMC
Identifier of a RMC NMEA sentence ("GPRMC"). |
static int |
BUFFMAX
Maximum serial port buffer size (256 chars). |
MeasuredPoint |
currentPoint
Current point received from the GPS. |
ewe.io.SerialPortOptions |
currentSPO
Port options that were used to open the serial port to the GPS. |
int |
debugCounter
Debugging counter to verify problems with connections |
protected static java.lang.String |
fGPGGA
Values sequence in a GGA sentence ("VVCVCIIVVCVCVI"). |
protected static java.lang.String |
fGPGSV
Values sequence in a GSV sentence ("IIIIIIIIIIIIIIIIIII"). |
protected static java.lang.String |
fGPRMC
Values sequence in a RMC sentence ("VCVCVCVVIVVC"). |
ewe.io.Stream |
inGPS
Input reader of the GPS serial port. |
static boolean |
isEmulating
Flag indicating that the receive should read from a "tmpGPSLog.txt" file in order to emulate the presence of a receiver. |
static boolean |
isLogging
Flag indicating that the receiver should log its data. |
static java.lang.String |
logFileName
For debugging, GPS data may be logged into a file. |
protected ewe.ui.EventListener |
myListener
Listener to this receiver. |
protected ReceiverEvent |
myPointEvent
Event passed to listeners when a new point is decoded. |
protected ReceiverEvent |
myStatusEvent
Event passed to listeners when the status of the receiver changes. |
static int |
NBLINESINBUFFER
Number of lines to buffer before parsing NMEA. |
static int |
NBSATMAX
Maximum number of satellites status to record (20). |
protected ewe.io.FileOutputStream |
outLog
Stream to output the logged GPS data to. |
ewe.sys.mThread |
reader
Thread reading the GPS receiver values and issueing events when a new point is decoded. |
int |
status
Status of the receiver (one of STATUS_XXX values). |
static int |
STATUS_GPSLOST
GPs is connected via the serial port but the GPS produces no valid fix. |
static int |
STATUS_NOK
GPS receiver does not transmit through the serial port. |
static int |
STATUS_OK
Receiver status is fine! |
char[] |
vNMEACar
Array containing single char values decoded from NMEA (20 char). |
int[] |
vNMEAInt
Array containing integer values decoded from NMEA (20 ints). |
double[] |
vNMEAVal
Array containing double values decoded from NMEA (20 double). |
int[] |
vSatAz
State of the GPS, azimtuhs of the satellites currently available. |
int[] |
vSatEl
State of the GPS, elevations of the satellites currently available. |
int[] |
vSatPRN
State of the GPS, idenfiers of the satellites currently available. |
int[] |
vSatSNR
State of the GPS, signal to noise of the satellites currently available. |
Constructor Summary | |
---|---|
SerialGPSConnection(ewe.io.SerialPortOptions spo,
ewe.ui.EventListener listener)
Creates a new instance of SerialGPSConnection |
Method Summary | |
---|---|
void |
analyseNMEAValues(byte[] b,
int iSt,
int iEnd)
When a valid sentence is received, analyses it to update the current point values. |
void |
close()
Stop the GPS reception. |
static SerialGPSConnection |
getAnActiveSerialGPSConnection(ewe.io.SerialPortOptions spo,
ewe.ui.EventListener listener)
Factory for serial connection creating an active connection. |
static ewe.io.SerialPortOptions |
getDefaultPortOptions()
Provides a set of default port options. |
static java.lang.String |
getPortOptionsAsString(ewe.io.SerialPortOptions forSPO)
Format forSPO in a string that will be readable later. |
static ewe.io.SerialPortOptions |
getPortOptionsFromString(java.lang.String sO)
Interprets a string with port name, rate, etc, into serial port options. |
java.lang.String |
getUTCFromGPS()
Get UTC provided by the GPS receiver. |
boolean |
isCheckSumOK(int valChk,
byte[] charChk,
int idxChk)
Verify checksum of an NMEA sentence. |
int |
parseNMEAContent(byte[] b,
int len)
Reads in the buffer to find NMEA sentences and analyses them in case there are. |
void |
run()
Method reading the GPS actived in thread reader. |
void |
setListener(ewe.ui.EventListener list)
Sets the listener of this receiver. |
boolean |
startLog()
Start to log received data fom the serial port. |
boolean |
startReading()
Starts the GPS reading thread myReader. |
void |
stopLog()
Stops logging GPS data. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int STATUS_OK
public static final int STATUS_GPSLOST
public static final int STATUS_NOK
public static int BUFFMAX
public static int NBLINESINBUFFER
public static int NBSATMAX
protected static final byte[] bGPGGA
protected static final java.lang.String fGPGGA
protected static final byte[] bGPRMC
protected static final java.lang.String fGPRMC
protected static final byte[] bGPGSV
protected static final java.lang.String fGPGSV
public static java.lang.String logFileName
public static boolean isLogging
public static boolean isEmulating
public int debugCounter
protected ewe.io.FileOutputStream outLog
public MeasuredPoint currentPoint
public int status
public ewe.sys.mThread reader
public ewe.io.SerialPortOptions currentSPO
public ewe.io.Stream inGPS
protected ReceiverEvent myPointEvent
protected ReceiverEvent myStatusEvent
protected ewe.ui.EventListener myListener
public int[] vNMEAInt
public double[] vNMEAVal
public char[] vNMEACar
public int[] vSatPRN
public int[] vSatAz
public int[] vSatEl
public int[] vSatSNR
Constructor Detail |
---|
public SerialGPSConnection(ewe.io.SerialPortOptions spo, ewe.ui.EventListener listener)
spo
- Serial port options to use for connection to the GPS.listener
- Listener which will receive the state and points events.Method Detail |
---|
public static SerialGPSConnection getAnActiveSerialGPSConnection(ewe.io.SerialPortOptions spo, ewe.ui.EventListener listener)
spo
- Serial ort options to use for the connectionlistener
- Listener for GPS events
public boolean startReading()
public void run()
run
in interface java.lang.Runnable
public int parseNMEAContent(byte[] b, int len)
b
- Buffer to read in.len
- Length of usable chars in the buffer, starting at 0.
public void analyseNMEAValues(byte[] b, int iSt, int iEnd)
GGA : get UTC, lat, lon, nbsats, alt, hdop RMC : get date, speed, heading GSV : updates satellite status (no event is generated but data is available for polling).When a point is fully analysed, generate a ReceiverEvent. If fix is not valid, modify status accordingly.
b
- Buffer to read in.iSt
- Index of starting location of the NMEA sentence.iEnd
- Index of ending location of the sentence.public void close()
public boolean startLog()
public void stopLog()
public boolean isCheckSumOK(int valChk, byte[] charChk, int idxChk)
valChk
- Computed checksum of the sentence.charChk
- Hexadecimal value of the checksum read from the port.idxChk
- Index of the checksum value in charChk.
public static ewe.io.SerialPortOptions getPortOptionsFromString(java.lang.String sO)
sO
- String containing the description of the options.
public static ewe.io.SerialPortOptions getDefaultPortOptions()
public static java.lang.String getPortOptionsAsString(ewe.io.SerialPortOptions forSPO)
forSPO
- Options to format.
public java.lang.String getUTCFromGPS()
public void setListener(ewe.ui.EventListener list)
list
- Listener to dispatch events to.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |