Ftp

class mavsdk.ftp.Ftp(async_plugin_manager)

Bases: mavsdk._base.AsyncBase

Implements file transfer functionality using MAVLink FTP.

Generated by dcsdkgen - MAVSDK Ftp API

async are_files_identical(local_file_path, remote_file_path)

Compares a local file to a remote file using a CRC32 checksum.

Parameters
  • local_file_path (std::string) – The path of the local file.

  • remote_file_path (std::string) – The path of the remote file.

Returns

are_identical – Whether the files are identical.

Return type

bool

Raises

FtpError – If the request fails. The error contains the reason for the failure.

async create_directory(remote_dir)

Creates a remote directory.

Parameters

remote_dir (std::string) – The remote directory to create.

Raises

FtpError – If the request fails. The error contains the reason for the failure.

download(remote_file_path, local_dir)

Downloads a file to local directory.

Parameters
  • remote_file_path (std::string) – The path of the remote file to download.

  • local_dir (std::string) – The local directory to download to.

Yields

progress_data (ProgressData) – The progress data if result is next

Raises

FtpError – If the request fails. The error contains the reason for the failure.

async get_our_compid()

Get our own component ID.

Returns

compid – Our component ID.

Return type

uint32_t

async list_directory(remote_dir)

Lists items from a remote directory.

Parameters

remote_dir (std::string) – The remote directory to list the contents for.

Returns

paths – The found directory contents.

Return type

[std::string]

Raises

FtpError – If the request fails. The error contains the reason for the failure.

name = 'Ftp'
async remove_directory(remote_dir)

Removes a remote directory.

Parameters

remote_dir (std::string) – The remote directory to remove.

Raises

FtpError – If the request fails. The error contains the reason for the failure.

async remove_file(remote_file_path)

Removes a remote file.

Parameters

remote_file_path (std::string) – The path of the remote file to remove.

Raises

FtpError – If the request fails. The error contains the reason for the failure.

async rename(remote_from_path, remote_to_path)

Renames a remote file or remote directory.

Parameters
  • remote_from_path (std::string) – The remote source path.

  • remote_to_path (std::string) – The remote destination path.

Raises

FtpError – If the request fails. The error contains the reason for the failure.

async reset()

Resets FTP server in case there are stale open sessions.

Raises

FtpError – If the request fails. The error contains the reason for the failure.

async set_root_directory(root_dir)

Set root directory for MAVLink FTP server.

Parameters

root_dir (std::string) – The root directory to set.

Raises

FtpError – If the request fails. The error contains the reason for the failure.

async set_target_compid(compid)

Set target component ID. By default it is the autopilot.

Parameters

compid (uint32_t) – The component ID to set.

Raises

FtpError – If the request fails. The error contains the reason for the failure.

upload(local_file_path, remote_dir)

Uploads local file to remote directory.

Parameters
  • local_file_path (std::string) – The local file path to upload.

  • remote_dir (std::string) – The remote directory to upload to.

Yields

progress_data (ProgressData) – The progress data if result is next

Raises

FtpError – If the request fails. The error contains the reason for the failure.

exception mavsdk.ftp.FtpError(result, origin, *params)

Bases: Exception

Raised when a FtpResult is a fail code

class mavsdk.ftp.FtpResult(result, result_str)

Bases: object

Result type.

Parameters
  • result (Result) – Result enum value

  • result_str (std::string) – Human-readable English string describing the result

class Result(value)

Bases: enum.Enum

Possible results returned for FTP commands

UNKNOWN

Unknown result

SUCCESS

Success

NEXT

Intermediate message showing progress

TIMEOUT

Timeout

BUSY

Operation is already in progress

FILE_IO_ERROR

File IO operation error

FILE_EXISTS

File exists already

FILE_DOES_NOT_EXIST

File does not exist

FILE_PROTECTED

File is write protected

INVALID_PARAMETER

Invalid parameter

UNSUPPORTED

Unsupported command

PROTOCOL_ERROR

General protocol error

BUSY = 4
FILE_DOES_NOT_EXIST = 7
FILE_EXISTS = 6
FILE_IO_ERROR = 5
FILE_PROTECTED = 8
INVALID_PARAMETER = 9
NEXT = 2
PROTOCOL_ERROR = 11
SUCCESS = 1
TIMEOUT = 3
UNKNOWN = 0
UNSUPPORTED = 10
class mavsdk.ftp.ProgressData(bytes_transferred, total_bytes)

Bases: object

Progress data type for file transfer.

Parameters
  • bytes_transferred (uint32_t) – The number of bytes already transferred.

  • total_bytes (uint32_t) – The total bytes to transfer.