Skip to main content

Slave properties and methods

Accessed through master.Slaves[n] (0-based index).​

tip
  • PDO I/O (primary path slave.PDO.InputsMapping / OutputsMapping, mapped once and pinned; CopyInputPdo / WriteOutputPdo are snapshots).

Properties​

CategoryPropertyTypeRead/writeDescription
Basic identificationSlaveNumushortread-onlySlave index (1-based)
Indexintread-onlySlave index (alias of SlaveNum)
Namestringread-onlyDevice name (read from the EEPROM group_name)
DriveNamestringread-onlyDrive/device name (read from the SII EEPROM device_name)
Device informationVendorIduintread-onlyManufacturer ID (read from the SII EEPROM)
VendorNamestring?read-onlyManufacturer name (read from the ESI file)
ProductIduintread-onlyProduct ID
RevIduintread-onlyRevision number
Revisionuintread-onlyAlias of RevId (revision number)
SerialNumberuintread-onlySerial number (native runtime identity snapshot). Cold configuration reads the SER word only for slaves that did not match an ESI; slaves that matched an ESI stay at 0 — 0 does not mean "the device serial number really is 0", and it does not mean a read failure; for the EEPROM real value with those two cases distinguished, use TryGetSerialNumber or Sii.TryReadIdentity
HasMDPboolread-onlyWhether the modular device profile is supported (ETG.5001)
IsMdpDeviceboolread-onlyWhether this is an MDP modular device (the ESI declares Slots definitions); false when there is no ESI / the ESI has no Slots / initialization fails. Division of labour with HasMDP: this property looks only at the ESI declaration, while HasMDP looks at device capability and actual reachability
BlockLRWboolread-onlyLRW logical read/write blocking flag
AddressConfigAddrushortread-onlyPhysical configuration address
AliasAddressushortread-onlyAlias address
StateStateEcStateread-onlyCurrent slave state
StatusEcSlaveStatusread-onlyComplete slave status (keeps the Error bit, composite enum), such as OpFault/SafeOpFault; recommended for UI and logs; same numeric value as State, only the type differs
ErrorCodeEcALStateread-onlyError code (AL Status Code). Read from the full 16-bit ALstatuscode in the slave structure (the state machine refreshes it from 0x0134 on demand); it is not the AL mirror's high byte
IsLostboolread-onlyWhether the slave is lost (reliable offline state confirmed by events)
LivenessSlaveLivenessStateread-onlyLiveness three-state: Alive = confirmed alive / Lost = confirmed offline / Unknown = insufficient evidence. IsLost only answers "is it confirmed lost"; use this property to tell "insufficient evidence"
OfflineReasonSlaveOfflineReasonread-onlyOffline reason classification: RealOffline = truly offline / Unreachable = not confirmed by the server — the server/probe did not see it, but the process data proves it is still contributing (not a confirmed offline) / Unknown = insufficient evidence; the same verdict source as the truth row
OutOfOpSinceUtcDateTime?read-onlyStart time of the out-of-OP period (UTC) during this run: latched by the state change event on the OP→non-OP edge and cleared after re-entering OP. null = currently in OP / never entered OP / no edge observed yet (it does not mean "it never dropped out")
OutOfOpDurationTimeSpan?read-onlyHow long it has continuously been out of OP (current UTC - OutOfOpSinceUtc); null has the same meaning as OutOfOpSinceUtc
OutOfOpDurationMslong?read-onlyMonotonic duration the slave has continuously been out of OP (ms); system clock changes do not affect this value. null = no provable start of the out-of-OP period
HasEnteredOperationalboolread-onlyWhether this slave has ever entered OP during this run (latches to true once it has, even if it drops out later)
DroppedFromOperationalboolread-onlyWhether it "entered OP but is not in OP now" (dropped out of OP at runtime; the hot-plug observability surface)
Real-time diagnosticsWcContributedWcContributionread-onlyThis slave's contribution state to the working counter (WKC) in the current cycle; reading it returns the current bus result with no refresh call
InputDataValidityPdoInputValidityread-onlyFour-state validity of the input process data: Valid = this cycle's data is valid; Degraded = this cycle has no full evidence (the group's inputs are incomplete for this cycle; on a single dropped frame / WKC=0 the data is the previous valid frame (last-good); when some slaves are missing, the input bytes of the absent slave and everything downstream may be the process-image initial values established at startup, do not treat it as definitely trustworthy); Stale = cannot be used as the current value; Unknown = no evidence. Use this property to decide "can this frame of data be used"; use IsLost to decide "has the slave been confirmed offline"
AlStatusMirrorEcSlaveStatusread-onlyLow byte of the AL status (including the Error bit); supports .Pretty()/.HasFault(). It is a cache sampled by the master while in OP, not the live truth at read time — see the sampling semantics below
AlStatusCodeEcALStateread-onlyDecoded from the AL mirror's high byte (low 8 bits, present only when the Error bit is set and the code differs from 0; codes ≥0x0100 are already truncated). Returns NoError when there is no Error; returns Unknown when not sampled, and also when the Error bit is set but the mirror's high byte is 0 — the SDK never reports "unknown" as NoError. Use ErrorCode for the full 16-bit code
StateLiveReadLiveReadread-onlyLive state read (forces one real read) plus four-state trust; Value is the raw AL Status byte (low 4 bits = base state, bit4 = Error), usable as the current state only when IsValid. Use State / Status for the cached view
StateLiveEcState?read-onlyConvenience entry point for StateLiveRead: gives a value only when Valid, otherwise null. null = there is no trustworthy current state; it is not INIT and not "confirmed no error"
ALStatusCodeLiveReadLiveReadread-onlyLive AL Status Code (lossless 16-bit) plus four-state trust. When the slave is lost / not responding native returns 0; this entry point files it as Stale and never reports it as NoError
ALStatusCodeLiveushort?read-onlyConvenience entry point for ALStatusCodeLiveRead: gives the full 16-bit code only when Valid, otherwise null. null = there is no trustworthy current AL code, not "no error"
MailboxHealthEcMailboxHealthread-onlyMailbox health of this slave (Unknown/Healthy/Degraded), making "in OP but the mailbox half-fails" visible
IsFreeRunDemotedboolread-onlyWhether this slave was forced to fall back from DC to FreeRun sync mode (the observation point for the root cause of half-failures)
HealthDegradedCountuintread-onlyConsecutive accumulated count of mailbox half-failures on this slave (roughly seconds; 0 = healthy)
TopologyLinkCountintread-onlyMeasured link count for the current sample, refreshed about every 200 ms: 1..4 = measured number of connections, -1 = unknown or invalid argument; unknown does not mean offline. Topology is only its compatibility byte projection (0..4 = number of connections, everything else including -1 → 0xFF unknown) and is not a structural classification.
TopologyTopologyTypeintread-onlyConfiguration-time topology structure classification snapshot: 0 = no link / 1 = endpoint / 2 = line intermediate node / 3 = fork / 4 = cross; -1 = unavailable (the SDK returns 0xFF or an out-of-range value outside 0..4). It is fixed once during configuration and is not refreshed at runtime; unplugging a cable or a slave drop does not change it. It is not interchangeable with LinkCount: structural decisions (project save, startup structure validation) read this property, while live display reads LinkCount. This is the only place the structure classification is read; there is no separate query method of the same name.
ParentStationushortread-onlyStation address of the parent slave (note: this is actually the 1-based slave index, not the station address; 0 means the parent is the master)
ParentPortintread-onlyParent port number: 0..3, -1 = unknown or invalid argument; unknown does not mean P0
EntryPortbyteread-onlyEntry port number
ActivePortsbyteread-onlyActive port bitmask
PhysicalTypebyteread-onlyPhysical port type
ChildCountintread-onlyNumber of child modules
PDO dataIbits / Obitsushortread-onlyInput/output data bit count
Ibytes / Obytesuintread-onlyInput/output data byte count
InputsByteCount / OutputsByteCountintread-onlyMapped byte count of the current input/output process image (0 when not in OP / not mapped)
Ioffset / Ooffsetuintread-onlyInput/output data offset
Istartbit / Ostartbitbyteread-onlyInput/output start bit
ESI/configurationHasEsiDcSyncboolread-onlyWhether the ESI declares DC sync; check both HasDC && HasEsiDcSync before enabling DC
EEPROMEep8ByteAddressingboolread-onlyEEPROM addressing mode (true = 8-byte, false = 4-byte)
EepPDIbyteread-onlyPhysical device interface (PDI) type
EbusCurrentshortread-onlyE-bus current consumption (mA)
MailboxMbxProtoMailboxProtocolread-onlySupported mailbox protocol capability bitmap (SII mbx_proto: bit0 = AoE, bit1 = EoE, bit2 = CoE, bit3 = FoE, bit4 = SoE, bit5 = VoE)
CoESupport, EoESupport, SoESupport, AoESupport, VoESupportbool?read-onlyTri-state capability of each protocol: true = supported, false = actually read and confirmed not declared, null = unknown (read failed); see GetMailboxProtocolSupport
MbxLengthushortread-onlyMailbox send buffer size
MbxReadLengthushortread-onlyMailbox receive buffer size
MbxReadOffset / MbxWriteOffsetushortread-onlyMailbox read/write offset
MbxCountbyteread-onlyMailbox counter (the Cnt field in the mailbox frame header)
Protocol detailsCoEdetailsEcCoEDetailsread-onlyCoE protocol feature flags (SDO / PDO Assign / Complete Access, etc.)
EoEdetailsEcEoEDetailsread-onlyEoE protocol feature flags (send frame / receive frame / IP parameters, etc.)
FoEdetailsbyteread-onlyFoE protocol details (from the SII EEPROM)
SoEdetailsbyteread-onlySoE protocol details (from the SII EEPROM)
FMMUFMMU0Functionbyteread-onlyFMMU0 function type (bit 0 = output, bit 1 = input)
FMMU1Functionbyteread-onlyFMMU1 function type
FMMU2Functionbyteread-onlyFMMU2 function type
FMMU3Functionbyteread-onlyFMMU3 function type
DCHasDCboolread-onlyWhether DC is supported
DCActiveushortread-onlyEffective value of 0x0980 AssignActivate (0 = not enabled, other than 0 = DC-active). A value other than 0 does not mean armed or synchronized: arming is reported by Sync0Armed, synchronization by the InSync / Applicable windows
DCCycle0intread-onlySYNC0 cycle (nanoseconds)
DCCycle1intread-onlySYNC1 cycle (nanoseconds)
DCShiftintread-onlyPhase shift (nanoseconds)
PropagationDelayintread-onlyPropagation delay of a frame from the master to this slave (nanoseconds)
PDelayintread-onlyAlias of PropagationDelay, propagation delay (nanoseconds)
DCNextushortread-onlyIndex of the next slave in the DC chain
DCPreviousushortread-onlyIndex of the previous slave in the DC chain
DCParentPortintread-onlyCompatibility entry point for ParentPort; also 0..3 / -1, not a separate DC-specific field
DCReceiveTimeAintread-onlyPort A receive time (nanoseconds)
DCReceiveTimeBintread-onlyPort B receive time (nanoseconds)
DCReceiveTimeCintread-onlyPort C receive time (nanoseconds)
DCReceiveTimeDintread-onlyPort D receive time (nanoseconds)
Topology extensionsChildrenList<Slave>read-onlyList of child slaves (used with ChildCount to navigate the topology tree)
SupportsFrameRepeatboolread-onlyWhether frame repeating is supported (ETG.1500 5.4.3)
RedundancyRedundancyActivatedboolread-onlyRedundancy protection is active = the master-level RedundancyRingMode is Dual or Degraded; always false for linear / end fold-back topologies, and not an independent per-slave conclusion
PrimaryLinkBrokenboolread-onlyWhether the primary link is broken
SecondaryLinkBrokenboolread-onlyWhether the secondary link is broken
ConfigurationGroupbyteread/writeSlave group number (0-7; 0 = unassigned and automatically placed in group 1 before mapping; valid PDO groups are 1-7 and must be set before SAFE_OP)
IsOptionalboolread/writeOptional-slave flag; when absent it does not affect the WKC check and does not raise a group offline alarm (must be set before OP)
Configuration sourceConfigSourceConfigSourceread-onlyConfiguration source declared for this slave: Eni / Deni; the default is Unknown = never declared. This is SDK-side declaration state, not a native read-back; to write it see SetConfigSource()

MbxProto returns the SII mbx_proto capability bitmap ([Flags] enum MailboxProtocol: AoE = 0x01, EoE = 0x02, CoE = 0x04, FoE = 0x08, SoE = 0x10, VoE = 0x20), not the mailbox frame-header type code MailboxType (the old MailboxType MbxProto form is obsolete). Test capabilities with SupportsCoE() / SupportsFoE() / SupportsEoE() / SupportsSoE() / SupportsAoE() / SupportsVoE(), or compare the bit directly: (slave.MbxProto & MailboxProtocol.CoE) != 0.

EcTopologyType / EcPortType enum values
public enum EcTopologyType : byte
{
NoLink = 0, // no link
EndPoint = 1, // endpoint
Line = 2, // intermediate node (line topology)
Fork = 3, // fork
Cross = 4 // cross
}

public enum EcPortType : byte
{
NotUsed = 0, // unused
MII = 1, // MII
EBUS = 2, // EBUS
EBUSEnhanced = 3 // EBUS enhanced
}

Topology structure classification is read from public properties

CategoryMemberTypeRead/writeDescription
Topologyslave.TopologyTypeintread-onlyConfiguration-time structure classification snapshot: 0 = no link / 1 = endpoint / 2 = line intermediate node / 3 = fork / 4 = cross; -1 = unavailable (reads back 0xFF or an out-of-range value outside 0..4). Fixed once during configuration and not refreshed at runtime
Topologyslave.Topologybyteread-onlyCompatibility byte projection of LinkCount (0..4 = number of connections, everything else 0xFF = unknown); not a structural classification
Topologyslave.LinkCountintread-onlyMeasured link count for the current sample, refreshed about every 200 ms: 1..4 = measured number of connections, -1 = unknown or invalid argument
Unknown values are not 0

EcTopologyType has no Unknown member. TopologyType returning -1 means it cannot be read or the value is outside 0..4 — treat it as "unknown"; do not fold it into NoLink.

MailboxType enum values
public enum MailboxType : ushort
{
ErrorMailbox = 0x00, // error mailbox
ADSOverEtherCAT = 0x01, // AoE
EthernetOverEtherCAT = 0x02, // EoE
CANopenOverEtherCAT = 0x03, // CoE
FileOverEtherCAT = 0x04, // FoE
ServoOverEtherCAT = 0x05, // SoE
VendorOverEtherCAT = 0x0F // VoE
}
EcCoEDetails enum values
[Flags]
public enum EcCoEDetails : byte
{
None = 0x00,
SDO = 0x01, // supports SDO
SDOInfo = 0x02, // supports SDO Info
PDOAssign = 0x04, // supports PDO Assign
PDOConfig = 0x08, // supports PDO Config
Startup = 0x10, // supports Startup
CompleteAccess = 0x20 // supports Complete Access
}
EcEoEDetails enum values
[Flags]
public enum EcEoEDetails : byte
{
None = 0x00,
SendFrame = 0x01, // supports sending frames
ReceiveFrame = 0x02, // supports receiving frames
SetIPParam = 0x04, // supports setting IP parameters
GetIPParam = 0x08 // supports getting IP parameters
}
EcSlaveStatus enum values (complete status, keeps the Error bit)

State lists only the 5 basic states plus an Error bit; EcSlaveStatus lists the composite states that actually occur on the factory floor (such as OpFault = OP+Error) as explicitly named members, avoiding raw numbers (such as 24). 0x10 is bit 4 = Error of the ETG.1000.6 AL Status (0x0130).

[Flags]
public enum EcSlaveStatus : byte
{
None = 0x00, // offline, or AL Status not read
Init = 0x01, // init
PreOp = 0x02, // pre-operational (mailbox available, PDO not started)
Boot = 0x03, // bootstrap (FoE firmware update)
SafeOp = 0x04, // safe-operational (PDO inputs valid, outputs at safe values)
OP = 0x08, // operational (production state)
ErrorFlag = 0x10, // Error flag bit (bitwise OR with the basic state)
InitFault = 0x11, // Init+Error
PreOpFault = 0x12, // PreOp+Error
BootFault = 0x13, // Boot+Error
SafeOpFault = 0x14, // SafeOp+Error
OpFault = 0x18 // OP+Error
}

Extension methods: BaseState() (low 4 bits) / HasFault() (includes the Error bit) / IsRunning() (SafeOp or OP without Error) / IsOp() (OP without Error) / Pretty() (e.g. "OpFault (OP+Error)").

WcContribution enum values (WKC contribution state)
public enum WcContribution : byte
{
NotContributed = 0x00, // this slave is not contributing WKC right now (suspected drop / hot-plug recovery)
Contributed = 0x01, // this slave contributes WKC normally (responding on the bus)
Unknown = 0xFF // PDO cycle not running yet or index out of range — reported honestly, never guessed
}
EcMailboxHealth enum values (mailbox health)
public enum EcMailboxHealth : byte
{
Unknown = 0, // unknown / no mailbox / not in OP — mailbox health is meaningless here
Healthy = 1, // healthy — in OP and the mailbox is usable
Degraded = 2 // degraded — in OP but the mailbox half-fails (CoE/SDO may block)
}

Mailbox protocol capabilities​

CategoryPropertyTypeRead/writeDescription
Protocol capabilityCoESupportbool?read-onlyCoE capability tri-state (SII mbx_proto bit2)
EoESupportbool?read-onlyEoE capability tri-state (bit1)
SoESupportbool?read-onlySoE capability tri-state (bit4)
AoESupportbool?read-onlyAoE capability tri-state (bit0)
VoESupportbool?read-onlyVoE capability tri-state (bit5)

Tri-state values: true = supported; false = the SII mbx_proto was actually read and the corresponding bit is not set; null = this read failed (conclusion unknown). Unknown is never folded into false — bool methods such as SupportsCoE() express only "known to be supported".

GetMailboxProtocolSupport(MailboxProtocol protocol)​

public bool? GetMailboxProtocolSupport(MailboxProtocol protocol)

Queries the capability tri-state of the given mailbox protocol. A read failure is caught and logged as a Warning, and the method returns null.

Parameters:

  • protocol (MailboxProtocol) — protocol capability bit (AoE / EoE / CoE / FoE / SoE / VoE)

Return value:

  • bool? — true supported / false confirmed not declared / null unknown (read failed)

Example:

bool? coe = slave.GetMailboxProtocolSupport(MailboxProtocol.CoE);
if (coe == null)
Console.WriteLine("CoE 能力未知(SII 读取失败),不要当成不支持"); // CoE capability unknown (SII read failed), do not treat as unsupported
else if (coe == false)
Console.WriteLine("从站 SII 未声明 CoE"); // Slave SII does not declare CoE

Sub-objects​

CategoryPropertyTypeRead/writeDescription
RuntimePDOSlavePdoread-onlyPDO data accessor
EventsSlaveEventsread-onlySlave-level events
DiagnosticsSlaveDiagnosticsread-onlyDiagnostics accessor
StartupStartupParameterListread-onlyStartup parameter list
ProtocolCoECoEInstance?read-onlyCANopen over EtherCAT; null when the slave does not support it
SoESoEInstance?read-onlyServo over EtherCAT; null when the slave does not support it
FoEFoEInstance?read-onlyFile over EtherCAT; null when the slave does not support it
EoEEoEInstance?read-onlyEthernet over EtherCAT; null when the slave does not support it
AoEAoEInstance?read-onlyADS over EtherCAT; null when the slave does not support it
VoEVoEInstance?read-onlyVendor over EtherCAT; null when the slave does not support it
FSoEFSoEInstance?read-onlyFunctional Safety over EtherCAT; null when the slave does not support it
ExtensionMDPMdpInstance?read-onlyMDP modular device; null when the slave does not support it
Protocol accessors are public fields

CoE / SoE / FoE / EoE / AoE / VoE / FSoE together with Events and SlaveNum are public fields (not properties), initialized lazily by the SDK. Applications only read them; do not assign to them.

Enum value display​

The SDK provides no localized enum text; an enum's ToString() returns the member name:

EcState state = slave.State;
Console.WriteLine(state.ToString()); // "OP"

StateCiA402 driveState = slave.CoE.CiA402.StateDrive;
Console.WriteLine(driveState.ToString()); // "OperationEnabled"

ModeCiA402 mode = slave.CoE.CiA402.OperationMode;
Console.WriteLine(mode.ToString()); // "CSP"

FSoEState fsoeState = slave.FSoE.State;
Console.WriteLine(fsoeState.ToString()); // "Data"
Chinese / English text

When the UI needs a Chinese or English description, the application layer maps it per enum member itself; the SDK provides only member names, not localized text.

Tuple deconstruction and identity keys​

Deconstruct(...)​

public void Deconstruct(out uint vendor, out uint product, out uint revision)
public void Deconstruct(out uint vendor, out uint product, out uint revision, out uint serial)
public void Deconstruct(out int index, out string name, out EcState state)

The three overloads unpack the 3-part identity, the 4-part identity (including the serial number) and a runtime-state view respectively, so the properties do not have to be read and combined first.

3-output overloads cannot be used as tuple deconstruction

The two 3-output overloads take the same number of parameters, so both var (a, b, c) = slave; and (int a, string b, EcState c) = slave; fail as ambiguous (CS0121) — tuple deconstruction syntax does not feed variable types into overload resolution. For 3 outputs, call Deconstruct(...) explicitly or read the properties directly. The 4-output overload is the only one, so var deconstruction works for it.

Parameters:

  • vendor (out uint) — vendor ID (VendorId)
  • product (out uint) — product ID (ProductId)
  • revision (out uint) — revision number (RevId)
  • serial (out uint) — serial number (SerialNumber)
  • index (out int) — slave index (SlaveNum, 1-based)
  • name (out string) — device name (Name; an empty string when it is empty)
  • state (out EcState) — current state (State)

Example:

// 4 outputs: destructure directly
var (vendor, product, revision, serial) = slave;
Console.WriteLine($"0x{vendor:X8}:0x{product:X8} rev 0x{revision:X8} sn {serial}");

// 3 outputs: call explicitly (tuple destructuring fails with an ambiguity error)
slave.Deconstruct(out uint v, out uint p, out uint r);
slave.Deconstruct(out int idx, out string name, out EcState state);
Console.WriteLine($"#{idx} {name} → {state}");

TryGetSerialNumber(out uint serialNumber)​

public bool TryGetSerialNumber(out uint serialNumber)

Gets the real serial number and separates "the real value is 0" from "could not read":

  • Returns true — a real value was obtained; serialNumber may be 0 (the device really declares serial number 0)
  • Returns false — the read failed; serialNumber is set to 0, and that 0 means unknown, not a real value

Read order: first, the native runtime identity snapshot already holds a value other than 0 → return it directly without touching the EEPROM; second, the snapshot is 0 (slaves whose SER read was skipped during cold configuration) → read SII words 0x000E / 0x000F on the spot. While the snapshot is 0, every call really reads the EEPROM; if you need it often, cache it in the caller.

Three different 0s

A 0 from the SerialNumber property, TryGetSerialNumber returning false, and TryGetSerialNumber returning true with value 0 are three different facts: a property value of 0 only says "the snapshot did not read it" (it may have been skipped by cold configuration, or it may really be 0), false + 0 is a "read failure" (unknown), and true + 0 is "the device serial number really is 0". Do not convert one into another.

Example:

if (slave.TryGetSerialNumber(out uint sn))
Console.WriteLine($"序列号 = {sn}"); // Serial number = {sn}
else
Console.WriteLine("序列号未知(SII 读不出来)"); // Serial number unknown (SII could not be read)

GetIdentityKey()​

public SlaveIdentityKey GetIdentityKey()

Returns the slave's immutable identity key, for use as a dictionary key, a configuration cache key and in pattern matching. Every call reads the current EEPROM identity, but the returned value itself is immutable, so it can be passed across threads and held long-term safely.

Return value:

  • SlaveIdentityKey — immutable identity key (a record struct with built-in value equality)

Related structures:

public readonly record struct SlaveIdentityKey(
uint VendorId, // Vendor ID
uint ProductId, // Product ID
uint Revision, // Revision version number
uint Serial) // Sequence number
{
public override string ToString(); // "0xVID:0xPID@0xREV" form
public bool MatchesType(SlaveIdentityKey other); // Compare Vendor + Product only, ignore Revision / Serial
}

Example:

var cache = new Dictionary<SlaveIdentityKey, string>();
cache[new SlaveIdentityKey(slave.VendorId, slave.ProductId, 0, 0)] = "同型号默认配置"; // Default configuration for the same model

var key = slave.GetIdentityKey();
Console.WriteLine(key); // 0x00000002:0x00000503@0x00010000

if (cache.TryGetValue(key with { Revision = 0, Serial = 0 }, out var fallback))
Console.WriteLine($"命中同型号默认配置: {fallback}"); // Matched the default configuration for the same model: {fallback}

Diagnostics​

tip

Slave diagnostics (communication error rate, redundancy state, DC sync) are accessed through slave.Diagnostics.

PdoInputValidity — input data validity​

slave.InputDataValidity answers "can this frame of input data be used as the current value", which is a different fact from "has the slave been confirmed offline" (slave.IsLost): when the slave is not judged lost but the WKC is short, this property can be Degraded or Stale.

ValueWhat you seeRecommended use
ValidThis cycle's PDO exchange was complete; the input image is the current valueUse normally
DegradedThis cycle has no full evidence: the group's inputs are incomplete for this cycle. On a single dropped frame / WKC=0 the data is the previous valid frame (last-good); when some slaves are missing, the input bytes of the absent slave and everything downstream may be the process-image initial values established at startup, not the last valid valueDo not treat this as "the data is definitely trustworthy": either wait for recovery, or cross-check IsLost / OfflineReason / InputDataValidity to see which slaves are untrustworthy. It turns Stale only after N full cycles without recovery (N is computed from the group cycle and the slave watchdog)
StaleThe input image cannot be used as the current value (WKC short / no frame this cycle / slave lost / exchange stalled)Do not use as a live value; take the safe fallback
UnknownNo evidence (no input PDO / group expectation not established / never exchanged / read failed)Unknown is not valid; treat it as unavailable

A read failure / out-of-range index / an older runtime without this capability returns Unknown (fail-closed).

Note: the native-side comment still says "three-state / degradation pending", which is stale text awaiting sync in the native domain; the public SDK contract is the four states in this section.

MasterDiagnosticsInfo.StaleInputCount counts only slaves confirmed Stale; it does not count while Degraded applies.

Live-read values and the four trust states (LiveRead)​

StateLiveRead / ALStatusCodeLiveRead both return LiveRead: the raw value plus an evidence level. Only a value that passes IsValid (that is, Validity == Valid) may be used as the current value; the other three states must never be taken as "this is how it is right now".

ValueMeaningUsable as the current value
Unknown(0)No usable read (call failed / old runtime missing the entry point / invalid handle)No. Unknown != normal
Valid(1)This measurement produced a result usable as the current valueYes
Stale(2)A value was obtained, but it is confirmed not current (the lower layer uses 0 as a placeholder when the slave is lost / not responding)No, this is a residual value
Degraded(3)A value was obtained, but only partial evidence is available (liveness state / probe unreadable or unknown)Not as confirmation

Live state criterion: 0 / 0xFF / low 4 bits are 0 -> Unknown; otherwise -> Valid. Value keeps the bit4 Error bit (Value & 0x10); to test the Error bit look at the raw byte, or read HasFault() on the cached Status view.

Live AL code criteria:

VerdictTriggerValue
UnknownThe call failed, or it returned 0xFFFF (the unavailable sentinel)0xFFFF
DegradedThe liveness state / probe read failedRaw code
StaleIsLost is true, or the probe confirms no responseRaw code (residual)
DegradedProbe evidence is insufficient (unknown)Raw code
ValidIsLost is false and the probe confirms the slave is onlineRaw code
A lost slave is not "no error"

The lower layer returns 0 for a lost / non-responding slave; that 0 is the "no data" placeholder, not "no error". ALStatusCodeLiveRead uses the liveness state and probe evidence to file it as Stale; the convenience entry point ALStatusCodeLive gives null in that case. Never read 0 / null as "the device confirmed no fault".

The AL mirror (AlStatusCode / AlStatusMirror) carries only the low 8 bits of the code, and codes >= 0x0100 are truncated; for the full 16-bit code always use ErrorCode or ALStatusCodeLive in this section.

ESI configuration​

Per-slave ESI loading is not a slave-level public entry point. ESI files are handed to Build() on the construction chain, and the SDK matches them to each slave automatically:

var master = new DarraEtherCAT()
.SetEsiFile(@"C:\ESI\Beckhoff EL7xxx.xml") // single file
.SetEsiFiles(@"C:\ESI") // file or directory, may be called several times
.SetENI(@"C:\config.xml")
.Build()
.Master;

See Initialization and construction. Whether the ESI declares DC sync can be read through slave.HasEsiDcSync.

Process data watchdog​

SetWatchdog(uint timeoutMs)​

public bool SetWatchdog(uint timeoutMs)

Sets the slave process data watchdog timeout. The watchdog error (ALStatusCode 0x001B) is raised when the slave receives no process data frame within the timeout.

Parameters:

  • timeoutMs (uint) — timeout in milliseconds; 0 = disabled, maximum 6553 ms

Return value:

  • bool — whether the call succeeded
note

Call it in the SafeOp or OP state.

SetPdiWatchdog(int timeoutMs)​

public bool SetPdiWatchdog(int timeoutMs)

Sets the slave PDI watchdog timeout. The PDI watchdog monitors whether the slave local application (microcontroller firmware) is running correctly.

Parameters:

  • timeoutMs (int) — timeout in milliseconds; 0 = disabled

Return value:

  • bool — whether the call succeeded

Example:

slave.SetWatchdog(100);  // 100 ms timeout
slave.SetWatchdog(0); // disable the watchdog

GetWatchdogConfig()​

public (ushort Divider, ushort PdiTimeout, ushort PdTimeout)? GetWatchdogConfig()

Reads the slave's current watchdog configuration. A return of null means the read failed.

Return value:

  • Divider (ushort) — watchdog divider
  • PdiTimeout (ushort) — PDI watchdog timeout value (divider units)
  • PdTimeout (ushort) — process data watchdog timeout value (divider units)

Example:

var config = slave.GetWatchdogConfig();
if (config.HasValue)
Console.WriteLine($"PD超时: {config.Value.PdTimeout} × {config.Value.Divider * 0.04}µs"); // PD timeout: {config.Value.PdTimeout} × {config.Value.Divider * 0.04}µs

GetWatchdogStatus()​

public (bool Expired, byte Counter, ushort Divider, ushort TimeoutValue)? GetWatchdogStatus()

Reads the slave watchdog runtime state. A return of null means the read failed, or any exposed register in this snapshot (0x0440 status / 0x0442 overflow count / 0x0400 divider / 0x0420 process data timeout value) was not read successfully.

Expired comes from bit0 of ESC register 0x0440: 0 = the watchdog has overflowed/expired, 1 = the watchdog is normal or not enabled, that is, Expired = (wd_status & 0x01) == 0; the bits other than bit0 are reserved. 0x0442 / 0x0443 are the watchdog overflow counters (write 0 to reset, reading does not clear them), which are not the same thing as the status bit in 0x0440.

Fields that failed to read do not count

Every field depends on whether it was actually read this time: if any exposed field fails to read, this method returns null, and "a 0 written back by a failed read" is never treated as the device's real value.

Return value:

  • Expired (bool) — whether the watchdog has expired (0x0440 bit0 is 0)
  • Counter (byte) — watchdog counter (0x0442, accumulated expiry count)
  • Divider (ushort) — current divider value (0x0400)
  • TimeoutValue (ushort) — current process data watchdog value (0x0420)

Example:

var status = slave.GetWatchdogStatus();
if (status is null)
Console.WriteLine("看门狗状态读取失败或任一寄存器未读到"); // Watchdog status read failed or one or more registers were not read
else if (status.Value.Expired)
Console.WriteLine($"看门狗过期! 计数: {status.Value.Counter}"); // Watchdog expired! Count: {status.Value.Counter}

GetWatchdogStatusEx()​

public (bool Expired, byte Counter, ushort Divider, ushort TimeoutValue, bool Conclusive)? GetWatchdogStatusEx()

An extended version of GetWatchdogStatus() that additionally returns Conclusive: whether the conclusion can be trusted. The conditions for returning null are exactly the same as for GetWatchdogStatus() (the SDK returns a failure, or any exposed field failed to read).

Return value:

  • Expired / Counter / Divider / TimeoutValue — same as GetWatchdogStatus()
  • Conclusive (bool) — whether the evidence chain is sufficient to support the conclusion
When Conclusive is false

It is false only when three pieces of evidence contradict one another: "0x0440 bit0 says expired" + "the state is known and really is OP" + "the 0x0442 counter does not advance" (some devices are known to report bit0 = 0 even when healthy). When the state cannot be read (State == None) it likewise does not claim the conclusion is trustworthy — unknown is not good evidence.

Example:

var wd = slave.GetWatchdogStatusEx();
if (wd is null)
Console.WriteLine("看门狗状态不可判定"); // Watchdog status cannot be determined
else if (wd.Value.Expired && wd.Value.Conclusive)
Console.WriteLine($"确认看门狗过期,计数 {wd.Value.Counter}"); // Confirmed watchdog expired, count {wd.Value.Counter}
else if (wd.Value.Expired)
Console.WriteLine("位报过期,但证据链不充分,请结合 AL 状态人工确认"); // The bit reports expiry, but the evidence chain is insufficient; confirm manually together with the AL state

State transitions​

SetState(EcState targetState, uint timeoutMs = 3000)​

public bool SetState(EcState targetState, uint timeoutMs = 3000)

Sets the slave EtherCAT state (with a timeout). Use it to manually recover a single slave or to switch a slave to a given state.

Parameters:

  • targetState (EcState) — target state
  • timeoutMs (uint) — timeout in milliseconds, default 3000 ms

Return value:

  • bool — whether the call succeeded
note

State transitions follow the standard EtherCAT state machine flow; the protocol layer handles the intermediate states automatically. For example, switching from INIT to OP automatically passes through PreOp → SafeOp → OP.

Failure logs carry the measured state

When it returns false, the SDK writes an Error log entry containing the target state, the slave's measured State and the AL Status Code (for example 实测State=SafeOpFault, AL=0x001B (SyncManagerWatchdog)), so that "the bus never got there" can be told apart from "the slave's AL rejected it".

Example:

// manually recover a single slave to OP
if (slave.State != EcState.OP)
slave.SetState(EcState.OP);

// switch the slave to Init (reset)
slave.SetState(EcState.Init, timeoutMs: 5000);

Diagnostics properties​

WcContributed / MailboxHealth / IsFreeRunDemoted / HealthDegradedCount return the real-time diagnostics result of the current bus on read; no refresh call is needed and no extra bus frame is produced. AlStatusMirror / AlStatusCode are the exception.

This value is a cache refreshed by the master only while it is in OP; it is not the live truth at read time. When the master is not currently in OP (or no sample has been taken yet) the getter returns 0 = not sampled / unknown; only a value other than 0 is a trustworthy sample. Once the master leaves OP the sampler stops and the cache keeps its last sample, so this property no longer claims realtime behaviour.

AlStatusCode extra semantics: its source is the AL mirror's high byte (the native side writes the low 8 bits of the AL Status Code into the high byte only when the Error bit is set and the code differs from 0, so codes ≥0x0100 are truncated), which is not the same data source as ErrorCode (the full 16-bit ALstatuscode field in the slave structure). Returns Unknown when not sampled, and also when the Error bit is set but the mirror's high byte is 0 — the SDK never reports "unknown" as NoError.

WKC contribution semantics​

WcContributed reflects whether this slave is really responding right now:

  • Contributed — the slave contributes the working counter (WKC) normally, that is, when the aggregate WKC is complete (actual == expected, i.e. the deficit WcDeficit == 0) every slave compares "full" byte by byte.
  • NotContributed — the slave is not contributing WKC right now (suspected slave drop / hot-plug recovery). This is not a master fault; once the slave is repaired the property returns to Contributed by itself.
  • Unknown (0xFF) — returned when the PDO cycle has not run yet or the index is out of range; exposed honestly, never guessed as "contributed".
R1 reliability rule

This property only "reflects the bus reality as it is" and takes part in no WKC tampering or accommodation logic. The per-slave contribution bit is the per-slave breakdown of the aggregate WKC deficit (expected - actual): when the aggregate is full the slave contributes; a deficit greater than 0 means some slave is not contributing right now, which calls for an alarm plus diagnostics, without lowering expected and without stopping OP.

Example:

foreach (var slave in master.Slaves)
{
if (slave.WcContributed == WcContribution.NotContributed)
Console.WriteLine($"从站 {slave.SlaveNum} 此刻未贡献 WKC(疑似掉站),AL={slave.AlStatusCode}"); // Slave {slave.SlaveNum} is not contributing WKC right now (suspected slave loss), AL={slave.AlStatusCode}

if (slave.MailboxHealth == EcMailboxHealth.Degraded)
Console.WriteLine($"从站 {slave.SlaveNum} 在 OP 但邮箱半失效,已持续 {slave.HealthDegradedCount}s"); // Slave {slave.SlaveNum} is in OP but its mailbox is partially failed, ongoing for {slave.HealthDegradedCount}s

// the AL state can be read directly as a string
Console.WriteLine($"从站 {slave.SlaveNum}: {slave.AlStatusMirror.Pretty()}"); // Slave {slave.SlaveNum}: {slave.AlStatusMirror.Pretty()}
}

RecoverMailboxHealth()​

public bool RecoverMailboxHealth()

Manually triggers mailbox half-failure recovery for this slave. It usually needs no manual call — the SDK repairs it automatically after the mailbox stays half-failed for about 3 seconds. Use it only when the upper layer wants to intervene immediately. It returns false on a communication error and throws no unhandled exception.

Return value:

  • bool — true = the recovery flow was triggered; false = invalid argument / the slave does not currently need recovery

This group of properties answers "how many legs this station itself has". The criterion comes from the topology model, not from a configuration fact such as "a secondary NIC is configured": in a ring-plus-branch topology a branch station stays single-path even when the whole network has a ring.

CategoryMemberTypeRead/writeDescription
Protection formProtectionStateSlavePathProtectionread-onlyTri-state: Unknown / NoProtectionPath (all linear stations, branch stations) / ProtectionPath (stations on a ring, dual path)
Reachable legsTryGetReachableLegs(int slaveNum, out ReachableLegs legs)boolread-onlyReturning false = unknown (model unavailable / cannot tell); legs is trustworthy only when it returns true
LinkPrimaryLinkBrokenboolread-onlyA break exists on the primary leg (Port0 direction) path; false when the model is unknown, which means "unknown" and must be told apart together with ProtectionState
LinkSecondaryLinkBrokenboolread-onlyThe secondary leg (fold-back window) is broken; can be true only for dual-path stations and is always false for single-path stations
Break attributionBrokenLegSideLegSideread-onlySide of the current break: Primary primary leg broken / Secondary secondary leg broken / Unknown the side cannot be proven (not "no break"). It answers only "which leg is broken", not "whether there is a break"
LinkRedundancyActivatedboolread-onlyDual-path station + the station is not lost + at least one leg is broken. Always false for a purely linear topology (even with two NICs)
Legacy propertyP1FoldbackOnlyintread-onlyRaw value (1 = reachable only through the fold-back window / 0 = no, or not calibrated / -1 = unavailable). Do not use it to decide legs; see below

SlavePathProtection​

ValueNameMeaning
0UnknownTopology model unavailable / ring membership of this station cannot be determined — unknown, must not be treated as single-path
1NoProtectionPathSingle path (all of a linear topology / branch stations in a ring-plus-branch topology): once broken there is no second leg
2ProtectionPathDual path (stations on a ring): primary leg plus secondary leg; breaking one still leaves the other

ReachableLegs​

ValueNameMeaning
0UnknownCannot read / model unavailable / the current capability cannot tell
1PrimaryOnlyReachable only through the primary leg (Port0 direction)
2SecondaryOnlyReachable only through the secondary leg (fold-back window)
3BothReachable through both legs (= station on a ring, with a protection path)

TryGetReachableLegs(int slaveNum, out ReachableLegs legs)​

public bool TryGetReachableLegs(int slaveNum, out ReachableLegs legs)

Decision rules (the first match returns):

  1. The master is released / closed, or RingMembershipKnown = false → false (Unknown)
  2. P1FoldbackOnly = 1 → SecondaryOnly
  3. P1FoldbackOnly = 0 and the model confirms a linear topology → PrimaryOnly
  4. P1FoldbackOnly = 0 and the station is on a ring → Both
  5. P1FoldbackOnly = 0 and the station is a branch station in a ring-plus-branch topology → false (the current capability cannot tell; do not guess)
Do not assume "primary leg only" when the result is false

P1FoldbackOnly carries only station-level position information, not a per-slave leg statement. On some rings 0 can mean "primary leg only", "both legs reachable" and "not calibrated" at the same time — in such cases this method returns false and the caller must treat it as "unknown".

What the tri-state means

SecondaryLinkRole (master level) answers "what role the secondary port plays in the topology"; ProtectionState (slave level) answers "how many legs this station itself has". Both are tri-state; unknown must never be folded into "protected" or "unprotected".

Example:

var slave = master.Slaves[0];

switch (slave.ProtectionState)
{
case SlavePathProtection.ProtectionPath:
Console.WriteLine("环上站:双路径"); // Slave on the ring: dual path
break;
case SlavePathProtection.NoProtectionPath:
Console.WriteLine("单路径:断线即失联"); // Single path: a cable break means loss of contact
break;
default:
Console.WriteLine("拓扑未知:不判断保护能力"); // Topology unknown: protection capability cannot be determined
break;
}

if (slave.TryGetReachableLegs(slave.SlaveNum, out var legs))
Console.WriteLine($"可达腿: {legs}"); // Reachable legs: {legs}
else
Console.WriteLine("可达腿: 未知(模型不可用或现有能力分不清)"); // Reachable legs: unknown (model unavailable or current capabilities cannot tell them apart)

BrokenLegSide​

public LegSide BrokenLegSide { get; }

Side attribution for the current break. The criterion comes from the topology leg model: when the ring is confirmed cut, the cut is placed on an edge of the parent chain according to the cutting station and the closed port, and the conclusion follows from which side of the cut this station lies on; when the ring is not cut, the per-station side criterion is used, identical word for word to PrimaryLinkBroken / SecondaryLinkBroken.

Unknown means the side cannot be proven, not "there is no break": when the master is released / closed, the model is not ready, the model is unproven, the chain folds back (there is no second leg to begin with), the closed port faces several directions, or this station's parent chain cannot be proven — the result is Unknown, and both *LinkBroken properties are then false. This property does not answer "is there a break"; see the master diagnostics for the break point.

Return value:

  • LegSide — the side attribution

Related structures:

public enum LegSide
{
Unknown = 0, // The side cannot be established (or there may be no link break event at all) - must not be taken as "not broken"
Primary = 1, // Primary leg broken: that slave is unreachable from the primary port direction (only the secondary leg still reaches it)
Secondary = 2 // Secondary leg broken: that slave is unreachable from the secondary port direction (only the primary leg still reaches it)
}

Example:

switch (slave.BrokenLegSide)
{
case LegSide.Primary:
Console.WriteLine("主腿断:只能经副腿到达"); // Primary leg broken: reachable only via the secondary leg
break;
case LegSide.Secondary:
Console.WriteLine("副腿断:只能经主腿到达"); // Secondary leg broken: reachable only via the primary leg
break;
default:
Console.WriteLine("证不出侧别(可能没断线,也可能证据不足)"); // Cannot prove which side (possibly no cable break, possibly insufficient evidence)
break;
}

Topology navigation (master.slave)​

master.slave is the topology-tree accessor (a compatibility entry point, hidden from IntelliSense by default; applications should prefer master.Slaves[n]):

CategoryMemberTypeRead/writeDescription
Topologymaster.slave[i]Slaveread-onlyThe i-th root slave (0-based); returns null when out of range
Topologymaster.slave["0x1001"]Slaveread-onlyGets a station by configuration address (0x hexadecimal and decimal strings are accepted); returns null when not found
TopologyRootSlavesIReadOnlyList<Slave>read-onlyList of root slaves (ascending by slave index)
TopologyCountintread-onlyNumber of roots

Per-station upper-level topology conclusions (LinkCount / TopologyType / ProtectionState) are still read from master.Slaves[n]; this accessor only answers "how the tree is layered".

ComputeRingBranch()​

public RingBranchInfo ComputeRingBranch()

Computes from the port topology "which stations are on the ring and which are on branches", without relying on WKC. The returned object is tri-state: when ModelKnown = false all ring-membership fields are unusable — that means "it cannot be computed" and must not be read as "linear, no ring, every station single-path". When the model does not recognize a shape code, State likewise reports Unknown rather than guessing down to a known shape.

The criterion comes from each station's ports and parent chain (one link-state read per slave, with retries in the worst case), so it is a blocking bus read. Do not call it every cycle from a UI refresh; reuse the cached snapshot in master.Diagnostics.TopologyModel, and when you do need to compute it yourself, call it on a low-frequency schedule.

Return value:

  • RingBranchInfo — the static port model; when it cannot be obtained, an instance with State = Unknown and a non-empty UnavailableReason is returned, never null

Example:

var model = master.slave.ComputeRingBranch();
if (!model.ModelKnown)
Console.WriteLine($"拓扑模型不可用: {model.UnavailableReason}"); // Topology model unavailable: {model.UnavailableReason}
else
Console.WriteLine($"{model.Mode}: 环成员 {model.RingCount} / 分支 {model.BranchCount} / 共 {model.TotalCount}"); // {model.Mode}: ring members {model.RingCount} / branches {model.BranchCount} / total {model.TotalCount}

RootSlaves​

public IReadOnlyList<Slave> RootSlaves { get; }

The root slave list of the topology tree (ascending by slave index). Normalization rules: a slave whose entry is an MII port, or whose parent is the master, becomes a root; a slave with an EBUS entry is merged upward into its coupler and lands in that root station's child list (Children / ChildCount).

The accessor is built once when it is created; after the station table changes (rescan / hot-plug), call master.RebuildTopology() first and then read RootSlaves again. It returns an empty list when there are no slaves on the bus — an empty list means "there is no root to traverse", not "there are no slaves on the bus"; see master.Slaves for the station table.

Return value:

  • IReadOnlyList<Slave> — list of root slaves (read-only)

Example:

foreach (var root in master.slave.RootSlaves)
{
Console.WriteLine($"根 #{root.SlaveNum} {root.Name},子模块 {root.ChildCount} 个"); // Root #{root.SlaveNum} {root.Name}, {root.ChildCount} submodules
foreach (var child in root.Children)
Console.WriteLine($" └ #{child.SlaveNum} {child.Name}");
}

ESC register access (advanced)​

Directly reads and writes slave ESC (EtherCAT Slave Controller) registers for fault diagnosis, custom ESC operations and register-level debugging. In redundant / dual-NIC deployments the reachable path is selected automatically.

Advanced API

It is not needed for normal SDK use — state transitions, PDO, mailbox and similar flows configure the registers automatically. This API is for deep diagnostics and special cases (for example reading error counters, forcing a port policy, or debugging an ESI write that does not take effect).

Register definitions are given in ETG.1000.4 §6 / ETG.1000.6 §5 (public standards), for example:

RegisterDescription
0x0000Type / Revision / Build (device type)
0x0030AL Control (the master issues a state request)
0x0130AL Status (current slave state)
0x0134AL Status Code (error code)
0x0300-0x030FError counters of ports 0-3
0x0400-0x043FWatchdog configuration / counters
0x0440-0x0443SM watchdog status / overflow counters: 0x0440 bit0 (0 = overflowed/expired, 1 = normal or not enabled; 0xFF = read failed/unknown); 0x0442/0x0443 are reset by writing 0 and are not cleared by reading

ReadRegister(ushort, byte[], uint)​

public bool ReadRegister(ushort registerAddress, byte[] data, uint length)

Reads slave ESC registers (FPRD).

Parameters:

  • registerAddress (ushort) — register address (for example 0x0130 = AL Status)
  • data (byte[]) — receive buffer, length ≥ length
  • length (uint) — number of bytes to read (1 / 2 / 4, etc.)

Return value:

  • bool — true on success, false on failure (slave offline / timeout)

WriteRegister(ushort, byte[], uint)​

public bool WriteRegister(ushort registerAddress, byte[] data, uint length)

Writes slave ESC registers (FPWR).

Parameters:

  • registerAddress (ushort) — register address
  • data (byte[]) — data to write
  • length (uint) — number of bytes

Return value:

  • bool — true on success

Example:

var slave = master.Slaves[0];

// read AL Status (0x0130, 2 bytes)
byte[] alStatus = new byte[2];
if (slave.ReadRegister(0x0130, alStatus, 2))
{
ushort state = (ushort)(alStatus[0] | (alStatus[1] << 8));
Console.WriteLine($"AL Status = 0x{state:X4} (state={state & 0x0F}, err={(state & 0x10) != 0})");
}

// read AL Status Code (0x0134, error code)
byte[] alCode = new byte[2];
slave.ReadRegister(0x0134, alCode, 2);
ushort code = (ushort)(alCode[0] | (alCode[1] << 8));
Console.WriteLine($"AL Status Code = 0x{code:X4}");

// write AL Control = 0x04 (request SafeOp)
slave.WriteRegister(0x0030, new byte[] { 0x04, 0x00 }, 2);

EEPROM (SII) access​

Reads and writes the slave SII EEPROM (Slave Information Interface, ETG.1000.6 §6). The EEPROM stores device identity and configuration information such as VendorID / ProductCode / RevisionNo / SerialNo / SyncManager / FMMU / PDO mapping / Strings. The SDK already reads it automatically during configuration, so applications generally need no direct access.

The full EEPROM API is reached through the slave.Sii sub-object (SiiInstance).

Dangerous operation

Use EEPROM writes with care — a wrong write can corrupt the slave identity information and, in the worst case, permanently brick the slave, requiring vendor tools to recover. Use it only in these cases:

  • writing the alias address (ESC 0x0012)
  • repairing factory data that was overwritten by mistake
  • vendor-authorized firmware / parameter programming

An EEPROM write requires the slave to be in the Init / PreOp state; writes are rejected in the OP state. A single-word write automatically takes the master hold and returns it to the PDI after the write; for a bulk write of a whole range, hold it with Sii.Acquire() / Sii.Release() so the PDI cannot take it back midway.

EEPROM size is usually 1 KB - 16 KB (word-addressed, 1 word = 2 bytes). The first 8 words hold basic vendor information, followed by the Category list (Strings / General / FMMU / SyncM / TxPdo / RxPdo / DC / End=0xFFFF).

ReadEeprom(int byteOffset, int byteLength)​

public byte[] ReadEeprom(int byteOffset, int byteLength)

Reads a byte range of the slave SII EEPROM. The SDK handles BUSY polling and word alignment automatically, so it is the recommended first choice for applications. Offset and length should be even-aligned (odd values are aligned down to the low byte automatically). Failures do not silently return an empty array: byteOffset < 0 or byteLength <= 0 throws ArgumentOutOfRangeException, and a word that does not come back throws InvalidOperationException (the message contains the failed word address); use TryReadEeprom if you prefer not to handle exceptions.

TryReadEeprom(int byteOffset, int byteLength, out byte[] data, out int failedWordAddress)​

public bool TryReadEeprom(int byteOffset, int byteLength, out byte[] data, out int failedWordAddress)

The exception-free version of ReadEeprom: returns true when every word was read successfully; returns false on an invalid argument or when any word fails to read (data is an empty array, failedWordAddress gives the address of the word that did not come back and is 0xFFFF on success).

WriteEeprom(int byteOffset, byte[] data)​

public bool WriteEeprom(int byteOffset, byte[] data)

Writes a byte range of the slave SII EEPROM. Both byteOffset and data.Length must be even, and it returns true when every word was written successfully. The slave must be in the Init / PreOp state; writes are rejected in the OP state.

Example:

var slave = master.Slaves[0];

// read vendor_id (EEPROM byte offset 0x10, length 4)
byte[] data = slave.ReadEeprom(0x10, 4);
if (data.Length == 4)
{
uint vendorId = BitConverter.ToUInt32(data, 0);
Console.WriteLine($"VendorID = 0x{vendorId:X8}");
}

// write the alias address (EEPROM byte offset 0x08, 2 bytes)
// the slave must be in the Init/PreOp state!
if (slave.State == EcState.Init)
{
slave.WriteEeprom(0x08, new byte[] { 0x01, 0x00 });
}
High-level API vs low-level SII API

Prefer ReadEeprom / WriteEeprom (byte-based, with automatic word alignment and automatic take/release of the EEPROM), then the already wrapped properties such as slave.VendorId / ProductId / SerialNumber. Use the low-level slave.Sii.* only when you need fine-grained word-level or Category-level control; see the overview table below.

Advanced usage: low-level Sii API​

The slave.Sii.* sub-object APIs below provide finer control at word level and Category level, plus ownership management. Ordinary applications should use ReadEeprom / WriteEeprom above.

CategoryMemberTypeRead/writeDescription
Word accessSii.ReadWord(ushort wordAddr, out ushort value)boolread-onlyReads a single EEPROM word (word offset, not bytes)
Sii.WriteWord(ushort wordAddr, ushort value)boolwrite-onlyWrites a single EEPROM word (with PDI handover protection; returned automatically after the write)
OwnershipSii.Acquire()boolread/writeForcibly takes EEPROM ownership for the master before a bulk write of a whole range
Sii.Release()boolread/writeReturns EEPROM ownership to the PDI
Sii.IsHeldByPdiboolread-onlyOwnership: false = held by the master, true = held by the PDI (slave local firmware)
Category lookupSii.FindCategory(SiiCategory cat)(uint, uint)?read-onlyFinds the byte offset and size of a Category; null = not present or read failure
Sii.TryFindCategory(SiiCategory cat, out uint byteOffset, out uint byteSize)SiiReadStatusread-onlyTri-state variant; the out parameters are 0 unless it returns Ok
Category readSii.ReadCategory(SiiCategory cat, int maxBytes = 4096)byte[]?read-onlyReads a whole Category as a byte array; null = not present or read failure
Sii.TryReadCategory(SiiCategory cat, out byte[]? data, int maxBytes = 4096)SiiReadStatusread-onlyTri-state variant; data is null unless it returns Ok
Sii.EnumerateCategories(int max = 64)SiiCategory[]read-onlyEnumerates all Category types of the slave
StringsSii.GetStrings(int maxBufBytes = 4096)List<string>read-onlyReads the Strings Category and parses it into a list of strings
Sii.GetStringByIndex(byte stringIndex, int maxBytes = 256)stringread-onlyGets a single string by index (1-based) (GroupName / DeviceName / ImageName, etc.)
GeneralSii.GetGeneralInfo()SiiGeneralInfo?read-onlyParses the General Category (type = 30) into structured information; null = not present or read failure
Sii.TryGetGeneralInfo(out SiiGeneralInfo? info)SiiReadStatusread-onlyTri-state variant; info is null unless it returns Ok
Identity areaSii.TryReadIdentity(out SiiIdentityInfo? identity)SiiReadStatusread-onlyReads identity words 0x0008..0x000F (V/P/R/Serial, low word first); any word that does not come back = ReadFailed with identity set to null — a partial identity is never returned
Sii.TryReadSerialNumber(out uint serialNumber)SiiReadStatusread-onlyReads only the Serial words 0x000E / 0x000F; on Ok the value may be 0 (the device's real value), on ReadFailed a value of 0 means unknown

Identity area (SiiIdentityInfo / TryReadSerialNumber): the VendorId / ProductCode / RevisionNo / SerialNo of SiiIdentityInfo come from identity words 0x0008..0x000F (V = 0x0008/0x0009, P = 0x000A/0x000B, R = 0x000C/0x000D, Serial = 0x000E/0x000F), each 32-bit value assembled low word first, from the same source as a direct EEPROM read. TryReadIdentity reports the whole read as ReadFailed as soon as any word does not come back and keeps identity = null — when the identity area is incomplete it does not deliver a partial identity. TryReadSerialNumber reads only the two Serial words: on Ok the value may be 0 (the device really declares serial number 0), on ReadFailed the value is set to 0 meaning unknown, which must not be folded into "the serial number is 0". The identity area is always locatable, so these two entry points only return Ok / ReadFailed, never NotFound.

SII read tri-state (SiiReadStatus)​

Category lookup / read and General parsing can both fail to read, which is a different fact from "the chain genuinely has no such Category". The Try* entry points distinguish them with SiiReadStatus:

public enum SiiReadStatus : byte
{
Ok = 0, // read succeeded, the out parameter holds the real value
NotFound = 1, // the object genuinely is not on the chain (a normal result, not an error)
ReadFailed = 2, // could not read; must not be treated as "not present"
}

Attribution rules:

  • The SII context cannot be obtained (even the Category chain cannot be read) → ReadFailed
  • The Category is on the chain, but locating it or reading its length word fails → ReadFailed
  • The chain is readable and does not contain the Category → NotFound
  • Unless the result is Ok, the out parameter is 0 / null and must not be used as a real value
switch (slave.Sii.TryReadCategory(SiiCategory.General, out byte[]? data))
{
case SiiReadStatus.Ok: Console.WriteLine($"General = {data!.Length} 字节"); break; // General = {data!.Length} bytes
case SiiReadStatus.NotFound: Console.WriteLine("设备没有 General 分类"); break; // Device has no General category
case SiiReadStatus.ReadFailed: Console.WriteLine("SII 读取失败, 不能断言不存在"); break; // SII read failed, cannot assert that it does not exist
}

The older FindCategory / ReadCategory / GetGeneralInfo use null for both "not present" and "read failure" (their return semantics are kept for compatibility). To tell them apart you must use TryFindCategory / TryReadCategory / TryGetGeneralInfo, which return SiiReadStatus.

SiiCategory enum (ETG.1000.6 Table 17)
public enum SiiCategory : ushort
{
Strings = 10,
DataTypes = 20,
General = 30,
FMMU = 40,
SyncM = 41,
TxPdo = 50,
RxPdo = 51,
DC = 60,
End = 0xFFFF,
}

Startup configuration​

CategoryPropertyTypeRead/writeDescription
Startup configurationStartupStartupParameterListread-onlyStartup parameter list
StartupParametersStartupParameterListread-onlyThe official entry point for the startup parameter list; the same instance as Startup (Startup is a compatibility alias)
ShouldWritePDOAssignmentboolread/writeWhether to write the PDO Assignment at startup; default true
ShouldWritePDOConfigurationboolread/writeWhether to write the PDO Configuration at startup; default false
SupportsCompleteAccessboolread/writeWhether the slave supports SDO Complete Access

AutoStartup() / AutoStartupFromMDP() / AutoStartupFromSM()​

public bool AutoStartup()
public bool AutoStartupFromMDP()
public bool AutoStartupFromSM()

Performs automatic startup configuration on the slave. AutoStartup() detects ESI/MDP/SM automatically and generates the parameters; AutoStartupFromMDP() / AutoStartupFromSM() only look at the MDP module list / SM configuration respectively. ESI files are handed to Build() by master.SetEsiFile / SetEsiFiles on the construction chain; there is no separate ESI entry point on the slave side.

SetConfigSource() / ConfigSource / SetConfigSourceENI() / SetConfigSourceDENI()​

public enum ConfigSource
{
Unknown = 0, // not declared (instance default; cannot be written explicitly with SetConfigSource)
Eni = 1, // configuration comes from ENI (standard ETG.2100 network configuration XML)
Deni = 2, // configuration comes from DENI (Darra extended network configuration, a superset of ENI)
}

public ConfigSource ConfigSource { get; } // read-only read-back
public void SetConfigSource(ConfigSource source)
public void SetConfigSourceENI() // equivalent to SetConfigSource(ConfigSource.Eni)
public void SetConfigSourceDENI() // equivalent to SetConfigSource(ConfigSource.Deni)
MemberValueDescription
ConfigSource.Unknown0Not declared (instance default); cannot be written explicitly with SetConfigSource
ConfigSource.Eni1Configuration comes from ENI (standard ETG.2100 network configuration XML)
ConfigSource.Deni2Configuration comes from DENI (Darra extended network configuration, a superset of ENI)

Declares where this slave's configuration comes from (which network configuration file its startup parameters / PDO configuration came from) and marks automatic configuration as already done:

  • Declaration only — it loads no file, reads or writes no slave, and issues no bus operation. The actual loading still goes through DarraEtherCAT.SetENI + Build().
  • Write and read-back are symmetric — ConfigSource reads back exactly what SetConfigSource wrote.
  • Last write wins — it may be called repeatedly and supports switching Eni ↔ Deni; ConfigSource always holds the most recent declaration.
  • Unknown cannot be written — only Eni or Deni may be declared; passing ConfigSource.Unknown (or an out-of-range value) throws ArgumentOutOfRangeException. "Unknown" is the default of an undeclared slave, so writing it would fabricate a source.
  • Affects AutoStartup() — after the declaration, AutoStartup() takes the "already configured, skip" branch and no longer re-issues ESI-derived configuration.
  • SetConfigSourceENI() / SetConfigSourceDENI() are kept as forwarders and behave exactly like calling SetConfigSource directly.
Native-side fact

Native does not record the ENI / DENI origin per slave (it only records explicit_replace / esi_installed), so ConfigSource is SDK-side declaration state, not a native read-back. Use it to express "which file this slave's configuration came from"; do not use it to infer the actual bus or slave state.

Example:

slave.SetConfigSource(ConfigSource.Deni);
Console.WriteLine(slave.ConfigSource); // Deni

slave.SetConfigSourceENI(); // switch back to ENI
Console.WriteLine(slave.ConfigSource); // Eni

// slave.SetConfigSource(ConfigSource.Unknown); // throws ArgumentOutOfRangeException

RefreshPDOStartupParameters()​

public int RefreshPDOStartupParameters()

Refreshes the PDO startup parameters (regenerates the PDO mapping parameters from the current configuration).

StartupParameterList methods (accessed through slave.Startup):

  • Add(StartupParameter param) — adds a startup parameter
  • AddParameter(index, subIndex, data, ...) — adds a startup parameter (explicit parameters)
  • Remove(index, subIndex) — removes a startup parameter
  • Clear() — clears all startup parameters

A single parameter is applied with the entry's own Apply(slave) (a method on StartupParameter, not a list method).

Related structures:

  • IP — Init → PreOp, default AfterTransition
  • PS — PreOp → SafeOp, default BeforeTransition
  • SO — SafeOp → Op, default BeforeTransition
  • OS — Op → SafeOp, default AfterTransition
  • SP — SafeOp → PreOp, default AfterTransition
  • PI — PreOp → Init, default BeforeTransition

Example:

slave.Startup.Add(new StartupParameter
{
Index = 0x1C12, SubIndex = 0,
Data = new byte[] { 0 },
TransitionEnum = StartupTransition.PS, Priority = 10
});