listConnections
List all active MAVLink connections
Description
lists all active connections for the connectionTable
= listConnections(mavlink
)mavlinkio
client
connection.
Examples
Work with MAVLink Connection
This example shows how to connect to MAVLink clients, inspect the list of topics, connections, and clients, and send messages through UDP ports using the MAVLink communication protocol.
Connect to a MAVLink client using the "common.xml"
dialect. This local client communicates with any other clients through a UDP port.
dialect = mavlinkdialect("common.xml"); mavlink = mavlinkio(dialect); connect(mavlink,"UDP")
ans = "Connection1"
You can list all the active clients, connections, and topics for the MAVLink connection. Currently, there is only one client connection and no topics have received messages.
listClients(mavlink)
ans=1×4 table
SystemID ComponentID ComponentType AutopilotType
________ ___________ ______________ _______________________
255 1 "MAV_TYPE_GCS" "MAV_AUTOPILOT_INVALID"
listConnections(mavlink)
ans=1×2 table
ConnectionName ConnectionInfo
______________ ___________________
"Connection1" "UDP@0.0.0.0:39273"
listTopics(mavlink)
ans = 0x5 empty table MessageID MessageName SystemID ComponentID MessageFrequency _________ ___________ ________ ___________ ________________
Create a subscriber for receiving messages on the client. This subscriber listens for the "HEARTBEAT"
message topic with ID equal to 0
.
sub = mavlinksub(mavlink,0);
Create a "HEARTBEAT"
message using the mavlinkdialect
object. Specify payload information and send the message over the MAVLink client.
msg = createmsg(dialect,"HEARTBEAT"); msg.Payload.type(:) = enum2num(dialect,'MAV_TYPE','MAV_TYPE_QUADROTOR'); sendmsg(mavlink,msg)
Disconnect from the client.
disconnect(mavlink)
Input Arguments
mavlink
— MAVLink client connection
mavlinkio
object
MAVLink client connection, specified as a mavlinkio
object.
Output Arguments
connectionTable
— Active connection info
table
Active connection info, returned as a table with ConnectionName
and ConnectionInfo
fields for each active connection.
Version History
Introduced in R2019a
See Also
connect
| listClients
| listTopics
| mavlinkio
| mavlinkdialect
| mavlinkclient
| mavlinksub
External Websites
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)