ethercat

package
v0.807.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ethercat decodes EtherCAT (Ethernet for Control Automation Technology, IEC 61158) frames — the real-time industrial Ethernet fieldbus dominating factory automation, motion control, and robotics (Beckhoff TwinCAT, and the many EtherCAT-slave drives, I/O terminals, and servo controllers built on the ET1100/ET1200 ESC ASICs).

EtherCAT runs directly on Ethernet (EtherType 0x88A4) or, less commonly, tunnelled in UDP/34980. A master emits one Ethernet frame containing an EtherCAT header and a chain of datagrams; each datagram is processed on-the-fly by every slave as the frame passes through the daisy-chain, and the working counter is incremented by each slave that handled it. There is no authentication or encryption on the wire — a capture reveals the full process image and addressing, which is exactly what an OT pentester inspects.

Wrap-vs-native judgement

Native. The EtherCAT data-link encoding is publicly documented (IEC 61158 / ETG.1000). The frame is a 2-byte EtherCAT header (11-bit length + 4-bit type) followed by one or more fixed-format datagrams, each a 10-byte header (command, index, address, length+flags, IRQ), a length-counted data block, and a 2-byte working counter. Command and addressing dispatch is a set of small lookup tables.

What this package covers

  • EtherCAT header: 11-bit Length, 4-bit Type (1 = command/DLPDU, 4 = network variables, 5 = mailbox) with a name table.
  • Datagram chain walk: per-datagram Command (16-entry table: NOP / APRD / APWR / APRW / FPRD / FPWR / FPRW / BRD / BWR / BRW / LRD / LWR / LRW / ARMW / FRMW), Index, addressing decode (position+offset ADP/ADO for auto-increment & configured-address commands, 32-bit logical address for the logical commands), 11-bit data length with the Circulating and More-follows (M) flags, IRQ, the data block (surfaced as hex), and the Working Counter.
  • The "more datagrams follow" (M) bit chains the walk and is validated against the remaining buffer.

What this package does NOT cover (deliberately out of scope)

  • The Ethernet / UDP framing: feed the EtherCAT payload (the bytes after EtherType 0x88A4, or the UDP/34980 payload).
  • Mailbox (Type 5) protocol contents — CoE (CANopen over EtherCAT), EoE, FoE, SoE: the datagram data block is surfaced as hex; the mailbox sub-protocols are a separate walker.
  • Process-data interpretation: the data block is the raw process image / register payload; mapping it to objects needs the slave's ESI/object dictionary and is out of scope.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Datagram

type Datagram struct {
	Index          int     `json:"index"`
	Command        int     `json:"command"`
	CommandName    string  `json:"command_name"`
	WorkingCmdIdx  int     `json:"datagram_index"`
	AddressMode    string  `json:"address_mode"`
	ADP            *int    `json:"adp,omitempty"`
	ADO            *int    `json:"ado,omitempty"`
	LogicalAddress *uint32 `json:"logical_address,omitempty"`
	DataLength     int     `json:"data_length"`
	Circulating    bool    `json:"circulating,omitempty"`
	MoreFollows    bool    `json:"more_follows,omitempty"`
	IRQ            int     `json:"irq"`
	DataHex        string  `json:"data_hex,omitempty"`
	WorkingCounter int     `json:"working_counter"`
}

Datagram is one EtherCAT command datagram.

type Frame

type Frame struct {
	HexInput    string      `json:"hex_input"`
	Length      int         `json:"length"`
	Type        int         `json:"type"`
	TypeName    string      `json:"type_name"`
	Datagrams   []*Datagram `json:"datagrams,omitempty"`
	DatagramHex string      `json:"undecoded_body_hex,omitempty"`
	Notes       []string    `json:"notes,omitempty"`
}

Frame is the decoded view of an EtherCAT frame.

func Decode

func Decode(hexBlob string) (*Frame, error)

Decode parses a hex-encoded EtherCAT frame.

func DecodeBytes

func DecodeBytes(b []byte) (*Frame, error)

DecodeBytes parses a raw EtherCAT frame (the payload after EtherType 0x88A4, or the UDP/34980 payload).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL