From 73f342616e275ca726d70807212a733f9971bf66 Mon Sep 17 00:00:00 2001 From: Thomas Gubler Date: Fri, 23 Jan 2015 15:16:13 +0100 Subject: [PATCH] add better accessor --- src/examples/subscriber/subscriber_example.cpp | 2 +- src/platforms/px4_subscriber.h | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/examples/subscriber/subscriber_example.cpp b/src/examples/subscriber/subscriber_example.cpp index 215336c174..781dde486c 100644 --- a/src/examples/subscriber/subscriber_example.cpp +++ b/src/examples/subscriber/subscriber_example.cpp @@ -81,5 +81,5 @@ void SubscriberExample::rc_channels_callback(const px4_rc_channels &msg) { PX4_INFO("Callback (method): [%llu]", msg.data().timestamp_last_valid); PX4_INFO("Callback (method): value of _sub_rc_chan: [%llu]", - _sub_rc_chan->get().data().timestamp_last_valid); + _sub_rc_chan->data().timestamp_last_valid); } diff --git a/src/platforms/px4_subscriber.h b/src/platforms/px4_subscriber.h index 6a81ef8d22..6ca35b173f 100644 --- a/src/platforms/px4_subscriber.h +++ b/src/platforms/px4_subscriber.h @@ -84,7 +84,15 @@ public: /** * Get the last message value */ - virtual T get() {return _msg_current;} + virtual T& get() {return _msg_current;} + + /** + * Get the last native message value + */ + virtual decltype(((T*)nullptr)->data()) data() + { + return _msg_current.data(); + } protected: T _msg_current; /**< Current Message value */