PX4 Firmware
PX4 Autopilot Software http://px4.io
uORBCommunicator.hpp
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 #ifndef _uORBCommunicator_hpp_
35 #define _uORBCommunicator_hpp_
36 
37 #include <stdint.h>
38 
39 
41 {
42 class IChannel;
43 class IChannelRxHandler;
44 }
45 
46 /**
47  * Interface to enable remote subscriptions. The implementor of this interface
48  * shall manage the communication channel. It can be fastRPC or tcp or ip.
49  */
50 
52 {
53 public:
54 
55  //=========================================================================
56  // INTERFACES FOR Control messages over a channel.
57  //=========================================================================
58 
59  /**
60  * @brief Interface to notify the remote entity of a topic being advertised.
61  *
62  * @param messageName
63  * This represents the uORB message name(aka topic); This message name should be
64  * globally unique.
65  * @return
66  * 0 = success; This means the messages is successfully sent to the receiver
67  * Note: This does not mean that the receiver as received it.
68  * otherwise = failure.
69  */
70  virtual int16_t topic_advertised(const char *messageName) = 0;
71 
72  /**
73  * @brief Interface to notify the remote entity of a topic being unadvertised
74  * and is no longer publishing messages.
75  *
76  * @param messageName
77  * This represents the uORB message name(aka topic); This message name should be
78  * globally unique.
79  * @return
80  * 0 = success; This means the messages is successfully sent to the receiver
81  * Note: This does not mean that the receiver as received it.
82  * otherwise = failure.
83  */
84  //virtual int16_t topic_unadvertised(const char *messageName) = 0;
85 
86  /**
87  * @brief Interface to notify the remote entity of interest of a
88  * subscription for a message.
89  *
90  * @param messageName
91  * This represents the uORB message name; This message name should be
92  * globally unique.
93  * @param msgRate
94  * The max rate at which the subscriber can accept the messages.
95  * @return
96  * 0 = success; This means the messages is successfully sent to the receiver
97  * Note: This does not mean that the receiver as received it.
98  * otherwise = failure.
99  */
100 
101  virtual int16_t add_subscription(const char *messageName, int32_t msgRateInHz) = 0;
102 
103 
104 
105  /**
106  * @brief Interface to notify the remote entity of removal of a subscription
107  *
108  * @param messageName
109  * This represents the uORB message name; This message name should be
110  * globally unique.
111  * @return
112  * 0 = success; This means the messages is successfully sent to the receiver
113  * Note: This does not necessarily mean that the receiver as received it.
114  * otherwise = failure.
115  */
116 
117  virtual int16_t remove_subscription(const char *messageName) = 0;
118 
119 
120  /**
121  * Register Message Handler. This is internal for the IChannel implementer*
122  */
123  virtual int16_t register_handler(uORBCommunicator::IChannelRxHandler *handler) = 0;
124 
125 
126  //=========================================================================
127  // INTERFACES FOR Data messages
128  //=========================================================================
129 
130  /**
131  * @brief Sends the data message over the communication link.
132  * @param messageName
133  * This represents the uORB message name; This message name should be
134  * globally unique.
135  * @param length
136  * The length of the data buffer to be sent.
137  * @param data
138  * The actual data to be sent.
139  * @return
140  * 0 = success; This means the messages is successfully sent to the receiver
141  * Note: This does not mean that the receiver as received it.
142  * otherwise = failure.
143  */
144 
145  virtual int16_t send_message(const char *messageName, int32_t length, uint8_t *data) = 0;
146 
147 };
148 
149 /**
150  * Class passed to the communication link implement to provide callback for received
151  * messages over a channel.
152  */
154 {
155 public:
156 
157  /**
158  * Interface to process a received topic from remote.
159  * @param topic_name
160  * This represents the uORB message Name (topic); This message Name should be
161  * globally unique.
162  * @param isAdvertisement
163  * Represents if the topic has been advertised or is no longer avialable.
164  * @return
165  * 0 = success; This means the messages is successfully handled in the
166  * handler.
167  * otherwise = failure.
168  */
169 
170  virtual int16_t process_remote_topic(const char *topic_name, bool isAdvertisement) = 0;
171 
172  /**
173  * Interface to process a received AddSubscription from remote.
174  * @param messageName
175  * This represents the uORB message Name; This message Name should be
176  * globally unique.
177  * @param msgRate
178  * The max rate at which the subscriber can accept the messages.
179  * @return
180  * 0 = success; This means the messages is successfully handled in the
181  * handler.
182  * otherwise = failure.
183  */
184 
185  virtual int16_t process_add_subscription(const char *messageName, int32_t msgRateInHz) = 0;
186 
187 
188  /**
189  * Interface to process a received control msg to remove subscription
190  * @param messageName
191  * This represents the uORB message Name; This message Name should be
192  * globally unique.
193  * @return
194  * 0 = success; This means the messages is successfully handled in the
195  * handler.
196  * otherwise = failure.
197  */
198 
199  virtual int16_t process_remove_subscription(const char *messageName) = 0;
200 
201 
202  /**
203  * Interface to process the received data message.
204  * @param messageName
205  * This represents the uORB message Name; This message Name should be
206  * globally unique.
207  * @param length
208  * The length of the data buffer to be sent.
209  * @param data
210  * The actual data to be sent.
211  * @return
212  * 0 = success; This means the messages is successfully handled in the
213  * handler.
214  * otherwise = failure.
215  */
216 
217  virtual int16_t process_received_message(const char *messageName, int32_t length, uint8_t *data) = 0;
218 
219 };
220 
221 #endif /* _uORBCommunicator_hpp_ */
virtual int16_t topic_advertised(const char *messageName)=0
Interface to notify the remote entity of a topic being advertised.
virtual int16_t send_message(const char *messageName, int32_t length, uint8_t *data)=0
Sends the data message over the communication link.
virtual int16_t remove_subscription(const char *messageName)=0
Interface to notify the remote entity of removal of a subscription.
virtual int16_t add_subscription(const char *messageName, int32_t msgRateInHz)=0
Interface to notify the remote entity of a topic being unadvertised and is no longer publishing messa...
uint8_t * data
Definition: dataman.cpp:149
Class passed to the communication link implement to provide callback for received messages over a cha...
virtual int16_t register_handler(uORBCommunicator::IChannelRxHandler *handler)=0
Register Message Handler.
Interface to enable remote subscriptions.