Merge branch 'master' into dsdl_review

This commit is contained in:
Pavel Kirienko
2015-03-16 23:52:27 +03:00
88 changed files with 667 additions and 240 deletions
+22 -3
View File
@@ -2,13 +2,14 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_BUILD_CONFIG_HPP_INCLUDED
#define UAVCAN_BUILD_CONFIG_HPP_INCLUDED
/**
* 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.
@@ -58,6 +59,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.
@@ -196,3 +213,5 @@ static const unsigned FloatComparisonEpsilonMult = 10;
#endif
}
#endif // UAVCAN_BUILD_CONFIG_HPP_INCLUDED
+4 -1
View File
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_DATA_TYPE_HPP_INCLUDED
#define UAVCAN_DATA_TYPE_HPP_INCLUDED
#include <cassert>
#include <cstring>
@@ -144,3 +145,5 @@ public:
};
}
#endif // UAVCAN_DATA_TYPE_HPP_INCLUDED
+4 -1
View File
@@ -3,7 +3,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_DEBUG_HPP_INCLUDED
#define UAVCAN_DEBUG_HPP_INCLUDED
#include <uavcan/build_config.hpp>
@@ -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
+4 -1
View File
@@ -3,7 +3,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_DRIVER_CAN_HPP_INCLUDED
#define UAVCAN_DRIVER_CAN_HPP_INCLUDED
#include <cassert>
#include <uavcan/stdint.hpp>
@@ -187,3 +188,5 @@ public:
};
}
#endif // UAVCAN_DRIVER_CAN_HPP_INCLUDED
@@ -3,7 +3,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_DRIVER_SYSTEM_CLOCK_HPP_INCLUDED
#define UAVCAN_DRIVER_SYSTEM_CLOCK_HPP_INCLUDED
#include <uavcan/stdint.hpp>
#include <uavcan/build_config.hpp>
@@ -44,3 +45,5 @@ public:
};
}
#endif // UAVCAN_DRIVER_SYSTEM_CLOCK_HPP_INCLUDED
+4 -1
View File
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_DYNAMIC_MEMORY_HPP_INCLUDED
#define UAVCAN_DYNAMIC_MEMORY_HPP_INCLUDED
#include <cassert>
#include <cstdlib>
@@ -297,3 +298,5 @@ unsigned PoolAllocator<PoolSize, BlockSize>::getNumFreeBlocks() const
}
}
#endif // UAVCAN_DYNAMIC_MEMORY_HPP_INCLUDED
+4 -1
View File
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_ERROR_HPP_INCLUDED
#define UAVCAN_ERROR_HPP_INCLUDED
#include <uavcan/build_config.hpp>
#include <uavcan/stdint.hpp>
@@ -53,3 +54,5 @@ UAVCAN_EXPORT
void handleFatalError(const char* msg);
}
#endif // UAVCAN_ERROR_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_HELPERS_COMPONENT_STATUS_MANAGER_HPP_INCLUDED
#define UAVCAN_HELPERS_COMPONENT_STATUS_MANAGER_HPP_INCLUDED
#include <uavcan/build_config.hpp>
#include <uavcan/stdint.hpp>
@@ -68,3 +69,5 @@ template <unsigned NumComponents_>
const unsigned ComponentStatusManager<NumComponents_>::NumComponents;
}
#endif // UAVCAN_HELPERS_COMPONENT_STATUS_MANAGER_HPP_INCLUDED
+4 -1
View File
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_HELPERS_OSTREAM_HPP_INCLUDED
#define UAVCAN_HELPERS_OSTREAM_HPP_INCLUDED
#include <uavcan/util/templates.hpp>
#include <cstdio>
@@ -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
+4 -1
View File
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_MARSHAL_ARRAY_HPP_INCLUDED
#define UAVCAN_MARSHAL_ARRAY_HPP_INCLUDED
#include <cassert>
#include <cstdio>
@@ -1034,3 +1035,5 @@ public:
};
}
#endif // UAVCAN_MARSHAL_ARRAY_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_MARSHAL_BIT_STREAM_HPP_INCLUDED
#define UAVCAN_MARSHAL_BIT_STREAM_HPP_INCLUDED
#include <cassert>
#include <uavcan/stdint.hpp>
@@ -116,3 +117,5 @@ public:
};
}
#endif // UAVCAN_MARSHAL_BIT_STREAM_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_MARSHAL_CHAR_ARRAY_FORMATTER_HPP_INCLUDED
#define UAVCAN_MARSHAL_CHAR_ARRAY_FORMATTER_HPP_INCLUDED
#include <uavcan/build_config.hpp>
#include <uavcan/marshal/array.hpp>
@@ -137,3 +138,5 @@ public:
#endif
}
#endif // UAVCAN_MARSHAL_CHAR_ARRAY_FORMATTER_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_MARSHAL_FLOAT_SPEC_HPP_INCLUDED
#define UAVCAN_MARSHAL_FLOAT_SPEC_HPP_INCLUDED
#include <cmath>
#include <uavcan/stdint.hpp>
@@ -222,3 +223,5 @@ public:
};
}
#endif // UAVCAN_MARSHAL_FLOAT_SPEC_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_MARSHAL_INTEGER_SPEC_HPP_INCLUDED
#define UAVCAN_MARSHAL_INTEGER_SPEC_HPP_INCLUDED
#include <uavcan/stdint.hpp>
#include <uavcan/data_type.hpp>
@@ -164,3 +165,5 @@ public:
};
}
#endif // UAVCAN_MARSHAL_INTEGER_SPEC_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_MARSHAL_SCALAR_CODEC_HPP_INCLUDED
#define UAVCAN_MARSHAL_SCALAR_CODEC_HPP_INCLUDED
#include <cassert>
#include <uavcan/stdint.hpp>
@@ -135,3 +136,5 @@ int ScalarCodec::decode(T& value)
}
}
#endif // UAVCAN_MARSHAL_SCALAR_CODEC_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_MARSHAL_TYPE_UTIL_HPP_INCLUDED
#define UAVCAN_MARSHAL_TYPE_UTIL_HPP_INCLUDED
#include <uavcan/build_config.hpp>
#include <uavcan/util/templates.hpp>
@@ -83,3 +84,5 @@ template <typename T>
class UAVCAN_EXPORT YamlStreamer;
}
#endif // UAVCAN_MARSHAL_TYPE_UTIL_HPP_INCLUDED
+4 -1
View File
@@ -2,9 +2,12 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_MARSHAL_TYPES_HPP_INCLUDED
#define UAVCAN_MARSHAL_TYPES_HPP_INCLUDED
#include <uavcan/marshal/integer_spec.hpp>
#include <uavcan/marshal/float_spec.hpp>
#include <uavcan/marshal/array.hpp>
#include <uavcan/marshal/type_util.hpp>
#endif // UAVCAN_MARSHAL_TYPES_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_NODE_ABSTRACT_NODE_HPP_INCLUDED
#define UAVCAN_NODE_ABSTRACT_NODE_HPP_INCLUDED
#include <uavcan/build_config.hpp>
#include <uavcan/node/scheduler.hpp>
@@ -78,3 +79,5 @@ public:
};
}
#endif // UAVCAN_NODE_ABSTRACT_NODE_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_NODE_GENERIC_PUBLISHER_HPP_INCLUDED
#define UAVCAN_NODE_GENERIC_PUBLISHER_HPP_INCLUDED
#include <uavcan/error.hpp>
#include <uavcan/node/abstract_node.hpp>
@@ -172,3 +173,5 @@ int GenericPublisher<DataSpec, DataStruct>::genericPublish(const DataStruct& mes
}
}
#endif // UAVCAN_NODE_GENERIC_PUBLISHER_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_NODE_GENERIC_SUBSCRIBER_HPP_INCLUDED
#define UAVCAN_NODE_GENERIC_SUBSCRIBER_HPP_INCLUDED
#include <uavcan/error.hpp>
#include <uavcan/node/abstract_node.hpp>
@@ -207,10 +208,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<DataStruct>& getReceivedStructStorage() { return message_; }
ReceivedDataStructure<DataStruct>& getReceivedStructStorage() { return message_; }
const ReceivedDataStructure<DataStruct>& getReceivedStructStorage() const { return message_; }
};
// ----------------------------------------------------------------------------
@@ -284,3 +288,5 @@ genericStart(bool (Dispatcher::*registration_method)(TransferListenerBase*))
}
#endif // UAVCAN_NODE_GENERIC_SUBSCRIBER_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_NODE_GLOBAL_DATA_TYPE_REGISTRY_HPP_INCLUDED
#define UAVCAN_NODE_GLOBAL_DATA_TYPE_REGISTRY_HPP_INCLUDED
#include <cassert>
#include <uavcan/error.hpp>
@@ -69,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:
@@ -87,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:
/**
@@ -107,7 +108,7 @@ public:
* @param id Data Type ID for this data type.
*/
template <typename Type>
RegistResult regist(DataTypeID id);
RegistrationResult registerDataType(DataTypeID id);
/**
* Data Type registry needs to be frozen before a node instance can use it in
@@ -125,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
@@ -204,10 +214,10 @@ struct UAVCAN_EXPORT DefaultDataTypeRegistrator
{
DefaultDataTypeRegistrator()
{
const GlobalDataTypeRegistry::RegistResult res =
GlobalDataTypeRegistry::instance().regist<Type>(Type::DefaultDataTypeID);
const GlobalDataTypeRegistry::RegistrationResult res =
GlobalDataTypeRegistry::instance().registerDataType<Type>(Type::DefaultDataTypeID);
if (res != GlobalDataTypeRegistry::RegistResultOk)
if (res != GlobalDataTypeRegistry::RegistrationResultOk)
{
handleFatalError("Type reg failed");
}
@@ -220,24 +230,24 @@ struct UAVCAN_EXPORT DefaultDataTypeRegistrator
* GlobalDataTypeRegistry
*/
template <typename Type>
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;
}
@@ -246,3 +256,5 @@ GlobalDataTypeRegistry::RegistResult GlobalDataTypeRegistry::regist(DataTypeID i
}
}
#endif // UAVCAN_NODE_GLOBAL_DATA_TYPE_REGISTRY_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_NODE_MARSHAL_BUFFER_HPP_INCLUDED
#define UAVCAN_NODE_MARSHAL_BUFFER_HPP_INCLUDED
#include <uavcan/build_config.hpp>
#include <uavcan/transport/transfer.hpp>
@@ -87,3 +88,5 @@ public:
};
}
#endif // UAVCAN_NODE_MARSHAL_BUFFER_HPP_INCLUDED
+4 -1
View File
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_NODE_NODE_HPP_INCLUDED
#define UAVCAN_NODE_NODE_HPP_INCLUDED
#include <cassert>
#include <uavcan/error.hpp>
@@ -322,3 +323,5 @@ checkNetworkCompatibility(NetworkCompatibilityCheckResult& result)
#endif
}
#endif // UAVCAN_NODE_NODE_HPP_INCLUDED
+4 -1
View File
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_NODE_PUBLISHER_HPP_INCLUDED
#define UAVCAN_NODE_PUBLISHER_HPP_INCLUDED
#include <uavcan/node/generic_publisher.hpp>
@@ -95,3 +96,5 @@ public:
};
}
#endif // UAVCAN_NODE_PUBLISHER_HPP_INCLUDED
+4 -1
View File
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_NODE_SCHEDULER_HPP_INCLUDED
#define UAVCAN_NODE_SCHEDULER_HPP_INCLUDED
#include <uavcan/error.hpp>
#include <uavcan/util/linked_list.hpp>
@@ -130,3 +131,5 @@ public:
};
}
#endif // UAVCAN_NODE_SCHEDULER_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_NODE_SERVICE_CLIENT_HPP_INCLUDED
#define UAVCAN_NODE_SERVICE_CLIENT_HPP_INCLUDED
#include <uavcan/build_config.hpp>
#include <uavcan/node/generic_publisher.hpp>
@@ -368,3 +369,5 @@ void ServiceClient<DataType_, Callback_>::cancel()
}
}
#endif // UAVCAN_NODE_SERVICE_CLIENT_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_NODE_SERVICE_SERVER_HPP_INCLUDED
#define UAVCAN_NODE_SERVICE_SERVER_HPP_INCLUDED
#include <uavcan/build_config.hpp>
#include <uavcan/node/generic_publisher.hpp>
@@ -157,3 +158,5 @@ public:
};
}
#endif // UAVCAN_NODE_SERVICE_SERVER_HPP_INCLUDED
+4 -1
View File
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_NODE_SUBSCRIBER_HPP_INCLUDED
#define UAVCAN_NODE_SUBSCRIBER_HPP_INCLUDED
#include <cassert>
#include <uavcan/build_config.hpp>
@@ -115,3 +116,5 @@ public:
};
}
#endif // UAVCAN_NODE_SUBSCRIBER_HPP_INCLUDED
+4 -1
View File
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_NODE_TIMER_HPP_INCLUDED
#define UAVCAN_NODE_TIMER_HPP_INCLUDED
#include <uavcan/stdint.hpp>
#include <uavcan/error.hpp>
@@ -143,3 +144,5 @@ typedef TimerEventForwarder<std::function<void (const TimerEvent& event)> > Time
#endif
}
#endif // UAVCAN_NODE_TIMER_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_PROTOCOL_DATA_TYPE_INFO_PROVIDER_HPP_INCLUDED
#define UAVCAN_PROTOCOL_DATA_TYPE_INFO_PROVIDER_HPP_INCLUDED
#include <uavcan/node/service_server.hpp>
#include <uavcan/util/method_binder.hpp>
@@ -51,3 +52,5 @@ public:
};
}
#endif // UAVCAN_PROTOCOL_DATA_TYPE_INFO_PROVIDER_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_PROTOCOL_GLOBAL_TIME_SYNC_MASTER_HPP_INCLUDED
#define UAVCAN_PROTOCOL_GLOBAL_TIME_SYNC_MASTER_HPP_INCLUDED
#include <uavcan/node/publisher.hpp>
#include <uavcan/node/subscriber.hpp>
@@ -92,3 +93,5 @@ public:
};
}
#endif // UAVCAN_PROTOCOL_GLOBAL_TIME_SYNC_MASTER_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_PROTOCOL_GLOBAL_TIME_SYNC_SLAVE_HPP_INCLUDED
#define UAVCAN_PROTOCOL_GLOBAL_TIME_SYNC_SLAVE_HPP_INCLUDED
#include <uavcan/node/subscriber.hpp>
#include <uavcan/util/method_binder.hpp>
@@ -103,3 +104,5 @@ public:
};
}
#endif // UAVCAN_PROTOCOL_GLOBAL_TIME_SYNC_SLAVE_HPP_INCLUDED
+34 -20
View File
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_PROTOCOL_LOGGER_HPP_INCLUDED
#define UAVCAN_PROTOCOL_LOGGER_HPP_INCLUDED
#include <uavcan/time.hpp>
#include <uavcan/protocol/debug/LogMessage.hpp>
@@ -148,52 +149,52 @@ public:
#if UAVCAN_CPP_VERSION >= UAVCAN_CPP11
template <typename... Args>
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 <typename... Args>
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 <typename... Args>
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 <typename... Args>
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 <typename... Args>
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,20 +208,33 @@ public:
#if UAVCAN_CPP_VERSION >= UAVCAN_CPP11
template <typename... Args>
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<typename protocol::debug::LogMessage::FieldTypes::text> 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<typename protocol::debug::LogMessage::FieldTypes::text> formatter(msg_buf_.text);
formatter.write(format, args...);
return log(msg_buf_);
}
return 0;
}
return 0;
#if UAVCAN_EXCEPTIONS
catch (...)
{
return -ErrFailure;
}
#endif
}
#endif
}
#endif // UAVCAN_PROTOCOL_LOGGER_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_PROTOCOL_NETWORK_COMPAT_CHECKER_HPP_INCLUDED
#define UAVCAN_PROTOCOL_NETWORK_COMPAT_CHECKER_HPP_INCLUDED
#include <uavcan/util/bitset.hpp>
#include <uavcan/util/method_binder.hpp>
@@ -104,3 +105,5 @@ public:
};
}
#endif // UAVCAN_PROTOCOL_NETWORK_COMPAT_CHECKER_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_PROTOCOL_NODE_STATUS_MONITOR_HPP_INCLUDED
#define UAVCAN_PROTOCOL_NODE_STATUS_MONITOR_HPP_INCLUDED
#include <uavcan/util/method_binder.hpp>
#include <uavcan/node/subscriber.hpp>
@@ -128,3 +129,5 @@ public:
};
}
#endif // UAVCAN_PROTOCOL_NODE_STATUS_MONITOR_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_PROTOCOL_NODE_STATUS_PROVIDER_HPP_INCLUDED
#define UAVCAN_PROTOCOL_NODE_STATUS_PROVIDER_HPP_INCLUDED
#include <uavcan/node/publisher.hpp>
#include <uavcan/node/subscriber.hpp>
@@ -110,3 +111,5 @@ public:
};
}
#endif // UAVCAN_PROTOCOL_NODE_STATUS_PROVIDER_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_PROTOCOL_PANIC_BROADCASTER_HPP_INCLUDED
#define UAVCAN_PROTOCOL_PANIC_BROADCASTER_HPP_INCLUDED
#include <uavcan/node/publisher.hpp>
#include <uavcan/node/timer.hpp>
@@ -31,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.
@@ -47,3 +50,5 @@ public:
};
}
#endif // UAVCAN_PROTOCOL_PANIC_BROADCASTER_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_PROTOCOL_PANIC_LISTENER_HPP_INCLUDED
#define UAVCAN_PROTOCOL_PANIC_LISTENER_HPP_INCLUDED
#include <cassert>
#include <uavcan/debug.hpp>
@@ -123,3 +124,5 @@ public:
};
}
#endif // UAVCAN_PROTOCOL_PANIC_LISTENER_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_PROTOCOL_PARAM_SERVER_HPP_INCLUDED
#define UAVCAN_PROTOCOL_PARAM_SERVER_HPP_INCLUDED
#include <uavcan/protocol/param/GetSet.hpp>
#include <uavcan/protocol/param/SaveErase.hpp>
@@ -105,3 +106,5 @@ public:
};
}
#endif // UAVCAN_PROTOCOL_PARAM_SERVER_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_PROTOCOL_RESTART_REQUEST_SERVER_HPP_INCLUDED
#define UAVCAN_PROTOCOL_RESTART_REQUEST_SERVER_HPP_INCLUDED
#include <uavcan/node/service_server.hpp>
#include <uavcan/util/method_binder.hpp>
@@ -66,3 +67,5 @@ public:
};
}
#endif // UAVCAN_PROTOCOL_RESTART_REQUEST_SERVER_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_PROTOCOL_TRANSPORT_STATS_PROVIDER_HPP_INCLUDED
#define UAVCAN_PROTOCOL_TRANSPORT_STATS_PROVIDER_HPP_INCLUDED
#include <uavcan/node/service_server.hpp>
#include <uavcan/util/method_binder.hpp>
@@ -39,3 +40,5 @@ public:
};
}
#endif // UAVCAN_PROTOCOL_TRANSPORT_STATS_PROVIDER_HPP_INCLUDED
+4 -1
View File
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_STDINT_HPP_INCLUDED
#define UAVCAN_STDINT_HPP_INCLUDED
#include <uavcan/build_config.hpp>
@@ -52,3 +53,5 @@ typedef ::int64_t int64_t;
}
#endif
#endif // UAVCAN_STDINT_HPP_INCLUDED
+4 -1
View File
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_TIME_HPP_INCLUDED
#define UAVCAN_TIME_HPP_INCLUDED
#include <cstdio>
#include <uavcan/stdint.hpp>
@@ -286,3 +287,5 @@ Stream& operator<<(Stream& s, const TimeBase<T, D>& t)
}
}
#endif // UAVCAN_TIME_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_TRANSPORT_ABSTRACT_TRANSFER_BUFFER_HPP_INCLUDED
#define UAVCAN_TRANSPORT_ABSTRACT_TRANSFER_BUFFER_HPP_INCLUDED
#include <uavcan/build_config.hpp>
#include <uavcan/stdint.hpp>
@@ -22,3 +23,5 @@ public:
};
}
#endif // UAVCAN_TRANSPORT_ABSTRACT_TRANSFER_BUFFER_HPP_INCLUDED
@@ -3,7 +3,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_TRANSPORT_CAN_IO_HPP_INCLUDED
#define UAVCAN_TRANSPORT_CAN_IO_HPP_INCLUDED
#include <cassert>
#include <uavcan/error.hpp>
@@ -164,6 +165,9 @@ public:
CanIfacePerfCounters getIfacePerfCounters(uint8_t iface_index) const;
const ICanDriver& getCanDriver() const { return driver_; }
ICanDriver& getCanDriver() { return driver_; }
/**
* Returns:
* 0 - rejected/timedout/enqueued
@@ -176,3 +180,5 @@ public:
};
}
#endif // UAVCAN_TRANSPORT_CAN_IO_HPP_INCLUDED
+4 -1
View File
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_TRANSPORT_CRC_HPP_INCLUDED
#define UAVCAN_TRANSPORT_CRC_HPP_INCLUDED
#include <cassert>
#include <uavcan/stdint.hpp>
@@ -75,3 +76,5 @@ public:
};
}
#endif // UAVCAN_TRANSPORT_CRC_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_TRANSPORT_DISPATCHER_HPP_INCLUDED
#define UAVCAN_TRANSPORT_DISPATCHER_HPP_INCLUDED
#include <cassert>
#include <uavcan/error.hpp>
@@ -192,3 +193,5 @@ public:
};
}
#endif // UAVCAN_TRANSPORT_DISPATCHER_HPP_INCLUDED
+4 -1
View File
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_TRANSPORT_FRAME_HPP_INCLUDED
#define UAVCAN_TRANSPORT_FRAME_HPP_INCLUDED
#include <cassert>
#include <uavcan/transport/transfer.hpp>
@@ -128,3 +129,5 @@ public:
};
}
#endif // UAVCAN_TRANSPORT_FRAME_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_TRANSPORT_OUTGOING_TRANSFER_REGISTRY_HPP_INCLUDED
#define UAVCAN_TRANSPORT_OUTGOING_TRANSFER_REGISTRY_HPP_INCLUDED
#include <cassert>
#include <uavcan/stdint.hpp>
@@ -174,3 +175,5 @@ void OutgoingTransferRegistry<NumStaticEntries>::cleanup(MonotonicTime ts)
}
}
#endif // UAVCAN_TRANSPORT_OUTGOING_TRANSFER_REGISTRY_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_TRANSPORT_PERF_COUNTER_HPP_INCLUDED
#define UAVCAN_TRANSPORT_PERF_COUNTER_HPP_INCLUDED
#include <uavcan/stdint.hpp>
#include <uavcan/build_config.hpp>
@@ -57,3 +58,5 @@ public:
#endif
}
#endif // UAVCAN_TRANSPORT_PERF_COUNTER_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_TRANSPORT_TRANSFER_HPP_INCLUDED
#define UAVCAN_TRANSPORT_TRANSFER_HPP_INCLUDED
#include <cassert>
#include <uavcan/build_config.hpp>
@@ -100,3 +101,5 @@ public:
};
}
#endif // UAVCAN_TRANSPORT_TRANSFER_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_TRANSPORT_TRANSFER_BUFFER_HPP_INCLUDED
#define UAVCAN_TRANSPORT_TRANSFER_BUFFER_HPP_INCLUDED
#include <uavcan/stdint.hpp>
#include <uavcan/error.hpp>
@@ -324,3 +325,5 @@ public:
};
}
#endif // UAVCAN_TRANSPORT_TRANSFER_BUFFER_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_TRANSPORT_TRANSFER_LISTENER_HPP_INCLUDED
#define UAVCAN_TRANSPORT_TRANSFER_LISTENER_HPP_INCLUDED
#include <cassert>
#include <uavcan/error.hpp>
@@ -246,3 +247,5 @@ void ServiceResponseTransferListener<MaxBufSize>::stopAcceptingAnything()
}
}
#endif // UAVCAN_TRANSPORT_TRANSFER_LISTENER_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_TRANSPORT_TRANSFER_RECEIVER_HPP_INCLUDED
#define UAVCAN_TRANSPORT_TRANSFER_RECEIVER_HPP_INCLUDED
#include <cstdlib>
#include <uavcan/build_config.hpp>
@@ -83,3 +84,5 @@ public:
UAVCAN_PACKED_END
}
#endif // UAVCAN_TRANSPORT_TRANSFER_RECEIVER_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_TRANSPORT_TRANSFER_SENDER_HPP_INCLUDED
#define UAVCAN_TRANSPORT_TRANSFER_SENDER_HPP_INCLUDED
#include <cstdlib>
#include <cassert>
@@ -75,3 +76,5 @@ public:
};
}
#endif // UAVCAN_TRANSPORT_TRANSFER_SENDER_HPP_INCLUDED
+4 -1
View File
@@ -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 <uavcan/build_config.hpp>
#include <uavcan/time.hpp>
@@ -22,3 +23,5 @@
#include <uavcan/util/templates.hpp>
#include <uavcan/util/lazy_constructor.hpp>
#include <uavcan/util/method_binder.hpp>
#endif // UAVCAN_UAVCAN_HPP_INCLUDED
+4 -1
View File
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_UTIL_BITSET_HPP_INCLUDED
#define UAVCAN_UTIL_BITSET_HPP_INCLUDED
#include <cassert>
#include <cstddef>
@@ -184,3 +185,5 @@ Stream& operator<<(Stream& s, const BitSet<NumBits>& x)
}
}
#endif // UAVCAN_UTIL_BITSET_HPP_INCLUDED
+4 -1
View File
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_UTIL_COMPARISON_HPP_INCLUDED
#define UAVCAN_UTIL_COMPARISON_HPP_INCLUDED
#include <uavcan/util/templates.hpp>
#include <uavcan/build_config.hpp>
@@ -266,3 +267,5 @@ inline bool isCloseToZero<long double>(const long double& x)
}
}
#endif // UAVCAN_UTIL_COMPARISON_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_UTIL_LAZY_CONSTRUCTOR_HPP_INCLUDED
#define UAVCAN_UTIL_LAZY_CONSTRUCTOR_HPP_INCLUDED
#include <cstdlib>
#include <uavcan/error.hpp>
@@ -173,3 +174,5 @@ public:
};
}
#endif // UAVCAN_UTIL_LAZY_CONSTRUCTOR_HPP_INCLUDED
@@ -3,7 +3,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_UTIL_LINKED_LIST_HPP_INCLUDED
#define UAVCAN_UTIL_LINKED_LIST_HPP_INCLUDED
#include <cstdlib>
#include <cassert>
@@ -99,9 +100,9 @@ unsigned LinkedListRoot<T>::getLength() const
template <typename T>
void LinkedListRoot<T>::insert(T* node)
{
UAVCAN_ASSERT(node);
if (node == NULL)
{
UAVCAN_ASSERT(0);
return;
}
remove(node); // Making sure there will be no loops
@@ -113,9 +114,9 @@ template <typename T>
template <typename Predicate>
void LinkedListRoot<T>::insertBefore(T* node, Predicate predicate)
{
UAVCAN_ASSERT(node);
if (node == NULL)
{
UAVCAN_ASSERT(0);
return;
}
@@ -170,3 +171,5 @@ void LinkedListRoot<T>::remove(const T* node)
}
}
#endif // UAVCAN_UTIL_LINKED_LIST_HPP_INCLUDED
+4 -1
View File
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_UTIL_MAP_HPP_INCLUDED
#define UAVCAN_UTIL_MAP_HPP_INCLUDED
#include <cassert>
#include <cstdlib>
@@ -500,3 +501,5 @@ unsigned MapBase<Key, Value>::getNumDynamicPairs() const
}
}
#endif // UAVCAN_UTIL_MAP_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_UTIL_METHOD_BINDER_HPP_INCLUDED
#define UAVCAN_UTIL_METHOD_BINDER_HPP_INCLUDED
#include <uavcan/error.hpp>
#include <uavcan/build_config.hpp>
@@ -79,3 +80,5 @@ public:
};
}
#endif // UAVCAN_UTIL_METHOD_BINDER_HPP_INCLUDED
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_UTIL_PLACEMENT_NEW_HPP_INCLUDED
#define UAVCAN_UTIL_PLACEMENT_NEW_HPP_INCLUDED
#include <cstddef>
#include <uavcan/build_config.hpp>
@@ -33,3 +34,5 @@ inline void operator delete[](void*, void*) throw() { }
#else
# include <new>
#endif
#endif // UAVCAN_UTIL_PLACEMENT_NEW_HPP_INCLUDED
+5 -1
View File
@@ -2,7 +2,8 @@
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
*/
#pragma once
#ifndef UAVCAN_UTIL_TEMPLATES_HPP_INCLUDED
#define UAVCAN_UTIL_TEMPLATES_HPP_INCLUDED
#include <climits>
#include <cstddef>
@@ -479,8 +480,11 @@ 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
}
}
#endif // UAVCAN_UTIL_TEMPLATES_HPP_INCLUDED