Skip to content
This repository has been archived by the owner on May 26, 2024. It is now read-only.

Commit

Permalink
If no valid data has been received yet lon/lat shall be NAN (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
aentinger authored Oct 13, 2020
1 parent 633e415 commit af0acdf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions extras/test/src/test_ArduinoNmeaParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ TEST_CASE("No NMEA message received", "[Parser-01]")
{
ArduinoNmeaParser parser(nullptr);

REQUIRE(parser.longitude() == Approx(52.2637009));
REQUIRE(parser.latitude() == Approx(20.9860468));
REQUIRE(parser.error() == ArduinoNmeaParser::Error::None);
REQUIRE(std::isnan(parser.latitude()) == true);
REQUIRE(std::isnan(parser.longitude()) == true);
REQUIRE(parser.time_utc().hour == -1);
REQUIRE(parser.time_utc().minute == -1);
REQUIRE(parser.time_utc().second == -1);
Expand All @@ -62,8 +63,8 @@ TEST_CASE("RMC message after startup, no satellites", "[Parser-02]")
encode(parser, GPRMC);

REQUIRE(parser.error() == ArduinoNmeaParser::Error::None);
REQUIRE(parser.latitude() == Approx(20.9860468));
REQUIRE(parser.longitude() == Approx(52.2637009));
REQUIRE(std::isnan(parser.latitude()) == true);
REQUIRE(std::isnan(parser.longitude()) == true);
REQUIRE(parser.time_utc().hour == -1);
REQUIRE(parser.time_utc().minute == -1);
REQUIRE(parser.time_utc().second == -1);
Expand All @@ -85,8 +86,8 @@ TEST_CASE("RMC message after startup, time fix available", "[Parser-03]")
encode(parser, GPRMC);

REQUIRE(parser.error() == ArduinoNmeaParser::Error::None);
REQUIRE(parser.latitude() == Approx(20.9860468));
REQUIRE(parser.longitude() == Approx(52.2637009));
REQUIRE(std::isnan(parser.latitude()) == true);
REQUIRE(std::isnan(parser.longitude()) == true);
REQUIRE(parser.time_utc().hour == 14);
REQUIRE(parser.time_utc().minute == 19);
REQUIRE(parser.time_utc().second == 28);
Expand Down
2 changes: 1 addition & 1 deletion src/ArduinoNmeaParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ArduinoNmeaParser::ArduinoNmeaParser(OnRMCUpdateFunc on_rmc_update)
: _error{Error::None}
, _parser_state{ParserState::Synching}
, _parser_buf{{0}, 0}
, _rmc{20.9860468, 52.2637009, NAN, NAN, NAN, {-1, -1, -1, -1}, {-1, -1, -1}}
, _rmc{NAN, NAN, NAN, NAN, NAN, {-1, -1, -1, -1}, {-1, -1, -1}}
, _on_rmc_update{on_rmc_update}
{

Expand Down

0 comments on commit af0acdf

Please sign in to comment.