mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-03-06 13:44:21 -04:00
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 "GCS.h"
|
||||||
|
|
||||||
|
#include <AP_BoardConfig/AP_BoardConfig.h>
|
||||||
#include <AP_Logger/AP_Logger.h>
|
#include <AP_Logger/AP_Logger.h>
|
||||||
#include <AP_BattMonitor/AP_BattMonitor.h>
|
#include <AP_BattMonitor/AP_BattMonitor.h>
|
||||||
|
#include <AP_Scheduler/AP_Scheduler.h>
|
||||||
|
|
||||||
extern const AP_HAL::HAL& hal;
|
extern const AP_HAL::HAL& hal;
|
||||||
|
|
||||||
@ -179,3 +182,22 @@ void GCS::update_sensor_status_flags()
|
|||||||
|
|
||||||
update_vehicle_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();
|
void update_receive();
|
||||||
virtual void setup_uarts();
|
virtual void setup_uarts();
|
||||||
|
|
||||||
bool out_of_time() const {
|
// minimum amount of time (in microseconds) that must remain in
|
||||||
return _out_of_time;
|
// the main scheduler loop before we are allowed to send any
|
||||||
}
|
// mavlink messages. We want to prioritise the main flight
|
||||||
void set_out_of_time(bool val) {
|
// control loop over communications
|
||||||
_out_of_time = val;
|
virtual uint16_t min_loop_time_remaining_for_message_send_us() const {
|
||||||
|
return 200;
|
||||||
}
|
}
|
||||||
|
bool out_of_time() const;
|
||||||
|
|
||||||
// frsky backend
|
// frsky backend
|
||||||
AP_Frsky_Telem frsky;
|
AP_Frsky_Telem frsky;
|
||||||
@ -1024,9 +1026,6 @@ private:
|
|||||||
// queue of outgoing statustext messages
|
// queue of outgoing statustext messages
|
||||||
ObjectArray<statustext_t> _statustext_queue{_status_capacity};
|
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:
|
// true if we have already allocated protocol objects:
|
||||||
bool initialised_missionitemprotocol_objects;
|
bool initialised_missionitemprotocol_objects;
|
||||||
|
|
||||||
|
@ -1438,7 +1438,6 @@ void GCS_MAVLINK::update_send()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
const uint32_t start = AP_HAL::millis();
|
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
|
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()) {
|
if (gcs().out_of_time()) {
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user