diff --git a/examples/ftp_download_file.py b/examples/ftp_download_file.py new file mode 100755 index 00000000..f20a6909 --- /dev/null +++ b/examples/ftp_download_file.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 + +import asyncio +from mavsdk import System + + +async def run(): + + drone = System(mavsdk_server_address="localhost", port=50051) + await drone.connect(system_address="serial:///dev/ttyACM0:57600") + + print("Waiting for drone to connect...") + async for state in drone.core.connection_state(): + if state.is_connected: + print(f"-- Connected to drone!") + break + + async for update in drone.ftp.download( + "/etc/extras/px4_io-v2_default.bin", ".", use_burst=False + ): + print(f"Got {update.bytes_transferred} of {update.total_bytes} bytes") + + +if __name__ == "__main__": + # Run the asyncio loop + asyncio.run(run()) diff --git a/examples/ftp_list_dir.py b/examples/ftp_list_dir.py new file mode 100755 index 00000000..0c8a85a3 --- /dev/null +++ b/examples/ftp_list_dir.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 + +import asyncio +from mavsdk import System + + +async def run(): + + drone = System(mavsdk_server_address='localhost', port=50051) + await drone.connect(system_address="serial:///dev/ttyACM0:57600") + + print("Waiting for drone to connect...") + async for state in drone.core.connection_state(): + if state.is_connected: + print(f"-- Connected to drone!") + break + + print("directory list", await drone.ftp.list_directory("/")) + + +if __name__ == "__main__": + # Run the asyncio loop + asyncio.run(run())