6.8. Error simulation functions
6.8.1. esSetErrorAtSlavePort
-
EC_T_DWORD esSetErrorAtSlavePort(EC_T_DWORD dwInstanceId, EC_T_WORD wCfgFixedAddress, EC_T_BYTE byPort, EC_T_BOOL bOutgoing)
Trigger physical layer error (“single shot”) destroying frames at slave port.
- Remark
See ESC registers RX Error Counter (0x0300:0x0307), Forwarded RX Error Counter (0x0308:0x030B), ECAT Processing Unit Error Counter (0x030C)
- Parameters
dwInstanceId – [in] Simulator Instance ID
wCfgFixedAddress – [in] Slave’s station address. 0: all slaves
byPort – [in] ESC port. 0, 1, 2, 3: port A, port B, port C, port D
bOutgoing – [in] Direction. EC_FALSE: Receive Frame, EC_TRUE: Send Frame
- Returns
EC_E_NOERROR or error code
6.8.2. esSetErrorGenerationAtSlavePort
-
EC_T_DWORD esSetErrorGenerationAtSlavePort(EC_T_DWORD dwInstanceId, EC_T_WORD wCfgFixedAddress, EC_T_BYTE byPort, EC_T_BOOL bOutgoing, EC_T_DWORD dwLikelihoodPpm, EC_T_DWORD dwFixedGoodFramesCnt, EC_T_DWORD dwFixedErroneousFramesCnt)
Generate physical layer errors destroying frames at slave port randomly or at fixed intervals.
- Remark
See ESC registers RX Error Counter (0x0300:0x0307), Forwarded RX Error Counter (0x0308:0x030B), ECAT Processing Unit Error Counter (0x030C)
- Parameters
dwInstanceId – [in] Simulator Instance ID
wCfgFixedAddress – [in] Slave’s station address. 0: all slaves
byPort – [in] ESC port. 0, 1, 2, 3: port A, port B, port C, port D
bOutgoing – [in] Direction. EC_FALSE: Receive Frame, EC_TRUE: Send Frame
dwLikelihoodPpm – [in] Random simulation: error likelihood (ppm)
dwFixedGoodFramesCnt – [in] after error was simulated: fixed amount of frames without errors (at least)
dwFixedErroneousFramesCnt – [in] on error simulation: fixed amount of frames with errors (at least)
- Returns
EC_E_NOERROR or error code
6.8.3. esResetErrorGenerationAtSlavePorts
-
EC_T_DWORD esResetErrorGenerationAtSlavePorts(EC_T_DWORD dwInstanceId, EC_T_WORD wCfgFixedAddress)
Reset physical layer error generation destroying frames at slave port.
- Parameters
dwInstanceId – [in] Simulator Instance ID
wCfgFixedAddress – [in] Slave’s station address. 0: all slaves
- Returns
EC_E_NOERROR or error code
6.8.4. esSetLinkDownAtSlavePort
-
EC_T_DWORD esSetLinkDownAtSlavePort(EC_T_DWORD dwInstanceId, EC_T_WORD wCfgFixedAddress, EC_T_BYTE byPort, EC_T_BOOL bDown, EC_T_DWORD dwLinkDownTimeMs)
Trigger link lost event.
- Parameters
dwInstanceId – [in] Simulator Instance ID
wCfgFixedAddress – [in] Slave’s station address. 0: all slaves
byPort – [in] ESC port. 0, 1, 2, 3: port A, port B, port C, port D
bDown – [in] Connect or disconnect cable. EC_TRUE: disconnect
dwLinkDownTimeMs – [in] Link down duration in ms
- Returns
EC_E_NOERROR or error code
6.8.5. esSetLinkDownGenerationAtSlavePort
-
EC_T_DWORD esSetLinkDownGenerationAtSlavePort(EC_T_DWORD dwInstanceId, EC_T_WORD wCfgFixedAddress, EC_T_BYTE byPort, EC_T_DWORD dwLikelihoodPpm, EC_T_DWORD dwFixedLinkDownTimeMs, EC_T_DWORD dwFixedLinkUpTimeMs)
Generate link lost events randomly or at fixed intervals.
- Parameters
dwInstanceId – [in] Simulator Instance ID
wCfgFixedAddress – [in] Slave’s station address. 0: all slaves
byPort – [in] ESC port. 0, 1, 2, 3: port A, port B, port C, port D
dwLikelihoodPpm – [in] Random simulation: link down likelihood (ppm) within OnTimer
dwFixedLinkDownTimeMs – [in] on link down simulation: fixed link down duration in ms (at least)
dwFixedLinkUpTimeMs – [in] after link down was simulated: fixed link up duration in ms (at least)
- Returns
EC_E_NOERROR or error code
6.8.6. esResetLinkDownGenerationAtSlavePorts
6.8.7. esLogFrameEnableAtSlavePort
-
EC_T_DWORD esLogFrameEnableAtSlavePort(EC_T_DWORD dwInstanceId, EC_T_WORD wCfgFixedAddress, EC_T_BYTE byPort, EC_T_PFLOGFRAME_CB pvLogFrameCallBack, EC_T_VOID *pvContext)
Register EtherCAT network traffic logging function at given slave port.
Note
The simulator introduces frame errors if the callback function modifies the Ethernet frame type at byte offset 12.
- Parameters
dwInstanceId – [in] Simulator Instance ID
wCfgFixedAddress – [in] Slave’s station address. 0: all slaves
byPort – [in] ESC port. 0, 1, 2, 3: port A, port B, port C, port D
pvLogFrameCallBack – [in] Pointer to frame logging callback function
pvContext – [in] Pointer to context passed as first parameters to callback function
- Returns
EC_E_NOERROR or error code
6.8.8. esLogFrameDisableAtSlavePort
-
EC_T_DWORD esLogFrameDisableAtSlavePort(EC_T_DWORD dwInstanceId, EC_T_WORD wCfgFixedAddress, EC_T_BYTE byPort)
Unregister EtherCAT network traffic logging function from given slave port.
- Parameters
dwInstanceId – [in] Simulator Instance ID
wCfgFixedAddress – [in] Slave’s station address. 0: all slaves
byPort – [in] ESC port. 0, 1, 2, 3: port A, port B, port C, port D
- Returns
EC_E_NOERROR or error code
6.8.9. esSendSlaveCoeEmergency
-
EC_T_DWORD esSendSlaveCoeEmergency(EC_T_DWORD dwInstanceId, EC_T_WORD wCfgFixedAddress, EC_T_WORD wCode, EC_T_BYTE *pbyData, EC_T_DWORD dwDataLen)
Send CoE emergency (queued)
- Parameters
dwInstanceId – [in] Simulator Instance ID
wCfgFixedAddress – [in] Slave’s station address
wCode – [in] Emergency code
pbyData – [in] Emergency data
dwDataLen – [in] Length of emergency data in byte
- Returns
EC_E_NOERROR or error code
CoE Emergency Example
The following code demonstrates how to send a CoE Emergency from a local buffer to the Master.
/* send CoE Emergency */
EC_T_BYTE abyEmergencyData[6] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
dwRes = esSendSlaveCoeEmergency(dwSimulatorId, wSlaveAddress, 0x1234 /* code */, abyEmergencyData, 6 /* data length */);
if (dwRes != EC_E_NOERROR)
{
EcLogMsg(EC_LOG_LEVEL_ERROR, (pEcLogContext, EC_LOG_LEVEL_ERROR, "esSendSlaveCoeEmergency failed: %s (0x%lx))\n", esGetText(dwSimulatorId, dwRes), dwRes));
goto Exit;
}