mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 23:03:34 +08:00
TransportStatsProvider
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
|
||||
*/
|
||||
|
||||
#include <uavcan/protocol/transport_stats_provider.hpp>
|
||||
|
||||
namespace uavcan
|
||||
{
|
||||
|
||||
void TransportStatsProvider::handleGetTransportStats(const protocol::GetTransportStats::Request&,
|
||||
protocol::GetTransportStats::Response& resp) const
|
||||
{
|
||||
const TransferPerfCounter& perf = srv_.getNode().getDispatcher().getTransferPerfCounter();
|
||||
resp.transfer_errors = perf.getErrorCount();
|
||||
resp.transfers_tx = perf.getTxTransferCount();
|
||||
resp.transfers_rx = perf.getRxTransferCount();
|
||||
|
||||
const CanIOManager& canio = srv_.getNode().getDispatcher().getCanIOManager();
|
||||
for (int i = 0; i < canio.getNumIfaces(); i++)
|
||||
{
|
||||
const CanIfacePerfCounters can_perf = canio.getIfacePerfCounters(i);
|
||||
protocol::CanIfaceStats stats;
|
||||
stats.errors = can_perf.errors;
|
||||
stats.frames_tx = can_perf.frames_tx;
|
||||
stats.frames_rx = can_perf.frames_rx;
|
||||
resp.can_iface_stats.push_back(stats);
|
||||
}
|
||||
}
|
||||
|
||||
int TransportStatsProvider::start()
|
||||
{
|
||||
return srv_.start(GetTransportStatsCallback(this, &TransportStatsProvider::handleGetTransportStats));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user