Skip to content

Commit 08c20d2

Browse files
authored
Merge pull request #668 from mavlink/mavlink_ftp_drives
mavftp: Define how virtual drives work
2 parents cbddae1 + 8ab32bc commit 08c20d2

1 file changed

Lines changed: 36 additions & 6 deletions

File tree

en/services/ftp.md

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,26 @@ The sequence of operations is:
508508
509509
The GSC should create a timeout after the `RemoveDirectory` command is sent and resend the message as needed (and [described above](#timeouts)).
510510
511+
## Virtual Directory Entries (Directory Alias)
512+
513+
MAVFTP supports the concept of "standard" virtual directories for storing particular types of data in a flight-stack-independent and file-system-independent location.
514+
This allows a GCS to provision or fetch data without having to know how or where it is stored in the target component.
515+
516+
::: info
517+
MAVFTP represents storage on a remote component as a single entity accessible via a directory structure that the protocol exposes.
518+
In order to represent multiple physical drives supported by the component, such as "c" or "d" drives, these can be abstracted to this structure.
519+
Similarly, in order to support virtual directories, components must abstract the syntax that indicates their location, and map it to their physical file system(s).
520+
:::
521+
522+
In the [MAVLink FTP URL Scheme](#mavlink-ftp-url-scheme) a virtual directory is specified using the `@<directory>` prefix, such as `@MAV_LOG` for log files.
523+
When encoded in the [FILE_TRANSFER_PROTOCOL](#FILE_TRANSFER_PROTOCOL) this prefix should be prepended when a path is being specified.
524+
For example, when [Listing a directory](#list_directory) the request might encode `data[0]` as `@MAV_LOG/path_in_log/`, and the recipient would be expected to map this to the underlying file system.
525+
If the full path including virtual directory is not known, the recipient would NAK with [FileNotFound](#error_codes) (this is just another "not found" error case).
526+
527+
The following standard directory locations are defined:
528+
529+
- `@MAV_LOG`- Log files
530+
511531
## Implementations
512532
513533
The FTP v1 Protocol has been implemented (at least) in PX4, ArduPilot, QGroundControl and MAVSDK.
@@ -523,7 +543,8 @@ _QGroundControl_ implementation:
523543
- [src/uas/FileManager.cc](https://github.com/mavlink/qgroundcontrol/blob/master/src/Vehicle/FTPManager.cc)
524544
- [/src/uas/FileManager.h](https://github.com/mavlink/qgroundcontrol/blob/master/src/Vehicle/FTPManager.h)
525545
526-
Everything is run by the master (QGC in this case); the slave simply responds to packets in order as they arrive. There’s buffering in the server for a little overlap (two packets in the queue at a time). This is a tradeoff between memory and link latency which may need to be reconsidered at some point.
546+
Everything is run by the client (QGC in this case); the server simply responds to packets in order as they arrive.
547+
There's buffering in the server for a little overlap (two packets in the queue at a time). This is a tradeoff between memory and link latency which may need to be reconsidered at some point.
527548
528549
The MAVLink receiver thread copies an incoming request verbatim from the MAVLink buffer into a request queue, and queues a low-priority work item to handle the packet. This avoids trying to do file I/O on the MAVLink receiver thread, as well as avoiding yet another worker thread. The worker is responsible for directly queuing replies, which are sent with the same sequence number as the request.
529550
@@ -538,28 +559,37 @@ The CRC32 algorithm used by MAVLink FTP is described in [MAVLink CRCs](../guide/
538559
Resources to be downloaded using MAVLink FTP can be referenced using the following URL-like format:
539560
540561
```txt
541-
mftp://[;comp=<id>]<path>
562+
mftp://[;comp=<id>][/@<directory>]/<path>
542563
```
543564

544565
Where:
545566

546-
- `path`: the location of the resource on the target component.
567+
- `path`: the location of the resource on the target component and/or in the virtual directory.
547568
- `id`: target _component ID_ of the component hosting the resource.
548-
The `[;comp=<id>]` part is optional (if omitted, the resource is downloaded from the current component).
569+
The `;comp=<id>` part is optional (if omitted, the resource is downloaded from the current component).
549570
It should be specified if the request must be redirected
571+
- `directory`: A [virtual directory](#virtual-directory-entries-directory-alias) on the target source.
572+
The `@<directory>` part is optional (if omitted, the resource is downloaded from the "normal" directory path).
550573

551574
For example:
552575

553576
- A GCS connected to an autopilot might download a file using the following URL:
554577

555578
```txt
556579
## FTP resource 'camera.xml' from current component
557-
mftp://camera.xml
580+
mftp:///camera.xml
558581
```
559582

560583
- A GCS connected to an autopilot through a companion computer might host the metadata on the companion (e.g. due to lack of flash space, faster download or if there's a central MAVFTP server on the vehicle), so it would need to specify the component ID of the component running on the companion (e.g. 100 for the camera), so that the request is redirected:
561584

562585
```txt
563586
## FTP resource '/info/version.json' from component with id 100
564-
mftp://[;comp=100]/info/version.json
587+
mftp://;comp=100/info/version.json
588+
```
589+
590+
- A GCS wanting to download a log might use
591+
592+
```txt
593+
## FTP resource '2024.log' from @MAV_LOG virtual directory
594+
mftp:///@MAV_LOG/2024.log
565595
```

0 commit comments

Comments
 (0)