MAVLink's command protocol: a COMMAND_LONG or COMMAND_INT to a
target, answered by COMMAND_ACK.
MAVLink2.Command.long(link, {1, 1}, :mav_cmd_component_arm_disarm, [1.0])
#=> {:ok, :mav_result_accepted, %MyDialect.CommandAck{...}}The link's dialect must have the messages (common.xml does). target
is {sysid, compid}; compid 0 accepts the reply from any component of the
system. command is a MAV_CMD entry atom or its value.
With no ack in :timeout, the command is sent again, up to :retries
more times; a COMMAND_LONG sent again has its confirmation counted up.
An ack of MAV_RESULT_IN_PROGRESS stops the resending: each one goes to
:on_progress, and the wait for the final ack restarts at
:progress_timeout. cancel/3 asks the target to stop a long-running
command.
Options:
:timeout | ms to wait for an ack before sending again (default 1000) |
:retries | times to send again (default 3) |
:progress_timeout | ms to wait after an in-progress ack (default 5000) |
:on_progress | called with each in-progress ack |
Returns {:ok, result, ack}, with result the MAV_RESULT entry atom
(:mav_result_accepted, :mav_result_denied, ...) and ack the decoded
COMMAND_ACK, or {:error, :timeout}.
Summary
Functions
Sends COMMAND_CANCEL for a long-running command the target is
executing. It is not acked: the long/5 or int/5 call waiting on the
command returns with the target's final ack, :mav_result_cancelled if
it cancelled. A target that cannot cancel carries on, and one with
nothing running ignores it. The dialect must have COMMAND_CANCEL
(current common.xml does).
Sends COMMAND_INT. fields are its fields other than the target and
command: :frame (a MAV_FRAME atom or value), :param1..:param4,
:x, :y (integers, degrees × 10^7 for a global frame), :z,
:current, :autocontinue; each defaults to 0.
Sends COMMAND_LONG with up to seven params (the rest 0.0).
Functions
@spec cancel(GenServer.server(), MAVLink2.target(), atom() | integer()) :: :ok | {:error, term()}
Sends COMMAND_CANCEL for a long-running command the target is
executing. It is not acked: the long/5 or int/5 call waiting on the
command returns with the target's final ack, :mav_result_cancelled if
it cancelled. A target that cannot cancel carries on, and one with
nothing running ignores it. The dialect must have COMMAND_CANCEL
(current common.xml does).
@spec int( GenServer.server(), MAVLink2.target(), atom() | integer(), keyword(), keyword() ) :: {:ok, atom() | integer(), struct()} | {:error, term()}
Sends COMMAND_INT. fields are its fields other than the target and
command: :frame (a MAV_FRAME atom or value), :param1..:param4,
:x, :y (integers, degrees × 10^7 for a global frame), :z,
:current, :autocontinue; each defaults to 0.
@spec long( GenServer.server(), MAVLink2.target(), atom() | integer(), [number()], keyword() ) :: {:ok, atom() | integer(), struct()} | {:error, term()}
Sends COMMAND_LONG with up to seven params (the rest 0.0).