Current section
Files
Jump to
Current section
Files
kino_ethercat
usage-rules.md
usage-rules.md
# Rules for working with KinoEtherCAT
KinoEtherCAT provides Livebook Smart Cells, runtime views, and signal widgets for
EtherCAT. KinoEtherCAT 0.5 uses `ethercat ~> 0.5.0` and its session-based API.
- Use `KinoEtherCAT.master/0`, `slave/1`, `domain/1`, `bus/0`, and `dc/0` for
renderable runtime resources, and `diagnostics/0` for an overview.
- Use `KinoEtherCAT.Widgets.led/3`, `switch/3`, `value/3`, `panel/2`, and
`dashboard/2` for signal and slave widgets. Slave and signal names are atoms
from the configured master. Read the function docs before choosing options.
- KinoEtherCAT supervises `EtherCAT.Runtime` by default. If the host application
already supervises it, configure `:kino_ethercat, supervise_runtime: false`.
- Starting a master returns `{:ok, session} = EtherCAT.start(backend: backend, ...)`.
Use canonical backends such as `{:raw, %{interface: "eth0"}}` or
`{:udp, %{host: {127, 0, 0, 2}, port: 34980}}`. Wait with
`EtherCAT.await_ready(session)` and `EtherCAT.await_operational(session)`.
- Resolve an existing session with `EtherCAT.Session.current/0`. Pass it to
`EtherCAT.read/3`, `EtherCAT.write/4`, `EtherCAT.Diagnostics`, and
`EtherCAT.Provisioning` operations. Reads return `{:ok, {value, timestamp_us}}`.
- Signal widgets and slave panels retain their original session. Re-evaluate
their cells after restarting the master; do not silently retarget writes.
- Custom drivers implement `EtherCAT.Driver`, return named
`%EtherCAT.Driver.Signal{}` mappings from `signal_model/2`, and return
`{:ok, value}` or `{:error, reason}` from codecs. Provide `describe/1` endpoint
metadata for the UI. Simulator companions implement `EtherCAT.Simulator.Adapter`.