transport_stats_provider.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
3  */
4 
5 #ifndef UAVCAN_PROTOCOL_TRANSPORT_STATS_PROVIDER_HPP_INCLUDED
6 #define UAVCAN_PROTOCOL_TRANSPORT_STATS_PROVIDER_HPP_INCLUDED
7 
11 #include <uavcan/protocol/GetTransportStats.hpp>
12 
13 namespace uavcan
14 {
20 {
21  typedef MethodBinder<const TransportStatsProvider*,
22  void (TransportStatsProvider::*)(const protocol::GetTransportStats::Request&,
23  protocol::GetTransportStats::Response&) const>
25 
27 
28  void handleGetTransportStats(const protocol::GetTransportStats::Request&,
29  protocol::GetTransportStats::Response& resp) const
30  {
31  const TransferPerfCounter& perf = srv_.getNode().getDispatcher().getTransferPerfCounter();
32  resp.transfer_errors = perf.getErrorCount();
33  resp.transfers_tx = perf.getTxTransferCount();
34  resp.transfers_rx = perf.getRxTransferCount();
35 
36  const CanIOManager& canio = srv_.getNode().getDispatcher().getCanIOManager();
37  for (uint8_t i = 0; i < canio.getNumIfaces(); i++)
38  {
39  const CanIfacePerfCounters can_perf = canio.getIfacePerfCounters(i);
40  protocol::CANIfaceStats stats;
41  stats.errors = can_perf.errors;
42  stats.frames_tx = can_perf.frames_tx;
43  stats.frames_rx = can_perf.frames_rx;
44  resp.can_iface_stats.push_back(stats);
45  }
46  }
47 
48 public:
50  : srv_(node)
51  { }
52 
57  int start()
58  {
60  }
61 };
62 
63 }
64 
65 #endif // UAVCAN_PROTOCOL_TRANSPORT_STATS_PROVIDER_HPP_INCLUDED
CanIfacePerfCounters getIfacePerfCounters(uint8_t iface_index) const
Definition: uc_can_io.cpp:282
std::uint8_t uint8_t
Definition: std.hpp:24
uint8_t getNumIfaces() const
Definition: can_io.hpp:158
const uint64_t & getErrorCount() const
void handleGetTransportStats(const protocol::GetTransportStats::Request &, protocol::GetTransportStats::Response &resp) const
const uint64_t & getTxTransferCount() const
ServiceServer< protocol::GetTransportStats, GetTransportStatsCallback > srv_
const uint64_t & getRxTransferCount() const
int start(const Callback &callback)


uavcan_communicator
Author(s):
autogenerated on Wed Jan 11 2023 03:59:40