mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 00:23:34 +08:00
TransportPerfCounter - counting transfers and transport errors
This commit is contained in:
@@ -98,7 +98,7 @@ class GenericSubscriber : Noncopyable
|
||||
|
||||
public:
|
||||
TransferForwarder(SelfType& obj, const DataTypeDescriptor& data_type, IAllocator& allocator)
|
||||
: TransferListenerType(data_type, allocator)
|
||||
: TransferListenerType(obj.node_.getDispatcher().getTransportPerfCounter(), data_type, allocator)
|
||||
, obj_(obj)
|
||||
{ }
|
||||
};
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <cassert>
|
||||
#include <uavcan/stdint.hpp>
|
||||
#include <uavcan/transport/perf_counter.hpp>
|
||||
#include <uavcan/transport/transfer_listener.hpp>
|
||||
#include <uavcan/transport/outgoing_transfer_registry.hpp>
|
||||
#include <uavcan/transport/can_io.hpp>
|
||||
@@ -57,6 +58,7 @@ class Dispatcher : Noncopyable
|
||||
CanIOManager canio_;
|
||||
ISystemClock& sysclock_;
|
||||
IOutgoingTransferRegistry& outgoing_transfer_reg_;
|
||||
TransportPerfCounter perf_;
|
||||
|
||||
class ListenerRegistry
|
||||
{
|
||||
@@ -141,6 +143,9 @@ public:
|
||||
ISystemClock& getSystemClock() { return sysclock_; }
|
||||
|
||||
const CanIOManager& getCanIOManager() const { return canio_; }
|
||||
|
||||
const TransportPerfCounter& getTransportPerfCounter() const { return perf_; }
|
||||
TransportPerfCounter& getTransportPerfCounter() { return perf_; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <uavcan/stdint.hpp>
|
||||
|
||||
namespace uavcan
|
||||
{
|
||||
|
||||
class TransportPerfCounter
|
||||
{
|
||||
uint64_t transfers_tx_;
|
||||
uint64_t transfers_rx_;
|
||||
uint64_t errors_;
|
||||
|
||||
public:
|
||||
TransportPerfCounter()
|
||||
: transfers_tx_(0)
|
||||
, transfers_rx_(0)
|
||||
, errors_(0)
|
||||
{ }
|
||||
|
||||
void addTxTransfer() { transfers_tx_++; }
|
||||
void addRxTransfer() { transfers_rx_++; }
|
||||
|
||||
void addError() { errors_++; }
|
||||
|
||||
void addErrors(unsigned int errors)
|
||||
{
|
||||
errors_ += errors;
|
||||
}
|
||||
|
||||
uint64_t getTxTransferCount() const { return transfers_tx_; }
|
||||
uint64_t getRxTransferCount() const { return transfers_rx_; }
|
||||
uint64_t getErrorCount() const { return errors_; }
|
||||
};
|
||||
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <algorithm>
|
||||
#include <uavcan/stdint.hpp>
|
||||
#include <uavcan/transport/transfer_receiver.hpp>
|
||||
#include <uavcan/transport/perf_counter.hpp>
|
||||
#include <uavcan/linked_list.hpp>
|
||||
#include <uavcan/map.hpp>
|
||||
#include <uavcan/debug.hpp>
|
||||
@@ -88,13 +89,15 @@ class TransferListenerBase : public LinkedListNode<TransferListenerBase>, Noncop
|
||||
{
|
||||
const DataTypeDescriptor& data_type_;
|
||||
const TransferCRC crc_base_; ///< Pre-initialized with data type hash, thus constant
|
||||
TransportPerfCounter& perf_;
|
||||
|
||||
bool checkPayloadCrc(const uint16_t compare_with, const ITransferBuffer& tbb) const;
|
||||
|
||||
protected:
|
||||
TransferListenerBase(const DataTypeDescriptor& data_type)
|
||||
TransferListenerBase(TransportPerfCounter& perf, const DataTypeDescriptor& data_type)
|
||||
: data_type_(data_type)
|
||||
, crc_base_(data_type.getSignature().toTransferCRC())
|
||||
, perf_(perf)
|
||||
{ }
|
||||
|
||||
virtual ~TransferListenerBase() { }
|
||||
@@ -181,8 +184,8 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
TransferListener(const DataTypeDescriptor& data_type, IAllocator& allocator)
|
||||
: TransferListenerBase(data_type)
|
||||
TransferListener(TransportPerfCounter& perf, const DataTypeDescriptor& data_type, IAllocator& allocator)
|
||||
: TransferListenerBase(perf, data_type)
|
||||
, bufmgr_(allocator)
|
||||
, receivers_(allocator)
|
||||
{
|
||||
@@ -246,8 +249,9 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
ServiceResponseTransferListener(const DataTypeDescriptor& data_type, IAllocator& allocator)
|
||||
: BaseType(data_type, allocator)
|
||||
ServiceResponseTransferListener(TransportPerfCounter& perf, const DataTypeDescriptor& data_type,
|
||||
IAllocator& allocator)
|
||||
: BaseType(perf, data_type, allocator)
|
||||
{ }
|
||||
|
||||
void setExpectedResponseParams(const ExpectedResponseParams& erp)
|
||||
|
||||
@@ -41,11 +41,11 @@ private:
|
||||
TransferID tid_;
|
||||
uint8_t iface_index_;
|
||||
uint8_t next_frame_index_;
|
||||
uint8_t error_cnt_;
|
||||
mutable uint8_t error_cnt_;
|
||||
|
||||
bool isInitialized() const { return iface_index_ != IfaceIndexNotSet; }
|
||||
|
||||
void registerError();
|
||||
void registerError() const;
|
||||
|
||||
TidRelation getTidRelation(const RxFrame& frame) const;
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ class TransferSender
|
||||
|
||||
Dispatcher& dispatcher_;
|
||||
|
||||
void registerError();
|
||||
|
||||
public:
|
||||
enum { AllIfacesMask = 0xFF };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user