Skip to content

Commit 108cb85

Browse files
Merge pull request #467 from mavlink/pr-add-statustext
takeoff_and_land: print statustext
2 parents 4b4981b + 7205076 commit 108cb85

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

examples/takeoff_and_land.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ async def run():
99
drone = System()
1010
await drone.connect(system_address="udp://:14540")
1111

12+
status_text_task = asyncio.ensure_future(print_status_text(drone))
13+
1214
print("Waiting for drone to connect...")
1315
async for state in drone.core.connection_state():
1416
if state.is_connected:
@@ -32,6 +34,18 @@ async def run():
3234
print("-- Landing")
3335
await drone.action.land()
3436

37+
status_text_task.cancel()
38+
39+
40+
41+
async def print_status_text(drone):
42+
try:
43+
async for status_text in drone.telemetry.status_text():
44+
print(f"Status: {status_text.type}: {status_text.text}")
45+
except asyncio.CancelledError:
46+
return
47+
48+
3549
if __name__ == "__main__":
3650
loop = asyncio.get_event_loop()
3751
loop.run_until_complete(run())

0 commit comments

Comments
 (0)