mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
mavlink: don't send wrong time
This prevents the autopilot from sending an invalid unix timestamp. Usually, if no time is set yet by a GPS, the date is somehow set to 2000-01-01, therefore we can ignore anything earlier than 2001.
This commit is contained in:
parent
df7364d2e2
commit
3917eb2d00
@ -1225,9 +1225,14 @@ protected:
|
||||
msg.time_boot_ms = hrt_absolute_time() / 1000;
|
||||
msg.time_unix_usec = (uint64_t)tv.tv_sec * 1000000 + tv.tv_nsec / 1000;
|
||||
|
||||
mavlink_msg_system_time_send_struct(_mavlink->get_channel(), &msg);
|
||||
// If the time is before 2001-01-01, it's probably the default 2000
|
||||
// and we don't need to bother sending it because it's definitely wrong.
|
||||
if (msg.time_unix_usec > 978307200000000) {
|
||||
mavlink_msg_system_time_send_struct(_mavlink->get_channel(), &msg);
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user