Master object dictionary (Master OD)
A master object dictionary that follows ETG.1510, exposing master identity plus slave configuration, state and diagnostic data to external diagnostic tools and HMI over the standard SDO interface.
Access through master.MasterOD.
The master object dictionary follows the ETG.1510 specification and the standard CoE index conventions. Unlike a slave CoE object dictionary, it holds the diagnostic objects that the master exposes for itself. Together with the mailbox gateway, it gives remote diagnostic tools standard access to the master.
Object index overview
| Index | Name | Subindexes | Read/write | Description |
|---|---|---|---|---|
| 0x1000 | Device Type | 0 | Read-only | 0x00001389 (EtherCAT master) |
| 0x1008 | Device Name | 0 | Read-only | "Darra EtherCAT Master" |
| 0x1009 | Hardware Version | 0 | Read-only | Process bitness: a 64-bit process returns "x64", a 32-bit process returns "x86" |
| 0x100A | Software Version | 0 | Read-only | SDK version string |
| 0x1018 | Identity Object | 4 | Read-only | Master identity (see the subindex table below) |
| 0x8nnn | Configuration Data | 40 | Read-only | Configuration data of slave n (address, name, vendor, mailbox, and so on) |
| 0x9nnn | Information Data | 32 | Read-only | Detected information of slave n (actual address, vendor ID, DL Status) |
| 0xAnnn | Diagnosis Data | 19 | Partially writable | Diagnostic data of slave n (AL Status, error counters, link, and so on) |
| 0xF002 | Detect Modules | 3 | Read-only | Slave scan status (external writes are rejected) |
| 0xF120 | Master Diag Data | 16 | Read-only | Master diagnostic data (lost-frame count, frame rate, state) |
| 0xF200 | Diag Interface Control | 16 | Writable | Diagnostic interface control (reset diagnostic information) |
nnn = slave index (1-based); the indexes are generated dynamically from master.SlaveCount. With 3 slaves, for example, 0x8001 ~ 0x8003, 0x9001 ~ 0x9003 and 0xA001 ~ 0xA003 are all accessible.
0x1018 — Master identity (Identity Object)
| Subindex | Name | Type | Value | Description |
|---|---|---|---|---|
| 0 | Number of Entries | byte | 4 | Fixed |
| 1 | Vendor ID | uint | 0x00001164 | Assigned by ETG, fixed value |
| 2 | Product Code | uint | 0x00000001 | Fixed value |
| 3 | Revision Number | uint | Automatic | Derived automatically from the SDK version (high word = major version, low word = minor version) |
| 4 | Serial Number | uint | Automatic, incrementing | Each instance is assigned 0, 1, 2… automatically, so several master instances can be told apart |
0x8nnn — Slave configuration data
Each slave has one 0x8nnn object (nnn = slave index) holding the static information configured in the ENI.
| Subindex | Name | Type | Read/write | Description |
|---|---|---|---|---|
| 0 | Number of Entries | byte | Read-only | Fixed at 40 |
| 1 | Fixed Station Address | ushort | Read-only | Configured address (ConfigAddr) |
| 2 | Type | string | Read-only | Device type string (DriveName) |
| 3 | Name | string | Read-only | Device name |
| 4 | Device Type | uint | Read-only | Device type code (always 0 at present; no usable data source) |
| 5 | Vendor ID | uint | Read-only | Vendor ID |
| 6 | Product Code | uint | Read-only | Product code |
| 7 | Revision Number | uint | Read-only | Revision number |
| 8 | Serial Number | uint | Read-only | Serial number |
| 33 | Mailbox Out Size | ushort | Read-only | SM0 mailbox output size |
| 34 | Mailbox In Size | ushort | Read-only | SM1 mailbox input size |
| 35 | Link Status | byte | Read-only | ETG.1510 port link status. bit0 = slave lost (judged from the live verdict for the current cycle, not carried over from a latched historical state); bit(4+p) = port p currently has a link (p=0..3); the remaining bits are always 0. A 0 does not mean "all four ports are down": all high bits 0 can also mean this slave's DLSTAT was never sampled. When the SDK returns <0 (bad parameter / not ready), the read returns null = subindex unavailable, not 0. |
| 36 | Link Preset | byte | Read-only | ETG.1510 port link preset. Low nibble = mask of the ports expected to have a link (bit0..3 = P0..P3), high nibble = the same mask shifted left by 4; N linked ports → 0x11 / 0x33 / 0x77 / 0xFF. The input is the popcount of the ports active in the current cycle (200ms DLSTAT refresh), the same sample as :35; it is not the link count from configuration time. 0 = no port is expected to have a link (also returned as 0 when the input is unknown). When the SDK returns <0, the read returns null = subindex unavailable, not 0. |
| 37 | Flags | byte | Read-only | Slave flags (Bit3 reserved; currently 0) |
| 38 | Port Physics | ushort | Read-only | Port physical type |
| 39 | Mailbox Protocols | ushort | Read-only | Supported mailbox protocols (CoE=0x04, FoE=0x08, and so on) |
| 40 | Diag History Supported | byte | Read-only | Whether the 0x10F3 diagnostic history object is supported (0 = not supported; returns null when the CoE object dictionary is not loaded — the diagnostic read path does not scan the bus) |
0x9nnn — Slave detection information
Each slave has one 0x9nnn object holding the actual information detected at runtime.
| Subindex | Name | Type | Read/write | Description |
|---|---|---|---|---|
| 0 | Number of Entries | byte | Read-only | Fixed at 32 |
| 1 | Station Address | ushort | Read-only | Actual configured address |
| 5 | Vendor ID | uint | Read-only | Detected vendor ID |
| 6 | Product Code | uint | Read-only | Detected product code |
| 7 | Revision Number | uint | Read-only | Detected revision number |
| 8 | Serial Number | uint | Read-only | Detected serial number |
| 32 | DL Status | ushort | Read-only | DL Status register (ESC 0x0110-0x0111) |
0xAnnn — Slave diagnostic data
Each slave has one 0xAnnn object holding live diagnostic data. It is updated automatically on every read.
| Subindex | Name | Type | Read/write | Description |
|---|---|---|---|---|
| 0 | Number of Entries | byte | Read-only | Fixed at 19 |
| 1 | AL Status | ushort | Read-only | Current AL state |
| 2 | AL Control | ushort | Writable | Written through to the slave |
| 3 | Last AL Status Code | ushort | Read-only | Most recent AL error code (ESC 0x0134) |
| 4 | Link Conn. Status | byte | Read-only | ETG.1510 two-bit-per-port connection state (0 no signal / 1 internal loopback only / 2 communication established / 3 signal present and loop closed); it is not "which port of the parent this slave is attached to" — for that the only answer is Slave.ParentPort. When the per-port two-bit state is unavailable, the read returns null = subindex unavailable. |
| 5 | Link Control | byte | Read-only | Link control (DL Control register 0x0101) |
| 6 | Fixed Addr Conn. Port 0 | ushort | Read-only | Fixed address of the slave connected to port 0 of this slave (the upstream parent). 0 = this port reports no connected slave and does not mean nothing is connected; to find which port of the parent this slave is attached to, use Slave.ParentPort. |
| 7 | Fixed Addr Conn. Port 1 | ushort | Read-only | Fixed address of the slave connected to port 1 of this slave (a downstream child, child parent_port == 1). 0 = this port reports no connected slave and does not mean nothing is connected; to find which port of the parent this slave is attached to, use Slave.ParentPort. |
| 8 | Fixed Addr Conn. Port 2 | ushort | Read-only | Fixed address of the slave connected to port 2 of this slave (a downstream child, child parent_port == 2). 0 = this port reports no connected slave and does not mean nothing is connected; to find which port of the parent this slave is attached to, use Slave.ParentPort. |
| 9 | Fixed Addr Conn. Port 3 | ushort | Read-only | Fixed address of the slave connected to port 3 of this slave (a downstream child, child parent_port == 3). 0 = this port reports no connected slave and does not mean nothing is connected; to find which port of the parent this slave is attached to, use Slave.ParentPort. |
| 10 | Frame Error Port 0 | uint | Read-only | Port 0 frame error count |
| 11 | Frame Error Port 1 | uint | Read-only | Port 1 frame error count |
| 12 | Frame Error Port 2 | uint | Read-only | Port 2 frame error count |
| 13 | Frame Error Port 3 | uint | Read-only | Port 3 frame error count |
| 14 | Cyclic WC Error Counter | uint | Read-only | Cyclic working counter errors (no usable data source; the read returns null = subindex unavailable) |
| 15 | Slave Not Present Counter | uint | Read-only | Count of slaves not present (no usable data source; the read returns null = subindex unavailable) |
| 16 | Abnormal State Change Counter | uint | Read-only | Count of abnormal state changes (no usable data source; the read returns null = subindex unavailable) |
| 17 | Disable Auto Link Control | byte | Read-only | No usable data source; the read returns null (subindex unavailable) — do not treat it as false |
| 18 | Last CoE/SoE Protocol Error | uint | Read-only | Most recent CoE/SoE protocol error code |
| 19 | New Diag Messages | byte | Read-only | Whether there are new diagnostic messages (answered only when 0x10F3:4 was really read from the slave; returns null when no usable data source exists) |
Subindexes 6..9 are delivered by the SDK 4 ports at a time: out[p] = the fixed address of the slave connected to port p of this slave (p=0 the upstream parent; p=1..3 a downstream child whose parent_port == p; a parent_port of 0xFE/0xFF means unknown and takes no part in matching). The caller's array must be int[4]; the SDK does not check its capacity. When the call returns <0 (bad parameter / not ready), all four subindexes report null = subindex unavailable; it does not write 0 to pass off "all four ports are empty".
0xF002 — Scan command
The 0xF002 scan command rejects external writes. Running a scan while the master is operating can lose the configuration and upset devices, so this object is read-only.
A slave scan runs only during master initialization.
| Subindex | Name | Type | Read/write | Description |
|---|---|---|---|---|
| 0 | Number of Entries | byte | Read-only | Fixed at 3 |
| 1 | Scan Command Request | ushort | Read-only | Scan command request (external writes are rejected) |
| 2 | Scan Command Status | byte | Read-only | Always 1 (the scan command rejects writes, so the state machine never leaves the idle state; in the specification 1 = finished without error, 3 = finished with error, 255 = in progress) |
| 3 | Scan Command Response | byte[6] | Read-only | State + reserved 0 + error code (2 bytes) + current slave count (2 bytes, live value) |
0xF120 — Master diagnostic data
| Subindex | Name | Type | Read/write | Description |
|---|---|---|---|---|
| 0 | Number of Entries | byte | Read-only | Fixed at 16 |
| 1 | Cyclic Lost Frames | uint | Read-only | Cyclic lost-frame count (reads the raw lost-frame counter, not a percentage) |
| 2 | Acyclic Lost Frames | uint | Read-only | Acyclic lost-frame count (this implementation always returns 0) |
| 3 | Cyclic Frames/Second | uint | Read-only | Cyclic frames per second |
| 4 | Acyclic Frames/Second | uint | Read-only | Acyclic frames per second (this implementation always returns 0) |
| 16 | Master State | ushort | Read-only | Current EtherCAT state of the master |
This path returns the raw lost-frame counter (it only increases from the counting start point; it returns to zero when 0xF200:16 resets it). It is a count of lost frames, not a lost-frame rate in percent.
0xF200 — Diagnostic interface control
| Subindex | Name | Type | Read/write | Description |
|---|---|---|---|---|
| 0 | Number of Entries | byte | Read-only | Fixed at 16 |
| 16 | Reset Diag Info | byte | Writable | Writing 1 resets the diagnostic counters of all slaves and of the master (triggered on a rising edge) |
Methods
ReadObject(ushort index, byte subindex)
public byte[]? ReadObject(ushort index, byte subindex)
Reads the data at the given index from the master object dictionary.
Parameters:
index(ushort) — object index (such as0x1018,0x8001,0xA001)subindex(byte) — subindex
Returns:
byte[]?— the raw data read; an unknown object returnsnull
Example:
byte[] vid = master.MasterOD.ReadObject(0x8001, 5);
uint vendorId = BitConverter.ToUInt32(vid, 0);
ReadObject(ushort index, byte subindex, out byte[] data, out ushort abortCode)
public int ReadObject(ushort index, byte subindex, out byte[] data, out ushort abortCode)
Reads the master object dictionary and keeps both the return code and the CoE abort code. A failure is no longer collapsed into a single null: the caller can tell "the object / subindex does not exist" from "the bus did not answer", which suits a diagnostic tool that enumerates a whole range of subindexes.
Parameters:
index(ushort) — object indexsubindex(byte) — subindexdata(out byte[]) — the data read; an empty array on failure (this overload does not returnnull)abortCode(out ushort) — CoE abort code (ETG.1000.6); 0 on success
Returns:
int—>= 0= number of bytes written todata; a negative value = failure code (object / subindex does not exist, master not ready, invalid parameter, buffer too small, bus I/O failure, version not supported). When the master is not yet created or already closed, it returns at once without starting a bus read
Example:
int rc = master.MasterOD.ReadObject(0x8001, 5, out byte[] data, out ushort abort);
if (rc < 0)
Console.WriteLine($"读失败 rc={rc}, CoE abort=0x{abort:X4}"); // Read failed rc={rc}, CoE abort=0x{abort:X4}
else
Console.WriteLine($"读到 {data.Length} 字节"); // Read {data.Length} bytes
WriteObject(ushort index, byte subindex, byte[] data)
public bool WriteObject(ushort index, byte subindex, byte[] data)
Writes to the master object dictionary. Only some objects accept writes (see the Read/write column of the object tables above).
Parameters:
index(ushort) — object indexsubindex(byte) — subindexdata(byte[]) — the data to write
Returns:
bool—trueon success
WriteObject(ushort index, byte subindex, byte[] data, out ushort abortCode)
public int WriteObject(ushort index, byte subindex, byte[] data, out ushort abortCode)
Writes to the master object dictionary and keeps both the return code and the CoE abort code (WriteObject(index, subindex, data) is the Boolean view of this overload). The writable range matches the WriteObject above; every other object is honestly rejected as read-only / unsupported.
Parameters:
index(ushort) — object indexsubindex(byte) — subindexdata(byte[]) — the data to writeabortCode(out ushort) — CoE abort code (ETG.1000.6); 0 on success
Returns:
int—0= success; a negative value = failure code (not writable / object does not exist / master not ready / invalid parameter / bus I/O failure / version not supported). When the master is not yet created or already closed, it returns at once without starting a bus write
GetObjectName(ushort index)
public string GetObjectName(ushort index)
Gets the name of an object.
Parameters:
index(ushort) — object index
Returns:
string— the object name; an unknown index returns a string of the form"Unknown (原始值: …)"(SDK output, = Unknown (original value: …))
GetSubindexCount(ushort index)
public byte GetSubindexCount(ushort index)
Gets the subindex count of an object.
Parameters:
index(ushort) — object index
Returns:
byte— the subindex count
GetSupportedObjectIndices()
public List<ushort> GetSupportedObjectIndices()
Gets the list of all object indexes currently supported (fixed indexes plus the 0x8nnn/0x9nnn/0xAnnn ranges generated dynamically from the slave count).
Returns:
List<ushort>— the list of supported indexes
Shortcut methods
// Same as master.MasterOD.ReadObject(index, subindex)
byte[] data = master.ReadMasterObject(0x1018, 1);
// Same as master.MasterOD.WriteObject(index, subindex, data)
bool ok = master.WriteMasterObject(0xF200, 16, new byte[] { 1 });
Full example
var od = master.MasterOD;
// Walk the diagnostic data of every slave
for (ushort i = 1; i <= master.SlaveCount; i++)
{
ushort cfgIdx = (ushort)(0x8000 | i);
ushort diagIdx = (ushort)(0xA000 | i);
// Read the slave name
byte[] nameData = od.ReadObject(cfgIdx, 3);
string name = nameData != null ? Encoding.ASCII.GetString(nameData) : "N/A";
// Read AL Status and the error code
byte[] alStatus = od.ReadObject(diagIdx, 1);
byte[] alCode = od.ReadObject(diagIdx, 3);
// Read the frame error count of each port
uint[] portErrors = new uint[4];
for (byte p = 0; p < 4; p++)
{
byte[] err = od.ReadObject(diagIdx, (byte)(10 + p));
if (err != null) portErrors[p] = BitConverter.ToUInt32(err, 0);
}
Console.WriteLine($"从站{i} [{name}]: " + // Slave{i} [{name}]:
$"AL=0x{BitConverter.ToUInt16(alStatus ?? new byte[2], 0):X4}, " +
$"Code=0x{BitConverter.ToUInt16(alCode ?? new byte[2], 0):X4}, " +
$"Errors=[{string.Join(",", portErrors)}]");
}
// Reset all diagnostics
od.WriteObject(0xF200, 16, new byte[] { 1 });