mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-11 23:43:35 +08:00
File IO services
This commit is contained in:
@@ -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
|
||||
@@ -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.
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user