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

Master control device for ObjDev. More...

#include <uORBDeviceMaster.hpp>

Collaboration diagram for uORB::DeviceMaster:

Classes

struct  DeviceNodeStatisticsData
 

Public Member Functions

int advertise (const struct orb_metadata *meta, bool is_advertiser, int *instance, int priority)
 
uORB::DeviceNodegetDeviceNode (const char *node_name)
 Public interface for getDeviceNodeLocked(). More...
 
uORB::DeviceNodegetDeviceNode (const struct orb_metadata *meta, const uint8_t instance)
 
void printStatistics (bool reset)
 Print statistics for each existing topic. More...
 
void showTop (char **topic_filter, int num_filters)
 Continuously print statistics, like the unix top command for processes. More...
 

Private Member Functions

 DeviceMaster ()
 
 ~DeviceMaster ()
 
int addNewDeviceNodes (DeviceNodeStatisticsData **first_node, int &num_topics, size_t &max_topic_name_length, char **topic_filter, int num_filters)
 
uORB::DeviceNodegetDeviceNodeLocked (const struct orb_metadata *meta, const uint8_t instance)
 Find a node give its name. More...
 
void lock ()
 
void unlock ()
 

Private Attributes

List< uORB::DeviceNode * > _node_list
 
hrt_abstime _last_statistics_output
 
px4_sem_t _lock
 lock to protect access to all class members (also for derived classes) More...
 

Friends

class uORB::Manager
 

Detailed Description

Master control device for ObjDev.

Used primarily to create new objects via the ORBIOCCREATE ioctl.

Definition at line 59 of file uORBDeviceMaster.hpp.

Constructor & Destructor Documentation

◆ DeviceMaster()

uORB::DeviceMaster::DeviceMaster ( )
private

Definition at line 46 of file uORBDeviceMaster.cpp.

References _last_statistics_output, _lock, and hrt_absolute_time().

Here is the call graph for this function:

◆ ~DeviceMaster()

uORB::DeviceMaster::~DeviceMaster ( )
private

Definition at line 52 of file uORBDeviceMaster.cpp.

References _lock.

Member Function Documentation

◆ addNewDeviceNodes()

int uORB::DeviceMaster::addNewDeviceNodes ( DeviceNodeStatisticsData **  first_node,
int &  num_topics,
size_t &  max_topic_name_length,
char **  topic_filter,
int  num_filters 
)
private

Definition at line 215 of file uORBDeviceMaster.cpp.

References _node_list, uORB::DeviceNode::get_meta(), uORB::DeviceMaster::DeviceNodeStatisticsData::last_lost_msg_count, uORB::DeviceMaster::DeviceNodeStatisticsData::last_pub_msg_count, uORB::DeviceNode::lost_message_count(), uORB::DeviceMaster::DeviceNodeStatisticsData::next, uORB::DeviceMaster::DeviceNodeStatisticsData::node, orb_metadata::o_name, and uORB::DeviceNode::published_message_count().

Referenced by printStatistics(), and showTop().

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

◆ advertise()

int uORB::DeviceMaster::advertise ( const struct orb_metadata meta,
bool  is_advertiser,
int *  instance,
int  priority 
)

Definition at line 58 of file uORBDeviceMaster.cpp.

References _lock, _node_list, getDeviceNodeLocked(), cdev::CDev::init(), ll40ls::instance, uORB::DeviceNode::is_advertised(), uORB::DeviceNode::mark_as_advertised(), uORB::Utils::node_mkpath(), uORB::orb_maxpath, ORB_MULTI_MAX_INSTANCES, and uORB::DeviceNode::set_priority().

Referenced by uORB::Manager::node_advertise().

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

◆ getDeviceNode() [1/2]

uORB::DeviceNode * uORB::DeviceMaster::getDeviceNode ( const char *  node_name)

Public interface for getDeviceNodeLocked().

Takes care of synchronization.

Returns
node if exists, nullptr otherwise

Definition at line 435 of file uORBDeviceMaster.cpp.

References _node_list, lock(), and unlock().

Referenced by uORB::Manager::node_open(), uORB::Manager::orb_exists(), and uORB::Subscription::subscribe().

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

◆ getDeviceNode() [2/2]

uORB::DeviceNode * uORB::DeviceMaster::getDeviceNode ( const struct orb_metadata meta,
const uint8_t  instance 
)

Definition at line 451 of file uORBDeviceMaster.cpp.

References getDeviceNodeLocked(), lock(), and unlock().

Here is the call graph for this function:

◆ getDeviceNodeLocked()

uORB::DeviceNode * uORB::DeviceMaster::getDeviceNodeLocked ( const struct orb_metadata meta,
const uint8_t  instance 
)
private

Find a node give its name.

_lock must already be held when calling this.

Returns
node if exists, nullptr otherwise

Definition at line 466 of file uORBDeviceMaster.cpp.

References _node_list, ll40ls::instance, and orb_metadata::o_name.

Referenced by advertise(), and getDeviceNode().

Here is the caller graph for this function:

◆ lock()

void uORB::DeviceMaster::lock ( )
inlineprivate

Definition at line 119 of file uORBDeviceMaster.hpp.

Referenced by getDeviceNode(), printStatistics(), and showTop().

Here is the caller graph for this function:

◆ printStatistics()

void uORB::DeviceMaster::printStatistics ( bool  reset)

Print statistics for each existing topic.

Parameters
resetif true, reset statistics afterwards

Definition at line 175 of file uORBDeviceMaster.cpp.

References _last_statistics_output, addNewDeviceNodes(), hrt_absolute_time(), hrt_abstime, lock(), uORB::DeviceMaster::DeviceNodeStatisticsData::next, uORB::DeviceMaster::DeviceNodeStatisticsData::node, uORB::DeviceNode::print_statistics(), and unlock().

Referenced by uorb_main().

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

◆ showTop()

void uORB::DeviceMaster::showTop ( char **  topic_filter,
int  num_filters 
)

Continuously print statistics, like the unix top command for processes.

Exited when the user presses the enter key.

Parameters
topic_filterlist of topic filters: if set, each string can be a substring for topics to match. Or it can be '-a', which means to print all topics instead of only currently publishing ones.
num_filters

Definition at line 286 of file uORBDeviceMaster.cpp.

References _node_list, addNewDeviceNodes(), CLEAR_LINE, dt, uORB::DeviceNode::get_instance(), uORB::DeviceNode::get_meta(), uORB::DeviceNode::get_queue_size(), hrt_absolute_time(), hrt_abstime, uORB::DeviceMaster::DeviceNodeStatisticsData::last_lost_msg_count, uORB::DeviceMaster::DeviceNodeStatisticsData::last_pub_msg_count, lock(), uORB::DeviceNode::lost_message_count(), uORB::DeviceMaster::DeviceNodeStatisticsData::lost_msg_delta, uORB::DeviceMaster::DeviceNodeStatisticsData::next, uORB::DeviceMaster::DeviceNodeStatisticsData::node, orb_metadata::o_name, uORB::DeviceMaster::DeviceNodeStatisticsData::pub_msg_delta, uORB::DeviceNode::published_message_count(), read(), uORB::DeviceNode::subscriber_count(), and unlock().

Referenced by uorb_main().

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

◆ unlock()

void uORB::DeviceMaster::unlock ( )
inlineprivate

Definition at line 120 of file uORBDeviceMaster.hpp.

Referenced by getDeviceNode(), printStatistics(), and showTop().

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ uORB::Manager

friend class uORB::Manager
friend

Definition at line 104 of file uORBDeviceMaster.hpp.

Member Data Documentation

◆ _last_statistics_output

hrt_abstime uORB::DeviceMaster::_last_statistics_output
private

Definition at line 115 of file uORBDeviceMaster.hpp.

Referenced by DeviceMaster(), and printStatistics().

◆ _lock

px4_sem_t uORB::DeviceMaster::_lock
private

lock to protect access to all class members (also for derived classes)

Definition at line 117 of file uORBDeviceMaster.hpp.

Referenced by advertise(), DeviceMaster(), and ~DeviceMaster().

◆ _node_list

List<uORB::DeviceNode *> uORB::DeviceMaster::_node_list
private

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