Skip to main content

Configuration

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

Properties​

CategoryPropertyTypeR/WDescription
Cycle configurationloop_cycleintread-writePDO exchange cycle (nanoseconds)
high_resolution_timerboolread-writeRead: whether the system clock precision is currently 1ms (or finer); write: turn on/off for this process, takes effect immediately. The installer leaves it off by default
Network transportframe_high_priorityboolread-writeFrame high priority (off by default; not effective on Windows at present, SO_PRIORITY on Linux)
use_udpboolread-writeUDP frame mode (gateway/EAP devices only; standard slaves do not support it)
is_udp_availableboolread-onlyWhether UDP mode is available
vlan_idintread-writeVLAN ID (0-4095, 0 = disabled)
vlan_priorityintread-writeVLAN priority PCP (0-7)
PDO configurationoverlapping_groupsboolread-writePDO overlap mode (disabled by default, TI ESC only)
packed_modeboolread-writePacked PDO mapping mode (disabled by default; when enabled, bits are packed tightly)
filter_thresholdintread-writePDO consecutive frame loss threshold (default 3)
Mutex protectionmutex_protectionboolread-writeMutex protection (enabled by default)
Adaptive timeoutadaptive_timeout_enabledboolread-writeAdaptive timeout (enabled by default after master initialization; the value comes from the master shared state; returns False when the master state is not readable)
State transition timeoutstimeout_init_to_preopintread-writeINIT→PREOP timeout (ms), 0 = default 3000ms
timeout_preop_to_safeopintread-writePREOP→SAFEOP timeout (ms), 0 = default 10000ms
timeout_safeop_to_opintread-writeSAFEOP→OP timeout (ms), 0 = default 10000ms
Watchdogpdi_watchdog_msintread-writePDI watchdog timeout (ms), 0 = default
process_data_watchdog_msintread-writeProcess data watchdog timeout (ms). 100 after master initialization (ETG.1000.4 factory default); writing 0 = slave default; returns 0 when the master state is not readable
Scan configurationscan_revision_matchScanRevisionMatchModeread-onlyScan revision matching policy for slaves. Setting is not supported at present: the lower layer has no scan-time matching entry point, the setter raises NotImplementedError, and reading always returns the default value
Frame repeatframe_repeat_countintread-writeFrame repeat count (1-3, 1 = disabled; effective only for groups in which all slaves support it)
DC configurationdrift_compensationboolread-writeDC drift compensation switch. The setter does apply it: calls master.enable_drift_compensation(value, 1000, 32)
Mailbox configurationmailbox_configMailboxConfigread-onlyMailbox configuration sub-object (timeout_ms defaults to 5000, retry_count defaults to 3). SDK-side local values that are not sent to the lower layer; the sub-field setters (timeout_ms / retry_count) write an ERROR log stating "persisted only, not effective" (this limitation is visible as it is, not silent)

VLAN tags must be set before entering SafeOp, and are effective only in real-time driver mode.

Cycle configuration​

loop_cycle​

@property
def loop_cycle(self) -> int

@loop_cycle.setter
def loop_cycle(self, value: int) -> None

PDO exchange cycle, in nanoseconds (ns). The master sends and receives PDO frames at this cycle; a smaller value refreshes faster but places higher demands on real-time behaviour. There is no product lower limit: non-negative values are applied as they are, with no minimum cycle gate; a negative value is treated as 0, and the lower layer rejects 0 ns and keeps the previous value. The cycle you can actually reach depends on the CPU, the isolation configuration, the NIC and the slaves; take the on-site measured jitter and overrun counts as the reference.

Recommended value (advisory, not a limit)

On Windows, 125,000ns (125 µs) is the usual recommended starting point; it is a recommendation, not a product limit. The cycle specification floor of the real-time driver path is 31 µs (31,000ns, in whole microseconds). Below the recommended value, jitter usually grows noticeably, so measure jitter and overrun counts on the target machine first.

Example:

master.config.loop_cycle = 1_000_000   # 1ms
master.config.loop_cycle = 250_000 # 250 µs
Mailbox communication and the PDO cycle

Mailbox communication rides along in the PDO cycle automatically and does not occupy an extra frame.

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

high_resolution_timer​

@property
def high_resolution_timer(self) -> bool

@high_resolution_timer.setter
def high_resolution_timer(self, value: bool) -> None
High-resolution clock

Read: whether the current system clock precision is already 1ms (or finer), not a hard-coded 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 feel sluggish; PDO on isolated cores does not depend on it. A no-op on non-Windows.

The read returns whether the system is currently at 1ms, not a hard-coded false; the installer does not enable it.

Example:

master.config.high_resolution_timer = True

Network transport​

frame_high_priority​

@property
def frame_high_priority(self) -> bool

@frame_high_priority.setter
def frame_high_priority(self, value: bool) -> None

Raises the transmit priority of EtherCAT frames through the OS layer to reduce queuing latency.

Default: False (off by default)

Platform implementation
  • Linux — SO_PRIORITY=6 socket option, network stack queuing priority (requires root)
  • Windows — not effective at present: the frame transmit path performs no priority boost, the value is stored but only logs a WARNING, and it does not pretend to be enabled

use_udp​

@property
def use_udp(self) -> bool

@use_udp.setter
def use_udp(self, value: bool) -> None

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

Only for gateway/EAP devices; standard slaves are not supported

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

Only for:

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

Not for: direct connection to standard EtherCAT slaves (EK1100, EL7041, servo drives and so on)

is_udp_available​

@property
def is_udp_available(self) -> bool

Whether a UDP socket was created successfully at system initialization. Only when this property returns True can you switch to UDP mode with use_udp.

Example:

if master.config.is_udp_available:
master.config.use_udp = True # Switch to UDP mode

vlan_id / vlan_priority​

@property
def vlan_id(self) -> int

@vlan_id.setter
def vlan_id(self, value: int) -> None

@property
def vlan_priority(self) -> int

@vlan_priority.setter
def vlan_priority(self, value: int) -> None

VLAN ID (IEEE 802.1Q) ranges from 0 to 4095, where 0 disables it; VLAN priority PCP ranges from 0 to 7, with 7 the highest priority. Out-of-range values raise ValueError. The VLAN configuration must be set before entering SafeOp (after a successful build(), before set_state(OP)).

Only effective in real-time driver mode

The VLAN tagging feature is effective only when the real-time driver is installed. The real-time driver sends raw frames directly, so VLAN tags are preserved intact on the cable.

Typical VLAN use cases:

  • IT/OT converged network — isolate industrial control traffic from office network traffic with VLANs
  • TSN (Time-Sensitive Networking) — IEEE 802.1Q priority tags for QoS scheduling
  • Coexisting network segments — one physical network carries several EtherCAT segments

PDO configuration​

overlapping_groups​

@property
def overlapping_groups(self) -> bool

@overlapping_groups.setter
def overlapping_groups(self, value: bool) -> None

PDO overlap mode switch. When enabled, the outputs and inputs of each slave share the same logical address range; an LRW command writes the outputs on the way out, and on the way back the ESC replaces the same location with input data. Applies only to special slaves such as TI ESC; do not enable it for standard Beckhoff or third-party slaves.

Default: False (disabled by default)

note

It can be set only in the INIT or PRE_OP state, because the memory layout is fixed when entering SAFE_OP.

packed_mode​

@property
def packed_mode(self) -> bool

@packed_mode.setter
def packed_mode(self, value: bool) -> None

Packed PDO mapping mode switch. When enabled, PDO data is packed tightly by bit; when disabled, it is byte-aligned.

Default: False (byte-aligned by default)

note

It can be set only in the INIT or PRE_OP state, because the memory layout is fixed when entering SAFE_OP.

Example:

master.config.packed_mode = True  # Enable tight bit packing

filter_threshold​

@property
def filter_threshold(self) -> int

@filter_threshold.setter
def filter_threshold(self, value: int) -> None

Consecutive PDO frame loss threshold, default 3. The master checks on each PDO cycle whether frames return normally. A single lost frame is treated as occasional interference and only counted; the **** callback fires only when the pdo_frame_lossconsecutive lost-frame count reaches this threshold. The setter range is 0..0xFFFFFFFF; out-of-range values raise ValueError (the value is not changed silently).

Example:

master.config.filter_threshold = 5  # Fire the callback only after 5 consecutive lost frames

Mutex protection​

mutex_protection​

@property
def mutex_protection(self) -> bool

@mutex_protection.setter
def mutex_protection(self, enable: bool) -> None

Mutex protection switch. Controls whether PDO reads and writes are locked automatically to guarantee thread safety.

  • Enabled (default) — the framework locks automatically to guarantee thread safety
  • Disabled — automatic mutex locking is off; you manage thread safety yourself, reducing lock contention overhead

Default: True

Note

With mutex protection disabled, you must ensure thread safety of PDO data yourself. Intended for scenarios with extremely tight latency requirements where you can manage concurrency on your own.

Adaptive timeout​

adaptive_timeout_enabled​

@property
def adaptive_timeout_enabled(self) -> bool

@adaptive_timeout_enabled.setter
def adaptive_timeout_enabled(self, value: bool) -> None

Adaptive timeout switch. When enabled, the system samples the network round-trip time (RTT) automatically and computes the optimal PDO timeout dynamically instead of the fixed default timeout. Enabled by default after master initialization; the value comes from the master shared state. When the master state is not readable it returns False, and assignment raises RuntimeError (the configuration is not written; nothing is dropped silently).

Why it is enabled by default

A fixed timeout is far larger than the actual RTT in most networks, so an occasional lost frame means a long wait that eats into the following cycle time. The adaptive timeout samples the actual network latency, keeps a safety margin and computes the optimal timeout, which markedly reduces timeout-induced frame loss and the cascading frame loss it causes.

State transition timeouts​

timeout_init_to_preop​

@property
def timeout_init_to_preop(self) -> int

@timeout_init_to_preop.setter
def timeout_init_to_preop(self, value: int) -> None

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

Default: 0 (uses the system default of 3000ms)

Setting a non-zero value overrides the default timeout. Useful for slaves that need a longer initialization time (for example devices with slow firmware loading or EEPROM reads). All three state transition timeout setters accept 0..0xFFFFFFFF; out-of-range values raise ValueError (no silent clamping).

Example:

master.config.timeout_init_to_preop = 5000  # 5-second timeout

timeout_preop_to_safeop​

@property
def timeout_preop_to_safeop(self) -> int

@timeout_preop_to_safeop.setter
def timeout_preop_to_safeop(self, value: int) -> None

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

Default: 0 (uses the system default of 10000ms)

This stage includes SM/FMMU configuration and PDO mapping and is usually the most time-consuming. With many slaves or complex PDO configuration, a larger timeout may be needed.

Example:

master.config.timeout_preop_to_safeop = 15000  # 15-second timeout

timeout_safeop_to_op​

@property
def timeout_safeop_to_op(self) -> int

@timeout_safeop_to_op.setter
def timeout_safeop_to_op(self, value: int) -> None

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

Default: 0 (uses the system default of 10000ms)

Example:

master.config.timeout_safeop_to_op = 12000  # 12-second timeout
When to change the timeouts
  • Many slaves — large networks (>50 slaves) may need a larger preop→safeop timeout
  • Special slaves — some servo drives or safety devices initialize slowly
  • Debugging phase — increase the timeout to observe problems during the transition
  • Value 0 — uses the system default, suitable for most scenarios

Watchdog​

pdi_watchdog_ms​

@property
def pdi_watchdog_ms(self) -> int

@pdi_watchdog_ms.setter
def pdi_watchdog_ms(self, value: int) -> None

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

The PDI watchdog monitors access by the slave local application (microcontroller firmware) to the ESC. If the slave firmware does not access the PDI interface within the given time, the ESC raises a watchdog error, which means the slave application may have crashed.

Default: 0 (uses the default value in the slave EEPROM/ESI). The setter range is 0-6553; out-of-range values raise ValueError (no silent clamping).

Example:

master.config.pdi_watchdog_ms = 100  # PDI watchdog 100ms
note

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

process_data_watchdog_ms​

@property
def process_data_watchdog_ms(self) -> int

@process_data_watchdog_ms.setter
def process_data_watchdog_ms(self, value: int) -> None

Process data watchdog timeout, in milliseconds (ms).

The process data watchdog monitors PDO communication from the master to the slave. If the slave does not receive a valid process data frame within the given time (SyncManager 2/3 not accessed by the master), the ESC triggers a watchdog timeout and the slave may fall back from OP to SafeOp automatically.

Default: 100 after master initialization (ETG.1000.4 factory default); writing 0 = slave default; returns 0 when the master state is not readable. The setter range is 0-6553; out-of-range values raise ValueError (no silent clamping).

After loading a configuration with watchdog declarations from a DENI/ENI, the master baseline is rewritten to the minimum of the values declared by each slave (the PD values of slaves on the same bus are tiered anyway), so the value you read may not be 100.

Example:

master.config.process_data_watchdog_ms = 200  # Process data watchdog 200ms
Setting guidance

The process data watchdog timeout should be several times the PDO cycle (loop_cycle) so that it does not trigger spuriously during normal operation. The recommended value is 10-100 times the PDO cycle. For example, with loop_cycle=1ms, set the watchdog to 100-200ms.

Scan configuration​

scan_revision_match​

@property
def scan_revision_match(self) -> ScanRevisionMatchMode

@scan_revision_match.setter
def scan_revision_match(self, value: ScanRevisionMatchMode) -> None

Scan revision matching policy for slaves. Setting is not supported at present: the lower layer has no scan-time matching entry point (the scan API does not accept a match mode and only provides comparison primitives), the setter always raises NotImplementedError, and reading always returns the default value ScanRevisionMatchMode.IGNORE_REVISION (matches VendorID + ProductID only). Matching of scan results against DENI/ESI devices follows the Type@CheckRevisionNo policy declared by the ESI device.

ScanRevisionMatchMode enum (type description, not configurable at present):

class ScanRevisionMatchMode(IntEnum):
EXACT = 0 # Exact match on VendorID + ProductID + RevisionID
COMPATIBLE_HIGHER = 1 # Compatible match: scanned RevisionID >= configured RevisionID
IGNORE_REVISION = 2 # Ignore RevisionID, match VendorID + ProductID only (default; reading always returns this value)

Example (reading works; setting raises):

print(master.config.scan_revision_match)   # ScanRevisionMatchMode.IGNORE_REVISION
# master.config.scan_revision_match = ScanRevisionMatchMode.EXACT # raises NotImplementedError

Frame repeat​

frame_repeat_count​

@property
def frame_repeat_count(self) -> int

@frame_repeat_count.setter
def frame_repeat_count(self, value: int) -> None

Frame repeat mechanism (ETG.1500 5.4.3). Sets globally how many times the same PDO frame is sent per cycle, and applies automatically to the groups that qualify.

Default: 1 (disabled), range 1-3; out-of-range values raise ValueError.

This property is a master-level global setting and is filtered per group automatically at runtime: frame repeat is performed only for groups in which all slaves declare FrameRepeatSupport=1 in their ESI. Group eligibility is computed automatically during IO mapping:

  • All slaves in the group support it → frame repeat is enabled for that group
  • Any slave in the group does not support it → the group skips frame repeat
Why a global setting with per-group filtering?

ETG.1500 defines frame repeat as a master-level capability, with one global repeat count. Because EtherCAT PDO frames are sent as LRW broadcasts, individual slaves cannot be handled differently within the same frame, so an all-or-nothing decision per group is the only compliant approach. There is no need to set a different repeat count for each group.

Example:

# Global setting: for every qualifying group, send the same PDO frame 2 times per cycle
master.config.frame_repeat_count = 2

DC configuration​

drift_compensation​

@property
def drift_compensation(self) -> bool

@drift_compensation.setter
def drift_compensation(self, value: bool) -> None

DC drift compensation switch. Default: False.

The setter does apply it: it calls master.enable_drift_compensation(value, threshold_ns=1000, gain=32) internally (threshold 1000ns, gain 32) rather than storing a local shadow value. When enabled, the master periodically detects the DC system time deviation and writes the compensation value (0x0920). To use a custom threshold / gain, call master.enable_drift_compensation() directly.

Mailbox configuration​

mailbox_config​

@property
def mailbox_config(self) -> MailboxConfig

Mailbox configuration sub-object, a read-only property (the sub-fields are writable). The fields are:

CategoryPropertyTypeR/WDescription
Mailboxtimeout_msintread-writeMailbox communication timeout (ms), default 5000
retry_countintread-writeMailbox communication retry count, default 3
SDK-side local values, not effective

timeout_ms / retry_count are SDK-side local values that are not sent to the lower layer: an assignment is saved and reads back faithfully, but it does not change the mailbox timeout and retry behaviour of the lower layer. So that it does not "look effective", the setters of both sub-fields write an ERROR log stating "persisted only, not effective"; out-of-range values raise ValueError (the value is not changed silently). For a per-transaction mailbox timeout that really takes effect, pass it to MailboxTransaction(timeout_ms=...) (see Mailbox gateway).

Example:

mc = master.config.mailbox_config
mc.timeout_ms = 5000 # Persisted only; does not change lower-layer behaviour (an ERROR log records it)
mc.retry_count = 3 # Same as above

IOmap locking​

lock_iomap / unlock_iomap​

def lock_iomap(self) -> bool
def unlock_iomap(self) -> None

Locks/unlocks the process image mutex manually, for atomic bulk writes across multiple axes. lock_iomap() is a try-lock (non-blocking): returning True = the lock is held, and the critical section must end with a matching unlock_iomap(); returning False = the lock is not held (held by another thread / the master is not ready / shutting down), in which case you must not enter the critical section and must not call unlock_iomap(). When mutex_protection = False, call this method manually to guarantee atomicity of PDO data. Writes take the direct mapping path outputs_mapping (fields write the process image at the same address); the whole-frame replacement of write_outputs is the snapshot path.

Three thread-safety modes compared:

  • Automatic mutex — mutex_protection = True (default), ~200ns latency, general scenarios, no need to think about thread safety
  • Manual lock — mutex_protection = False + lock_iomap/unlock_iomap, ~50ns latency, multi-axis interpolation, needs atomic bulk writes
  • Lock-free — mutex_protection = False, no lock calls, 0 latency, single-threaded writes, guaranteed freedom from contention
Multi-axis interpolation

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

Example (bulk write for multi-axis interpolation):

# Disable the automatic mutex and use a manual lock
master.mutex_protection = False

import struct

def on_pdo_cycle(mi):
if not master.lock_iomap():
raise RuntimeError("LockIOmap 未取得锁:另一线程仍持有,拒绝进入临界区") # LockIOmap did not acquire the lock: another thread still holds it, refusing to enter the critical section
try:
for s, pos in ((slave1, target_pos1), (slave2, target_pos2), (slave3, target_pos3)):
frame = bytearray(s.pdo.outputs or b'')
if len(frame) >= 4:
struct.pack_into('<i', frame, 0, pos)
s.pdo.write_outputs(bytes(frame))
finally:
master.unlock_iomap()

master.on_pdo_cycle(on_pdo_cycle)

Startup parameters and configuration validation​

apply_startup_params_all()​

def apply_startup_params_all(self, transition: int, timing: int = TIMING_AFTER) -> int

Runs the startup parameters (the SDO writes in the startup parameter queue) for the given state transition on all slaves.

Parameters:

  • transition (int) — state transition number: TRANS_IP=0 (Init→PreOp), TRANS_PS=1 (PreOp→SafeOp), TRANS_SO=2 (SafeOp→OP), TRANS_OS=3 (OP→SafeOp), TRANS_SP=4 (SafeOp→PreOp), TRANS_PI=5 (PreOp→Init)
  • timing (int) — TIMING_BEFORE=0 (before the transition) or TIMING_AFTER=1 (after the transition), default TIMING_AFTER

Returns:

  • int — a value >= 0 is the number of startup parameters written successfully this time. Returning 0 when this phase has no parameter to send is a normal conclusion, not a failure
  • -1 — invalid master index
  • -5 — writing SDOs downward failed (the whole batch is aborted on a bus-level fault)
  • -6 — the master is not initialized
  • Any other negative value — an underlying failure code, returned as it is

A transition / timing outside the values above does not raise: as long as no group is selected it returns 0; a negative number raises 1 << n at ValueError.

Example:

from darra_ethercat import TRANS_PS, TIMING_AFTER

applied = master.apply_startup_params_all(TRANS_PS, TIMING_AFTER)
print("已应用启动参数条数:", applied) # Number of startup parameters applied:

clear_all_startup_params()​

def clear_all_startup_params(self) -> int

Clears the startup parameter queues of all slaves. Only the master-side plan is cleared; configuration that has already taken effect in the slaves is not rolled back.

Returns:

  • 0 — success
  • -1 — invalid master index
  • -6 — the master is not initialized
  • Any other negative value — an underlying failure code, returned as it is

Example:

rc = master.clear_all_startup_params()
if rc != 0:
print("清空启动参数失败, 返回码:", rc) # Failed to clear the startup parameters, return code:

validate_config()​

def validate_config(self) -> int

Validates the self-consistency of the configuration according to ETG.1500 5.5.2. The subject is the configuration table this process actually uses (shared by the whole master, not validated per master object), so calling it on any master in the same process gives the same result.

Returns:

  • 0 — the configuration is self-consistent
  • -1 — invalid master index
  • -2 — some communication timeout is 0
  • -3 — mailbox size out of range or the interval is inverted
  • -4 — the mailbox default size is out of range
  • -5 — the DC drift threshold is invalid
  • -6 — the retry interval is 0
  • -7 — bulk transfer is enabled but the batch size is 0
  • -8 — the configuration structure version does not match
  • -9 — the buffer size is 0
  • -10 — the DC cycle / synchronization offset is invalid
  • -11 — the log verbosity is out of range

Which field violated which constraint is written to the WARNING log as well.

Difference from master.validate(): validate() is the minimal availability pre-check before Build and returns a ValidationResult (with an error list); validate_config() only returns the self-consistency code of the configuration table and does not check the network interface, the ENI or the slaves.

Example:

rc = master.validate_config()
if rc != 0:
print("配置不自洽, 返回码:", rc) # see the log for the specific fields

Full example​

# Basic configuration
master.config.loop_cycle = 1_000_000 # 1ms cycle
master.config.frame_high_priority = False # Frame high priority (off by default)
master.config.overlapping_groups = False # PDO overlap mode (TI ESC only)
master.config.filter_threshold = 5 # Fire only after 5 consecutive lost frames

# Timeout configuration
master.config.timeout_preop_to_safeop = 15000 # 15s

# Watchdog
master.config.process_data_watchdog_ms = 200 # 200ms

# VLAN (requires real-time driver mode)
master.config.vlan_id = 100
master.config.vlan_priority = 6

Timeout configuration best practices​

EtherCAT communication involves several kinds of timeout fields that are independent of each other, and they directly affect how sensitively network faults are detected and how long recovery takes. The table below summarizes the common fields, typical defaults and recommended ranges; when deploying, balance network length / interference level / real-time priority.

FieldUnitDefaultRecommended rangeImpact
loop_cyclens1,000,000 (1ms)125,000 ~ 4,000,000 (125 µs ~ 4ms)PDO cycle; determines the refresh rate and CPU load
timeout_init_to_preopms0 (=3000)3000 ~ 10000INIT→PREOP waiting time (slow slaves / EEPROM loading)
timeout_preop_to_safeopms0 (=10000)10000 ~ 30000PREOP→SAFEOP waiting time (includes SM/FMMU/PDO mapping; increase for large networks)
timeout_safeop_to_opms0 (=10000)10000 ~ 15000SAFEOP→OP waiting time
process_data_watchdog_msms100 (writing 0 = slave default)loop_cycle × 10 ~ 100Time for a slave to fall back to SafeOp after losing the master connection
pdi_watchdog_msms0 (slave default)0 ~ 200Detection window for local slave firmware that stops accessing the ESC
mailbox_config.timeout_msms5000—SDK-side local value that does not change lower-layer behaviour (pass the real transaction timeout to MailboxTransaction(timeout_ms=...))

When to increase / decrease​

Increasing is appropriate 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; the retry room needs to be wider
  • Across VLAN / TSN compound networks — passing through switches introduces queuing jitter
  • Large networks (>50 slaves) — timeout_preop_to_safeop must be increased, otherwise the SafeOp transition fails
  • Slow slaves (large FoE downloads / EEPROM writes) — both the mailbox and Init→PreOp timeouts need to be longer

Decreasing is appropriate for:

  • Fast fault detection first — industrial emergency stop scenarios; set the watchdog to 5×loop_cycle to detect frame loss within 50ms
  • Benchtop short cables / lab — very low RTT; the watchdog can go down to 20~50ms
  • Strict RT (≤ 250 µs cycle) — the overall timing is tight, so every timeout must be short

Default / lab / industrial / high-EMI presets​

# (1) SDK defaults — suitable for standard short cables + benchtop to ordinary shop floor
master.config.loop_cycle = 1_000_000 # 1ms
master.config.timeout_preop_to_safeop = 0 # = 10000ms
master.config.process_data_watchdog_ms = 0 # Slave default (~100ms)

# (2) Lab high speed — short cable + strict RT
master.config.loop_cycle = 250_000 # 250 µs
master.config.timeout_preop_to_safeop = 5000
master.config.process_data_watchdog_ms = 20 # Very fast detection

# (3) Typical industrial — long cables + large network
master.config.loop_cycle = 1_000_000
master.config.timeout_preop_to_safeop = 20000 # Relaxed for a large network
master.config.process_data_watchdog_ms = 200

# (4) High EMI / welding site — tolerate occasional frame loss
master.config.loop_cycle = 2_000_000 # 2ms
master.config.timeout_preop_to_safeop = 30000
master.config.process_data_watchdog_ms = 500
master.config.adaptive_timeout_enabled = True # Adaptive timeout absorbs jitter
Side effects
  • Timeouts too large — real faults are also reported only when the timeout expires, so application alarms / safe stops are delayed
  • Timeouts too small — occasional jitter is mistaken for a fault, repeatedly triggering noisy pdo_frame_loss / state_change alarms
  • Watchdog < loop_cycle × a few — it triggers during normal operation too, and slaves repeatedly fall back to SafeOp
  • After adjusting, run a 24h communication stress test before going live
Pairing with the adaptive timeout

With adaptive_timeout_enabled enabled (on by default), the SDK computes the single-frame PDO timeout from the real RTT automatically, so you do not need to tighten loop_cycle manually. The watchdog / state transition fields above still need to be configured per scenario.

CPU core pinning​

set_cpu_affinity()​

def set_cpu_affinity(self, cpu_core: int) -> bool

To pin the master thread to a specific core, use master.set_cpu_affinity(); it returns a bool indicating whether the binding succeeded.

if master.set_cpu_affinity(1):     # Pin the master thread to core 1
print("已绑定核心 1") # Bound to core 1
Scope of core pinning

set_cpu_affinity() affects only the master thread and is not the same as pinning the whole Python process (interpreter worker threads are not constrained by it). This entry point does not raise a UAC prompt.