Raw AF_PACKET socket transport for EtherCAT.
Sends and receives full Ethernet frames with EtherType 0x88A4.
Implements the EtherCAT.Bus.Transport behaviour.
Uses sysfs for MAC address lookup and :net for interface index.
The EtherCAT payload (from Bus.Frame.encode/1) is wrapped in a standard
Ethernet frame internally — callers only deal with EtherCAT payloads.
On Linux this transport enables PACKET_IGNORE_OUTGOING so the kernel does
not loop the process' own transmitted EtherCAT frames back to the socket.
Summary
Functions
Close the underlying socket. Returns the struct with raw set to nil.
Drain all frames in the socket buffer; cancel any lingering select.
Returns the interface name used by the bus link monitor.
Match a {:"$socket", raw, :select, _} message from this socket.
Returns the network interface name for telemetry and link monitoring.
Open a raw AF_PACKET socket bound to the given interface.
Returns true when the socket handle is open.
Re-arm without draining — self-sends a select notification.
Send an EtherCAT payload wrapped in an Ethernet frame.
Arm for one async receive via :socket select mechanism.
Returns this NIC's source MAC address (6 bytes).
Types
@type t() :: %EtherCAT.Bus.Transport.RawSocket{ ifindex: non_neg_integer(), interface: String.t(), raw: :socket.socket() | nil, src_mac: <<_::48>> }
Functions
Close the underlying socket. Returns the struct with raw set to nil.
@spec drain(t()) :: :ok
Drain all frames in the socket buffer; cancel any lingering select.
Returns the interface name used by the bus link monitor.
Match a {:"$socket", raw, :select, _} message from this socket.
When matched, calls recvmsg internally to read the frame, strips the
Ethernet headers, and returns the EtherCAT payload with an rx timestamp
and the frame's source MAC address (6 bytes).
Returns :ignore for all other messages or non-EtherCAT frames.
Returns the network interface name for telemetry and link monitoring.
Open a raw AF_PACKET socket bound to the given interface.
Returns true when the socket handle is open.
@spec rearm(t()) :: :ok
Re-arm without draining — self-sends a select notification.
Send an EtherCAT payload wrapped in an Ethernet frame.
@spec set_active_once(t()) :: :ok
Arm for one async receive via :socket select mechanism.
@spec src_mac(t()) :: <<_::48>>
Returns this NIC's source MAC address (6 bytes).