From 2337a5d547fa2de6119195b70baffba80a8b6fb0 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Sun, 15 Jun 2014 21:10:36 +0400 Subject: [PATCH] File IO services --- dsdl/uavcan/protocol/file/580.GetInfo.uavcan | 17 +++++++++++++ .../file/581.GetDirectoryEntryInfo.uavcan | 16 ++++++++++++ dsdl/uavcan/protocol/file/582.Delete.uavcan | 10 ++++++++ dsdl/uavcan/protocol/file/583.Read.uavcan | 17 +++++++++++++ dsdl/uavcan/protocol/file/584.Write.uavcan | 25 +++++++++++++++++++ .../file/589.BeginFirmwareUpdate.uavcan | 25 +++++++++++++++++++ dsdl/uavcan/protocol/file/EntryType.uavcan | 13 ++++++++++ dsdl/uavcan/protocol/file/Error.uavcan | 18 +++++++++++++ dsdl/uavcan/protocol/file/Path.uavcan | 9 +++++++ 9 files changed, 150 insertions(+) create mode 100644 dsdl/uavcan/protocol/file/580.GetInfo.uavcan create mode 100644 dsdl/uavcan/protocol/file/581.GetDirectoryEntryInfo.uavcan create mode 100644 dsdl/uavcan/protocol/file/582.Delete.uavcan create mode 100644 dsdl/uavcan/protocol/file/583.Read.uavcan create mode 100644 dsdl/uavcan/protocol/file/584.Write.uavcan create mode 100644 dsdl/uavcan/protocol/file/589.BeginFirmwareUpdate.uavcan create mode 100644 dsdl/uavcan/protocol/file/EntryType.uavcan create mode 100644 dsdl/uavcan/protocol/file/Error.uavcan create mode 100644 dsdl/uavcan/protocol/file/Path.uavcan diff --git a/dsdl/uavcan/protocol/file/580.GetInfo.uavcan b/dsdl/uavcan/protocol/file/580.GetInfo.uavcan new file mode 100644 index 0000000000..0ee9ec2d59 --- /dev/null +++ b/dsdl/uavcan/protocol/file/580.GetInfo.uavcan @@ -0,0 +1,17 @@ +# +# Request info about a remote file system entry (file, directory, etc). +# +# CRC computation algorithm is the same as for DSDL signature (refer to the protocol specification). The CRC field +# should be set to zero for directories. +# +# Size is the file size in bytes. It should be set to zero for directories. +# + +Path path + +--- + +uint64 crc64 # Ignored/Zero for directories +uint32 size # Ignored/Zero for directories +Error error +EntryType entry_type diff --git a/dsdl/uavcan/protocol/file/581.GetDirectoryEntryInfo.uavcan b/dsdl/uavcan/protocol/file/581.GetDirectoryEntryInfo.uavcan new file mode 100644 index 0000000000..79a370a179 --- /dev/null +++ b/dsdl/uavcan/protocol/file/581.GetDirectoryEntryInfo.uavcan @@ -0,0 +1,16 @@ +# +# This service can be used to retrieve remote directory listing, one entry per request. +# The client should query each entry independently, iterating 'entry_index' from 0 until the last entry is passed, +# in which case the server will report that there is no such entry (via the fields 'entry_type' and 'error'). +# The entry_index shall be applied to the ordered list of directory entries (e.g. alphabetically ordered). The exact +# sorting criteria does not matter as long as it provides the same ordering for subsequent service calls. +# + +uint32 entry_index +Path directory_path + +--- + +Error error +EntryType entry_type +Path entry_full_path # Ignored/Empty if such entry does not exist. diff --git a/dsdl/uavcan/protocol/file/582.Delete.uavcan b/dsdl/uavcan/protocol/file/582.Delete.uavcan new file mode 100644 index 0000000000..fce57f4552 --- /dev/null +++ b/dsdl/uavcan/protocol/file/582.Delete.uavcan @@ -0,0 +1,10 @@ +# +# Delete remote file system entry. +# If the remote entry is a directory, all nested entries will be removed too. +# + +Path path + +--- + +Error error diff --git a/dsdl/uavcan/protocol/file/583.Read.uavcan b/dsdl/uavcan/protocol/file/583.Read.uavcan new file mode 100644 index 0000000000..7de61aed60 --- /dev/null +++ b/dsdl/uavcan/protocol/file/583.Read.uavcan @@ -0,0 +1,17 @@ +# +# Read contents of the file from remote node. +# Empty data in response means that 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 maximum. +# Thus, if the client needs to fetch the entire file, it should repeatedly call this service while increasing the +# offset, until the empty data is returned. +# If the object pointed by 'path' cannot be read (e.g. is a directory or does not exist), appropriate error code +# will be returned. +# + +uint32 offset +Path path + +--- + +Error error +uint8[<=250] data diff --git a/dsdl/uavcan/protocol/file/584.Write.uavcan b/dsdl/uavcan/protocol/file/584.Write.uavcan new file mode 100644 index 0000000000..f3a08356de --- /dev/null +++ b/dsdl/uavcan/protocol/file/584.Write.uavcan @@ -0,0 +1,25 @@ +# +# Write a remote file. +# The server shall place the contents of the field 'data' into the file pointed by 'path' at the offset specified by +# the field 'offset'. +# +# When writing a file, the client should repeatedly call this service with data while advancing offset until the file +# is written completely. Then the client shall call the service one last time, with the offset equal the size of the +# file and the data field empty, which will signal the server that the write operation is complete. +# +# When the write operation is complete, the server shall truncate the resulting file past the specified offset. +# +# Server implementation advice: +# It is recommended to implement proper handling of concurrent writes to the same file from different clients, for +# example by means of creating a staging area for uncompleted writes (like FTP servers do). Then the write-complete +# calls (with empty data fields, as described above) will trigger the server to move the file from the staging area +# to the proper location specified by 'path'. +# + +uint32 offset +Path path +uint8[<=200] data + +--- + +Error error diff --git a/dsdl/uavcan/protocol/file/589.BeginFirmwareUpdate.uavcan b/dsdl/uavcan/protocol/file/589.BeginFirmwareUpdate.uavcan new file mode 100644 index 0000000000..accb0d8d4f --- /dev/null +++ b/dsdl/uavcan/protocol/file/589.BeginFirmwareUpdate.uavcan @@ -0,0 +1,25 @@ +# +# This service initiates the firmware update procedure on a remote node. +# The node that is being updated will retrieve the firmware image file 'image_file_remote_path' from the node +# 'source_node_id' using the file read service, update the firmware, and reboot. +# +# Nodes are allowed to explicitly reject this request under some circumstances (e.g. BLDC drive should reject if +# the motor is running). +# +# If the node accepts the request, initiator will get the response immediately, before the update process actually +# begins. +# + +uint8 source_node_id # If there is an invalid value (e.g. zero), the caller Node ID will be used instead +Path image_file_remote_path + +--- + +uint8 ERROR_OK = 0 +uint8 ERROR_INVALID_MODE = 1 # Cannot perform the update right now (e.g. the vehicle is operating) +uint8 ERROR_INVALID_FIRMWARE = 2 # Wrong firmware image, or this image cannot be loaded via UAVCAN +uint8 ERROR_FILE_READ_FAILED = 3 # Remote image file could not be read +uint8 ERROR_UNKNOWN = 255 + +uint8 error +uint8[<128] optional_error_message # Detailed error description diff --git a/dsdl/uavcan/protocol/file/EntryType.uavcan b/dsdl/uavcan/protocol/file/EntryType.uavcan new file mode 100644 index 0000000000..024e1e7f07 --- /dev/null +++ b/dsdl/uavcan/protocol/file/EntryType.uavcan @@ -0,0 +1,13 @@ +# +# Nested type. +# Represents the type of the file system entry (e.g. file or directory). +# If such entry does not exist, 'flags' must be set to zero. +# + +uint8 FLAG_FILE = 1 +uint8 FLAG_DIRECTORY = 2 +uint8 FLAG_SYMLINK = 4 +uint8 FLAG_READABLE = 8 +uint8 FLAG_WRITEABLE = 16 + +uint8 flags diff --git a/dsdl/uavcan/protocol/file/Error.uavcan b/dsdl/uavcan/protocol/file/Error.uavcan new file mode 100644 index 0000000000..448c0ce361 --- /dev/null +++ b/dsdl/uavcan/protocol/file/Error.uavcan @@ -0,0 +1,18 @@ +# +# Nested type. +# File operation result code. +# + +int16 OK = 0 +int16 UNKNOWN_ERROR = 32767 + +# These error codes match some standard UNIX errno values +int16 NOT_FOUND = 2 +int16 IO_ERROR = 5 +int16 ACCESS_DENIED = 13 +int16 IS_DIRECTORY = 21 # I.e. attempt to read/write on a path that points to a directory +int16 INVALID_VALUE = 22 # E.g. file name is not valid for the target file system +int16 FILE_TOO_LARGE = 27 +int16 OUT_OF_SPACE = 28 + +int16 value diff --git a/dsdl/uavcan/protocol/file/Path.uavcan b/dsdl/uavcan/protocol/file/Path.uavcan new file mode 100644 index 0000000000..8a30feb0be --- /dev/null +++ b/dsdl/uavcan/protocol/file/Path.uavcan @@ -0,0 +1,9 @@ +# +# Nested type. +# File system path in ASCII or UTF8. +# The only valid separator is forward flash. +# + +uint8 SEPARATOR = '/' + +uint8[<=200] path