GCS_MAVLink: handle out-of-time to send messages in parent class
This commit is contained in:
parent
88111ef81a
commit
feddaabc42
@ -1,6 +1,9 @@
|
||||
#include "GCS.h"
|
||||
|
||||
#include <AP_BoardConfig/AP_BoardConfig.h>
|
||||
#include <AP_Logger/AP_Logger.h>
|
||||
#include <AP_BattMonitor/AP_BattMonitor.h>
|
||||
#include <AP_Scheduler/AP_Scheduler.h>
|
||||
|
||||
extern const AP_HAL::HAL& hal;
|
||||
|
||||
@ -179,3 +182,22 @@ void GCS::update_sensor_status_flags()
|
||||
|
||||
update_vehicle_sensor_status_flags();
|
||||
}
|
||||
|
||||
bool GCS::out_of_time() const
|
||||
{
|
||||
// while we are in the delay callback we are never out of time:
|
||||
if (hal.scheduler->in_delay_callback()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// we always want to be able to send messages out while in the error loop:
|
||||
if (AP_BoardConfig::in_sensor_config_error()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (min_loop_time_remaining_for_message_send_us() <= AP::scheduler().time_available_usec()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -966,12 +966,14 @@ public:
|
||||
void update_receive();
|
||||
virtual void setup_uarts();
|
||||
|
||||
bool out_of_time() const {
|
||||
return _out_of_time;
|
||||
}
|
||||
void set_out_of_time(bool val) {
|
||||
_out_of_time = val;
|
||||
// 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
|
||||
virtual uint16_t min_loop_time_remaining_for_message_send_us() const {
|
||||
return 200;
|
||||
}
|
||||
bool out_of_time() const;
|
||||
|
||||
// frsky backend
|
||||
AP_Frsky_Telem frsky;
|
||||
@ -1024,9 +1026,6 @@ private:
|
||||
// queue of outgoing statustext messages
|
||||
ObjectArray<statustext_t> _statustext_queue{_status_capacity};
|
||||
|
||||
// true if we are running short on time in our main loop
|
||||
bool _out_of_time;
|
||||
|
||||
// true if we have already allocated protocol objects:
|
||||
bool initialised_missionitemprotocol_objects;
|
||||
|
||||
|
@ -1438,7 +1438,6 @@ void GCS_MAVLINK::update_send()
|
||||
#endif
|
||||
|
||||
const uint32_t start = AP_HAL::millis();
|
||||
gcs().set_out_of_time(false);
|
||||
while (AP_HAL::millis() - start < 5) { // spend a max of 5ms sending messages. This should never trigger - out_of_time() should become true
|
||||
if (gcs().out_of_time()) {
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user