From 90702b5795392b7c5fe23d66af601d18daabd4c4 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Tue, 15 Jul 2014 00:47:47 +0400 Subject: [PATCH] libuavcan: Enforcing constant node name and version information --- .../src/protocol/uc_node_status_provider.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libuavcan/src/protocol/uc_node_status_provider.cpp b/libuavcan/src/protocol/uc_node_status_provider.cpp index 983782ff98..377620261c 100644 --- a/libuavcan/src/protocol/uc_node_status_provider.cpp +++ b/libuavcan/src/protocol/uc_node_status_provider.cpp @@ -107,17 +107,26 @@ void NodeStatusProvider::setStatusCode(uint8_t code) void NodeStatusProvider::setName(const char* name) { - node_info_.name = name; + if ((name != NULL) && (*name != '\0') && (node_info_.name.empty())) + { + node_info_.name = name; // The string contents will be copied, not just pointer. + } } void NodeStatusProvider::setSoftwareVersion(const protocol::SoftwareVersion& version) { - node_info_.software_version = version; + if (node_info_.software_version == protocol::SoftwareVersion()) + { + node_info_.software_version = version; + } } void NodeStatusProvider::setHardwareVersion(const protocol::HardwareVersion& version) { - node_info_.hardware_version = version; + if (node_info_.hardware_version == protocol::HardwareVersion()) + { + node_info_.hardware_version = version; + } } }