PX4 Firmware
PX4 Autopilot Software http://px4.io
uORB.cpp
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright (c) 2012-2015 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 
34 /**
35  * @file uORB.cpp
36  * A lightweight object broker.
37  */
38 
39 #include "uORB.h"
40 #include "uORBManager.hpp"
41 #include "uORBCommon.hpp"
42 
43 orb_advert_t orb_advertise(const struct orb_metadata *meta, const void *data)
44 {
45  return uORB::Manager::get_instance()->orb_advertise(meta, data);
46 }
47 
48 orb_advert_t orb_advertise_queue(const struct orb_metadata *meta, const void *data, unsigned int queue_size)
49 {
50  return uORB::Manager::get_instance()->orb_advertise(meta, data, queue_size);
51 }
52 
53 orb_advert_t orb_advertise_multi(const struct orb_metadata *meta, const void *data, int *instance,
54  int priority)
55 {
56  return uORB::Manager::get_instance()->orb_advertise_multi(meta, data, instance, priority);
57 }
58 
59 orb_advert_t orb_advertise_multi_queue(const struct orb_metadata *meta, const void *data, int *instance,
60  int priority, unsigned int queue_size)
61 {
62  return uORB::Manager::get_instance()->orb_advertise_multi(meta, data, instance, priority, queue_size);
63 }
64 
66 {
68 }
69 
70 int orb_publish(const struct orb_metadata *meta, orb_advert_t handle, const void *data)
71 {
72  return uORB::Manager::get_instance()->orb_publish(meta, handle, data);
73 }
74 
75 int orb_subscribe(const struct orb_metadata *meta)
76 {
78 }
79 
80 int orb_subscribe_multi(const struct orb_metadata *meta, unsigned instance)
81 {
82  return uORB::Manager::get_instance()->orb_subscribe_multi(meta, instance);
83 }
84 
85 int orb_unsubscribe(int handle)
86 {
88 }
89 
90 int orb_copy(const struct orb_metadata *meta, int handle, void *buffer)
91 {
92  return uORB::Manager::get_instance()->orb_copy(meta, handle, buffer);
93 }
94 
95 int orb_check(int handle, bool *updated)
96 {
97  return uORB::Manager::get_instance()->orb_check(handle, updated);
98 }
99 
100 int orb_stat(int handle, uint64_t *time)
101 {
102  return uORB::Manager::get_instance()->orb_stat(handle, time);
103 }
104 
105 int orb_exists(const struct orb_metadata *meta, int instance)
106 {
107  return uORB::Manager::get_instance()->orb_exists(meta, instance);
108 }
109 
110 int orb_group_count(const struct orb_metadata *meta)
111 {
112  unsigned instance = 0;
113 
114  while (uORB::Manager::get_instance()->orb_exists(meta, instance) == OK) {
115  ++instance;
116  };
117 
118  return instance;
119 }
120 
121 int orb_priority(int handle, int32_t *priority)
122 {
123  return uORB::Manager::get_instance()->orb_priority(handle, priority);
124 }
125 
126 int orb_set_interval(int handle, unsigned interval)
127 {
128  return uORB::Manager::get_instance()->orb_set_interval(handle, interval);
129 }
130 
131 int orb_get_interval(int handle, unsigned *interval)
132 {
133  return uORB::Manager::get_instance()->orb_get_interval(handle, interval);
134 }
static uORB::Manager * get_instance()
Method to get the singleton instance for the uORB::Manager.
Definition: uORBManager.hpp:89
int orb_copy(const struct orb_metadata *meta, int handle, void *buffer)
Definition: uORB.cpp:90
int orb_set_interval(int handle, unsigned interval)
Set the minimum interval between which updates are seen for a subscription.
API for the uORB lightweight object broker.
int orb_priority(int handle, int32_t *priority)
Definition: uORB.cpp:121
int orb_set_interval(int handle, unsigned interval)
Definition: uORB.cpp:126
orb_advert_t orb_advertise(const struct orb_metadata *meta, const void *data)
Definition: uORB.cpp:43
int orb_unsubscribe(int handle)
Unsubscribe from a topic.
LidarLite * instance
Definition: ll40ls.cpp:65
int orb_exists(const struct orb_metadata *meta, int instance)
Definition: uORB.cpp:105
orb_advert_t orb_advertise_queue(const struct orb_metadata *meta, const void *data, unsigned int queue_size)
Definition: uORB.cpp:48
int orb_subscribe(const struct orb_metadata *meta)
Definition: uORB.cpp:75
int orb_subscribe(const struct orb_metadata *meta)
Subscribe to a topic.
int orb_stat(int handle, uint64_t *time)
Definition: uORB.cpp:100
orb_advert_t orb_advertise_multi(const struct orb_metadata *meta, const void *data, int *instance, int priority, unsigned int queue_size=1)
Advertise as the publisher of a topic.
orb_advert_t orb_advertise_multi_queue(const struct orb_metadata *meta, const void *data, int *instance, int priority, unsigned int queue_size)
Definition: uORB.cpp:59
int orb_unadvertise(orb_advert_t handle)
Unadvertise a topic.
uint8_t * data
Definition: dataman.cpp:149
int orb_unsubscribe(int handle)
Definition: uORB.cpp:85
int orb_priority(int handle, int32_t *priority)
Return the priority of the topic.
__BEGIN_DECLS typedef void * orb_advert_t
ORB topic advertiser handle.
Definition: uORB.h:134
int orb_group_count(const struct orb_metadata *meta)
Get the number of published instances of a topic group.
Definition: uORB.cpp:110
int orb_publish(const struct orb_metadata *meta, orb_advert_t handle, const void *data)
Definition: uORB.cpp:70
int orb_publish(const struct orb_metadata *meta, orb_advert_t handle, const void *data)
Publish new data to a topic.
int orb_subscribe_multi(const struct orb_metadata *meta, unsigned instance)
Subscribe to a multi-instance of a topic.
int orb_get_interval(int handle, unsigned *interval)
Definition: uORB.cpp:131
int orb_copy(const struct orb_metadata *meta, int handle, void *buffer)
Fetch data from a topic.
int orb_exists(const struct orb_metadata *meta, int instance)
Check if a topic has already been created and published (advertised)
Object metadata.
Definition: uORB.h:50
int orb_check(int handle, bool *updated)
Definition: uORB.cpp:95
int orb_subscribe_multi(const struct orb_metadata *meta, unsigned instance)
Definition: uORB.cpp:80
int orb_unadvertise(orb_advert_t handle)
Definition: uORB.cpp:65
orb_advert_t orb_advertise(const struct orb_metadata *meta, const void *data, unsigned int queue_size=1)
Advertise as the publisher of a topic.
int orb_get_interval(int handle, unsigned *interval)
Get the minimum interval between which updates are seen for a subscription.
#define OK
Definition: uavcan_main.cpp:71
int orb_check(int handle, bool *updated)
Check whether a topic has been published to since the last orb_copy.
orb_advert_t orb_advertise_multi(const struct orb_metadata *meta, const void *data, int *instance, int priority)
Definition: uORB.cpp:53
int orb_stat(int handle, uint64_t *time)
Return the last time that the topic was updated.