mavlink: adding message stream by name implemnted, mavlink streams definitions and formatters moved to mavlink_messages.h/cpp, mavlink_orb_listener class and thread removed

This commit is contained in:
Anton Babushkin
2014-02-26 00:24:14 +04:00
parent 4e27fd9a38
commit e291af990f
10 changed files with 326 additions and 713 deletions
@@ -13,14 +13,13 @@
#include "mavlink_orb_subscription.h"
MavlinkOrbSubscription::MavlinkOrbSubscription(const struct orb_metadata *meta, size_t size)
MavlinkOrbSubscription::MavlinkOrbSubscription(const struct orb_metadata *topic, size_t size)
{
this->meta = meta;
this->topic = topic;
this->data = malloc(size);
memset(this->data, 0, size);
this->fd = orb_subscribe(meta);
this->fd = orb_subscribe(topic);
this->last_update = 0;
this->interval = 0;
}
MavlinkOrbSubscription::~MavlinkOrbSubscription()
@@ -29,19 +28,15 @@ MavlinkOrbSubscription::~MavlinkOrbSubscription()
free(data);
}
int MavlinkOrbSubscription::set_interval(const unsigned int interval)
{
this->interval = interval;
return orb_set_interval(fd, interval);
}
int MavlinkOrbSubscription::update(const hrt_abstime t)
bool MavlinkOrbSubscription::update(const hrt_abstime t)
{
if (last_update != t) {
bool updated;
orb_check(fd, &updated);
if (updated)
return orb_copy(meta, fd, data);
if (updated) {
orb_copy(topic, fd, data);
return true;
}
}
return OK;
return false;
}