PX4 Firmware
PX4 Autopilot Software http://px4.io
uORB::FastRpcChannel Class Reference

#include <uORBFastRpcChannel.hpp>

Inheritance diagram for uORB::FastRpcChannel:
Collaboration diagram for uORB::FastRpcChannel:

Classes

struct  BulkTransferHeader
 
struct  FastRpcControlMsg
 
struct  FastRpcDataMsg
 
class  Mutex
 
class  Semaphore
 

Public Member Functions

virtual int16_t topic_advertised (const char *messageName)
 Interface to notify the remote entity of a topic being advertised. More...
 
virtual int16_t topic_unadvertised (const char *messageName)
 Interface to notify the remote entity of a topic being unadvertised and is no longer publishing messages. More...
 
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. More...
 
virtual int16_t remove_subscription (const char *messageName)
 Interface to notify the remote entity of removal of a subscription. More...
 
virtual int16_t register_handler (uORBCommunicator::IChannelRxHandler *handler)
 Register Message Handler. More...
 
virtual int16_t send_message (const char *messageName, int32_t length, uint8_t *data)
 Sends the data message over the communication link. More...
 
int16_t get_data (int32_t *msg_type, char *topic_name, int32_t topic_name_len, uint8_t *data, int32_t data_len_in_bytes, int32_t *bytes_returned)
 
int16_t get_bulk_data (uint8_t *buffer, int32_t max_size_in_bytes, int32_t *returned_bytes, int32_t *topic_count)
 
int16_t is_subscriber_present (const char *messageName, int32_t *status)
 
int16_t unblock_get_data_method ()
 
uORBCommunicator::IChannelRxHandlerGetRxHandler ()
 
void AddRemoteSubscriber (const std::string &messageName)
 
void RemoveRemoteSubscriber (const std::string &messageName)
 

Static Public Member Functions

static uORB::FastRpcChannelGetInstance ()
 static method to get the IChannel Implementor. More...
 

Private Member Functions

 FastRpcChannel ()
 constructor. More...
 
void check_and_expand_data_buffer (int32_t index, int32_t length)
 
bool IsControlQFull ()
 
bool IsControlQEmpty ()
 
bool IsDataQFull ()
 
bool IsDataQEmpty ()
 
int32_t DataQSize ()
 
int32_t ControlQSize ()
 
int32_t get_msg_size_at (bool isData, int32_t index)
 
int32_t copy_msg_to_buffer (bool isData, int32_t src_index, uint8_t *dst_buffer, int32_t offset, int32_t dst_buffer_len)
 
int16_t control_msg_queue_add (int32_t msgtype, const char *messageName)
 

Private Attributes

uORBCommunicator::IChannelRxHandler_RxHandler
 
struct FastRpcDataMsg _DataMsgQueue [_MAX_MSG_QUEUE_SIZE]
 
int32_t _DataQInIndex
 
int32_t _DataQOutIndex
 
struct FastRpcControlMsg _ControlMsgQueue [_MAX_MSG_QUEUE_SIZE]
 
int32_t _ControlQInIndex
 
int32_t _ControlQOutIndex
 
std::list< std::string > _Subscribers
 
Mutex _QueueMutex
 
Semaphore _DataAvailableSemaphore
 
std::set< std::string > _RemoteSubscribers
 

Static Private Attributes

static uORB::FastRpcChannel _Instance
 
static const int32_t _MAX_MSG_QUEUE_SIZE = 100
 data structure to store the messages to be retrived by Krait. More...
 
static const int32_t _CONTROL_MSG_TYPE_ADD_SUBSCRIBER = 1
 
static const int32_t _CONTROL_MSG_TYPE_REMOVE_SUBSCRIBER = 2
 
static const int32_t _DATA_MSG_TYPE = 3
 
static const int32_t _CONTROL_MSG_TYPE_ADVERTISE = 4
 
static const int32_t _CONTROL_MSG_TYPE_UNADVERTISE = 5
 
static const int32_t _PACKET_FIELD_TOPIC_NAME_LEN_SIZE_IN_BYTES = 2
 
static const int32_t _PACKET_FIELD_DATA_LEN_IN_BYTES = 2
 
static const int32_t _PACKET_HEADER_SIZE
 

Detailed Description

Definition at line 49 of file uORBFastRpcChannel.hpp.

Constructor & Destructor Documentation

◆ FastRpcChannel()

Member Function Documentation

◆ add_subscription()

int16_t uORB::FastRpcChannel::add_subscription ( const char *  messageName,
int32_t  msgRateInHz 
)
virtual

Interface to notify the remote entity of interest of a subscription for a message.

Parameters
messageNameThis represents the uORB message name; This message name should be globally unique.
msgRateThe max rate at which the subscriber can accept the messages.
Returns
0 = success; This means the messages is successfully sent to the receiver Note: This does not mean that the receiver as received it. otherwise = failure.

Implements uORBCommunicator::IChannel.

Definition at line 149 of file uORBFastRpcChannel.cpp.

References _Subscribers.

Referenced by GetInstance().

Here is the caller graph for this function:

◆ AddRemoteSubscriber()

void uORB::FastRpcChannel::AddRemoteSubscriber ( const std::string &  messageName)
inline

Definition at line 167 of file uORBFastRpcChannel.hpp.

References _RemoteSubscribers.

Referenced by px4muorb_add_subscriber().

Here is the caller graph for this function:

◆ check_and_expand_data_buffer()

void uORB::FastRpcChannel::check_and_expand_data_buffer ( int32_t  index,
int32_t  length 
)
private

Definition at line 284 of file uORBFastRpcChannel.cpp.

References uORB::FastRpcChannel::FastRpcDataMsg::_Buffer, _DataMsgQueue, and uORB::FastRpcChannel::FastRpcDataMsg::_MaxBufferSize.

Referenced by send_message().

Here is the caller graph for this function:

◆ control_msg_queue_add()

int16_t uORB::FastRpcChannel::control_msg_queue_add ( int32_t  msgtype,
const char *  messageName 
)
private

Definition at line 88 of file uORBFastRpcChannel.cpp.

References _avg_q, _ControlMsgQueue, _ControlQInIndex, _ControlQOutIndex, _count, _DataAvailableSemaphore, _dropped_pkts, _MAX_MSG_QUEUE_SIZE, _max_q, _min_q, uORB::FastRpcChannel::FastRpcControlMsg::_MsgName, _QueueMutex, uORB::FastRpcChannel::FastRpcControlMsg::_Type, ControlQSize(), DataQSize(), hrt_absolute_time(), hrt_abstime, IsControlQFull(), uORB::FastRpcChannel::Mutex::lock(), uORB::FastRpcChannel::Semaphore::post(), t1, t2, and uORB::FastRpcChannel::Mutex::unlock().

Referenced by topic_advertised(), and topic_unadvertised().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ControlQSize()

int32_t uORB::FastRpcChannel::ControlQSize ( )
private

Definition at line 312 of file uORBFastRpcChannel.cpp.

References _ControlQInIndex, _ControlQOutIndex, and _MAX_MSG_QUEUE_SIZE.

Referenced by control_msg_queue_add(), get_bulk_data(), get_data(), IsControlQEmpty(), IsControlQFull(), and send_message().

Here is the caller graph for this function:

◆ copy_msg_to_buffer()

int32_t uORB::FastRpcChannel::copy_msg_to_buffer ( bool  isData,
int32_t  src_index,
uint8_t *  dst_buffer,
int32_t  offset,
int32_t  dst_buffer_len 
)
private

Definition at line 636 of file uORBFastRpcChannel.cpp.

References _ControlMsgQueue, _DATA_MSG_TYPE, _DataMsgQueue, uORB::FastRpcChannel::FastRpcDataMsg::_Length, uORB::FastRpcChannel::FastRpcDataMsg::_MsgName, uORB::FastRpcChannel::FastRpcControlMsg::_MsgName, and uORB::FastRpcChannel::FastRpcControlMsg::_Type.

Referenced by get_bulk_data().

Here is the caller graph for this function:

◆ DataQSize()

int32_t uORB::FastRpcChannel::DataQSize ( )
private

Definition at line 304 of file uORBFastRpcChannel.cpp.

References _DataQInIndex, _DataQOutIndex, and _MAX_MSG_QUEUE_SIZE.

Referenced by control_msg_queue_add(), get_bulk_data(), get_data(), IsDataQEmpty(), IsDataQFull(), and send_message().

Here is the caller graph for this function:

◆ get_bulk_data()

int16_t uORB::FastRpcChannel::get_bulk_data ( uint8_t *  buffer,
int32_t  max_size_in_bytes,
int32_t *  returned_bytes,
int32_t *  topic_count 
)

Definition at line 460 of file uORBFastRpcChannel.cpp.

References _bulk_topic_count_max, _bulk_topic_count_min, _ControlQOutIndex, _DataAvailableSemaphore, _DataQOutIndex, _get_bulk_max, _get_bulk_min, _MAX_MSG_QUEUE_SIZE, _QueueMutex, ControlQSize(), copy_msg_to_buffer(), DataQSize(), get_msg_size_at(), hrt_absolute_time(), hrt_abstime, uORB::FastRpcChannel::Mutex::lock(), t1, t3, uORB::FastRpcChannel::Mutex::unlock(), and uORB::FastRpcChannel::Semaphore::wait().

Referenced by get_data(), GetInstance(), and px4muorb_receive_bulk_data().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_data()

int16_t uORB::FastRpcChannel::get_data ( int32_t *  msg_type,
char *  topic_name,
int32_t  topic_name_len,
uint8_t *  data,
int32_t  data_len_in_bytes,
int32_t *  bytes_returned 
)

Definition at line 341 of file uORBFastRpcChannel.cpp.

References _ControlMsgQueue, _ControlQOutIndex, _DATA_MSG_TYPE, _DataAvailableSemaphore, _DataMsgQueue, _DataQOutIndex, _get_max, _get_min, _MAX_MSG_QUEUE_SIZE, uORB::FastRpcChannel::FastRpcDataMsg::_MsgName, uORB::FastRpcChannel::FastRpcControlMsg::_MsgName, _QueueMutex, uORB::FastRpcChannel::FastRpcControlMsg::_Type, ControlQSize(), DataQSize(), get_bulk_data(), hrt_absolute_time(), hrt_abstime, uORB::FastRpcChannel::Mutex::lock(), t1, t3, uORB::FastRpcChannel::Mutex::unlock(), and uORB::FastRpcChannel::Semaphore::wait().

Referenced by GetInstance(), IsDataQEmpty(), and px4muorb_receive_msg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_msg_size_at()

int32_t uORB::FastRpcChannel::get_msg_size_at ( bool  isData,
int32_t  index 
)
private

Definition at line 618 of file uORBFastRpcChannel.cpp.

References _ControlMsgQueue, _DataMsgQueue, uORB::FastRpcChannel::FastRpcDataMsg::_Length, uORB::FastRpcChannel::FastRpcDataMsg::_MsgName, uORB::FastRpcChannel::FastRpcControlMsg::_MsgName, and _PACKET_HEADER_SIZE.

Referenced by get_bulk_data().

Here is the caller graph for this function:

◆ GetInstance()

static uORB::FastRpcChannel* uORB::FastRpcChannel::GetInstance ( )
inlinestatic

static method to get the IChannel Implementor.

Definition at line 55 of file uORBFastRpcChannel.hpp.

References _Instance, add_subscription(), data, get_bulk_data(), get_data(), is_subscriber_present(), register_handler(), remove_subscription(), send_message(), status, topic_advertised(), topic_unadvertised(), and unblock_get_data_method().

Referenced by px4muorb_add_subscriber(), px4muorb_is_subscriber_present(), px4muorb_orb_initialize(), px4muorb_receive_bulk_data(), px4muorb_receive_msg(), px4muorb_remove_subscriber(), px4muorb_send_topic_data(), px4muorb_topic_advertised(), px4muorb_topic_unadvertised(), and px4muorb_unblock_recieve_msg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetRxHandler()

uORBCommunicator::IChannelRxHandler* uORB::FastRpcChannel::GetRxHandler ( )
inline

Definition at line 162 of file uORBFastRpcChannel.hpp.

References _RxHandler.

Referenced by px4muorb_add_subscriber(), px4muorb_remove_subscriber(), px4muorb_send_topic_data(), px4muorb_topic_advertised(), and px4muorb_topic_unadvertised().

Here is the caller graph for this function:

◆ is_subscriber_present()

int16_t uORB::FastRpcChannel::is_subscriber_present ( const char *  messageName,
int32_t *  status 
)

Definition at line 167 of file uORBFastRpcChannel.cpp.

References _Subscribers, and param_value_u::i.

Referenced by GetInstance(), and px4muorb_is_subscriber_present().

Here is the caller graph for this function:

◆ IsControlQEmpty()

bool uORB::FastRpcChannel::IsControlQEmpty ( )
private

Definition at line 325 of file uORBFastRpcChannel.cpp.

References ControlQSize().

Here is the call graph for this function:

◆ IsControlQFull()

bool uORB::FastRpcChannel::IsControlQFull ( )
private

Definition at line 320 of file uORBFastRpcChannel.cpp.

References _MAX_MSG_QUEUE_SIZE, and ControlQSize().

Referenced by control_msg_queue_add().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsDataQEmpty()

bool uORB::FastRpcChannel::IsDataQEmpty ( )
private

Definition at line 335 of file uORBFastRpcChannel.cpp.

References DataQSize(), and get_data().

Here is the call graph for this function:

◆ IsDataQFull()

bool uORB::FastRpcChannel::IsDataQFull ( )
private

Definition at line 330 of file uORBFastRpcChannel.cpp.

References _MAX_MSG_QUEUE_SIZE, and DataQSize().

Referenced by send_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ register_handler()

int16_t uORB::FastRpcChannel::register_handler ( uORBCommunicator::IChannelRxHandler handler)
virtual

Register Message Handler.

This is internal for the IChannel implementer*

Implements uORBCommunicator::IChannel.

Definition at line 200 of file uORBFastRpcChannel.cpp.

References _RxHandler.

Referenced by GetInstance().

Here is the caller graph for this function:

◆ remove_subscription()

int16_t uORB::FastRpcChannel::remove_subscription ( const char *  messageName)
virtual

Interface to notify the remote entity of removal of a subscription.

Parameters
messageNameThis represents the uORB message name; This message name should be globally unique.
Returns
0 = success; This means the messages is successfully sent to the receiver Note: This does not necessarily mean that the receiver as received it. otherwise = failure.

Implements uORBCommunicator::IChannel.

Definition at line 159 of file uORBFastRpcChannel.cpp.

References _Subscribers.

Referenced by GetInstance().

Here is the caller graph for this function:

◆ RemoveRemoteSubscriber()

void uORB::FastRpcChannel::RemoveRemoteSubscriber ( const std::string &  messageName)
inline

Definition at line 171 of file uORBFastRpcChannel.hpp.

References _RemoteSubscribers.

Referenced by px4muorb_add_subscriber(), and px4muorb_remove_subscriber().

Here is the caller graph for this function:

◆ send_message()

int16_t uORB::FastRpcChannel::send_message ( const char *  messageName,
int32_t  length,
uint8_t *  data 
)
virtual

Sends the data message over the communication link.

Parameters
messageNameThis represents the uORB message name; This message name should be globally unique.
lengthThe length of the data buffer to be sent.
dataThe actual data to be sent.
Returns
0 = success; This means the messages is successfully sent to the receiver Note: This does not mean that the receiver as received it. otherwise = failure.

Implements uORBCommunicator::IChannel.

Definition at line 209 of file uORBFastRpcChannel.cpp.

References _avg_q, _count, _DataAvailableSemaphore, _DataMsgQueue, _DataQInIndex, _DataQOutIndex, _dropped_pkts, uORB::FastRpcChannel::FastRpcDataMsg::_Length, _MAX_MSG_QUEUE_SIZE, _max_q, _min_q, uORB::FastRpcChannel::FastRpcDataMsg::_MsgName, _QueueMutex, _RemoteSubscribers, check_and_expand_data_buffer(), ControlQSize(), DataQSize(), hrt_absolute_time(), hrt_abstime, IsDataQFull(), uORB::FastRpcChannel::Mutex::lock(), uORB::FastRpcChannel::Semaphore::post(), t1, t2, and uORB::FastRpcChannel::Mutex::unlock().

Referenced by GetInstance().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ topic_advertised()

int16_t uORB::FastRpcChannel::topic_advertised ( const char *  messageName)
virtual

Interface to notify the remote entity of a topic being advertised.

Parameters
messageNameThis represents the uORB message name(aka topic); This message name should be globally unique.
Returns
0 = success; This means the messages is successfully sent to the receiver Note: This does not mean that the receiver as received it. otherwise = failure.

Implements uORBCommunicator::IChannel.

Definition at line 74 of file uORBFastRpcChannel.cpp.

References _CONTROL_MSG_TYPE_ADVERTISE, and control_msg_queue_add().

Referenced by GetInstance().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ topic_unadvertised()

int16_t uORB::FastRpcChannel::topic_unadvertised ( const char *  messageName)
virtual

Interface to notify the remote entity of a topic being unadvertised and is no longer publishing messages.

Parameters
messageNameThis represents the uORB message name(aka topic); This message name should be globally unique.
Returns
0 = success; This means the messages is successfully sent to the receiver Note: This does not mean that the receiver as received it. otherwise = failure.

Definition at line 81 of file uORBFastRpcChannel.cpp.

References _CONTROL_MSG_TYPE_UNADVERTISE, and control_msg_queue_add().

Referenced by GetInstance().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unblock_get_data_method()

int16_t uORB::FastRpcChannel::unblock_get_data_method ( )

Definition at line 192 of file uORBFastRpcChannel.cpp.

References _DataAvailableSemaphore, and uORB::FastRpcChannel::Semaphore::post().

Referenced by GetInstance(), and px4muorb_unblock_recieve_msg().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _CONTROL_MSG_TYPE_ADD_SUBSCRIBER

const int32_t uORB::FastRpcChannel::_CONTROL_MSG_TYPE_ADD_SUBSCRIBER = 1
staticprivate

Definition at line 182 of file uORBFastRpcChannel.hpp.

◆ _CONTROL_MSG_TYPE_ADVERTISE

const int32_t uORB::FastRpcChannel::_CONTROL_MSG_TYPE_ADVERTISE = 4
staticprivate

Definition at line 185 of file uORBFastRpcChannel.hpp.

Referenced by topic_advertised().

◆ _CONTROL_MSG_TYPE_REMOVE_SUBSCRIBER

const int32_t uORB::FastRpcChannel::_CONTROL_MSG_TYPE_REMOVE_SUBSCRIBER = 2
staticprivate

Definition at line 183 of file uORBFastRpcChannel.hpp.

◆ _CONTROL_MSG_TYPE_UNADVERTISE

const int32_t uORB::FastRpcChannel::_CONTROL_MSG_TYPE_UNADVERTISE = 5
staticprivate

Definition at line 186 of file uORBFastRpcChannel.hpp.

Referenced by topic_unadvertised().

◆ _ControlMsgQueue

struct FastRpcControlMsg uORB::FastRpcChannel::_ControlMsgQueue[_MAX_MSG_QUEUE_SIZE]
private

◆ _ControlQInIndex

int32_t uORB::FastRpcChannel::_ControlQInIndex
private

Definition at line 217 of file uORBFastRpcChannel.hpp.

Referenced by control_msg_queue_add(), and ControlQSize().

◆ _ControlQOutIndex

int32_t uORB::FastRpcChannel::_ControlQOutIndex
private

◆ _DATA_MSG_TYPE

const int32_t uORB::FastRpcChannel::_DATA_MSG_TYPE = 3
staticprivate

Definition at line 184 of file uORBFastRpcChannel.hpp.

Referenced by copy_msg_to_buffer(), and get_data().

◆ _DataAvailableSemaphore

Semaphore uORB::FastRpcChannel::_DataAvailableSemaphore
private

◆ _DataMsgQueue

struct FastRpcDataMsg uORB::FastRpcChannel::_DataMsgQueue[_MAX_MSG_QUEUE_SIZE]
private

◆ _DataQInIndex

int32_t uORB::FastRpcChannel::_DataQInIndex
private

Definition at line 213 of file uORBFastRpcChannel.hpp.

Referenced by DataQSize(), and send_message().

◆ _DataQOutIndex

int32_t uORB::FastRpcChannel::_DataQOutIndex
private

Definition at line 214 of file uORBFastRpcChannel.hpp.

Referenced by DataQSize(), get_bulk_data(), get_data(), and send_message().

◆ _Instance

uORB::FastRpcChannel uORB::FastRpcChannel::_Instance
staticprivate

Definition at line 177 of file uORBFastRpcChannel.hpp.

Referenced by GetInstance().

◆ _MAX_MSG_QUEUE_SIZE

const int32_t uORB::FastRpcChannel::_MAX_MSG_QUEUE_SIZE = 100
staticprivate

data structure to store the messages to be retrived by Krait.

Definition at line 181 of file uORBFastRpcChannel.hpp.

Referenced by control_msg_queue_add(), ControlQSize(), DataQSize(), FastRpcChannel(), get_bulk_data(), get_data(), IsControlQFull(), IsDataQFull(), and send_message().

◆ _PACKET_FIELD_DATA_LEN_IN_BYTES

const int32_t uORB::FastRpcChannel::_PACKET_FIELD_DATA_LEN_IN_BYTES = 2
staticprivate

Definition at line 189 of file uORBFastRpcChannel.hpp.

◆ _PACKET_FIELD_TOPIC_NAME_LEN_SIZE_IN_BYTES

const int32_t uORB::FastRpcChannel::_PACKET_FIELD_TOPIC_NAME_LEN_SIZE_IN_BYTES = 2
staticprivate

Definition at line 188 of file uORBFastRpcChannel.hpp.

◆ _PACKET_HEADER_SIZE

const int32_t uORB::FastRpcChannel::_PACKET_HEADER_SIZE
staticprivate

◆ _QueueMutex

Mutex uORB::FastRpcChannel::_QueueMutex
private

◆ _RemoteSubscribers

std::set<std::string> uORB::FastRpcChannel::_RemoteSubscribers
private

◆ _RxHandler

uORBCommunicator::IChannelRxHandler* uORB::FastRpcChannel::_RxHandler
private

Definition at line 178 of file uORBFastRpcChannel.hpp.

Referenced by GetRxHandler(), and register_handler().

◆ _Subscribers

std::list<std::string> uORB::FastRpcChannel::_Subscribers
private

The documentation for this class was generated from the following files: