listConnections
R2026bList all active MAVLink connections
Description
lists all active connections for the connectionTable = listConnections(mavlink)mavlinkio client
connection.
Examples
Connect a local MAVLink client to QGroundControl by exchanging heartbeat messages over UDP,
Open QGroundControl.

Create a mavlinkdialect object using the common.xml file.
dialect = mavlinkdialect("common.xml");Create a local MAVLink client that represents a simulated UAV by creating a mavlinkio object with these settings:
MAVLink message definition —
dialectMAVLink system ID —
1MAVLink component ID —
1MAVLink component type —
MAV_TYPE_QUADROTORMAVLink autopilot type —
MAV_AUTOPILOT_GENERIC
uav = mavlinkio(dialect,SystemID=1,ComponentID=1,AutopilotType="MAV_AUTOPILOT_GENERIC", ... ComponentType="MAV_TYPE_QUADROTOR");
Store the remote MAVLink client information that represents QGroundControl. By default, QGroundControl has a system ID of 255 and a component ID of 190.
qgc = mavlinkclient(uav,255,190);
Connect the local MAVLink client to a UDP port by using the connect function.
connect(uav,"UDP");Verify that the local MAVLink client has connected to a UDP port by using the listConnections function.
connectionTable = listConnections(uav)
connectionTable =
1x2 table
ConnectionName ConnectionInfo
______________ ___________________
"Connection1" "UDP@0.0.0.0:55371"Create a heartbeat microservice object.
heartbeat = mavlinkmicroservice(uav,"heartbeat");Specify the host address and port of QGroundControl.
qgcHost = "127.0.0.1";
qgcPort = 14550;Start sending heartbeat messages to QGroundControl by using the start function.
start(heartbeat,qgc,"UDP",RemoteHost=qgcHost,RemotePort=qgcPort);If QGroundControl replies with heartbeat messages, the local MAVLink client establishes a connection to it.

Verify that the connection has been established by using the listClients
function.
listClients(uav)
ans = 2×4 table
SystemID ComponentID ComponentType AutopilotType
________ ___________ ____________________ _______________________
255 190 "MAV_TYPE_GCS" "MAV_AUTOPILOT_INVALID"
1 1 "MAV_TYPE_QUADROTOR" "MAV_AUTOPILOT_GENERIC"To stop the connection, first stop the heartbeat message stream.
stop(heartbeat,gcs)
Then, disconnect the local MAVLink client from the UDP port.
disconnect(uav)
Input Arguments
Local MAVLink client, specified as a mavlinkio object.
Output Arguments
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 Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.
Amériques
- 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)