EtherCAT is an experimental pure-Elixir EtherCAT master. Read the module docs for
this dependency version before using it; unreleased main and published versions
may have different APIs.
- Supervise one
EtherCAT.Runtimeper BEAM node in the host application. EtherCAT.start/1returns{:ok, session}. Carry thatEtherCAT.Sessionthrough runtime, provisioning, diagnostic, subscription, and capture calls.EtherCAT.stop/1ends the session, not the host supervisor. Do not reuse stopped sessions; they return{:error, :stale_session}.- Use an explicit
:backend(EtherCAT.Backend). Physical rings use raw Ethernet; UDP is the simulator/integration transport, not a physical ESC transport.
- Without a slave list, discovery holds the ring in PREOP. Use
EtherCAT.await_ready/2, notawait_operational/2, for this workflow. - Cyclic I/O requires ordered
EtherCAT.Slave.Configentries andEtherCAT.Domain.Configentries. Domain periods are whole milliseconds, expressed in microseconds. Useawait_operational/2after requesting cyclic operation. EtherCAT.Provisioningowns PREOP configuration, activation/deactivation, and SDOs.EtherCAT.Diagnosticsowns detailed runtime inspection.EtherCAT.sample/3returns a coherent per-slave, per-domain observation; there is no cross-domain consistency guarantee. CheckSample.errorsfor decode failures. A retained sample alone is not proof that the ring is currently healthy.EtherCAT.subscribe/3returns{:ok, ref, status, samples}and pushes{:ethercat, ref, payload}with no backpressure. Pollsamples/2for latest-only consumers.EtherCAT.Signalsis the specialist signal/latch subscription API.EtherCAT.write/4stages an output;:okis not proof of physical actuation. Never hide transport, WKC, AL-state, or topology faults with optimistic state.
- Implement
EtherCAT.Driver, not a slave-runtime behaviour.signal_model/2maps named signals onto discovered PDOs;describe/1is static/offline metadata. - Codecs return
{:ok, value}/{:error, reason}. Encoding must match the declared width and zero unused high bits. Only registered directions require codecs. - Use
EtherCAT.Driver.Provisioningfor optional mailbox/sync configuration andEtherCAT.Simulator.Adapterfor separate simulator definitions. Device identity metadata is not automatic hardware compatibility enforcement. - Start with deterministic
EtherCAT.Simulatortests. Raw-socket and hardware tests need explicit interface setup and privileges; never run them on a production ring. - Distributed Clocks synchronize device clocks; they do not make BEAM scheduling hard real-time or guarantee that PDO frames arrive before a device deadline.