mikalhart / TinyGPSPlus

A new, customizable Arduino NMEA parsing library
http://arduiniana.org
1.1k stars 494 forks source link

Error in example code? #22

Closed rkyleg closed 7 years ago

rkyleg commented 7 years ago

In all of the examples, the code wraps gps.encode in an if statement.

if (gps.encode(ss.read()))

However, the encode function always returns false in each case statement. I wasn't getting any results using the example code, but when I removed the if statement, I got valid gps sentences returned.

bool TinyGPSPlus::encode(char c)

cmaglie commented 7 years ago

However, the encode function always returns false in each case statement. I wasn't getting any results using the example code, but when I removed the if statement, I got valid gps sentences returned.

the examples are correct the encode function may return true, but only when a complete sentence is received:

https://github.com/mikalhart/TinyGPSPlus/blob/master/TinyGPS%2B%2B.cpp#L77