6.3. General functions
6.3.1. emInitMaster
-
static EC_T_DWORD ecatInitMaster(const EC_T_INIT_MASTER_PARMS *pParms)
-
EC_T_DWORD emInitMaster(EC_T_DWORD dwInstanceID, const EC_T_INIT_MASTER_PARMS *pParms)
Initialize EC-Master.
This function has to be called prior to calling any other function of EC-Master.
- Parameters
dwInstanceID – [in] Instance ID (Multiple EtherCAT Network Support)
pParms – [in] Pointer to parameter definitions
- Returns
EC_E_NOERROR if successful
EC_E_INVALIDSTATE if EtherCAT stack is already initialized
EC_E_INVALIDPARM if dwInstanceID is out of range or pParms is EC_NULL or contains some values out of range
EC_E_SIGNATURE_MISMATCH if EC_T_INIT_MASTER_PARMS.dwSignature mismatch
EC_E_NOTFOUND if the link layer cannot be found
EC_E_FEATURE_DISABLED if a configured feature is not included in the license key
EC_E_NOTSUPPORTED if a configured feature is not supported (e.g not compiled in the library)
EC_E_LOCK_CREATE_FAILED if some lock (e.g mutex) cannot be created
EC_E_NOMEMORY if some memory cannot be allocated
-
struct EC_T_INIT_MASTER_PARMS
Public Members
-
EC_T_LOG_PARMS LogParms
[in] Logging parameters
-
EC_T_OS_PARMS *pOsParms
[in] OS layer parameters
-
EC_T_LINK_PARMS *pLinkParms
[in] Link layer parameters
-
EC_T_LINK_PARMS *pLinkParmsRed
[in] Link layer parameters for red device (cable redundancy)
-
EC_T_DWORD dwMaxAcycBytesPerCycle
[in] Maximum bytes sent during eUsrJob_SendAcycFrames per cycle ( default: 4096 )
-
EC_T_DWORD dwMaxAcycFramesPerCycle
[in] Maximum frames sent during eUsrJob_SendAcycFrames per cycle ( default: 32 )
-
EC_T_DWORD dwMaxAcycCmdsPerCycle
[in] Maximum commands sent during eUsrJob_SendAcycFrames per cycle ( default: 124 )
-
EC_T_DWORD dwMaxSlavesProcessedPerCycle
[in] Maximum slave-related state machine calls per cycle (default = all)
-
EC_T_DWORD dwEcatCmdMaxRetries
[in] Maximum retries to send pending EtherCAT command frames ( default: 3 )
-
EC_T_DWORD dwEcatCmdTimeout
[in] Timeout [ms] to send pending EtherCAT command frames ( default: 3 * bus cycle time, at least 2 ms )
-
EC_T_WORD wMaxSlavesProcessedPerBusScanStep
[in] Maximum slave-related calls per cycle during bus scans (default = all)
-
EC_T_BOOL bApiLockByApp
[in] Lock pending API against emDeinitMaster(). EC_FALSE (default): locked internally. EC_TRUE: application is responsible for locking.
-
EC_T_PERF_MEAS_INTERNAL_PARMS PerfMeasInternalParms
[in] Internal performance measurement parameters
-
EC_T_LOG_PARMS LogParms
-
struct EC_T_OS_PARMS
Public Members
-
EC_T_LOG_PARMS *pLogParms
[in] Pointer to logging parameters
-
EC_T_LOG_PARMS *pLogParms
-
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
-
EC_T_DWORD dwLogLevel
EC_LOG_LEVEL… The following log levels are defined:
-
typedef EC_T_DWORD (*EC_PF_LOGMSGHK)(EC_T_LOG_CONTEXT *pContext, EC_T_DWORD dwLogMsgSeverity, const EC_T_CHAR *szFormat, ...)
- Param pContext
[in] Context pointer. This pointer is used as parameter when the callback function is called.
- Param dwLogMsgSeverity
[in] Log message severity, EC_LOG_LEVEL_…
- Param 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.
- Return
EC_E_NOERROR or error code
Log messages are passed from the EC-Master 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-Master 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. emDeinitMaster
-
EC_T_DWORD emDeinitMaster(EC_T_DWORD dwInstanceID)
Deinitialize EC-Master.
Waits for pending API calls if emInitMaster() was called with EC_T_INIT_MASTER_PARMS::bApiLockByApp = EC_FALSE (default).
- Parameters
dwInstanceID – [in] Instance ID (Multiple EtherCAT Network Support)
- Returns
EC_E_NOERROR or error code
6.3.3. emGetMasterParms
-
static EC_T_DWORD ecatGetMasterParms(EC_T_INIT_MASTER_PARMS *pParms, EC_T_DWORD dwParmsBufSize)
-
EC_T_DWORD emGetMasterParms(EC_T_DWORD dwInstanceID, EC_T_INIT_MASTER_PARMS *pParms, EC_T_DWORD dwParmsBufSize)
Get current Master initialization parameters.
If the given buffer is larger than the actual size of the structure EC_T_INIT_MASTER_PARMS, the parameters of EC_T_INIT_MASTER_PARMS.pOsParms, EC_T_INIT_MASTER_PARMS.pLinkParms and EC_T_INIT_MASTER_PARMS.pLinkParmsRed are appended.
- Parameters
dwInstanceID – [in] Instance ID (Multiple EtherCAT Network Support)
pParms – [out] Buffer to store Master parameters
dwParmsBufSize – [in] Size of Master parameters buffer
- Returns
EC_E_NOERROR if successful
EC_E_INVALIDSTATE if EtherCAT stack isn’t initialized
EC_E_INVALIDPARM if dwInstanceID is out of range or the output pointer is EC_NULL or dwParmsBufSize is too small
emGetMasterParms() Example
EC_T_BYTE abyBuffer[sizeof(EC_T_INIT_MASTER_PARMS)
+ sizeof(EC_T_OS_PARMS) + 512 /* LinkLayer parameters */];
EC_T_INIT_MASTER_PARMS* pParms = (EC_T_INIT_MASTER_PARMS*)abyBuffer;
dwRes = emGetMasterParms(dwInstanceId, pParms, sizeof(abyBuffer));
See also
6.3.4. emSetMasterParms
-
static EC_T_DWORD ecatSetMasterParms(const EC_T_INIT_MASTER_PARMS *pParms)
-
EC_T_DWORD emSetMasterParms(EC_T_DWORD dwInstanceID, const EC_T_INIT_MASTER_PARMS *pParms)
Change Master initialization parameters.
Currently the following parameters cannot be changed:
- Parameters
dwInstanceID – [in] Instance ID (Multiple EtherCAT Network Support)
pParms – [in] New Master parameters
- Returns
EC_E_NOERROR if successful
EC_E_INVALIDSTATE if EtherCAT stack isn’t initialized
emSetMasterParms() Example
EC_T_BYTE abyBuffer[sizeof(EC_T_INIT_MASTER_PARMS) + sizeof(EC_T_OS_PARMS)
+ 512 /* LinkLayer parameters */];
EC_T_INIT_MASTER_PARMS* pParms = (EC_T_INIT_MASTER_PARMS*)abyBuffer;
dwRes = emGetMasterParms(dwInstanceId, pParms, sizeof(abyBuffer));
pParms->wReserved = 1;
/* change Master initialization parameters */
dwRes = emSetMasterParms(dwInstanceId, pParms);
See also
6.3.5. emScanBus
-
EC_T_DWORD emScanBus(EC_T_DWORD dwInstanceID, EC_T_DWORD dwTimeout)
Scans all connected slaves.
Scans all connected slaves connected to EC-Master. If a configuration has been loaded, a validation between the configuration and the connected slaves is done. This function should not be called from within the JobTask’s context.
- Parameters
dwInstanceID – [in] Instance ID (Multiple EtherCAT Network Support)
dwTimeout – [in] Timeout [ms]
- Returns
EC_E_NOERROR if successful
EC_E_INVALIDSTATE if EtherCAT stack isn’t initialized
EC_E_INVALIDPARM if dwInstanceID is out of range
EC_E_LINK_DISCONNECTED if link is disconnected
EC_E_TIMEOUT if dwTimeout elapsed during the API call
EC_E_BUSCONFIG_MISMATCH if the slaves found do not match the configured ones
EC_E_LINE_CROSSED if a line crossed (cabling wrong) condition has been detected
EC_E_REDLINEBREAK if cable redundancy is configured and a line break condition has been detected
EC_E_JUNCTION_RED_LINE_BREAK if junction redundancy is configured and a line break condition has been detected
EC_E_MAX_BUS_SLAVES_EXCEEDED if the amount of slaves found exceeds EC_T_INIT_MASTER_PARMS.dwMaxBusSlaves
EC_E_MASTER_RED_STATE_INACTIVE if Master Redundancy is configured and master is inactive
EC_E_ADS_IS_RUNNING if the ADS server is running
emScanBus() Example
dwRes = emScanBus(dwInstanceId, 5000 /* timeout */);
See also
6.3.6. emRescueScan
-
EC_T_DWORD emRescueScan(EC_T_DWORD dwInstanceID, EC_T_DWORD dwTimeout)
Recovers the bus from permanent frame loss situations.
Scans all connected slaves. Closes and opens ports on the network to rule out slaves which permanently discard frames. The Master notifies every slave port which permanently discards frames with EC_NOTIFY_FRAMELOSS_AFTER_SLAVE. Due to port opening and closing the scanning time is increased about 2 seconds per slave. The Master will not automatically re-open this port. The application can force to open the port again. This function may not be called from within the JobTask’s context.
- Parameters
dwInstanceID – [in] Instance ID (Multiple EtherCAT Network Support)
dwTimeout – [in] Timeout [ms]
- Returns
EC_E_NOERROR or error code
emRescueScan() Example
dwRes = emRescueScan(dwInstanceId, 5000 /* timeout */);
6.3.7. emConfigureNetwork
-
static EC_T_DWORD ecatConfigureNetwork(EC_T_CNF_TYPE eCnfType, EC_T_PBYTE pbyCnfData, EC_T_DWORD dwCnfDataLen)
-
EC_T_DWORD emConfigureNetwork(EC_T_DWORD dwInstanceID, EC_T_CNF_TYPE eCnfType, EC_T_PBYTE pbyCnfData, EC_T_DWORD dwCnfDataLen)
Configure the Network.
This function must be called after the initialization. Among others the EtherCAT topology defined in the given XML configuration file will be stored internally.
Analyzing the network including mailbox communication can be done without specifying an ENI file using eCnfType_GenPreopENI.
Note
A client must not be registered prior to calling this function. Existing client registrations will be dropped.
- Parameters
dwInstanceID – [in] Instance ID (Multiple EtherCAT Network Support)
eCnfType – [in] Type of configuration data provided
pbyCnfData – [in] Filename / configuration data, or EC_NULL if eCnfType is eCnfType_GenPreopENI
dwCnfDataLen – [in] Length of configuration data in byte, or zero if eCnfType is eCnfType_GenPreopENI
- Returns
EC_E_NOERROR if successful
EC_E_INVALIDSTATE if EtherCAT stack isn’t initialized or eCnfType is eCnfType_GenPreopENI or eCnfType_GenOpENI and link is disconnected
EC_E_INVALIDPARM if dwInstanceID is out of range or pParms is EC_NULL contains some values out of range
EC_E_LINK_DISCONNECTED if link is disconnected
EC_E_FEATURE_DISABLED if a configured feature is not included in the license key
EC_E_NOTSUPPORTED if a configured feature is not supported (e.g not compiled in the library)
EC_E_CFGFILENOTFOUND if the ENI file cannot be found
EC_E_WRONG_FORMAT if format errors have been detected in the ENI or EEPROM in case of eCnfType_GenPreopENI or eCnfType_GenOpENI
EC_E_OEM_SIGNATURE_MISMATCH if the OEM signature in the ENI file doesn’t match the used OEM key
EC_E_ENI_ENCRYPTION_WRONG_VERSION if the ENI encryption version is not supported (e.g. the library is too old)
EC_E_ENI_ENCRYPTED if the ENI is encrypted and no OEM key has been set
EC_E_XML_CYCCMDS_MISSING if the ENI doesn’t contain cyclic commands
EC_E_XML_ALSTATUS_READ_MISSING if the ENI doesn’t contain any read AL status command
EC_E_XML_CYCCMDS_SIZEMISMATCH if the size of the cyclic commands in the ENI mismatch
EC_E_XML_INVALID_INP_OFF if some input offsets in the ENI are invalid
EC_E_XML_INVALID_OUT_OFF if some output offsets in the ENI are invalid
EC_E_XML_INVALID_CMD_WITH_RED if the ENI contains LRW commands and cable redundancy is configured
EC_E_XML_PREV_PORT_MISSING if some previous port information are missing in the ENI
EC_E_XML_DC_CYCCMDS_MISSING if the DC related cyclic commands are missing in the ENI
EC_E_XML_AOE_NETID_INVALID if the ENI contains some invalid NetID
-
enum EC_T_CNF_TYPE
Values:
-
enumerator eCnfType_GenOpENI
Generate ENI based on bus-scan result to get into OP state. The default PDO mapping read from the slaves is activated. See ETG2010 “SII Specification”, Table 14 “Structure Category TXPDO and RXPDO for each PDO”.
-
enumerator eCnfType_GenOpENINoStrings
Generate ENI based on bus-scan result to get into OP state, does not read strings from EEPROM
-
enumerator eCnfType_FileByApp
File access provided by user application, See EC_T_CNF_FILEBYAPP_DESC
-
enumerator eCnfType_GenOpENI
Depending on this enum pbyCnfData is interpreted differently. This function may not be called from within the JobTask’s context.
-
struct EC_T_CNF_FILEBYAPP_DESC
Public Members
-
EC_PF_CNF_OPEN pfnFileOpen
[in] Function pointer called instead of OsCfgFileOpen()
-
EC_PF_CNF_CLOSE pfnFileClose
[in] Function pointer called instead of OsCfgFileClose()
-
EC_PF_CNF_READ pfnFileRead
[in] Function pointer called instead of OsCfgFileRead()
-
EC_PF_CNF_ERROR pfnFileError
[in] Function pointer called instead of OsCfgFileError()
-
EC_PF_CNF_EOF pfnFileEof
[in] Function pointer called instead of OsCfgFileEof()
-
EC_PF_CNF_OPEN pfnFileOpen
-
typedef EC_T_DWORD (*EC_PF_CNF_OPEN)(EC_T_VOID *pvContext)
Called by the EtherCAT stack instead of OsCfgFileOpen() within emConfigureNetwork(eCnfType_FileByApp)
- Param pvContext
[in] Arbitrarily application-defined parameter passed to callback
- Return
EC_E_NOERROR or error code
-
typedef EC_T_DWORD (*EC_PF_CNF_CLOSE)(EC_T_VOID *pvContext)
Called by the EtherCAT stack instead of OsCfgFileClose() within emConfigureNetwork(eCnfType_FileByApp)
- Param pvContext
[in] Arbitrarily application-defined parameter passed to callback
- Return
EC_E_NOERROR or error code
-
typedef EC_T_DWORD (*EC_PF_CNF_READ)(EC_T_VOID *pvContext, EC_T_BYTE *pbyReadData, EC_T_DWORD dwReadLen, EC_T_DWORD *pdwNumOutData)
Called by the EtherCAT stack instead of OsCfgFileRead() within emConfigureNetwork(eCnfType_FileByApp)
- Param pvContext
[in] Arbitrarily application-defined parameter passed to callback
- Param pbyReadData
[out] Pointer to the data read
- Param dwReadLen
[in] Amount of bytes to be read by the EtherCAT stack (next part of the configuration file)
- Param pdwNumOutData
[out] Amount of bytes written to pbyReadData by callback
- Return
EC_E_NOERROR or error code
-
typedef EC_T_DWORD (*EC_PF_CNF_ERROR)(EC_T_VOID *pvContext)
Called by the EtherCAT stack instead of OsCfgFileError() within emConfigureNetwork(eCnfType_FileByApp)
- Param pvContext
[in] Arbitrarily application-defined parameter passed to callback
- Return
EC_E_NOERROR or error code
-
typedef EC_T_DWORD (*EC_PF_CNF_EOF)(EC_T_VOID *pvContext, EC_T_BOOL *bEof)
Called by the EtherCAT stack instead of OsCfgFileEof() within emConfigureNetwork(eCnfType_FileByApp)
- Param pvContext
[in] Arbitrarily application-defined parameter passed to callback
- Param bEof
[out] Indicates whether the end of the file has been reached (EC_TRUE if EOF, EC_FALSE otherwise).
- Return
EC_E_NOERROR or error code
emConfigureNetwork() Example
/* load ENI */
const EC_T_CHAR* szFileName = "eni.xml";
dwRes = emConfigureNetwork(dwInstanceId, eCnfType_Filename,
(EC_T_BYTE*)szFileName, (EC_T_DWORD)OsStrlen(szFileName));
6.3.8. emConfigGet
-
EC_T_DWORD emConfigGet(EC_T_DWORD dwInstanceID, EC_T_BYTE **ppbyCnfData, EC_T_DWORD *pdwCnfDataLen)
Get the master configuration.
This function returns the result of ENI parsing in binary format. This data can be stored at a different location (e.g. read only flash). Later on, the Master can be configured without ENI using the type EC_T_CNF_TYPE::eCnfType_ConfigData.
Note
The binary format is not version independent and the data becomes invalid when used with a different version. The returned pointer is valid as long as the Master is initialized and no other configuration was loaded.
- Parameters
dwInstanceID – [in] Instance ID (Multiple EtherCAT Network Support)
ppbyCnfData – [out] Configuration data
pdwCnfDataLen – [out] Length of configuration data in byte
- Returns
EC_E_NOERROR or error code
emConfigGet() Example
EC_T_BYTE* pbyConfigData = EC_NULL;
EC_T_DWORD dwConfigDataSize = 0;
/* set config data memory pool */
EC_IOCTL_SET_CONFIGDATA_MEMORY_POOL_DESC oPoolDesc;
oPoolDesc.dwSize = 100000; /* max config file size */
oPoolDesc.pbyStart = (EC_T_BYTE*)OsMalloc(oPoolDesc.dwSize);
dwRes = emIoCtl(dwInstanceId, EC_IOCTL_SET_CONFIGDATA_MEMORY_POOL,
&oPoolDesc, sizeof(EC_IOCTL_SET_CONFIGDATA_MEMORY_POOL_DESC),
EC_NULL, 0, EC_NULL);
if (dwRes != EC_E_NOERROR)
{
dwRetVal = dwRes;
goto Exit;
}
/* load config */
dwRes = emConfigLoad(dwInstanceId, eCnfType_Filename,
(EC_T_BYTE*)szFileName, (EC_T_DWORD)OsStrlen(szFileName));
if (dwRes != EC_E_NOERROR)
{
dwRetVal = dwRes;
goto Exit;
}
/* get config */
dwRes = emConfigGet(dwInstanceId, &pbyConfigData, &dwConfigDataSize);
if (dwRes != EC_E_NOERROR)
{
dwRetVal = dwRes;
goto Exit;
}
See also
6.3.9. emConfigExtend
Warning
Before using this function, please check if the following patents have to be taken into consideration for your application and use case: JP5212509:ADDRESS SETTING METHOD IN NETWORK SYSTEM
-
EC_T_DWORD emConfigExtend(EC_T_DWORD dwInstanceID, EC_T_BOOL bResetConfig, EC_T_DWORD dwTimeout)
Extends the existing network configuration.
This function extends the existing configuration described in the ENI to allow mailbox communication with unexpected slaves. After this function was called, unexpected slaves can reach PREOP state. After the configuration was extended, disconnecting any slave will generate a bus mismatch, because all the slaves are part of the configuration. Recalling this function with bResetConfig set to EC_FALSE will extend the configuration again by any new connected unexpected slaves. The previous extension is not deleted. Calling the function with bResetConfig set to EC_TRUE will reset all the previous extensions.
Note
This function may not be called from within the JobTask’s context.
- Parameters
dwInstanceID – [in] Instance ID (Multiple EtherCAT Network Support)
bResetConfig – [in] EC_TRUE: Extended configuration will be removed
dwTimeout – [in] Timeout [ms]
- Returns
EC_E_NOERROR or error code
emConfigExtend() Example
dwRes = emConfigExtend(dwInstanceId, EC_TRUE, 5000 /* timeout */);
6.3.10. emRegisterClient
-
static EC_T_DWORD ecatRegisterClient(EC_PF_NOTIFY pfnNotify, EC_T_VOID *pCallerData, EC_T_REGISTERRESULTS *pRegResults)
-
EC_T_DWORD emRegisterClient(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 EtherCAT stack 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)
- Param dwCode
[in] Notification code, see EC_NOTIFY_…
- Param pParms
[in] Notification code depending data
emRegisterClient() Example
EC_T_REGISTERRESULTS oRegResults;
OsMemset(&oRegResults, 0, sizeof(EC_T_REGISTERRESULTS));
dwRes = emRegisterClient(dwInstanceId, myAppNotify, pvMyAppContext, &oRegResults);
6.3.11. emUnregisterClient
-
EC_T_DWORD emUnregisterClient(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. emGetSrcMacAddress
-
EC_T_DWORD emGetSrcMacAddress(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
See also
emGetSrcMacAddress() Example
/* get MAC address of EtherCAT network adapter */
ETHERNET_ADDRESS oMacSrc;
OsMemset(&oMacSrc, 0, sizeof(ETHERNET_ADDRESS));
dwRes = emGetSrcMacAddress(dwInstanceId, &oMacSrc);
6.3.13. emSetMasterState
-
static EC_T_DWORD ecatSetMasterState(EC_T_DWORD dwTimeout, EC_T_STATE eReqState)
-
EC_T_DWORD emSetMasterState(EC_T_DWORD dwInstanceID, EC_T_DWORD dwTimeout, EC_T_STATE eReqState)
Set the master (and all slaves) into the requested EtherCAT state.
If the function is called with EC_NOWAIT, the client may wait for reaching the requested state using the notification callback (EC_NOTIFY_STATECHANGED).
By default the Master will just change to a higher state if all slaves have reached the requested state. It may happen that some slaves are in higher state at network than the Master, e.g.:
Master and all slaves are in PREOP
Application requests SAFEOP
Master starts transition for all slaves
Some slaves changed to SAFEOP, but some fail and therefore stay in PREOP
Master state stays in PREOP, function returns with error
The application can request SAFEOP again to re-request the state of previously failed slaves. Transition to a lower state: The master changes to a lower state even if one slave is not able to follow. This function may not be called from within the JobTask’s context with dwTimeout other than EC_NOWAIT.
- Parameters
dwInstanceID – [in] Instance ID (Multiple EtherCAT Network Support)
dwTimeout – [in] Timeout [ms]. This function will block until the requested state is reached or the timeout elapsed. If the timeout value is set to EC_NOWAIT the function will return immediately.
eReqState – [in] Requested System state
- Returns
EC_E_NOERROR if successful
EC_E_INVALIDSTATE if EtherCAT stack isn’t initialized
EC_E_INVALIDPARM if dwInstanceID is out of range
EC_E_TIMEOUT if dwTimeout elapsed during the API call
EC_E_MASTER_RED_STATE_INACTIVE if Master Redundancy is configured and master is inactive
EC_E_ADS_IS_RUNNING if the ADS server is running
emSetMasterState() Example
/* set EtherCAT master (and all slaves) into requested state */
dwRes = emSetMasterState(dwInstanceId, 5000, eEcatState_PREOP);
6.3.14. emSetMasterStateReq
-
static EC_T_DWORD ecatSetMasterStateReq(EC_T_DWORD dwTimeout, EC_T_STATE eReqState)
-
EC_T_DWORD emSetMasterStateReq(EC_T_DWORD dwInstanceID, EC_T_DWORD dwTimeout, EC_T_STATE eReqState)
Request to set the master (and all slaves) into the requested EtherCAT state and return immediately.
The Master by default will just change to a higher state, if all slaves have reached the requested state. It may happen that some slaves are in higher state at network than Master, e.g.:
Master and all slaves are in PREOP
Application requests SAFEOP
Master starts transition for all slaves
Some slaves changed to SAFEOP, but some fail and therefore stay in PREOP
Master state stays in PREOP, function returns with error
The application can request SAFEOP again to re-request state of previously failed slaves. Transition to lower state: The master changes to lower state, even if one slave is not able to follow.
See also EC_NOTIFY_STATECHANGED.
- Parameters
dwInstanceID – [in] Instance ID (Multiple EtherCAT Network Support)
dwTimeout – [in] Timeout [ms]. This function will block until the requested state is reached or the timeout elapsed. If the timeout value is set to EC_NOWAIT the function will return immediately.
eReqState – [in] Requested System state
- Returns
EC_E_NOERROR if successful
EC_E_INVALIDSTATE if EtherCAT stack isn’t initialized
EC_E_INVALIDPARM if dwInstanceID is out of range
EC_E_MASTER_RED_STATE_INACTIVE if Master Redundancy is configured and master is inactive
EC_E_ADS_IS_RUNNING if ADS server is running
emSetMasterStateReq() Example
/* set EtherCAT master (and all slaves) into requested state */
dwRes = emSetMasterStateReq(dwInstanceId, 5000, eEcatState_PREOP);
See also
6.3.15. emGetMasterState
-
static EC_T_STATE ecatGetMasterState(EC_T_VOID)
-
EC_T_STATE emGetMasterState(EC_T_DWORD dwInstanceID)
Get the EtherCAT master current state.
- Parameters
dwInstanceID – [in] Instance ID (Multiple EtherCAT Network Support)
- Returns
EtherCAT master state
emGetMasterState() Example
EC_T_STATE eMasterState = emGetMasterState(dwInstanceId);
EcLogMsg(EC_LOG_LEVEL_INFO, (pEcLogContext, EC_LOG_LEVEL_INFO,
"Current Master State: %s:\n", ecatStateToStr(eMasterState)));
6.3.16. emGetMasterStateEx
-
EC_T_DWORD emGetMasterStateEx(EC_T_DWORD dwInstanceID, EC_T_WORD *pwCurrState, EC_T_WORD *pwReqState)
Get the EtherCAT master current and requested state. Possible return values for current and requested state:
- Parameters
dwInstanceID – [in] Instance ID (Multiple EtherCAT Network Support)
pwCurrState – [out] Current master state
pwReqState – [out] Requested master state
- Returns
EC_E_NOERROR if successful
EC_E_INVALIDSTATE if EtherCAT stack isn’t initialized
EC_E_INVALIDPARM if dwInstanceID is out of range or the output pointers are EC_NULL
emGetMasterStateEx() Example
EC_T_WORD wCurrState = 0;
EC_T_WORD wReqState = 0;
/* get EtherCAT master current state */
dwRes = emGetMasterStateEx(dwInstanceId, &wCurrState, &wReqState);
EcLogMsg(EC_LOG_LEVEL_INFO, (pEcLogContext, EC_LOG_LEVEL_INFO,
"Current state: %s, requested state: %s\n",
ecatDeviceStateText(wCurrState), ecatDeviceStateText(wReqState)));
6.3.17. emExecJob
-
static EC_T_DWORD ecatExecJob(EC_T_USER_JOB eUserJob, EC_T_USER_JOB_PARMS *pUserJobParms)
-
EC_T_DWORD emExecJob(EC_T_DWORD dwInstanceID, EC_T_USER_JOB eUserJob, EC_T_USER_JOB_PARMS *pUserJobParms)
Execute or initiate the requested 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 EtherCAT stack 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 the 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_ProcessAllRxFramesWhen the Real-time Ethernet Driver operates in polling mode this call will process all currently received frames, when the Real-time Ethernet Driver operates in interrupt mode all received frames are processed immediately and this call just returns with nothing done.
pUserJobParms->bAllCycFramesProcessed
If this flag is set to a value of
EC_TRUEit indicates that all previously initiated cyclic frames (eUsrJob_SendAllCycFrames) are received and processed within this call. Not used if pUserJobParms is set toEC_NULL.Return:
EC_E_NOERRORif successful, error code in case of failures.
eUsrJob_SendAllCycFramesSend all cyclic frames. New values will be written to the EtherCAT® SubDevice’s outputs and new input values will be received. If the Real-time Ethernet Driver operates in interrupt mode, the process data input values will be updated immediately after receiving the frames. If the Real-time Ethernet Driver operates in polling mode, the next call to
emExecJob()with theeUsrJob_ProcessAllRxFramesjob will check for received frames and update the process data input values.pUserJobParms->dwNumFramesSent
Indicates number of frames sent within this call. Not used if pUserJobParms is set to
EC_NULL.Return:
EC_E_NOERRORif successful, error code in case of failures.In case not all previously initiated cyclic frames are processed when calling this function an error notification will be generated ( emNotify - EC_NOTIFY_FRAME_RESPONSE_ERROR).
eUsrJob_SendAcycFramesAcyclic EtherCAT® datagrams stored in the acyclic frame buffer FIFO will be sent when executing this call.
pUserJobParms->dwNumFramesSent
Indicates number of frames sent within this call. Not used if pUserJobParms is set to
EC_NULL.Return:
EC_E_NOERRORif successful, error code in case of failures.
eUsrJob_MasterTimerTo trigger the MainDevice and SubDevice state machines as well as the mailbox handling this call has to be executed cyclically. The MainDevice 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_NOERRORif successful, error code in case of failures.
eUsrJob_SendCycFramesByTaskIdSend cyclic frames related to a specific task id. If more than one cyclic entries are configured this user job can be used to send the appropriate cyclic frames. All frames stored in cyclic entries with the given task id will be sent.
pUserJobParms->SendCycFramesByTaskId.dwTaskId
Task id.
Return:
EC_E_NOERRORif successful, error code in case of failures. If not all previously initiated cyclic frames for the same task are already processed when calling this function an error will be generated ( emNotify - EC_NOTIFY_FRAME_RESPONSE_ERROR).
eUsrJob_ProcessRxFramesByTaskId-
See also
Feature-Pack Split Frame Processing
eUsrJob_SwitchEoeFramesThis job must be called if emIoCtl - EC_IOCTL_SET_EOE_DEFFERED_SWITCHING_ENABLED has been called before. It can be called in parallel to Send / Process jobs in a lower prioritized task
pUserJobParms->SwitchEoeFrames.dwMaxPortsToProcess
Indicates number of ports to be processed within this call. If zero, all ports will be processed.
pUserJobParms->SwitchEoeFrames.dwNumFramesProcessed
Returns number of frames processed within this call.
Return:
EC_E_NOERRORif successful
eUsrJob_StartTaskInform EC-Master that the current task is started. Specify pUserJobParms.StartTask.dwTaskId or pass pUserJobParms set to EC_NULL for task ID 0.
eUsrJob_StopTaskInform EC-Master that the current task is stopped. Specify pUserJobParms.StopTask.dwTaskId or pass pUserJobParms set to EC_NULL for task ID 0.
emExecJob() Example
EC_T_USER_JOB oUserJob;
OsMemset(&oUserJob, 0, sizeof(EC_T_USER_JOB));
oUserJob = eUsrJob_StartTask;
EC_T_USER_JOB_PARMS oUserJobParms;
OsMemset(&oUserJobParms, 0, sizeof(EC_T_USER_JOB));
dwRes = emExecJob(dwInstanceId, oUserJob, &oUserJobParms);
6.3.18. emGetVersion
-
EC_T_DWORD emGetVersion(EC_T_DWORD dwInstanceID, EC_T_DWORD *pdwVersion, EC_T_DWORD *pdwVersionType)
Gets the version information.
- Parameters
dwInstanceID – [in] Instance ID (Multiple EtherCAT Network Support)
pdwVersion – [out] Pointer to EC_T_DWORD to carry out version number as a 32-bit value
pdwVersionType – [out] Pointer to EC_T_DWORD to carry out version type. See EC_VERSION_TYPE.
- Returns
EC_E_NOERROR if successful
EC_E_INVALIDSTATE if EtherCAT stack isn’t initialized
EC_E_INVALIDPARM if dwInstanceID is out of range or the output pointer is EC_NULL
EC Version Type
emGetVersion() Example
/* get stack version */
EC_T_DWORD dwVersion = EC_E_ERROR;
EC_T_DWORD dwVersionType = 0;
dwRes = emGetVersion(dwInstanceId, &dwVersion, &dwVersionType);
6.3.19. emSetLicenseKey
-
EC_T_DWORD emSetLicenseKey(EC_T_DWORD dwInstanceID, const EC_T_CHAR *szLicenseKey)
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)
szLicenseKey – [in] License key as zero terminated string with 26, 53 or 56 characters
- Returns
EC_E_NOERROR if successful
EC_E_INVALIDSTATE if EtherCAT stack isn’t initialized
EC_E_INVALIDPARM if dwInstanceID is out of range
EC_E_INVALIDSIZE if the format of the license key is wrong. The correct length is 26, 53 or 56 characters.
EC_E_LICENSE_MISSING if the license key doesn’t match the MAC Address
emSetLicenseKey() Example
dwRes = emSetLicenseKey(dwInstanceId, "DA1099F2-15C249E9-54327FBC");
See also
6.3.20. emSetOemKey
-
static EC_T_DWORD emSetOemKey(EC_T_DWORD dwInstanceID, EC_T_UINT64 qwOemKey)
Provide OEM Key needed for OEM Masters to parse ENI files and provide access via RAS. Must be called after initialization and before configuration.
- Parameters
dwInstanceID – [in] Instance ID (Multiple EtherCAT Network Support)
qwOemKey – [in] 64 bit OEM key
emSetOemKey() Example
dwRes = emSetOemKey(dwInstanceId, 0x1234567812345678);
See also
6.3.21. emIoCtl
-
static EC_T_DWORD ecatIoCtl(EC_T_DWORD dwCode, const EC_T_VOID *const pbyInBuf, EC_T_DWORD dwInBufSize, EC_T_VOID *const pbyOutBuf, EC_T_DWORD dwOutBufSize, EC_T_DWORD *const pdwNumOutData)
-
EC_T_DWORD emIoCtl(EC_T_DWORD dwInstanceID, EC_T_DWORD dwCode, const EC_T_VOID *const pbyInBuf, EC_T_DWORD dwInBufSize, EC_T_VOID *const pbyOutBuf, EC_T_DWORD dwOutBufSize, EC_T_DWORD *const pdwNumOutData)
A generic control interface between the application, the EtherCAT stack and its Link Layers.
- Parameters
dwInstanceID – [in] Instance ID (Multiple EtherCAT Network Support)
dwCode – [in] IOCTL code (EC_IOCTL…)
pbyInBuf – [in] IOCTL input parameters
dwInBufSize – [in] Size of IOCTL input parameters in bytes
pbyOutBuf – [out] Buffer for IOCTL output
dwOutBufSize – [in] Size of buffer at pbyOutBuf in bytes
pdwNumOutData – [out] Amount of bytes written to pbyOutBuf by IOCTL. EC_NULL: amount not set by IOCTL.
- Returns
EC_E_NOERROR if successful
EC_E_INVALIDSTATE if EtherCAT stack isn’t initialized
EC_E_INVALIDPARM if dwInstanceID is out of range, the input pointer is EC_NULL or contains EC_NULL pointer
EC_E_NOMEMORY if memory cannot be allocated
EC_E_ADS_IS_RUNNING if the ADS server is running
6.3.22. emIoCtl - EC_IOCTL_GET_PDMEMORYSIZE
-
EC_IOCTL_GET_PDMEMORYSIZE
Get the process data image size. This information may be used to provide process data image storage from outside the core. This IOCTL is to be called after network configuration.
- Parameters
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 (type: EC_T_MEMREQ_DESC)
dwOutBufSize – [in] Size of the output buffer in bytes
pdwNumOutData – [out] Pointer to EC_T_DWORD. Amount of bytes written to the output buffer.
- Returns
EC_E_NOERROR or error code
See also
6.3.23. emIoCtl - EC_IOCTL_REGISTER_PDMEMORYPROVIDER
-
EC_IOCTL_REGISTER_PDMEMORYPROVIDER
This function call registers an external memory provider to the stack, this memory will be used to store process data. If no memory provider is registered the stack will internally allocate the necessary amount of memory. The function EC_IOCTL_GET_PDMEMORYSIZE should be executed to determine the amount of memory the stack needs to store process data values. An external memory provider may additionally supply some hooks to give the stack a possibility to synchronize memory access with the application. Also the memory provider has to be registered after configuring the network but prior to registering any client. Every client that registers with the stack will get back the memory pointers to PDOut/PDIn data registered within this call.
- Parameters
pbyInBuf – [in] Memory provider (EC_T_MEMPROV_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
- Returns
EC_E_NOERROR or error code
-
struct EC_T_MEMPROV_DESC
Public Members
-
EC_T_PVOID pvContext
Context pointer. This pointer is used every time one of the callback functions (e.g. pfPDOutReadRequest) is called.
-
EC_T_PBYTE pbyPDOutData
Pointer to the fixed output process data buffer (values transferred from the master to the slaves). A value of EC_NULL may be given in case the pointer will be provided later when the function EC_T_MEMPROV_DESC.pfPDOutDataReadRequest is called.
-
EC_T_PBYTE pbyPDInData
Pointer to the fixed input process data buffer (values transferred from the slaves to the master). A value of EC_NULL may be given in case the pointer will be provided later when the function EC_T_MEMPROV_DESC.pfPDInDataWriteRequest is called.
-
EC_T_PFMEMREQ pfPDOutDataReadRequest
This function will be called cyclically within the process data transfer cycle prior to reading data from the output process data buffer. If EC_NULL is set, the fixed buffer EC_T_MEMPROV_DESC.pbyPDOutData is used.
-
EC_T_PFMEMREL pfPDOutDataReadRelease
This function will be called cyclically within the process data transfer cycle after all data were read from the output process data buffer
-
EC_T_PFMEMREQ pfPDOutDataWriteRequest
This function will be called cyclically within the process data transfer cycle prior to writing new data into the output process data buffer. If EC_NULL is set, the fixed buffer EC_T_MEMPROV_DESC.pbyPDOutData is used.
-
EC_T_PFMEMREL pfPDOutDataWriteRelease
This function will be called cyclically within the process data transfer cycle after all data were written into the output process data buffer
-
EC_T_PFMEMREQ pfPDInDataWriteRequest
This function will be called cyclically within the process data transfer cycle prior to writing new data into the input process data buffer. If EC_NULL is set, the fixed buffer EC_T_MEMPROV_DESC.pbyPDInData is used.
-
EC_T_PFMEMREL pfPDInDataWriteRelease
This function will be called cyclically within the process data transfer cycle after all data were written into the input process data buffer
-
EC_T_PBYTE pbyMasterRedPDOutData
Pointer to the MasterRed output process data buffer (ACTIVE to INACTIVE)
-
EC_T_PBYTE pbyMasterRedPDInData
Pointer to the default input process data buffer (INACTIVE to ACTIVE)
-
EC_T_PFMEMREQ pfMasterRedPDOutReadRequest
This function will be called within the process data transfer cycle prior to reading data
-
EC_T_PFMEMREL pfMasterRedPDOutReadRelease
This function will be called after all data has been read from the output process data buffer
-
EC_T_PFMEMREQ pfMasterRedPDOutWriteRequest
This function will be called within the process data transfer cycle prior to reading data
-
EC_T_PFMEMREL pfMasterRedPDOutWriteRelease
This function will be called after all data were read from the output process data buffer
-
EC_T_PFMEMREQ pfMasterRedPDInWriteRequest
This function will be called within the process data transfer cycle prior to writing data
-
EC_T_PFMEMREL pfMasterRedPDInWriteRelease
This function will be called after all data were written to the input process data buffer
-
EC_T_PFMEMREQ pfMasterRedPDInReadRequest
This function will be called within the process data transfer cycle prior to writing data
-
EC_T_PFMEMREL pfMasterRedPDInReadRelease
This function will be called after all data were written to the input process data buffer
-
EC_T_PVOID pvContext
-
typedef EC_T_VOID (*EC_T_PFMEMREQ)(EC_T_PVOID pvContext, EC_T_DWORD dwTaskId, EC_T_PBYTE *ppbyPDData)
- Param pvContext
[in] Arbitrarily application-defined parameter passed to callback
- Param dwTaskId
[in] Task ID of cyclic data transfer (ENI: Cyclic/TaskId). If TASKID_COMPLETE_PD is given, the function must return a complete output process data buffer which contains valid data for all cyclic tasks.
- Param ppbyPDData
[out] Pointer to the process data buffer to be used. If set to EC_NULL, the corresponding fixed buffer from EC_T_MEMPROV_DESC is used. The provided buffer size must correspond to the caller context.
-
typedef EC_T_VOID (*EC_T_PFMEMREL)(EC_T_PVOID pvContext, EC_T_DWORD dwTaskId)
- Param pvContext
[in] Arbitrarily application-defined parameter passed to callback
- Param dwTaskId
[in] Task ID of cyclic data transfer (ENI: Cyclic/TaskId)
See also
Feature Pack “MainDevice Redundancy”
6.3.24. emIoCtl - EC_IOCTL_REGISTER_CYCFRAME_RX_CB
-
EC_IOCTL_REGISTER_CYCFRAME_RX_CB
Register callback for all cyclic frames received. Typically this is used when the Real-time Ethernet Driver operates in interrupt mode to get an event when the new input data (cyclic frame) is available. The callback function has to be registered after the stack initialization and before starting the job task.
- Parameters
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
- Returns
EC_E_NOERROR or error code
-
struct EC_T_CYCFRAME_RX_CBDESC
Public Members
-
EC_T_VOID *pCallbackContext
[in] Context pointer. This pointer is used as parameter every time 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
-
typedef EC_T_VOID (*EC_PF_CYCFRAME_RECV)(EC_T_DWORD dwTaskId, EC_T_VOID *pvContext)
- Param dwTaskId
[in] Task id of the received cyclic frame
- Param pvContext
[in] Context pointer. This pointer is used as parameter every time when the callback function is called.
See also
6.3.25. emIoCtl - EC_IOCTL_ISLINK_CONNECTED
-
EC_IOCTL_ISLINK_CONNECTED
Determine whether the main link or redundancy link is connected.
Note
See also EC_IOCTL_IS_MAIN_LINK_CONNECTED, EC_IOCTL_IS_RED_LINK_CONNECTED
- Parameters
pbyInBuf – [in] Should be set to EC_NULL
dwInBufSize – [in] Should be set to 0
pbyOutBuf – [out] Pointer to EC_T_DWORD or EC_T_LINK_CONNECTED_INFO. EC_T_DWORD: If value is EC_TRUE link is connected, if EC_FALSE it is not.
dwOutBufSize – [in] Size of the output buffer in bytes (sizeof(EC_T_DWORD) / sizeof(EC_T_LINK_CONNECTED_INFO))
pdwNumOutData – [out] Pointer to EC_T_DWORD. Amount of bytes written to the output buffer.
- Returns
EC_E_NOERROR or error code
With Redundancy support enabled, EC_FALSE is only set if main and redundancy link are down.
See also
6.3.26. emIoCtl - EC_IOCTL_GET_LINKLAYER_MODE
-
EC_IOCTL_GET_LINKLAYER_MODE
Get Real-time Ethernet Driver mode (EcLinkMode_POLLING, EcLinkMode_INTERRUPT)
- Parameters
pbyInBuf – [in] Should be set to EC_NULL
dwInBufSize – [in] Should be set to 0
pbyOutBuf – [out] Pointer to struct EC_T_LINKLAYER_MODE_DESC
dwOutBufSize – [in] Size of the output buffer in bytes
pdwNumOutData – [out] Pointer to EC_T_DWORD. Amount of bytes written to the output buffer.
- Returns
EC_E_NOERROR or error code
-
struct EC_T_LINKLAYER_MODE_DESC
Public Members
-
EC_T_LINKMODE eLinkMode
[out] Operation mode of main interface
-
EC_T_LINKMODE eLinkModeRed
[out] Operation mode of redundancy interface
-
EC_T_LINKMODE eLinkMode
See also
6.3.27. emIoCtl - EC_IOCTL_GET_CYCLIC_CONFIG_INFO
-
EC_IOCTL_GET_CYCLIC_CONFIG_INFO
Get cyclic configuration information from ENI file.
- Parameters
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.
- Returns
EC_E_NOERROR or error code
See also
6.3.28. emIoCtl - EC_IOCTL_IS_SLAVETOSLAVE_COMM_CONFIGURED
-
EC_IOCTL_IS_SLAVETOSLAVE_COMM_CONFIGURED
Determine if any slave to slave communication is configured.
- Parameters
pbyInBuf – [in] Should be set to EC_NULL
dwInBufSize – [in] Should be set to 0
pbyOutBuf – [out] Pointer to EC_T_DWORD. If value is EC_TRUE slave to slave communication is configured, if EC_FALSE it is not.
dwOutBufSize – [in] Size of the output buffer in bytes
pdwNumOutData – [out] Pointer to EC_T_DWORD. Amount of bytes written to the output buffer.
- Returns
EC_E_NOERROR or error code
See also
6.3.29. emIoCtl - EC_LINKIOCTL…
The generic control interface provides access to the main network adapter when adding EC_IOCTL_LINKLAYER_MAIN to the EC_LINKIOCTL parameter at dwCode.
EC_T_DWORD dwCode = (EC_IOCTL_LINKLAYER_MAIN | EC_LINKIOCTL_GET_ETHERNET_ADDRESS);
See also
6.3.30. emIoCtl - EC_LINKIOCTL_GET_ETHERNET_ADDRESS
Provides MAC addresses of main or red line.
- emIoCtl - 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 in bytes (at least 6)pdwNumOutData: [out] Pointer to EC_T_DWORD. Amount of bytes written to the output buffer.
- Return
EC_E_NOERROR or error code
See also
6.3.31. emIoCtl - EC_LINKIOCTL_GET_SPEED
- emIoCtl - 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 Real-time Ethernet Driver to 10/100/1000.dwOutBufSize: [in] Size of the output buffer in bytespdwNumOutData: [out] Pointer to EC_T_DWORD. Amount of bytes written to the output buffer.
- Return
EC_E_NOERROR or error code
See also
6.3.32. emIoCtl - EC_LINKIOCTL_GET_PCI_INFO
Get current network adapter’s PCI information
- emIoCtl - EC_LINKIOCTL_GET_PCI_INFO
- Parameter
pbyInBuf: [in] Should be set to EC_NULLdwInBufSize: [in] Should be set to 0pbyOutBuf: [out] Pointer to EC_T_PCI_INFO bufferdwOutBufSize: [in] Size of the output buffer in bytes. Must be at least the size of EC_T_PCI_INFO.pdwNumOutData: [out] Pointer to EC_T_DWORD. Amount of bytes written to the output buffer.
- Return
EC_E_NOERROR or error code
-
struct EC_T_PCI_INFO
Public Members
-
EC_T_PCI_INFO_LOCATION Location
PCI location (bus, device, function)
-
EC_T_PCI_INFO_IDENIFICATION Ident
PCI identification (vendor id, device id)
-
EC_T_PCI_INFO_IOBAR aIoBar
PCI I/O bars info
-
EC_T_PCI_INFO_MEMBAR aMemBar
PCI Memory bars info
-
EC_T_PCI_INFO_INTERRUPT aInterrupt
PCI IRQ info
-
EC_T_PCI_INFO_LOCATION Location
See also
6.3.33. emIoCtl - EC_IOCTL_SET_CYCFRAME_LAYOUT
-
EC_IOCTL_SET_CYCFRAME_LAYOUT
Set the cyclic frames layout.
- Parameters
pbyInBuf – [in] Pointer to an EC_T_CYCFRAME_LAYOUT value containing the cyclic frame layout
dwInBufSize – [in] Size of the input buffer provided at pbyInBuf in bytes
pbyOutBuf – [out] Pointer to EC_T_BOOL to carry out current enable set
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.
- Returns
EC_E_NOERROR or error code
-
enum EC_T_CYCFRAME_LAYOUT
Values:
-
enumerator eCycFrameLayout_STANDARD
Layout according ENI with command add/reordering, no relationship to PD
-
enumerator eCycFrameLayout_STANDARD
See also
6.3.34. emIoCtl - EC_IOCTL_SET_MASTER_DEFAULT_TIMEOUTS
-
EC_IOCTL_SET_MASTER_DEFAULT_TIMEOUTS
Set master default timeouts.
- Parameters
pbyInBuf – [in] Pointer to EC_T_MASTERDEFAULTTIMEOUTS_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
- Returns
EC_E_NOERROR or error code
-
struct EC_T_MASTERDEFAULTTIMEOUTS_DESC
Public Members
-
EC_T_DWORD dwMasterStateChange
Default state change timeout [ms], applied if emSetMasterState called with EC_NOWAIT
-
EC_T_DWORD dwDcmInSync
Timeout [ms] to wait for DCM InSync in state change PREOP to SAFEOP ( default: infinite )
-
EC_T_DWORD dwSlaveIdentification
Timeout [ms] to wait for the reading of the slave identification ( default: 5000 )
-
EC_T_DWORD dwMasterStateChange
Setting a value of this descriptor to zero resets the default timeout value to the initial value.
See also
6.3.35. emIoCtl - EC_IOCTL_SET_COPYINFO_IN_SENDCYCFRAMES
-
EC_IOCTL_SET_COPYINFO_IN_SENDCYCFRAMES
Set copy info processed in either eUsrJob_SendAllCycFrames or in eUsrJob_ProcessAllRxFrames.
- Parameters
pbyInBuf – [in] Pointer to EC_T_BOOL. EC_TRUE: SendCycFrames, EC_FALSE: ProcessAllRxFrames.
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
- Returns
EC_E_NOERROR or error code
Default: Set by ProcessAllRxFrames.
See also
6.3.36. emIoCtl - EC_IOCTL_SET_BUS_CYCLE_TIME
-
EC_IOCTL_SET_BUS_CYCLE_TIME
Set bus cycle time [us] master parameter without calling emInitMaster() again.
- Parameters
pbyInBuf – [in] Pointer to value of EC_T_DWORD. Value may not be 0!
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
- Returns
EC_E_NOERROR or error code
Implicitly recalculates Order Timeout and EC_T_INIT_MASTER_PARMS::dwEcatCmdTimeout.
See also
6.3.37. emIoCtl - EC_IOCTL_ADDITIONAL_VARIABLES_FOR_SPECIFIC_DATA_TYPES
-
EC_IOCTL_ADDITIONAL_VARIABLES_FOR_SPECIFIC_DATA_TYPES
Enable or disable additional variables for specific data types. Default: Enabled.
- Parameters
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
- Returns
EC_E_NOERROR or error code
Additional variables are added to the process image for the following data types:
FSOE_4096
FSOE_4098
FSOE_4099
FB Info 1
FB Info 3
See also
6.3.38. emIoCtl - EC_IOCTL_SLV_ALIAS_ENABLE
-
EC_IOCTL_SLV_ALIAS_ENABLE
Enables slave alias addressing for all slaves.
- Parameters
pbyInBuf – [in] Should be set to EC_NULL
dwInBufSize – [in] Should be set to 0
pbyOutBuf – [out] Should be set to EC_NULL
dwOutBufSize – [in] Should be set to 0
pdwNumOutData – [out] Should be set to EC_NULL
- Returns
EC_E_NOERROR or error code
Important
All SubDevice need to have the correct alias address set! If in doubt, don’t use this IOCTL.
See also
6.3.39. emIoCtl - EC_IOCTL_SET_IGNORE_INPUTS_ON_WKC_ERROR
-
EC_IOCTL_SET_IGNORE_INPUTS_ON_WKC_ERROR
Set ignore INPUTs on WKC error.
- Parameters
pbyInBuf – [in] Pointer to value of EC_T_BOOL. EC_TRUE: Ignore INPUTs on WKC error.
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
- Returns
EC_E_NOERROR or error code
Calling this IOCTL with EC_TRUE as parameter will ignore input data of cyclic commands on WKC error.
By default input data are updated if WKC is non zero. If WKC is not matching the expected value a notification emNotify - EC_NOTIFY_CYCCMD_WKC_ERROR is generated and the application must consider this status for the current cycle.
See also
6.3.40. emIoCtl - EC_IOCTL_SET_ZERO_INPUTS_ON_WKC_ERROR
-
EC_IOCTL_SET_ZERO_INPUTS_ON_WKC_ERROR
Set INPUTs to zero on WKC error.
- Parameters
pbyInBuf – [in] Pointer to value of EC_T_BOOL. EC_TRUE: INPUTs are set to zero on WKC error.
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
- Returns
EC_E_NOERROR or error code
Calling this IOCTL with EC_TRUE as parameter will set inputs to zero on WKC error.
By default input data are updated if WKC is non zero. If WKC is not matching the expected value a notification emNotify - EC_NOTIFY_CYCCMD_WKC_ERROR is generated and the application must consider this status for the current cycle.
See also
6.3.41. emIoCtl - EC_IOCTL_SET_ZERO_INPUTS_ON_WKC_ZERO
-
EC_IOCTL_SET_ZERO_INPUTS_ON_WKC_ZERO
Set INPUTs to zero on WKC is zero.
- Parameters
pbyInBuf – [in] Pointer to value of EC_T_BOOL. EC_TRUE: Set INPUTs to zero if WKC is zero.
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
- Returns
EC_E_NOERROR or error code
Calling this IOCTL with EC_TRUE as parameter will set inputs to zero on WKC is zero.
By default input data are ignored on WKC is zero and remain unchanged. If WKC is not matching the expected value a notification emNotify - EC_NOTIFY_CYCCMD_WKC_ERROR is generated and the application must consider this status for the current cycle.
6.3.42. emIoCtl - EC_IOCTL_SET_ZERO_INPUTS_ON_FRAME_LOSS
-
EC_IOCTL_SET_ZERO_INPUTS_ON_FRAME_LOSS
Set inputs to zero on frame loss.
- Parameters
pbyInBuf – [in] Pointer to value of EC_T_BOOL. EC_TRUE: Set inputs to zero on frame loss
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
- Returns
EC_E_NOERROR or error code
Calling this IOCTL with EC_TRUE as parameter will set inputs to zero on frame loss.
By default input data are ignored on frame loss and remain unchanged.
See also
6.3.43. emIoCtl - EC_IOCTL_SET_GENENI_ASSIGN_EEPROM_BACK_TO_ECAT
-
EC_IOCTL_SET_GENENI_ASSIGN_EEPROM_BACK_TO_ECAT
Enable or disable creation of “assign EEPROM back to ECAT” InitCmd if ENI generated based on bus-scan result.
- Parameters
pbyInBuf – [in] Pointer to value of EC_T_BOOL. EC_TRUE: generate InitCmd.
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
- Returns
EC_E_NOERROR or error code
The InitCmd “assign EEPROM back to ECAT” in the ENI depends on the attribute “AssignToPdi” of the EEPROM tag in the SubDevice’s description within the ESI file. Because this attribute is not reflected in the SII in the SubDevice’s EEPROM, the MainDevice cannot know its value and inserts the InitCmd by default for legacy reasons.
See also
6.3.44. emIoCtl - EC_IOCTL_SET_EOE_DEFFERED_SWITCHING_ENABLED
-
EC_IOCTL_SET_EOE_DEFFERED_SWITCHING_ENABLED
Enable or disable deferred EoE switching.
- Parameters
pbyInBuf – [in] Pointer to value of EC_T_BOOL. EC_TRUE: Deferred EoE switching enabled.
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
- Returns
EC_E_NOERROR or error code
Enabling deferred EoE switching reduces the CPU load of JOB_ProcessAllRxFrames in case of EoE communication. eUsrJob_SwitchEoeFrames has to be called explicitly to switch the received EoE frames between the EoE SubDevices and EoE end point(s).
See also
6.3.45. emIoCtl - EC_IOCTL_SET_MAILBOX_POLLING_CYCLES
-
EC_IOCTL_SET_MAILBOX_POLLING_CYCLES
Change the mailbox polling interval.
- Parameters
pbyInBuf – [in] Pointer to struct EC_T_SET_MAILBOX_POLLING_CYCLES_DESC
dwInBufSize – [in] Size of the input buffer in bytes, e.g. sizeof(EC_T_SET_MAILBOX_POLLING_CYCLES_DESC)
pbyOutBuf – [out] Should be set to EC_NULL
dwOutBufSize – [in] Should be set to 0
pdwNumOutData – [out] Should be set to EC_NULL
- Returns
EC_E_NOERROR or error code
See also
6.3.46. emIoCtl - EC_IOCTL_SET_MASTER_MAX_STATE
-
EC_IOCTL_SET_MASTER_MAX_STATE
Set maximal master state. emSetMasterState() returns with EC_E_INVALIDSTATE if the requested master state exceeds the maximal master state.
- Parameters
pbyInBuf – [in] Pointer to value of EC_T_STATE
dwInBufSize – [in] Size of the input buffer in bytes, e.g. sizeof(EC_T_STATE)
pbyOutBuf – [out] Should be set to EC_NULL
dwOutBufSize – [in] Should be set to 0
pdwNumOutData – [out] Should be set to EC_NULL
- Returns
EC_E_NOERROR or error code
See also
-
enum EC_T_STATE
-
enum EC_T_STATE
6.3.47. emIoCtl - EC_IOCTL_SET_AUTO_ADJUST_MBX_STATE_COUNT_ENABLED
-
EC_IOCTL_SET_AUTO_ADJUST_MBX_STATE_COUNT_ENABLED
This call specifies if the mailbox states count must be automatically adjusted according the mailbox state addresses in the ENI. This is needed if the ENI is inconsistent regarding the mailbox states, leading to Error 0x98130033 ENI: Inconsistent content. Default: Use ENI specified mailbox state count (EC_FALSE).
- Parameters
pbyInBuf – [in] Pointer to EC_T_BOOL
dwInBufSize – [in] Size of the input buffer in bytes, e.g. sizeof(EC_T_BOOL)
pbyOutBuf – [out] Should be set to EC_NULL
dwOutBufSize – [in] Should be set to 0
pdwNumOutData – [out] Should be set to EC_NULL
- Returns
EC_E_NOERROR or error code
See also
6.3.48. emIoCtl - EC_IOCTL_ACTIVATE_VOE_RECV_FIFO
-
EC_IOCTL_ACTIVATE_VOE_RECV_FIFO
Activates and set the size of the VoE receive FIFO.
- Parameters
pbyInBuf – [in] Pointer to value of EC_T_WORD, size of the FIFO, use 0 to set it to the original size
dwInBufSize – [in] Size of the input buffer in bytes, e.g. sizeof(EC_T_WORD)
pbyOutBuf – [out] Should be set to EC_NULL
dwOutBufSize – [in] Should be set to 0
pdwNumOutData – [out] Should be set to EC_NULL
- Returns
EC_E_NOERROR or error code
See also
6.3.49. emIoCtl - EC_IOCTL_SET_GEN_ENI_PARM
Identifier |
Description |
EC_GEN_ENI_PARM_ID_SLAVE_PREFIX |
Prefix of SubDevices and their variables’ names. By default the prefix is ‘Slave’. |
-
EC_IOCTL_SET_GEN_ENI_PARM
Change the behavior when the configuration of the EtherCAT network is generated according to a bus scan result of emConfigureNetwork() with the parameter eCnfType_GenPreopENI or eCnfType_GenOpENI. In that case, default settings are taken to set e.g. the name of the EtherCAT slave device. The next table gives an overview about the possible parameters to be changed.
- Parameters
pbyInBuf – [in] Pointer to struct EC_T_SET_GEN_ENI_PARM
dwInBufSize – [in] Size of the input buffer in bytes, e.g. sizeof(EC_T_SET_GEN_ENI_PARM)
pbyOutBuf – [out] Should be set to EC_NULL
dwOutBufSize – [in] Should be set to 0
pdwNumOutData – [out] Should be set to EC_NULL
- Returns
EC_E_NOERROR or error code
-
struct EC_T_SET_GEN_ENI_PARM
Public Members
-
EC_T_GEN_ENI_PARM GenEniParm
Value of parameter to be set
-
EC_T_GEN_ENI_PARM GenEniParm
See also
6.3.50. emIoCtl - EC_IOCTL_REALLOC_MBX_QUEUE
-
EC_IOCTL_REALLOC_MBX_QUEUE
Reallocate the mailbox queues of the different mailbox protocols.
- Parameters
pbyInBuf – [in] Pointer to struct EC_T_REALLOC_MBX_QUEUE_DESC
dwInBufSize – [in] Size of the input buffer in bytes, e.g. sizeof(EC_T_REALLOC_MBX_QUEUE_DESC)
pbyOutBuf – [out] Should be set to EC_NULL
dwOutBufSize – [in] Should be set to 0
pdwNumOutData – [out] Should be set to EC_NULL
- Returns
EC_E_NOERROR or error code
See also