ArtNet.Packet.BitField.PortType (ArtNet v0.1.0)

View Source

PortType bit field used by ArtNet.Packet.ArtPollReply.

The low bits store the protocol type through ArtNet.Packet.EnumTable.PortType; the high bits indicate whether the port supports input and/or output.

Bit size

This bit field is encoded in 8 bits.

Bit layout

FieldDescriptionBitsDefaultValue
port_typeProtocol used by the port.0..5requiredArtNet.Packet.EnumTable.PortType enum (6 bits)
inputPort can receive data.6requiredboolean flag
outputPort can transmit data.7requiredboolean flag

Summary

Functions

Returns the bit-field schema in declaration order.

Returns the total number of bits encoded by this bit field.

Decodes an unsigned integer into this bit-field struct.

Encodes this bit-field struct into an unsigned integer.

Types

t()

@type t() :: %ArtNet.Packet.BitField.PortType{
  input: :boolean,
  output: :boolean,
  port_type: ArtNet.Packet.EnumTable.PortType.type()
}

Functions

bit_field_schema()

@spec bit_field_schema() :: [
  {key :: atom(),
   {ArtNet.Packet.BitField.schema_type(),
    {start_bit :: non_neg_integer(), length :: pos_integer()}}}
]

Returns the bit-field schema in declaration order.

bit_size()

@spec bit_size() :: pos_integer()

Returns the total number of bits encoded by this bit field.

This bit field is encoded in 8 bits.

decode(value)

@spec decode(non_neg_integer()) :: {:ok, t()} | :error

Decodes an unsigned integer into this bit-field struct.

encode(struct)

@spec encode(t()) :: {:ok, non_neg_integer()} | :error

Encodes this bit-field struct into an unsigned integer.