mavlink: MavlinkStream API updated

This commit is contained in:
Anton Babushkin 2014-07-23 11:03:37 +02:00
parent 4722b609cc
commit 344a34bb72
2 changed files with 13 additions and 5 deletions

View File

@ -71,11 +71,12 @@ int
MavlinkStream::update(const hrt_abstime t)
{
uint64_t dt = t - _last_sent;
unsigned int interval = _interval * _mavlink->get_rate_mult();
if (dt > 0 && dt >= _interval) {
if (dt > 0 && dt >= interval) {
/* interval expired, send message */
send(t);
_last_sent = (t / _interval) * _interval;
_last_sent = t;
return 0;
}

View File

@ -46,8 +46,6 @@
class Mavlink;
class MavlinkStream;
#include "mavlink_main.h"
class MavlinkStream
{
@ -70,7 +68,6 @@ public:
* @return the inveral in microseconds (us) between messages
*/
unsigned get_interval() { return _interval; }
void set_channel(mavlink_channel_t channel);
/**
* @return 0 if updated / sent, -1 if unchanged
@ -82,6 +79,16 @@ public:
virtual const char *get_name() const = 0;
virtual uint8_t get_id() = 0;
/**
* @return true if steam rate shouldn't be adjusted
*/
virtual bool const_rate() { return false; }
/**
* Get maximal total messages size on update
*/
virtual unsigned get_size() = 0;
protected:
Mavlink * _mavlink;
unsigned int _interval;