mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-06 14:01:35 +08:00
mavlink: add detailed stats about rx messages
This commit is contained in:
@@ -2814,6 +2814,7 @@ Mavlink::display_status()
|
|||||||
printf("\t tx rate max: %i B/s\n", _datarate);
|
printf("\t tx rate max: %i B/s\n", _datarate);
|
||||||
printf("\t rx: %.1f B/s\n", (double)_tstatus.rx_rate_avg);
|
printf("\t rx: %.1f B/s\n", (double)_tstatus.rx_rate_avg);
|
||||||
printf("\t rx loss: %.1f%%\n", (double)_tstatus.rx_message_lost_rate);
|
printf("\t rx loss: %.1f%%\n", (double)_tstatus.rx_message_lost_rate);
|
||||||
|
_receiver.print_detailed_rx_stats();
|
||||||
|
|
||||||
if (_mavlink_ulog) {
|
if (_mavlink_ulog) {
|
||||||
printf("\tULog rate: %.1f%% of max %.1f%%\n", (double)_mavlink_ulog->current_data_rate() * 100.,
|
printf("\tULog rate: %.1f%% of max %.1f%%\n", (double)_mavlink_ulog->current_data_rate() * 100.,
|
||||||
|
|||||||
@@ -3151,6 +3151,26 @@ void MavlinkReceiver::update_rx_stats(const mavlink_message_t &message)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MavlinkReceiver::print_detailed_rx_stats() const
|
||||||
|
{
|
||||||
|
const uint32_t now_ms = hrt_absolute_time() / 1000;
|
||||||
|
|
||||||
|
// TODO: add mutex around shared data.
|
||||||
|
for (unsigned i = 0; i < MAX_REMOTE_COMPONENTS; ++i) {
|
||||||
|
if (_component_states[i].received_messages > 0) {
|
||||||
|
printf("\t received from %u/%u: %lu, lost: %lu, last %lu ms ago\n",
|
||||||
|
_component_states[i].system_id,
|
||||||
|
_component_states[i].component_id,
|
||||||
|
_component_states[i].received_messages,
|
||||||
|
_component_states[i].missed_messages,
|
||||||
|
now_ms - _component_states[i].last_time_received_ms);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MavlinkReceiver::start()
|
void MavlinkReceiver::start()
|
||||||
{
|
{
|
||||||
pthread_attr_t receiveloop_attr;
|
pthread_attr_t receiveloop_attr;
|
||||||
|
|||||||
@@ -124,6 +124,8 @@ public:
|
|||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
|
void print_detailed_rx_stats() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void *start_trampoline(void *context);
|
static void *start_trampoline(void *context);
|
||||||
void run();
|
void run();
|
||||||
|
|||||||
Reference in New Issue
Block a user