Skip to content

Commit 4b4981b

Browse files
authored
Merge pull request #465 from danylevskyi/send_status_message
Add example for server_utility plugin
2 parents 3d0b7dd + 3679e75 commit 4b4981b

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

examples/send_status_message.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env python3
2+
3+
import asyncio
4+
from mavsdk import System
5+
from mavsdk.server_utility import StatusTextType
6+
7+
"""
8+
This example shows how to use server_utility plugin to send status messages.
9+
10+
The messages will appear in GCS log. In order to debug messages you can use:
11+
- QGroundControll MAVLink Inspector
12+
- Wireshark (https://mavlink.io/en/guide/wireshark.html)
13+
14+
In this example we are changing sysid in order to show our message along the
15+
other messages in QGroundControll interface.
16+
"""
17+
18+
19+
async def run():
20+
21+
drone = System(sysid=1)
22+
await drone.connect(system_address="udp://:14540")
23+
24+
print("Waiting for drone to connect...")
25+
async for state in drone.core.connection_state():
26+
if state.is_connected:
27+
print(f"-- Connected to drone!")
28+
await drone.server_utility.send_status_text(StatusTextType.INFO, "Hello world!")
29+
break
30+
31+
if __name__ == "__main__":
32+
loop = asyncio.get_event_loop()
33+
loop.run_until_complete(run())

0 commit comments

Comments
 (0)