From 451ea11795659a97baa29511bde813e3980c7ef7 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Thu, 6 Mar 2014 13:32:38 +0400 Subject: [PATCH] Added standard DSDL types: uavcan.*, uavcan.protocol.*, uavcan.mavlink.* --- dsdl/uavcan/FigureOfMerit.uavcan | 8 ++++++ dsdl/uavcan/Timestamp.uavcan | 7 +++++ dsdl/uavcan/mavlink/767.Message.uavcan | 10 +++++++ dsdl/uavcan/protocol/0.GlobalTimeSync.uavcan | 11 ++++++++ dsdl/uavcan/protocol/1.Panic.uavcan | 17 ++++++++++++ dsdl/uavcan/protocol/550.NodeStatus.uavcan | 26 +++++++++++++++++++ dsdl/uavcan/protocol/551.GetNodeInfo.uavcan | 14 ++++++++++ .../551.GlobalDiscoveryRequest.uavcan | 5 ++++ .../protocol/552.GetDataTypeInfo.uavcan | 17 ++++++++++++ .../protocol/553.GetProtocolStatistics.uavcan | 15 +++++++++++ .../554.ComputeAggregateTypeSignature.uavcan | 11 ++++++++ dsdl/uavcan/protocol/560.RestartNode.uavcan | 11 ++++++++ dsdl/uavcan/protocol/DataTypeIDMask.uavcan | 5 ++++ dsdl/uavcan/protocol/DataTypeKind.uavcan | 7 +++++ dsdl/uavcan/protocol/DataTypeName.uavcan | 5 ++++ dsdl/uavcan/protocol/DataTypeSignature.uavcan | 5 ++++ dsdl/uavcan/protocol/Version.uavcan | 7 +++++ .../protocol/debug/1022.KeyValue.uavcan | 15 +++++++++++ .../debug/1022.StartHilSimulation.uavcan | 12 +++++++++ .../protocol/debug/1023.LogMessage.uavcan | 12 +++++++++ dsdl/uavcan/protocol/file/570.GetInfo.uavcan | 11 ++++++++ dsdl/uavcan/protocol/file/571.List.uavcan | 17 ++++++++++++ dsdl/uavcan/protocol/file/572.Delete.uavcan | 9 +++++++ dsdl/uavcan/protocol/file/573.Read.uavcan | 15 +++++++++++ .../protocol/file/574.BeginTransfer.uavcan | 11 ++++++++ .../file/575.BeginFirmwareUpdate.uavcan | 16 ++++++++++++ dsdl/uavcan/protocol/file/Crc.uavcan | 6 +++++ dsdl/uavcan/protocol/file/Errno.uavcan | 5 ++++ dsdl/uavcan/protocol/file/Path.uavcan | 7 +++++ dsdl/uavcan/ranges | 10 +++++++ libuavcan/CMakeLists.txt | 6 +++-- 31 files changed, 331 insertions(+), 2 deletions(-) create mode 100644 dsdl/uavcan/FigureOfMerit.uavcan create mode 100644 dsdl/uavcan/Timestamp.uavcan create mode 100644 dsdl/uavcan/mavlink/767.Message.uavcan create mode 100644 dsdl/uavcan/protocol/0.GlobalTimeSync.uavcan create mode 100644 dsdl/uavcan/protocol/1.Panic.uavcan create mode 100644 dsdl/uavcan/protocol/550.NodeStatus.uavcan create mode 100644 dsdl/uavcan/protocol/551.GetNodeInfo.uavcan create mode 100644 dsdl/uavcan/protocol/551.GlobalDiscoveryRequest.uavcan create mode 100644 dsdl/uavcan/protocol/552.GetDataTypeInfo.uavcan create mode 100644 dsdl/uavcan/protocol/553.GetProtocolStatistics.uavcan create mode 100644 dsdl/uavcan/protocol/554.ComputeAggregateTypeSignature.uavcan create mode 100644 dsdl/uavcan/protocol/560.RestartNode.uavcan create mode 100644 dsdl/uavcan/protocol/DataTypeIDMask.uavcan create mode 100644 dsdl/uavcan/protocol/DataTypeKind.uavcan create mode 100644 dsdl/uavcan/protocol/DataTypeName.uavcan create mode 100644 dsdl/uavcan/protocol/DataTypeSignature.uavcan create mode 100644 dsdl/uavcan/protocol/Version.uavcan create mode 100644 dsdl/uavcan/protocol/debug/1022.KeyValue.uavcan create mode 100644 dsdl/uavcan/protocol/debug/1022.StartHilSimulation.uavcan create mode 100644 dsdl/uavcan/protocol/debug/1023.LogMessage.uavcan create mode 100644 dsdl/uavcan/protocol/file/570.GetInfo.uavcan create mode 100644 dsdl/uavcan/protocol/file/571.List.uavcan create mode 100644 dsdl/uavcan/protocol/file/572.Delete.uavcan create mode 100644 dsdl/uavcan/protocol/file/573.Read.uavcan create mode 100644 dsdl/uavcan/protocol/file/574.BeginTransfer.uavcan create mode 100644 dsdl/uavcan/protocol/file/575.BeginFirmwareUpdate.uavcan create mode 100644 dsdl/uavcan/protocol/file/Crc.uavcan create mode 100644 dsdl/uavcan/protocol/file/Errno.uavcan create mode 100644 dsdl/uavcan/protocol/file/Path.uavcan create mode 100644 dsdl/uavcan/ranges diff --git a/dsdl/uavcan/FigureOfMerit.uavcan b/dsdl/uavcan/FigureOfMerit.uavcan new file mode 100644 index 0000000000..b3fb072657 --- /dev/null +++ b/dsdl/uavcan/FigureOfMerit.uavcan @@ -0,0 +1,8 @@ +# +# Represents the quality of associated data, higher is better. +# + +float16 UNKNOWN = -65504 +float16 MIN = 0 +float16 MAX = 65504 +float16 value diff --git a/dsdl/uavcan/Timestamp.uavcan b/dsdl/uavcan/Timestamp.uavcan new file mode 100644 index 0000000000..8154f6b1a6 --- /dev/null +++ b/dsdl/uavcan/Timestamp.uavcan @@ -0,0 +1,7 @@ +# +# Global timestamp in hectomicroseconds (1 = 100 usec), 6 bytes. +# + +uint48 UNKNOWN = 0 +uint48 USEC_PER_LSB = 100 # Timestamp resolution +truncated uint48 husec # Hectomicroseconds (10^-4) diff --git a/dsdl/uavcan/mavlink/767.Message.uavcan b/dsdl/uavcan/mavlink/767.Message.uavcan new file mode 100644 index 0000000000..110d1ca45e --- /dev/null +++ b/dsdl/uavcan/mavlink/767.Message.uavcan @@ -0,0 +1,10 @@ +# +# Encapsulated MAVLink message. +# + +uint8 seq +uint8 sysid +uint8 compid +uint8 msgid + +uint8[<256] payload diff --git a/dsdl/uavcan/protocol/0.GlobalTimeSync.uavcan b/dsdl/uavcan/protocol/0.GlobalTimeSync.uavcan new file mode 100644 index 0000000000..d9d87f718a --- /dev/null +++ b/dsdl/uavcan/protocol/0.GlobalTimeSync.uavcan @@ -0,0 +1,11 @@ +# +# Time synchronization; publish frequency 0.5 Hz. +# Should be UTC time, not GPS time nor local time. +# Any node that publishes a timestamped data must use this time reference. +# Multiple nodes can provide the time synchronization concurrently. +# + +uint16 PUBLICATION_PERIOD_MS = 2000 + +uavcan.Timestamp timestamp # Must be known +float16 timestamp_variance # Units of the timestamp ^2 diff --git a/dsdl/uavcan/protocol/1.Panic.uavcan b/dsdl/uavcan/protocol/1.Panic.uavcan new file mode 100644 index 0000000000..1cd934a579 --- /dev/null +++ b/dsdl/uavcan/protocol/1.Panic.uavcan @@ -0,0 +1,17 @@ +# +# This message must never be published during normal operation. This message may +# be published with high frequency (~10..100 Hz) to inform the network participants +# that the system has entered unrecoverable fault condition (e.g. mission critical +# node failure) and is not capable of further operation. +# +# Typical reaction to this message may include emergency motor/power shutdown, +# safety parachute deployment, etc. Nodes that are expected to react to this message +# should wait for at least MIN_MESSAGES subsequent messages published with the +# interval no higher than MAX_INTERVAL_MS before undertaking any emergency actions. +# + +uint8 MIN_MESSAGES = 5 +uint16 MAX_INTERVAL_MS = 500 + +# Short description that would fit into single CAN frame +uint8[<=8] reason_text diff --git a/dsdl/uavcan/protocol/550.NodeStatus.uavcan b/dsdl/uavcan/protocol/550.NodeStatus.uavcan new file mode 100644 index 0000000000..93312bd6a0 --- /dev/null +++ b/dsdl/uavcan/protocol/550.NodeStatus.uavcan @@ -0,0 +1,26 @@ +# +# Abstract node status information. +# Must be published periodically. +# + +uint16 PUBLICATION_PERIOD_MS = 1000 + +# If a node fails to publish this message in this amount of time, it should be considered offline. +uint16 OFFLINE_TIMEOUT_MS = 4000 + +# Uptime counter should never overflow. +uint24 uptime_sec + +# Status code should be used to reflect the node status in the most abstract way. +# Use cases: top-level onboard computer should not allow the UAV to begin normal operation +# unless all nodes report OK. If a mission critical node reports CRITICAL status, current +# mission should be immediately yet safely aborted (e.g. RTL). +# OFFLINE status can be actually reported by the node to explicitly inform other network +# participants that the sending node is about to shutdown. In this case other nodes will not +# have to wait OFFLINE_TIMEOUT_MS before they detect that the node is no longer available. +uint4 STATUS_OK = 0 +uint4 STATUS_INITIALIZING = 1 +uint4 STATUS_WARNING = 2 +uint4 STATUS_CRITICAL = 3 +uint4 STATUS_OFFLINE = 15 +uint4 status_code diff --git a/dsdl/uavcan/protocol/551.GetNodeInfo.uavcan b/dsdl/uavcan/protocol/551.GetNodeInfo.uavcan new file mode 100644 index 0000000000..1a5f773d99 --- /dev/null +++ b/dsdl/uavcan/protocol/551.GetNodeInfo.uavcan @@ -0,0 +1,14 @@ +# +# Full node info request. +# + +--- + +Version software_version +Version hardware_version +Version uavcan_version + +NodeStatus status + +# Human readable name, e.g. "pixhawk", "gnss_mag". Alphanumeric and underscores. +uint8[<64] name diff --git a/dsdl/uavcan/protocol/551.GlobalDiscoveryRequest.uavcan b/dsdl/uavcan/protocol/551.GlobalDiscoveryRequest.uavcan new file mode 100644 index 0000000000..db57891a3e --- /dev/null +++ b/dsdl/uavcan/protocol/551.GlobalDiscoveryRequest.uavcan @@ -0,0 +1,5 @@ +# +# This message can be broadcasted in order to perform global network discovery. +# Alternatively, it is possible to wait some time so each node of the network +# transmits NodeStatus message at least once. +# diff --git a/dsdl/uavcan/protocol/552.GetDataTypeInfo.uavcan b/dsdl/uavcan/protocol/552.GetDataTypeInfo.uavcan new file mode 100644 index 0000000000..bc08c23849 --- /dev/null +++ b/dsdl/uavcan/protocol/552.GetDataTypeInfo.uavcan @@ -0,0 +1,17 @@ +# +# Get the implementation details of a given data type. +# + +uint16 id +DataTypeKind kind + +--- + +DataTypeSignature signature # Data type hash as computed by DSDL compiler (type name + each field) +DataTypeName name # Full data type name, e.g. "std.node.GetDataTypeInfo" + +uint8 MASK_KNOWN = 1 # This data type is defined +uint8 MASK_SUBSCRIBED = 2 # Subscribed to messages of this type +uint8 MASK_PUBLISHING = 4 # Publishing messages of this type +uint8 MASK_SERVING = 8 # Providing service of this type +uint8 mask diff --git a/dsdl/uavcan/protocol/553.GetProtocolStatistics.uavcan b/dsdl/uavcan/protocol/553.GetProtocolStatistics.uavcan new file mode 100644 index 0000000000..e97cb7647c --- /dev/null +++ b/dsdl/uavcan/protocol/553.GetProtocolStatistics.uavcan @@ -0,0 +1,15 @@ +# +# Get protocol statistics for CAN and UAVCAN. +# + +--- + +# CAN bus statistics, for each interface independently +uint64[<=3] can_frames_tx +uint64[<=3] can_frames_rx +uint64[<=3] can_frames_errors + +# UAVCAN transport layer statistics +uint64 transfers_tx +uint64 transfers_rx +uint32 transfers_rx_errors diff --git a/dsdl/uavcan/protocol/554.ComputeAggregateTypeSignature.uavcan b/dsdl/uavcan/protocol/554.ComputeAggregateTypeSignature.uavcan new file mode 100644 index 0000000000..112eb52f4c --- /dev/null +++ b/dsdl/uavcan/protocol/554.ComputeAggregateTypeSignature.uavcan @@ -0,0 +1,11 @@ +# +# This service allows to detect type compatibility between two nodes in one request. +# + +DataTypeIDMask known_ids +DataTypeKind kind + +--- + +DataTypeIDMask mutually_known_ids +DataTypeSignature aggregate_signature diff --git a/dsdl/uavcan/protocol/560.RestartNode.uavcan b/dsdl/uavcan/protocol/560.RestartNode.uavcan new file mode 100644 index 0000000000..7ba6a9e09b --- /dev/null +++ b/dsdl/uavcan/protocol/560.RestartNode.uavcan @@ -0,0 +1,11 @@ +# +# Restart the node. +# Some nodes may require restart before the new configuration will be applied. +# + +uint64 MAGIC_NUMBER = 0xACCE551B1E012345 +uint64 magic_number + +--- + +bool ok diff --git a/dsdl/uavcan/protocol/DataTypeIDMask.uavcan b/dsdl/uavcan/protocol/DataTypeIDMask.uavcan new file mode 100644 index 0000000000..74cce5828e --- /dev/null +++ b/dsdl/uavcan/protocol/DataTypeIDMask.uavcan @@ -0,0 +1,5 @@ +# +# Data type ID mask; 1 - known, 0 - unknown. +# + +bool[1024] value diff --git a/dsdl/uavcan/protocol/DataTypeKind.uavcan b/dsdl/uavcan/protocol/DataTypeKind.uavcan new file mode 100644 index 0000000000..925a575e0c --- /dev/null +++ b/dsdl/uavcan/protocol/DataTypeKind.uavcan @@ -0,0 +1,7 @@ +# +# Data type kind (message or service). +# + +uint2 SERVICE = 0 +uint2 MESSAGE = 1 +uint2 value diff --git a/dsdl/uavcan/protocol/DataTypeName.uavcan b/dsdl/uavcan/protocol/DataTypeName.uavcan new file mode 100644 index 0000000000..575678e93c --- /dev/null +++ b/dsdl/uavcan/protocol/DataTypeName.uavcan @@ -0,0 +1,5 @@ +# +# Full data type name. +# + +uint8[<=80] value diff --git a/dsdl/uavcan/protocol/DataTypeSignature.uavcan b/dsdl/uavcan/protocol/DataTypeSignature.uavcan new file mode 100644 index 0000000000..d07714b6ab --- /dev/null +++ b/dsdl/uavcan/protocol/DataTypeSignature.uavcan @@ -0,0 +1,5 @@ +# +# Data type signature value, 64 bit. +# + +uint64 value diff --git a/dsdl/uavcan/protocol/Version.uavcan b/dsdl/uavcan/protocol/Version.uavcan new file mode 100644 index 0000000000..197f00bfa2 --- /dev/null +++ b/dsdl/uavcan/protocol/Version.uavcan @@ -0,0 +1,7 @@ +# +# Nested type. +# Generic version information. +# + +uint8 major +uint8 minor diff --git a/dsdl/uavcan/protocol/debug/1022.KeyValue.uavcan b/dsdl/uavcan/protocol/debug/1022.KeyValue.uavcan new file mode 100644 index 0000000000..be9668cfaf --- /dev/null +++ b/dsdl/uavcan/protocol/debug/1022.KeyValue.uavcan @@ -0,0 +1,15 @@ +# +# Generic named parameter (key/value pair). +# + +uint3 TYPE_UNDEF = 0 +uint3 TYPE_INTEGER = 1 +uint3 TYPE_FLOAT = 2 +uint3 TYPE_STRING = 3 +uint3 TYPE_BYTES = 4 +uint3 type + +uint8[<64] key + +float64[<=1] numeric_value # For type = INTEGER, FLOAT +uint8[<256] binary_value # For type = STRING, BYTES diff --git a/dsdl/uavcan/protocol/debug/1022.StartHilSimulation.uavcan b/dsdl/uavcan/protocol/debug/1022.StartHilSimulation.uavcan new file mode 100644 index 0000000000..6b78bf3a86 --- /dev/null +++ b/dsdl/uavcan/protocol/debug/1022.StartHilSimulation.uavcan @@ -0,0 +1,12 @@ +# +# Start HIL simulation for the specified components. +# + +uint64 MAGIC_NUMBER = 0xACCE551B1E012345 +uint64 magic_number + +uint64 component_mask # Components are application defined + +--- + +bool ok diff --git a/dsdl/uavcan/protocol/debug/1023.LogMessage.uavcan b/dsdl/uavcan/protocol/debug/1023.LogMessage.uavcan new file mode 100644 index 0000000000..91abf734b0 --- /dev/null +++ b/dsdl/uavcan/protocol/debug/1023.LogMessage.uavcan @@ -0,0 +1,12 @@ +# +# Generic log message. +# + +uint3 SEVERITY_DEBUG = 0 +uint3 SEVERITY_INFO = 1 +uint3 SEVERITY_WARNING = 2 +uint3 SEVERITY_ERROR = 3 +uint3 severity + +uint8[<32] source +uint8[<128] text diff --git a/dsdl/uavcan/protocol/file/570.GetInfo.uavcan b/dsdl/uavcan/protocol/file/570.GetInfo.uavcan new file mode 100644 index 0000000000..3a7977fe76 --- /dev/null +++ b/dsdl/uavcan/protocol/file/570.GetInfo.uavcan @@ -0,0 +1,11 @@ +# +# Remote file info. +# + +Path path + +--- + +Crc crc +int64 size +Errno result diff --git a/dsdl/uavcan/protocol/file/571.List.uavcan b/dsdl/uavcan/protocol/file/571.List.uavcan new file mode 100644 index 0000000000..2c14a25e3c --- /dev/null +++ b/dsdl/uavcan/protocol/file/571.List.uavcan @@ -0,0 +1,17 @@ +# +# Remote directory contents. +# + +uint32 entry_index +Path directory_path + +--- + +Errno result + +uint4 ENTRY_TYPE_NONE = 0 +uint4 ENTRY_TYPE_FILE = 1 +uint4 ENTRY_TYPE_DIR = 2 +uint4 entry_type + +Path entry_abs_path diff --git a/dsdl/uavcan/protocol/file/572.Delete.uavcan b/dsdl/uavcan/protocol/file/572.Delete.uavcan new file mode 100644 index 0000000000..c972d381a0 --- /dev/null +++ b/dsdl/uavcan/protocol/file/572.Delete.uavcan @@ -0,0 +1,9 @@ +# +# Remote file deletion request. +# + +Path path + +--- + +Errno result diff --git a/dsdl/uavcan/protocol/file/573.Read.uavcan b/dsdl/uavcan/protocol/file/573.Read.uavcan new file mode 100644 index 0000000000..293d68868c --- /dev/null +++ b/dsdl/uavcan/protocol/file/573.Read.uavcan @@ -0,0 +1,15 @@ +# +# Read contents of the file from a remote node. +# Use cases: Firmware update, log download. +# + +int64 offset +Path path + +--- + +Errno result + +# Empty data means the offset is out of file boundaries. +# Non-empty data means the end of file is not reached yet, even if the length is less than max. +truncated uint8[<256] data diff --git a/dsdl/uavcan/protocol/file/574.BeginTransfer.uavcan b/dsdl/uavcan/protocol/file/574.BeginTransfer.uavcan new file mode 100644 index 0000000000..ac2f5c6a61 --- /dev/null +++ b/dsdl/uavcan/protocol/file/574.BeginTransfer.uavcan @@ -0,0 +1,11 @@ +# +# Initiates file transfer between two nodes. +# Use cases: Configuration file replacement, executable update. +# + +Path src # On the requesting node +Path dst # On the serving node + +--- + +Errno result diff --git a/dsdl/uavcan/protocol/file/575.BeginFirmwareUpdate.uavcan b/dsdl/uavcan/protocol/file/575.BeginFirmwareUpdate.uavcan new file mode 100644 index 0000000000..4aa260966f --- /dev/null +++ b/dsdl/uavcan/protocol/file/575.BeginFirmwareUpdate.uavcan @@ -0,0 +1,16 @@ +# +# This service initiates the firmware update procedure. +# +# Nodes are allowed to explicitly reject this request under some circumstances +# (e.g. ESC should reject this if the motor is running). +# +# If the node accepts the request, initiator will get the response immediately, +# before the update process actually begins. +# + +Path image_file_remote_path + +--- + +Errno result +uint8[<64] error_message diff --git a/dsdl/uavcan/protocol/file/Crc.uavcan b/dsdl/uavcan/protocol/file/Crc.uavcan new file mode 100644 index 0000000000..d1e57fd542 --- /dev/null +++ b/dsdl/uavcan/protocol/file/Crc.uavcan @@ -0,0 +1,6 @@ +# +# File CRC. +# Algorithm: CRC-64-WE. +# + +uint64 value diff --git a/dsdl/uavcan/protocol/file/Errno.uavcan b/dsdl/uavcan/protocol/file/Errno.uavcan new file mode 100644 index 0000000000..8c8e5c2af2 --- /dev/null +++ b/dsdl/uavcan/protocol/file/Errno.uavcan @@ -0,0 +1,5 @@ +# +# File operation result - UNIX errno. +# + +int16 value diff --git a/dsdl/uavcan/protocol/file/Path.uavcan b/dsdl/uavcan/protocol/file/Path.uavcan new file mode 100644 index 0000000000..27b1558a25 --- /dev/null +++ b/dsdl/uavcan/protocol/file/Path.uavcan @@ -0,0 +1,7 @@ +# +# Encoded FS path (ASCII/UTF8). +# + +uint8 SEPARATOR = 47 # ASCII '/' + +uint8[<128] value diff --git a/dsdl/uavcan/ranges b/dsdl/uavcan/ranges new file mode 100644 index 0000000000..bed08cd70f --- /dev/null +++ b/dsdl/uavcan/ranges @@ -0,0 +1,10 @@ + +256..399 - high priority equipment + +500..519 - nav + +550..599 - protocol + +600..749 - low priority eqipment + +767 - MAVLink diff --git a/libuavcan/CMakeLists.txt b/libuavcan/CMakeLists.txt index 03be475cef..3f09304379 100644 --- a/libuavcan/CMakeLists.txt +++ b/libuavcan/CMakeLists.txt @@ -52,8 +52,10 @@ if (GTEST_FOUND) # DSDL compiler invocation add_custom_target(dsdlc dsdl_compiler/dsdlc.py -v - test/dsdl_test/root_ns_a test/dsdl_test/root_ns_b # Inputs - -Otest/dsdlc_output # Output + test/dsdl_test/root_ns_a # Input + test/dsdl_test/root_ns_b # Input + ${CMAKE_SOURCE_DIR}/../dsdl/uavcan # Input + -Otest/dsdlc_output # Output WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) add_dependencies(libuavcan_test dsdlc) include_directories(${CMAKE_SOURCE_DIR}/test/dsdlc_output)