AutoApi.GetCommand (auto_api v13.2.0) View Source
Abstraction for a get
command in AutoApi (id 0x00
).
The struct
contains two fields:
capability
specifies the capability of the command as a Capability moduleproperties
specifies which properties are requested. An empty list indicates all properties
Link to this section Summary
Functions
Parses a command binary and returns a GetCommand struct
Returns the identifier of the command.
Returns the name of the command.
Creates a new GetCommand structure with the given capability
and properties
.
Returns the properties set in the command.
Transforms a GetCommand struct into a binary format.
Link to this section Types
Specs
properties() :: [AutoApi.Capability.property()]
Specs
t() :: %AutoApi.GetCommand{ capability: AutoApi.Capability.t(), properties: properties(), version: AutoApi.version() }
Link to this section Functions
Specs
Parses a command binary and returns a GetCommand struct
Examples
iex> Elixir.AutoApi.GetCommand.from_bin(<<0x0D, 0x00, 0x33, 0x00, 0x01, 0x04>>)
%Elixir.AutoApi.GetCommand{capability: AutoApi.DiagnosticsCapability, properties: [:mileage, :engine_rpm], version: 13}
Specs
identifier() :: byte()
Returns the identifier of the command.
Example
iex> Elixir.AutoApi.GetCommand.identifier() 0x00
Specs
name() :: AutoApi.Command.name()
Returns the name of the command.
Example
iex> Elixir.AutoApi.GetCommand.name() :get
Specs
new(AutoApi.Capability.t(), properties()) :: t()
Creates a new GetCommand structure with the given capability
and properties
.
Example
iex> capability = AutoApi.ClimateCapability
iex> properties = [:hvac_state, :defogging_state]
iex> Elixir.AutoApi.GetCommand.new(capability, properties)
%Elixir.AutoApi.GetCommand{capability: AutoApi.ClimateCapability, properties: [:hvac_state, :defogging_state]}
Specs
properties(t()) :: [AutoApi.Capability.property()]
Returns the properties set in the command.
If the command specifies all properties (that is, it is an empty list) it will return a list of the state properties as by the specifications of the capability.
Examples
iex> command = Elixir.AutoApi.GetCommand.new(AutoApi.RaceCapability, [:vehicle_moving, :gear_mode])
iex> Elixir.AutoApi.GetCommand.properties(command)
[:vehicle_moving, :gear_mode]
iex> command = Elixir.AutoApi.GetCommand.new(AutoApi.HoodCapability, [])
iex> Elixir.AutoApi.GetCommand.properties(command)
[:position, :lock, :lock_safety, :nonce, :vehicle_signature, :timestamp, :vin, :brand]
Specs
Transforms a GetCommand struct into a binary format.
If the command is somehow invalid, it returns an error.
Examples
iex> # Request the door locks state iex> command = %Elixir.AutoApi.GetCommand{capability: AutoApi.DoorsCapability, properties: [:locks_state]} iex> Elixir.AutoApi.GetCommand.to_bin(command) <<13, 0, 32, 0, 6>>
iex> # Request all properties for race state iex> command = %Elixir.AutoApi.GetCommand{capability: AutoApi.RaceCapability, properties: []} iex> Elixir.AutoApi.GetCommand.to_bin(command) <<13, 0, 87, 0>>