An implementation of the Sirf Binary and NMEA Protocol for gps devices using the SiRFstarIII chipset

Committer:
p3p
Date:
Thu Jun 28 21:17:29 2012 +0000
Revision:
0:43da35949666
update to baud selection

Who changed what in which revision?

UserRevisionLine numberNew contents of line
p3p 0:43da35949666 1 #ifndef SIRF_PROTOCOL_NMEA_PACKETS
p3p 0:43da35949666 2 #define SIRF_PROTOCOL_NMEA_PACKETS
p3p 0:43da35949666 3
p3p 0:43da35949666 4 #include <string>
p3p 0:43da35949666 5 #include <vector>
p3p 0:43da35949666 6 #include <map>
p3p 0:43da35949666 7
p3p 0:43da35949666 8 namespace SirfStarIII {
p3p 0:43da35949666 9
p3p 0:43da35949666 10 namespace NMEAPacket {
p3p 0:43da35949666 11
p3p 0:43da35949666 12 enum PacketNames{
p3p 0:43da35949666 13 ID_GGA, //Time, position and fix type data.
p3p 0:43da35949666 14 ID_GLL, //Latitude, longitude, UTC time of position fix and status.
p3p 0:43da35949666 15 ID_GSA, //GPS receiver operating mode, satellites used in the position solution, and DOP values.
p3p 0:43da35949666 16 ID_GSV, //The number of GPS satellites in view satellite ID numbers, elevation, azimuth, and SNR values.
p3p 0:43da35949666 17 ID_MSS, //Signal-to-noise ratio, signal strength, frequency, and bit rate from a radio-beacon receiver.
p3p 0:43da35949666 18 ID_RMC, //Time, date, position, course and speed data.
p3p 0:43da35949666 19 ID_VTG, //Course and speed information relative to the ground.
p3p 0:43da35949666 20 ID_ZDA, //PPS timing message (synchronized to PPS).
p3p 0:43da35949666 21 ID_150 //OK to send message.
p3p 0:43da35949666 22 };
p3p 0:43da35949666 23
p3p 0:43da35949666 24 class NMEAPacket {
p3p 0:43da35949666 25 public:
p3p 0:43da35949666 26 NMEAPacket() {}
p3p 0:43da35949666 27 virtual ~NMEAPacket() {}
p3p 0:43da35949666 28
p3p 0:43da35949666 29 std::vector<std::string> _fields;
p3p 0:43da35949666 30
p3p 0:43da35949666 31 void interpretData(SimpleSerialProtocol::Packet* packet) {
p3p 0:43da35949666 32 std::string raw_data( (char *) packet->_data);
p3p 0:43da35949666 33 std::string temp;
p3p 0:43da35949666 34 while (raw_data.find(",", 0) != std::string::npos) {
p3p 0:43da35949666 35 size_t pos = raw_data.find(",", 0);
p3p 0:43da35949666 36 temp = raw_data.substr(0, pos);
p3p 0:43da35949666 37 raw_data.erase(0, pos + 1);
p3p 0:43da35949666 38 if (temp.size() == 0) {
p3p 0:43da35949666 39 temp = "0";
p3p 0:43da35949666 40 }
p3p 0:43da35949666 41 _fields.push_back(temp);
p3p 0:43da35949666 42 }
p3p 0:43da35949666 43 _fields.push_back(raw_data);
p3p 0:43da35949666 44 }
p3p 0:43da35949666 45
p3p 0:43da35949666 46 };
p3p 0:43da35949666 47
p3p 0:43da35949666 48 }
p3p 0:43da35949666 49
p3p 0:43da35949666 50 }
p3p 0:43da35949666 51
p3p 0:43da35949666 52 #endif