Skip to main content

Configuration

Access the MasterConfig object through master.config(); it manages all communication configuration in one place.

How read-write properties are read and written

Configuration properties are read and written with overloaded methods: a call with no argument reads, a call with an argument writes.

int cycle = config.loopCycle();        // read
config.loopCycle(1_000_000); // write

Properties​

CategoryPropertyTypeR/WDescription
Cycle configurationloopCycle()intread-writePDO exchange cycle (nanoseconds, whole microseconds, 31 µs ~ 10,000 µs)
highResolutionTimer()booleanread-writeRead: whether the system clock precision is currently 1 ms (or finer); write: turn on/off for this process, takes effect immediately. The installer does not enable it by default
Network transportframeHighPriority()booleanread-writeHigh frame priority (off by default; must be set before setNetwork; only takes real effect on Linux)
useUdp()booleanread-writeUDP frame mode (gateway/EAP devices only; standard slaves do not support it)
isUdpAvailable()booleanread-onlyWhether UDP is available
vlanId()intread-writeVLAN ID (0-4095, 0 = disabled; must be set before entering SafeOp)
vlanPriority()intread-writeVLAN priority (0-7)
PDO configurationoverlappingGroups()booleanread-writePDO overlapping mode (disabled by default, TI ESC only)
packedMode()booleanread-writePacked PDO mapping mode (disabled by default)
filterThreshold()intread-writePDO consecutive frame loss threshold (default 3)
Frame repeatframeRepeatCount()intread-writeFrame repeat count (1-3, 1 = disabled)
Mutex protectionmutexProtection()booleanread-writeMutex protection (enabled by default)
Adaptive timeoutadaptiveTimeoutEnabled()booleanread-writeAdaptive timeout (enabled by default after master initialization; reading returns false when the master state is not readable)
State transition timeoutstimeoutInitToPreOp()intread-writeINIT→PREOP timeout (milliseconds, default 3000, taken from the underlying state machine default timeout table; the SDK does not hardcode this number)
timeoutPreOpToSafeOp()intread-writePREOP→SAFEOP timeout (milliseconds, default 10000)
timeoutSafeOpToOp()intread-writeSAFEOP→OP timeout (milliseconds, default 10000)
WatchdogprocessDataWatchdogMs()intread-writeProcess data watchdog timeout (milliseconds). 100 after master initialization (ETG.1000.4 factory default); write 0 = use the slave default value
pdiWatchdogMs()intread-writePDI watchdog timeout (milliseconds, default 0 = use the slave default value)
DC configurationdriftCompensation()booleanread-writeDC drift compensation switch (the setter does apply it: threshold 1000 ns / gain 32; the getter returns the most recent requested value)
Scan configurationscanRevisionMatch()RevisionMatchread-onlyScan revision matching policy. Setting is not supported at present: the scan entry point does not accept a match mode, the setter throws UnsupportedOperationException, and reading always returns IGNORE_REVISION
Mailbox configurationmailboxConfig()MailboxConfigread-onlyMailbox configuration sub-object (mailboxTimeout() fixed reference value 5000 ms, mailboxRetries() fixed reference value 3). Setting is not supported at present: there is no master-level apply entry point and both setters throw UnsupportedOperationException
Out-of-range arguments raise an explicit error (no more silent clamping)

For the setters below, an out-of-range argument throws IllegalArgumentException, the previous value is kept, and the out-of-range value is no longer silently changed to the boundary value:

setterLegal range
vlanId(int)0-4095
vlanPriority(int)0-7
frameRepeatCount(int)1-3
filterThreshold(int)≥ 0
processDataWatchdogMs(int) / pdiWatchdogMs(int)0-6553
timeoutInitToPreOp(int) / timeoutPreOpToSafeOp(int) / timeoutSafeOpToOp(int)≥ 0

loopCycle(int) follows a different rule: on the Java side the argument is not clipped and no exception is thrown, and the value is applied as-is. The applying side checks that the cycle is a whole number of microseconds falling within 31 µs ~ 10,000 µs (31,000 ~ 10,000,000 ns); an invalid value is rejected and the previous value is kept (0 is rejected as well) with an ERROR log entry, and is never silently changed to a boundary value.

Access after shutdown

When the master has been released or is shutting down, all configuration reads and writes throw IllegalStateException (the configuration object may be held for a long time, and accessing it after the master shuts down would hit resources that have already been reclaimed). When writing, if the master state is unavailable (not initialized / shutting down) an IllegalStateException is thrown as well; writes are never silently dropped.

Cycle configuration​

loopCycle​

public int loopCycle()
public void loopCycle(int timeNs)

PDO exchange cycle time, in nanoseconds (ns).

The master RT thread (the real-time driver timer) sends and receives PDO frames at this cycle. This value determines the refresh rate of process data between master and slaves -- the smaller the value, the faster the data refresh, but the higher the real-time requirements on the system. The real-time driver cycle range is 31 µs ~ 10,000 µs (31,000 ~ 10,000,000 ns); 31 µs is the product minimum cycle (about the 32 kHz servo class).

Parameters:

ParameterTypeDescription
timeNsintPDO exchange cycle (nanoseconds). Must be a multiple of 1000 (whole microseconds) and fall within 31 µs ~ 10,000 µs

Returns: reading returns the current cycle (nanoseconds); returns 0 when the master state is not readable (meaning unknown, not a 0 ns cycle).

Invalid value behavior: 0, a value that is not a multiple of 1000, and values below 31 µs or above 10,000 µs are all rejected and the previous value is kept, with an ERROR log entry. The Java layer throws no exception and does no range clipping, nor does it clamp out-of-range values to the boundary (setting 30 µs means 30 µs is not accepted; it does not quietly run at 31 µs).

When it takes effect: the cycle is picked up when the PDO cycle starts, so it must be set before start(); changing it after startup does not change the tick of the running cycle -- stop and restart before it runs at the new cycle.

Recommended values

On Windows, do not go below 125,000 ns (125 µs). The real-time driver fully supports a minimum of 31 µs; smaller values are rejected. 125 µs and above is the usual starting point; below that, jitter normally grows noticeably, so measure jitter and overrun counts on the target machine first.

Example:

config.loopCycle(1_000_000);  // 1ms     = 1,000,000ns
config.loopCycle(500_000); // 500 µs = 500,000ns
config.loopCycle(250_000); // 250 µs = 250,000ns
config.loopCycle(125_000); // 125 µs = 125,000ns (recommended Windows minimum)
config.loopCycle(31_000); // 31 µs = 31,000ns (product minimum cycle)
DC drift compensation

DC drift compensation is off by default; enable it explicitly with driftCompensation when needed (or use master.enableDriftCompensation(...) to specify the threshold and gain).

DC sync window monitoring is managed automatically and is enabled whenever DC slaves are present on the network.

Mailbox communication and the PDO cycle

Mailbox frames (SDO read/write, FoE file transfer, emergency messages and so on) ride along in PDO frames and do not consume an extra frame.

Mailbox response latency: about 2-3 PDO cycles. With loopCycle=1ms, an SDO read takes about 2-3ms.

highResolutionTimer​

public boolean highResolutionTimer()
public void highResolutionTimer(boolean enable)
High-resolution clock

Read: whether the system clock precision is currently 1 ms (or finer) -- not a hardcoded false. Write: turn on/off for this process, takes effect immediately. The installer does not enable it by default; you set it in the cycle configuration. Once enabled, waits are more accurate but the mouse may become sluggish; PDO on isolated cores does not depend on it. On non-Windows systems it is a no-op.

Reading returns whether the system is currently at 1 ms, not a hardcoded false; the installer does not enable it.

Example:

config.highResolutionTimer(true);

Network transport​

frameHighPriority​

public boolean frameHighPriority()
public void frameHighPriority(boolean enable)

Raises the send priority of EtherCAT frames through the OS layer, reducing queuing delay.

Default: false (off by default)

Parameters:

ParameterTypeDescription
enablebooleantrue = enable high frame priority

Returns: reading returns the current setting of this switch; it does not mean "already in effect".

When it takes effect: must be set before setNetwork(...); it is applied when the network connection is established. Changing it afterwards has no retroactive effect.

Actual effect per platform
  • Linux -- SO_PRIORITY=6 socket option (system network stack queuing priority), requires root privileges; if setting fails, a WARNING is logged and it is treated as not in effect.
  • Windows -- not in effect in the current version; a WARNING states this explicitly (frame priority requires support from the system network stack / NIC-side QoS). The switch can still be set and read as usual, but it does not change the actual send priority of frames.

useUdp​

public boolean useUdp()
public boolean useUdp(boolean enable)

Parameters:

ParameterTypeDescription
enablebooleantrue = switch to UDP mode, false = return to raw Ethernet frame mode

Returns: reading returns whether UDP mode is currently active; the call with an argument returns whether this switch succeeded (false = not switched, for example because UDP is unavailable).

UDP frame mode (ETG.1500 5.3.7). Once enabled, EtherCAT datagrams no longer use raw Ethernet frames (EtherType 0x88A4) but are carried inside UDP/IP packets (UDP port 34980).

Gateway/EAP devices only; standard slaves do not support it

The ESC (EtherCAT Slave Controller) chip on a standard EtherCAT slave works at the data link layer and only recognizes raw Ethernet frames with EtherType=0x88A4. UDP/IP-encapsulated frames are invisible to these slaves.

Applies only to:

  • EtherCAT gateways or bridging devices that support the UDP protocol
  • Communication with EtherCAT Automation Protocol (EAP) devices

Does not apply to: direct connection to standard EtherCAT slaves (EK1100, EL7041, servo drives, etc.)

isUdpAvailable​

public boolean isUdpAvailable()

Whether a UDP socket was created successfully during system initialization. Only when this method returns true can you switch to UDP mode through useUdp.

Example:

if (config.isUdpAvailable()) {
config.useUdp(true); // switch to UDP mode
}

vlanId​

public int vlanId()
public void vlanId(int vlanId)

VLAN ID (IEEE 802.1Q, ETG1000_4 table 9, ETG.1500 optional feature). Range 0-4095; 0 disables the VLAN tag.

After a non-zero value is set, a 4-byte 802.1Q VLAN tag is inserted into every EtherCAT frame, and the frame header grows from the standard 14 bytes to 18 bytes.

Parameters:

ParameterTypeDescription
vlanIdintVLAN ID, range 0-4095; 0 = disable the VLAN tag

Returns: reading returns the current VLAN ID; returns 0 when the master state is not readable.

Exception: an argument outside 0-4095 throws IllegalArgumentException; the previous value is kept.

When it takes effect: must be set before entering SafeOp (frames are built from the current value when entering SafeOp); changing it after entering SafeOp has no effect.

Only in effect in real-time driver mode

The VLAN tag feature only takes effect when the real-time driver is installed. The real-time driver sends raw frames directly and the VLAN tag is preserved on the cable in full.

vlanPriority​

public int vlanPriority()
public void vlanPriority(int priority)

VLAN priority (PCP -- Priority Code Point, IEEE 802.1Q, ETG.1500 optional feature). Range 0-7, where 7 is the highest priority.

vlanId must be set to a non-zero value and real-time driver mode must be in use for this property to be meaningful.

Parameters:

ParameterTypeDescription
priorityintVLAN priority (PCP), range 0-7, 7 is highest

Returns: reading returns the current priority; returns 0 when the master state is not readable.

Exception: an argument outside 0-7 throws IllegalArgumentException; the previous value is kept.

When it takes effect: the same as vlanId; it must be set before entering SafeOp.

Example:

config.vlanId(100);
config.vlanPriority(6); // high priority

PDO configuration​

overlappingGroups​

public boolean overlappingGroups()
public void overlappingGroups(boolean enable)

PDO overlapping mode switch. Once enabled, the outputs and inputs of each slave share the same logical address range (the larger of the two sizes); the LRW command writes the outputs on the way out, and on the way back the ESC replaces the same location with the input data, which reduces the frame size.

Default: false (disabled by default)

note

Can only be set in the INIT or PRE_OP state, because the memory layout is fixed once SAFE_OP is entered.

TI ESC

Slaves that use a TI (Texas Instruments) EtherCAT Slave Controller must enable overlapping mode, otherwise the LRW command does not work correctly. Do not enable it for standard Beckhoff/third-party slaves.

packedMode​

public boolean packedMode()
public void packedMode(boolean enable)

Packed PDO mapping mode switch. Once enabled, PDO variables are packed tightly bit by bit without forced byte alignment.

Default: false (disabled by default, byte-aligned mode)

When to use it

Suitable for bit-level IO modules (such as the Beckhoff EL1008/EL2008 digital IO terminals) whose PDO data is a single bit. Enabling PackedMode packs multiple bit IOs tightly into contiguous memory, saving IOmap space.

Example:

config.packedMode(true);  // enable tight bit packing

filterThreshold​

public int filterThreshold()
public void filterThreshold(int threshold)

PDO consecutive frame loss threshold, default 3.

The master checks in every PDO cycle whether the frame returned normally. A single lost frame is treated as occasional interference and only counted; the PDOFrameLoss callback fires only when the number of consecutive lost frames reaches this threshold, which avoids excessive alarms from occasional frame loss.

Parameters:

ParameterTypeDescription
thresholdintConsecutive frame loss threshold, ≥ 0

Returns: reading returns the current threshold; returns 3 (the default) when the master state is not readable.

Exception: a negative argument throws IllegalArgumentException; the previous value is kept.

When it takes effect: can be changed at run time and applies immediately to subsequent frame loss decisions (it does not affect the consecutive count already accumulated).

Example:

config.filterThreshold(5);  // fire the callback only after 5 consecutive lost frames

Scan configuration​

scanRevisionMatch​

public RevisionMatch scanRevisionMatch()
public void scanRevisionMatch(RevisionMatch match)

Revision matching policy when scanning slaves. Controls how strictly the revision numbers of the slaves found during build() are matched against the slaves in the configuration.

Setting is not supported at present: the scan entry point does not accept a match mode, scanRevisionMatch(RevisionMatch) throws UnsupportedOperationException and the passed value has no effect; reading always returns RevisionMatch.IGNORE_REVISION. In this version scanning always runs as "ignore RevisionID, match VendorID + ProductID only".

Returns: always RevisionMatch.IGNORE_REVISION.

Exception: calling the setter throws UnsupportedOperationException (there is no "set but silently ignored" state).

Related structure:

public enum RevisionMatch {
EXACT(0), // exact match of VendorID + ProductID + RevisionID
COMPATIBLE_HIGHER(1), // compatible match: scanned RevisionID >= configured RevisionID
IGNORE_REVISION(2); // ignore RevisionID, match VendorID + ProductID only (default)
}

Enum value semantics:

MemberValueMeaning
EXACT0VendorID + ProductID + RevisionID all equal
COMPATIBLE_HIGHER1VendorID + ProductID equal, and the scanned RevisionID ≥ the configured RevisionID
IGNORE_REVISION2Only VendorID + ProductID (default, and the only behaviour actually implemented in this version)
  • Identity is authoritative as VendorID + ProductID; RevisionID is only a compatibility hint, not part of identity.
  • RevisionMatch.fromValue(int): unknown values fall back to IGNORE_REVISION, not to EXACT (to avoid reading "no constraint" as "must be exactly equal").
  • getValue() returns the public contract value (0/1/2), not the argument value of the runtime comparison primitive; do not pass it directly as a mode argument.

Example:

RevisionMatch current = config.scanRevisionMatch();   // always IGNORE_REVISION
// config.scanRevisionMatch(RevisionMatch.COMPATIBLE_HIGHER); // currently throws UnsupportedOperationException

DC configuration​

driftCompensation​

public boolean driftCompensation()
public void driftCompensation(boolean enable)

DC drift compensation switch. Once enabled, the master periodically measures the DC system time deviation and writes a compensation value (0x0920).

Default: false (off by default)

Parameters:

ParameterTypeDescription
enablebooleantrue = enable DC drift compensation

Returns: reading returns the value most recently requested through this API (this switch has no independent read-back channel), not the actual switch state read back from the runtime; reading does not throw when the master has been released.

When it takes effect: genuinely applied (threshold 1000 ns, gain 32 = a conservative ratio of about 1/32); after the call it takes effect according to the current DC state. The setter throws IllegalStateException when the master has been released or is shutting down.

note

You can also enable it through master.enableDriftCompensation(enable, thresholdNs, gain); that method additionally supports configuring the threshold and gain parameters (legal gain range 1-1024; an invalid value falls back to the conservative default 32).

Frame repeat​

frameRepeatCount​

public int frameRepeatCount()
public void frameRepeatCount(int count)

Frame repeat mechanism (ETG.1500 5.4.3), a global setting for the number of times the same PDO frame is sent per cycle; applied automatically to groups that qualify.

Default: 1 (disabled), range 1-3

This property is a master-level global setting; at run time it filters by group -- frame repeat is performed only for groups in which all slaves declare FrameRepeatSupport=1 in their ESI:

  • All slaves in the group support it -> frame repeat is enabled for that group
  • Any slave in the group does not support it -> that group skips frame repeat

Parameters:

ParameterTypeDescription
countintRepetitions per cycle, range 1-3; 1 = disabled

Returns: reading returns the current count; returns 1 (disabled) when the master state is not readable.

Exception: an argument outside 1-3 throws IllegalArgumentException; the previous value is kept.

When it takes effect: can be changed at run time and applies from the next PDO cycle onwards.

Example:

config.frameRepeatCount(2);  // send 2 times per cycle for every group that qualifies

Mutex protection​

mutexProtection​

public boolean mutexProtection()
public void mutexProtection(boolean enable)

Mutex protection switch. Controls whether PDO reads and writes take a lock automatically to ensure thread safety.

  • Enabled (default) -- the framework locks automatically to ensure thread safety
  • Disabled -- automatic mutex locking is turned off and you manage thread safety yourself, reducing lock contention overhead

Default: true

When it takes effect: can be changed at run time, effective immediately. After disabling it, use lockIOmap / unlockIOmap for batch atomic writes.

Note

After mutex protection is disabled, you must ensure thread safety of PDO data yourself. Suitable for scenarios with very low latency requirements where you can manage concurrency yourself.

Adaptive timeout​

adaptiveTimeoutEnabled​

public boolean adaptiveTimeoutEnabled()
public void adaptiveTimeoutEnabled(boolean enable)

Adaptive timeout switch. Once enabled, the system samples the network round-trip time (RTT) automatically and computes the optimal PDO timeout dynamically in place of the fixed default timeout.

Default: true (enabled by default after master initialization); reading returns false when the master state is not readable.

Returns: reading returns the current value of this switch.

Write semantics (important): writing only updates the read value of this switch; the adaptive timeout policy in the current version always runs as the runtime default (enabled), so turning this switch off does not disable adaptive timeout. If you need a longer wait, increase the state transition timeouts or watchdog fields below.

Why it is enabled by default

In most networks a fixed timeout is far larger than the actual RTT, so an occasional lost frame waits too long and eats into subsequent cycle time. Adaptive timeout samples the actual network latency, keeps a safety margin and computes the optimal timeout, which markedly reduces frames lost to timeout.

State transition timeouts​

timeoutInitToPreOp​

public int timeoutInitToPreOp()
public void timeoutInitToPreOp(int ms)

INIT→PREOP state transition timeout, in milliseconds (ms).

Default: 3000 (ETG.1020 state transition default; this number is not hardcoded in the SDK -- it is read dynamically from the underlying state machine default timeout table, whose Init→PREOP entry is 3000)

Parameters:

ParameterTypeDescription
msintTimeout (milliseconds), ≥ 0

Returns: reading returns the current timeout; when the master state is not readable it falls back to a dynamic lookup in the underlying state machine default timeout table (Init→PREOP gives 3000), and if the underlying lookup fails it returns 0 (unknown, not a legal timeout -- do not treat it as 3000).

Exception: a negative argument throws IllegalArgumentException; the previous value is kept.

When it takes effect: can be changed at run time and applies to state transitions started afterwards (a transition already waiting still uses the old value).

Example:

config.timeoutInitToPreOp(5000);  // 5 second timeout

timeoutPreOpToSafeOp​

public int timeoutPreOpToSafeOp()
public void timeoutPreOpToSafeOp(int ms)

PREOP→SAFEOP state transition timeout, in milliseconds (ms).

Default: 10000 (ETG.1020 state transition default)

This phase includes SM/FMMU configuration and PDO mapping and usually takes the longest. A larger timeout may be needed with many slaves or a complex PDO configuration.

Parameters:

ParameterTypeDescription
msintTimeout (milliseconds), ≥ 0

Returns: reading returns the current timeout; when the master state is not readable it falls back to a dynamic lookup in the underlying state machine default timeout table (PREOP→SAFEOP gives 10000), and if the underlying lookup fails it returns 0 (unknown, not a legal timeout).

Exception: a negative argument throws IllegalArgumentException; the previous value is kept.

When it takes effect: can be changed at run time and applies to state transitions started afterwards.

Example:

config.timeoutPreOpToSafeOp(15000);  // 15 second timeout

timeoutSafeOpToOp​

public int timeoutSafeOpToOp()
public void timeoutSafeOpToOp(int ms)

SAFEOP→OP state transition timeout, in milliseconds (ms).

Default: 10000 (ETG.1020 state transition default)

Parameters:

ParameterTypeDescription
msintTimeout (milliseconds), ≥ 0

Returns: reading returns the current timeout; when the master state is not readable it falls back to a dynamic lookup in the underlying state machine default timeout table (SAFEOP→OP gives 10000), and if the underlying lookup fails it returns 0 (unknown, not a legal timeout).

Exception: a negative argument throws IllegalArgumentException; the previous value is kept.

When it takes effect: can be changed at run time and applies to state transitions started afterwards.

Example:

config.timeoutSafeOpToOp(12000);  // 12 second timeout
When the timeouts need changing
  • Many slaves -- large networks (>50 slaves) may need a larger PreOp→SafeOp timeout
  • Special slaves -- some servo drives or safety devices initialize slowly
  • Commissioning -- increase the timeouts to observe problems during a transition

Watchdog​

pdiWatchdogMs​

public int pdiWatchdogMs()
public void pdiWatchdogMs(int ms)

PDI (Process Data Interface) watchdog timeout, in milliseconds (ms).

The PDI watchdog monitors the slave's local application (microcontroller firmware) accessing the ESC. If the slave firmware does not access the PDI interface within the specified time, the ESC raises a watchdog error, indicating that the slave application may have crashed.

Default: 0 (use the default value in the slave EEPROM/ESI; this item is not written)

Parameters:

ParameterTypeDescription
msintPDI watchdog timeout (milliseconds), range 0-6553; 0 = use the slave default value

Returns: reading returns the current configured value; returns 0 when the master state is not readable.

Exception: a negative argument or one greater than 6553 throws IllegalArgumentException; the previous value is kept.

When it takes effect: applied to each slave during the startup configuration phase; applied again with the current value when a slave powers down / is reconnected through hot-plug. Changing it at run time does not retroactively rewrite slaves that are already online.

Example:

config.pdiWatchdogMs(100);  // PDI watchdog 100 ms
note

The PDI watchdog and the process data watchdog are two independent monitoring mechanisms. The PDI watchdog monitors the slave's internal firmware; the process data watchdog monitors master communication.

processDataWatchdogMs​

public int processDataWatchdogMs()
public void processDataWatchdogMs(int ms)

Process data watchdog timeout, in milliseconds (ms).

The process data watchdog monitors PDO communication from the master to the slave. If a slave does not receive a valid process data frame within the specified time, the ESC raises a watchdog timeout and the slave may automatically drop from OP to SafeOp.

Default: 100 after master initialization (ETG.1000.4 factory default); writing 0 = use the slave default value (this item is not written).

Parameters:

ParameterTypeDescription
msintProcess data watchdog timeout (milliseconds), range 0-6553; 0 = use the slave default value

Returns: reading returns the current configured value; returns 100 when the master state is not readable.

Exception: a negative argument or one greater than 6553 throws IllegalArgumentException; the previous value is kept.

When it takes effect: applied to each slave during the startup configuration phase; applied again with the current value when a slave powers down / is reconnected through hot-plug. Changing it at run time does not retroactively rewrite slaves that are already online.

The actual written value may be raised by a topology safety floor

When the value is applied to a slave, a safety floor is taken from the topology so that recovery / forwarding delays do not make a healthy slave look faulty:

Slave positionValue you setActually written
Branch slave (coupler forwarding)below 5000 ms5000 ms
Slave on the ring with PDObelow 400 ms400 ms
Otheranythe value you set

So setting 50 ms does not mean the slave really runs at 50 ms; rely on the value read back from the slave.

Example:

config.processDataWatchdogMs(200);  // process data watchdog 200 ms
Setting advice

The process data watchdog timeout should be several times the PDO cycle (loopCycle) to avoid spurious triggers during normal operation. The recommended value is 10-100 times the PDO cycle. For example, with loopCycle=1ms, set the watchdog to 100-200ms.

Mailbox configuration​

Access through master.config().mailboxConfig(). Setting is not supported at present: mailbox timeout / retries have no master-level apply entry point, both setters throw UnsupportedOperationException, and the read values are fixed reference values only; there is no "set but silently ignored" state.

CategoryPropertyTypeR/WDescription
Mailbox configurationmailboxTimeout()intread-onlyMailbox timeout reference value (milliseconds, default 5000); the setter throws UnsupportedOperationException
mailboxRetries()intread-onlyMailbox retry count reference value (default 3); the setter throws UnsupportedOperationException

Returns: mailboxTimeout() always returns 5000; mailboxRetries() always returns 3.

Exception: mailboxTimeout(int) / mailboxRetries(int) both throw UnsupportedOperationException (no apply entry point; the passed value has no effect).

Where the real mailbox timeout lives: the mailbox timing of a single slave is determined by the mailbox timeout that device declares in its ESI (query EcEsi_GetDeviceMailboxTimeout). The reference value of this configuration item comes from EtherCATTypes.EsmTimeouts.MAILBOX_TIMEOUT (5000 ms) and uses the same default timeout (the same 5000 ms origin as C# / Python / Rust); it is not a different thing.

Example:

int t = config.mailboxConfig().mailboxTimeout();   // 5000
int r = config.mailboxConfig().mailboxRetries(); // 3
// config.mailboxConfig().mailboxTimeout(5000); // throws UnsupportedOperationException

IOmap locking​

lockIOmap / unlockIOmap​

public boolean lockIOmap()   // EtherCATMaster: true = lock held
public void unlockIOmap()

Lock/unlock the IOmap manually, for multi-axis batch atomic writes. With mutexProtection(false), you must call this method yourself to guarantee atomicity of PDO data. You hold the lock only when lockIOmap() returns true, and only then may you call unlockIOmap() to pair with it; a return of false means the lock was not acquired this time and must not be unlocked.

EtherCATMaster and SlavePdo each have a copy with the same semantics: the former locks the whole IOmap, the latter acts on that slave's PDO view.

Returns: lockIOmap() is a try-lock; true = the lock is held by this call; false = the lock was not acquired (do not enter the critical section in this cycle, and do not unlock). unlockIOmap() has no return value.

Exception: throws IllegalStateException when the master has been released or is shutting down.

Comparison of the three thread-safety modes:

  • Automatic mutex -- mutexProtection(true) (default), general scenarios, no need to think about thread safety
  • Manual IOmap lock -- mutexProtection(false) + lockIOmap / unlockIOmap, multi-axis interpolation, needs batch atomic writes
  • Lock-free -- mutexProtection(false), no lock call, single-threaded writes, guaranteed contention-free
Multi-axis interpolation

During coordinated multi-axis interpolation, the target positions of several slaves must take effect in the same PDO cycle. A manual IOmap lock guarantees that a batch of writes is committed atomically within one PDO frame.

Example (multi-axis interpolation batch write):

// turn off the automatic mutex and use a manual IOmap lock instead
master.setMutexProtection(false);

// write multiple axis positions in a batch inside the PDO callback (frame1 / frame2 / frame3 are output frames built earlier)
master.events().addProcessDataCyclicSyncListener((mi) -> {
if (!master.lockIOmap()) return; // skip this cycle if the lock was not acquired; do not unlock
try {
slave1.PDO().writeOutputDataDirect(frame1);
slave2.PDO().writeOutputDataDirect(frame2);
slave3.PDO().writeOutputDataDirect(frame3);
} finally {
master.unlockIOmap();
}
});

Startup parameter snapshot​

A slave's startup parameters (object dictionary writes applied from a queue after entering PreOp) are read and written as a snapshot plus generation / revision: reading gives you a complete read-only copy, and writing back performs an atomic replacement keyed on generation / revision, so if another entry point changed the parameters after the snapshot was taken the replacement fails instead of writing half of them.

CategoryMethodType/ReturnsR/WDescription
Startup parameter snapshotreadStartupSnapshot(short)EtherCATMaster.StartupSnapshotcallRead the complete startup parameter snapshot of one slave (including generation / revision)
replaceStartupSnapshot(...)booleancallAtomically replace the startup parameters by generation / revision
clearAllStartupParameters()intcallClear the startup parameter queue of all slaves

readStartupSnapshot(short slaveIndex)​

public StartupSnapshot readStartupSnapshot(short slaveIndex)

Read the complete startup parameter snapshot of the given slave. The snapshot is a read-only copy, so later edits to that slave's startup parameters do not change a snapshot that has already been taken.

The snapshot carries a generation number (generation) and a revision number (revision), which are handed to replaceStartupSnapshot(...) for the version comparison when writing back. When the parameter count is short, the actual count filled in by the runtime triggers one automatic re-read, so parameters at the tail are not missed because of a capacity estimate.

Parameters:

  • slaveIndex (short) -- slave index (1-based)

Returns: EtherCATMaster.StartupSnapshot -- startup parameter snapshot; returns null when the read fails (an ERROR log entry has been written, carrying the failure code, the master number and the slave index)

Exception: throws IllegalStateException when the master has been released or is shutting down

Snapshot structure:

CategoryPropertyTypeR/WDescription
Startup parameter snapshotparamsDarraCore.StartupParam[]read-onlyParameter array (read-only snapshot, unaffected by later edits)
generationintread-onlyGeneration number (interpreted as an unsigned 32-bit value)
revisionlongread-onlyRevision number
sourceFlagsintread-onlySource flags (interpreted as an unsigned 32-bit value)

Fields of a single parameter (DarraCore.StartupParam): Index / SubIndex (object index and subindex), Data / DataLen (data to write and its valid length), Transition (when it is applied: 0=IP / 1=PS / 2=SO / 3=OS / 4=SP / 5=PI), Timing (0=Before / 1=After), Priority (apply priority), CompleteAccess (whole-object access), IsRegisterWrite (treat as a register write).

Example:

EtherCATMaster.StartupSnapshot snapshot = master.readStartupSnapshot((short) 1);
if (snapshot != null) {
System.out.println("从站 1 启动参数 " + snapshot.params.length // Slave 1 startup parameters {snapshot.params.length}
+ " 条, 代际 " + snapshot.generation); // entries, generation {snapshot.generation}
}

replaceStartupSnapshot(short slaveIndex, DarraCore.StartupParam[] params, int expectedGeneration, long expectedRevision, LongByReference newRevision)​

public boolean replaceStartupSnapshot(short slaveIndex, DarraCore.StartupParam[] params,
int expectedGeneration, long expectedRevision,
LongByReference newRevision)

Atomically replace the startup parameter snapshot of one slave, keyed on generation / revision. The whole set is written only if the comparison passes; if another entry point changed the parameters in the meantime (the generation or revision has already moved on) the whole replacement fails, so you never end up with a half-written parameter queue.

Parameters:

  • slaveIndex (short) -- slave index (1-based)
  • params (DarraCore.StartupParam[]) -- the new parameter array; elements may be independent instances, and they are packed into a contiguous array internally before being submitted
  • expectedGeneration (int) -- expected generation number (taken from the snapshot's generation)
  • expectedRevision (long) -- expected revision number (taken from the snapshot's revision)
  • newRevision (LongByReference) -- optional out parameter filled with the new revision number after the replacement; pass null when you do not need it

Returns: boolean -- true = the replacement succeeded; false = generation / revision mismatch or invalid parameters (an ERROR log entry has been written and nothing was written)

Exception: IllegalArgumentException -- params is null, or any element of the array is null; IllegalStateException -- the master has been released or is shutting down

Example (read a snapshot → write back on the same generation / revision):

EtherCATMaster.StartupSnapshot snapshot = master.readStartupSnapshot((short) 1);
if (snapshot == null) return;

// newParams is the array of new parameters you have prepared
boolean replaced = master.replaceStartupSnapshot((short) 1, newParams,
snapshot.generation, snapshot.revision, null);
if (!replaced) {
System.out.println("替换失败: 快照已过期, 请重新读取后再写"); // Replace failed: the snapshot is stale, read it again before writing
}

clearAllStartupParameters()​

public int clearAllStartupParameters()

Clear the startup parameter queue of every slave registered with this master (equivalent to clearing the "all slaves" range). Clearing only affects the parameter queue on the master side; values that are already in effect on the slaves are unchanged.

Returns: int -- 0 = success; a negative value = failure (runtime result code)

Exception: throws IllegalStateException when the master has been released or is shutting down

Example:

if (master.clearAllStartupParameters() != 0) {
System.out.println("清空启动参数失败"); // Clearing startup parameters failed
}

Sync manager auto-configuration​

autoConfigureSM(short slaveIndex)​

public int autoConfigureSM(short slaveIndex)

Compute and configure the process data Sync Manager lengths of a slave (SM2 outputs / SM3 inputs) automatically from the startup parameters already registered, so the PDO mapping sizes match the widths declared by the startup parameters.

Parameters:

  • slaveIndex (short) -- slave index (1-based); pass 0 = run for all slaves

Returns: int -- number of Sync Managers configured (≥ 0); a negative value = failure (invalid master number / master not initialized / slave index out of range)

Exception: throws IllegalStateException when the master has been released or is shutting down

The normal startup sequence already includes this step

The startup flow of enableAutoStartup() / ENI auto-configuration configures the Sync Managers automatically, so a separate call is normally not needed. Call it explicitly only when you drive the startup sequence yourself, or after adjusting startup parameters before entering PreOp, and only then continue raising the state.

Example:

int smCount = master.autoConfigureSM((short) 0);   // 0 = all slaves
if (smCount < 0) {
System.out.println("同步管理器自动配置失败: " + smCount); // Sync Manager auto-configuration failed: {smCount}
}

Cycle and registered callbacks​

CategoryMethodType/ReturnsR/WDescription
CyclesetCycleTime(int)voidcallSet the PDO exchange cycle (nanoseconds)
timingMode()intcallRead the current timing mode (read-only)
recordPDOCycleStart()voidcallMark the start of a PDO cycle (cycle counting)
Register callbackregisterSlavePreOpReconfigCallback(...)voidcallRegister the parameter replay callback for when a slave enters PreOp

setCycleTime(int timeNs)​

public void setCycleTime(int timeNs)

Set the PDO exchange cycle, in nanoseconds. This and master.config().loopCycle(int) are two entry points to the same setting (MasterConfig delegates to the same place); the two are equivalent.

Parameters:

  • timeNs (int) -- PDO exchange cycle (nanoseconds); must be a multiple of 1000 (whole microseconds) and fall within 31 µs ~ 10,000 µs (31,000 ~ 10,000,000 ns)

Returns: none (void).

Invalid value behavior: identical to loopCycle -- the applying side checks that the cycle is legal; an invalid value is rejected, the previous value is kept and an ERROR log entry is written. The Java side does not clip the argument, throws no exception, and does not clamp out-of-range values to the boundary.

When it takes effect: the cycle is picked up when the PDO cycle starts, so it must be set before start(); changing it after startup does not change the tick of the running cycle -- stop and restart before it runs at the new cycle.

Exception: throws IllegalStateException when the master has been released or is shutting down

Example:

master.setCycleTime(1_000_000);   // 1ms

timingMode()​

public int timingMode()

Read the timing mode the PDO cycle currently runs in (read-only; it cannot be set).

Returns: int -- 0 = free run (master local tick), 1 = DC SYNC0 synchronization, 2 = DC SYNC0 + SYNC1 synchronization; any other value is returned as-is (an unrecognized mode -- no guessing and no mapping to 0)

Exception: throws IllegalStateException when the master has been released or is shutting down

Example:

switch (config.timingMode()) {
case 0: System.out.println("自由运行"); break; // Free run
case 1: System.out.println("DC SYNC0 同步"); break; // DC SYNC0 synchronization
case 2: System.out.println("DC SYNC0 + SYNC1 同步"); break; // DC SYNC0 + SYNC1 synchronization
default: System.out.println("未识别的定时模式"); // Unrecognized timing mode
}

recordPDOCycleStart()​

public void recordPDOCycleStart()

Mark the start of a PDO cycle, used for cycle counting and cycle-frequency statistics. The runtime calls it automatically in its own PDO cycle; you only need to call it once at the start of each tick when you drive the cycle loop yourself, which keeps the cycle count in diagnostics in step with your application tick.

Returns: none (void).

Exception: throws IllegalStateException when the master has been released or is shutting down

Example:

while (running) {
master.recordPDOCycleStart(); // Mark the start of every application cycle
// ... send/receive and process application data this cycle ...
}

registerSlavePreOpReconfigCallback(DarraCore.SlavePreOpReconfigCallback callback)​

public void registerSlavePreOpReconfigCallback(DarraCore.SlavePreOpReconfigCallback callback)

Register a "replay the startup parameters after a slave enters PreOp" callback: it is invoked once when a slave enters PreOp and the runtime replays that slave's parameters from the startup parameter queue, so you can run your own initialization after the replay.

Callback signature:

void invoke(short masterIndex, short slaveIndex)
  • masterIndex (short) -- master index
  • slaveIndex (short) -- slave index (1-based)

Parameters:

  • callback (DarraCore.SlavePreOpReconfigCallback) -- the callback; pass null = remove the callback registered by this instance (nothing else happens)

Returns: none (void).

Registration semantics:

  • Single slot: registering again on the same instance replaces the previously registered callback.
  • Registration makes sure the event callback system is initialized and uses the same dispatch chain as master.events().
  • Exceptions thrown inside the callback are ignored; they do not affect the master or other subscribers.
  • This entry point is the older registration method on EtherCATMaster; MasterEvents has no listener method of the same name (see events for the event matrix).

Behaviour after shutdown: registration itself does not check the master lifecycle; a callback registered after the instance has been shut down is never delivered (the instance is no longer among the event dispatch targets), and passing null to remove the registration is equally safe.

Example:

master.registerSlavePreOpReconfigCallback((masterIndex, slaveIndex) ->
System.out.println("从站 " + slaveIndex + " 已进入 PreOp, 启动参数已重放")); // Slave {slaveIndex} has entered PreOp, startup parameters replayed

Removing the registration:

master.registerSlavePreOpReconfigCallback(null);

Emergency cleanup​

emergencyCleanup()​

public static void emergencyCleanup()

Release the NIC resources held by this process in an emergency: the NIC opened by the master is closed directly, without going through the normal stop / state rollback sequence. Use it for crash handling, when the process is about to exit, or when a normal shutdown no longer works.

  • Static entry point that targets no particular master instance; there is no need to call it during normal operation.
  • Failures during the final cleanup are ignored; no exception is thrown on the exit path.
  • For a normal release use master.close() (stops PDO in order, rolls back the state and returns the NIC and ports).

Returns: none (void).

Example (last-resort hook for process exit):

Runtime.getRuntime().addShutdownHook(new Thread(EtherCATMaster::emergencyCleanup));

Full example​

try (EtherCATMaster master = EtherCATMaster.create()) {
master.setNetwork("\\Device\\NPF_{...}");

MasterConfig config = master.config();

// cycle configuration
config.loopCycle(1_000_000); // 1ms cycle

// network transport
config.frameHighPriority(true);

// PDO configuration
config.filterThreshold(5);

// state transition timeouts
config.timeoutPreOpToSafeOp(15000);

// watchdog
config.processDataWatchdogMs(200);

// mailbox configuration: setting is not supported at present (the setter throws UnsupportedOperationException)
// config.mailboxConfig().mailboxTimeout(5000);

// scan configuration: setting is not supported at present (the setter throws UnsupportedOperationException)
// config.scanRevisionMatch(RevisionMatch.COMPATIBLE_HIGHER);

// start
master.start();
}

Timeout configuration best practices​

The various timeout fields involved in EtherCAT communication are independent of one another and have a direct bearing on sensitivity to network anomalies and on recovery latency. The table below summarises the common fields, typical defaults and recommended ranges; when deploying, balance the three dimensions of cable length / interference level / real-time priority.

Key field quick reference​

  • loopCycle (ns) — default 1,000,000 (1ms), recommended 125,000 ~ 4,000,000 (125 µs ~ 4ms), PDO cycle; determines refresh rate and CPU load
  • timeoutInitToPreOp (ms) — default 3000, recommended 3000 ~ 10000, INIT→PREOP wait (slow slaves / EEPROM loading)
  • timeoutPreOpToSafeOp (ms) — default 10000, recommended 10000 ~ 30000, PREOP→SAFEOP wait (includes SM/FMMU/PDO mapping; increase for large networks)
  • timeoutSafeOpToOp (ms) — default 10000, recommended 10000 ~ 15000, SAFEOP→OP wait
  • processDataWatchdogMs (ms) — default 100 (ETG.1000.4 factory default; write 0 = use the slave default value), recommended loopCycle × 10 ~ 100; time for a slave to fall back to SafeOp after losing the master connection
  • pdiWatchdogMs (ms) — default 0 (use the slave default value), recommended 0 ~ 200; detection window for the slave's local firmware stopping access to the ESC
  • MailboxConfig.mailboxTimeout (ms) — read-only reference value 5000 (same origin as EtherCATTypes.EsmTimeouts.MAILBOX_TIMEOUT), not settable at present (the setter throws UnsupportedOperationException); per-slave mailbox timing is declared in the ESI

When to increase / decrease​

Increase for:

  • Long cables / across cabinets / across workshops -- large physical transmission delay; occasional RTT jitter needs headroom
  • High EMI / welding / near high-power inverters -- noise causes occasional frame loss; retry headroom needs to be wider
  • Across VLANs / TSN compound networks -- passing through switches introduces queuing jitter
  • Large networks (>50 slaves) -- timeoutPreOpToSafeOp must be increased, otherwise the SafeOp transition fails
  • Slow slaves (large FoE file download / EEPROM write) -- mailbox / Init→PreOp both need to be longer

Decrease for:

  • Fast fault detection first -- industrial emergency stop scenarios; set the watchdog to 5×loopCycle to detect frame loss within 50ms
  • Desktop short cables / laboratory -- very low RTT; the watchdog can go down to 20~50ms
  • Strict RT (≤ 250 µs cycles) -- overall timing is tight; every timeout must be short
There is a lower bound when decreasing the watchdog

When the watchdog is applied, a safety floor is taken from the topology (branch slaves 5000 ms, slaves on the ring with PDO 400 ms); setting a smaller value does not take effect on those slaves. For faster fault detection, shorten loopCycle and use the PDOFrameLoss event for detection.

Default / lab / industrial / high-EMI presets​

MasterConfig config = master.config();

// (1) SDK defaults -- standard short cables + desktop ~ ordinary workshop
config.loopCycle(1_000_000); // 1ms
config.timeoutPreOpToSafeOp(10000); // default value
config.processDataWatchdogMs(0); // use the slave default value
// mailbox timeout is currently not settable (the setter throws UnsupportedOperationException); per-slave timing comes from the ESI

// (2) Laboratory high speed -- short cables + strict RT
config.loopCycle(250_000); // 250 µs
config.timeoutPreOpToSafeOp(5000);
config.processDataWatchdogMs(400); // smaller values are raised to 400/5000ms by the topology floor

// (3) Typical industrial -- long cables + large network
config.loopCycle(1_000_000);
config.timeoutPreOpToSafeOp(20000); // relaxed for large networks
config.processDataWatchdogMs(200);

// (4) High EMI / welding site -- tolerate occasional frame loss
config.loopCycle(2_000_000); // 2ms
config.timeoutPreOpToSafeOp(30000);
config.processDataWatchdogMs(500);
config.adaptiveTimeoutEnabled(true); // adaptive absorbs jitter (enabled by default)
Side effects
  • Timeout too large -- real faults are reported only when the timeout expires; application-level alarms / safety shutdowns are delayed
  • Timeout too small -- occasional jitter is misjudged as a fault, frequently producing PDOFrameLoss / StateChange nuisance alarms
  • Watchdog < loopCycle × several -- it triggers even in normal operation and slaves repeatedly fall back to SafeOp
  • After any adjustment, run a 24h communication stress test before going live
Pairing with adaptive timeout

Adaptive timeout is enabled by default; the SDK computes the single-frame PDO timeout from the real RTT automatically, so there is no need to tighten loopCycle by hand. The watchdog / state transition fields above still need to be configured per scenario.