mavlink: don't send streams with interval 0

We only need to send them immediately if the interval is < 0 meaning
unlimited.
This commit is contained in:
Julian Oes
2020-05-28 14:05:45 +02:00
parent 3815e608f4
commit b54c44bd37
+9 -2
View File
@@ -82,12 +82,19 @@ MavlinkStream::update(const hrt_abstime &t)
}
int64_t dt = t - _last_sent;
int interval = (_interval > 0) ? _interval : 0;
int interval = _interval;
if (!const_rate()) {
interval /= _mavlink->get_rate_mult();
}
// We don't need to send anything if the inverval is 0. send() will be called manually.
if (interval == 0) {
return 0;
}
const bool unlimited_rate = interval < 0;
// Send the message if it is due or
// if it will overrun the next scheduled send interval
// by 30% of the interval time. This helps to avoid
@@ -98,7 +105,7 @@ MavlinkStream::update(const hrt_abstime &t)
// This method is not theoretically optimal but a suitable
// stopgap as it hits its deadlines well (0.5 Hz, 50 Hz and 250 Hz)
if (interval == 0 || (dt > (interval - (_mavlink->get_main_loop_delay() / 10) * 3))) {
if (unlimited_rate || (dt > (interval - (_mavlink->get_main_loop_delay() / 10) * 3))) {
// interval expired, send message
// If the interval is non-zero and dt is smaller than 1.5 times the interval