Skip to main content

MDP — Modular devices

The Modular Device Profile (MDP) is the standard EtherCAT protocol for describing modular devices.

Accessed through slave.MDP. It is null when the slave does not support MDP.​

Automatic handling

When the state switches to OP, the SDK orchestrates MDP modular devices automatically — module detection, PDO Assignment generation and startup parameter writes are all handled by the SDK, transparently to the user. Typical MDP devices such as the GCAN-8200 need no extra code to enter OP.
In the vast majority of scenarios, users do not need to work with slave.MDP directly; the API on this page is only for diagnostic queries (which modules are configured/detected, the PDO layout) and for triggering module detection manually.

About hot-plug

The SDK supports reconfiguration self-repair after an MDP module hot-plug.
In production environments, however, hot-plugging MDP modules is almost never a real scenario.
The module configuration of an EtherCAT slave is fixed once the device is powered on and does not change at runtime.
DENI is recommended for deploying MDP modular devices;
if automatic configuration is required, import the corresponding ESI file first, then call AutoStartup().

Properties​

CategoryPropertyTypeRead/writeDescription
Module listsConfiguredModulesIReadOnlyList<MdpSlotInfo>read-onlyConfigured module list (index 0xF030)
DetectedModulesIReadOnlyList<MdpSlotInfo>read-onlyDetected module list (index 0xF050)
AvailableModulesIReadOnlyList<MdpAvailableModule>read-onlyOptional modules declared in the ESI (cached)
Module indexModuleIndexDistanceushortread-onlyModule index distance (0xF000:01, default 0x0008); slot OD address = distance × slot number
SlotPdoIncrementushortread-onlyModule PDO index increment declared by the Slots node in the ESI; returns 1 when not declared
Identity arraysConfigModuleIdentsuint[]read-only0xF030 module ident array (read directly, no ESI dependency)
DetectedModuleIdentsuint[]read-only0xF050 module ident array (read directly, no ESI dependency)
Read statusLastConfigReadStatusMdpIdentReadStatusread-onlyResult of the most recent 0xF030 read; NotRead before the first read
LastDetectedReadStatusMdpIdentReadStatusread-onlyResult of the most recent 0xF050 read; NotRead before the first read
MdpIdentReadStatus enum
public enum MdpIdentReadStatus
{
NotRead, // Never read: the read entry point was never called, so it cannot support any conclusion
Ok, // The list was read completely (0 entries = the slave explicitly answered that it has no modules)
ObjectNotSupported, // The device explicitly does not implement that object - a definitive conclusion, not a communication failure
ReadFailed, // Read failed (timeout / no reply) - the result is unknown and must not be taken as "no modules"
Incomplete // The list is incomplete - the entry count is not trustworthy
}

ConfiguredModules​

public IReadOnlyList<MdpSlotInfo> ConfiguredModules { get; }

Configured module list. Every access reads it live (index 0xF030, read directly, no ESI dependency); module names and I/O types are derived from the ESI.

Returns:

  • IReadOnlyList<MdpSlotInfo> — configured module list

Related structures:

public class MdpSlotInfo
{
public int SlotIndex { get; set; } // slot index (starting at 1)
public uint ModuleIdent { get; set; } // module ident code (32-bit)
public string ModuleName { get; set; } // module name
public uint ModuleType { get; set; } // module device type code
public string Status { get; set; } // status ("configured" / "detected")
public ushort ObjectDictionaryIndex { get; set; } // object dictionary base address
public string ModuleIOType { get; set; } // I/O type (Input / Output / I/O / Unknown)
}
ModuleIOType determination logic

TxPdo / RxPdo configuration is read from the module definition in the ESI file first:

  • TxPdo only → "Input" (slave sends to the master)
  • RxPdo only → "Output" (master sends to the slave)
  • both → "I/O"

When the ESI cannot determine it, the code falls back to keyword matching on the module name.

Example:

foreach (var slot in slave.MDP.ConfiguredModules)
Console.WriteLine($"Slot {slot.SlotIndex}: {slot.ModuleName} (0x{slot.ModuleIdent:X8})");

DetectedModules​

public IReadOnlyList<MdpSlotInfo> DetectedModules { get; }

Detected module list, reflecting the modules physically inserted. Every access reads it live (index 0xF050, read directly, no ESI dependency); module names and I/O types are derived from the ESI.

Returns:

  • IReadOnlyList<MdpSlotInfo> — detected module list (same structure as ConfiguredModules)

Example:

foreach (var slot in slave.MDP.DetectedModules)
Console.WriteLine($"Slot {slot.SlotIndex}: {slot.ModuleName}");

AvailableModules​

public IReadOnlyList<MdpAvailableModule> AvailableModules { get; }

Optional module list declared in the ESI. The ESI file must have been imported for the slave; otherwise an empty list is returned. The result is cached and parsed only on first access.

Returns:

  • IReadOnlyList<MdpAvailableModule> — optional module list

Related structures:

public class MdpAvailableModule
{
public uint ModuleIdent { get; set; } // module ident code
public uint ModuleType { get; set; } // module device type code
public string ModuleName { get; set; } // module name
public string Description { get; set; } // module description
}

Example:

foreach (var mod in slave.MDP.AvailableModules)
Console.WriteLine($"{mod.ModuleName} (0x{mod.ModuleIdent:X8})");

LastConfigReadStatus​

public MdpIdentReadStatus LastConfigReadStatus { get; }

The conclusion of the most recent read of the 0xF030 configured module ident list, updated by ConfigModuleIdents and TryReadConfigIdents. See MdpIdentReadStatus for the values.

note

Only Ok with 0 entries means the slave explicitly answered "there are no configured modules". NotRead / ObjectNotSupported / ReadFailed / Incomplete all leave the conclusion unknown and must not be treated as 0 modules.

Example:

uint[] idents = slave.MDP.ConfigModuleIdents;
if (slave.MDP.LastConfigReadStatus != MdpIdentReadStatus.Ok)
Console.WriteLine($"0xF030 结论不可用: {slave.MDP.LastConfigReadStatus}"); // 0xF030 conclusion unavailable: {slave.MDP.LastConfigReadStatus}

LastDetectedReadStatus​

public MdpIdentReadStatus LastDetectedReadStatus { get; }

The conclusion of the most recent read of the 0xF050 detected module ident list, updated by DetectedModuleIdents and TryReadDetectedIdents. See MdpIdentReadStatus for the values.

note

Only Ok with 0 entries means the slave explicitly answered "no modules detected". Every other value leaves the conclusion unknown and must not be treated as the device having no modules.

Example:

uint[] idents = slave.MDP.DetectedModuleIdents;
if (slave.MDP.LastDetectedReadStatus != MdpIdentReadStatus.Ok)
Console.WriteLine($"0xF050 结论不可用: {slave.MDP.LastDetectedReadStatus}"); // 0xF050 conclusion unavailable: {slave.MDP.LastDetectedReadStatus}

SlotPdoIncrement​

public ushort SlotPdoIncrement { get; }

Module PDO index increment declared by the Slots node in this device's ESI. The actual index of a module PDO = the base index within the group + (slot number - 1) × this value + the ESI relative index. Returns 1 when no ESI is loaded, the ESI has no Slots node, or the field is not declared; when several ESI files are loaded at the same time, the value from the file this device belongs to wins.

Returns:

  • ushort — the increment; 1 when it is not declared

Example:

ushort step = slave.MDP.SlotPdoIncrement;
int slotIndex = 2;
int pdoIndexOffset = (slotIndex - 1) * step;
Console.WriteLine($"槽位 {slotIndex} 的 PDO 索引偏移: 0x{pdoIndexOffset:X}"); // PDO index offset for slot {slotIndex}: 0x{pdoIndexOffset:X}

Methods​

CategoryMethodReturn typeRead/writeDescription
Module detectionDetectModules()boolwriteTriggers a rescan of the modules installed on the slave (writes 0xF002:01)
CheckModuleMatch()ModuleListMatchResultread-onlyChecks whether the 0xF030 and 0xF050 lists match
List readsReadModuleProfileList()Dictionary<byte, uint>read-onlyReads the Module Profile List (0xF010)
ReadConfiguredAddressList()Dictionary<byte, uint>read-onlyReads the Configured Address List (0xF020)
ReadDetectedAddressList()Dictionary<byte, uint>read-onlyReads the Detected Address List (0xF040)
TryReadConfigIdents()boolread-onlyReads the 0xF030 ident list; returns success and a diagnostic conclusion in Chinese (distinguishes a read failure from 0 modules)
TryReadDetectedIdents()boolread-onlyReads the 0xF050 ident list; returns success and a diagnostic conclusion in Chinese (distinguishes a read failure from 0 modules)
PDO layoutGetModulePdoLayout()List<MdpModulePdoInfo>?read-onlyPDO layout of each module in the IOmap
Automatic configurationAutoConfigureFromDetectedModules()List<StartupParameter>read-onlyGenerates startup parameters from the detected modules; generates only, does not write to the device

DetectModules()​

public bool DetectModules()

Triggers the slave module detection command (ETG.5001.1 Table 5, writes 0xF002:01); the slave rescans the installed modules. Some slaves do not support this object, so confirm the device implements it before calling. After success, the next property access returns the latest data.

Returns:

  • bool — true when the write succeeds, false when the write fails or the slave does not support it

Example:

if (slave.MDP.DetectModules())
Console.WriteLine("模块检测命令已下发"); // Module detection command issued

CheckModuleMatch()​

public ModuleListMatchResult CheckModuleMatch()

Checks whether the 0xF030 configured module list and the 0xF050 detected module list agree, for manual review. The method only reads the two lists and does not change the slave state.

The conclusion has three states, not a bool:

  • Full match — IsMatch is true and FirstMismatchSlot is -1
  • Mismatch — IsMatch is false and Undetermined is false; FirstMismatchSlot points at the first slot that differs (0-based)
  • Undetermined — IsMatch is false and Undetermined is true; the reason is in UndeterminedReason (object does not exist / read failed / list incomplete / the slave does not support MDP)
caution

Undetermined is neither a "full match" nor a "mismatch". The UI and the log must show UndeterminedReason; never render every IsMatch == false as "modules do not match".

Returns:

Related structures:

ModuleListMatchResult​

public class ModuleListMatchResult
{
public bool IsMatch { get; set; } // Whether it matches exactly (same count + same identity per slot)
public bool Undetermined { get; set; } // Whether it "cannot be determined"; IsMatch must then be false, but the reason is not a mismatch
public string UndeterminedReason { get; set; } // Specific reason it cannot be determined (populated when Undetermined is true)
public int FirstMismatchSlot { get; set; } // Index of the first mismatching slot (from 0); -1 when it matches or cannot be determined
public uint[] ConfigIdents { get; set; } // 0xF030 array of module identities read (empty array when it cannot be read, which does not mean 0 modules)
public uint[] DetectedIdents { get; set; } // 0xF050 array of module identities read (empty array when it cannot be read, which does not mean 0 modules)
public string Message { get; set; } // Explanation of the outcome (match / mismatch / why it cannot be determined)
}

Example:

var match = slave.MDP.CheckModuleMatch();
if (match.IsMatch)
Console.WriteLine("模块列表完全匹配"); // Module list matches exactly
else if (match.Undetermined)
Console.WriteLine($"无法判定: {match.UndeterminedReason}"); // Cannot be determined: {match.UndeterminedReason}
else
Console.WriteLine($"模块不一致,首个差异槽位: {match.FirstMismatchSlot}"); // Module mismatch, first differing slot: {match.FirstMismatchSlot}

GetModulePdoLayout()​

public List<MdpModulePdoInfo>? GetModulePdoLayout()

Gets the PDO layout of each module in the slave IOmap. It reads the PDO Assignment (0x1C12/0x1C13) and PDO Mapping entries through CoE SDORead and accumulates the byte offset of each module.

note

Requires the slave to be configured through DENI (available after ConfigMap); it does not depend on an ESI file. Returns null when CoE is unavailable or no module is detected.

Returns:

  • List<MdpModulePdoInfo>? — PDO layout information of each module; returns null when it cannot be obtained

Related structures:

public class MdpModulePdoInfo
{
public int SlotIndex { get; set; } // slot index
public uint InputOffset { get; set; } // input PDO offset (relative to slave.Ioffset)
public ushort InputSize { get; set; } // input PDO byte count
public uint OutputOffset { get; set; } // output PDO offset (relative to slave.Ooffset)
public ushort OutputSize { get; set; } // output PDO byte count
}

Example:

var layout = slave.MDP.GetModulePdoLayout();
if (layout != null)
{
foreach (var mod in layout)
Console.WriteLine($"Slot {mod.SlotIndex}: In={mod.InputSize}B @{mod.InputOffset}, Out={mod.OutputSize}B @{mod.OutputOffset}");
}

TryReadConfigIdents(out uint[] idents, out string reason)​

public bool TryReadConfigIdents(out uint[] idents, out string reason)

Reads the 0xF030 configured module ident list. It returns true only when the whole list was read; a failed read, an object that does not exist, and an incomplete list all return false together with a reason in Chinese — in that case idents is an empty array but does not mean there are no modules. The read conclusion is also written to LastConfigReadStatus.

Parameters:

  • idents (uint[]) — the complete ident list (valid only when the method returns true; may contain 0 entries)
  • reason (string) — a diagnosable conclusion in Chinese (the entry count is included on success as well)

Returns:

  • bool — whether the whole list was read

Example:

if (slave.MDP.TryReadConfigIdents(out var idents, out var reason))
Console.WriteLine($"已配置模块: {idents.Length} 个"); // Configured modules: {idents.Length}
else
Console.WriteLine($"读取未完成: {reason}"); // Read incomplete: {reason}

TryReadDetectedIdents(out uint[] idents, out string reason)​

public bool TryReadDetectedIdents(out uint[] idents, out string reason)

Reads the 0xF050 detected module ident list. It returns true only when the whole list was read; a failed read, an object that does not exist, and an incomplete list all return false together with a reason in Chinese — in that case idents is an empty array but does not mean the device has no modules. The read conclusion is also written to LastDetectedReadStatus.

Parameters:

  • idents (uint[]) — the complete ident list (valid only when the method returns true; may contain 0 entries)
  • reason (string) — a diagnosable conclusion in Chinese (the entry count is included on success as well)

Returns:

  • bool — whether the whole list was read

Example:

if (slave.MDP.TryReadDetectedIdents(out var idents, out var reason))
Console.WriteLine($"已检测模块: {idents.Length} 个"); // Detected modules: {idents.Length}
else
Console.WriteLine($"读取未完成: {reason}"); // Read incomplete: {reason}

AutoConfigureFromDetectedModules()​

public List<StartupParameter> AutoConfigureFromDetectedModules()

Generates a set of startup parameters from the modules detected through 0xF050: module SDOInit, the write of the 0xF030 configured module list, and the global PDO Assignment (0x1C12 / 0x1C13). The method only generates the parameters and returns them; it does not write to the device. In normal scenarios the automatic startup flow calls it internally, so users generally do not need to run it directly.

Degraded behavior

It returns an empty list directly when 0xF050 was not read in full or explicitly reports 0 modules. When no ESI is loaded, or the ESI lacks definitions for some of the detected modules, only the 0xF030 write parameter is generated — module SDOInit and PDO Assignment are not generated, and the slave keeps its default mapping. It also returns an empty list when CoE is unavailable.

If ESI parsing throws InvalidOperationException, the method rethrows it as-is and does not swallow it into an empty list.

Returns:

  • List<StartupParameter> — startup parameters that can be added to slave.StartupParameters directly (not yet sent)

Example:

if (slave.MDP != null)
{
foreach (var param in slave.MDP.AutoConfigureFromDetectedModules())
slave.StartupParameters.Add(param);
}

Automatic configuration​

Automatic configuration of MDP devices requires the corresponding ESI file to be imported first, and is performed by the following methods: