UDP/IP transport for simulator and integration endpoints.
Sends the EtherCAT payload (Bus.Frame.encode/1 output) inside a UDP datagram,
using the conventional EtherCAT UDP port 0x88A4 (34980) by default. This is
not the raw Ethernet transport used for ordinary physical EtherCAT rings;
the destination must explicitly support this encapsulation.
Implements the EtherCAT.Bus.Transport behaviour. Application startup should
select it through EtherCAT.Backend, not by opening a transport directly.
Options
:host— destination IP tuple (default:{255, 255, 255, 255}broadcast):port— local bind and destination UDP port (default:34980=0x88A4):bind_ip— optional local IP tuple; otherwise binds all local addresses
A same-host simulator must bind a different local address when sharing the
port. See EtherCAT.Simulator for a Linux loopback example.
Summary
Functions
Close the UDP socket. Returns the struct with raw set to nil.
Drain buffered datagrams and disable active delivery.
Returns nil — UDP sockets don't use OS interface link monitoring.
Match a {:udp, raw, _ip, _port, data} message from this socket.
Returns a string identifier for telemetry: "host:port".
Open a UDP socket bound to the configured port and optional local IP.
Returns true when the socket is open.
Re-arm — delegates to set_active_once/1 (UDP has no drain issue).
Send an EtherCAT payload as a UDP datagram.
Arm for one async delivery via {:active, :once}.
Returns nil — UDP has no Ethernet-level source MAC.
Types
@type t() :: %EtherCAT.Bus.Transport.UdpSocket{ host: :inet.ip_address(), port: :inet.port_number(), raw: :gen_udp.socket() | nil }
Functions
Close the UDP socket. Returns the struct with raw set to nil.
@spec drain(t()) :: :ok
Drain buffered datagrams and disable active delivery.
@spec interface(t()) :: nil
Returns nil — UDP sockets don't use OS interface link monitoring.
Match a {:udp, raw, _ip, _port, data} message from this socket.
Returns {:ok, ecat_payload, rx_at, nil} when the message belongs to this
socket. src_mac is always nil for UDP (no Ethernet headers).
This function matches socket ownership only; EtherCAT payload validation is
performed by the link/frame layer.
Returns a string identifier for telemetry: "host:port".
Open a UDP socket bound to the configured port and optional local IP.
Returns true when the socket is open.
@spec rearm(t()) :: :ok
Re-arm — delegates to set_active_once/1 (UDP has no drain issue).
Send an EtherCAT payload as a UDP datagram.
@spec set_active_once(t()) :: :ok
Arm for one async delivery via {:active, :once}.
@spec src_mac(t()) :: nil
Returns nil — UDP has no Ethernet-level source MAC.