mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-26 12:33:34 +08:00
Commander: Only consider latest active data link heartbeat for timeout.
This commit is contained in:
@@ -767,6 +767,7 @@ int commander_thread_main(int argc, char *argv[])
|
|||||||
|
|
||||||
hrt_abstime last_idle_time = 0;
|
hrt_abstime last_idle_time = 0;
|
||||||
hrt_abstime start_time = 0;
|
hrt_abstime start_time = 0;
|
||||||
|
hrt_abstime latest_heartbeat = 0;
|
||||||
|
|
||||||
bool status_changed = true;
|
bool status_changed = true;
|
||||||
bool param_init_forced = true;
|
bool param_init_forced = true;
|
||||||
@@ -1367,19 +1368,24 @@ int commander_thread_main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* data link check */
|
/* data link check */
|
||||||
if (hrt_absolute_time() < telemetry.heartbeat_time + DL_TIMEOUT) {
|
if (telemetry.heartbeat_time >= latest_heartbeat) {
|
||||||
/* handle the case where data link was regained */
|
if (hrt_absolute_time() < telemetry.heartbeat_time + DL_TIMEOUT) {
|
||||||
if (status.data_link_lost) {
|
/* handle the case where data link was regained */
|
||||||
mavlink_log_critical(mavlink_fd, "#audio: data link regained");
|
if (status.data_link_lost) {
|
||||||
status.data_link_lost = false;
|
mavlink_log_critical(mavlink_fd, "#audio: data link regained");
|
||||||
status_changed = true;
|
status.data_link_lost = false;
|
||||||
}
|
status_changed = true;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
/* Only consider data link with most recent heartbeat */
|
||||||
if (!status.data_link_lost) {
|
latest_heartbeat = telemetry.heartbeat_time;
|
||||||
mavlink_log_critical(mavlink_fd, "#audio: CRITICAL: DATA LINK LOST");
|
|
||||||
status.data_link_lost = true;
|
} else {
|
||||||
status_changed = true;
|
if (!status.data_link_lost) {
|
||||||
|
mavlink_log_critical(mavlink_fd, "#audio: CRITICAL: DATA LINK LOST");
|
||||||
|
status.data_link_lost = true;
|
||||||
|
status_changed = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user