correctly handle interval, call callback only when topic updated, add example for 2 topics

This commit is contained in:
Thomas Gubler
2014-11-28 16:30:12 +01:00
parent a9c1e4ad61
commit 9abc8e26b7
3 changed files with 12 additions and 6 deletions
+1 -1
View File
@@ -114,7 +114,7 @@ public:
SubscriberPX4<M> *sub_px4 = new SubscriberPX4<M>(meta, interval, callback, &_subs);
/* Check if this is the smallest interval so far and update _sub_min_interval */
if (_sub_min_interval == nullptr || _sub_min_interval->getInterval() < sub_px4->getInterval()) {
if (_sub_min_interval == nullptr || _sub_min_interval->getInterval() > sub_px4->getInterval()) {
_sub_min_interval = sub_px4;
}
return (Subscriber*)sub_px4;
+5
View File
@@ -89,6 +89,11 @@ public:
~SubscriberPX4() {};
void update() {
if (!uORB::Subscription<M>::updated()) {
/* Topic not updated, do not call callback */
return;
}
/* get latest data */
uORB::Subscription<M>::update();