6.1. Generic API return status values
Most of the functions and also some notifications will return an error status value to indicate whether a function was successfully executed or not. Some of the return status values have a generic meaning unspecific to the called API function.
EC_E_NOERROR: The function was successfully executed.
EC_E_NOTSUPPORTED: Unsupported feature or functionality.
EC_E_BUSY: The stack currently is busy and the function has to be re-tried at a later time.
EC_E_NOMEMORY: Not enough memory or frame buffer resources available.
EC_E_INVALIDPARM: Invalid or inconsistent parameters.
EC_E_TIMEOUT: Timeout error.
EC_E_SLAVE_ERROR: A slave error was detected.
EC_E_INVALID_SLAVE_STATE: The slave is not in the requested state to execute the operation (e.g. when initiating a mailbox transfer the slave must be at least in PREOP state).
EC_E_SLAVE_NOT_ADDRESSABLE: The slave does not respond to its station address (e.g. when requesting its AL_STATUS value). The slave may be removed from the bus or powered-off.
EC_E_LINK_DISCONNECTED: Link cable not connected.
EC_E_MASTERCORE_INACCESSIBLE: Master core inaccessible. This result code usually means a remote connected server / EC-Simulator stack does not respond anymore
6.2. Multiple EtherCAT Network Support
6.2.1. Overview
The acontis EC-Simulator stack supports multiple EtherCAT network instances within the same application process. The first parameter of all esXxx API functions is the Instance ID, starting with 0. The maximum Instance ID of the EC-Simulator SDK is defined as MAX_NUMOF_SIMULATOR_INTERFACES - 1. Implementing multiple EtherCAT network instances is realized by using multiple Instance IDs.

The Link Layers can be of same or different type (emllPcap, emlli8254x, …).
6.2.2. Licensing
For each network identified with the unique Instance ID a separate runtime license is required.
6.3. General functions
6.3.1. esInitSimulator
-
EC_T_DWORD esInitSimulator(EC_T_DWORD dwInstanceId, EC_T_SIMULATOR_INIT_PARMS *pParms)
Initialize EC-Simulator.
- Parameters
dwInstanceId – [in] Simulator Instance ID
pParms – [in] Pointer to init parameters
- Returns
EC_E_NOERROR or error code
-
struct EC_T_SIMULATOR_INIT_PARMS
Public Members
-
EC_T_LINK_PARMS *apLinkParms[EC_SIMULATOR_MAX_LINK_PARMS]
[in] Link layer parameters
-
EC_T_LINK_PARMS *apLinkParms[EC_SIMULATOR_MAX_LINK_PARMS]
-
struct EC_T_OS_PARMS
Public Members
-
EC_PF_SYSTIME pfSystemTimeGet
[in] Function to get host time in nanoseconds since 1st January 2000. Used as time base for DC Initialization.
-
EC_PF_HW_TIMER_GET_INPUT_FREQUENCY pfHwTimerGetInputFrequency
[in] Function to get input frequency of HW timer. This function is needed by some DCM modes described in the Class A manual
-
EC_PF_SYSTIME pfSystemTimeGet
-
struct EC_T_LOG_PARMS
Public Members
-
EC_PF_LOGMSGHK pfLogMsg
[in] Log callback function called on every message
-
EC_PF_LOGMSGHK pfLogMsg
EC_LOG_LEVEL… The following log levels are defined:
-
typedef EC_T_DWORD (*EC_PF_LOGMSGHK)(struct _EC_T_LOG_CONTEXT *pContext, EC_T_DWORD dwLogMsgSeverity, const EC_T_CHAR *szFormat, ...)
- Parameters
pContext – [in] Context pointer. This pointer is used as parameter when the callback function is called
dwLogMsgSeverity – [in] Log message severity, EC_LOG_LEVEL_…
szFormat – [in] String that contains the text to be written. It can optionally contain embedded format specifiers that are replaced by the values specified in subsequent additional arguments and formatted as requested.
- Returns
EC_E_NOERROR or error code
Log messages are passed from the EC-Simulator to the callback given at EC_T_LOG_PARMS::pfLogMsg
. EcLogging.cpp
demonstrates how messages can be handled by the application.
For performance reasons the EC-Simulator automatically filters log messages according to EC_T_LOG_PARMS::dwLogLevel
. E.g. messages of severity EC_LOG_LEVEL_WARNING
are not passed to the application if EC_T_LOG_PARMS::dwLogLevel
is set to EC_LOG_LEVEL_ERROR
.
The application can provide customized log message handlers of type EC_PF_LOGMSGHK
if the default handler in EcLogging.cpp
does not fulfill the application’s needs. Note: The callback is typically called from the Job Task’s context and should return as fast as possible.
-
struct EC_T_PERF_MEAS_INTERNAL_PARMS
Public Members
-
EC_T_PERF_MEAS_COUNTER_PARMS CounterParms
[in] Timer function settings. When not provided OsMeasGetCounterTicks is used
-
EC_T_PERF_MEAS_HISTOGRAM_PARMS HistogramParms
[in] Histogram settings. When not provided the histogram is disabled.
-
EC_T_PERF_MEAS_COUNTER_PARMS CounterParms
-
struct EC_T_PERF_MEAS_COUNTER_PARMS
Public Members
-
EC_PF_PERF_MEAS_GETCOUNTERTICKS pfGetCounterTicks
[in] Function returning the current counter ticks
-
EC_PF_PERF_MEAS_GETCOUNTERTICKS pfGetCounterTicks
6.3.2. esDeinitSimulator
6.3.3. esGetSimulatorParms
-
EC_T_DWORD esGetSimulatorParms(EC_T_DWORD dwInstanceId, EC_T_SIMULATOR_INIT_PARMS *pParms, EC_T_DWORD dwParmsBufSize)
Get Simulator parameters provided by esInitSimulator(…) or esSetSimulatorParms(…).
- Parameters
dwInstanceId – [in] Simulator Instance ID
pParms – [out] Pointer to simulator parameters
dwParmsBufSize – [in] Size of buffer at pParms
- Returns
EC_E_NOERROR or error code
See also
6.3.4. esSetSimulatorParms
-
EC_T_DWORD esSetSimulatorParms(EC_T_DWORD dwInstanceId, EC_T_SIMULATOR_INIT_PARMS *pParms)
Change Simulator parameters provided by esInitSimulator(…).
- Parameters
dwInstanceId – [in] Simulator Instance ID
pParms – [in] Pointer to simulator parameters
- Returns
EC_E_NOERROR or error code
See also
6.3.5. esGetSrcMacAddress
-
EC_T_DWORD esGetSrcMacAddress(EC_T_DWORD dwInstanceID, ETHERNET_ADDRESS *pMacSrc)
Gets the source MAC address.
- Parameters
dwInstanceID – [in] Instance ID (Multiple EtherCAT Network Support)
pMacSrc – [out] 6-byte buffer to write source MAC address to.
- Returns
EC_E_NOERROR or error code
Refers to adapter from EC_T_SIMULATOR_INIT_PARMS.pLinkParms at esInitSimulator()
.
6.3.6. esSetLicenseKey (HiL)
-
EC_T_DWORD esSetLicenseKey(EC_T_DWORD dwInstanceID, const EC_T_CHAR *pszLicenseKey)
Sets the license key for the protected version of EC-Master.
Must be called after initialization and before configuration. This function may not be called if a non protected version is used.
- Parameters
dwInstanceID – [in] Instance ID (Multiple EtherCAT Network Support)
pszLicenseKey – [in] License key as zero terminated string with 26 characters.
- Returns
EC_E_NOERROR if successful
EC_E_INVALIDSTATE if master isn’t initialized
EC_E_INVALIDPARM if dwInstanceID is out of range
EC_E_INVALIDSIZE the format of the license key is wrong. The correct length is 26 characters
EC_E_LICENSE_MISSING the license key doesn’t match to the MAC Address
Must be called after esInitSimulator()
and before esConfigureNetwork()
.This function may not be called if a non protected version is used.
Example:
dwRes = esSetLicenseKey(dwInstanceID, "DA1099F2-15C249E9-54327FBC");
6.3.7. esSetOemKey (HiL)
Must be called after esInitSimulator()
and before esConfigureNetwork()
.
Example:
dwRes = esSetOemKey(dwInstanceID, 0x1234567812345678);
6.3.8. esConfigureNetwork
-
EC_T_DWORD esConfigureNetwork(EC_T_DWORD dwInstanceId, EC_T_CNF_TYPE eCnfType, EC_T_PBYTE pbyCnfData, EC_T_DWORD dwCnfDataLen)
Configure EtherCAT network.
- Parameters
dwInstanceId – [in] Instance ID
eCnfType – [in] Enum type of configuration data provided
pbyCnfData – [in] Configuration data
dwCnfDataLen – [in] Length of configuration data in byte
- Returns
EC_E_NOERROR or error code
6.3.9. esSetSlaveSscApplication
-
EC_T_DWORD esSetSlaveSscApplication(EC_T_DWORD dwInstanceId, EC_T_WORD wCfgFixedAddress, struct _EC_T_SLAVE_SSC_APPL_DESC *pApp)
Register slave application’s callback functions for slave without device emulation.
- Parameters
dwInstanceId – [in] Simulator Instance ID
wCfgFixedAddress – [in] Slave’s station address
pApp – [in] Pointer to application descriptor
- Returns
EC_E_NOERROR or error code
6.3.10. esRegisterClient
-
EC_T_DWORD esRegisterClient(EC_T_DWORD dwInstanceID, EC_PF_NOTIFY pfnNotify, EC_T_VOID *pCallerData, EC_T_REGISTERRESULTS *pRegResults)
Registers a client on the EC-Master.
It must be called after configuration, otherwise the registration handle is lost. This function may not be called from within the JobTask’s context.
- Parameters
dwInstanceID – [in] Instance ID (Multiple EtherCAT Network Support)
pfnNotify – [in] Notification callback function. This function will be called every time a state change occurs, an error occurs or a mailbox transfer terminates.
pCallerData – [in] Pointer to a caller data area which will be passed to the client on every notification callback.
pRegResults – [out] Registration results, a pointer to a structure of type EC_T_REGISTERRESULTS.
- Returns
EC_E_NOERROR if successful
EC_E_INVALIDSTATE if master isn’t initialized
EC_E_INVALIDPARM if dwInstanceID is out of range or the output pointer is EC_NULL
EC_E_NOMEMORY if some memory cannot be allocated
-
typedef EC_T_DWORD (*EC_PF_NOTIFY)(EC_T_DWORD dwCode, EC_T_NOTIFYPARMS *pParms)
- Parameters
dwCode – [in] Notification code.
pParms – [in] Notification code depending data.
6.3.11. esUnregisterClient
-
EC_T_DWORD esUnregisterClient(EC_T_DWORD dwInstanceID, EC_T_DWORD dwClntId)
Unregister a client from the EtherCAT master.
This function may not be called from within the JobTask’s context.
- Parameters
dwInstanceID – [in] Instance ID (Multiple EtherCAT Network Support)
dwClntId – [in] Client ID determined when registering with the master.
- Returns
EC_E_NOERROR or error code
6.3.12. esExecJob
-
EC_T_DWORD esExecJob(EC_T_DWORD dwInstanceID, EC_T_USER_JOB eUserJob, EC_T_USER_JOB_PARMS *pUserJobParms)
Execute or initiate the requested master job.
To achieve maximum speed, this function is implemented non re-entrant. It is highly recommended that only one single task is calling all required jobs to run the stack. If multiple tasks are calling this function, the calls have to be synchronized externally. Calling it in a context that doesn’t support operating system calls can lead to unpredictable behavior.
- Parameters
dwInstanceID – [in] Instance ID (Multiple EtherCAT Network Support)
eUserJob – [in] user requested job
pUserJobParms – [in] optional user job parameters
- Returns
EC_E_NOERROR if successful
EC_E_INVALIDSTATE if master isn’t initialized
EC_E_INVALIDPARM if dwInstanceID is out of range or the output pointer is EC_NULL
EC_E_LINK_DISCONNECTED if the link is disconnected
EC_E_FEATURE_DISABLED for eUsrJob_SwitchEoeFrames if EC_IOCTL_SET_EOE_DEFFERED_SWITCHING_ENABLED hasn’t be called before
EC_E_ADS_IS_RUNNING if ADS server is running
Brief job overview:
-
union EC_T_USER_JOB_PARMS
Public Members
-
struct EC_T_USER_JOB_PARMS::_SEND_CYCFRAME_BY_TASKID SendCycFramesByTaskId
-
struct EC_T_USER_JOB_PARMS::_PROCESS_RXFRAME_BY_TASKID ProcessRxFramesByTaskId
-
struct EC_T_USER_JOB_PARMS::_SWITCH_EOE_FRAMES SwitchEoeFrames
-
struct EC_T_USER_JOB_PARMS::_START_TASK StartTask
-
struct EC_T_USER_JOB_PARMS::_STOP_TASK StopTask
-
struct EC_T_USER_JOB_PARMS::_SEND_CYCFRAME_BY_TASKID SendCycFramesByTaskId
Detailed job description:
eUsrJob_ProcessAllRxFrames
When the Link Layer operates in polling mode this call will process all currently received frames, when the Link Layer operates in interrupt mode all received frames are processed immediately and this call just returns with nothing done.
pUserJobParms->bAllCycFramesProcessed
This flag is set to a value of
EC_TRUE
it indicates that all previously initiated cyclic frames (eUsrJob_SendAllCycFrames
) are received and processed within this call. Not used if pUserJobParms set toEC_NULL
.Return: EC_E_NOERROR if successful, error code in case of failures.
eUsrJob_SimulatorTimer
This has to be called cyclically to trigger the slave state machines, copy process data from simulated slave firmware as well as the mailbox handling. The slave state machines handle the EtherCAT state change transitions.
Return: EC_E_NOERROR if successful, error code in case of failures.
6.3.13. esGetMasterState
6.3.14. esIoControl
With :ref`esIoControl` a generic control interface exists between the application and the EC-Simulator and its Link Layers.
6.3.15. esIoControl - EC_IOCTL_GET_PDMEMORYSIZE
Queries the necessary size the process data image has got. This IOCTL is to be called after esConfigureNetwork.
- esIoControl - EC_IOCTL_GET_PDMEMORYSIZE
- Parameter
pbyInBuf
: [in] Should be set to EC_NULLdwInBufSize
: [in] Should be set to 0pbyOutBuf
: [out] Pointer to memory where the memory size information will be stored (EC_T_MEMREQ_DESC)dwOutBufSize
: [in] Size of the output buffer provided at pbyOutBuf in bytes.pdwNumOutData
: [out] Should be set to EC_NULL
6.3.16. esIoControl - EC_IOCTL_REGISTER_CYCFRAME_RX_CB
This function call registers a callback function which is called after the cyclic frame is received. Typically this is used when the Link Layer operates interrupt mode to get an event when the new input data (cyclic frame) is available.
The callback function has to be registered after calling esConfigureNetwork()
before starting the job task.
- esIoControl - EC_IOCTL_REGISTER_CYCFRAME_RX_CB
- Parameter
pbyInBuf
: [in] Cyclic frame received callback descriptor (EC_T_CYCFRAME_RX_CBDESC)dwInBufSize
: [in] Size of the input buffer provided at pbyInBuf in bytes.pbyOutBuf
: [out] Should be set to EC_NULLdwOutBufSize
: [in] Should be set to 0pdwNumOutData
: [out] Should be set to EC_NULL
-
struct EC_T_CYCFRAME_RX_CBDESC
Public Members
-
EC_T_VOID *pCallbackContext
[in] Context pointer. This pointer is used as parameter every time when the callback function is called
-
EC_PF_CYCFRAME_RECV pfnCallback
[in] This function will be called after the cyclic frame is received, if there is more than one cyclic frame after the last frame. The application has to assure that these functions will not block.
-
EC_T_VOID *pCallbackContext
6.3.17. esIoControl - EC_IOCTL_ISLINK_CONNECTED
Determine whether link between the EC-Simulator stack and the first slave is connected.
- esIoControl - EC_IOCTL_ISLINK_CONNECTED
- Parameter
pbyInBuf
: [in] Should be set to EC_NULLdwInBufSize
: [in] Should be set to 0pbyOutBuf
: [out] Pointer to EC_T_DWORD. If value is EC_TRUE link is connected, if EC_FALSE it is not.dwOutBufSize
: [in] Size of the output buffer provided at pbyOutBuf in bytes.pdwNumOutData
: [out] Should be set to EC_NULL
Important
With cable redundancy support enabled, EC_FALSE is only set if all links are down.
6.3.18. esIoControl - EC_IOCTL_GET_CYCLIC_CONFIG_INFO
Get cyclic configuration details from ENI configuration file.
- esIoControl - EC_IOCTL_GET_CYCLIC_CONFIG_INFO
- Parameter
pbyInBuf
: [in] Pointer to dwCycEntryIndex: cyclic entry index for which to get informationdwInBufSize
: [in] Size of the input buffer provided at pbyInBuf in bytes.pbyOutBuf
: [out] Pointer to EC_T_CYC_CONFIG_DESC data typedwOutBufSize
: [in] Size of the output buffer provided at pbyOutBuf in bytes.pdwNumOutData
: [out] Pointer to EC_T_DWORD. Amount of bytes written to the output buffer.
6.3.19. esIoControl - EC_IOCTL_ADDITIONAL_VARIABLES_FOR_SPECIFIC_DATA_TYPES
Enable or disable additional variables for specific data types. Default: Enabled.
- esIoControl - EC_IOCTL_ADDITIONAL_VARIABLES_FOR_SPECIFIC_DATA_TYPES
- Parameter
pbyInBuf
: [in] Pointer to value of EC_T_BOOL. EC_TRUE: enable, EC_FALSE: disable.dwInBufSize
: [in] Size of the input buffer provided at pbyInBuf in bytes.pbyOutBuf
: [out] Should be set to EC_NULLdwOutBufSize
: [in] Should be set to 0pdwNumOutData
: [out] Should be set to EC_NULL
6.3.20. esIoControl - EC_IOCTL_SIMULATOR_SET_MBX_PROCESS_CTL
Enable or disable mailbox processing at slave. Default: Enabled.
- esIoControl - EC_IOCTL_SIMULATOR_SET_MBX_PROCESS_CTL
- Parameter
pbyInBuf
: [in] Pointer to value of :cpp:struct:`EC_T_SIMULATOR_MBX_PROCESS_CTL_DESC`dwInBufSize
: [in] Size of the input buffer provided at pbyInBuf in bytespbyOutBuf
: [out] Should be set to EC_NULLdwOutBufSize
: [in] Should be set to 0pdwNumOutData
: [out] Should be set to EC_NULL
6.3.21. esIoControl - EC_IOCTL_SIMULATOR_GET_MBX_PROCESS_CTL
Enable or disable mailbox processing at slave. Default: Enabled.
- esIoControl - EC_IOCTL_SIMULATOR_GET_MBX_PROCESS_CTL
- Parameter
pbyInBuf
: [in] Pointer to value of EC_T_WORD. Configured station address of slavedwInBufSize
: [in] Size of the input buffer provided at pbyInBuf in bytespbyOutBuf
: [out] Pointer to value of :cpp:struct:`EC_T_SIMULATOR_MBX_PROCESS_CTL_DESC`dwOutBufSize
: [in] Size of the output buffer provided at pbyOutBuf in bytespdwNumOutData
: [out] Pointer to EC_T_DWORD. Amount of bytes written to the output buffer.
6.3.22. esIoControl - EC_LINKIOCTL_XXXX
The generic control interface esIoControl() provides access to the main network adapter when adding EC_IOCTL_LINKLAYER_MAIN to the EC_LINKIOCTL_XXXX parameter at dwCode. EC_IOCTL_LINKLAYER_RED specifies the redundant network adapter.
Parameters pbyInBuf, dwInBufSize, pbyOutBuf, dwOutBufSize, pdwNumOutData are specific to EC_LINKIOCTL_XXXX, e.g. EC_LINKIOCTL_GET_ETHERNET_ADDRESS.
6.3.23. esIoControl - EC_LINKIOCTL_GET_ETHERNET_ADDRESS
Get MAC address of network adapter
- esIoControl - EC_LINKIOCTL_GET_ETHERNET_ADDRESS
- Parameter
pbyInBuf
: [in] Should be set to EC_NULLdwInBufSize
: [in] Should be set to 0pbyOutBuf
: [out] Pointer to MAC address buffer (6 bytes)dwOutBufSize
: [in] Size of the output buffer provided at pbyOutBuf in bytespdwNumOutData
: [out] Pointer to EC_T_DWORD: amount of bytes written to the output buffer
6.3.24. esIoControl - EC_LINKIOCTL_GET_SPEED
Get current network adapter’s speed in MBits.
- esIoControl - EC_LINKIOCTL_GET_SPEED
- Parameter
pbyInBuf
: [in] Should be set to EC_NULLdwInBufSize
: [in] Should be set to 0pbyOutBuf
: [out] Pointer to EC_T_DWORD. Set by Link Layer driver to 10/100/1000.dwOutBufSize
: [in] Size of the output buffer provided at pbyOutBuf in bytespdwNumOutData
: [out] Pointer to EC_T_DWORD: amount of bytes written to the output buffer
6.3.25. esGetVersion
-
EC_T_DWORD esGetVersion(EC_T_DWORD dwInstanceID, EC_T_DWORD *pdwVersion)
Gets the version number as a 32-bit value.
- Parameters
dwInstanceID – [in] Instance ID (Multiple EtherCAT Network Support)
pdwVersion – [out] Pointer to EC_T_DWORD to carry out version number
- Returns
EC_E_NOERROR if successful
EC_E_INVALIDSTATE if master isn’t initialized
EC_E_INVALIDPARM if dwInstanceID is out of range or the output pointer is EC_NULL
6.3.26. esGetText
6.3.27. esGetMemoryUsage
-
EC_T_DWORD esGetMemoryUsage(EC_T_DWORD dwInstanceID, EC_T_DWORD *pdwCurrentUsage, EC_T_DWORD *pdwMaxUsage)
Returns information about memory usage.
All calls to malloc/free and new/delete are monitored.
- Parameters
dwInstanceID – [in] Instance ID (Multiple EtherCAT Network Support)
pdwCurrentUsage – [out] Current memory usage in Bytes at the time where this function is called
pdwMaxUsage – [out] Maximum memory usage in Bytes since initialization at the time where this function is called
- Returns
EC_E_NOERROR or error code
6.3.28. esPerfMeasInit
-
EC_T_VOID esPerfMeasInit(EC_T_DWORD dwInstanceId, EC_T_TSC_MEAS_DESC *pTscMeasDesc, EC_T_UINT64 dwlFreqSet, EC_T_DWORD dwNumMeas, EC_T_FNMESSAGE pfnMessage)
Initialize performance measurement.
- Parameters
pTscMeasDesc – [in,out] measurement descriptor
dwlFreqSet – [in] TSC frequency, 0: auto-calibrate
dwNumMeas – [in] number of elements to be allocated in in pTscMeasDesc->aTscTime
pfnMessage – [in] Reserved. Set to EC_NULL
6.3.29. esPerfMeasDeinit
6.3.30. esPerfMeasEnable
6.3.31. esPerfMeasDisable
6.3.32. esPerfMeasStart
6.3.33. esPerfMeasEnd
-
EC_T_TSC_TIME *esPerfMeasEnd(EC_T_DWORD dwInstanceId, EC_T_TSC_MEAS_DESC *pTscMeasDesc, EC_T_DWORD dwIndex)
End measurement.
- Parameters
pTscMeasDesc – [in,out] measurement descriptor
dwIndex – [in] measurement index
- Returns
Pointer to corresponding time descriptor
6.3.34. esPerfMeasReset
6.3.35. esPerfMeasShow
-
EC_T_VOID esPerfMeasShow(EC_T_DWORD dwInstanceId, EC_T_TSC_MEAS_DESC *pTscMeasDesc, EC_T_DWORD dwIndex, EC_T_CHAR **aszMeasCaption)
Show measurement results.
- Parameters
pTscMeasDesc – [in,out] measurement descriptor
dwIndex – [in] measurement index, 0xFFFFFFFF: all indexes
aszMeasCaption – [in] measurement caption
6.3.36. esPerfMeasSetIrqCtlEnabled
-
EC_T_VOID esPerfMeasSetIrqCtlEnabled(EC_T_DWORD dwInstanceId, EC_T_BOOL bEnabled)
By default, the beginning of the measurement deactivates interrupts and the end activates interrupts again in order to protect against external events that affect the measurement. This behavior can be deactivated through this API.
- Parameters
bEnabled – [in] EC_TRUE: IRQ control enabled. EC_FALSE: disabled
6.3.37. esLogFrameEnable
-
EC_T_DWORD esLogFrameEnable(EC_T_DWORD dwInstanceID, EC_T_PFLOGFRAME_CB pvLogFrameCallBack, EC_T_VOID *pvContext)
Setup a callback function to log the EtherCAT network traffic.
The callback function is called by the cyclic task. Therefore the code inside the callback has to be fast and non-blocking. The callback parameter dwLogFlags can be used as a filter to log just specific frames. The master discards the frame if the callback function modifies the Ethernet frame type at byte offset 12.
- Parameters
dwInstanceID – [in] Instance ID (Multiple EtherCAT Network Support)
pvLogFrameCallBack – [in] Pointer to frame logging callback function
pvContext – [in] Pointer to function specific context
- Returns
EC_E_NOERROR or error code
/********************************************************************************/
/** \brief Handler to log frames.
*
* CAUTION: Called by cyclic task! Do not consume to much CPU time!
*/
EC_T_VOID LogFrameHandler(EC_T_VOID* pvContext, EC_T_DWORD dwLogFlags, EC_T_DWORD dwFrameSize, EC_T_BYTE* pbyFrame)
{
EC_T_STATE eMasterState;
/* get master state */
eMasterState = (EC_T_STATE)(dwLogFlags & EC_LOG_FRAME_FLAG_MASTERSTATE_MASK);
/* skip tx frame */
if ((S_dwLogFrameLevel == 3) && !(dwLogFlags & EC_LOG_FRAME_FLAG_RX_FRAME))
return;
/* skip cyclic frame */
if ((S_dwLogFrameLevel == 2) && !(dwLogFlags & EC_LOG_FRAME_FLAG_ACYC_FRAME))
return;
/* skip red frame */
if (dwLogFlags & EC_LOG_FRAME_FLAG_RED_FRAME)
return;
/* do something with pbyFrame ... */
}
6.3.38. esLogFrameDisable
-
EC_T_DWORD esLogFrameDisable(EC_T_DWORD dwInstanceID)
Disable the frame logging callback.
- Parameters
dwInstanceID – [in] Instance ID (Multiple EtherCAT Network Support)
- Returns
EC_E_NOERROR or error code