aboutsummaryrefslogtreecommitdiff
path: root/src/platforms/px4_nodehandle.h
diff options
context:
space:
mode:
authorThomas Gubler <thomasgubler@gmail.com>2014-11-28 16:08:51 +0100
committerThomas Gubler <thomasgubler@gmail.com>2014-11-28 16:08:51 +0100
commita9c1e4ad6145485805366fad5c08ae7351886ff3 (patch)
treea32520d33cb1c5b1cf32d6fc640c77634816099b /src/platforms/px4_nodehandle.h
parentcefccc0037f18275b8d8c7e49e15d13801ef28a1 (diff)
downloadpx4-firmware-a9c1e4ad6145485805366fad5c08ae7351886ff3.tar.gz
px4-firmware-a9c1e4ad6145485805366fad5c08ae7351886ff3.tar.bz2
px4-firmware-a9c1e4ad6145485805366fad5c08ae7351886ff3.zip
make px4::ok work, use it in px4::spin
Diffstat (limited to 'src/platforms/px4_nodehandle.h')
-rw-r--r--src/platforms/px4_nodehandle.h19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/platforms/px4_nodehandle.h b/src/platforms/px4_nodehandle.h
index ced844fd5..eb90590e4 100644
--- a/src/platforms/px4_nodehandle.h
+++ b/src/platforms/px4_nodehandle.h
@@ -41,6 +41,7 @@
/* includes for all platforms */
#include "px4_subscriber.h"
#include "px4_publisher.h"
+#include "px4_middleware.h"
#if defined(__linux) || (defined(__APPLE__) && defined(__MACH__))
/* includes when building for ros */
@@ -126,10 +127,24 @@ public:
return pub;
}
- void spinOnce();
+ void spinOnce() {
+ /* Loop through subscriptions, call callback for updated subscriptions */
+ uORB::SubscriptionNode *sub = _subs.getHead();
+ int count = 0;
+
+ while (sub != nullptr) {
+ if (count++ > kMaxSubscriptions) {
+ PX4_WARN("exceeded max subscriptions");
+ break;
+ }
+
+ sub->update();
+ sub = sub->getSibling();
+ }
+ }
void spin() {
- while (true) { //XXX check for termination
+ while (ok()) {
const int timeout_ms = 100;
/* Only continue in the loop if the nodehandle has subscriptions */
if (_sub_min_interval == nullptr) {