aboutsummaryrefslogtreecommitdiff
path: root/src/examples
diff options
context:
space:
mode:
authorThomas Gubler <thomasgubler@gmail.com>2014-11-28 16:30:12 +0100
committerThomas Gubler <thomasgubler@gmail.com>2014-11-28 16:30:12 +0100
commit9abc8e26b789af0ef132c5c38e3d8ada821c3657 (patch)
treeadc3791edcc01a9c79d37cb7ec20ce050a483852 /src/examples
parenta9c1e4ad6145485805366fad5c08ae7351886ff3 (diff)
downloadpx4-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/examples')
-rw-r--r--src/examples/subscriber/subscriber.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/examples/subscriber/subscriber.cpp b/src/examples/subscriber/subscriber.cpp
index ed0635f18..a186ba94a 100644
--- a/src/examples/subscriber/subscriber.cpp
+++ b/src/examples/subscriber/subscriber.cpp
@@ -36,10 +36,10 @@ void rc_channels_callback(const PX4_TOPIC_T(rc_channels) &msg)
{
PX4_INFO("I heard: [%llu]", msg.timestamp_last_valid);
}
-// void rc_channels_callback(int i)
-// {
- // PX4_INFO("I heard: [%d]", i);
-// }
+void rc_channels_callback2(const PX4_TOPIC_T(rc_channels) &msg)
+{
+ PX4_INFO("I heard2: [%llu]", msg.timestamp_last_valid);
+}
namespace px4
{
bool task_should_exit = false;
@@ -81,7 +81,8 @@ PX4_MAIN_FUNCTION(subscriber)
* is the number of messages that will be buffered up before beginning to throw
* away the oldest ones.
*/
- PX4_SUBSCRIBE(n, rc_channels, rc_channels_callback, 1000);
+ PX4_SUBSCRIBE(n, rc_channels, rc_channels_callback, 100);
+ PX4_SUBSCRIBE(n, rc_channels, rc_channels_callback2, 1000);
PX4_INFO("subscribed");
/**