EtherCAT.Diagnostics (ethercat v0.5.0)

Copy Markdown View Source

Session-bound inspection and diagnostic API.

Normal protocol-level runtime usage should stay on EtherCAT. This module is for topology inspection, DC status, slave/domain details, and lower-level runtime visibility. Every query requires its owning %EtherCAT.Session{}.

Master status, domain lists, and DC queries collect live observations in the caller under a shared one-second timeout budget. An unavailable worker returns {:error, {:diagnostic_unavailable, source, reason}}, where source is :bus, :dc, or {:domain, id}. The session is revalidated after collection; results from a stopped or replaced generation return {:error, :stale_session}.

Choose the narrowest query you need:

QueryUse
master_status/1Session target, activation/recovery faults, and subsystem observations
slaves/1Discovered/configured slave summary
slave_info/2One slave's AL state, identity, registrations, and runtime details
domain_info/2One domain's cycle health, counters, and invalid reason
dc_status/1DC lock state and synchronization diagnostics
last_failure/1Retained master failure information, when present

Diagnostic collection is not an atomic snapshot of the entire ring. An operational master can still track non-critical slave-local faults; inspect the returned fault fields rather than using its state as machine readiness. For static/offline metadata use EtherCAT.describe/2 or EtherCAT.inventory/1.

Summary

Functions

bus(session)

dc_status(session)

domain_info(session, domain_id)

@spec domain_info(EtherCAT.Session.t(), atom()) :: {:ok, map()} | {:error, term()}

domains(session)

last_failure(session)

@spec last_failure(EtherCAT.Session.t()) :: EtherCAT.session_query_result(map() | nil)

master_status(session)

@spec master_status(EtherCAT.Session.t()) ::
  {:ok, EtherCAT.Master.Status.t()} | {:error, term()}

reference_clock(session)

@spec reference_clock(EtherCAT.Session.t()) ::
  {:ok, %{name: atom() | nil, station: non_neg_integer()}} | {:error, term()}

slave_info(session, slave_name)

@spec slave_info(EtherCAT.Session.t(), atom()) :: {:ok, map()} | {:error, term()}

slaves(session)