Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process GSA sentence data #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,11 @@ void loop(void)
ledState = !ledState;
digitalWrite(LED_BUILTIN, ledState);

// Output GPS information from previous second
console.print("Valid fix: ");
console.println(nmea.isValid() ? "yes" : "no");
// Output GPS information from previous second
Serial.print ("Valid fix: ");
Serial.print (nmea.isValid () ? "yes " : "no ");
Serial.print (nmea.getFix () == 1 ? "No Fix" : nmea.getFix () == 2 ? "2D" : "3D");
Serial.println (nmea.getAutofix () == 'A' ? " Auto" : " Manual");

console.print("Nav. system: ");
if (nmea.getNavSystem())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,11 @@ void loop(void)
ledState = !ledState;
digitalWrite(LED_BUILTIN, ledState);

// Output GPS information from previous second
console.print("Valid fix: ");
console.println(nmea.isValid() ? "yes" : "no");
// Output GPS information from previous second
Serial.print ("Valid fix: ");
Serial.print (nmea.isValid () ? "yes " : "no ");
Serial.print (nmea.getFix () == 1 ? "No Fix" : nmea.getFix () == 2 ? "2D" : "3D");
Serial.println (nmea.getAutofix () == 'A' ? " Auto" : " Manual");

console.print("Nav. system: ");
if (nmea.getNavSystem())
Expand Down
6 changes: 4 additions & 2 deletions examples/demo/demo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@ void loop(void)
digitalWrite(LED_BUILTIN, ledState);

// Output GPS information from previous second
console.print("Valid fix: ");
console.println(nmea.isValid() ? "yes" : "no");
Serial.print ("Valid fix: ");
Serial.print (nmea.isValid () ? "yes " : "no ");
Serial.print (nmea.getFix () == 1 ? "No Fix" : nmea.getFix () == 2 ? "2D" : "3D");
Serial.println (nmea.getAutofix () == 'A' ? " Auto" : " Manual");

console.print("Nav. system: ");
if (nmea.getNavSystem())
Expand Down
16 changes: 16 additions & 0 deletions src/MicroNMEA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ bool MicroNMEA::process(char c)
return processGGA(data);
else if (strcmp(&_messageID[0], "RMC") == 0)
return processRMC(data);
else if (strcmp (&_messageID[0], "GSA") == 0)
return processGSA (data);
else if (_unknownSentenceHandler)
(*_unknownSentenceHandler)(*this);
}
Expand Down Expand Up @@ -284,6 +286,20 @@ const char* MicroNMEA::parseDate(const char* s)
return skipField(s + 6);
}

bool MicroNMEA::processGSA (const char* s) {
_autofix = *s;
s=s+2; // Skip fix and comma
_fix = parseFloat (s, 0, &s);
for (int i = 0; i < 12; i++) {
// Skip 12 satellite ID fields
s = skipField (s);
}
_pdop = parseFloat (s, 1, &s);
_hdop = parseFloat (s, 1, &s);
_vdop = parseFloat (s, 1, &s);

return true;
}

bool MicroNMEA::processGGA(const char *s)
{
Expand Down
25 changes: 24 additions & 1 deletion src/MicroNMEA.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,32 @@ class MicroNMEA {
uint8_t getNumSatellites(void) const {
return _numSat;
}

// Fix selection (A = Auto, M = Manual)
char getAutofix (void) const {
return _autofix;
}

// Type of fix (1= no fix, 2= 2D, 3= 3D)
uint8_t getFix (void) const {
return _fix;
}

// Dilution of precision, in tenths
uint8_t getPDOP (void) const {
return _pdop;
}

// Horizontal dilution of precision, in tenths
uint8_t getHDOP(void) const {
return _hdop;
}

// Vertical dilution of precision, in tenths
uint8_t getVDOP (void) const {
return _vdop;
}

// Validity of latest fix
bool isValid(void) const {
return _isValid;
Expand Down Expand Up @@ -154,6 +174,7 @@ class MicroNMEA {
const char* parseDate(const char* s);

bool processGGA(const char *s);
bool processGSA (const char* s);
bool processRMC(const char* s);

private:
Expand All @@ -178,7 +199,9 @@ class MicroNMEA {
uint16_t _year;
uint8_t _month, _day, _hour, _minute, _second, _hundredths;
uint8_t _numSat;
uint8_t _hdop;
uint8_t _hdop, _vdop, _pdop;
char _autofix;
uint8_t _fix;

void (*_badChecksumHandler)(const MicroNMEA &nmea);
void (*_unknownSentenceHandler)(const MicroNMEA &nmea);
Expand Down