Skip to content

Commit

Permalink
Merge pull request #701 from mavlink/pr-example-list-dir
Browse files Browse the repository at this point in the history
Add example how to list directory
  • Loading branch information
julianoes authored May 22, 2024
2 parents da24c3c + 4e59416 commit 7a78033
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 7a78033

Please sign in to comment.