Firmware
mavlink_orb_subscription.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright (c) 2014 PX4 Development Team. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in
13  * the documentation and/or other materials provided with the
14  * distribution.
15  * 3. Neither the name PX4 nor the names of its contributors may be
16  * used to endorse or promote products derived from this software
17  * without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
26  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  *
32  ****************************************************************************/
33 
41 #ifndef MAVLINK_ORB_SUBSCRIPTION_H_
42 #define MAVLINK_ORB_SUBSCRIPTION_H_
43 
44 #include <drivers/drv_hrt.h>
45 #include <containers/List.hpp>
46 #include "uORB/uORB.h" // orb_id_t
47 
48 class MavlinkOrbSubscription : public ListNode<MavlinkOrbSubscription *>
49 {
50 public:
51 
52  MavlinkOrbSubscription(const orb_id_t topic, int instance);
54 
64  bool update(uint64_t *time, void *data);
65 
71  bool update(void *data);
72 
79  bool update_if_changed(void *data);
80 
88  bool is_published();
89 
90  void subscribe_from_beginning(bool from_beginning);
91 
92  orb_id_t get_topic() const;
93  int get_instance() const;
94 
95  int get_fd() { return _fd; }
96 
97 private:
98  const orb_id_t _topic;
99  const uint8_t _instance;
100 
101  int _fd{-1};
102 
103  bool _published{false};
104 
105  bool _subscribe_from_beginning{false};
106 
107  hrt_abstime _last_pub_check{0};
108 
109  /* do not allow copying this class */
112 };
113 
114 
115 #endif /* MAVLINK_ORB_SUBSCRIPTION_H_ */
An intrusive linked list.
Definition: List.hpp:45
bool update_if_changed(void *data)
Check if the subscription has been updated.
Definition: mavlink_orb_subscription.cpp:120
High-resolution timer with callouts and timekeeping.
API for the uORB lightweight object broker.
__BEGIN_DECLS typedef uint64_t hrt_abstime
Absolute time, in microsecond units.
Definition: drv_hrt.h:58
Object metadata.
Definition: uORB.h:50
bool update(uint64_t *time, void *data)
Check if subscription updated based on timestamp.
Definition: mavlink_orb_subscription.cpp:78
bool is_published()
Check if the topic has been published.
Definition: mavlink_orb_subscription.cpp:136
Definition: mavlink_orb_subscription.h:48