Skip to main content

ENI/DENI configuration management

ENI is the network configuration file for EtherCAT: which slaves are on the bus, how PDO is mapped, and how DC and the startup parameters are set are all written in this file. DENI is Darra's version of the standard ENI with deni: extensions added.

Why two? The standard ENI is the format shared across the industry: common EtherCAT configuration tools can all export it, and the SDK loads it directly. But it has none of the engineering semantics "this slot may be absent", "bind the slot by identity", "replay the startup parameters after a module is replaced". DENI adds those deni: extensions; the body of the file (slaves, PDO, DC, startup parameters) is still standard ENI structure.

ItemStandard ENIDENI
Typical sourceExported by other EtherCAT configuration toolsExported by the Darra configuration tool
Slaves, PDO, DC, startup parametersYesYes (the same body)
Optional slot <deni:Optional>NoYes
Slot binding by identity, hot-plug replayNoYes
Network portMust be specified with SetNetworkThe file carries network port information, so the NIC is selected automatically
Recommended useCompatible format for importing existing projectsPreferred for new projects
Recommended workflow
  1. Use the Darra configuration tool to connect to the slaves and configure PDO/DC/startup parameters
  2. Export a DENI file (.deni)
  3. Load the configuration in code with SetENI() + Build()
Public API only

This page covers public API usage only.

Loading a configuration​

The user SDK only goes through SetENI. SetENI(path) only records the path; the file is not actually read until Build(). C# does not expose a configuration method of the same name.

Build() decides which route to take from the file content:

  • DENI (EtherCATConfig + deni: extensions): the full engineering semantics — slot binding by identity, optional slots, absent/extra slave handling, grouping/watchdog/DC contracts, hot-plug replay.
  • Standard ENI (no deni: extensions): the compatibility path, where startup parameters and device characteristics are applied by declaration position. It has no concept of optional slots, and provides neither slot binding by identity nor automatic promotion on hot-plug; with this format you must specify the network port yourself with SetNetwork.
  • Other formats (neither DENI nor standard ENI): Build() fails outright and lists the supported formats; it does not guess.

Network port override rule: with SetENI(...).SetNetwork(...), SetNetwork overrides the NIC only and the rest of the DENI takes effect as usual; with SetNetwork(...).SetENI(...), the network port in the file wins.

Build() applies the NIC, slave, PDO, DC, SDO, watchdog, and grouping configuration in the file; if the scan finds no slaves, the build fails and the reason is in the returned message.

SetENI(string eniPath)​

public DarraEtherCAT SetENI(string eniPath)

Loads a DENI or ENI configuration file. The path takes effect at Build().

Parameters:

  • eniPath (string) — path to the DENI or ENI configuration file

Returns:

  • DarraEtherCAT — the current instance, supporting chained calls

Example:

var ecat = new DarraEtherCAT().SetENI(@"C:\EtherCAT\MyProject.deni");
var result = ecat.Build();

if (!result.Success)
{
Console.WriteLine($"初始化失败:{result.Message}"); // Initialization failed: {result.Message}
return;
}

var master = result.Master;
if (master == null) return;
master.SetState(EcState.OP, out var error);
Exporting a DENI is provided by Darra products

The SDK exposes no interface for "saving a configuration" or "scanning the current hardware to generate a DENI". Use the wizard in the Darra main application or on the PLC side to complete the configuration and export a DENI, then load it in code with SetENI(path).Build().

When there is no DENI and ESI auto-matching is needed, use SetEsiFile / SetEsiFiles + EnableAutoStartup().

Validate()​

public ValidationResult Validate()

Validates that the configuration is complete without running Build(); use it for pre-checks.

Returns:

public class ValidationResult
{
public bool IsValid { get; } // whether validation passed
public IReadOnlyList<string> Errors { get; } // validation error list (empty when it passes)
}

Current checks: a NIC or ENI configuration has been set, the ENI file exists, and the master instance limit has not been reached.

A passing Validate() does not mean Build() will succeed: it checks only "does the file exist, is a network port set, is the instance count within the limit" — it does not parse the file content and never touches the bus. Slave declarations, identities and PDO conflicts in the file are only exposed at Build().

Example:

var result = new DarraEtherCAT().SetENI(@"C:\EtherCAT\MyProject.deni").Validate();
if (!result.IsValid)
{
foreach (var err in result.Errors)
Console.WriteLine(err);
return;
}

Troubleshooting build failures​

Start with the three fields of BuildResult: Success for whether it succeeded, Message for the failure reason, and Outcome, which is Success / AlreadyBuilt / Failed. A second Build() call on the same instance returns AlreadyBuilt (Success is still true); it neither reinitializes nor rescans.

SymptomCommon causeAction
A file-not-found error is reportedWrong path, or a relative path resolved against the wrong baseUse an absolute path; check the runtime working directory
Scan finds 0 slavesWrong NIC, slaves not powered up, broken wiring, or the network port information in the DENI does not match the local NICCheck the MAC and link with GetNetworkAdapters(); for a standard ENI, specify the NIC with SetNetwork
Identity mismatchThe Vendor/Product declared in the DENI does not match the actual modulePut the correct module back, or change the configuration; a Revision difference between same-model modules is not an identity mismatch
Mandatory slave absentThe slot is not declared optionalAdd <deni:Optional>true</deni:Optional>, or plug the module back in
Master instance limit reachedUnclosed masters are still open in the same processClose() / Dispose() unused instances first
Validate() passes but Build() failsValidate() checks only the file and the network port settings; it does not parse the contentLook at Message and the failing stage in the log
The DENI loads, but a replaced module is not promoted automaticallyA standard ENI is in use; or the slot is not declared optional; or the new module's identity is not declaredSwitch to a DENI, add the optional declaration, or follow the model-change procedure in Hot-plug

How to tell same-model recovery from a model change: read slave.VendorId, slave.ProductId and slave.RevId for that slave, or subscribe to SlaveIdentityMismatch (the payload carries both the expected identity and the measured one). Same Vendor/Product = same model (Revision is recorded only, never a reason to reject); a different Vendor or Product = a model change. The former is recovered automatically by the master; for the latter you select the configuration at the application layer.

What to look at when a slave will not reach OP: check slave.State and slave.IsLost first, then slave.ErrorCode (the full AL Status Code). For what the AL codes mean and the troubleshooting order see Diagnostics; for identity problems see Hot-plug.

Full example​

var ecat = new DarraEtherCAT().SetENI(@"C:\EtherCAT\MyProject.deni");

// Pre-check: does the file exist, is a network port set, is the instance count within the limit
var check = ecat.Validate();
if (!check.IsValid)
{
foreach (var err in check.Errors)
Console.WriteLine(err);
return;
}

var result = ecat.Build();
if (!result.Success)
{
Console.WriteLine($"初始化失败:{result.Message}"); // Initialization failed: {result.Message}
return;
}

var master = result.Master;
if (master == null) return;

if (!master.SetState(EcState.OP, out var error))
{
Console.WriteLine($"切换 OP 失败:{error}"); // Failed to switch to OP: {error}
return;
}

Console.WriteLine($"主站已到 OP,从站 {master.SlaveCount} 个"); // Master reached OP, {master.SlaveCount} slaves
Related

ENI/DENI configuration is used together with Initialization and construction (SetENI() / Build() streaming initialization).