EtherCAT.Transport behaviour (yaethercat v0.1.0)

Copy Markdown View Source

How EtherCAT frames get to the SubDevices and back: the behaviour of a transport, which an EtherCAT.MainDevice opens and owns.

A transport takes and gives EtherCAT frames, from their header of two bytes on; the Ethernet or UDP around them is its own business. What it receives comes to the process that opened it as messages, which that process hands to handle/2.

Summary

Types

t()

A transport's own state.

Callbacks

Closes the transport.

Takes a message the process received: the EtherCAT frames it brought, none or more, with the transport's state; an error when the transport is gone; or :ignore for a message that isn't the transport's.

Opens the transport, in the process that will receive its frames.

Sends an EtherCAT frame.

Functions

The transport for an interface on this operating system: EtherCAT.Transport.Packet on Linux and EtherCAT.Transport.BPF on macOS.

Types

t()

@type t() :: term()

A transport's own state.

Callbacks

close(t)

@callback close(t()) :: :ok

Closes the transport.

handle(t, term)

@callback handle(t(), term()) :: {:ok, [binary()], t()} | {:error, term()} | :ignore

Takes a message the process received: the EtherCAT frames it brought, none or more, with the transport's state; an error when the transport is gone; or :ignore for a message that isn't the transport's.

open(keyword)

@callback open(keyword()) :: {:ok, t()} | {:error, term()}

Opens the transport, in the process that will receive its frames.

send(t, binary)

@callback send(t(), binary()) :: :ok | {:error, term()}

Sends an EtherCAT frame.

Functions

raw()

@spec raw() :: module()

The transport for an interface on this operating system: EtherCAT.Transport.Packet on Linux and EtherCAT.Transport.BPF on macOS.