An EtherCAT frame: a header of two bytes, with the length of what follows and its type, then one or more datagrams (ETG.1000.4, 5.3). It goes in an Ethernet frame of EtherType 0x88A4, or in a UDP datagram to port 0x88A4 (34980).
iex> frame = EtherCAT.Frame.encode([%{EtherCAT.Datagram.new({:brd, 0x0000, 1}) | index: 7}])
<<13, 0x10, 0x07, 7, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0>>
iex> {:ok, [datagram]} = EtherCAT.Frame.decode(frame)
iex> datagram.command
:brdOnly frames of datagrams are this library's: the spec's network variables (type 4) and mailbox frames (type 5) are decoded no further than their type.
Summary
Functions
The datagrams of a frame. What follows its length, such as padding, is passed over.
The frame of some datagrams, next set in all but the last. Raises ArgumentError when they don't
fit in one.
The EtherType of EtherCAT frames, and the UDP port they go to.
The EtherCAT frame in an Ethernet frame, with the source address, or :error for an Ethernet frame
of another EtherType. A VLAN tag is passed over.
The bytes of datagrams a frame can take.
An EtherCAT frame in an Ethernet frame from source, a MAC address of six bytes, to the broadcast
address, padded to the least Ethernet allows.
Types
Functions
@spec decode(binary()) :: {:ok, [EtherCAT.Datagram.t()]} | {:error, {:type, type()} | :invalid_length | :invalid_command}
The datagrams of a frame. What follows its length, such as padding, is passed over.
{:ok, datagrams}{:error, {:type, type}}for a frame of another type than datagrams{:error, :invalid_length},{:error, :invalid_command}for one that isn't a frame
@spec encode([EtherCAT.Datagram.t()]) :: binary()
The frame of some datagrams, next set in all but the last. Raises ArgumentError when they don't
fit in one.
@spec ethertype() :: 34980
The EtherType of EtherCAT frames, and the UDP port they go to.
The EtherCAT frame in an Ethernet frame, with the source address, or :error for an Ethernet frame
of another EtherType. A VLAN tag is passed over.
@spec max_size() :: pos_integer()
The bytes of datagrams a frame can take.
An EtherCAT frame in an Ethernet frame from source, a MAC address of six bytes, to the broadcast
address, padded to the least Ethernet allows.