3.9. Trace Data

Trace Data allows applications to trace data in real-time on the network. To ensure real-time transmission, it is implemented as part of the cyclic process data. They are placed behind the SubDevice output data in the output area of the process data image of the EtherCAT® application. The trace data area can be configured either via the ENI with the help of the EC-Engineer or without changing the ENI using the API emTraceDataConfig().

Trace Data can be captured with a network monitoring tool like Wireshark.

Trace Data architecture showing how application trace data is placed behind SubDevice output data in the process image and transmitted as a NOP EtherCAT command appended to cyclic frames

To transfer the data, an additional NOP cmd is appended to the end of the cyclic EtherCAT® frame. The NOP cmd has ADP 0 and ADO 0x4154. The EC-Master automatically fills the data area of the NOP Cmd with the current trace data when sending cyclic frames. Since the trace data are transferred to the network as NOP Cmd, they are not evaluated by any ESC. Therefore, the WKC of the trace data remains 0 and the application cannot validate the data.

3.9.1. Trace Data configuration via EC-Engineer

The easiest and most comfortable way to create trace data variables is with the help of the EC-Engineer. The necessary NOP cmd and the process data variables are automatically created and exported to the ENI. The process variables can be accessed as usual using the emFindOutpVarByNameEx() function.

Trace data variables of any size and number can be created in the Variables tab of the EC-Engineer:
EC-Engineer Variables tab showing the creation of a new trace data variable with configurable name and bit size
The automatically created variable names can also be edited:
EC-Engineer Variables tab showing an automatically generated trace data variable name being edited to a custom name
The generated process variables can be found in the exported ENI file:
ENI file process image section showing the generated variable entry for the configured trace data, including its name, bit size, offset and custom name
As well as the NOP cmd:
ENI file cyclic configuration section showing the generated NOP EtherCAT command with ADP 0 and ADO 0x4154 that carries trace data in every cycle

3.9.2. Trace Data configuration via API

The application can configure the trace data size using the emTraceDataConfig() API. The trace data configuration must take place between the initialization of the EC-Master (emInitMaster()) and the configuration of the network (emConfigureNetwork()). During emConfigureNetwork() the EC-Master tries to expand the process image output area by the trace data buffer and generates the corresponding NOP cmd.

Access to the trace data buffer is via an offset to the process data output image. The offset can be determined via the API emTraceDataGetInfo().

Configuration of the trace data buffer:

//emInitMaster();

emTraceDataConfig(dwInstanceId, sizeof(EC_T_DWORD));

//emConfigureNetwork;

Access to the trace data buffer:

EC_T_TRACE_DATA_INFO oTraceDataInfo;
emTraceDataGetInfo(dwInstanceId, &oTraceDataInfo);

EC_SET_FRM_DWORD(oTraceDataInfo.pbyData + oTraceDataInfo.dwOffset, 0x11223344);

Warning