diff --git a/libuavcan/include/uavcan/global_data_type_registry.hpp b/libuavcan/include/uavcan/global_data_type_registry.hpp index 262fcd9cc9..d6be9cab3e 100644 --- a/libuavcan/include/uavcan/global_data_type_registry.hpp +++ b/libuavcan/include/uavcan/global_data_type_registry.hpp @@ -13,6 +13,9 @@ #include #include #include +#if UAVCAN_DEBUG +#include +#endif namespace uavcan { @@ -92,7 +95,7 @@ public: } /// Further calls to regist<>() will fail - void freeze() { frozen_ = true; } + void freeze(); bool isFrozen() const { return frozen_; } const DataTypeDescriptor* find(DataTypeKind kind, const char* name) const; @@ -108,6 +111,8 @@ public: /// Required for unit testing void reset() { + UAVCAN_TRACE("GlobalDataTypeRegistry", "Reset; was frozen: %i, num msgs: %u, num srvs: %u", + int(frozen_), getNumMessageTypes(), getNumServiceTypes()); frozen_ = false; while (msgs_.get()) msgs_.remove(msgs_.get()); diff --git a/libuavcan/src/global_data_type_registry.cpp b/libuavcan/src/global_data_type_registry.cpp index 86a928e97f..cdec7e59ab 100644 --- a/libuavcan/src/global_data_type_registry.cpp +++ b/libuavcan/src/global_data_type_registry.cpp @@ -5,6 +5,7 @@ #include #include #include +#include namespace uavcan { @@ -111,6 +112,15 @@ GlobalDataTypeRegistry& GlobalDataTypeRegistry::instance() return inst; } +void GlobalDataTypeRegistry::freeze() +{ + if (!frozen_) + { + frozen_ = true; + UAVCAN_TRACE("GlobalDataTypeRegistry", "Frozen"); + } +} + const DataTypeDescriptor* GlobalDataTypeRegistry::find(DataTypeKind kind, const char* name) const { const List* list = selectList(kind);