aboutsummaryrefslogtreecommitdiff
path: root/src/examples/subscriber
diff options
context:
space:
mode:
authorThomas Gubler <thomasgubler@gmail.com>2014-11-28 08:58:44 +0100
committerThomas Gubler <thomasgubler@gmail.com>2014-11-28 08:58:44 +0100
commit36bf0c04c8cb052c67e613eb051b0deb650eb216 (patch)
treec9a498d808dbc973b3ad2a2611703fa463c27c8f /src/examples/subscriber
parent486d81cb95bb7dc912ee0a7636b0a6aeb87009d9 (diff)
downloadpx4-firmware-36bf0c04c8cb052c67e613eb051b0deb650eb216.tar.gz
px4-firmware-36bf0c04c8cb052c67e613eb051b0deb650eb216.tar.bz2
px4-firmware-36bf0c04c8cb052c67e613eb051b0deb650eb216.zip
WIP, c++11 style callbacks for px4
Diffstat (limited to 'src/examples/subscriber')
-rw-r--r--src/examples/subscriber/subscriber.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/examples/subscriber/subscriber.cpp b/src/examples/subscriber/subscriber.cpp
index 0d0a81d7e..f8b138844 100644
--- a/src/examples/subscriber/subscriber.cpp
+++ b/src/examples/subscriber/subscriber.cpp
@@ -36,6 +36,10 @@ void rc_channels_callback(const PX4_TOPIC_T(rc_channels) &msg)
{
PX4_INFO("I heard: [%lu]", msg.timestamp_last_valid);
}
+// void rc_channels_callback(int i)
+// {
+ // PX4_INFO("I heard: [%d]", i);
+// }
namespace px4
{
bool task_should_exit = false;
@@ -77,7 +81,11 @@ PX4_MAIN_FUNCTION(subscriber)
* is the number of messages that will be buffered up before beginning to throw
* away the oldest ones.
*/
- n.subscribe(PX4_TOPIC(rc_channels), rc_channels_callback);
+ // n.subscribe(PX4_TOPIC(rc_channels), [&](const PX4_TOPIC_T(rc_channels) &msg){rc_channels_callback(msg);});
+ // n.subscribe(PX4_TOPIC(rc_channels), [&](int i){ return rc_channels_callback(i);});
+ // CallbackFunction cbf = [](int i){ return rc_channels_callback(i);};
+ std::function<void(const PX4_TOPIC_T(rc_channels)&)> cbf = [](const PX4_TOPIC_T(rc_channels)& msg){ return rc_channels_callback(msg);};
+ n.subscribe<PX4_TOPIC_T(rc_channels)>(PX4_TOPIC(rc_channels), cbf);
PX4_INFO("subscribed");
/**