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 uses the standard CoE index conventions. Unlike a slave CoE object dictionary, it holds the diagnostic objects the master exposes for itself. Together with the mailbox gateway, it enables standard access to the master for remote diagnostic tools.
Object index overview
| Category | Index | Name | Subindexes | Read/write | Description |
|---|---|---|---|---|---|
| Identity | 0x1000 | Device Type | 0 | Read-only | 0x00001389 (EtherCAT master) |
| Identity | 0x1008 | Manufacturer Device Name | 0 | Read-only | "Darra EtherCAT Master" |
| Identity | 0x1009 | Manufacturer Hardware Version | 0 | Read-only | Process bitness: a 64-bit process returns "x64", a 32-bit process returns "x86" (through the ETG.1510 read entry point) |
| Identity | 0x100A | Manufacturer Software Version | 0 | Read-only | Runtime library version number (major.minor.revision[.build]) |
| Identity | 0x1018 | Identity Object | 4 | Read-only | Master identity information (see the subindex table below) |
| Configuration | 0x8nnn | Configuration Data | 40 | Read-only | Configuration data of slave n (address, type, name, identity, mailbox sizes, link status/preset) |
| Detection | 0x9nnn | Information Data | 32 | Read-only | Fixed information of slave n (configuration address, vendor/product/revision/serial number, DL status) |
| Diagnostics | 0xAnnn | Diagnosis Data | 19 | Read/write | Diagnostic data of slave n (AL Status, link, port connection addresses, port error counters and so on; only :2 is writable) |
| Detection | 0xF002 | Detect Modules Command | 3 | Read-only | Scan command request / status / response (external writes are rejected) |
| Diagnostics | 0xF120 | Master Diag Data | 16 | Read-only | Master diagnostic data (lost-frame count, frame rate, master state) |
| Control | 0xF200 | Diag Interface Control | 16 | Read/write | Diagnostic interface control (subindex 16 resets the diagnostic counters) |
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.
0x1000 / 0x1008 / 0x1009 / 0x100A are variable objects; take their value directly with readObject(index, (byte) 0). Do not use getSubindexCount to determine their subindex count.
0x1009 has two read paths and two return values: master.masterOD().readObject goes through the ETG.1510 read entry point and returns "x64" / "x86"; the mailbox gateway path currently returns "1.0". Both paths answer truthfully according to their own current state.
0x1018 — Master identity (Identity Object)
| Subindex | Name | Type | Value | Read/write | Description |
|---|---|---|---|---|---|
| 0 | Number of Entries | byte | 4 | Read-only | Fixed |
| 1 | Vendor ID | uint | 0x00001164 | Read-only | Assigned by ETG, fixed value |
| 2 | Product Code | uint | 0x00000001 | Read-only | Fixed value |
| 3 | Revision Number | uint | Automatic | Read-only | Derived from the runtime library version: high 16 bits = major version, low 16 bits = minor version |
| 4 | Serial Number | uint | Automatic | Read-only | Derived from the runtime library version: high 16 bits = revision part, low 16 bits = build part |
Revision Number and Serial Number follow the runtime library version and are not fixed constants; to get the version string, read 0x100A.
0x8nnn — Slave configuration data
Each slave has one 0x8nnn object (nnn = slave index), with a fixed layout of 40 subindexes, the same as the other language editions.
| Subindex | Name | Type | Read/write | Description |
|---|---|---|---|---|
| 0 | Number of Entries | byte | Read-only | Fixed at 40 (a conforming client reads :0 first and then decides which subindexes to read) |
| 1 | Fixed Station Address | ushort | Read-only | Configuration address of this slave (slave.configAddr()) |
| 2 | Type | string | Read-only | Device type string |
| 3 | Name | string | Read-only | Device name; it currently returns the same name as :2. To tell the EEPROM name apart from the SDO 0x1008 name, use slave.name() / slave.driveName() |
| 4 | Device Type | uint | Read-only | Always 0 (no Device Type value is currently provided) |
| 5 | Vendor ID | uint | Read-only | Vendor ID (slave.vendorId(), or slave.getSlaveIdentity()[0]) |
| 6 | Product Code | uint | Read-only | Product code (slave.productId()) |
| 7 | Revision Number | uint | Read-only | Revision number (slave.revision()) |
| 8 | Serial Number | uint | Read-only | Serial number (slave.serialNumber()) |
| 33 | Mailbox Out Size | ushort | Read-only | Send mailbox length (slave.mbxLength()) |
| 34 | Mailbox In Size | ushort | Read-only | Receive mailbox length (slave.mbxReadLength()) |
| 35 | Link Status | byte | Read-only | bit0 = slave-lost state (the verdict measured in the current cycle); bit(4+p) = port p currently has a link (p = 0..3); the remaining bits are always 0. This byte has no unknown encoding: all high bits being 0 can also mean this slave's DL status was never sampled, so a 0 alone must not be taken to assert "all four ports are down". Returns null when unreadable. |
| 36 | Link Preset | byte | Read-only | 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 number of ports with a link measured in the current cycle, using the same link bits as :35; it is not a configuration-time topology snapshot. 0 = definitively no expected port (also returns 0 when the input is unknown). Returns null when unreadable. |
| 37 | Flags | byte | Read-only | Always 0 (Bit3 reserved) |
| 38 | Port Physics | ushort | Read-only | Topology physical type (slave.physicalType(), 0-4) |
| 39 | Mailbox Protocols | ushort | Read-only | SII mbx_proto capability bitmap (slave.mbxProtoRaw()) |
- Both entry points agree:
readObject(0x8nnn, 0)andgetSubindexCount(0x8nnn)both answer 40. The subindexes that are actually readable are the ones listed below; reading any other subindex returnsnull— read:0first and then decide which subindexes to read. - Implemented subindexes:
:0,:1..:8,:33..:39. Here:1= Fixed Station Address,:2= Type,:3= Name (not the earlier C# layout that put the identity quadruple in:1..:4); the identity quadruple is in:5..:8(Vendor ID / Product Code / Revision Number / Serial Number);:37is always 0. The slave group number is not in this object — useslave.group(). - The remaining subindexes (
:9..:32,:40) have no usable data source, andreadObjectreturnsnull;:35/:36likewise returnnullwhen unreadable — never use 0 to pass off a conclusion, because 0 is a definite value. - String subindexes (
:2,:3) are returned as UTF-8 bytes without a trailing NUL. - Numeric subindexes are always little-endian:
:1/:33/:34are 2 bytes,:4..:8/:38/:39are 4 bytes (the values of:38/:39fit in 16 bits).
0x9nnn — Slave detection information
Each slave has one 0x9nnn object holding the fixed information read back at runtime plus link status.
| Subindex | Name | Type | Read/write | Description |
|---|---|---|---|---|
| 0 | Number of Entries | byte | Read-only | Fixed at 32 |
| 1 | Fixed Station Address | ushort | Read-only | Configuration address of this slave (slave.configAddr()) |
| 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 |
| 32 | DL Status | ushort | Read-only | Raw value of the slave DL status register (0x0110) |
The remaining subindexes (:2..:4, :9..:31) are not implemented at present and return null when read.
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 status word (status byte + Error bit + AL status code), taken from ESC 0x0130 |
| 2 | AL Control | ushort | Read/write | AL control word (ESC 0x0120). Reading returns 2 bytes; a write must be exactly 2 bytes, a wrong length returns false, and the write is propagated 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 | Per-port link bits: bit p = communication established on port p, bit(4+p) = port p currently has a link (p = 0..3). This is not "which port of the parent this slave is attached to"; for that use slave.parentPort() |
| 5 | Link Control | byte | Read-only | Raw value of the link control register (ESC 0x0101) |
| 6 | Fixed Addr Conn. Port 0 | ushort | Read-only | Fixed address of the upstream parent slave (the raw configadr value). 0 = this port did not report a connected slave and does not mean none is connected |
| 7 | Fixed Addr Conn. Port 1 | ushort | Read-only | Fixed address of the downstream child slave attached to P1 of this slave; same interpretation as :6. 0 = no connected slave reported, and it does not mean none is connected |
| 8 | Fixed Addr Conn. Port 2 | ushort | Read-only | Fixed address of the downstream child slave attached to P2 of this slave; same interpretation as :6. 0 = no connected slave reported, and it does not mean none is connected |
| 9 | Fixed Addr Conn. Port 3 | ushort | Read-only | Fixed address of the downstream child slave attached to P3 of this slave; same interpretation as :6. 0 = no connected slave reported, and it does not mean none is connected |
| 10 | Frame Error Port 0 | int | Read-only | Port 0 frame error count (8-bit counter, returned as 4 bytes) |
| 11 | Frame Error Port 1 | int | Read-only | Port 1 frame error count (8-bit counter, returned as 4 bytes) |
| 12 | Frame Error Port 2 | int | Read-only | Port 2 frame error count (8-bit counter, returned as 4 bytes) |
| 13 | Frame Error Port 3 | int | Read-only | Port 3 frame error count (8-bit counter, returned as 4 bytes) |
| 14 | Cyclic WC Error Counter | int | Unavailable | No usable data source; the read returns null |
| 15 | Slave Not Present Counter | int | Unavailable | No usable data source; the read returns null |
| 16 | Abnormal State Change Counter | int | Unavailable | No usable data source; the read returns null |
| 17 | Disable Auto Link Control | byte | Unavailable | No usable data source; the read returns null |
| 18 | Last CoE/SoE Protocol Error | int | Unavailable | No usable data source; the read returns null; for that quantity use lastCoESoEProtocolError(int) |
| 19 | New Diag Messages | byte | Unavailable | No usable data source; the read returns null |
The readable ones are :1..:13; :14..:19 have no usable data source and always return null when read — another field is never passed off in their place.
Only :2 (AL Control) is available for writing, and the length must be 2 bytes; writeObject on any other subindex returns false and logs.
Note that :4 (Link Conn. Status) holds per-port link bits; it is not "which port of the parent this slave is attached to" — the only answer to that is slave.parentPort(). Only slave.parentPort() together with :6..:9 reconstructs the topology.
0xF002 — Scan command
0xF002 rejects external writes (writeObject always returns false). 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, driven by internal logic.
More functionality will come in a future update.
| 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, always 0 |
| 2 | Scan Command Status | byte | Read-only | Scan command status |
| 3 | Scan Command Response | byte[6] | Read-only | First 4 bytes = status and error code, last 2 bytes = current slave count (ushort, little-endian) |
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 |
| 2 | Acyclic Lost Frames | uint | Read-only | Acyclic lost-frame count |
| 3 | Cyclic Frames/Second | uint | Read-only | Cyclic frames per second |
| 4 | Acyclic Frames/Second | uint | Read-only | Acyclic frames per second |
| 16 | Master State | ushort | Read-only | Current EtherCAT state of the master (as defined by ETG.1510) |
The remaining subindexes are not implemented at present and return null when read.
0xF120 provides lost-frame counts, frame rates and the master state; for the slave count, the expected WKC and link status, read the corresponding metrics from master.diagnostics() (diagnostic tools read the ETG.1510 field semantics through the standard objects).
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 | Read/write | Write 1 byte and take the lowest bit as the reset level; the diagnostic counters are reset only on a rising edge from 0 to 1, and writing again while the level stays 1 does not reset again. Reading returns the current level |
The remaining subindexes are not implemented at present and return null when read.
Resetting is equivalent to master.diagnostics().reset(); both entry points have the same effect, so use either one.
Method overview
| Category | Method | Type | Read/write | Description |
|---|---|---|---|---|
| Read | readObject(int index, byte subindex) | byte[] | Read-only | Reads raw data; an unreadable entry returns null |
| Write | writeObject(int index, byte subindex, byte[] data) | boolean | Write-only | Writes; only 0xAnnn:2 and 0xF200:16 are writable, everything else returns false |
| Query | getObjectName(int index) | String | Read-only | Object name; an unknown index returns null |
| Query | getSubindexCount(int index) | byte | Read-only | Subindex count of a record object |
| Query | getSupportedObjectIndices() | List<Integer> | Read-only | List of supported indexes |
| Link | linkStatus(int slaveIndex) | Integer | Read-only | 0x8nnn:35 link status byte; returns null when unreadable |
| Link | linkPreset(int slaveIndex) | Integer | Read-only | 0x8nnn:36 link preset byte; returns null when unreadable |
| Link | fixedAddrConnPorts(int slaveIndex) | int[] | Read-only | Fixed addresses of the slaves connected to the four ports, from 0xAnnn:6..:9; returns null when unreadable |
| Diagnostics | alStatusExtended(int slaveIndex) | Integer | Read-only | 0xAnnn:1 AL status word; returns null when unreadable |
| Diagnostics | lastALStatusCode(int slaveIndex) | int | Read-only | 0xAnnn:3 most recent AL error code; returns 0 when the read fails |
| Diagnostics | lastCoESoEProtocolError(int slaveIndex) | long | Read-only | Most recent CoE/SoE protocol error code (SDO Abort Code); 0 when it has never occurred |
| Diagnostics | cyclicWCErrorCounter(int slaveIndex) | Long | Read-only | 0xAnnn:14 WKC error count; returns null when unreadable |
| Diagnostics | newDiagMessagesAvailable(int slaveIndex) | Boolean | Read-only | 0xAnnn:19 whether there are new diagnostic messages; returns null when unreadable |
| Diagnostics | disableAutomaticLinkControl(int slaveIndex) | Boolean | Read-only | 0xAnnn:17 whether automatic link control is disabled; returns null when unreadable |
All methods throw IllegalStateException when called after the master has been released or while it is shutting down; the methods that take a slave index (linkStatus etc., 9 in total) throw IllegalArgumentException when the slave index is out of range.
API details
readObject(int index, byte subindex)
public byte[] readObject(int index, byte subindex)
Reads the data at the specified index from the master object dictionary.
Parameters:
index(int) — object index (such as0x1018,0x8001,0xA001)subindex(byte) — subindex
Returns:
byte[]— the raw data read; unreadable entries (object / subindex does not exist, master not ready, register read failure and so on) returnnull. Integers are returned little-endian, strings as UTF-8 bytes without a trailing NUL
Exceptions:
IllegalArgumentException—indexoutside0x0000-0xFFFFIllegalStateException— the master has been released or is shutting down
Example:
byte[] vid = master.masterOD().readObject(0x8001, (byte) 5); // 0x8001:5 = VendorId (4 bytes)
int vendorId = ByteBuffer.wrap(vid).order(ByteOrder.LITTLE_ENDIAN).getInt();
writeObject(int index, byte subindex, byte[] data)
public boolean writeObject(int index, byte subindex, byte[] data)
Writes to the master object dictionary. Only 0xAnnn:2 (AL Control) and 0xF200:16 (diagnostic reset) support writing; any other object returns false and logs.
Parameters:
index(int) — object indexsubindex(byte) — subindexdata(byte[]) — the data to write; passingnullis treated as empty data
Returns:
boolean—trueon a successful write; a read-only object / subindex, a length mismatch and a failed register write all returnfalse
Exceptions:
IllegalArgumentException—indexoutside0x0000-0xFFFFIllegalStateException— the master has been released or is shutting down
Example:
// 0xF200:16 - write 1 to trigger one diagnostic counter reset (rising-edge semantics)
od.writeObject(0xF200, (byte) 16, new byte[] { 1 });
// 0xAnnn:2 - AL Control, must be exactly 2 bytes
od.writeObject(0xA001, (byte) 2, new byte[] { 0x00, 0x02 });
getObjectName(int index)
public String getObjectName(int index)
Gets the name of an object (it answers only the name metadata; values and availability always go through readObject).
Parameters:
index(int) — object index
Returns:
String— the object name; an unknown index returnsnull. Fixed indexes return the standard name (Device Type,Manufacturer Device Name,Manufacturer Hardware Version,Manufacturer Software Version,Identity Object,Detect Modules Command,Master Diag Data,Diag Interface Control);0x8nnn/0x9nnn/0xAnnnreturnSlave Config/Slave Info/Slave Diagplus the hexadecimal index
Exceptions:
IllegalStateException— the master has been released or is shutting down
getSubindexCount(int index)
public byte getSubindexCount(int index)
Gets the subindex count of an object (equivalent to reading the first byte of readObject(index, (byte) 0)).
0x8nnn / 0x9nnn / 0xAnnn / 0x1018 / 0xF002 / 0xF120 / 0xF200 each answer their own entry count (40 / 32 / 19 / 4 / 3 / 16 / 16), consistent with readObject(索引, (byte) 0).
0x1000 / 0x1008 / 0x1009 / 0x100A are variable objects with no subindexes, so the value returned by getSubindexCount is meaningless for them (do not use it as a subindex count); always take their value with readObject(index, (byte) 0). An index that is not registered returns 0.
Parameters:
index(int) — object index
Returns:
byte— the subindex count; an unregistered or unreadable index returns0
Exceptions:
IllegalArgumentException—indexoutside0x0000-0xFFFFIllegalStateException— the master has been released or is shutting down
getSupportedObjectIndices()
public List<Integer> getSupportedObjectIndices()
Gets the list of all object indexes currently supported (the fixed indexes plus the 0x8nnn/0x9nnn/0xAnnn indexes generated dynamically from the slave count).
Returns:
List<Integer>— the list of supported indexes, in the order: the fixed indexes (0x1000,0x1008,0x1009,0x100A,0x1018,0xF002,0xF120,0xF200) followed by0x8nnn,0x9nnnand0xAnnnfor each slave
Exceptions:
IllegalStateException— the master has been released or is shutting down
linkStatus(int slaveIndex)
public Integer linkStatus(int slaveIndex)
Reads the 0x8nnn:35 link status byte. Bit meaning: bit0 = slave-lost state (the verdict measured in the current cycle), bit(4+p) = port p currently has a link (p = 0..3). This byte has no unknown encoding; all high bits being 0 can also mean this slave's DL status was never sampled.
Parameters:
slaveIndex(int) — slave index (1-based)
Returns:
Integer— the raw status byte; returnsnullwhen unreadable (it is not folded into 0)
Exceptions:
IllegalArgumentException— slave index out of rangeIllegalStateException— the master has been released or is shutting down
linkPreset(int slaveIndex)
public Integer linkPreset(int slaveIndex)
Reads the 0x8nnn:36 link preset byte: 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 number of ports with a link measured in the current cycle, the same link bits as linkStatus.
Parameters:
slaveIndex(int) — slave index (1-based)
Returns:
Integer— the raw preset byte; returnsnullwhen unreadable. 0 = definitively no expected port (also returned as 0 when the input is unknown)
Exceptions:
IllegalArgumentException— slave index out of rangeIllegalStateException— the master has been released or is shutting down
fixedAddrConnPorts(int slaveIndex)
public int[] fixedAddrConnPorts(int slaveIndex)
Reads the fixed addresses of the slaves connected to the four ports from 0xAnnn:6..:9.
Parameters:
slaveIndex(int) — slave index (1-based)
Returns:
int[]— an array of length 4:addrs[0]= fixed address of the upstream parent,addrs[1]..addrs[3]= fixed addresses of the downstream children attached to P1..P3 of this slave. 0 = this port did not report a connected slave and it does not mean none is connected (also returned as 0 when the parent / attachment port is unknown). Returnsnullwhen unreadable
Exceptions:
IllegalArgumentException— slave index out of rangeIllegalStateException— the master has been released or is shutting down
alStatusExtended(int slaveIndex)
public Integer alStatusExtended(int slaveIndex)
Reads the 0xAnnn:1 AL status word (u16, containing the status byte, the Error bit and the AL status code).
Parameters:
slaveIndex(int) — slave index (1-based)
Returns:
Integer— the AL status word; returnsnullwhen the read fails (it does not return 0 to pass off "no error")
Exceptions:
IllegalArgumentException— slave index out of rangeIllegalStateException— the master has been released or is shutting down
lastALStatusCode(int slaveIndex)
public int lastALStatusCode(int slaveIndex)
Reads the most recent AL error code from 0xAnnn:3 (ESC 0x0134).
Parameters:
slaveIndex(int) — slave index (1-based)
Returns:
int— the AL error code. The return value cannot express "unavailable", so a failed read returns 0 and logs; to tell "a genuine 0" from "read failed", callreadObject(0xA000 + slaveIndex, (byte) 3)directly and check fornull
Exceptions:
IllegalArgumentException— slave index out of rangeIllegalStateException— the master has been released or is shutting down
lastCoESoEProtocolError(int slaveIndex)
public long lastCoESoEProtocolError(int slaveIndex)
Reads the most recent CoE/SoE protocol error code of the slave (SDO Abort Code, from the same source as that slave's LastSdoError). Note that this entry point is not an object dictionary read: 0xAnnn:18 has no usable data source in the object dictionary (the read returns null); use this method for that quantity.
Parameters:
slaveIndex(int) — slave index (1-based)
Returns:
long— the error code (returned as an unsigned 32-bit value); returns 0 (a genuine value) when a protocol error has never occurred
Exceptions:
IllegalArgumentException— slave index out of rangeIllegalStateException— the master has been released or is shutting down
cyclicWCErrorCounter(int slaveIndex)
public Long cyclicWCErrorCounter(int slaveIndex)
Reads the 0xAnnn:14 cyclic WKC error count.
Parameters:
slaveIndex(int) — slave index (1-based)
Returns:
Long— the counter value; this subindex currently has no usable data source, so it returnsnull(it does not return 0 to pass off "the count really is 0"). For WKC observation usemaster.diagnostics()
Exceptions:
IllegalArgumentException— slave index out of rangeIllegalStateException— the master has been released or is shutting down
newDiagMessagesAvailable(int slaveIndex)
public Boolean newDiagMessagesAvailable(int slaveIndex)
Reads 0xAnnn:19 and queries whether there are new diagnostic messages.
Parameters:
slaveIndex(int) — slave index (1-based)
Returns:
Boolean—true= there are new diagnostic messages; this subindex currently has no usable data source, so it returnsnull(it does not returnfalseto pass off "no messages")
Exceptions:
IllegalArgumentException— slave index out of rangeIllegalStateException— the master has been released or is shutting down
disableAutomaticLinkControl(int slaveIndex)
public Boolean disableAutomaticLinkControl(int slaveIndex)
Reads 0xAnnn:17 and queries whether automatic link control is disabled.
Parameters:
slaveIndex(int) — slave index (1-based)
Returns:
Boolean—true= disabled; this subindex currently has no usable data source, so it returnsnull(it does not returnfalseto pass off "not disabled")
Exceptions:
IllegalArgumentException— slave index out of rangeIllegalStateException— the master has been released or is shutting down
Shortcut methods
MasterObjectDictionary also provides read accessors for the common ETG.1510 diagnostic fields (equivalent to reading the corresponding 0xAnnn subindex; lastCoESoEProtocolError is the exception, see the previous section):
Integer alExt = od.alStatusExtended(1); // 0xAnnn:1 AL status word (returns null when the read fails)
int alLast = od.lastALStatusCode(1); // 0xAnnn:3 most recent AL error code; returns 0 when the read fails
long protoErr = od.lastCoESoEProtocolError(1); // Last CoE/SoE error code (not an OD entry); returns 0 if it never happened
Long wkcErr = od.cyclicWCErrorCounter(1); // 0xAnnn:14 currently has no value source, always null
Boolean hasNew = od.newDiagMessagesAvailable(1); // 0xAnnn:19 currently has no value source, always null
Boolean autoOff = od.disableAutomaticLinkControl(1); // 0xAnnn:17 currently has no value source, always null
Integer link = od.linkStatus(1); // 0x8nnn:35 link status byte
Integer preset = od.linkPreset(1); // 0x8nnn:36 link preset byte
int[] conn = od.fixedAddrConnPorts(1); // 0xAnnn:6..9 connection addresses of the four ports
Complete example
MasterObjectDictionary od = master.masterOD();
// Iterate over the diagnostics data of all slaves
for (int i = 1; i <= master.slaveCount(); i++) {
int cfgIdx = 0x8000 | i;
int diagIdx = 0xA000 | i;
// 0x8nnn:3 = Name (device name), :2 = Type (same name)
String name = master.getSlave(i).name();
// Identity data (0x8nnn:5 = VendorId; :1 is the Fixed Station Address, not identity)
byte[] vid = od.readObject(cfgIdx, (byte) 5);
int vendorId = vid != null ? ByteBuffer.wrap(vid).order(ByteOrder.LITTLE_ENDIAN).getInt() : 0;
// Read the AL Status and the error code
byte[] alStatus = od.readObject(diagIdx, (byte) 1);
byte[] alCode = od.readObject(diagIdx, (byte) 3);
int alVal = (alStatus != null && alStatus.length >= 2)
? ByteBuffer.wrap(alStatus).order(ByteOrder.LITTLE_ENDIAN).getShort() & 0xFFFF : 0;
int codeVal = (alCode != null && alCode.length >= 2)
? ByteBuffer.wrap(alCode).order(ByteOrder.LITTLE_ENDIAN).getShort() & 0xFFFF : 0;
System.out.printf("从站%d [%s]: Vendor=0x%08X, AL=0x%04X, Code=0x%04X%n", // Slave %d [%s]: Vendor=0x%08X, AL=0x%04X, Code=0x%04X%n
i, name, vendorId, alVal, codeVal);
}
// Port frame error counter (0xAnnn:10-13, 4 bytes little-endian)
byte[] fe0 = od.readObject(diagIdx, (byte) 10);
int fe0Val = (fe0 != null && fe0.length >= 4)
? ByteBuffer.wrap(fe0).order(ByteOrder.LITTLE_ENDIAN).getInt() : -1;
// Subindices with no value source (0xAnnn:14..19): readObject returns null rather than a fake 0
// Reset the diagnostic counter: triggered by a rising edge on 0xF200:16 (write 1 byte, take the lowest bit)
od.writeObject(0xF200, (byte) 16, new byte[] { 1 });
// Equivalent diagnostics entry point
master.diagnostics().reset();
// List all supported objects
List<Integer> indices = od.getSupportedObjectIndices();
for (int idx : indices) {
String name = od.getObjectName(idx);
System.out.printf("0x%04X: %s%n", idx, name);
}
// ETG.1510 diagnostic shortcuts
Integer alStatus = od.alStatusExtended(1);
Long wkcErrors = od.cyclicWCErrorCounter(1);
Boolean hasNewDiag = od.newDiagMessagesAvailable(1);
Failures and handling
| Symptom | Meaning | Action |
|---|---|---|
readObject returns null | The entry is unreadable (object / subindex does not exist, master not ready, register read failure) | Treat it as "unavailable"; do not treat it as 0. To tell the causes apart, see the failure records in the log |
writeObject returns false | The object is read-only, the length does not match, or the register write failed | Only 0xAnnn:2 and 0xF200:16 are writable; 0xAnnn:2 must be exactly 2 bytes |
A shortcut method returns null (Boolean / Long / Integer) | That subindex currently has no usable data source | Judge with the tri-state semantics; do not substitute == false / == 0 |
lastALStatusCode returns 0 | It may be a genuine 0 or a failed read | To tell them apart, use readObject and check for null |
Throws IllegalArgumentException | The index is outside 0x0000-0xFFFF, or the slave index is out of range | Check the arguments |
Throws IllegalStateException | The master has been released or is shutting down | Do not hold an object reference and use it across master lifecycles |
Failure paths always log (including the failing index / subindex and the reason) and are never swallowed silently; for logging usage see Logging.