Skip to content

Tips to improve stability #3

@dotMorten

Description

@dotMorten

Found two issues and wanted to share the findings:

  • I know the NMEA spec specifies 82 character max, however when using a high-accuracy GPS which needs a lot more digits to represent the precision, you go beyond the limit. I'd suggest making the buffer size configurable beyond 77. (100 works just fine for me).
  • I was getting A LOT of parsing errors. I couldn't reproduce in a console app, making me suspect the buffer. I found the following approach to run way more stable:

in setup() set timeout pretty low:

Serial.setTimeout(10);

In the loop reach in chunks:

char buf[1024];
int readCount;
void loop()
{
  if (Serial1.available()) {
    while((readCount = Serial.readBytes(buf, 1024)) > 0)
    {
      for(int i=0;i<readCount;i++)
        parser << buf[i];
    }
 }

With these two changes, all my parser errors went away.
You might want to update the doc to suggest the read approach. Might only be an issue on slow arduino's?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions