GithubHelp home page GithubHelp logo

Location: INVALID about tinygpsplus HOT 3 OPEN

Nikitanagar avatar Nikitanagar commented on August 16, 2024
Location: INVALID

from tinygpsplus.

Comments (3)

TD-er avatar TD-er commented on August 16, 2024 1

Nope, NOT calling serial.available() is faster as you need to query something that's for sure a call to some hardware.
And it might be possible you keep on running longer when checking again for new available bytes, where in the first code example you only check this once and just assume no more bytes have entered the serial buffer.

from tinygpsplus.

JasonPittenger avatar JasonPittenger commented on August 16, 2024

I see you define the baud for GPS, but that is never used again.

static const uint32_t GPSBaud = 9600;

That's fine, because you later initialize two serial ports at 9600 baud.
Serial.begin(9600);
Serial2.begin(9600);

It looks like Serial is your debugging port, based on usage in your code.
I assume then that Serial2 is your GPS serial port.
I only see you reading it inside the function display(), which is called in loop()

void display()
{
gps.encode(Serial2.read());
}

This will not work.
The read() function returns the first byte of incoming serial data available (or -1 if no data is available).
This means you're only grabbing a single byte and trying to display the data.
Instead, put this inside loop()

uint16_t GPSbytesAvailable;
GPSbytesAvailable = Serial2.available();
if(GPSbytesAvailable)
{
	while(GPSbytesAvailable--)
	{
		gps.encode(Serial2.read());
	}
}

or

while (Serial2.available() > 0)
{
	gps.encode(Serial2.read);
}

The first code is a little faster because it doesn't repeatedly call Serial2.available();

from tinygpsplus.

svdrummer avatar svdrummer commented on August 16, 2024

I was wondering why "GPSbytesAvailable--" is faster?

from tinygpsplus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.