4.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

4.2. Multiple EtherCAT Network Support

4.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, …).

4.2.2. Licensing

For each network identified with the unique Instance ID a separate runtime license is required.

4.3. General functions

4.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_DWORD dwSignature

[in] Set to SIMULATOR_SIGNATURE

EC_T_DWORD dwSize

[in] Set to sizeof(EC_T_SIMULATOR_INIT_PARMS)

EC_T_DWORD dwSimulatorAddress

[in] Reserved

struct _EC_T_OS_PARMS *pOsParms

[in] OS layer parameters

EC_T_LINK_PARMS *apLinkParms[EC_SIMULATOR_MAX_LINK_PARMS]

[in] Link layer parameters

EC_T_DWORD dwBusCycleTimeUsec

[in] [usec] bus cycle time in microseconds

EC_T_BOOL bDisableProcessDataImage

[in] (legacy support, CiA402 simulation)

EC_T_SIMULATOR_DEVICE_CONNECTION_DESC aoDeviceConnection[EC_SIMULATOR_MAX_LINK_PARMS]

[in] see EC_SIMULATOR_DEVICE_CONNECTION_TYPE_…

EC_T_BOOL bConnectHcGroups

[in] connect hot connect groups in topology (floating group heads to free ports)

struct EC_T_OS_PARMS

Public Members

EC_T_DWORD dwSignature

[in] Set to EC_OS_PARMS_SIGNATURE

EC_T_DWORD dwSize

[in] Set to sizeof(EC_T_OS_PARMS)

struct _EC_T_LOG_PARMS *pLogParms

[in] Pointer to logging parameters

EC_PF_SYSTIME pfSystemTimeGet

[in] Function to get host time in nanoseconds since 1st January 2000. Used as time base for DC Initialization.

EC_T_DWORD dwSupportedFeatures

[in/out] reserved

EC_PF_QUERY_MSEC_COUNT pfSystemQueryMsecCount

[in] Function to get system’s msec count

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_HW_TIMER_MODIFY_INITIAL_COUNT pfHwTimerModifyInitialCount

[in] Function to modify initial count of HW timer. This function is needed by some DCM modes described in the Class A manual

EC_PF_HW_TIMER_GET_CURRENT_COUNT pfHwTimerGetCurrentCount

[in] Function to get current count of HW timer. This function is needed by some DCM modes described in the Class A manual

struct EC_T_LOG_PARMS

Public Members

EC_T_DWORD dwLogLevel

[in] Log level. See EC_LOG_LEVEL_…

EC_PF_LOGMSGHK pfLogMsg

[in] Log callback function called on every message

struct _EC_T_LOG_CONTEXT *pLogContext

[in] Log context to be passed to log callback

EC_LOG_LEVEL… The following log levels are defined:

EC_LOG_LEVEL_SILENT
EC_LOG_LEVEL_ANY
EC_LOG_LEVEL_CRITICAL
EC_LOG_LEVEL_ERROR
EC_LOG_LEVEL_WARNING
EC_LOG_LEVEL_INFO
EC_LOG_LEVEL_INFO_API
EC_LOG_LEVEL_VERBOSE
EC_LOG_LEVEL_VERBOSE_ACYC
EC_LOG_LEVEL_VERBOSE_CYC
EC_LOG_LEVEL_UNDEFINED
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_BOOL bEnabled

[in] enable/disable internal performance counters.

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.

struct EC_T_PERF_MEAS_COUNTER_PARMS

Public Members

EC_PF_PERF_MEAS_GETCOUNTERTICKS pfGetCounterTicks

[in] Function returning the current counter ticks

EC_T_VOID *pvGetCounterTicksContext

[in] Context passed into GetCounterTicks

EC_T_UINT64 qwFrequency

[in] Frequency in Hz used by the timer in GetCounterTicks

typedef EC_T_UINT64 (*EC_PF_PERF_MEAS_GETCOUNTERTICKS)(EC_T_VOID *pvContext)
Parameters

pvContext[in] – Context pointer

struct EC_T_PERF_MEAS_HISTOGRAM_PARMS

Public Members

EC_T_DWORD dwBinCount

[in] amount of bins to use for the histogram.

EC_T_UINT64 qwMinTicks

[in] results below qwMinTicks are stored in the first bin

EC_T_UINT64 qwMaxTicks

[in] results above qwMaxTicks are stored in the last bin

4.3.2. esDeinitSimulator

EC_T_DWORD esDeinitSimulator(EC_T_DWORD dwInstanceId)

Deinitialize EC-Simulator.

Parameters

dwInstanceId – [in] Simulator Instance ID

Returns

EC_E_NOERROR or error code

4.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

4.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

4.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().

4.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

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");

4.3.7. esSetOemKey (HiL)

static EC_T_DWORD esSetOemKey(EC_T_DWORD dwInstanceID, EC_T_UINT64 qwOemKey)

Must be called after esInitSimulator() and before esConfigureNetwork().

Example:

dwRes = esSetOemKey(dwInstanceID, 0x1234567812345678);

4.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

enum EC_T_CNF_TYPE

Values:

enumerator eCnfType_Unknown
enumerator eCnfType_Filename

pbyCnfData: ENI filename to read

enumerator eCnfType_Data

pbyCnfData: ENI data

enumerator eCnfType_Datadiag

pbyCnfData: ENI data for diagnosis

enumerator eCnfType_GenPreopENI

Generate ENI based on bus-scan result to get into PREOP state

enumerator eCnfType_GenPreopENIWithCRC

same as eCnfType_GenPreopENI with CRC protection

enumerator eCnfType_GenOpENI

Generate ENI based on bus-scan result to get into OP state

enumerator eCnfType_None

Reset configuration

enumerator eCnfType_ConfigData

pbyCnfData: Binary structured configuration

enumerator eCnfType_BCppDummy

4.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

4.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 or error code

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.

struct EC_T_REGISTERRESULTS

Public Members

EC_T_DWORD dwClntId

[out] Client ID

EC_T_BYTE *pbyPDIn

[out] Pointer to process data input memory

EC_T_DWORD dwPDInSize

[out] Size of process data input memory (in bytes)

EC_T_BYTE *pbyPDOut

[out] Pointer to process data output memory

EC_T_DWORD dwPDOutSize

[out] Size of process data output memory (in bytes)

4.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

4.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 or error code

Brief job overview:

enum EC_T_USER_JOB

Values:

enumerator eUsrJob_Undefined
enumerator eUsrJob_ProcessAllRxFrames
enumerator eUsrJob_SendAllCycFrames
enumerator eUsrJob_RunMcSm
enumerator eUsrJob_MasterTimer
enumerator eUsrJob_FlushQueuedCmds
enumerator eUsrJob_SendAcycFrames
enumerator eUsrJob_SendCycFramesByTaskId
enumerator eUsrJob_MasterTimerMinimal
enumerator eUsrJob_ProcessRxFramesByTaskId
enumerator eUsrJob_ProcessAcycRxFrames
enumerator eUsrJob_SwitchEoeFrames
enumerator eUsrJob_StartTask
enumerator eUsrJob_StopTask
enumerator eUsrJob_StampSendAllCycFrames
enumerator eUsrJob_StampSendCycFramesByTaskId
enumerator eUsrJob_SimulatorTimer
enumerator eUsrJob_MonitorTimer
enumerator eUsrJob_BCppDummy
union EC_T_USER_JOB_PARMS

Public Members

EC_T_BOOL bAllCycFramesProcessed
EC_T_DWORD dwNumFramesSent
EC_T_DWORD dwTaskIdToSend
EC_T_DWORD dwTaskId
struct EC_T_USER_JOB_PARMS::[anonymous] SendCycFramesByTaskId
EC_T_BOOL bCycFramesProcessed
struct EC_T_USER_JOB_PARMS::[anonymous] ProcessRxFramesByTaskId
EC_T_DWORD dwMaxPortsToProcess
EC_T_DWORD dwNumFramesProcessed
struct EC_T_USER_JOB_PARMS::[anonymous] SwitchEoeFrames
struct EC_T_USER_JOB_PARMS::[anonymous] StartTask
struct EC_T_USER_JOB_PARMS::[anonymous] StopTask

Detailed job description:

  1. 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 to EC_NULL.

    Return: EC_E_NOERROR if successful, error code in case of failures.

  2. eUsrJob_MasterTimer

    To trigger the master and slave state machines as well as the mailbox handling this call has to be executed cyclically. The master cycle time is determined by the period between calling emExecJob() ( eUsrJob_MasterTimer). The state-machines are handling the EtherCAT state change transfers.

    Return: EC_E_NOERROR if successful, error code in case of failures.

4.3.13. esGetMasterState

EC_T_STATE esGetMasterState(EC_T_DWORD dwInstanceID)

Get the EtherCAT master current state.

Parameters

dwInstanceID – [in] Instance ID (Multiple EtherCAT Network Support)

Returns

EtherCAT master state

4.3.14. esIoControl

With :ref`esIoControl` a generic control interface exists between the application and the EC-Simulator and its Link Layers.

struct EC_T_IOCTLPARMS

Public Members

EC_T_BYTE *pbyInBuf

[in] Pointer to control input parameter.

EC_T_DWORD dwInBufSize

[in] Size of the input buffer provided at pbyInBuf in bytes

EC_T_BYTE *pbyOutBuf

[out] Pointer to control output buffer where the results will be copied into

EC_T_DWORD dwOutBufSize

[in] Size of the output buffer provided at pbyOutBuf in bytes

EC_T_DWORD *pdwNumOutData

[out] Pointer to EC_T_DWORD. Amount of bytes written to the output buffer

4.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_NULL

  • dwInBufSize: [in] Should be set to 0

  • pbyOutBuf: [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

struct EC_T_MEMREQ_DESC

4.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_NULL

  • dwOutBufSize: [in] Should be set to 0

  • pdwNumOutData: [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.

typedef EC_T_VOID (*EC_PF_CYCFRAME_RECV)(EC_T_DWORD dwTaskId, EC_T_VOID *pvContext)
Parameters
  • dwTaskId – [in] Task id of the received cyclic frame.

  • pvContext – [in] Context pointer. This pointer is used as parameter every time when the callback function is called.

4.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 information

  • dwInBufSize: [in] Size of the input buffer provided at pbyInBuf in bytes.

  • pbyOutBuf: [out] Pointer to EC_T_CYC_CONFIG_DESC data type

  • dwOutBufSize: [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.

struct EC_T_CYC_CONFIG_DESC

Public Members

EC_T_DWORD dwNumCycEntries

[out] Total number of cyclic entries

EC_T_DWORD dwTaskId

[out] Task id of selected cyclic entry

EC_T_DWORD dwPriority

[out] Priority of selected cyclic entry

EC_T_DWORD dwCycleTime

[out] Cycle time of selected cyclic entry

4.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_NULL

  • dwOutBufSize: [in] Should be set to 0

  • pdwNumOutData: [out] Should be set to EC_NULL

4.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 bytes

  • pbyOutBuf: [out] Should be set to EC_NULL

  • dwOutBufSize: [in] Should be set to 0

  • pdwNumOutData: [out] Should be set to EC_NULL

struct EC_T_SIMULATOR_MBX_PROCESS_CTL_DESC

Public Members

EC_T_WORD wCfgFixedAddress

Slave’s station address. 0: all slaves

EC_T_BOOL bReadMbxOutEnabled

Read mailbox out sync manager from DPRAM (received mailbox data from the master)

EC_T_BOOL bProcessMbxEnabled

Process mailbox data from the master (MailboxServiceInd)

4.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 slave

  • dwInBufSize: [in] Size of the input buffer provided at pbyInBuf in bytes

  • pbyOutBuf: [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 bytes

  • pdwNumOutData: [out] Pointer to EC_T_DWORD. Amount of bytes written to the output buffer.

4.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.

4.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_NULL

  • dwInBufSize: [in] Should be set to 0

  • pbyOutBuf: [out] Pointer to MAC address buffer (6 bytes)

  • dwOutBufSize: [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

4.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_NULL

  • dwInBufSize: [in] Should be set to 0

  • pbyOutBuf: [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 bytes

  • pdwNumOutData: [out] Pointer to EC_T_DWORD: amount of bytes written to the output buffer

4.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

4.3.26. esGetText

const EC_T_CHAR *esGetText(EC_T_DWORD dwInstanceID, EC_T_DWORD dwTextId)

Return text tokens by ID.

Parameters

dwInstanceID – [in] Instance ID (Multiple EtherCAT Network Support)

Returns

Textual description of the given ID

4.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

4.3.28. esPerfMeasInit

EC_T_VOID ecatPerfMeasInit(EC_T_TSC_MEAS_DESC *pTscMeasDesc, EC_T_UINT64 dwlFreqSet, EC_T_DWORD dwNumMeas, EC_T_FNMESSAGE pfnMessage)
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

4.3.29. esPerfMeasDeinit

EC_T_VOID ecatPerfMeasDeinit(EC_T_TSC_MEAS_DESC *pTscMeasDesc)
Parameters

pTscMeasDesc – [in,out] measurement descriptor

4.3.30. esPerfMeasEnable

EC_T_VOID ecatPerfMeasEnable(EC_T_TSC_MEAS_DESC *pTscMeasDesc)
Parameters

pTscMeasDesc – [in,out] measurement descriptor

4.3.31. esPerfMeasDisable

EC_T_VOID ecatPerfMeasDisable(EC_T_TSC_MEAS_DESC *pTscMeasDesc)
Parameters

pTscMeasDesc – [in,out] measurement descriptor

4.3.32. esPerfMeasStart

EC_T_VOID ecatPerfMeasStart(EC_T_TSC_MEAS_DESC *pTscMeasDesc, EC_T_DWORD dwIndex)
Parameters
  • pTscMeasDesc – [in,out] measurement descriptor

  • dwIndex – [in] measurement index

4.3.33. esPerfMeasEnd

EC_T_TSC_TIME *ecatPerfMeasEnd(EC_T_TSC_MEAS_DESC *pTscMeasDesc, EC_T_DWORD dwIndex)
Parameters
  • pTscMeasDesc – [in,out] measurement descriptor

  • dwIndex – [in] measurement index

struct EC_T_TSC_TIME

Public Members

EC_T_UINT64 qwStart

start time

EC_T_UINT64 qwEnd

end time

EC_T_DWORD dwCurr

[1/10 usec]

EC_T_DWORD dwMin

[1/10 usec]

EC_T_DWORD dwMax

[1/10 usec]

EC_T_DWORD dwAvg

[1/1600 usec]

EC_T_BOOL bMeasReset

EC_TRUE if measurement values shall be reset

EC_T_INT nIntLevel

for interrupt lockout handling

4.3.34. esPerfMeasReset

EC_T_VOID ecatPerfMeasReset(EC_T_TSC_MEAS_DESC *pTscMeasDesc, EC_T_DWORD dwIndex)
Parameters
  • pTscMeasDesc – [in,out] measurement descriptor

  • dwIndex – [in] measurement index, 0xFFFFFFFF: all indexes

4.3.35. esPerfMeasShow

EC_T_VOID ecatPerfMeasShow(EC_T_TSC_MEAS_DESC *pTscMeasDesc, EC_T_DWORD dwIndex, EC_T_CHAR **aszMeasCaption)
Parameters
  • pTscMeasDesc – [in,out] measurement descriptor

  • dwIndex – [in] measurement index, 0xFFFFFFFF: all indexes

  • aszMeasCaption – [in] measurement caption

4.3.36. esPerfMeasSetIrqCtlEnabled

EC_T_VOID ecatPerfMeasSetIrqCtlEnabled(EC_T_BOOL bEnabled)
Parameters

bEnabled – [in] EC_TRUE: IRQ control enabled. EC_FALSE: disabled

4.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 ... */
}

4.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