orca-robotics


INTRODUCTION
Overview
Download and Install
Documentation

REPOSITORY
Interfaces
Drivers
Libraries
Utilities
Software Map

DEVELOPER
Dashboard

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         

nmea.h

00001 /*
00002  * Orca-Robotics Project: Components for robotics 
00003  *               http://orca-robotics.sf.net/
00004  * Copyright (c) 2004-2008  Alex Brooks, Alexei Makarenko, Tobias Kaupp, Duncan Mercer
00005  *
00006  * This copy of Orca is licensed to you under the terms described in
00007  * the LICENSE file included in this distribution.
00008  *
00009  */
00010 
00011 #include <vector>
00012 #include <string>
00013 
00014 #include <hydroportability/sharedlib.h>
00015 
00016 #ifndef _NMEA_H_
00017 #define _NMEA_H_
00018 
00019 
00020 
00021 /*
00022 
00023 for further info:
00024 
00025 http://www.kh-gps.de/nmea-faq.htm
00026 http://vancouver-webpages.com/peter/nmeafaq.txt
00027 
00028 NMEA-0183 sentence
00029 
00030 $aaccc,c--c*hh<CR><LF>
00031 ||    ||   || |
00032 ||    ||   || \________ <CR><LF> - End of sentence (0xOD 0xOA)
00033 ||    ||   |\__________ hh    - Checksum field hexadecimal [optional]
00034 ||    ||   \___________ *     - Checksum delimiter (0x2A) [optional]
00035 ||    |\_______________ c--c  - Data sentence block
00036 ||    \________________ ,     - Field delimiter (0x2c)
00037 |\_____________________ aaccc - Address field/Command
00038 \______________________ $     - Start of sentence
00039 
00040         The optional checksum field consists of a "*" and two hex digits
00041         representing the exclusive OR of all characters between, but not
00042         including, the "$" and "*".  A checksum is required on some
00043         sentences.
00044 
00045 */
00046 
00047 using namespace std;
00048 
00049 namespace hydrogpsutil{
00050 
00051 
00052 class SOEXPORT NmeaException : public std::exception
00053 {
00054 public:
00055 
00056     NmeaException(const char *message)
00057         : message_(message) {}
00058     NmeaException(const std::string &message)
00059         : message_(message) {}
00060     virtual ~NmeaException() throw() {}
00061     virtual const char* what() const throw() { return message_.c_str(); }
00062 
00063 protected:
00064     std::string  message_;
00065 };
00066 
00067 
00068 #define MAX_SENTENCE_LEN 256
00069 
00072     enum{TestChecksum, AddChecksum, DontTestOrAddChecksum};
00073 
00074     class SOEXPORT NmeaMessage{
00075     public:
00076         NmeaMessage();
00077         NmeaMessage(const char *sentence, int testCheckSum = DontTestOrAddChecksum);
00078         ~NmeaMessage();
00079 
00081         bool haveSentence(){return haveSentence_;};
00083         void setSentence(const char *data, int testCheckSum = DontTestOrAddChecksum);
00085         bool haveTokens(){return haveTokens_;};
00087         bool haveValidChecksum(){return checkSumOK_;};    
00089         bool haveTestedChecksum(){return haveCheckSum_;};    
00092         bool testChecksumOk();
00094         const char * sentence(){return sentence_;};
00096         string& getDataToken(int i){return dataTokens_[i];};
00097 
00099         int numDataTokens(){return dataTokens_.size();};
00100         //Tokenise the string that we received
00101         void parseTokens();
00102 
00103     private:
00104         void init();
00105         void addCheckSum();
00107         bool haveSentence_;
00109         bool haveTokens_;
00111         bool haveCheckSum_;
00112         bool checkSumOK_;
00114         char sentence_[MAX_SENTENCE_LEN+1];
00116         vector<string> dataTokens_;
00117         
00118     };
00119 
00120 }
00121 
00122 #endif
 

Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)


Generated for Orca Robotics by  doxygen 1.4.5