aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2014-03-17 15:09:15 +0100
committerLorenz Meier <lm@inf.ethz.ch>2014-03-17 15:09:15 +0100
commit67298d47c19649146659dd4885db39bc8a9fe0d0 (patch)
treed93e4fc6b6ff685875c0a3b3fa8e124833b2792b /src
parent51658ac857390f20d3cc9e2e59a485516c4e0814 (diff)
parent762e8f52893afee6e8ffb6a728e5bc88518829c3 (diff)
downloadpx4-firmware-67298d47c19649146659dd4885db39bc8a9fe0d0.tar.gz
px4-firmware-67298d47c19649146659dd4885db39bc8a9fe0d0.tar.bz2
px4-firmware-67298d47c19649146659dd4885db39bc8a9fe0d0.zip
Merge branch 'beta_mavlink2' of github.com:PX4/Firmware into mavlink2_hil
Diffstat (limited to 'src')
-rw-r--r--src/modules/mavlink/mavlink_orb_subscription.cpp15
-rw-r--r--src/modules/mavlink/mavlink_orb_subscription.h15
2 files changed, 19 insertions, 11 deletions
diff --git a/src/modules/mavlink/mavlink_orb_subscription.cpp b/src/modules/mavlink/mavlink_orb_subscription.cpp
index 996318468..4de722832 100644
--- a/src/modules/mavlink/mavlink_orb_subscription.cpp
+++ b/src/modules/mavlink/mavlink_orb_subscription.cpp
@@ -78,12 +78,15 @@ MavlinkOrbSubscription::get_data()
bool
MavlinkOrbSubscription::update(const hrt_abstime t)
{
- if (_last_check != t) {
+ if (_last_check == t) {
+ /* already checked right now, return result of the check */
+ return _updated;
+
+ } else {
_last_check = t;
- bool updated;
- orb_check(_fd, &updated);
+ orb_check(_fd, &_updated);
- if (updated) {
+ if (_updated) {
orb_copy(_topic, _fd, _data);
return true;
}
@@ -95,6 +98,10 @@ MavlinkOrbSubscription::update(const hrt_abstime t)
bool
MavlinkOrbSubscription::is_published()
{
+ if (_published) {
+ return true;
+ }
+
bool updated;
orb_check(_fd, &updated);
diff --git a/src/modules/mavlink/mavlink_orb_subscription.h b/src/modules/mavlink/mavlink_orb_subscription.h
index 42d47e96e..5c6543e81 100644
--- a/src/modules/mavlink/mavlink_orb_subscription.h
+++ b/src/modules/mavlink/mavlink_orb_subscription.h
@@ -48,7 +48,7 @@
class MavlinkOrbSubscription
{
public:
- MavlinkOrbSubscription *next;
+ MavlinkOrbSubscription *next; /*< pointer to next subscription in list */
MavlinkOrbSubscription(const orb_id_t topic);
~MavlinkOrbSubscription();
@@ -59,18 +59,19 @@ public:
* Check if the topic has been published.
*
* This call will return true if the topic was ever published.
- * @param true if the topic has been published at least once.
+ * @return true if the topic has been published at least once.
*/
bool is_published();
void *get_data();
const orb_id_t get_topic();
private:
- const orb_id_t _topic;
- int _fd;
- bool _published;
- void *_data;
- hrt_abstime _last_check;
+ const orb_id_t _topic; /*< topic metadata */
+ int _fd; /*< subscription handle */
+ bool _published; /*< topic was ever published */
+ void *_data; /*< pointer to data buffer */
+ hrt_abstime _last_check; /*< time of last check */
+ bool _updated; /*< updated on last check */
};