Skip to content

Commit

Permalink
Add FTP examples
Browse files Browse the repository at this point in the history
  • Loading branch information
julianoes committed May 22, 2024
1 parent da24c3c commit 4e59416
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
26 changes: 26 additions & 0 deletions examples/ftp_download_file.py
Original file line number Diff line number Diff line change
@@ -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())
23 changes: 23 additions & 0 deletions examples/ftp_list_dir.py
Original file line number Diff line number Diff line change
@@ -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())

0 comments on commit 4e59416

Please sign in to comment.