Skip to main content

Master object dictionary (Master OD)

A master object dictionary that follows ETG.1510, exposing master identity and diagnostic data. Together with the mailbox gateway, it gives remote diagnostic tools standard access to the master.

Read coverage of the C SDK

diagnostics_etg1510_read() implements only two fast paths: 0x1018 subindexes 1..4 and 0xF120 subindex 0; every other index returns -4 (no usable implementation).

The slave configuration / information / diagnosis objects (0x8nnn / 0x9nnn / 0xAnnn) have two read paths: ① take the equivalent fields with GetSlave() / GetSlaveDetailedInfo(); ② use the generic ETG.1510 OD read entry point (DarraEcat_Etg1510_ReadObject, no short-name wrapper; the declaration is in darra_ethercat_shell.h), which covers the standard subindexes of 0x8nnn / 0x9nnn / 0xAnnn (per-row availability is marked in the tables below).

The tables below describe the master object dictionary itself; with the mailbox gateway, an external CoE diagnostic tool can reach it in the standard way.

Object index overview​

IndexNameCategorySubindexesRead/writeDescription
0x1000Device TypeStandard object0Read-only0x00001389 (EtherCAT master)
0x1008Device NameStandard object0Read-only"Darra EtherCAT Master"
0x1009Hardware VersionStandard object0Read-onlyThe mailbox gateway and GetMasterIdentity return "1.0"; the generic ETG.1510 OD read entry point returns "x64" (64-bit) / "x86" (32-bit) — see Known difference below
0x100ASoftware VersionStandard object0Read-onlySDK version
0x1018Identity ObjectStandard object4Read-onlyMaster identity
0x8nnnConfiguration DataSlave configuration40Read-onlyConfiguration data of slave n (address, name, vendor, mailbox, and so on)
0x9nnnInformation DataSlave information32Read-onlyDetected information of slave n (actual address, vendor ID, DL Status)
0xAnnnDiagnosis DataSlave diagnosis19Partially writableDiagnostic data of slave n (AL Status, error counters, link, and so on)
0xF002Detect ModulesDetection command3Read-onlySlave scan status
0xF120Master Diag DataMaster diagnosis16Read-onlyMaster diagnostic data (lost-frame count, frame rate, state)
0xF200Diag Interface ControlDiagnostic control16WritableDiagnostic interface control (reset diagnostic information)

The index of slave n is the base address plus n (1-based): configuration 0x8000 | n, information 0x9000 | n, diagnosis 0xA000 | n. Slave 1, for example, is 0x8001 / 0x9001 / 0xA001.

Known difference (to be unified in a later version)

0x1009 has two read paths and two return values: the mailbox gateway and GetMasterIdentity() return "1.0", while the generic ETG.1510 OD read entry point (no short-name wrapper; the declaration is in darra_ethercat_shell.h) returns "x64" (64-bit) / "x86" (32-bit). This records the current implementation as it is; a later version will unify them.

Identity Object (0x1018)​

SubindexNameCategoryTypeRead/writeDescription
0x01Vendor IDStandard objectuint32Read-onlyVendor ID
0x02Product CodeStandard objectuint32Read-onlyProduct code
0x03Revision NumberStandard objectuint32Read-onlyRevision number
0x04Serial NumberStandard objectuint32Read-onlySerial number

Configuration Data (0x8nnn) — Slave configuration​

Address calculation

The configuration data index of slave n is 0x8000 | n (n = 1..slave_count; the 1-based slave index lands directly in the low 12 bits). Slave 1, for example, is 0x8001 and slave 2 is 0x8002.

SubindexNameCategoryTypeRead/writeDescription
0x00Number of EntriesSlave configurationbyteRead-onlyFixed at 40
0x01Fixed Station AddressSlave configurationuint16Read-onlyConfigured address (ConfigAddr)
0x02TypeSlave configurationstringRead-onlyDevice type string (the C read path currently returns the same device name as 0x03)
0x03NameSlave configurationstringRead-onlyDevice name
0x04Device TypeSlave configurationuint32Read-onlyDevice type code (always 0 at present; Dtype no longer has a real source)
0x05Vendor IDSlave configurationuint32Read-onlyVendor ID
0x06Product CodeSlave configurationuint32Read-onlyProduct code
0x07Revision NumberSlave configurationuint32Read-onlyRevision number
0x08Serial NumberSlave configurationuint32Read-onlySerial number
0x21Mailbox Out SizeSlave configurationuint16Read-onlySM0 mailbox output size
0x22Mailbox In SizeSlave configurationuint16Read-onlySM1 mailbox input size
0x23Link StatusSlave configurationbyteRead-only0x8nnn:35: bit0 = slave lost (the criterion is the live verdict for the current cycle, not a sticky latch); bit(4+p) = port p currently has a link (p=0..3); the remaining bits are always 0. All high bits 0 can also mean "this slave's link state was never sampled", so a 0 alone does not prove all four ports are down
0x24Link PresetSlave configurationbyteRead-only0x8nnn:36: 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 per-cycle 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)
0x25FlagsSlave configurationbyteRead-onlyBit3 reserved; currently 0
0x26Port PhysicsSlave configurationuint16Read-onlyPort physical type
0x27Mailbox ProtocolsSlave configurationuint16Read-onlySupported mailbox protocols (CoE=0x04, FoE=0x08, and so on)
0x28Diag History SupportedSlave configurationbyteRead-onlyIn the specification, "whether the 0x10F3 diagnostic history object is supported"; the C read path has no data source and returns -5 (subindex does not exist)

Information Data (0x9nnn) — Slave detection information​

Each slave has one 0x9nnn object holding the actual information detected at runtime.

Address calculation

The detection information index of slave n is 0x9000 | n (n = 1..slave_count; the 1-based slave index lands directly in the low 12 bits). Slave 1, for example, is 0x9001 and slave 2 is 0x9002.

SubindexNameCategoryTypeRead/writeDescription
0x00Number of EntriesSlave informationbyteRead-onlyFixed at 32
0x01Station AddressSlave informationuint16Read-onlyActual configured address
0x05Vendor IDSlave informationuint32Read-onlyDetected vendor ID
0x06Product CodeSlave informationuint32Read-onlyDetected product code
0x07Revision NumberSlave informationuint32Read-onlyDetected revision number
0x08Serial NumberSlave informationuint32Read-onlyDetected serial number
0x20DL StatusSlave informationuint16Read-onlyDL Status register (ESC 0x0110-0x0111, read with a blocking register read); the mailbox gateway path does not provide this subindex

Diagnosis Data (0xAnnn) — Slave diagnosis​

Each slave has one 0xAnnn object holding live diagnostic data. It is updated automatically on every read.

Address calculation

The diagnostic data index of slave n is 0xA000 | n (n = 1..slave_count; the 1-based slave index lands directly in the low 12 bits). Slave 1, for example, is 0xA001 and slave 2 is 0xA002.

SubindexNameCategoryTypeRead/writeDescription
0x00Number of EntriesSlave diagnosisbyteRead-onlyFixed at 19
0x01AL StatusSlave diagnosisuint16Read-onlyCurrent AL state
0x02AL ControlSlave diagnosisuint16Read/writeWritten through to the slave (writes ESC 0x0120 and needs 2 bytes; the register can also be read)
0x03Last AL Status CodeSlave diagnosisuint16Read-onlyMost recent AL error code (ESC 0x0134)
0x04Link Conn. StatusSlave diagnosisbyteRead-onlyLink Conn. Status (the per-port link byte decoded from ESC 0x0110: bit(p) = port p has communication established, bit(4+p) = port p has a link, p = 0..3); it is not "which port of the parent this slave is attached to" — use GetSlaveParentPort for that
0x05Link ControlSlave diagnosisbyteRead-onlyLink control (DL Control register 0x0101)
0x06Fixed Addr Conn. Port 0Slave diagnosisuint16Read-onlyConfigured address of the slave connected to port 0 (the upstream parent); 0 = this port reports no connected slave, which does not mean nothing is connected; to find which port of the parent this slave is attached to, use GetSlaveParentPort
0x07Fixed Addr Conn. Port 1Slave diagnosisuint16Read-onlyConfigured address of the slave connected to port 1 (a downstream child); 0 = this port reports no connected slave, which does not mean nothing is connected
0x08Fixed Addr Conn. Port 2Slave diagnosisuint16Read-onlyConfigured address of the slave connected to port 2 (a downstream child); 0 = this port reports no connected slave, which does not mean nothing is connected
0x09Fixed Addr Conn. Port 3Slave diagnosisuint16Read-onlyConfigured address of the slave connected to port 3 (a downstream child); 0 = this port reports no connected slave, which does not mean nothing is connected
0x0AFrame Error Port 0Slave diagnosisuint32Read-onlyPort 0 frame error count (reads ESC 0x0300, low byte zero-extended)
0x0BFrame Error Port 1Slave diagnosisuint32Read-onlyPort 1 frame error count (ESC 0x0302)
0x0CFrame Error Port 2Slave diagnosisuint32Read-onlyPort 2 frame error count (ESC 0x0304)
0x0DFrame Error Port 3Slave diagnosisuint32Read-onlyPort 3 frame error count (ESC 0x0306)
0x0ECyclic WC Error CounterSlave diagnosisuint32Read-onlyIn the specification, "cyclic working counter errors"; the C read path has no data source and returns -5 (subindex does not exist)
0x0FSlave Not Present CounterSlave diagnosisuint32Read-onlyIn the specification, "count of slaves not present"; the C read path has no data source and returns -5 (subindex does not exist)
0x10Abnormal State Change CounterSlave diagnosisuint32Read-onlyIn the specification, "count of abnormal state changes"; the C read path has no data source and returns -5 (subindex does not exist)
0x11Disable Auto Link ControlSlave diagnosisbyteRead-onlyIn the specification, "automatic link control disable flag"; the C read path has no data source and returns -5 (subindex does not exist)
0x12Last CoE/SoE Protocol ErrorSlave diagnosisuint32Read-onlyIn the specification, "most recent CoE/SoE protocol error code"; the C read path has no data source and returns -5 (subindex does not exist)
0x13New Diag MessagesSlave diagnosisbyteRead-onlyIn the specification, "whether there are new diagnostic messages (0x10F3)"; the C read path has no data source and returns -5 (subindex does not exist)
Read path coverage difference

The table is marked with the actual coverage of the generic ETG.1510 OD read entry point (DarraEcat_Etg1510_ReadObject). The mailbox gateway (an external CoE tool) answers only part of it: 0x8nnn:0x28, 0x9nnn:0x20 and 0xAnnn:0x02 / 0x04 / 0x05 / 0x0A..0x13 return "subindex does not exist" on the gateway path.

Master identity​

GetMasterIdentity()​

BOOL GetMasterIdentity(uint16_t master_index, ec_master_identity_t* identity);

Gets the master identity information.

Parameters:

  • master_index (uint16_t) — master index
  • identity (ec_master_identity_t*) — output identity information

Returns:

  • BOOL — TRUE on success

ec_master_identity_t​

typedef struct {
uint32_t VendorId; /* Vendor ID */
uint32_t ProductCode; /* Product code */
uint32_t RevisionNo; /* Revision number */
uint32_t SerialNo; /* Serial number */
char DeviceName[64]; /* Device name */
char HwVersion[32]; /* Hardware version */
char SwVersion[32]; /* Software version */
} ec_master_identity_t;

Master diagnostic data (0xF120)​

The C SDK wires the fast path only on subindex 0: when diagnostics_etg1510_read() reads 0xF120:00 it calls GetMasterDiagData(), which returns the whole ec_master_diag_data_t in one go (20 bytes = 4 × uint32 + uint16 + 2 bytes of alignment padding) rather than splitting it per subindex; every other subindex on that fast-path entry point has no usable implementation and returns -4. To read 0..4 and 16 subindex by subindex, use the generic ETG.1510 OD entry point (see above). How the struct fields map to the ETG.1510 subindexes:

OffsetFieldCategoryTypeRead/writeETG.1510 subindexDescription
0CyclicLostFramesMaster diagnosisuint32Read-only01Cyclic lost-frame count (5-second sliding-window value, not a percentage)
4AcyclicLostFramesMaster diagnosisuint32Read-only02Acyclic lost-frame count (counted by timed-out frames, also a 5-second sliding-window value)
8CyclicFramesPerSecMaster diagnosisuint32Read-only03Cyclic frames per second
12AcyclicFramesPerSecMaster diagnosisuint32Read-only04Acyclic frames per second (this field is not filled at present; the reading is always 0)
16MasterStateMaster diagnosisuint16Read-only16Current EtherCAT state of the master

GetMasterDiagData()​

BOOL GetMasterDiagData(uint16_t master_index, ec_master_diag_data_t* diag);

Gets the master diagnostic data (ETG.1510 0xF120).

Parameters:

  • master_index (uint16_t) — master index
  • diag (ec_master_diag_data_t*) — output diagnostic data

Returns:

  • BOOL — TRUE on success

ec_master_diag_data_t​

typedef struct {
uint32_t CyclicLostFrames; /* cyclic frame loss count (5-second sliding-window value) */
uint32_t AcyclicLostFrames; /* acyclic frame loss count (counted by timed-out frames, also a 5-second sliding-window value) */
uint32_t CyclicFramesPerSec; /* cyclic frames per second */
uint32_t AcyclicFramesPerSec; /* acyclic frames per second (this field is not filled at present; the reading is always 0) */
uint16_t MasterState; /* current master state */
} ec_master_diag_data_t;

0xF200 — Diagnostic interface control​

SubindexNameCategoryTypeRead/writeDescription
0x00Number of EntriesDiagnostic controlbyteRead-onlyFixed at 16
0x10Reset Diag InfoDiagnostic controlbyteWritableWriting 1 resets the diagnostic counters of all slaves and of the master (triggered on a rising edge)

ETG.1510 index constants​

Object index macros defined in master/diagnostics_ext.h:

MacroValueObject
ETG1510_DEVICE_TYPE0x1000Device Type
ETG1510_DEVICE_NAME0x1008Manufacturer Device Name
ETG1510_HW_VERSION0x1009Hardware Version
ETG1510_SW_VERSION0x100ASoftware Version
ETG1510_IDENTITY0x1018Identity Object
ETG1510_CONFIG_DATA_BASE0x8000Base address of the slave configuration data
ETG1510_INFO_DATA_BASE0x9000Base address of the slave information data
ETG1510_DIAG_DATA_BASE0xA000Base address of the slave diagnostic data
ETG1510_DETECT_MODULES0xF002Detect Modules Command
ETG1510_MASTER_DIAG_DATA0xF120Master Diag Data
ETG1510_DIAG_INTERFACE_CTRL0xF200Diag Interface Control

Generic OD access​

The functions below (declared in master/diagnostics_ext.h) forward only two fast paths: 0x1018 subindexes 1..4 route to GetMasterIdentity and 0xF120 subindex 0 routes to GetMasterDiagData. Every other index has no usable implementation in the C SDK: reads and writes return the matching failure code directly instead of being mixed up with "the slave did not answer / the index does not exist". These two SDK-level functions are called directly with the master index and need no context handle.

diagnostics_etg1510_read()​

int diagnostics_etg1510_read(uint16_t master_index, uint16_t index, uint8_t subindex,
uint8_t* outBuf, int bufSize);

Reads a master object through the ETG.1510 OD (an SDO Upload wrapper).

Parameters:

  • master_index (uint16_t) — master index
  • index (uint16_t) — OD index (0x1000-0xFFFF)
  • subindex (uint8_t) — OD subindex
  • outBuf (uint8_t*) — output buffer
  • bufSize (int) — buffer size

Returns:

  • int — the number of bytes actually written; -1 = parameter error; -3 = buffer too small; -4 = no usable implementation for this index (every index except 0x1018:1..4 and 0xF120:0, including 0x1018:0)
  • 0x1018:1..4 fills in 4 bytes (uint32) each time; a buffer smaller than 4 bytes returns -3
  • 0xF120:0 copies the whole struct in one go (ec_master_diag_data_t, 20 bytes under MSVC); a smaller buffer truncates to bufSize and returns the number of bytes actually written

diagnostics_etg1510_write()​

int diagnostics_etg1510_write(uint16_t master_index, uint16_t index, uint8_t subindex,
const uint8_t* data, int len);

Writes a master object through the ETG.1510 OD (an SDO Download wrapper). It is meant for the writable master objects such as 0xF200 Diag Interface Control and 0xF002 Detect Modules; this entry point goes through the master SDO route (slave index 0), which is currently rejected, so the call always returns -2. To reset the diagnostic counters or write AL Control, use the generic ETG.1510 OD entry point below.

Returns:

  • int — 0 success (no index reaches it at present); -1 parameter error; -2 SDO failure (request rejected / Abort / timeout); -4 SDK unavailable (entry point not ready, nothing sent)

Example:

/* Read 0x1018:01 VendorId (fast path, 4 bytes) */
uint8_t buf[32] = {0};
int n = diagnostics_etg1510_read(mi, 0x1018, 0x01, buf, sizeof(buf));
if (n >= 4) {
uint32_t vendor = (uint32_t)buf[0] | ((uint32_t)buf[1] << 8)
| ((uint32_t)buf[2] << 16) | ((uint32_t)buf[3] << 24);
printf("VendorId: 0x%08X\n", vendor);
}

/* Read 0xF120:0 master diagnostics (fast path, whole struct) */
uint8_t diag[32] = {0};
int m = diagnostics_etg1510_read(mi, 0xF120, 0x00, diag, sizeof(diag));
printf("GetMasterDiagData 快路径写入 %d 字节\n", m); /* GetMasterDiagData fast path wrote %d bytes */

Generic ETG.1510 OD entry point​

The generic read / write entry points covering the standard subindexes such as 0x8nnn / 0x9nnn / 0xAnnn; declared in darra_ethercat_shell.h (no short-name wrapper; call DarraEcat_Etg1510_* directly).

DarraEcat_Etg1510_ReadObject()​

int DarraEcat_Etg1510_ReadObject(uint16_t master_index, uint16_t index, uint8_t subindex,
uint8_t* out_buf, int out_cap,
int* out_len, uint16_t* out_abort);

Reads a master object dictionary entry. The call needs no context handle; out_len / out_abort are cleared on entry.

Parameters:

  • master_index (uint16_t) — master index
  • index (uint16_t) — object index (0x1000 / 0x8nnn / 0x9nnn / 0xAnnn / 0xF002 / 0xF120 / 0xF200)
  • subindex (uint8_t) — subindex
  • out_buf / out_cap — output buffer (must not be NULL) and its capacity in bytes
  • out_len (int*) — may be NULL; on success it receives the number of bytes actually written
  • out_abort (uint16_t*) — may be NULL; on failure it receives the CoE abort code (0 on success)

Returns:

  • int — >= 0 = number of bytes written; a negative value = error code:
  • -1 parameter error / -2 invalid master index / -3 not ready (master not initialized / shutting down)
  • -4 object does not exist (CoE abort 0x06020000) / -5 subindex does not exist (0x06090011) / -6 read-only (0x06010002)
  • -7 not supported by this entry point (0x06010000) / -8 buffer too small / -9 register or bus I/O failure (no valid answer)

Coverage — 0x1000 / 0x1008 / 0x1009 / 0x100A / 0x1018 (subindexes 0..4); 0x8nnn's 0..8, 33..39; 0x9nnn's 0, 1, 5..8, 32; 0xAnnn's 0..13; 0xF002's 0..3; 0xF120's 0..4, 16; 0xF200's 0, 16. Subindexes not listed return -5 (subindex does not exist); it does not return 0 to pass off a value.

DarraEcat_Etg1510_WriteObject()​

int DarraEcat_Etg1510_WriteObject(uint16_t master_index, uint16_t index, uint8_t subindex,
const uint8_t* data, int len, uint16_t* out_abort);

Writes a master object dictionary entry. Only two writable entry points are supported:

  • 0xF200:16 — diagnostic reset level (data[0] & 1; a 0→1 rising edge triggers one diagnostic reset, and reading back returns this level)
  • 0xAnnn:2 — AL Control (writes ESC register 0x0120; needs 2 bytes)

0xF002 (a scan at runtime would lose the configuration) and all other read-only indexes are always rejected.

Returns:

  • int — 0 success; a negative value = the same error code set as DarraEcat_Etg1510_ReadObject (-6 read-only for 0xF002 and the other read-only objects, -9 register write failure)

Example:

uint8_t buf[8];
int len = 0;
uint16_t abort = 0;
int rc = DarraEcat_Etg1510_ReadObject(mi, 0xA001, 0x01, buf, sizeof(buf), &len, &abort);
if (rc >= 0)
printf("从站 1 AL Status: 0x%04X\n", (uint16_t)(buf[0] | (buf[1] << 8))); /* Slave 1 AL Status: 0x%04X */
else
printf("读失败 rc=%d abort=0x%04X\n", rc, abort); /* Read failed rc=%d abort=0x%04X */

uint8_t one = 1;
DarraEcat_Etg1510_WriteObject(mi, 0xF200, 0x10, &one, 1, &abort); /* Reset the diagnostic counters */

AL status code classification​

diagnostics_classify_al_error()​

DarraAlErrorClass diagnostics_classify_al_error(uint16_t alStatusCode);

Classifies AL Status Codes per code into the 5 ETG.1020 error classes (none / transient / configuration / hardware / unknown), so a UI can group alarms for display. The single authority is the AL status table built into the runtime (status_codes.c in k_al_status_table[].recovery_class, implemented once by the runtime); the C SDK keeps no second classification table and does not bucket by the high-order segment. The per-code results match C++ / C# / Java / Python / Rust exactly.

Returns:

  • DarraAlErrorClass — the error class enumeration; returns AL_ERR_UNKNOWN when the runtime is unavailable (never AL_ERR_NONE)

Related structure:

typedef enum {
AL_ERR_NONE = 0, /* no error (0x0000) */
AL_ERR_TRANSIENT = 1, /* transient error */
AL_ERR_CONFIGURATION = 2, /* configuration error */
AL_ERR_HARDWARE = 3, /* hardware error */
AL_ERR_UNKNOWN = 4 /* unknown / unlisted / classification unavailable */
} DarraAlErrorClass;

Full example​

#include "ethercat.h"
#include <stdio.h>

int main(void)
{
uint16_t master = Initialize();
if (master == 0 || master == (uint16_t)-1) return 1; /* returns (uint16_t)-1 on failure */

uint16_t slave_count = SetNetwork(master, "\\Device\\NPF_{...}", "");
if (slave_count == 0 || slave_count == (uint16_t)-1) { /* >0 = number of slaves found by the scan */
Dispose(master); return 1;
}

if (!SetStateSequence(master, EC_STATE_OPERATIONAL, 10000)) {
Dispose(master); return 1;
}
if (!Start(master)) {
Dispose(master); return 1;
}

/* ===== Read the master identity (0x1018) ===== */
ec_master_identity_t id;
if (GetMasterIdentity(master, &id)) {
printf("=== 主站信息 (0x1018) ===\n"); /* === Master information (0x1018) === */
printf("设备名称: %s\n", id.DeviceName); /* Device name: %s */
printf("软件版本: %s\n", id.SwVersion); /* Software version: %s */
printf("硬件版本: %s\n", id.HwVersion); /* Hardware version: %s */
printf("VendorId: 0x%08X\n", id.VendorId);
printf("ProductCode: 0x%08X\n", id.ProductCode);
printf("RevisionNo: 0x%08X\n", id.RevisionNo);
printf("SerialNo: 0x%08X\n", id.SerialNo);
}

/* ===== Read the master diagnostic data (0xF120) ===== */
/* the fields map to ETG.1510 subindexes 01/02/03/04/16; the lost-frame count is a 5-second sliding-window value, not a percentage */
ec_master_diag_data_t diag;
if (GetMasterDiagData(master, &diag)) {
printf("\n=== 主站诊断 (0xF120) ===\n"); /* === Master diagnostics (0xF120) === */
printf("周期帧频率: %u Hz\n", diag.CyclicFramesPerSec); /* Cyclic frame rate: %u Hz */
printf("非周期帧频率: %u Hz\n", diag.AcyclicFramesPerSec); /* Acyclic frame rate: %u Hz */
printf("周期帧丢失计数: %u\n", diag.CyclicLostFrames); /* Cyclic frame loss count: %u */
printf("主站状态: 0x%04X\n", diag.MasterState); /* Master state: 0x%04X */
}

/* ===== Generic ETG.1510 OD entry point reads slave diagnostics (0xA001:01 AL Status) ===== */
uint8_t al[8] = {0};
int len = 0;
uint16_t abort = 0;
if (DarraEcat_Etg1510_ReadObject(master, 0xA001, 0x01, al, sizeof(al), &len, &abort) >= 2)
printf("从站 1 AL Status: 0x%04X\n", (uint16_t)(al[0] | (al[1] << 8))); /* Slave 1 AL Status: 0x%04X */

/* ===== Walk all slaves (equivalent-field path) ===== */
printf("\n=== 从站诊断 ===\n"); /* === Slave diagnostics === */
for (uint16_t i = 1; i <= slave_count; i++) {
char name[128];
GetSlaveName(master, i, name, sizeof(name));

uint8_t al_state = GetSlaveState(master, i); /* state byte */
uint16_t al_code = GetSlaveALStatusCode(master, i); /* AL Status Code */
int16_t link_quality = GetSlaveLinkQuality(master, i); /* -1 = unknown / never sampled */

printf("从站 %d [%s]: AL=0x%02X, Code=0x%04X, 链路=%d%%\n", /* Slave %d [%s]: AL=0x%02X, Code=0x%04X, link=%d%% */
i, name, al_state, al_code, link_quality);
}

/* ===== PDO frame loss statistics (per group) ===== */
printf("\n=== PDO 丢帧统计 ===\n"); /* === PDO frame loss statistics === */
for (uint8_t g = 0; g < 8; g++) {
uint32_t total = 0, consecutive = 0, max_consecutive = 0;
GetPDOFrameLossStats(master, g, &total, &consecutive, &max_consecutive);
if (total > 0 || GetGroupSlaveCount(master, g) > 0) {
printf("组 %d: 累计=%u, 连续=%u, 最大连续=%u\n", /* Group %d: total=%u, consecutive=%u, max consecutive=%u */
g, total, consecutive, max_consecutive);
}
}

if (!Stop(master)) {
/* the cycle thread was not fully reclaimed: Stop can be retried */
}
if (!Dispose(master)) {
/* not fully released: Dispose can be retried */
}
return 0;
}