MavlinkDirect¶
- class mavsdk.mavlink_direct.MavlinkDirect(async_plugin_manager)¶
Bases:
AsyncBase
Enable direct MAVLink communication using libmav.
Generated by dcsdkgen - MAVSDK MavlinkDirect API
- async load_custom_xml(xml_content)¶
Load custom MAVLink message definitions from XML.
This allows loading custom MAVLink message definitions at runtime, extending the available message types beyond the built-in definitions.
- Parameters:
xml_content (std::string) – The custom MAVLink XML definition content
- Raises:
MavlinkDirectError – If the request fails. The error contains the reason for the failure.
- async message(message_name)¶
Subscribe to incoming MAVLink messages.
This provides direct access to incoming MAVLink messages. Use an empty string in message_name to subscribe to all messages, or specify a message name (e.g., “HEARTBEAT”) to filter for specific message types.
- Parameters:
message_name (std::string) – MAVLink message name to filter for (e.g., “HEARTBEAT”), empty string = all messages
- Yields:
message (MavlinkMessage) – The received MAVLink message
- name = 'MavlinkDirect'¶
- async send_message(message)¶
Send a MAVLink message directly to the system.
This allows sending any MAVLink message with full control over the message content.
- Parameters:
message (MavlinkMessage) – The MAVLink message to send
- Raises:
MavlinkDirectError – If the request fails. The error contains the reason for the failure.
- exception mavsdk.mavlink_direct.MavlinkDirectError(result, origin, *params)¶
Bases:
Exception
Raised when a MavlinkDirectResult is a fail code
- class mavsdk.mavlink_direct.MavlinkDirectResult(result, result_str)¶
Bases:
object
Result type.
- Parameters:
result (Result) – Result enum value
result_str (std::string) – Human-readable English string describing the result
- class Result(value)¶
Bases:
Enum
Possible results returned for action requests.
Values¶
- UNKNOWN
Unknown result
- SUCCESS
Request succeeded
- ERROR
Error
- INVALID_MESSAGE
Invalid MAVLink message
- INVALID_FIELD
Invalid field name or value
- CONNECTION_ERROR
Connection error
- NO_SYSTEM
No system connected
- TIMEOUT
Request timed out
- CONNECTION_ERROR = 5¶
- ERROR = 2¶
- INVALID_FIELD = 4¶
- INVALID_MESSAGE = 3¶
- NO_SYSTEM = 6¶
- SUCCESS = 1¶
- TIMEOUT = 7¶
- UNKNOWN = 0¶
- class mavsdk.mavlink_direct.MavlinkMessage(message_name, system_id, component_id, target_system, target_component, fields_json)¶
Bases:
object
A complete MAVLink message with all header information and fields
- Parameters:
message_name (std::string) – MAVLink message name (e.g., “HEARTBEAT”, “GLOBAL_POSITION_INT”)
system_id (uint32_t) – System ID of the sender (for received messages)
component_id (uint32_t) – Component ID of the sender (for received messages)
target_system (uint32_t) – Target system ID (for sending, 0 for broadcast)
target_component (uint32_t) – Target component ID (for sending, 0 for broadcast)
fields_json (std::string) – All message fields as single JSON object