Ftp¶
- class mavsdk.ftp.Ftp(async_plugin_manager)¶
Bases:
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.
- async download(remote_file_path, local_dir, use_burst)¶
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.
use_burst (bool) – Use burst for faster downloading.
- 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 list_directory(remote_dir)¶
Lists items from a remote directory.
- Parameters:
remote_dir (std::string) – The remote directory to list the contents for.
- Returns:
data – The found directories and files.
- Return type:
- 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 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.
- async 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
Possible results returned for FTP commands
Values¶
- 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
- NO_SYSTEM
No system connected
- BUSY = 4¶
- FILE_DOES_NOT_EXIST = 7¶
- FILE_EXISTS = 6¶
- FILE_IO_ERROR = 5¶
- FILE_PROTECTED = 8¶
- INVALID_PARAMETER = 9¶
- NEXT = 2¶
- NO_SYSTEM = 12¶
- PROTOCOL_ERROR = 11¶
- SUCCESS = 1¶
- TIMEOUT = 3¶
- UNKNOWN = 0¶
- UNSUPPORTED = 10¶
- class mavsdk.ftp.ListDirectoryData(dirs, files)¶
Bases:
object
The output of a directory list
- Parameters:
dirs ([std::string]) – The found directories.
files ([std::string]) – The found files.
- 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.