orb status: print information about lost messages

This commit is contained in:
Beat Küng
2016-05-23 10:22:32 +02:00
committed by Lorenz Meier
parent 7280f71cef
commit b86cf2b017
6 changed files with 142 additions and 5 deletions
+48 -1
View File
@@ -203,6 +203,7 @@ uORB::DeviceNode::read(device::file_t *filp, char *buffer, size_t buflen)
if (_generation > sd->generation + _queue_size) {
/* Reader is too far behind: some messages are lost */
_lost_messages += _generation - (sd->generation + _queue_size);
sd->generation = _generation - _queue_size;
}
@@ -553,6 +554,27 @@ uORB::DeviceNode::update_deferred_trampoline(void *arg)
node->update_deferred();
}
bool
uORB::DeviceNode::print_statistics(bool reset)
{
if (!_lost_messages) {
return false;
}
lock();
//This can be wrong: if a reader never reads, _lost_messages will not be increased either
uint32_t lost_messages = _lost_messages;
if (reset) {
_lost_messages = 0;
}
unlock();
PX4_INFO("%s: %i", _meta->o_name, lost_messages);
return true;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void uORB::DeviceNode::add_internal_subscriber()
@@ -657,7 +679,7 @@ uORB::DeviceMaster::DeviceMaster(Flavor f) :
{
// enable debug() calls
//_debug_enabled = true;
_last_statistics_output = hrt_absolute_time();
}
uORB::DeviceMaster::~DeviceMaster()
@@ -777,6 +799,31 @@ uORB::DeviceMaster::ioctl(device::file_t *filp, int cmd, unsigned long arg)
}
}
void uORB::DeviceMaster::printStatistics(bool reset)
{
hrt_abstime current_time = hrt_absolute_time();
PX4_INFO("Statistics, since last output (%i ms):",
(int)((current_time - _last_statistics_output) / 1000));
_last_statistics_output = current_time;
PX4_INFO("TOPIC, NR LOST MSGS");
lock();
bool had_print = false;
for (const auto &node : _node_map) {
if (node.second->print_statistics(reset)) {
had_print = true;
}
}
unlock();
if (!had_print) {
PX4_INFO("No lost messages");
}
}
uORB::DeviceNode *uORB::DeviceMaster::getDeviceNode(const char *nodepath)
{
lock();