OTR logging

This commit is contained in:
Pavel Kirienko
2014-03-14 00:52:51 +04:00
parent e7cef20c79
commit 4bb66fb492
@@ -6,9 +6,12 @@
#include <cassert>
#include <stdint.h>
#include <sstream>
#include <uavcan/internal/impl_constants.hpp>
#include <uavcan/internal/map.hpp>
#include <uavcan/internal/debug.hpp>
#include <uavcan/internal/transport/transfer.hpp>
#include <uavcan/internal/debug.hpp>
#include <uavcan/time.hpp>
namespace uavcan
@@ -46,6 +49,15 @@ public:
(transfer_type_ == rhs.transfer_type_) &&
(destination_node_id_ == rhs.destination_node_id_);
}
std::string toString() const
{
std::ostringstream os;
os << "dtid=" << int(data_type_id_.get())
<< " tt=" << int(transfer_type_)
<< " dnid=" << int(destination_node_id_.get());
return os.str();
}
};
UAVCAN_PACKED_END
@@ -83,7 +95,13 @@ UAVCAN_PACKED_END
{
(void)key;
assert(!value.deadline.isZero());
return value.deadline <= ts_;
const bool expired = value.deadline <= ts_;
if (expired)
{
UAVCAN_TRACE("OutgoingTransferRegistry", "Expired %s tid=%i",
key.toString().c_str(), int(value.tid.get()));
}
return expired;
}
};
@@ -99,9 +117,12 @@ public:
assert(!new_deadline.isZero());
Value* p = map_.access(key);
if (p == NULL)
{
p = map_.insert(key, Value());
if (p == NULL)
return NULL;
if (p == NULL)
return NULL;
UAVCAN_TRACE("OutgoingTransferRegistry", "Created %s", key.toString().c_str());
}
p->deadline = new_deadline;
return &p->tid;
}