mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-23 07:03:33 +08:00
Mavlink set last sent timestamp to space out initial publication
- remove QURT defines no longer required
This commit is contained in:
committed by
Lorenz Meier
parent
98465171aa
commit
a99f75dde2
@@ -45,29 +45,16 @@
|
||||
#include "mavlink_main.h"
|
||||
|
||||
MavlinkStream::MavlinkStream(Mavlink *mavlink) :
|
||||
next(nullptr),
|
||||
_mavlink(mavlink),
|
||||
_interval(1000000),
|
||||
_last_sent(0 /* 0 means unlimited - updates on every iteration */)
|
||||
_mavlink(mavlink)
|
||||
{
|
||||
}
|
||||
|
||||
MavlinkStream::~MavlinkStream() = default;
|
||||
|
||||
/**
|
||||
* Set messages interval in ms
|
||||
*/
|
||||
void
|
||||
MavlinkStream::set_interval(const int interval)
|
||||
{
|
||||
_interval = interval;
|
||||
_last_sent = hrt_absolute_time();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update subscriptions and send message if necessary
|
||||
*/
|
||||
int
|
||||
MavlinkStream::update(const hrt_abstime t)
|
||||
MavlinkStream::update(const hrt_abstime &t)
|
||||
{
|
||||
update_data();
|
||||
|
||||
@@ -77,12 +64,10 @@ MavlinkStream::update(const hrt_abstime t)
|
||||
// this will give different messages on the same run a different
|
||||
// initial timestamp which will help spacing them out
|
||||
// on the link scheduling
|
||||
#ifndef __PX4_QURT
|
||||
if (send(t)) {
|
||||
_last_sent = hrt_absolute_time();
|
||||
}
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -111,16 +96,12 @@ MavlinkStream::update(const hrt_abstime t)
|
||||
|
||||
if (interval == 0 || (dt > (interval - (_mavlink->get_main_loop_delay() / 10) * 3))) {
|
||||
// interval expired, send message
|
||||
bool sent = true;
|
||||
#ifndef __PX4_QURT
|
||||
sent = send(t);
|
||||
#endif
|
||||
|
||||
// If the interval is non-zero and dt is smaller than 1.5 times the interval
|
||||
// do not use the actual time but increment at a fixed rate, so that processing delays do not
|
||||
// distort the average rate. The check of the maximum interval is done to ensure that after a
|
||||
// long time not sending anything, sending multiple messages in a short time is avoided.
|
||||
if (sent) {
|
||||
if (send(t)) {
|
||||
_last_sent = ((interval > 0) && ((int64_t)(1.5f * interval) > dt)) ? _last_sent + interval : t;
|
||||
return 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user