Skip to content

Commit

Permalink
Merge pull request #962 from frogonwheels/nmea-blank-speed-direction
Browse files Browse the repository at this point in the history
Internal GPS - Handle speed/direction missing from data
  • Loading branch information
dexterbg committed Jan 15, 2024
2 parents 88f5ec5 + d195c0c commit 889abb2
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions vehicle/OVMS.V3/components/ovms_cellular/src/gsmnmea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ void GsmNMEA::IncomingLine(const std::string line)

if (std::getline(sentence, token, ','))
strncpy(time, token.c_str(), 6);
bool speedok = false, directionok = false;
if (std::getline(sentence, token, ','))
{;} // Status
if (std::getline(sentence, token, ','))
Expand All @@ -254,9 +255,17 @@ void GsmNMEA::IncomingLine(const std::string line)
if (std::getline(sentence, token, ','))
{;} // EW
if (std::getline(sentence, token, ','))
speed = atof(token.c_str()) * 1.852;
{
speedok = !token.empty();
if (speedok)
speed = atof(token.c_str()) * 1.852;
}
if (std::getline(sentence, token, ','))
direction = atof(token.c_str());
{
directionok = !token.empty();
if (directionok)
direction = atof(token.c_str());
}
if (std::getline(sentence, token, ','))
strncpy(date, token.c_str(), 6);

Expand All @@ -275,8 +284,11 @@ void GsmNMEA::IncomingLine(const std::string line)
MyTime.Set(TAG, 2, true, tm);
}

*StdMetrics.ms_v_pos_direction = (float) direction;
*StdMetrics.ms_v_pos_gpsspeed = (float) speed;
if (directionok)
*StdMetrics.ms_v_pos_direction = (float) direction;

if (speedok)
*StdMetrics.ms_v_pos_gpsspeed = speed;

// END "RMC" handler
}
Expand Down

0 comments on commit 889abb2

Please sign in to comment.