39 #ifdef ORB_COMMUNICATOR 43 #include <px4_platform_common/sem.hpp> 48 px4_sem_init(&
_lock, 0, 1);
54 px4_sem_destroy(&
_lock);
75 unsigned group_tries = 0;
83 if (group_tries >= max_group_tries) {
88 SmartLock smart_lock(
_lock);
92 if (instance !=
nullptr) {
94 nodepath[strlen(nodepath) - 1] =
'0' + group_tries;
95 *instance = group_tries;
99 const char *devpath = strdup(nodepath);
101 if (devpath ==
nullptr) {
109 if (node ==
nullptr) {
110 free((
void *)devpath);
121 if (ret == -EEXIST) {
136 bool is_single_instance_advertiser = is_advertiser && !
instance;
138 if (existing_node !=
nullptr &&
139 (!existing_node->
is_advertised() || is_single_instance_advertiser || !is_advertiser)) {
166 }
while (ret != PX4_OK && (group_tries < max_group_tries));
168 if (ret != PX4_OK && group_tries >= max_group_tries) {
181 PX4_INFO(
"TOPIC, NR LOST MSGS");
182 bool had_print =
false;
189 size_t max_topic_name_length = 0;
191 int ret =
addNewDeviceNodes(&first_node, num_topics, max_topic_name_length,
nullptr, 0);
195 PX4_ERR(
"addNewDeviceNodes failed (%i)", ret);
198 cur_node = first_node;
206 cur_node = cur_node->
next;
211 PX4_INFO(
"No lost messages");
216 size_t &max_topic_name_length,
char **topic_filter,
int num_filters)
223 while (last_node->
next) {
224 last_node = last_node->
next;
233 cur_node = *first_node;
235 while (cur_node && cur_node->
node != node) {
236 cur_node = cur_node->
next;
243 if (num_filters > 0 && topic_filter) {
244 bool matched =
false;
246 for (
int i = 0; i < num_filters; ++i) {
247 if (strstr(node->get_meta()->o_name, topic_filter[i])) {
259 last_node = last_node->
next;
269 last_node->
node = node;
273 if (name_length > max_topic_name_length) {
274 max_topic_name_length = name_length;
284 #define CLEAR_LINE "\033[K" 288 bool print_active_only =
true;
289 bool only_once =
false;
291 if (topic_filter && num_filters > 0) {
292 bool show_all =
false;
294 for (
int i = 0; i < num_filters; ++i) {
295 if (!strcmp(
"-a", topic_filter[i])) {
298 }
else if (!strcmp(
"-1", topic_filter[i])) {
303 print_active_only = only_once ? (num_filters == 1) :
false;
305 if (show_all || print_active_only) {
310 PX4_INFO_RAW(
"\033[2J\n");
316 PX4_INFO(
"no active topics");
322 size_t max_topic_name_length = 0;
324 int ret =
addNewDeviceNodes(&first_node, num_topics, max_topic_name_length, topic_filter, num_filters);
330 PX4_ERR(
"addNewDeviceNodes failed (%i)", ret);
333 #ifdef __PX4_QURT //QuRT has no poll() 336 const int stdin_fileno = 0;
339 fds.fd = stdin_fileno;
351 for (
int k = 0; k < 5; k++) {
354 ret = ::poll(&fds, 1, 0);
358 ret =
::read(stdin_fileno, &c, 1);
375 float dt = (current_time - start_time) / 1.e6f;
376 cur_node = first_node;
385 cur_node = cur_node->
next;
388 start_time = current_time;
391 PX4_INFO_RAW(
"\033[H");
392 PX4_INFO_RAW(
CLEAR_LINE "update: 1s, num topics: %i\n", num_topics);
393 PX4_INFO_RAW(
CLEAR_LINE "%-*s INST #SUB #MSG #LOST #QSIZE\n", (
int)max_topic_name_length - 2,
"TOPIC NAME");
394 cur_node = first_node;
399 PX4_INFO_RAW(
CLEAR_LINE "%-*s %2i %4i %4i %5i %i\n", (
int)max_topic_name_length,
405 cur_node = cur_node->
next;
409 ret =
addNewDeviceNodes(&first_node, num_topics, max_topic_name_length, topic_filter, num_filters);
413 PX4_ERR(
"addNewDeviceNodes failed (%i)", ret);
424 cur_node = first_node;
429 cur_node = next_node;
440 if (strcmp(node->get_devname(), nodepath) == 0) {
453 if (meta ==
nullptr) {
469 if ((strcmp(node->get_name(), meta->
o_name) == 0) && (node->get_instance() ==
instance)) {
uint8_t get_queue_size() const
List< uORB::DeviceNode * > _node_list
void set_priority(uint8_t priority)
uint32_t lost_message_count() const
int addNewDeviceNodes(DeviceNodeStatisticsData **first_node, int &num_topics, size_t &max_topic_name_length, char **topic_filter, int num_filters)
A set of useful macros for enhanced runtime and compile time error detection and warning suppression...
int8_t subscriber_count() const
int reset(enum LPS22HB_BUS busid)
Reset the driver.
void mark_as_advertised()
uORB::DeviceNode * getDeviceNodeLocked(const struct orb_metadata *meta, const uint8_t instance)
Find a node give its name.
static void read(bootloader_app_shared_t *pshared)
unsigned published_message_count() const
Per-object device instance.
uint32_t last_lost_msg_count
__BEGIN_DECLS typedef uint64_t hrt_abstime
Absolute time, in microsecond units.
bool is_advertised() const
Return true if this topic has been advertised.
uint8_t get_instance() const
hrt_abstime _last_statistics_output
const orb_metadata * get_meta() const
void showTop(char **topic_filter, int num_filters)
Continuously print statistics, like the unix top command for processes.
static constexpr unsigned orb_maxpath
unsigned int pub_msg_delta
px4_sem_t _lock
lock to protect access to all class members (also for derived classes)
#define ORB_MULTI_MAX_INSTANCES
Maximum number of multi topic instances.
bool print_statistics(bool reset)
Print statistics (nr of lost messages)
DeviceNodeStatisticsData * next
__EXPORT hrt_abstime hrt_absolute_time(void)
Get absolute time in [us] (does not wrap).
uORB::DeviceNode * getDeviceNode(const char *node_name)
Public interface for getDeviceNodeLocked().
void printStatistics(bool reset)
Print statistics for each existing topic.
static int node_mkpath(char *buf, const struct orb_metadata *meta, int *instance=nullptr)
unsigned int last_pub_msg_count
int advertise(const struct orb_metadata *meta, bool is_advertiser, int *instance, int priority)