From 973222c7867ceea96410e573d0aebfbf5687936a Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Fri, 26 Apr 2019 17:13:16 +1000 Subject: [PATCH] Sub: allow GCS MAVLink base class to handle out-of-time for sending messages --- ArduSub/GCS_Mavlink.cpp | 8 -------- ArduSub/GCS_Sub.h | 10 ++++++++++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ArduSub/GCS_Mavlink.cpp b/ArduSub/GCS_Mavlink.cpp index 4a4ca671f0..66d9f557ab 100644 --- a/ArduSub/GCS_Mavlink.cpp +++ b/ArduSub/GCS_Mavlink.cpp @@ -219,14 +219,6 @@ bool GCS_Sub::vehicle_initialised() const { // try to send a message, return false if it won't fit in the serial tx buffer bool GCS_MAVLINK_Sub::try_send_message(enum ap_message id) { - // if we don't have at least 250 micros remaining before the main loop - // wants to fire then don't send a mavlink message. We want to - // prioritise the main flight control loop over communications - if (sub.scheduler.time_available_usec() < 250 && sub.motors.armed()) { - gcs().set_out_of_time(true); - return false; - } - switch (id) { case MSG_NAMED_FLOAT: diff --git a/ArduSub/GCS_Sub.h b/ArduSub/GCS_Sub.h index 9e1c20482e..1521725eea 100644 --- a/ArduSub/GCS_Sub.h +++ b/ArduSub/GCS_Sub.h @@ -27,6 +27,16 @@ public: bool vehicle_initialised() const override; +protected: + + // minimum amount of time (in microseconds) that must remain in + // the main scheduler loop before we are allowed to send any + // mavlink messages. We want to prioritise the main flight + // control loop over communications + uint16_t min_loop_time_remaining_for_message_send_us() const override { + return 250; + } + private: GCS_MAVLINK_Sub _chan[MAVLINK_COMM_NUM_BUFFERS];