diff --git a/src/modules/commander/Commander.cpp b/src/modules/commander/Commander.cpp index eb02ff6cb2d35f68fc07fc51009b22f86a91b2fc..f0e9e3a872f83fb99a5791cc6ed9f6348ebabaa4 100644 --- a/src/modules/commander/Commander.cpp +++ b/src/modules/commander/Commander.cpp @@ -3858,7 +3858,7 @@ void Commander::data_link_check(bool &status_changed) case (telemetry_status_s::LINK_TYPE_IRIDIUM): // lazily subscribe - if (orb_exists(ORB_ID(iridiumsbd_status), 0) == PX4_OK) { + if (_iridiumsbd_status_sub == -1 && orb_exists(ORB_ID(iridiumsbd_status), 0) == PX4_OK) { _iridiumsbd_status_sub = orb_subscribe(ORB_ID(iridiumsbd_status)); } @@ -3892,10 +3892,12 @@ void Commander::data_link_check(bool &status_changed) case (telemetry_status_s::MAV_TYPE_GCS): _datalink_last_heartbeat_gcs = telemetry.heartbeat_time; + // Recover from data link lost if (status.data_link_lost) { - if (hrt_elapsed_time(&_datalink_lost) > (_datalink_regain_threshold.get() * 1_s)) { + if (hrt_elapsed_time(&_datalink_last_heartbeat_gcs) < (_datalink_regain_threshold.get() * 1_s)) { status.data_link_lost = false; status_changed = true; + mavlink_log_critical(&mavlink_log_pub, "DATA LINK REGAINED"); } } @@ -3932,12 +3934,10 @@ void Commander::data_link_check(bool &status_changed) } // GCS data link loss failsafe - if ((_datalink_last_heartbeat_gcs > 0) && - (hrt_elapsed_time(&_datalink_last_heartbeat_gcs) > (_datalink_loss_threshold.get() * 1_s))) { + if (!status.data_link_lost) { + if (_datalink_last_heartbeat_gcs != 0 + && hrt_elapsed_time(&_datalink_last_heartbeat_gcs) > (_datalink_loss_threshold.get() * 1_s)) { - _datalink_lost = hrt_absolute_time(); - - if (!status.data_link_lost) { status.data_link_lost = true; status.data_link_lost_counter++; @@ -3998,7 +3998,8 @@ void Commander::data_link_check(bool &status_changed) // high latency data link loss failsafe - if (hrt_elapsed_time(&_high_latency_datalink_heartbeat) > (_high_latency_datalink_loss_threshold.get() * 1_s)) { + if (_high_latency_datalink_heartbeat > 0 + && hrt_elapsed_time(&_high_latency_datalink_heartbeat) > (_high_latency_datalink_loss_threshold.get() * 1_s)) { _high_latency_datalink_lost = hrt_absolute_time(); if (!status.high_latency_data_link_lost) { diff --git a/src/modules/commander/Commander.hpp b/src/modules/commander/Commander.hpp index 6d52e1ccf67946543350a16b2ca587283f6793c8..1344c39b43df979b4c150028cbdd7db6b531a2be 100644 --- a/src/modules/commander/Commander.hpp +++ b/src/modules/commander/Commander.hpp @@ -175,7 +175,6 @@ private: int _telemetry_status_sub[ORB_MULTI_MAX_INSTANCES] {}; uint64_t _datalink_last_heartbeat_gcs{0}; - uint64_t _datalink_lost{0}; uint64_t _datalink_last_heartbeat_onboard_controller{0}; uint64_t _onboard_controller_lost{0}; diff --git a/src/modules/commander/commander_params.c b/src/modules/commander/commander_params.c index 14eb645e0b224478cb9e43f49ebd2e6eb04e5870..e170eebba3a7750df35bf473d65b7bbe4ae11509 100644 --- a/src/modules/commander/commander_params.c +++ b/src/modules/commander/commander_params.c @@ -116,7 +116,7 @@ PARAM_DEFINE_INT32(COM_DL_LOSS_T, 10); * @decimal 1 * @increment 0.5 */ -PARAM_DEFINE_INT32(COM_DL_REG_T, 0); +PARAM_DEFINE_INT32(COM_DL_REG_T, 2); /** * High Latency Datalink loss time threshold