From 222ea1e093de9d52afe1d852824db1ddb8bb2fd0 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Wed, 4 Feb 2015 20:17:29 +0300 Subject: [PATCH 01/35] CanIOManager::getCanDriver() --- libuavcan/include/uavcan/transport/can_io.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libuavcan/include/uavcan/transport/can_io.hpp b/libuavcan/include/uavcan/transport/can_io.hpp index 005e9825ea..c8d4e6925f 100644 --- a/libuavcan/include/uavcan/transport/can_io.hpp +++ b/libuavcan/include/uavcan/transport/can_io.hpp @@ -164,6 +164,8 @@ public: CanIfacePerfCounters getIfacePerfCounters(uint8_t iface_index) const; + const ICanDriver& getCanDriver() const { return driver_; } + /** * Returns: * 0 - rejected/timedout/enqueued From c415cf90c39351a0a621323717216a4db76f236e Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Wed, 4 Feb 2015 22:53:17 +0300 Subject: [PATCH 02/35] Const version of getReceivedStructStorage(), clarified docs --- libuavcan/include/uavcan/node/generic_subscriber.hpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libuavcan/include/uavcan/node/generic_subscriber.hpp b/libuavcan/include/uavcan/node/generic_subscriber.hpp index 2cb6083ddf..0782d718bf 100644 --- a/libuavcan/include/uavcan/node/generic_subscriber.hpp +++ b/libuavcan/include/uavcan/node/generic_subscriber.hpp @@ -207,10 +207,13 @@ protected: TransferListenerType* getTransferListener() { return forwarder_; } /** - * Returns the mutable reference to the temporary storage for decoded received messages. + * Returns a reference to the temporary storage for decoded received messages. * Reference to this storage is used as a parameter for subscription callbacks. + * This storage is guaranteed to stay intact after the last message was decoded, i.e. + * the application can use it to access the last received message object. */ - ReceivedDataStructure& getReceivedStructStorage() { return message_; } + ReceivedDataStructure& getReceivedStructStorage() { return message_; } + const ReceivedDataStructure& getReceivedStructStorage() const { return message_; } }; // ---------------------------------------------------------------------------- From f4ba884b3112a371951841ff99dd042dd7be1c5f Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Wed, 4 Feb 2015 22:53:27 +0300 Subject: [PATCH 03/35] Formatting fix --- libuavcan/src/transport/uc_transfer_buffer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libuavcan/src/transport/uc_transfer_buffer.cpp b/libuavcan/src/transport/uc_transfer_buffer.cpp index f851eb05ed..4a56b75632 100644 --- a/libuavcan/src/transport/uc_transfer_buffer.cpp +++ b/libuavcan/src/transport/uc_transfer_buffer.cpp @@ -24,7 +24,8 @@ std::string TransferBufferManagerKey::toString() const /* * DynamicTransferBuffer::Block */ -DynamicTransferBufferManagerEntry::Block* DynamicTransferBufferManagerEntry::Block::instantiate(IPoolAllocator& allocator) +DynamicTransferBufferManagerEntry::Block* +DynamicTransferBufferManagerEntry::Block::instantiate(IPoolAllocator& allocator) { void* const praw = allocator.allocate(sizeof(Block)); if (praw == NULL) From 2d1c8f1a2d44fb60083f652f51481a9c90f2a19e Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Wed, 4 Feb 2015 23:27:04 +0300 Subject: [PATCH 04/35] Note on code size for LPC11C24 --- libuavcan_drivers/lpc11c24/test_olimex_lpc_p11c24/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/libuavcan_drivers/lpc11c24/test_olimex_lpc_p11c24/Makefile b/libuavcan_drivers/lpc11c24/test_olimex_lpc_p11c24/Makefile index ea3df6840b..24f375c9d6 100644 --- a/libuavcan_drivers/lpc11c24/test_olimex_lpc_p11c24/Makefile +++ b/libuavcan_drivers/lpc11c24/test_olimex_lpc_p11c24/Makefile @@ -49,6 +49,7 @@ DEPDIR = $(BUILDDIR)/dep DEF += -DNDEBUG -DCHIP_LPC11CXX -DCORE_M0 -DTHUMB_NO_INTERWORKING -U__STRICT_ANSI__ +# Removing -fconserve-stack reduces code size a little FLAGS = -mthumb -mcpu=cortex-m0 -mno-thumb-interwork -flto -Os -g3 -Wall -Wextra -Werror -Wundef -ffunction-sections \ -fdata-sections -fno-common -fno-exceptions -fno-unwind-tables -fno-stack-protector -fomit-frame-pointer \ -ftracer -ftree-loop-distribute-patterns -frename-registers -freorder-blocks -fconserve-stack \ From 849abc817918e978cfed7ff1452c9adcd9d0a55a Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Wed, 4 Feb 2015 23:53:02 +0300 Subject: [PATCH 05/35] README.md - Coverity build instructions --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 26e3e21dae..d49680ef24 100644 --- a/README.md +++ b/README.md @@ -31,4 +31,20 @@ cmake .. -DCMAKE_BUILD_TYPE=Debug make ``` +Test outputs can be found in the build directory under `libuavcan`. + Contributors, please follow the [Zubax Style Guide](https://github.com/Zubax/zubax_style_guide). + +### Submitting a coverity build + +First, [get the Coverity build tool](https://scan.coverity.com/download?tab=cxx). Then build the library with it: + +```bash +export PATH=$PATH:/bin/ +mkdir debug && cd debug +cmake -DCMAKE_BUILD_TYPE=Debug +cov-build --dir cov-int make -j8 +tar czvf uavcan.tgz cov-int +``` + +Then upload the resulting archive to Coverity. From 60cf13995a9104304afce19391a699544b83e915 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Thu, 5 Feb 2015 02:04:13 +0300 Subject: [PATCH 06/35] Coverity CID 1268191 --- libuavcan_drivers/linux/apps/uavcan_nodetool.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libuavcan_drivers/linux/apps/uavcan_nodetool.cpp b/libuavcan_drivers/linux/apps/uavcan_nodetool.cpp index 5cca98eafd..0917b724eb 100644 --- a/libuavcan_drivers/linux/apps/uavcan_nodetool.cpp +++ b/libuavcan_drivers/linux/apps/uavcan_nodetool.cpp @@ -110,6 +110,7 @@ void printGetSetResponse(const uavcan::protocol::param::GetSet::Response& resp) std::cout << std::setw(15) << paramValueToString(resp.min_value); std::cout << std::setw(15) << paramValueToString(resp.max_value); std::cout << std::endl; + std::cout.width(0); // Clears the effect of std::setw() } uavcan_linux::NodePtr initNode(const std::vector& ifaces, uavcan::NodeID nid, const std::string& name) From 035a607944a5aec88629084857cc431818651b35 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Thu, 5 Feb 2015 02:31:28 +0300 Subject: [PATCH 07/35] Logging functions defined with UAVCAN_NOEXCEPT --- libuavcan/include/uavcan/build_config.hpp | 16 +++++++ libuavcan/include/uavcan/protocol/logger.hpp | 49 ++++++++++++-------- libuavcan/src/protocol/uc_logger.cpp | 25 +++++++--- 3 files changed, 64 insertions(+), 26 deletions(-) diff --git a/libuavcan/include/uavcan/build_config.hpp b/libuavcan/include/uavcan/build_config.hpp index f9d6c65934..06a771c2cc 100644 --- a/libuavcan/include/uavcan/build_config.hpp +++ b/libuavcan/include/uavcan/build_config.hpp @@ -58,6 +58,22 @@ # endif #endif +/** + * This specification is used by some error reporting functions like in the Logger class. + * The default can be overriden by defining the macro UAVCAN_NOEXCEPT explicitly, e.g. via compiler options. + */ +#ifndef UAVCAN_NOEXCEPT +# if UAVCAN_EXCEPTIONS +# if UAVCAN_CPP_VERSION >= UAVCAN_CPP11 +# define UAVCAN_NOEXCEPT noexcept +# else +# define UAVCAN_NOEXCEPT throw() +# endif +# else +# define UAVCAN_NOEXCEPT +# endif +#endif + /** * Struct layout control. * Set UAVCAN_PACK_STRUCTS=1 and define UAVCAN_PACKED_BEGIN and UAVCAN_PACKED_END to reduce memory usage. diff --git a/libuavcan/include/uavcan/protocol/logger.hpp b/libuavcan/include/uavcan/protocol/logger.hpp index e7d606a630..9001dcf65f 100644 --- a/libuavcan/include/uavcan/protocol/logger.hpp +++ b/libuavcan/include/uavcan/protocol/logger.hpp @@ -148,52 +148,52 @@ public: #if UAVCAN_CPP_VERSION >= UAVCAN_CPP11 template - int log(LogLevel level, const char* source, const char* format, Args... args); + int log(LogLevel level, const char* source, const char* format, Args... args) UAVCAN_NOEXCEPT; template - inline int logDebug(const char* source, const char* format, Args... args) + inline int logDebug(const char* source, const char* format, Args... args) UAVCAN_NOEXCEPT { return log(protocol::debug::LogLevel::DEBUG, source, format, args...); } template - inline int logInfo(const char* source, const char* format, Args... args) + inline int logInfo(const char* source, const char* format, Args... args) UAVCAN_NOEXCEPT { return log(protocol::debug::LogLevel::INFO, source, format, args...); } template - inline int logWarning(const char* source, const char* format, Args... args) + inline int logWarning(const char* source, const char* format, Args... args) UAVCAN_NOEXCEPT { return log(protocol::debug::LogLevel::WARNING, source, format, args...); } template - inline int logError(const char* source, const char* format, Args... args) + inline int logError(const char* source, const char* format, Args... args) UAVCAN_NOEXCEPT { return log(protocol::debug::LogLevel::ERROR, source, format, args...); } #else - int log(LogLevel level, const char* source, const char* text); + int log(LogLevel level, const char* source, const char* text) UAVCAN_NOEXCEPT; - int logDebug(const char* source, const char* text) + int logDebug(const char* source, const char* text) UAVCAN_NOEXCEPT { return log(protocol::debug::LogLevel::DEBUG, source, text); } - int logInfo(const char* source, const char* text) + int logInfo(const char* source, const char* text) UAVCAN_NOEXCEPT { return log(protocol::debug::LogLevel::INFO, source, text); } - int logWarning(const char* source, const char* text) + int logWarning(const char* source, const char* text) UAVCAN_NOEXCEPT { return log(protocol::debug::LogLevel::WARNING, source, text); } - int logError(const char* source, const char* text) + int logError(const char* source, const char* text) UAVCAN_NOEXCEPT { return log(protocol::debug::LogLevel::ERROR, source, text); } @@ -207,18 +207,29 @@ public: #if UAVCAN_CPP_VERSION >= UAVCAN_CPP11 template -int Logger::log(LogLevel level, const char* source, const char* format, Args... args) +int Logger::log(LogLevel level, const char* source, const char* format, Args... args) UAVCAN_NOEXCEPT { - if (level >= level_ || level >= getExternalSinkLevel()) +#if UAVCAN_EXCEPTIONS + try +#endif { - msg_buf_.level.value = level; - msg_buf_.source = source; - msg_buf_.text.clear(); - CharArrayFormatter formatter(msg_buf_.text); - formatter.write(format, args...); - return log(msg_buf_); + if (level >= level_ || level >= getExternalSinkLevel()) + { + msg_buf_.level.value = level; + msg_buf_.source = source; + msg_buf_.text.clear(); + CharArrayFormatter formatter(msg_buf_.text); + formatter.write(format, args...); + return log(msg_buf_); + } + return 0; } - return 0; +#if UAVCAN_EXCEPTIONS + catch (...) + { + return -ErrFailure; + } +#endif } #endif diff --git a/libuavcan/src/protocol/uc_logger.cpp b/libuavcan/src/protocol/uc_logger.cpp index a0e900b285..3c6661e306 100644 --- a/libuavcan/src/protocol/uc_logger.cpp +++ b/libuavcan/src/protocol/uc_logger.cpp @@ -36,16 +36,27 @@ int Logger::log(const protocol::debug::LogMessage& message) #if UAVCAN_CPP_VERSION < UAVCAN_CPP11 -int Logger::log(LogLevel level, const char* source, const char* text) +int Logger::log(LogLevel level, const char* source, const char* text) UAVCAN_NOEXCEPT { - if (level >= level_ || level >= getExternalSinkLevel()) +#if UAVCAN_EXCEPTIONS + try +#endif { - msg_buf_.level.value = level; - msg_buf_.source = source; - msg_buf_.text = text; - return log(msg_buf_); + if (level >= level_ || level >= getExternalSinkLevel()) + { + msg_buf_.level.value = level; + msg_buf_.source = source; + msg_buf_.text = text; + return log(msg_buf_); + } + return 0; } - return 0; +#if UAVCAN_EXCEPTIONS + catch (...) + { + return -ErrFailure; + } +#endif } #endif From b9f802026e3424aa9185c6b38efb91abf0b5b509 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Thu, 5 Feb 2015 02:35:25 +0300 Subject: [PATCH 08/35] Coverity CID 1268184..1268189 --- .../linux/apps/uavcan_nodetool.cpp | 22 ++++++++++----- .../linux/apps/uavcan_status_monitor.cpp | 28 ++++++++++++------- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/libuavcan_drivers/linux/apps/uavcan_nodetool.cpp b/libuavcan_drivers/linux/apps/uavcan_nodetool.cpp index 0917b724eb..f40485967e 100644 --- a/libuavcan_drivers/linux/apps/uavcan_nodetool.cpp +++ b/libuavcan_drivers/linux/apps/uavcan_nodetool.cpp @@ -348,14 +348,22 @@ void runForever(const uavcan_linux::NodePtr& node) int main(int argc, const char** argv) { - if (argc < 3) + try { - std::cout << "Usage:\n\t" << argv[0] << " [can-iface-name-N...]" << std::endl; + if (argc < 3) + { + std::cout << "Usage:\n\t" << argv[0] << " [can-iface-name-N...]" << std::endl; + return 1; + } + const int self_node_id = std::stoi(argv[1]); + const std::vector iface_names(argv + 2, argv + argc); + uavcan_linux::NodePtr node = initNode(iface_names, self_node_id, "org.uavcan.linux_nodetool"); + runForever(node); + return 0; + } + catch (const std::exception& ex) + { + std::cerr << "Error: " << ex.what() << std::endl; return 1; } - const int self_node_id = std::stoi(argv[1]); - const std::vector iface_names(argv + 2, argv + argc); - uavcan_linux::NodePtr node = initNode(iface_names, self_node_id, "org.uavcan.linux_nodetool"); - runForever(node); - return 0; } diff --git a/libuavcan_drivers/linux/apps/uavcan_status_monitor.cpp b/libuavcan_drivers/linux/apps/uavcan_status_monitor.cpp index 9c8b8ebdef..5f3f232e3a 100644 --- a/libuavcan_drivers/linux/apps/uavcan_status_monitor.cpp +++ b/libuavcan_drivers/linux/apps/uavcan_status_monitor.cpp @@ -127,17 +127,25 @@ static void runForever(const uavcan_linux::NodePtr& node) int main(int argc, const char** argv) { - if (argc < 2) + try { - std::cout << "Usage:\n\t" << argv[0] << " [can-iface-name-N...]" << std::endl; + if (argc < 2) + { + std::cout << "Usage:\n\t" << argv[0] << " [can-iface-name-N...]" << std::endl; + return 1; + } + std::vector iface_names; + for (int i = 1; i < argc; i++) + { + iface_names.emplace_back(argv[i]); + } + uavcan_linux::NodePtr node = initNodeInPassiveMode(iface_names, "org.uavcan.status_monitor"); + runForever(node); + return 0; + } + catch (const std::exception& ex) + { + std::cerr << "Error: " << ex.what() << std::endl; return 1; } - std::vector iface_names; - for (int i = 1; i < argc; i++) - { - iface_names.emplace_back(argv[i]); - } - uavcan_linux::NodePtr node = initNodeInPassiveMode(iface_names, "org.uavcan.status_monitor"); - runForever(node); - return 0; } From 315d21c2563b5cb854a08ed2c9393c3600ebd2b1 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Thu, 5 Feb 2015 02:37:42 +0300 Subject: [PATCH 09/35] Coverity CID 1268181, 1268182 --- libuavcan/include/uavcan/util/linked_list.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libuavcan/include/uavcan/util/linked_list.hpp b/libuavcan/include/uavcan/util/linked_list.hpp index d36e83b463..dcc91d61ed 100644 --- a/libuavcan/include/uavcan/util/linked_list.hpp +++ b/libuavcan/include/uavcan/util/linked_list.hpp @@ -99,9 +99,9 @@ unsigned LinkedListRoot::getLength() const template void LinkedListRoot::insert(T* node) { - UAVCAN_ASSERT(node); if (node == NULL) { + UAVCAN_ASSERT(0); return; } remove(node); // Making sure there will be no loops @@ -113,9 +113,9 @@ template template void LinkedListRoot::insertBefore(T* node, Predicate predicate) { - UAVCAN_ASSERT(node); if (node == NULL) { + UAVCAN_ASSERT(0); return; } From 3a0aa4ce466146296f870858e9a99e6b3c7ffb93 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Thu, 5 Feb 2015 02:41:46 +0300 Subject: [PATCH 10/35] Coverity CID 1268180 --- libuavcan/include/uavcan/util/templates.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libuavcan/include/uavcan/util/templates.hpp b/libuavcan/include/uavcan/util/templates.hpp index 8c3b3028b2..8e2db29b7e 100644 --- a/libuavcan/include/uavcan/util/templates.hpp +++ b/libuavcan/include/uavcan/util/templates.hpp @@ -479,6 +479,7 @@ inline bool getSignBit(T arg) #if UAVCAN_CPP_VERSION >= UAVCAN_CPP11 return std::signbit(arg); #else + // coverity[divide_by_zero : FALSE] return arg < T(0) || (((arg <= T(0)) && (arg >= T(0))) && (T(1) / arg < T(0))); #endif } From 00bada6fb9693f2b3ef4002b4886f7fb9e89860b Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Thu, 5 Feb 2015 02:47:35 +0300 Subject: [PATCH 11/35] Coverity CID 1203388..1203395 --- libuavcan_drivers/linux/apps/test_node.cpp | 32 +++++++++------ libuavcan_drivers/linux/apps/test_socket.cpp | 40 +++++++++++-------- .../linux/apps/test_time_sync.cpp | 30 +++++++++----- 3 files changed, 63 insertions(+), 39 deletions(-) diff --git a/libuavcan_drivers/linux/apps/test_node.cpp b/libuavcan_drivers/linux/apps/test_node.cpp index cb00a98c99..3ec9b0938b 100644 --- a/libuavcan_drivers/linux/apps/test_node.cpp +++ b/libuavcan_drivers/linux/apps/test_node.cpp @@ -102,19 +102,27 @@ static void runForever(const uavcan_linux::NodePtr& node) int main(int argc, const char** argv) { - if (argc < 3) + try { - std::cout << "Usage:\n\t" << argv[0] << " [can-iface-name-N...]" << std::endl; + if (argc < 3) + { + std::cout << "Usage:\n\t" << argv[0] << " [can-iface-name-N...]" << std::endl; + return 1; + } + const int self_node_id = std::stoi(argv[1]); + std::vector iface_names; + for (int i = 2; i < argc; i++) + { + iface_names.emplace_back(argv[i]); + } + uavcan_linux::NodePtr node = initNode(iface_names, self_node_id, "org.uavcan.linux_test_node"); + std::cout << "Node initialized successfully" << std::endl; + runForever(node); + return 0; + } + catch (const std::exception& ex) + { + std::cerr << "Exception: " << ex.what() << std::endl; return 1; } - const int self_node_id = std::stoi(argv[1]); - std::vector iface_names; - for (int i = 2; i < argc; i++) - { - iface_names.emplace_back(argv[i]); - } - uavcan_linux::NodePtr node = initNode(iface_names, self_node_id, "org.uavcan.linux_test_node"); - std::cout << "Node initialized successfully" << std::endl; - runForever(node); - return 0; } diff --git a/libuavcan_drivers/linux/apps/test_socket.cpp b/libuavcan_drivers/linux/apps/test_socket.cpp index 5c8a33e2ce..1b37fc8c7a 100644 --- a/libuavcan_drivers/linux/apps/test_socket.cpp +++ b/libuavcan_drivers/linux/apps/test_socket.cpp @@ -332,23 +332,31 @@ static void testDriver(const std::vector& iface_names) int main(int argc, const char** argv) { - if (argc < 2) + try { - std::cout << "Usage:\n\t" << argv[0] << " [can-iface-name-N...]" << std::endl; + if (argc < 2) + { + std::cout << "Usage:\n\t" << argv[0] << " [can-iface-name-N...]" << std::endl; + return 1; + } + + std::vector iface_names; + for (int i = 1; i < argc; i++) + { + iface_names.emplace_back(argv[i]); + } + + testNonexistentIface(); + testSocketRxTx(iface_names[0]); + testSocketFilters(iface_names[0]); + + testDriver(iface_names); + + return 0; + } + catch (const std::exception& ex) + { + std::cerr << "Exception: " << ex.what() << std::endl; return 1; } - - std::vector iface_names; - for (int i = 1; i < argc; i++) - { - iface_names.emplace_back(argv[i]); - } - - testNonexistentIface(); - testSocketRxTx(iface_names[0]); - testSocketFilters(iface_names[0]); - - testDriver(iface_names); - - return 0; } diff --git a/libuavcan_drivers/linux/apps/test_time_sync.cpp b/libuavcan_drivers/linux/apps/test_time_sync.cpp index 8da3e2ad1b..b85f889b48 100644 --- a/libuavcan_drivers/linux/apps/test_time_sync.cpp +++ b/libuavcan_drivers/linux/apps/test_time_sync.cpp @@ -84,18 +84,26 @@ static void runForever(const uavcan_linux::NodePtr& node) int main(int argc, const char** argv) { - if (argc < 3) + try { - std::cout << "Usage:\n\t" << argv[0] << " [can-iface-name-N...]" << std::endl; + if (argc < 3) + { + std::cout << "Usage:\n\t" << argv[0] << " [can-iface-name-N...]" << std::endl; + return 1; + } + const int self_node_id = std::stoi(argv[1]); + std::vector iface_names; + for (int i = 2; i < argc; i++) + { + iface_names.emplace_back(argv[i]); + } + uavcan_linux::NodePtr node = initNode(iface_names, self_node_id, "org.uavcan.linux_test_node_status_monitor"); + runForever(node); + return 0; + } + catch (const std::exception& ex) + { + std::cerr << "Exception: " << ex.what() << std::endl; return 1; } - const int self_node_id = std::stoi(argv[1]); - std::vector iface_names; - for (int i = 2; i < argc; i++) - { - iface_names.emplace_back(argv[i]); - } - uavcan_linux::NodePtr node = initNode(iface_names, self_node_id, "org.uavcan.linux_test_node_status_monitor"); - runForever(node); - return 0; } From 9675e31933e93cab800f56670a8a85143655997e Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Thu, 5 Feb 2015 02:49:53 +0300 Subject: [PATCH 12/35] Linux apps: printing usage to stderr --- libuavcan_drivers/linux/apps/test_node.cpp | 2 +- libuavcan_drivers/linux/apps/test_socket.cpp | 2 +- libuavcan_drivers/linux/apps/test_time_sync.cpp | 2 +- libuavcan_drivers/linux/apps/uavcan_nodetool.cpp | 2 +- libuavcan_drivers/linux/apps/uavcan_status_monitor.cpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libuavcan_drivers/linux/apps/test_node.cpp b/libuavcan_drivers/linux/apps/test_node.cpp index 3ec9b0938b..2241f246ca 100644 --- a/libuavcan_drivers/linux/apps/test_node.cpp +++ b/libuavcan_drivers/linux/apps/test_node.cpp @@ -106,7 +106,7 @@ int main(int argc, const char** argv) { if (argc < 3) { - std::cout << "Usage:\n\t" << argv[0] << " [can-iface-name-N...]" << std::endl; + std::cerr << "Usage:\n\t" << argv[0] << " [can-iface-name-N...]" << std::endl; return 1; } const int self_node_id = std::stoi(argv[1]); diff --git a/libuavcan_drivers/linux/apps/test_socket.cpp b/libuavcan_drivers/linux/apps/test_socket.cpp index 1b37fc8c7a..5d62ad4fea 100644 --- a/libuavcan_drivers/linux/apps/test_socket.cpp +++ b/libuavcan_drivers/linux/apps/test_socket.cpp @@ -336,7 +336,7 @@ int main(int argc, const char** argv) { if (argc < 2) { - std::cout << "Usage:\n\t" << argv[0] << " [can-iface-name-N...]" << std::endl; + std::cerr << "Usage:\n\t" << argv[0] << " [can-iface-name-N...]" << std::endl; return 1; } diff --git a/libuavcan_drivers/linux/apps/test_time_sync.cpp b/libuavcan_drivers/linux/apps/test_time_sync.cpp index b85f889b48..c956a4912e 100644 --- a/libuavcan_drivers/linux/apps/test_time_sync.cpp +++ b/libuavcan_drivers/linux/apps/test_time_sync.cpp @@ -88,7 +88,7 @@ int main(int argc, const char** argv) { if (argc < 3) { - std::cout << "Usage:\n\t" << argv[0] << " [can-iface-name-N...]" << std::endl; + std::cerr << "Usage:\n\t" << argv[0] << " [can-iface-name-N...]" << std::endl; return 1; } const int self_node_id = std::stoi(argv[1]); diff --git a/libuavcan_drivers/linux/apps/uavcan_nodetool.cpp b/libuavcan_drivers/linux/apps/uavcan_nodetool.cpp index f40485967e..1b19fb4bb2 100644 --- a/libuavcan_drivers/linux/apps/uavcan_nodetool.cpp +++ b/libuavcan_drivers/linux/apps/uavcan_nodetool.cpp @@ -352,7 +352,7 @@ int main(int argc, const char** argv) { if (argc < 3) { - std::cout << "Usage:\n\t" << argv[0] << " [can-iface-name-N...]" << std::endl; + std::cerr << "Usage:\n\t" << argv[0] << " [can-iface-name-N...]" << std::endl; return 1; } const int self_node_id = std::stoi(argv[1]); diff --git a/libuavcan_drivers/linux/apps/uavcan_status_monitor.cpp b/libuavcan_drivers/linux/apps/uavcan_status_monitor.cpp index 5f3f232e3a..9672c77988 100644 --- a/libuavcan_drivers/linux/apps/uavcan_status_monitor.cpp +++ b/libuavcan_drivers/linux/apps/uavcan_status_monitor.cpp @@ -131,7 +131,7 @@ int main(int argc, const char** argv) { if (argc < 2) { - std::cout << "Usage:\n\t" << argv[0] << " [can-iface-name-N...]" << std::endl; + std::cerr << "Usage:\n\t" << argv[0] << " [can-iface-name-N...]" << std::endl; return 1; } std::vector iface_names; From de1a669bea7bc0b98abde32ffd9536b4c58acc60 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Thu, 5 Feb 2015 02:52:02 +0300 Subject: [PATCH 13/35] Linux vcan_init fix (requires bash, not sh) --- libuavcan_drivers/linux/scripts/vcan_init | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libuavcan_drivers/linux/scripts/vcan_init b/libuavcan_drivers/linux/scripts/vcan_init index 6a9bb6e4ec..ffa1c43bf0 100755 --- a/libuavcan_drivers/linux/scripts/vcan_init +++ b/libuavcan_drivers/linux/scripts/vcan_init @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # Copyright (C) 2014 Pavel Kirienko # From 403a70e89956f8bb77e0b9340513ca0717a7b13d Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Thu, 5 Feb 2015 03:02:31 +0300 Subject: [PATCH 14/35] Proper node names for Linux apps --- libuavcan_drivers/linux/apps/uavcan_nodetool.cpp | 2 +- libuavcan_drivers/linux/apps/uavcan_status_monitor.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libuavcan_drivers/linux/apps/uavcan_nodetool.cpp b/libuavcan_drivers/linux/apps/uavcan_nodetool.cpp index 1b19fb4bb2..00acf6de7c 100644 --- a/libuavcan_drivers/linux/apps/uavcan_nodetool.cpp +++ b/libuavcan_drivers/linux/apps/uavcan_nodetool.cpp @@ -357,7 +357,7 @@ int main(int argc, const char** argv) } const int self_node_id = std::stoi(argv[1]); const std::vector iface_names(argv + 2, argv + argc); - uavcan_linux::NodePtr node = initNode(iface_names, self_node_id, "org.uavcan.linux_nodetool"); + uavcan_linux::NodePtr node = initNode(iface_names, self_node_id, "org.uavcan.linux_app.nodetool"); runForever(node); return 0; } diff --git a/libuavcan_drivers/linux/apps/uavcan_status_monitor.cpp b/libuavcan_drivers/linux/apps/uavcan_status_monitor.cpp index 9672c77988..c8374ded0d 100644 --- a/libuavcan_drivers/linux/apps/uavcan_status_monitor.cpp +++ b/libuavcan_drivers/linux/apps/uavcan_status_monitor.cpp @@ -139,7 +139,7 @@ int main(int argc, const char** argv) { iface_names.emplace_back(argv[i]); } - uavcan_linux::NodePtr node = initNodeInPassiveMode(iface_names, "org.uavcan.status_monitor"); + uavcan_linux::NodePtr node = initNodeInPassiveMode(iface_names, "org.uavcan.linux_app.node_status_monitor"); runForever(node); return 0; } From 9f7149d85c4fa518dbb2cbd95b857e3b7f08fcca Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Thu, 5 Feb 2015 03:25:52 +0300 Subject: [PATCH 15/35] Coverity CID 1268191 --- libuavcan_drivers/linux/apps/uavcan_nodetool.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libuavcan_drivers/linux/apps/uavcan_nodetool.cpp b/libuavcan_drivers/linux/apps/uavcan_nodetool.cpp index 00acf6de7c..822144701b 100644 --- a/libuavcan_drivers/linux/apps/uavcan_nodetool.cpp +++ b/libuavcan_drivers/linux/apps/uavcan_nodetool.cpp @@ -104,13 +104,17 @@ void printGetSetResponseHeader() void printGetSetResponse(const uavcan::protocol::param::GetSet::Response& resp) { + const auto original_flags = std::cout.flags(); + std::cout << std::setw(41) << std::left << resp.name.c_str(); std::cout << std::setw(15) << paramValueToString(resp.value); std::cout << std::setw(15) << paramValueToString(resp.default_value); std::cout << std::setw(15) << paramValueToString(resp.min_value); std::cout << std::setw(15) << paramValueToString(resp.max_value); std::cout << std::endl; + std::cout.width(0); // Clears the effect of std::setw() + std::cout.flags(original_flags); } uavcan_linux::NodePtr initNode(const std::vector& ifaces, uavcan::NodeID nid, const std::string& name) From beefb2cd60aabff768eb573d75295b88408d9bdf Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Thu, 5 Feb 2015 22:20:42 +0300 Subject: [PATCH 16/35] CanIOManager::getCanDriver() - mutating overload --- libuavcan/include/uavcan/transport/can_io.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libuavcan/include/uavcan/transport/can_io.hpp b/libuavcan/include/uavcan/transport/can_io.hpp index c8d4e6925f..2d2e945033 100644 --- a/libuavcan/include/uavcan/transport/can_io.hpp +++ b/libuavcan/include/uavcan/transport/can_io.hpp @@ -165,6 +165,7 @@ public: CanIfacePerfCounters getIfacePerfCounters(uint8_t iface_index) const; const ICanDriver& getCanDriver() const { return driver_; } + ICanDriver& getCanDriver() { return driver_; } /** * Returns: From b6d145aa352ea3d44375ff4ceae9e427799a7f4f Mon Sep 17 00:00:00 2001 From: postal Date: Fri, 6 Feb 2015 19:24:43 +0100 Subject: [PATCH 17/35] Dependencies update for linux/cmake --- libuavcan_drivers/linux/CMakeLists.txt | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/libuavcan_drivers/linux/CMakeLists.txt b/libuavcan_drivers/linux/CMakeLists.txt index 6069f762d0..252cd8a69e 100644 --- a/libuavcan_drivers/linux/CMakeLists.txt +++ b/libuavcan_drivers/linux/CMakeLists.txt @@ -11,6 +11,12 @@ project(libuavcan_linux) # install(DIRECTORY include/uavcan_linux DESTINATION include) +# +# System dependecies +# +find_package(Threads REQUIRED) + + # # Finding libuavcan - it will be a target if we're running from the top-level CMakeLists.txt, # otherwise try to find it in the system directories. @@ -36,27 +42,27 @@ set(CMAKE_CXX_FLAGS "-Wall -Wextra -pedantic -std=c++0x") # GCC or Clang # These aren't installed, an average library user should not care about them. # add_executable(test_clock apps/test_clock.cpp) -target_link_libraries(test_clock ${UAVCAN_LIB} rt) +target_link_libraries(test_clock ${UAVCAN_LIB} rt ${CMAKE_THREAD_LIBS_INIT}) add_executable(test_socket apps/test_socket.cpp) -target_link_libraries(test_socket ${UAVCAN_LIB} rt) +target_link_libraries(test_socket ${UAVCAN_LIB} rt ${CMAKE_THREAD_LIBS_INIT}) add_executable(test_node apps/test_node.cpp) -target_link_libraries(test_node ${UAVCAN_LIB} rt) +target_link_libraries(test_node ${UAVCAN_LIB} rt ${CMAKE_THREAD_LIBS_INIT}) add_executable(test_time_sync apps/test_time_sync.cpp) -target_link_libraries(test_time_sync ${UAVCAN_LIB} rt) +target_link_libraries(test_time_sync ${UAVCAN_LIB} rt ${CMAKE_THREAD_LIBS_INIT}) # # Tools # Someday they will be replaced with Python scripts (pyuavcan is not finished at the moment) # add_executable(uavcan_status_monitor apps/uavcan_status_monitor.cpp) -target_link_libraries(uavcan_status_monitor ${UAVCAN_LIB} rt) +target_link_libraries(uavcan_status_monitor ${UAVCAN_LIB} rt ${CMAKE_THREAD_LIBS_INIT}) add_executable(uavcan_nodetool apps/uavcan_nodetool.cpp) -target_link_libraries(uavcan_nodetool ${UAVCAN_LIB} rt) +target_link_libraries(uavcan_nodetool ${UAVCAN_LIB} rt ${CMAKE_THREAD_LIBS_INIT}) install(TARGETS uavcan_status_monitor uavcan_nodetool - RUNTIME DESTINATION bin) + RUNTIME DESTINATION bin) \ No newline at end of file From 1bf41b135dedc24c5dd38549e69356433a5da22a Mon Sep 17 00:00:00 2001 From: postal Date: Fri, 6 Feb 2015 19:42:26 +0100 Subject: [PATCH 18/35] Dependencies update for linux/cmake --- libuavcan_drivers/linux/CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libuavcan_drivers/linux/CMakeLists.txt b/libuavcan_drivers/linux/CMakeLists.txt index 252cd8a69e..803c4daae3 100644 --- a/libuavcan_drivers/linux/CMakeLists.txt +++ b/libuavcan_drivers/linux/CMakeLists.txt @@ -26,7 +26,7 @@ if (TARGET uavcan) set(UAVCAN_LIB uavcan) include_directories(${libuavcan_SOURCE_DIR}/include ${libuavcan_SOURCE_DIR}/include/dsdlc_generated) -else () +else ()- message(STATUS "Using installed uavcan library") find_library(UAVCAN_LIB uavcan REQUIRED) endif () @@ -65,4 +65,5 @@ target_link_libraries(uavcan_nodetool ${UAVCAN_LIB} rt ${CMAKE_THREAD_LIBS_INIT} install(TARGETS uavcan_status_monitor uavcan_nodetool - RUNTIME DESTINATION bin) \ No newline at end of file + RUNTIME DESTINATION bin) + \ No newline at end of file From 41755b46a81aa212a849e3e4ec52a79e6ce92be9 Mon Sep 17 00:00:00 2001 From: postal Date: Fri, 6 Feb 2015 19:50:02 +0100 Subject: [PATCH 19/35] Dependencies update for linux/cmake --- libuavcan_drivers/linux/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libuavcan_drivers/linux/CMakeLists.txt b/libuavcan_drivers/linux/CMakeLists.txt index 803c4daae3..99e75959b0 100644 --- a/libuavcan_drivers/linux/CMakeLists.txt +++ b/libuavcan_drivers/linux/CMakeLists.txt @@ -26,7 +26,7 @@ if (TARGET uavcan) set(UAVCAN_LIB uavcan) include_directories(${libuavcan_SOURCE_DIR}/include ${libuavcan_SOURCE_DIR}/include/dsdlc_generated) -else ()- +else () message(STATUS "Using installed uavcan library") find_library(UAVCAN_LIB uavcan REQUIRED) endif () From 672874d11e0474ce64e842a9d307cc15bd8dc987 Mon Sep 17 00:00:00 2001 From: postal Date: Fri, 6 Feb 2015 19:54:18 +0100 Subject: [PATCH 20/35] Dependencies update for linux/cmake --- libuavcan_drivers/linux/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/libuavcan_drivers/linux/CMakeLists.txt b/libuavcan_drivers/linux/CMakeLists.txt index 99e75959b0..51cbcf1c97 100644 --- a/libuavcan_drivers/linux/CMakeLists.txt +++ b/libuavcan_drivers/linux/CMakeLists.txt @@ -16,7 +16,6 @@ install(DIRECTORY include/uavcan_linux DESTINATION include) # find_package(Threads REQUIRED) - # # Finding libuavcan - it will be a target if we're running from the top-level CMakeLists.txt, # otherwise try to find it in the system directories. From 803e60f30f44ca25c074df8d967edccd932e62fb Mon Sep 17 00:00:00 2001 From: postal Date: Mon, 23 Feb 2015 19:07:18 +0100 Subject: [PATCH 21/35] Cmake gcc 4.9 compatability --- libuavcan/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/libuavcan/CMakeLists.txt b/libuavcan/CMakeLists.txt index 0648b8ca14..fc4afc96ad 100644 --- a/libuavcan/CMakeLists.txt +++ b/libuavcan/CMakeLists.txt @@ -103,6 +103,7 @@ if (DEBUG_BUILD) if (COMPILER_IS_GCC_COMPATIBLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -pedantic -Wfloat-equal -Wconversion") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsign-conversion -Wcast-align -Wmissing-declarations") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=array-bounds") set(cpp03_flags "-std=c++03 -Wno-variadic-macros -Wno-long-long") set(optim_flags "-O3 -DNDEBUG -g0") else () From 9ad492e745f169957bff89b60496a4bfacf11ad9 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Fri, 27 Feb 2015 04:05:21 +0300 Subject: [PATCH 22/35] .gitignore update --- .gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 179d3cd025..0ad0dfa15d 100644 --- a/.gitignore +++ b/.gitignore @@ -10,8 +10,8 @@ __pycache__ *.pyc # Eclipse -.metadata/* -.settings/* +.metadata +.settings .project .cproject .pydevproject From d4986598b154c1292289335fa99b0d999d9d57ea Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Fri, 27 Feb 2015 16:17:03 +0300 Subject: [PATCH 23/35] LPC11C24: Stack overflow fix --- libuavcan_drivers/lpc11c24/test_olimex_lpc_p11c24/src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libuavcan_drivers/lpc11c24/test_olimex_lpc_p11c24/src/main.cpp b/libuavcan_drivers/lpc11c24/test_olimex_lpc_p11c24/src/main.cpp index a5e7e85321..22485746e3 100644 --- a/libuavcan_drivers/lpc11c24/test_olimex_lpc_p11c24/src/main.cpp +++ b/libuavcan_drivers/lpc11c24/test_olimex_lpc_p11c24/src/main.cpp @@ -13,7 +13,7 @@ namespace { -typedef uavcan::Node<3136> Node; +typedef uavcan::Node<2800> Node; Node& getNode() { From 79623033c1b938ec21e405130ee66832ef6a9657 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Thu, 12 Mar 2015 00:36:25 +0300 Subject: [PATCH 24/35] Abandoning pragma once --- libuavcan/dsdl_compiler/libuavcan_dsdl_compiler/__init__.py | 1 + .../libuavcan_dsdl_compiler/data_type_template.tmpl | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libuavcan/dsdl_compiler/libuavcan_dsdl_compiler/__init__.py b/libuavcan/dsdl_compiler/libuavcan_dsdl_compiler/__init__.py index 88b4def241..0de8fea8a9 100644 --- a/libuavcan/dsdl_compiler/libuavcan_dsdl_compiler/__init__.py +++ b/libuavcan/dsdl_compiler/libuavcan_dsdl_compiler/__init__.py @@ -165,6 +165,7 @@ def generate_one_type(template_expander, t): t.short_name = t.full_name.split('.')[-1] t.cpp_type_name = t.short_name + '_' t.cpp_full_type_name = '::' + t.full_name.replace('.', '::') + t.include_guard = t.full_name.replace('.', '_').upper() + '_HPP_INCLUDED' # Dependencies (no duplicates) def fields_includes(fields): diff --git a/libuavcan/dsdl_compiler/libuavcan_dsdl_compiler/data_type_template.tmpl b/libuavcan/dsdl_compiler/libuavcan_dsdl_compiler/data_type_template.tmpl index 144bd58850..8b3ba7855e 100644 --- a/libuavcan/dsdl_compiler/libuavcan_dsdl_compiler/data_type_template.tmpl +++ b/libuavcan/dsdl_compiler/libuavcan_dsdl_compiler/data_type_template.tmpl @@ -6,7 +6,8 @@ * Source file: ${t.source_file} */ -#pragma once +#ifndef ${t.include_guard} +#define ${t.include_guard} #include #include @@ -385,3 +386,5 @@ ${define_streaming_operator(type_name=t.cpp_full_type_name)} % for nsc in t.cpp_namespace_components: } % endfor + +#endif // ${t.include_guard} From c47f196281b0a15829bdc5cb9debc8f961e7f921 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Thu, 12 Mar 2015 00:52:23 +0300 Subject: [PATCH 25/35] New tool: unpragma_once.pl --- libuavcan/tools/unpragma_once.pl | 59 ++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100755 libuavcan/tools/unpragma_once.pl diff --git a/libuavcan/tools/unpragma_once.pl b/libuavcan/tools/unpragma_once.pl new file mode 100755 index 0000000000..e21e759827 --- /dev/null +++ b/libuavcan/tools/unpragma_once.pl @@ -0,0 +1,59 @@ +#!/usr/bin/env perl +############################################################################### +# Purpose: Remove all occurrences of "#pragma once" from the source tree. +# Usage: "unpragma-once *.h" or "find . -name \*.h | xargs unpragma-once" +# Author: Vadim Zeitlin +# Licence: Free Software released under BSD license +# Copyright: (C) 2011 TT-Solutions SARL +############################################################################### +# Pavel Kirienko , 2015: +# Include guard naming adapted to UAVCAN coding style. +############################################################################### + +use warnings; +use strict; +use autodie; + +use File::Copy qw(move); +use File::Spec (); +use File::Temp (); +use IO::Handle; + +sub process_single_file +{ + my $filename = shift; + + my ($volume, $dir, $basename) = File::Spec->splitpath($filename); + + open my $in, '<', $filename; + my $out = File::Temp->new(DIR => $volume . $dir); + + my $guard = ''; + my $last_was_empty = 0; + while (<$in>) { + if (/^#pragma\s+once\s+$/) { + die "Duplicate #pragma once at $filename:$.\n" if $guard; + + ($guard = uc $filename) =~ s/[\/\.]/_/g; + $guard .= "_INCLUDED"; + print $out "#ifndef $guard\n"; + print $out "#define $guard\n"; + } + else { + $last_was_empty = ($_ =~ /^\s*$/); + print $out $_ + } + } + + if ($guard) { + print $out "\n" unless $last_was_empty; + print $out "#endif // $guard\n"; + + $out->flush(); + move($out->filename, $filename); + } +} + +for (@ARGV) { + process_single_file $_ +} From eb982bdd40e3b47bf436cec5c91aab5ac836b1d1 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Thu, 12 Mar 2015 00:53:18 +0300 Subject: [PATCH 26/35] All occurences of pragma once in libuavcan headers were replaced with conventional include guards. --- libuavcan/include/uavcan/build_config.hpp | 5 ++++- libuavcan/include/uavcan/data_type.hpp | 5 ++++- libuavcan/include/uavcan/debug.hpp | 5 ++++- libuavcan/include/uavcan/driver/can.hpp | 5 ++++- libuavcan/include/uavcan/driver/system_clock.hpp | 5 ++++- libuavcan/include/uavcan/dynamic_memory.hpp | 5 ++++- libuavcan/include/uavcan/error.hpp | 5 ++++- .../include/uavcan/helpers/component_status_manager.hpp | 5 ++++- libuavcan/include/uavcan/helpers/ostream.hpp | 5 ++++- libuavcan/include/uavcan/marshal/array.hpp | 5 ++++- libuavcan/include/uavcan/marshal/bit_stream.hpp | 5 ++++- libuavcan/include/uavcan/marshal/char_array_formatter.hpp | 5 ++++- libuavcan/include/uavcan/marshal/float_spec.hpp | 5 ++++- libuavcan/include/uavcan/marshal/integer_spec.hpp | 5 ++++- libuavcan/include/uavcan/marshal/scalar_codec.hpp | 5 ++++- libuavcan/include/uavcan/marshal/type_util.hpp | 5 ++++- libuavcan/include/uavcan/marshal/types.hpp | 5 ++++- libuavcan/include/uavcan/node/abstract_node.hpp | 5 ++++- libuavcan/include/uavcan/node/generic_publisher.hpp | 5 ++++- libuavcan/include/uavcan/node/generic_subscriber.hpp | 5 ++++- libuavcan/include/uavcan/node/global_data_type_registry.hpp | 5 ++++- libuavcan/include/uavcan/node/marshal_buffer.hpp | 5 ++++- libuavcan/include/uavcan/node/node.hpp | 5 ++++- libuavcan/include/uavcan/node/publisher.hpp | 5 ++++- libuavcan/include/uavcan/node/scheduler.hpp | 5 ++++- libuavcan/include/uavcan/node/service_client.hpp | 5 ++++- libuavcan/include/uavcan/node/service_server.hpp | 5 ++++- libuavcan/include/uavcan/node/subscriber.hpp | 5 ++++- libuavcan/include/uavcan/node/timer.hpp | 5 ++++- .../include/uavcan/protocol/data_type_info_provider.hpp | 5 ++++- .../include/uavcan/protocol/global_time_sync_master.hpp | 5 ++++- libuavcan/include/uavcan/protocol/global_time_sync_slave.hpp | 5 ++++- libuavcan/include/uavcan/protocol/logger.hpp | 5 ++++- libuavcan/include/uavcan/protocol/network_compat_checker.hpp | 5 ++++- libuavcan/include/uavcan/protocol/node_status_monitor.hpp | 5 ++++- libuavcan/include/uavcan/protocol/node_status_provider.hpp | 5 ++++- libuavcan/include/uavcan/protocol/panic_broadcaster.hpp | 5 ++++- libuavcan/include/uavcan/protocol/panic_listener.hpp | 5 ++++- libuavcan/include/uavcan/protocol/param_server.hpp | 5 ++++- libuavcan/include/uavcan/protocol/restart_request_server.hpp | 5 ++++- .../include/uavcan/protocol/transport_stats_provider.hpp | 5 ++++- libuavcan/include/uavcan/stdint.hpp | 5 ++++- libuavcan/include/uavcan/time.hpp | 5 ++++- .../include/uavcan/transport/abstract_transfer_buffer.hpp | 5 ++++- libuavcan/include/uavcan/transport/can_io.hpp | 5 ++++- libuavcan/include/uavcan/transport/crc.hpp | 5 ++++- libuavcan/include/uavcan/transport/dispatcher.hpp | 5 ++++- libuavcan/include/uavcan/transport/frame.hpp | 5 ++++- .../include/uavcan/transport/outgoing_transfer_registry.hpp | 5 ++++- libuavcan/include/uavcan/transport/perf_counter.hpp | 5 ++++- libuavcan/include/uavcan/transport/transfer.hpp | 5 ++++- libuavcan/include/uavcan/transport/transfer_buffer.hpp | 5 ++++- libuavcan/include/uavcan/transport/transfer_listener.hpp | 5 ++++- libuavcan/include/uavcan/transport/transfer_receiver.hpp | 5 ++++- libuavcan/include/uavcan/transport/transfer_sender.hpp | 5 ++++- libuavcan/include/uavcan/uavcan.hpp | 5 ++++- libuavcan/include/uavcan/util/bitset.hpp | 5 ++++- libuavcan/include/uavcan/util/comparison.hpp | 5 ++++- libuavcan/include/uavcan/util/lazy_constructor.hpp | 5 ++++- libuavcan/include/uavcan/util/linked_list.hpp | 5 ++++- libuavcan/include/uavcan/util/map.hpp | 5 ++++- libuavcan/include/uavcan/util/method_binder.hpp | 5 ++++- libuavcan/include/uavcan/util/placement_new.hpp | 5 ++++- libuavcan/include/uavcan/util/templates.hpp | 5 ++++- 64 files changed, 256 insertions(+), 64 deletions(-) diff --git a/libuavcan/include/uavcan/build_config.hpp b/libuavcan/include/uavcan/build_config.hpp index 06a771c2cc..31c34ecf3f 100644 --- a/libuavcan/include/uavcan/build_config.hpp +++ b/libuavcan/include/uavcan/build_config.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_BUILD_CONFIG_HPP_INCLUDED +#define UAVCAN_BUILD_CONFIG_HPP_INCLUDED /** * UAVCAN version definition @@ -212,3 +213,5 @@ static const unsigned FloatComparisonEpsilonMult = 10; #endif } + +#endif // UAVCAN_BUILD_CONFIG_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/data_type.hpp b/libuavcan/include/uavcan/data_type.hpp index 4fb3daf12f..8e47751647 100644 --- a/libuavcan/include/uavcan/data_type.hpp +++ b/libuavcan/include/uavcan/data_type.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_DATA_TYPE_HPP_INCLUDED +#define UAVCAN_DATA_TYPE_HPP_INCLUDED #include #include @@ -144,3 +145,5 @@ public: }; } + +#endif // UAVCAN_DATA_TYPE_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/debug.hpp b/libuavcan/include/uavcan/debug.hpp index bee2dd0ad1..8b2ca17247 100644 --- a/libuavcan/include/uavcan/debug.hpp +++ b/libuavcan/include/uavcan/debug.hpp @@ -3,7 +3,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_DEBUG_HPP_INCLUDED +#define UAVCAN_DEBUG_HPP_INCLUDED #include @@ -30,3 +31,5 @@ static void UAVCAN_TRACE(const char* src, const char* fmt, ...) # define UAVCAN_TRACE(...) ((void)0) #endif + +#endif // UAVCAN_DEBUG_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/driver/can.hpp b/libuavcan/include/uavcan/driver/can.hpp index d55859d0a0..ad77abfcf7 100644 --- a/libuavcan/include/uavcan/driver/can.hpp +++ b/libuavcan/include/uavcan/driver/can.hpp @@ -3,7 +3,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_DRIVER_CAN_HPP_INCLUDED +#define UAVCAN_DRIVER_CAN_HPP_INCLUDED #include #include @@ -187,3 +188,5 @@ public: }; } + +#endif // UAVCAN_DRIVER_CAN_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/driver/system_clock.hpp b/libuavcan/include/uavcan/driver/system_clock.hpp index d19480e358..22055b457e 100644 --- a/libuavcan/include/uavcan/driver/system_clock.hpp +++ b/libuavcan/include/uavcan/driver/system_clock.hpp @@ -3,7 +3,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_DRIVER_SYSTEM_CLOCK_HPP_INCLUDED +#define UAVCAN_DRIVER_SYSTEM_CLOCK_HPP_INCLUDED #include #include @@ -44,3 +45,5 @@ public: }; } + +#endif // UAVCAN_DRIVER_SYSTEM_CLOCK_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/dynamic_memory.hpp b/libuavcan/include/uavcan/dynamic_memory.hpp index 3783f8ba8f..7c0ffb2038 100644 --- a/libuavcan/include/uavcan/dynamic_memory.hpp +++ b/libuavcan/include/uavcan/dynamic_memory.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_DYNAMIC_MEMORY_HPP_INCLUDED +#define UAVCAN_DYNAMIC_MEMORY_HPP_INCLUDED #include #include @@ -297,3 +298,5 @@ unsigned PoolAllocator::getNumFreeBlocks() const } } + +#endif // UAVCAN_DYNAMIC_MEMORY_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/error.hpp b/libuavcan/include/uavcan/error.hpp index 13935a1fd6..1cbeafcc22 100644 --- a/libuavcan/include/uavcan/error.hpp +++ b/libuavcan/include/uavcan/error.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_ERROR_HPP_INCLUDED +#define UAVCAN_ERROR_HPP_INCLUDED #include #include @@ -53,3 +54,5 @@ UAVCAN_EXPORT void handleFatalError(const char* msg); } + +#endif // UAVCAN_ERROR_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/helpers/component_status_manager.hpp b/libuavcan/include/uavcan/helpers/component_status_manager.hpp index a71610b3ce..78d700b758 100644 --- a/libuavcan/include/uavcan/helpers/component_status_manager.hpp +++ b/libuavcan/include/uavcan/helpers/component_status_manager.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_HELPERS_COMPONENT_STATUS_MANAGER_HPP_INCLUDED +#define UAVCAN_HELPERS_COMPONENT_STATUS_MANAGER_HPP_INCLUDED #include #include @@ -68,3 +69,5 @@ template const unsigned ComponentStatusManager::NumComponents; } + +#endif // UAVCAN_HELPERS_COMPONENT_STATUS_MANAGER_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/helpers/ostream.hpp b/libuavcan/include/uavcan/helpers/ostream.hpp index e75f9d22fe..5add58f4f3 100644 --- a/libuavcan/include/uavcan/helpers/ostream.hpp +++ b/libuavcan/include/uavcan/helpers/ostream.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_HELPERS_OSTREAM_HPP_INCLUDED +#define UAVCAN_HELPERS_OSTREAM_HPP_INCLUDED #include #include @@ -58,3 +59,5 @@ inline OStream& operator<<(OStream& s, const char* x) { std::printf("%s", x); re inline OStream& operator<<(OStream& s, OStream&(*manip)(OStream&)) { return manip(s); } } + +#endif // UAVCAN_HELPERS_OSTREAM_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/marshal/array.hpp b/libuavcan/include/uavcan/marshal/array.hpp index 8fc64f350f..70f1c27d97 100644 --- a/libuavcan/include/uavcan/marshal/array.hpp +++ b/libuavcan/include/uavcan/marshal/array.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_MARSHAL_ARRAY_HPP_INCLUDED +#define UAVCAN_MARSHAL_ARRAY_HPP_INCLUDED #include #include @@ -1034,3 +1035,5 @@ public: }; } + +#endif // UAVCAN_MARSHAL_ARRAY_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/marshal/bit_stream.hpp b/libuavcan/include/uavcan/marshal/bit_stream.hpp index 413893e627..b7504112ec 100644 --- a/libuavcan/include/uavcan/marshal/bit_stream.hpp +++ b/libuavcan/include/uavcan/marshal/bit_stream.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_MARSHAL_BIT_STREAM_HPP_INCLUDED +#define UAVCAN_MARSHAL_BIT_STREAM_HPP_INCLUDED #include #include @@ -116,3 +117,5 @@ public: }; } + +#endif // UAVCAN_MARSHAL_BIT_STREAM_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/marshal/char_array_formatter.hpp b/libuavcan/include/uavcan/marshal/char_array_formatter.hpp index 85e9d37678..244c3b1204 100644 --- a/libuavcan/include/uavcan/marshal/char_array_formatter.hpp +++ b/libuavcan/include/uavcan/marshal/char_array_formatter.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_MARSHAL_CHAR_ARRAY_FORMATTER_HPP_INCLUDED +#define UAVCAN_MARSHAL_CHAR_ARRAY_FORMATTER_HPP_INCLUDED #include #include @@ -137,3 +138,5 @@ public: #endif } + +#endif // UAVCAN_MARSHAL_CHAR_ARRAY_FORMATTER_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/marshal/float_spec.hpp b/libuavcan/include/uavcan/marshal/float_spec.hpp index ec06e53f60..ab0063056a 100644 --- a/libuavcan/include/uavcan/marshal/float_spec.hpp +++ b/libuavcan/include/uavcan/marshal/float_spec.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_MARSHAL_FLOAT_SPEC_HPP_INCLUDED +#define UAVCAN_MARSHAL_FLOAT_SPEC_HPP_INCLUDED #include #include @@ -222,3 +223,5 @@ public: }; } + +#endif // UAVCAN_MARSHAL_FLOAT_SPEC_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/marshal/integer_spec.hpp b/libuavcan/include/uavcan/marshal/integer_spec.hpp index 8561b02155..2a74218581 100644 --- a/libuavcan/include/uavcan/marshal/integer_spec.hpp +++ b/libuavcan/include/uavcan/marshal/integer_spec.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_MARSHAL_INTEGER_SPEC_HPP_INCLUDED +#define UAVCAN_MARSHAL_INTEGER_SPEC_HPP_INCLUDED #include #include @@ -164,3 +165,5 @@ public: }; } + +#endif // UAVCAN_MARSHAL_INTEGER_SPEC_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/marshal/scalar_codec.hpp b/libuavcan/include/uavcan/marshal/scalar_codec.hpp index 6bc62c8e80..b46c1b16bb 100644 --- a/libuavcan/include/uavcan/marshal/scalar_codec.hpp +++ b/libuavcan/include/uavcan/marshal/scalar_codec.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_MARSHAL_SCALAR_CODEC_HPP_INCLUDED +#define UAVCAN_MARSHAL_SCALAR_CODEC_HPP_INCLUDED #include #include @@ -135,3 +136,5 @@ int ScalarCodec::decode(T& value) } } + +#endif // UAVCAN_MARSHAL_SCALAR_CODEC_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/marshal/type_util.hpp b/libuavcan/include/uavcan/marshal/type_util.hpp index 45df4d03c4..5be02921e8 100644 --- a/libuavcan/include/uavcan/marshal/type_util.hpp +++ b/libuavcan/include/uavcan/marshal/type_util.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_MARSHAL_TYPE_UTIL_HPP_INCLUDED +#define UAVCAN_MARSHAL_TYPE_UTIL_HPP_INCLUDED #include #include @@ -83,3 +84,5 @@ template class UAVCAN_EXPORT YamlStreamer; } + +#endif // UAVCAN_MARSHAL_TYPE_UTIL_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/marshal/types.hpp b/libuavcan/include/uavcan/marshal/types.hpp index a9df753a21..4fbbe98371 100644 --- a/libuavcan/include/uavcan/marshal/types.hpp +++ b/libuavcan/include/uavcan/marshal/types.hpp @@ -2,9 +2,12 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_MARSHAL_TYPES_HPP_INCLUDED +#define UAVCAN_MARSHAL_TYPES_HPP_INCLUDED #include #include #include #include + +#endif // UAVCAN_MARSHAL_TYPES_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/node/abstract_node.hpp b/libuavcan/include/uavcan/node/abstract_node.hpp index 9b93646000..cebdcec7fc 100644 --- a/libuavcan/include/uavcan/node/abstract_node.hpp +++ b/libuavcan/include/uavcan/node/abstract_node.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_NODE_ABSTRACT_NODE_HPP_INCLUDED +#define UAVCAN_NODE_ABSTRACT_NODE_HPP_INCLUDED #include #include @@ -78,3 +79,5 @@ public: }; } + +#endif // UAVCAN_NODE_ABSTRACT_NODE_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/node/generic_publisher.hpp b/libuavcan/include/uavcan/node/generic_publisher.hpp index 38bb31826f..aece082ddb 100644 --- a/libuavcan/include/uavcan/node/generic_publisher.hpp +++ b/libuavcan/include/uavcan/node/generic_publisher.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_NODE_GENERIC_PUBLISHER_HPP_INCLUDED +#define UAVCAN_NODE_GENERIC_PUBLISHER_HPP_INCLUDED #include #include @@ -172,3 +173,5 @@ int GenericPublisher::genericPublish(const DataStruct& mes } } + +#endif // UAVCAN_NODE_GENERIC_PUBLISHER_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/node/generic_subscriber.hpp b/libuavcan/include/uavcan/node/generic_subscriber.hpp index 0782d718bf..3ec6b87f92 100644 --- a/libuavcan/include/uavcan/node/generic_subscriber.hpp +++ b/libuavcan/include/uavcan/node/generic_subscriber.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_NODE_GENERIC_SUBSCRIBER_HPP_INCLUDED +#define UAVCAN_NODE_GENERIC_SUBSCRIBER_HPP_INCLUDED #include #include @@ -287,3 +288,5 @@ genericStart(bool (Dispatcher::*registration_method)(TransferListenerBase*)) } + +#endif // UAVCAN_NODE_GENERIC_SUBSCRIBER_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/node/global_data_type_registry.hpp b/libuavcan/include/uavcan/node/global_data_type_registry.hpp index 8ee9d39a95..f1b8cbf6dd 100644 --- a/libuavcan/include/uavcan/node/global_data_type_registry.hpp +++ b/libuavcan/include/uavcan/node/global_data_type_registry.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_NODE_GLOBAL_DATA_TYPE_REGISTRY_HPP_INCLUDED +#define UAVCAN_NODE_GLOBAL_DATA_TYPE_REGISTRY_HPP_INCLUDED #include #include @@ -246,3 +247,5 @@ GlobalDataTypeRegistry::RegistResult GlobalDataTypeRegistry::regist(DataTypeID i } } + +#endif // UAVCAN_NODE_GLOBAL_DATA_TYPE_REGISTRY_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/node/marshal_buffer.hpp b/libuavcan/include/uavcan/node/marshal_buffer.hpp index f33c037653..7e55ce49dc 100644 --- a/libuavcan/include/uavcan/node/marshal_buffer.hpp +++ b/libuavcan/include/uavcan/node/marshal_buffer.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_NODE_MARSHAL_BUFFER_HPP_INCLUDED +#define UAVCAN_NODE_MARSHAL_BUFFER_HPP_INCLUDED #include #include @@ -87,3 +88,5 @@ public: }; } + +#endif // UAVCAN_NODE_MARSHAL_BUFFER_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/node/node.hpp b/libuavcan/include/uavcan/node/node.hpp index 7f20d714c3..c04bf1103b 100644 --- a/libuavcan/include/uavcan/node/node.hpp +++ b/libuavcan/include/uavcan/node/node.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_NODE_NODE_HPP_INCLUDED +#define UAVCAN_NODE_NODE_HPP_INCLUDED #include #include @@ -322,3 +323,5 @@ checkNetworkCompatibility(NetworkCompatibilityCheckResult& result) #endif } + +#endif // UAVCAN_NODE_NODE_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/node/publisher.hpp b/libuavcan/include/uavcan/node/publisher.hpp index 5d1524f4da..6abb3bd533 100644 --- a/libuavcan/include/uavcan/node/publisher.hpp +++ b/libuavcan/include/uavcan/node/publisher.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_NODE_PUBLISHER_HPP_INCLUDED +#define UAVCAN_NODE_PUBLISHER_HPP_INCLUDED #include @@ -95,3 +96,5 @@ public: }; } + +#endif // UAVCAN_NODE_PUBLISHER_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/node/scheduler.hpp b/libuavcan/include/uavcan/node/scheduler.hpp index f283f72e7e..847f76b9d9 100644 --- a/libuavcan/include/uavcan/node/scheduler.hpp +++ b/libuavcan/include/uavcan/node/scheduler.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_NODE_SCHEDULER_HPP_INCLUDED +#define UAVCAN_NODE_SCHEDULER_HPP_INCLUDED #include #include @@ -130,3 +131,5 @@ public: }; } + +#endif // UAVCAN_NODE_SCHEDULER_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/node/service_client.hpp b/libuavcan/include/uavcan/node/service_client.hpp index 378c0601ff..1b73c5163b 100644 --- a/libuavcan/include/uavcan/node/service_client.hpp +++ b/libuavcan/include/uavcan/node/service_client.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_NODE_SERVICE_CLIENT_HPP_INCLUDED +#define UAVCAN_NODE_SERVICE_CLIENT_HPP_INCLUDED #include #include @@ -368,3 +369,5 @@ void ServiceClient::cancel() } } + +#endif // UAVCAN_NODE_SERVICE_CLIENT_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/node/service_server.hpp b/libuavcan/include/uavcan/node/service_server.hpp index 5ca6f970b5..6d5695451c 100644 --- a/libuavcan/include/uavcan/node/service_server.hpp +++ b/libuavcan/include/uavcan/node/service_server.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_NODE_SERVICE_SERVER_HPP_INCLUDED +#define UAVCAN_NODE_SERVICE_SERVER_HPP_INCLUDED #include #include @@ -157,3 +158,5 @@ public: }; } + +#endif // UAVCAN_NODE_SERVICE_SERVER_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/node/subscriber.hpp b/libuavcan/include/uavcan/node/subscriber.hpp index 62b15e11b7..1112a6abc0 100644 --- a/libuavcan/include/uavcan/node/subscriber.hpp +++ b/libuavcan/include/uavcan/node/subscriber.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_NODE_SUBSCRIBER_HPP_INCLUDED +#define UAVCAN_NODE_SUBSCRIBER_HPP_INCLUDED #include #include @@ -115,3 +116,5 @@ public: }; } + +#endif // UAVCAN_NODE_SUBSCRIBER_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/node/timer.hpp b/libuavcan/include/uavcan/node/timer.hpp index 3e0b360a84..1521489f99 100644 --- a/libuavcan/include/uavcan/node/timer.hpp +++ b/libuavcan/include/uavcan/node/timer.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_NODE_TIMER_HPP_INCLUDED +#define UAVCAN_NODE_TIMER_HPP_INCLUDED #include #include @@ -143,3 +144,5 @@ typedef TimerEventForwarder > Time #endif } + +#endif // UAVCAN_NODE_TIMER_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/protocol/data_type_info_provider.hpp b/libuavcan/include/uavcan/protocol/data_type_info_provider.hpp index 799dc51ac4..9ec95c73d4 100644 --- a/libuavcan/include/uavcan/protocol/data_type_info_provider.hpp +++ b/libuavcan/include/uavcan/protocol/data_type_info_provider.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_PROTOCOL_DATA_TYPE_INFO_PROVIDER_HPP_INCLUDED +#define UAVCAN_PROTOCOL_DATA_TYPE_INFO_PROVIDER_HPP_INCLUDED #include #include @@ -51,3 +52,5 @@ public: }; } + +#endif // UAVCAN_PROTOCOL_DATA_TYPE_INFO_PROVIDER_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/protocol/global_time_sync_master.hpp b/libuavcan/include/uavcan/protocol/global_time_sync_master.hpp index 0d477cc0e1..e658b33730 100644 --- a/libuavcan/include/uavcan/protocol/global_time_sync_master.hpp +++ b/libuavcan/include/uavcan/protocol/global_time_sync_master.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_PROTOCOL_GLOBAL_TIME_SYNC_MASTER_HPP_INCLUDED +#define UAVCAN_PROTOCOL_GLOBAL_TIME_SYNC_MASTER_HPP_INCLUDED #include #include @@ -92,3 +93,5 @@ public: }; } + +#endif // UAVCAN_PROTOCOL_GLOBAL_TIME_SYNC_MASTER_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/protocol/global_time_sync_slave.hpp b/libuavcan/include/uavcan/protocol/global_time_sync_slave.hpp index 04c4e0f955..3da6532998 100644 --- a/libuavcan/include/uavcan/protocol/global_time_sync_slave.hpp +++ b/libuavcan/include/uavcan/protocol/global_time_sync_slave.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_PROTOCOL_GLOBAL_TIME_SYNC_SLAVE_HPP_INCLUDED +#define UAVCAN_PROTOCOL_GLOBAL_TIME_SYNC_SLAVE_HPP_INCLUDED #include #include @@ -103,3 +104,5 @@ public: }; } + +#endif // UAVCAN_PROTOCOL_GLOBAL_TIME_SYNC_SLAVE_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/protocol/logger.hpp b/libuavcan/include/uavcan/protocol/logger.hpp index 9001dcf65f..fcacfc4801 100644 --- a/libuavcan/include/uavcan/protocol/logger.hpp +++ b/libuavcan/include/uavcan/protocol/logger.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_PROTOCOL_LOGGER_HPP_INCLUDED +#define UAVCAN_PROTOCOL_LOGGER_HPP_INCLUDED #include #include @@ -235,3 +236,5 @@ int Logger::log(LogLevel level, const char* source, const char* format, Args... #endif } + +#endif // UAVCAN_PROTOCOL_LOGGER_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/protocol/network_compat_checker.hpp b/libuavcan/include/uavcan/protocol/network_compat_checker.hpp index 2a5799e3bc..5a39b5c6fc 100644 --- a/libuavcan/include/uavcan/protocol/network_compat_checker.hpp +++ b/libuavcan/include/uavcan/protocol/network_compat_checker.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_PROTOCOL_NETWORK_COMPAT_CHECKER_HPP_INCLUDED +#define UAVCAN_PROTOCOL_NETWORK_COMPAT_CHECKER_HPP_INCLUDED #include #include @@ -104,3 +105,5 @@ public: }; } + +#endif // UAVCAN_PROTOCOL_NETWORK_COMPAT_CHECKER_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/protocol/node_status_monitor.hpp b/libuavcan/include/uavcan/protocol/node_status_monitor.hpp index 1c499014ee..0cf829a63a 100644 --- a/libuavcan/include/uavcan/protocol/node_status_monitor.hpp +++ b/libuavcan/include/uavcan/protocol/node_status_monitor.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_PROTOCOL_NODE_STATUS_MONITOR_HPP_INCLUDED +#define UAVCAN_PROTOCOL_NODE_STATUS_MONITOR_HPP_INCLUDED #include #include @@ -123,3 +124,5 @@ public: }; } + +#endif // UAVCAN_PROTOCOL_NODE_STATUS_MONITOR_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/protocol/node_status_provider.hpp b/libuavcan/include/uavcan/protocol/node_status_provider.hpp index 22f6eb2f80..524dd43c35 100644 --- a/libuavcan/include/uavcan/protocol/node_status_provider.hpp +++ b/libuavcan/include/uavcan/protocol/node_status_provider.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_PROTOCOL_NODE_STATUS_PROVIDER_HPP_INCLUDED +#define UAVCAN_PROTOCOL_NODE_STATUS_PROVIDER_HPP_INCLUDED #include #include @@ -110,3 +111,5 @@ public: }; } + +#endif // UAVCAN_PROTOCOL_NODE_STATUS_PROVIDER_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/protocol/panic_broadcaster.hpp b/libuavcan/include/uavcan/protocol/panic_broadcaster.hpp index 0fe5b9fca4..2976933919 100644 --- a/libuavcan/include/uavcan/protocol/panic_broadcaster.hpp +++ b/libuavcan/include/uavcan/protocol/panic_broadcaster.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_PROTOCOL_PANIC_BROADCASTER_HPP_INCLUDED +#define UAVCAN_PROTOCOL_PANIC_BROADCASTER_HPP_INCLUDED #include #include @@ -47,3 +48,5 @@ public: }; } + +#endif // UAVCAN_PROTOCOL_PANIC_BROADCASTER_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/protocol/panic_listener.hpp b/libuavcan/include/uavcan/protocol/panic_listener.hpp index d39f41115f..4a93252608 100644 --- a/libuavcan/include/uavcan/protocol/panic_listener.hpp +++ b/libuavcan/include/uavcan/protocol/panic_listener.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_PROTOCOL_PANIC_LISTENER_HPP_INCLUDED +#define UAVCAN_PROTOCOL_PANIC_LISTENER_HPP_INCLUDED #include #include @@ -123,3 +124,5 @@ public: }; } + +#endif // UAVCAN_PROTOCOL_PANIC_LISTENER_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/protocol/param_server.hpp b/libuavcan/include/uavcan/protocol/param_server.hpp index ad82f4f57a..f0292198a2 100644 --- a/libuavcan/include/uavcan/protocol/param_server.hpp +++ b/libuavcan/include/uavcan/protocol/param_server.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_PROTOCOL_PARAM_SERVER_HPP_INCLUDED +#define UAVCAN_PROTOCOL_PARAM_SERVER_HPP_INCLUDED #include #include @@ -105,3 +106,5 @@ public: }; } + +#endif // UAVCAN_PROTOCOL_PARAM_SERVER_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/protocol/restart_request_server.hpp b/libuavcan/include/uavcan/protocol/restart_request_server.hpp index 7964f61a77..4f9a414e13 100644 --- a/libuavcan/include/uavcan/protocol/restart_request_server.hpp +++ b/libuavcan/include/uavcan/protocol/restart_request_server.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_PROTOCOL_RESTART_REQUEST_SERVER_HPP_INCLUDED +#define UAVCAN_PROTOCOL_RESTART_REQUEST_SERVER_HPP_INCLUDED #include #include @@ -66,3 +67,5 @@ public: }; } + +#endif // UAVCAN_PROTOCOL_RESTART_REQUEST_SERVER_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/protocol/transport_stats_provider.hpp b/libuavcan/include/uavcan/protocol/transport_stats_provider.hpp index 3687e94015..173e9c4b7c 100644 --- a/libuavcan/include/uavcan/protocol/transport_stats_provider.hpp +++ b/libuavcan/include/uavcan/protocol/transport_stats_provider.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_PROTOCOL_TRANSPORT_STATS_PROVIDER_HPP_INCLUDED +#define UAVCAN_PROTOCOL_TRANSPORT_STATS_PROVIDER_HPP_INCLUDED #include #include @@ -39,3 +40,5 @@ public: }; } + +#endif // UAVCAN_PROTOCOL_TRANSPORT_STATS_PROVIDER_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/stdint.hpp b/libuavcan/include/uavcan/stdint.hpp index a3340a0b77..4fc668a2a7 100644 --- a/libuavcan/include/uavcan/stdint.hpp +++ b/libuavcan/include/uavcan/stdint.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_STDINT_HPP_INCLUDED +#define UAVCAN_STDINT_HPP_INCLUDED #include @@ -52,3 +53,5 @@ typedef ::int64_t int64_t; } #endif + +#endif // UAVCAN_STDINT_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/time.hpp b/libuavcan/include/uavcan/time.hpp index 8158c802b9..094016fb35 100644 --- a/libuavcan/include/uavcan/time.hpp +++ b/libuavcan/include/uavcan/time.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_TIME_HPP_INCLUDED +#define UAVCAN_TIME_HPP_INCLUDED #include #include @@ -286,3 +287,5 @@ Stream& operator<<(Stream& s, const TimeBase& t) } } + +#endif // UAVCAN_TIME_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/transport/abstract_transfer_buffer.hpp b/libuavcan/include/uavcan/transport/abstract_transfer_buffer.hpp index 660ae794c7..7cc703c4c2 100644 --- a/libuavcan/include/uavcan/transport/abstract_transfer_buffer.hpp +++ b/libuavcan/include/uavcan/transport/abstract_transfer_buffer.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_TRANSPORT_ABSTRACT_TRANSFER_BUFFER_HPP_INCLUDED +#define UAVCAN_TRANSPORT_ABSTRACT_TRANSFER_BUFFER_HPP_INCLUDED #include #include @@ -22,3 +23,5 @@ public: }; } + +#endif // UAVCAN_TRANSPORT_ABSTRACT_TRANSFER_BUFFER_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/transport/can_io.hpp b/libuavcan/include/uavcan/transport/can_io.hpp index 2d2e945033..cee418569d 100644 --- a/libuavcan/include/uavcan/transport/can_io.hpp +++ b/libuavcan/include/uavcan/transport/can_io.hpp @@ -3,7 +3,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_TRANSPORT_CAN_IO_HPP_INCLUDED +#define UAVCAN_TRANSPORT_CAN_IO_HPP_INCLUDED #include #include @@ -179,3 +180,5 @@ public: }; } + +#endif // UAVCAN_TRANSPORT_CAN_IO_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/transport/crc.hpp b/libuavcan/include/uavcan/transport/crc.hpp index 15b19e4e97..abee099522 100644 --- a/libuavcan/include/uavcan/transport/crc.hpp +++ b/libuavcan/include/uavcan/transport/crc.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_TRANSPORT_CRC_HPP_INCLUDED +#define UAVCAN_TRANSPORT_CRC_HPP_INCLUDED #include #include @@ -75,3 +76,5 @@ public: }; } + +#endif // UAVCAN_TRANSPORT_CRC_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/transport/dispatcher.hpp b/libuavcan/include/uavcan/transport/dispatcher.hpp index 94e70a6ef4..a34789bf36 100644 --- a/libuavcan/include/uavcan/transport/dispatcher.hpp +++ b/libuavcan/include/uavcan/transport/dispatcher.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_TRANSPORT_DISPATCHER_HPP_INCLUDED +#define UAVCAN_TRANSPORT_DISPATCHER_HPP_INCLUDED #include #include @@ -192,3 +193,5 @@ public: }; } + +#endif // UAVCAN_TRANSPORT_DISPATCHER_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/transport/frame.hpp b/libuavcan/include/uavcan/transport/frame.hpp index ce8d82cff7..49d1da2214 100644 --- a/libuavcan/include/uavcan/transport/frame.hpp +++ b/libuavcan/include/uavcan/transport/frame.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_TRANSPORT_FRAME_HPP_INCLUDED +#define UAVCAN_TRANSPORT_FRAME_HPP_INCLUDED #include #include @@ -128,3 +129,5 @@ public: }; } + +#endif // UAVCAN_TRANSPORT_FRAME_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/transport/outgoing_transfer_registry.hpp b/libuavcan/include/uavcan/transport/outgoing_transfer_registry.hpp index 72144e7647..9d91ac1955 100644 --- a/libuavcan/include/uavcan/transport/outgoing_transfer_registry.hpp +++ b/libuavcan/include/uavcan/transport/outgoing_transfer_registry.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_TRANSPORT_OUTGOING_TRANSFER_REGISTRY_HPP_INCLUDED +#define UAVCAN_TRANSPORT_OUTGOING_TRANSFER_REGISTRY_HPP_INCLUDED #include #include @@ -174,3 +175,5 @@ void OutgoingTransferRegistry::cleanup(MonotonicTime ts) } } + +#endif // UAVCAN_TRANSPORT_OUTGOING_TRANSFER_REGISTRY_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/transport/perf_counter.hpp b/libuavcan/include/uavcan/transport/perf_counter.hpp index 2e35fdc06e..009dfeec81 100644 --- a/libuavcan/include/uavcan/transport/perf_counter.hpp +++ b/libuavcan/include/uavcan/transport/perf_counter.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_TRANSPORT_PERF_COUNTER_HPP_INCLUDED +#define UAVCAN_TRANSPORT_PERF_COUNTER_HPP_INCLUDED #include #include @@ -57,3 +58,5 @@ public: #endif } + +#endif // UAVCAN_TRANSPORT_PERF_COUNTER_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/transport/transfer.hpp b/libuavcan/include/uavcan/transport/transfer.hpp index c2ca103008..d5c3f8268f 100644 --- a/libuavcan/include/uavcan/transport/transfer.hpp +++ b/libuavcan/include/uavcan/transport/transfer.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_TRANSPORT_TRANSFER_HPP_INCLUDED +#define UAVCAN_TRANSPORT_TRANSFER_HPP_INCLUDED #include #include @@ -100,3 +101,5 @@ public: }; } + +#endif // UAVCAN_TRANSPORT_TRANSFER_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/transport/transfer_buffer.hpp b/libuavcan/include/uavcan/transport/transfer_buffer.hpp index 15d337daad..d29bcce9ed 100644 --- a/libuavcan/include/uavcan/transport/transfer_buffer.hpp +++ b/libuavcan/include/uavcan/transport/transfer_buffer.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_TRANSPORT_TRANSFER_BUFFER_HPP_INCLUDED +#define UAVCAN_TRANSPORT_TRANSFER_BUFFER_HPP_INCLUDED #include #include @@ -324,3 +325,5 @@ public: }; } + +#endif // UAVCAN_TRANSPORT_TRANSFER_BUFFER_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/transport/transfer_listener.hpp b/libuavcan/include/uavcan/transport/transfer_listener.hpp index 2965415735..a8210821ce 100644 --- a/libuavcan/include/uavcan/transport/transfer_listener.hpp +++ b/libuavcan/include/uavcan/transport/transfer_listener.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_TRANSPORT_TRANSFER_LISTENER_HPP_INCLUDED +#define UAVCAN_TRANSPORT_TRANSFER_LISTENER_HPP_INCLUDED #include #include @@ -246,3 +247,5 @@ void ServiceResponseTransferListener::stopAcceptingAnything() } } + +#endif // UAVCAN_TRANSPORT_TRANSFER_LISTENER_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/transport/transfer_receiver.hpp b/libuavcan/include/uavcan/transport/transfer_receiver.hpp index 8fbb6865bd..737c9bc2db 100644 --- a/libuavcan/include/uavcan/transport/transfer_receiver.hpp +++ b/libuavcan/include/uavcan/transport/transfer_receiver.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_TRANSPORT_TRANSFER_RECEIVER_HPP_INCLUDED +#define UAVCAN_TRANSPORT_TRANSFER_RECEIVER_HPP_INCLUDED #include #include @@ -83,3 +84,5 @@ public: UAVCAN_PACKED_END } + +#endif // UAVCAN_TRANSPORT_TRANSFER_RECEIVER_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/transport/transfer_sender.hpp b/libuavcan/include/uavcan/transport/transfer_sender.hpp index 0e5ac32a3a..27ab8a1038 100644 --- a/libuavcan/include/uavcan/transport/transfer_sender.hpp +++ b/libuavcan/include/uavcan/transport/transfer_sender.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_TRANSPORT_TRANSFER_SENDER_HPP_INCLUDED +#define UAVCAN_TRANSPORT_TRANSFER_SENDER_HPP_INCLUDED #include #include @@ -75,3 +76,5 @@ public: }; } + +#endif // UAVCAN_TRANSPORT_TRANSFER_SENDER_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/uavcan.hpp b/libuavcan/include/uavcan/uavcan.hpp index cb925b139c..9a0139aeb3 100644 --- a/libuavcan/include/uavcan/uavcan.hpp +++ b/libuavcan/include/uavcan/uavcan.hpp @@ -4,7 +4,8 @@ * This header should be included by the user application. */ -#pragma once +#ifndef UAVCAN_UAVCAN_HPP_INCLUDED +#define UAVCAN_UAVCAN_HPP_INCLUDED #include #include @@ -22,3 +23,5 @@ #include #include #include + +#endif // UAVCAN_UAVCAN_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/util/bitset.hpp b/libuavcan/include/uavcan/util/bitset.hpp index 0a9c5ea43e..3ef06494bb 100644 --- a/libuavcan/include/uavcan/util/bitset.hpp +++ b/libuavcan/include/uavcan/util/bitset.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_UTIL_BITSET_HPP_INCLUDED +#define UAVCAN_UTIL_BITSET_HPP_INCLUDED #include #include @@ -184,3 +185,5 @@ Stream& operator<<(Stream& s, const BitSet& x) } } + +#endif // UAVCAN_UTIL_BITSET_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/util/comparison.hpp b/libuavcan/include/uavcan/util/comparison.hpp index d53116790d..8c8f007371 100644 --- a/libuavcan/include/uavcan/util/comparison.hpp +++ b/libuavcan/include/uavcan/util/comparison.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_UTIL_COMPARISON_HPP_INCLUDED +#define UAVCAN_UTIL_COMPARISON_HPP_INCLUDED #include #include @@ -266,3 +267,5 @@ inline bool isCloseToZero(const long double& x) } } + +#endif // UAVCAN_UTIL_COMPARISON_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/util/lazy_constructor.hpp b/libuavcan/include/uavcan/util/lazy_constructor.hpp index 3ca212d006..93152adc71 100644 --- a/libuavcan/include/uavcan/util/lazy_constructor.hpp +++ b/libuavcan/include/uavcan/util/lazy_constructor.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_UTIL_LAZY_CONSTRUCTOR_HPP_INCLUDED +#define UAVCAN_UTIL_LAZY_CONSTRUCTOR_HPP_INCLUDED #include #include @@ -173,3 +174,5 @@ public: }; } + +#endif // UAVCAN_UTIL_LAZY_CONSTRUCTOR_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/util/linked_list.hpp b/libuavcan/include/uavcan/util/linked_list.hpp index dcc91d61ed..9ca898e1fd 100644 --- a/libuavcan/include/uavcan/util/linked_list.hpp +++ b/libuavcan/include/uavcan/util/linked_list.hpp @@ -3,7 +3,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_UTIL_LINKED_LIST_HPP_INCLUDED +#define UAVCAN_UTIL_LINKED_LIST_HPP_INCLUDED #include #include @@ -170,3 +171,5 @@ void LinkedListRoot::remove(const T* node) } } + +#endif // UAVCAN_UTIL_LINKED_LIST_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/util/map.hpp b/libuavcan/include/uavcan/util/map.hpp index 1cedffb1cc..d72ca18578 100644 --- a/libuavcan/include/uavcan/util/map.hpp +++ b/libuavcan/include/uavcan/util/map.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_UTIL_MAP_HPP_INCLUDED +#define UAVCAN_UTIL_MAP_HPP_INCLUDED #include #include @@ -500,3 +501,5 @@ unsigned MapBase::getNumDynamicPairs() const } } + +#endif // UAVCAN_UTIL_MAP_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/util/method_binder.hpp b/libuavcan/include/uavcan/util/method_binder.hpp index 23fa476f87..5cf89e07f6 100644 --- a/libuavcan/include/uavcan/util/method_binder.hpp +++ b/libuavcan/include/uavcan/util/method_binder.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_UTIL_METHOD_BINDER_HPP_INCLUDED +#define UAVCAN_UTIL_METHOD_BINDER_HPP_INCLUDED #include #include @@ -79,3 +80,5 @@ public: }; } + +#endif // UAVCAN_UTIL_METHOD_BINDER_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/util/placement_new.hpp b/libuavcan/include/uavcan/util/placement_new.hpp index d05bac40c1..8c13308111 100644 --- a/libuavcan/include/uavcan/util/placement_new.hpp +++ b/libuavcan/include/uavcan/util/placement_new.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_UTIL_PLACEMENT_NEW_HPP_INCLUDED +#define UAVCAN_UTIL_PLACEMENT_NEW_HPP_INCLUDED #include #include @@ -33,3 +34,5 @@ inline void operator delete[](void*, void*) throw() { } #else # include #endif + +#endif // UAVCAN_UTIL_PLACEMENT_NEW_HPP_INCLUDED diff --git a/libuavcan/include/uavcan/util/templates.hpp b/libuavcan/include/uavcan/util/templates.hpp index 8e2db29b7e..e25102790d 100644 --- a/libuavcan/include/uavcan/util/templates.hpp +++ b/libuavcan/include/uavcan/util/templates.hpp @@ -2,7 +2,8 @@ * Copyright (C) 2014 Pavel Kirienko */ -#pragma once +#ifndef UAVCAN_UTIL_TEMPLATES_HPP_INCLUDED +#define UAVCAN_UTIL_TEMPLATES_HPP_INCLUDED #include #include @@ -485,3 +486,5 @@ inline bool getSignBit(T arg) } } + +#endif // UAVCAN_UTIL_TEMPLATES_HPP_INCLUDED From 5b8bb647271d5d69c81a30540b40ef4d84e3aa84 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Thu, 12 Mar 2015 00:54:09 +0300 Subject: [PATCH 27/35] Revert "New tool: unpragma_once.pl" This reverts commit c47f196281b0a15829bdc5cb9debc8f961e7f921. --- libuavcan/tools/unpragma_once.pl | 59 -------------------------------- 1 file changed, 59 deletions(-) delete mode 100755 libuavcan/tools/unpragma_once.pl diff --git a/libuavcan/tools/unpragma_once.pl b/libuavcan/tools/unpragma_once.pl deleted file mode 100755 index e21e759827..0000000000 --- a/libuavcan/tools/unpragma_once.pl +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env perl -############################################################################### -# Purpose: Remove all occurrences of "#pragma once" from the source tree. -# Usage: "unpragma-once *.h" or "find . -name \*.h | xargs unpragma-once" -# Author: Vadim Zeitlin -# Licence: Free Software released under BSD license -# Copyright: (C) 2011 TT-Solutions SARL -############################################################################### -# Pavel Kirienko , 2015: -# Include guard naming adapted to UAVCAN coding style. -############################################################################### - -use warnings; -use strict; -use autodie; - -use File::Copy qw(move); -use File::Spec (); -use File::Temp (); -use IO::Handle; - -sub process_single_file -{ - my $filename = shift; - - my ($volume, $dir, $basename) = File::Spec->splitpath($filename); - - open my $in, '<', $filename; - my $out = File::Temp->new(DIR => $volume . $dir); - - my $guard = ''; - my $last_was_empty = 0; - while (<$in>) { - if (/^#pragma\s+once\s+$/) { - die "Duplicate #pragma once at $filename:$.\n" if $guard; - - ($guard = uc $filename) =~ s/[\/\.]/_/g; - $guard .= "_INCLUDED"; - print $out "#ifndef $guard\n"; - print $out "#define $guard\n"; - } - else { - $last_was_empty = ($_ =~ /^\s*$/); - print $out $_ - } - } - - if ($guard) { - print $out "\n" unless $last_was_empty; - print $out "#endif // $guard\n"; - - $out->flush(); - move($out->filename, $filename); - } -} - -for (@ARGV) { - process_single_file $_ -} From c791f65ccd87a019b8ad310283202ed9b502828e Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Thu, 12 Mar 2015 01:01:07 +0300 Subject: [PATCH 28/35] UAVCAN_VERSION_NUMBER set to 1.0. Although it is not a release yet, no major changes are anticipated --- libuavcan/include/uavcan/build_config.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libuavcan/include/uavcan/build_config.hpp b/libuavcan/include/uavcan/build_config.hpp index 31c34ecf3f..fac52be812 100644 --- a/libuavcan/include/uavcan/build_config.hpp +++ b/libuavcan/include/uavcan/build_config.hpp @@ -8,8 +8,8 @@ /** * UAVCAN version definition */ -#define UAVCAN_VERSION_MAJOR 0 -#define UAVCAN_VERSION_MINOR 1 +#define UAVCAN_VERSION_MAJOR 1 +#define UAVCAN_VERSION_MINOR 0 /** * UAVCAN_CPP_VERSION - version of the C++ standard used during compilation. From 5694ea55088582c9563be07c97bc0d0201e92809 Mon Sep 17 00:00:00 2001 From: Jani Hirvinen Date: Mon, 16 Mar 2015 15:53:11 +0700 Subject: [PATCH 29/35] Adding more install instructions --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index d49680ef24..c31f2b132c 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,14 @@ Prerequisites: * CMake 2.8+ * Optional: static analysis tool for C++ - cppcheck +Installring GTest libraries: +* [GTest Install guide](http://stackoverflow.com/questions/13513905/how-to-properly-setup-googletest-on-linux) + +Install cppcheck +```bash +sudo apt-get install cppcheck +``` + Building the debug version and running the unit tests: ```bash mkdir build From e17ad9fc008a3d3dc481c3b42ba2e8ce4457af36 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Mon, 16 Mar 2015 13:10:33 +0300 Subject: [PATCH 30/35] README formatting --- README.md | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index c31f2b132c..14e62c21de 100644 --- a/README.md +++ b/README.md @@ -18,18 +18,10 @@ Despite the fact that the library itself can be used on virtually any platform t Prerequisites: -* Google test library for C++ - gtest +* Google test library for C++ - gtest (see [how to install on Debian/Ubuntu](http://stackoverflow.com/questions/13513905/how-to-properly-setup-googletest-on-linux)) * C++03 *and* C++11 capable compiler with GCC-like interface (e.g. GCC, Clang) * CMake 2.8+ -* Optional: static analysis tool for C++ - cppcheck - -Installring GTest libraries: -* [GTest Install guide](http://stackoverflow.com/questions/13513905/how-to-properly-setup-googletest-on-linux) - -Install cppcheck -```bash -sudo apt-get install cppcheck -``` +* Optional: static analysis tool for C++ - cppcheck (use Debian/Ubuntu package `cppcheck`) Building the debug version and running the unit tests: ```bash From 7ecd0a425952a2698668a0327ffcc65f870b34d1 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Mon, 16 Mar 2015 19:34:32 +0300 Subject: [PATCH 31/35] Bit array copy algorithm update - Fixed an error with 1 bit lengthed copies (see the original discussion at stackoverflow.com) --- libuavcan/src/marshal/uc_bit_array_copy.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libuavcan/src/marshal/uc_bit_array_copy.cpp b/libuavcan/src/marshal/uc_bit_array_copy.cpp index ae516b1f4c..034b752584 100644 --- a/libuavcan/src/marshal/uc_bit_array_copy.cpp +++ b/libuavcan/src/marshal/uc_bit_array_copy.cpp @@ -11,7 +11,7 @@ namespace uavcan { -static const unsigned char reverse_mask[] = { 0x55U, 0x80U, 0xC0U, 0xE0U, 0xF0U, 0xF8U, 0xFCU, 0xFEU, 0xFFU }; +static const unsigned char reverse_mask[] = { 0x00U, 0x80U, 0xC0U, 0xE0U, 0xF0U, 0xF8U, 0xFCU, 0xFEU, 0xFFU }; static const unsigned char reverse_mask_xor[] = { 0xFFU, 0x7FU, 0x3FU, 0x1FU, 0x0FU, 0x07U, 0x03U, 0x01U, 0x00U }; #if UAVCAN_TINY @@ -23,7 +23,7 @@ static const unsigned char reverse_mask_xor[] = { 0xFFU, 0x7FU, 0x3FU, 0x1FU, 0x src_len -= CHAR_BIT - dst_offset_modulo; \ } else { \ *dst &= reverse_mask[dst_offset_modulo] | \ - reverse_mask_xor[dst_offset_modulo + src_len + 1]; \ + reverse_mask_xor[dst_offset_modulo + src_len]; \ c &= reverse_mask[dst_offset_modulo + src_len]; \ src_len = 0; \ } } while (0) From 670e8bda518e4032f5a40e5b48d74ec1b42f72dd Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Mon, 16 Mar 2015 20:01:39 +0300 Subject: [PATCH 32/35] Minor API cleanup in GDTR: regist() --> registerDataType() --- .../uavcan/node/global_data_type_registry.hpp | 34 +++++++++---------- .../src/node/uc_global_data_type_registry.cpp | 24 ++++++------- .../test/node/global_data_type_registry.cpp | 31 +++++++++-------- 3 files changed, 46 insertions(+), 43 deletions(-) diff --git a/libuavcan/include/uavcan/node/global_data_type_registry.hpp b/libuavcan/include/uavcan/node/global_data_type_registry.hpp index f1b8cbf6dd..3fc788d0ce 100644 --- a/libuavcan/include/uavcan/node/global_data_type_registry.hpp +++ b/libuavcan/include/uavcan/node/global_data_type_registry.hpp @@ -70,12 +70,12 @@ public: /** * Result of data type registration */ - enum RegistResult + enum RegistrationResult { - RegistResultOk, ///< Success, data type is now registered and can be used. - RegistResultCollision, ///< Data type name or ID is not unique. - RegistResultInvalidParams, ///< Invalid input parameters. - RegistResultFrozen ///< Data Type Registery has been frozen and can't be modified anymore. + RegistrationResultOk, ///< Success, data type is now registered and can be used. + RegistrationResultCollision, ///< Data type name or ID is not unique. + RegistrationResultInvalidParams, ///< Invalid input parameters. + RegistrationResultFrozen ///< Data Type Registery has been frozen and can't be modified anymore. }; private: @@ -88,8 +88,8 @@ private: List* selectList(DataTypeKind kind) const; - RegistResult remove(Entry* dtd); - RegistResult registImpl(Entry* dtd); + RegistrationResult remove(Entry* dtd); + RegistrationResult registImpl(Entry* dtd); public: /** @@ -108,7 +108,7 @@ public: * @param id Data Type ID for this data type. */ template - RegistResult regist(DataTypeID id); + RegistrationResult registerDataType(DataTypeID id); /** * Data Type registry needs to be frozen before a node instance can use it in @@ -205,10 +205,10 @@ struct UAVCAN_EXPORT DefaultDataTypeRegistrator { DefaultDataTypeRegistrator() { - const GlobalDataTypeRegistry::RegistResult res = - GlobalDataTypeRegistry::instance().regist(Type::DefaultDataTypeID); + const GlobalDataTypeRegistry::RegistrationResult res = + GlobalDataTypeRegistry::instance().registerDataType(Type::DefaultDataTypeID); - if (res != GlobalDataTypeRegistry::RegistResultOk) + if (res != GlobalDataTypeRegistry::RegistrationResultOk) { handleFatalError("Type reg failed"); } @@ -221,24 +221,24 @@ struct UAVCAN_EXPORT DefaultDataTypeRegistrator * GlobalDataTypeRegistry */ template -GlobalDataTypeRegistry::RegistResult GlobalDataTypeRegistry::regist(DataTypeID id) +GlobalDataTypeRegistry::RegistrationResult GlobalDataTypeRegistry::registerDataType(DataTypeID id) { if (isFrozen()) { - return RegistResultFrozen; + return RegistrationResultFrozen; } static Entry entry; { - const RegistResult remove_res = remove(&entry); - if (remove_res != RegistResultOk) + const RegistrationResult remove_res = remove(&entry); + if (remove_res != RegistrationResultOk) { return remove_res; } } entry = Entry(DataTypeKind(Type::DataTypeKind), id, Type::getDataTypeSignature(), Type::getDataTypeFullName()); { - const RegistResult remove_res = remove(&entry); - if (remove_res != RegistResultOk) + const RegistrationResult remove_res = remove(&entry); + if (remove_res != RegistrationResultOk) { return remove_res; } diff --git a/libuavcan/src/node/uc_global_data_type_registry.cpp b/libuavcan/src/node/uc_global_data_type_registry.cpp index 13250d991e..20fa8b03c9 100644 --- a/libuavcan/src/node/uc_global_data_type_registry.cpp +++ b/libuavcan/src/node/uc_global_data_type_registry.cpp @@ -27,22 +27,22 @@ GlobalDataTypeRegistry::List* GlobalDataTypeRegistry::selectList(DataTypeKind ki } } -GlobalDataTypeRegistry::RegistResult GlobalDataTypeRegistry::remove(Entry* dtd) +GlobalDataTypeRegistry::RegistrationResult GlobalDataTypeRegistry::remove(Entry* dtd) { if (!dtd) { UAVCAN_ASSERT(0); - return RegistResultInvalidParams; + return RegistrationResultInvalidParams; } if (isFrozen()) { - return RegistResultFrozen; + return RegistrationResultFrozen; } List* list = selectList(dtd->descriptor.getKind()); if (!list) { - return RegistResultInvalidParams; + return RegistrationResultInvalidParams; } list->remove(dtd); // If this call came from regist<>(), that would be enough @@ -56,25 +56,25 @@ GlobalDataTypeRegistry::RegistResult GlobalDataTypeRegistry::remove(Entry* dtd) } p = next; } - return RegistResultOk; + return RegistrationResultOk; } -GlobalDataTypeRegistry::RegistResult GlobalDataTypeRegistry::registImpl(Entry* dtd) +GlobalDataTypeRegistry::RegistrationResult GlobalDataTypeRegistry::registImpl(Entry* dtd) { if (!dtd || (dtd->descriptor.getID() > DataTypeID::Max)) { UAVCAN_ASSERT(0); - return RegistResultInvalidParams; + return RegistrationResultInvalidParams; } if (isFrozen()) { - return RegistResultFrozen; + return RegistrationResultFrozen; } List* list = selectList(dtd->descriptor.getKind()); if (!list) { - return RegistResultInvalidParams; + return RegistrationResultInvalidParams; } { // Collision check @@ -83,12 +83,12 @@ GlobalDataTypeRegistry::RegistResult GlobalDataTypeRegistry::registImpl(Entry* d { if (p->descriptor.getID() == dtd->descriptor.getID()) // ID collision { - return RegistResultCollision; + return RegistrationResultCollision; } if (!std::strncmp(p->descriptor.getFullName(), dtd->descriptor.getFullName(), DataTypeDescriptor::MaxFullNameLen)) // Name collision { - return RegistResultCollision; + return RegistrationResultCollision; } p = p->getNextListNode(); } @@ -122,7 +122,7 @@ GlobalDataTypeRegistry::RegistResult GlobalDataTypeRegistry::registImpl(Entry* d } } #endif - return RegistResultOk; + return RegistrationResultOk; } GlobalDataTypeRegistry& GlobalDataTypeRegistry::instance() diff --git a/libuavcan/test/node/global_data_type_registry.cpp b/libuavcan/test/node/global_data_type_registry.cpp index 9e8db32e6a..63dc87e5f3 100644 --- a/libuavcan/test/node/global_data_type_registry.cpp +++ b/libuavcan/test/node/global_data_type_registry.cpp @@ -95,8 +95,9 @@ TEST(GlobalDataTypeRegistry, Basic) /* * Runtime registrations */ - ASSERT_EQ(GlobalDataTypeRegistry::RegistResultOk, - GlobalDataTypeRegistry::instance().regist(DataTypeAService::DefaultDataTypeID)); + ASSERT_EQ(GlobalDataTypeRegistry::RegistrationResultOk, + GlobalDataTypeRegistry::instance().registerDataType( + DataTypeAService::DefaultDataTypeID)); ASSERT_EQ(2, GlobalDataTypeRegistry::instance().getNumMessageTypes()); ASSERT_EQ(1, GlobalDataTypeRegistry::instance().getNumServiceTypes()); @@ -109,8 +110,10 @@ TEST(GlobalDataTypeRegistry, Basic) /* * Runtime re-registration */ - ASSERT_EQ(GlobalDataTypeRegistry::RegistResultOk, GlobalDataTypeRegistry::instance().regist(147)); - ASSERT_EQ(GlobalDataTypeRegistry::RegistResultOk, GlobalDataTypeRegistry::instance().regist(741)); + ASSERT_EQ(GlobalDataTypeRegistry::RegistrationResultOk, + GlobalDataTypeRegistry::instance().registerDataType(147)); + ASSERT_EQ(GlobalDataTypeRegistry::RegistrationResultOk, + GlobalDataTypeRegistry::instance().registerDataType(741)); ASSERT_EQ(2, GlobalDataTypeRegistry::instance().getNumMessageTypes()); ASSERT_EQ(1, GlobalDataTypeRegistry::instance().getNumServiceTypes()); @@ -129,11 +132,11 @@ TEST(GlobalDataTypeRegistry, Basic) /* * These types will be necessary for the aggregate signature test */ - ASSERT_EQ(GlobalDataTypeRegistry::RegistResultCollision, - GlobalDataTypeRegistry::instance().regist(741)); // ID COLLISION + ASSERT_EQ(GlobalDataTypeRegistry::RegistrationResultCollision, + GlobalDataTypeRegistry::instance().registerDataType(741)); // ID COLLISION - ASSERT_EQ(GlobalDataTypeRegistry::RegistResultOk, - GlobalDataTypeRegistry::instance().regist(DataTypeC::DefaultDataTypeID)); + ASSERT_EQ(GlobalDataTypeRegistry::RegistrationResultOk, + GlobalDataTypeRegistry::instance().registerDataType(DataTypeC::DefaultDataTypeID)); uavcan::DefaultDataTypeRegistrator reg_DataTypeD; GlobalDataTypeRegistry::instance().getDataTypeIDMask(uavcan::DataTypeKindMessage, dtmask); @@ -154,14 +157,14 @@ TEST(GlobalDataTypeRegistry, Basic) */ GlobalDataTypeRegistry::instance().freeze(); - ASSERT_EQ(GlobalDataTypeRegistry::RegistResultFrozen, - GlobalDataTypeRegistry::instance().regist(555)); // Rejected + ASSERT_EQ(GlobalDataTypeRegistry::RegistrationResultFrozen, + GlobalDataTypeRegistry::instance().registerDataType(555)); // Rejected - ASSERT_EQ(GlobalDataTypeRegistry::RegistResultFrozen, - GlobalDataTypeRegistry::instance().regist(999)); // Rejected + ASSERT_EQ(GlobalDataTypeRegistry::RegistrationResultFrozen, + GlobalDataTypeRegistry::instance().registerDataType(999)); // Rejected - ASSERT_EQ(GlobalDataTypeRegistry::RegistResultFrozen, - GlobalDataTypeRegistry::instance().regist(888)); // Rejected + ASSERT_EQ(GlobalDataTypeRegistry::RegistrationResultFrozen, + GlobalDataTypeRegistry::instance().registerDataType(888)); // Rejected /* * Searching From 14c176015a797bbb14c048d9e1cf537932ffecd3 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Mon, 16 Mar 2015 20:18:36 +0300 Subject: [PATCH 33/35] GDTR find() overload for name only --- .../include/uavcan/node/global_data_type_registry.hpp | 9 +++++++++ libuavcan/src/node/uc_global_data_type_registry.cpp | 10 ++++++++++ libuavcan/test/node/global_data_type_registry.cpp | 3 +++ 3 files changed, 22 insertions(+) diff --git a/libuavcan/include/uavcan/node/global_data_type_registry.hpp b/libuavcan/include/uavcan/node/global_data_type_registry.hpp index 3fc788d0ce..7e27d92886 100644 --- a/libuavcan/include/uavcan/node/global_data_type_registry.hpp +++ b/libuavcan/include/uavcan/node/global_data_type_registry.hpp @@ -126,6 +126,15 @@ public: /** * Finds data type descriptor by full data type name, e.g. "uavcan.protocol.NodeStatus". + * Messages are searched first, then services. + * Returns null pointer if the data type with this name is not registered. + * @param name Full data type name + * @return Descriptor for this data type or null pointer if not found + */ + const DataTypeDescriptor* find(const char* name) const; + + /** + * Finds data type descriptor by full data type name, e.g. "uavcan.protocol.NodeStatus", and data type kind. * Returns null pointer if the data type with this name is not registered. * @param kind Data Type Kind - message or service * @param name Full data type name diff --git a/libuavcan/src/node/uc_global_data_type_registry.cpp b/libuavcan/src/node/uc_global_data_type_registry.cpp index 20fa8b03c9..aa96308d0d 100644 --- a/libuavcan/src/node/uc_global_data_type_registry.cpp +++ b/libuavcan/src/node/uc_global_data_type_registry.cpp @@ -141,6 +141,16 @@ void GlobalDataTypeRegistry::freeze() } } +const DataTypeDescriptor* GlobalDataTypeRegistry::find(const char* name) const +{ + const DataTypeDescriptor* desc = find(DataTypeKindMessage, name); + if (desc == NULL) + { + desc = find(DataTypeKindService, name); + } + return desc; +} + const DataTypeDescriptor* GlobalDataTypeRegistry::find(DataTypeKind kind, const char* name) const { if (!name) diff --git a/libuavcan/test/node/global_data_type_registry.cpp b/libuavcan/test/node/global_data_type_registry.cpp index 63dc87e5f3..7edf41d2b2 100644 --- a/libuavcan/test/node/global_data_type_registry.cpp +++ b/libuavcan/test/node/global_data_type_registry.cpp @@ -171,6 +171,7 @@ TEST(GlobalDataTypeRegistry, Basic) */ const uavcan::DataTypeDescriptor* pdtd = NULL; ASSERT_FALSE(GlobalDataTypeRegistry::instance().find(uavcan::DataTypeKindMessage, "Nonexistent")); + ASSERT_FALSE(GlobalDataTypeRegistry::instance().find("Nonexistent")); ASSERT_FALSE(GlobalDataTypeRegistry::instance().find(uavcan::DataTypeKindMessage, 987)); // Asking for service, but this is a message: ASSERT_FALSE(GlobalDataTypeRegistry::instance().find(uavcan::DataTypeKindService, "my_namespace.DataTypeB")); @@ -178,12 +179,14 @@ TEST(GlobalDataTypeRegistry, Basic) ASSERT_TRUE((pdtd = GlobalDataTypeRegistry::instance().find(uavcan::DataTypeKindMessage, "my_namespace.DataTypeB"))); + ASSERT_TRUE((pdtd = GlobalDataTypeRegistry::instance().find("my_namespace.DataTypeB"))); ASSERT_EQ(extractDescriptor(741), *pdtd); ASSERT_TRUE((pdtd = GlobalDataTypeRegistry::instance().find(uavcan::DataTypeKindMessage, 741))); ASSERT_EQ(extractDescriptor(741), *pdtd); ASSERT_TRUE((pdtd = GlobalDataTypeRegistry::instance().find(uavcan::DataTypeKindMessage, "my_namespace.DataTypeA"))); + ASSERT_TRUE((pdtd = GlobalDataTypeRegistry::instance().find("my_namespace.DataTypeA"))); ASSERT_EQ(extractDescriptor(), *pdtd); ASSERT_TRUE((pdtd = GlobalDataTypeRegistry::instance().find(uavcan::DataTypeKindMessage, uavcan::DataTypeID(0)))); ASSERT_EQ(extractDescriptor(), *pdtd); From f2cfed70cb4b3b24f58e15fefc2e21c553aac271 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Mon, 16 Mar 2015 23:35:37 +0300 Subject: [PATCH 34/35] GetDataTypeInfo now can be requested either by dtid/id, or by name --- .../protocol/552.GetDataTypeInfo.uavcan | 18 ++++-- dsdl/uavcan/protocol/DataTypeKind.uavcan | 6 +- .../protocol/uc_data_type_info_provider.cpp | 56 +++++++++++++----- .../test/protocol/data_type_info_provider.cpp | 59 ++++++++++++++++++- 4 files changed, 114 insertions(+), 25 deletions(-) diff --git a/dsdl/uavcan/protocol/552.GetDataTypeInfo.uavcan b/dsdl/uavcan/protocol/552.GetDataTypeInfo.uavcan index 8392045c26..c744ad707a 100644 --- a/dsdl/uavcan/protocol/552.GetDataTypeInfo.uavcan +++ b/dsdl/uavcan/protocol/552.GetDataTypeInfo.uavcan @@ -1,13 +1,23 @@ # # Get the implementation details of a given data type. # +# Request is interpreted as follows: +# - If the field 'name' is empty, the fields 'kind' and 'id' will be used to identify the data type. +# - If the field 'name' is non-empty, it will be used to identify the data type; the +# fields 'kind' and 'id' will be ignored. +# -uint16 id -DataTypeKind kind +uint16 id # Ignored if 'name' is non-empty +DataTypeKind kind # Ignored if 'name' is non-empty + +uint8[<=80] name # Full data type name, e.g. "uavcan.protocol.GetDataTypeInfo" --- -uint64 signature # Data type signature +uint64 signature # Data type signature; valid only if the data type is known (see MASK_KNOWN) + +uint16 id # Valid only if the data type is known (see MASK_KNOWN) +DataTypeKind kind # Ditto uint8 MASK_KNOWN = 1 # This data type is defined uint8 MASK_SUBSCRIBED = 2 # Subscribed to messages of this type @@ -15,4 +25,4 @@ uint8 MASK_PUBLISHING = 4 # Publishing messages of this type uint8 MASK_SERVING = 8 # Providing service of this type uint8 mask -uint8[<=80] name # Full data type name, e.g. "uavcan.protocol.GetDataTypeInfo" +uint8[<=80] name # Full data type name; valid only if the data type is known (see MASK_KNOWN) diff --git a/dsdl/uavcan/protocol/DataTypeKind.uavcan b/dsdl/uavcan/protocol/DataTypeKind.uavcan index 925a575e0c..58dd68b056 100644 --- a/dsdl/uavcan/protocol/DataTypeKind.uavcan +++ b/dsdl/uavcan/protocol/DataTypeKind.uavcan @@ -2,6 +2,6 @@ # Data type kind (message or service). # -uint2 SERVICE = 0 -uint2 MESSAGE = 1 -uint2 value +uint8 SERVICE = 0 +uint8 MESSAGE = 1 +uint8 value diff --git a/libuavcan/src/protocol/uc_data_type_info_provider.cpp b/libuavcan/src/protocol/uc_data_type_info_provider.cpp index 38a0a023b5..c736d06842 100644 --- a/libuavcan/src/protocol/uc_data_type_info_provider.cpp +++ b/libuavcan/src/protocol/uc_data_type_info_provider.cpp @@ -35,43 +35,67 @@ void DataTypeInfoProvider::handleComputeAggregateTypeSignatureRequest( void DataTypeInfoProvider::handleGetDataTypeInfoRequest(const protocol::GetDataTypeInfo::Request& request, protocol::GetDataTypeInfo::Response& response) { - const DataTypeKind kind = DataTypeKind(request.kind.value); - if (!isValidDataTypeKind(kind)) + /* + * Asking the Global Data Type Registry for the matching type descriptor, either by name or by ID + */ + const DataTypeDescriptor* desc = NULL; + + if (request.name.empty()) { - UAVCAN_TRACE("DataTypeInfoProvider", "GetDataTypeInfo request with invalid DataTypeKind %i", kind); - return; + response.id = request.id; // Pre-setting the fields so they have meaningful values even in + response.kind = request.kind; // ...case of failure. + + if (!isValidDataTypeKind(DataTypeKind(request.kind.value))) + { + UAVCAN_TRACE("DataTypeInfoProvider", "GetDataTypeInfo request with invalid DataTypeKind %i", + static_cast(request.kind.value)); + return; + } + + desc = GlobalDataTypeRegistry::instance().find(DataTypeKind(request.kind.value), request.id); + } + else + { + response.name = request.name; + + desc = GlobalDataTypeRegistry::instance().find(request.name.c_str()); } - const DataTypeDescriptor* const desc = GlobalDataTypeRegistry::instance().find(kind, request.id); - if (!desc) + if (desc == NULL) { - UAVCAN_TRACE("DataTypeInfoProvider", "Cannot process GetDataTypeInfo for nonexistent type dtid=%i dtk=%i", - int(request.id), int(request.kind.value)); + UAVCAN_TRACE("DataTypeInfoProvider", + "Cannot process GetDataTypeInfo for nonexistent type: dtid=%i dtk=%i name='%s'", + static_cast(request.id), static_cast(request.kind.value), request.name.c_str()); return; } UAVCAN_TRACE("DataTypeInfoProvider", "GetDataTypeInfo request for %s", desc->toString().c_str()); - response.signature = desc->getSignature().get(); - response.name = desc->getFullName(); - response.mask = protocol::GetDataTypeInfo::Response::MASK_KNOWN; + /* + * Filling the response struct + */ + response.signature = desc->getSignature().get(); + response.id = desc->getID().get(); + response.kind.value = desc->getKind(); + response.mask = protocol::GetDataTypeInfo::Response::MASK_KNOWN; + response.name = desc->getFullName(); const Dispatcher& dispatcher = getNode().getDispatcher(); - if (request.kind.value == protocol::DataTypeKind::SERVICE) + if (desc->getKind() == DataTypeKindService) { - if (dispatcher.hasServer(request.id)) + if (dispatcher.hasServer(desc->getID().get())) { response.mask |= protocol::GetDataTypeInfo::Response::MASK_SERVING; } } - else if (request.kind.value == protocol::DataTypeKind::MESSAGE) + else if (desc->getKind() == DataTypeKindMessage) { - if (dispatcher.hasSubscriber(request.id)) + if (dispatcher.hasSubscriber(desc->getID().get())) { response.mask |= protocol::GetDataTypeInfo::Response::MASK_SUBSCRIBED; } - if (dispatcher.hasPublisher(request.id)) + if (dispatcher.hasPublisher(desc->getID().get())) { response.mask |= protocol::GetDataTypeInfo::Response::MASK_PUBLISHING; } diff --git a/libuavcan/test/protocol/data_type_info_provider.cpp b/libuavcan/test/protocol/data_type_info_provider.cpp index 046d6074fa..add46c17ac 100644 --- a/libuavcan/test/protocol/data_type_info_provider.cpp +++ b/libuavcan/test/protocol/data_type_info_provider.cpp @@ -23,22 +23,39 @@ static bool validateDataTypeInfoResponse(const std::auto_ptrisSuccessful()) { + std::cout << "Request was not successful" << std::endl; return false; } if (resp->response.name != DataType::getDataTypeFullName()) { + std::cout << "Type name mismatch: '" + << resp->response.name.c_str() << "' '" + << DataType::getDataTypeFullName() << "'" << std::endl; return false; } if (DataType::getDataTypeSignature().get() != resp->response.signature) { + std::cout << "Signature mismatch" << std::endl; return false; } if (resp->response.mask != mask) { + std::cout << "Mask mismatch" << std::endl; + return false; + } + if (resp->response.kind.value != DataType::DataTypeKind) + { + std::cout << "Kind mismatch" << std::endl; + return false; + } + if (resp->response.id != DataType::DefaultDataTypeID) + { + std::cout << "DTID mismatch" << std::endl; return false; } return true; @@ -75,9 +92,25 @@ TEST(DataTypeInfoProvider, Basic) GetDataTypeInfo::Response::MASK_SERVING)); ASSERT_EQ(1, gdti_cln.collector.result->server_node_id.get()); + /* + * GetDataTypeInfo request for GetDataTypeInfo by name + */ + gdti_request = GetDataTypeInfo::Request(); + gdti_request.id = 999; // Intentionally wrong + gdti_request.kind.value = DataTypeKind::MESSAGE; // Intentionally wrong + gdti_request.name = "uavcan.protocol.GetDataTypeInfo"; + ASSERT_LE(0, gdti_cln.call(1, gdti_request)); + nodes.spinBoth(MonotonicDuration::fromMSec(10)); + + ASSERT_TRUE(validateDataTypeInfoResponse(gdti_cln.collector.result, + GetDataTypeInfo::Response::MASK_KNOWN | + GetDataTypeInfo::Response::MASK_SERVING)); + ASSERT_EQ(1, gdti_cln.collector.result->server_node_id.get()); + /* * GetDataTypeInfo request for NodeStatus - not used yet */ + gdti_request = GetDataTypeInfo::Request(); gdti_request.id = NodeStatus::DefaultDataTypeID; gdti_request.kind.value = DataTypeKind::MESSAGE; ASSERT_LE(0, gdti_cln.call(1, gdti_request)); @@ -107,15 +140,37 @@ TEST(DataTypeInfoProvider, Basic) /* * Requesting a non-existent type */ + gdti_request = GetDataTypeInfo::Request(); gdti_request.id = ComputeAggregateTypeSignature::DefaultDataTypeID; - gdti_request.kind.value = 0xFF; // INVALID VALUE + gdti_request.kind.value = 3; // INVALID VALUE ASSERT_LE(0, gdti_cln.call(1, gdti_request)); nodes.spinBoth(MonotonicDuration::fromMSec(10)); ASSERT_TRUE(gdti_cln.collector.result.get()); ASSERT_TRUE(gdti_cln.collector.result->isSuccessful()); ASSERT_EQ(1, gdti_cln.collector.result->server_node_id.get()); - ASSERT_TRUE(gdti_cln.collector.result->response == GetDataTypeInfo::Response()); // Empty response + ASSERT_EQ(0, gdti_cln.collector.result->response.mask); + ASSERT_TRUE(gdti_cln.collector.result->response.name.empty()); // Empty name + ASSERT_EQ(gdti_request.id, gdti_cln.collector.result->response.id); + ASSERT_EQ(gdti_request.kind.value, gdti_cln.collector.result->response.kind.value); + + /* + * Requesting a non-existent type by name + */ + gdti_request = GetDataTypeInfo::Request(); + gdti_request.id = 999; // Intentionally wrong + gdti_request.kind.value = 3; // Intentionally wrong + gdti_request.name = "uavcan.equipment.gnss.Fix"; + ASSERT_LE(0, gdti_cln.call(1, gdti_request)); + nodes.spinBoth(MonotonicDuration::fromMSec(10)); + + ASSERT_TRUE(gdti_cln.collector.result.get()); + ASSERT_TRUE(gdti_cln.collector.result->isSuccessful()); + ASSERT_EQ(1, gdti_cln.collector.result->server_node_id.get()); + ASSERT_EQ(0, gdti_cln.collector.result->response.mask); + ASSERT_EQ("uavcan.equipment.gnss.Fix", gdti_cln.collector.result->response.name); + ASSERT_EQ(0, gdti_cln.collector.result->response.id); + ASSERT_EQ(0, gdti_cln.collector.result->response.kind.value); /* * ComputeAggregateTypeSignature test From 2d7e20b88510bce0532a36dfdd3d191b130297fd Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Mon, 16 Mar 2015 23:43:42 +0300 Subject: [PATCH 35/35] Improved doc for PanicBroadcaster --- libuavcan/include/uavcan/protocol/panic_broadcaster.hpp | 6 ++++-- libuavcan/src/protocol/uc_panic_broadcaster.cpp | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libuavcan/include/uavcan/protocol/panic_broadcaster.hpp b/libuavcan/include/uavcan/protocol/panic_broadcaster.hpp index 2976933919..c05a55fe2e 100644 --- a/libuavcan/include/uavcan/protocol/panic_broadcaster.hpp +++ b/libuavcan/include/uavcan/protocol/panic_broadcaster.hpp @@ -32,10 +32,12 @@ public: } /** - * Begin broadcasting at the standard interval. + * Begin broadcasting at the standard interval (see BROADCASTING_INTERVAL_MS). * This method does not block and can't fail. + * @param short_reason Short ASCII string that describes the reason of the panic, 7 characters max. + * If the string exceeds 7 characters, it will be truncated. */ - void panic(const char* short_reason); + void panic(const char* short_reason_description); /** * Stop broadcasting immediately. diff --git a/libuavcan/src/protocol/uc_panic_broadcaster.cpp b/libuavcan/src/protocol/uc_panic_broadcaster.cpp index 059e288320..8c73929586 100644 --- a/libuavcan/src/protocol/uc_panic_broadcaster.cpp +++ b/libuavcan/src/protocol/uc_panic_broadcaster.cpp @@ -22,10 +22,10 @@ void PanicBroadcaster::handleTimerEvent(const TimerEvent&) publishOnce(); } -void PanicBroadcaster::panic(const char* short_reason) +void PanicBroadcaster::panic(const char* short_reason_description) { msg_.reason_text.clear(); - const char* p = short_reason; + const char* p = short_reason_description; while (p && *p) { if (msg_.reason_text.size() == msg_.reason_text.capacity())