33 #ifndef _uORBFastRpcChannel_hpp_ 34 #define _uORBFastRpcChannel_hpp_ 39 #include "uORB/uORBCommunicator.hpp" 40 #include <semaphore.h> 101 virtual int16_t
add_subscription(
const char *messageName, int32_t msgRateInHz);
141 virtual int16_t
send_message(
const char *messageName, int32_t length, uint8_t *data);
148 int32_t topic_name_len,
150 int32_t data_len_in_bytes,
151 int32_t *bytes_returned
154 int16_t get_bulk_data(uint8_t *
buffer, int32_t max_size_in_bytes, int32_t *returned_bytes, int32_t *topic_count);
157 int16_t is_subscriber_present(
const char *messageName, int32_t *status);
160 int16_t unblock_get_data_method();
167 void AddRemoteSubscriber(
const std::string &messageName)
169 _RemoteSubscribers.insert(messageName);
171 void RemoveRemoteSubscriber(
const std::string &messageName)
173 _RemoteSubscribers.erase(messageName);
181 static const int32_t _MAX_MSG_QUEUE_SIZE = 100;
182 static const int32_t _CONTROL_MSG_TYPE_ADD_SUBSCRIBER = 1;
183 static const int32_t _CONTROL_MSG_TYPE_REMOVE_SUBSCRIBER = 2;
184 static const int32_t _DATA_MSG_TYPE = 3;
185 static const int32_t _CONTROL_MSG_TYPE_ADVERTISE = 4;
186 static const int32_t _CONTROL_MSG_TYPE_UNADVERTISE = 5;
188 static const int32_t _PACKET_FIELD_TOPIC_NAME_LEN_SIZE_IN_BYTES = 2;
189 static const int32_t _PACKET_FIELD_DATA_LEN_IN_BYTES = 2;
190 static const int32_t _PACKET_HEADER_SIZE = 1 +
191 _PACKET_FIELD_TOPIC_NAME_LEN_SIZE_IN_BYTES + _PACKET_FIELD_DATA_LEN_IN_BYTES;
193 struct FastRpcDataMsg {
194 int32_t _MaxBufferSize;
197 std::string _MsgName;
200 struct FastRpcControlMsg {
202 std::string _MsgName;
205 struct BulkTransferHeader {
207 uint16_t _MsgNameLen;
212 struct FastRpcDataMsg _DataMsgQueue[ _MAX_MSG_QUEUE_SIZE ];
213 int32_t _DataQInIndex;
214 int32_t _DataQOutIndex;
216 struct FastRpcControlMsg _ControlMsgQueue[ _MAX_MSG_QUEUE_SIZE ];
217 int32_t _ControlQInIndex;
218 int32_t _ControlQOutIndex;
220 std::list<std::string> _Subscribers;
228 sem_init(&_Sem, 0, 1);
245 Mutex(
const Mutex &);
247 Mutex &operator=(
const Mutex &);
255 sem_init(&_Sem, 0, 0);
257 px4_sem_setprotocol(&_Sem, SEM_PRIO_NONE);
273 Semaphore(
const Semaphore &);
274 Semaphore &operator=(
const Semaphore &);
279 Semaphore _DataAvailableSemaphore;
285 void check_and_expand_data_buffer(int32_t index, int32_t length);
287 bool IsControlQFull();
288 bool IsControlQEmpty();
292 int32_t ControlQSize();
294 int32_t get_msg_size_at(
bool isData, int32_t index);
295 int32_t copy_msg_to_buffer(
bool isData, int32_t src_index, uint8_t *dst_buffer, int32_t offset, int32_t dst_buffer_len);
296 int16_t control_msg_queue_add(int32_t msgtype,
const char *messageName);
298 std::set<std::string> _RemoteSubscribers;
virtual int16_t remove_subscription(const char *messageName)
Interface to notify the remote entity of removal of a subscription.
Definition: uORBFastRpcChannel.cpp:159
static uORB::FastRpcChannel * GetInstance()
static method to get the IChannel Implementor.
Definition: uORBFastRpcChannel.hpp:55
virtual int16_t add_subscription(const char *messageName, int32_t msgRateInHz)
Interface to notify the remote entity of interest of a subscription for a message.
Definition: uORBFastRpcChannel.cpp:149
Definition: uORBFastRpcChannel.hpp:44
virtual int16_t topic_unadvertised(const char *messageName)
Interface to notify the remote entity of a topic being unadvertised and is no longer publishing messa...
Definition: uORBFastRpcChannel.cpp:81
Synchronization primitive: Semaphore.
Interface to enable remote subscriptions.
Definition: uORBCommunicator.hpp:51
Class passed to the communication link implement to provide callback for received messages over a cha...
Definition: uORBCommunicator.hpp:153
Definition: uORBFastRpcChannel.hpp:49
virtual int16_t topic_advertised(const char *messageName)
Interface to notify the remote entity of a topic being advertised.
Definition: uORBFastRpcChannel.cpp:74
virtual int16_t register_handler(uORBCommunicator::IChannelRxHandler *handler)
Register Message Handler.
Definition: uORBFastRpcChannel.cpp:200
Definition: video_device.h:50
virtual int16_t send_message(const char *messageName, int32_t length, uint8_t *data)
Sends the data message over the communication link.
Definition: uORBFastRpcChannel.cpp:209