XMAVLink.Utils (xmavlink v0.4.3)

View Source

MAVLink support functions used during code generation and runtime Parts of this module are ported from corresponding implementations in mavutils.py

Summary

Functions

Helper function for messages to pack array fields

Helper function for messages to pack string fields

Parse an ip address string into a tuple

Resolve an address string to an IP address tuple.

Helper function for decode() to unpack array fields

Sort parsed message fields into wire order according to https://mavlink.io/en/guide/serialization.html List extension fields separately so that we can not include them for MAVLink 1 messages

Calculate an x25 checksum of a list or binary based on pymavlink mavcrc.x25crc

Functions

eight_bit_checksum(value)

pack_array(a, ordinality, field_packer)

@spec pack_array(list(), integer(), (any() -> binary())) :: binary()

Helper function for messages to pack array fields

pack_double(f)

pack_float(f)

pack_string(s, ordinality)

@spec pack_string(binary(), non_neg_integer()) :: binary()

Helper function for messages to pack string fields

parse_ip_address(address)

Parse an ip address string into a tuple

parse_ip_address(list, address, count)

parse_positive_integer(port)

resolve_address(address)

Resolve an address string to an IP address tuple.

Accepts both IP addresses (e.g., "192.168.1.1") and DNS hostnames (e.g., "service.namespace.svc.cluster.local").

Uses Erlang's :inet.getaddr/2 for resolution, which handles both IP addresses and DNS lookups.

Returns {:ok, ip_tuple} on success or {:error, reason} on failure.

Examples

iex> resolve_address("127.0.0.1")
{:ok, {127, 0, 0, 1}}

iex> resolve_address("localhost")
{:ok, {127, 0, 0, 1}}

unpack_array(bin, fun)

@spec unpack_array(binary(), (binary() -> {any(), list()})) :: list()

Helper function for decode() to unpack array fields

unpack_array(bin, fun, lst)

unpack_double(arg)

unpack_float(arg)

wire_order(fields)

@spec wire_order([%{type: String.t(), is_extension: boolean()}]) :: [[%{}]]

Sort parsed message fields into wire order according to https://mavlink.io/en/guide/serialization.html List extension fields separately so that we can not include them for MAVLink 1 messages

x25_crc(list)

@spec x25_crc([] | binary()) :: pos_integer()

Calculate an x25 checksum of a list or binary based on pymavlink mavcrc.x25crc

x25_crc(crc, arg2)