mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-06-28 01:00:36 +08:00
Improved Raft event tracer - added event code to string conversion
This commit is contained in:
@@ -57,9 +57,9 @@ class EventTracer : public uavcan::IDynamicNodeIDAllocationServerEventTracer
|
||||
{
|
||||
const std::string id_;
|
||||
|
||||
virtual void onEvent(uavcan::uint16_t event_code, uavcan::int64_t event_argument)
|
||||
virtual void onEvent(uavcan::uint16_t code, uavcan::int64_t argument)
|
||||
{
|
||||
std::cout << "EVENT [" << id_ << "]\t" << event_code << "\t" << event_argument << std::endl;
|
||||
std::cout << "EVENT [" << id_ << "]\t" << code << "\t" << getEventName(code) << "\t" << argument << std::endl;
|
||||
}
|
||||
|
||||
public:
|
||||
@@ -874,6 +874,23 @@ TEST(DynamicNodeIDAllocationServer, RaftCoreBasic)
|
||||
}
|
||||
|
||||
|
||||
TEST(DynamicNodeIDAllocationServer, EventCodeToString)
|
||||
{
|
||||
using uavcan::IDynamicNodeIDAllocationServerEventTracer;
|
||||
using namespace uavcan::dynamic_node_id_server_impl;
|
||||
|
||||
// Simply checking some error codes
|
||||
ASSERT_STREQ("Error",
|
||||
IDynamicNodeIDAllocationServerEventTracer::getEventName(TraceError));
|
||||
ASSERT_STREQ("RaftModeSwitch",
|
||||
IDynamicNodeIDAllocationServerEventTracer::getEventName(TraceRaftModeSwitch));
|
||||
ASSERT_STREQ("RaftAppendEntriesCallFailure",
|
||||
IDynamicNodeIDAllocationServerEventTracer::getEventName(TraceRaftAppendEntriesCallFailure));
|
||||
ASSERT_STREQ("DiscoveryReceived",
|
||||
IDynamicNodeIDAllocationServerEventTracer::getEventName(TraceDiscoveryReceived));
|
||||
}
|
||||
|
||||
|
||||
TEST(DynamicNodeIDAllocationServer, ObjectSizes)
|
||||
{
|
||||
std::cout << "Log: " << sizeof(uavcan::dynamic_node_id_server_impl::Log) << std::endl;
|
||||
|
||||
Reference in New Issue
Block a user