-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #701 from mavlink/pr-example-list-dir
Add example how to list directory
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |