From fbe2e75b9f8a46809411ba3e8a3ba64513f02f7b Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 25 Feb 2020 15:23:52 +1100 Subject: [PATCH] GCS_MAVLink: divide time allowed to send messages fairly --- libraries/GCS_MAVLink/GCS.h | 6 ++++++ libraries/GCS_MAVLink/GCS_Common.cpp | 12 +++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/libraries/GCS_MAVLink/GCS.h b/libraries/GCS_MAVLink/GCS.h index 4aed6d3d72..49eb6d006a 100644 --- a/libraries/GCS_MAVLink/GCS.h +++ b/libraries/GCS_MAVLink/GCS.h @@ -978,6 +978,12 @@ private: // timer called to implement pass-thru void passthru_timer(); + + // this contains the index of the GCS_MAVLINK backend we will + // first call update_send on. It is incremented each time + // GCS::update_send is called so we don't starve later links of + // time in which they are permitted to send messages. + uint8_t first_backend_to_send; }; GCS &gcs(); diff --git a/libraries/GCS_MAVLink/GCS_Common.cpp b/libraries/GCS_MAVLink/GCS_Common.cpp index acf8558871..e28b47d46d 100644 --- a/libraries/GCS_MAVLink/GCS_Common.cpp +++ b/libraries/GCS_MAVLink/GCS_Common.cpp @@ -1961,9 +1961,19 @@ void GCS::update_send() if (_missionitemprotocol_fence != nullptr) { _missionitemprotocol_fence->update(); } - for (uint8_t i=0; iupdate_send(); } + for (uint8_t i=0; iupdate_send(); + } + first_backend_to_send++; + if (first_backend_to_send >= num_gcs()) { + first_backend_to_send = 0; + } WITH_SEMAPHORE(_statustext_sem); service_statustext(); }