Commit 1faba76a authored by Lorenz Meier's avatar Lorenz Meier

Minor state machine fixes to reboot / timestamp detection

parent 8f2ae9ef
...@@ -1535,6 +1535,7 @@ quint64 UAS::getUnixTimeFromMs(quint64 time) ...@@ -1535,6 +1535,7 @@ quint64 UAS::getUnixTimeFromMs(quint64 time)
*/ */
quint64 UAS::getUnixTime(quint64 time) quint64 UAS::getUnixTime(quint64 time)
{ {
bool isNull = (time == 0);
// Check if the offset estimation likely went wrong // Check if the offset estimation likely went wrong
// and we're talking to a new instance / the system // and we're talking to a new instance / the system
// has rebooted. Only reset if this is consistent. // has rebooted. Only reset if this is consistent.
...@@ -1542,7 +1543,7 @@ quint64 UAS::getUnixTime(quint64 time) ...@@ -1542,7 +1543,7 @@ quint64 UAS::getUnixTime(quint64 time)
{ {
onboardTimeOffsetInvalidCount++; onboardTimeOffsetInvalidCount++;
} }
else if (lastNonNullTime < time) else if (time != 0 && lastNonNullTime < time)
{ {
onboardTimeOffsetInvalidCount = 0; onboardTimeOffsetInvalidCount = 0;
} }
...@@ -1554,7 +1555,6 @@ quint64 UAS::getUnixTime(quint64 time) ...@@ -1554,7 +1555,6 @@ quint64 UAS::getUnixTime(quint64 time)
onboardTimeOffsetInvalidCount = 0; onboardTimeOffsetInvalidCount = 0;
} }
quint64 ret = 0; quint64 ret = 0;
if (attitudeStamped) if (attitudeStamped)
{ {
...@@ -1599,6 +1599,11 @@ quint64 UAS::getUnixTime(quint64 time) ...@@ -1599,6 +1599,11 @@ quint64 UAS::getUnixTime(quint64 time)
// a Unix epoch timestamp. Do nothing. // a Unix epoch timestamp. Do nothing.
ret = time/1000; ret = time/1000;
} }
if (!isNull) {
lastNonNullTime = time;
}
return ret; return ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment