diff options
author | Thomas Gubler <thomasgubler@gmail.com> | 2014-12-10 17:03:24 +0100 |
---|---|---|
committer | Thomas Gubler <thomasgubler@gmail.com> | 2014-12-10 17:03:24 +0100 |
commit | 1b6b6cd35c1f14766d49144bbc18d19d02656362 (patch) | |
tree | 8b38458d1e2f0a492683b2b6e81707da30d99100 | |
parent | f0ad2c9ef55dc2508e777384f8d0496042ade9e8 (diff) | |
download | px4-firmware-1b6b6cd35c1f14766d49144bbc18d19d02656362.tar.gz px4-firmware-1b6b6cd35c1f14766d49144bbc18d19d02656362.tar.bz2 px4-firmware-1b6b6cd35c1f14766d49144bbc18d19d02656362.zip |
add no callback example to subscriber example
-rw-r--r-- | src/examples/subscriber/subscriber_example.cpp | 15 | ||||
-rw-r--r-- | src/examples/subscriber/subscriber_example.h | 3 |
2 files changed, 12 insertions, 6 deletions
diff --git a/src/examples/subscriber/subscriber_example.cpp b/src/examples/subscriber/subscriber_example.cpp index e6d63cab3..460a3267a 100644 --- a/src/examples/subscriber/subscriber_example.cpp +++ b/src/examples/subscriber/subscriber_example.cpp @@ -50,21 +50,24 @@ void rc_channels_callback_function(const PX4_TOPIC_T(rc_channels) &msg) { SubscriberExample::SubscriberExample() : _n(), _p_sub_interv(PX4_PARAM_INIT(SUB_INTERV)), - _sub_interval(0), + _interval(0), _p_test_float(PX4_PARAM_INIT(SUB_TESTF)), _test_float(0.0f) { /* Read the parameter back as example */ - PX4_PARAM_GET(_p_sub_interv, &_sub_interval); - PX4_INFO("Param SUB_INTERV = %d", _sub_interval); + PX4_PARAM_GET(_p_sub_interv, &_interval); + PX4_INFO("Param SUB_INTERV = %d", _interval); PX4_PARAM_GET(_p_test_float, &_test_float); PX4_INFO("Param SUB_TESTF = %.3f", (double)_test_float); /* Do some subscriptions */ /* Function */ - PX4_SUBSCRIBE(_n, rc_channels, rc_channels_callback_function, _sub_interval); + PX4_SUBSCRIBE(_n, rc_channels, rc_channels_callback_function, _interval); /* Class Method */ PX4_SUBSCRIBE(_n, rc_channels, SubscriberExample::rc_channels_callback, this, 1000); + /* No callback */ + _sub_rc_chan = PX4_SUBSCRIBE(_n, rc_channels, 500); + PX4_INFO("subscribed"); } @@ -72,5 +75,7 @@ SubscriberExample::SubscriberExample() : * This tutorial demonstrates simple receipt of messages over the PX4 middleware system. */ void SubscriberExample::rc_channels_callback(const PX4_TOPIC_T(rc_channels) &msg) { - PX4_INFO("Subscriber callback: [%llu]", msg.timestamp_last_valid); + PX4_INFO("Subscriber callback: [%llu], value of _sub_rc_chan: [%llu]", + msg.timestamp_last_valid, + ((SubscriberPX4<PX4_TOPIC_T(rc_channels)> *)_sub_rc_chan)->timestamp_last_valid); } diff --git a/src/examples/subscriber/subscriber_example.h b/src/examples/subscriber/subscriber_example.h index b52f89ba8..848d43f76 100644 --- a/src/examples/subscriber/subscriber_example.h +++ b/src/examples/subscriber/subscriber_example.h @@ -48,9 +48,10 @@ public: protected: px4::NodeHandle _n; px4_param_t _p_sub_interv; - int32_t _sub_interval; + int32_t _interval; px4_param_t _p_test_float; float _test_float; + px4::Subscriber * _sub_rc_chan; void rc_channels_callback(const PX4_TOPIC_T(rc_channels) &msg); |