diff options
author | Thomas Gubler <thomasgubler@gmail.com> | 2014-11-28 16:30:12 +0100 |
---|---|---|
committer | Thomas Gubler <thomasgubler@gmail.com> | 2014-11-28 16:30:12 +0100 |
commit | 9abc8e26b789af0ef132c5c38e3d8ada821c3657 (patch) | |
tree | adc3791edcc01a9c79d37cb7ec20ce050a483852 /src/platforms | |
parent | a9c1e4ad6145485805366fad5c08ae7351886ff3 (diff) | |
download | px4-firmware-9abc8e26b789af0ef132c5c38e3d8ada821c3657.tar.gz px4-firmware-9abc8e26b789af0ef132c5c38e3d8ada821c3657.tar.bz2 px4-firmware-9abc8e26b789af0ef132c5c38e3d8ada821c3657.zip |
correctly handle interval, call callback only when topic updated, add example for 2 topics
Diffstat (limited to 'src/platforms')
-rw-r--r-- | src/platforms/px4_nodehandle.h | 2 | ||||
-rw-r--r-- | src/platforms/px4_subscriber.h | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/src/platforms/px4_nodehandle.h b/src/platforms/px4_nodehandle.h index eb90590e4..45ef225fa 100644 --- a/src/platforms/px4_nodehandle.h +++ b/src/platforms/px4_nodehandle.h @@ -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; diff --git a/src/platforms/px4_subscriber.h b/src/platforms/px4_subscriber.h index efec8f2a3..6e0ef8aed 100644 --- a/src/platforms/px4_subscriber.h +++ b/src/platforms/px4_subscriber.h @@ -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(); |