# index.html.md # EC-Simulator # api.html.md # Application programming interface, reference Function prototypes, definitions etc. of the API can be found in the header file `EcSimulator.h` which is the main header file to include when using EC-Simulator. ### Fundamental types ### typedef void \*EC_T_PVOID Pointer of type void ### typedef int EC_T_BOOL Boolean ### typedef char EC_T_CHAR Character, 8 bit ### typedef unsigned short EC_T_WCHAR Wide-character, 16 bit ### typedef unsigned char EC_T_BYTE Byte, unsigned integer 8 bit ### typedef unsigned char \*EC_T_PBYTE Pointer of type EC_T_BYTE ### typedef unsigned short EC_T_WORD Word, unsigned integer 16 bit ### typedef unsigned int EC_T_DWORD Double word, unsigned integer 32 bit ### typedef signed char EC_T_SBYTE Signed-Byte, signed integer 8 bit ### typedef signed short EC_T_SWORD Signed-Word, signed integer 16 bit ### typedef signed int EC_T_SDWORD Signed-Double-Word, signed integer 32 bit ### typedef int EC_T_INT Integer ### typedef unsigned int EC_T_UINT Unsigned-Integer ### typedef short EC_T_SHORT Short ### typedef unsigned short EC_T_USHORT Unsigned-Short ### typedef float EC_T_REAL Real, floating point ### typedef double EC_T_LREAL long Real, floating point ### typedef unsigned long long EC_T_UINT64 Unsigned integer 64 bits ### typedef signed long long EC_T_INT64 Signed integer 64 bits ### EC_T_VOID Void type ### Macros ### EC_TRUE Boolean value: True ### EC_FALSE Boolean value: False ### EC_NULL Null pointer constant # api_dc.html.md # Distributed Clocks (DC) Distributed Clocks are rudimentarily supported. # api_error_simulation_functions.html.md # Error simulation functions ## esSetErrorAtSlavePort ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esSetErrorAtSlavePort([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wCfgFixedAddress, [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) byPort, [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bOutgoing) Trigger loss of sent or received EtherCAT frames at slave port (“single shot”). \_ * **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](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ## esSetErrorGenerationAtSlavePort ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esSetErrorGenerationAtSlavePort([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wCfgFixedAddress, [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) byPort, [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bOutgoing, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwLikelihoodPpm, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwFixedGoodFramesCnt, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwFixedErroneousFramesCnt) Simulate the loss of sent EtherCAT frames at the port of a simulated slave at either random, periodic or random periodic intervalls. * Random frame loss simulation: For each frame the dwLikelihoodPpm parameter determines whether the frame will be discarded. * Periodic frame loss simulation: After dwFixedErroneousFramesCnt discarded frames, dwFixedGoodFramesCnt frames will be processed. * Random periodic frame loss simulation: The dwLikelihoodPpm parameter determines whether a periodic frame loss sequence is triggered. \_ * **Parameters:** * **dwInstanceId** – [in] Simulator Instance ID * **wCfgFixedAddress** – [in] Slave 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] Likelihood (ppm) according to frame loss simulation mode (Random / Random Periodic). Set to 0 in case of Periodic frame loss simulation. * **dwFixedGoodFramesCnt** – [in] Number of processed frames according to frame loss simulation mode (Periodic / Random Periodic). Set to 0 in case of Random frame loss simulation. * **dwFixedErroneousFramesCnt** – [in] Number of discarded frames according to frame loss simulation mode (Periodic / Random Periodic). Set to 0 in case of Random frame loss simulation. * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ## esResetErrorGenerationAtSlavePorts ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esResetErrorGenerationAtSlavePorts([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceId, [EC_T_WORD](api.html.md#_CPPv49EC_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](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ## esSetLinkDownAtSlavePort ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esSetLinkDownAtSlavePort([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wCfgFixedAddress, [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) byPort, [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bDown, [EC_T_DWORD](api.html.md#_CPPv410EC_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 [ms] or EC_WAITINFINITE * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ## esSetLinkDownGenerationAtSlavePort ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esSetLinkDownGenerationAtSlavePort([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wCfgFixedAddress, [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) byPort, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwLikelihoodPpm, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwFixedLinkDownTimeMs, [EC_T_DWORD](api.html.md#_CPPv410EC_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 [ms] (at least) * **dwFixedLinkUpTimeMs** – [in] After link down was simulated: fixed link up duration [ms] (at least) * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ## esResetLinkDownGenerationAtSlavePorts ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esResetLinkDownGenerationAtSlavePorts([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wCfgFixedAddress) Reset link lost event generation. \_ * **Parameters:** * **dwInstanceId** – [in] Simulator Instance ID * **wCfgFixedAddress** – [in] Slave’s station address. 0: all slaves * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ## esLogFrameEnableAtSlavePort ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esLogFrameEnableAtSlavePort([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wCfgFixedAddress, [EC_T_BYTE](api.html.md#_CPPv49EC_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](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ## esLogFrameDisableAtSlavePort ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esLogFrameDisableAtSlavePort([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wCfgFixedAddress, [EC_T_BYTE](api.html.md#_CPPv49EC_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](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ## esSendSlaveCoeEmergency ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esSendSlaveCoeEmergency([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wCfgFixedAddress, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wCode, [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) \*pbyData, [EC_T_DWORD](api.html.md#_CPPv410EC_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](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ### **CoE Emergency Example** The following code demonstrates how to send a CoE Emergency from a local buffer to the MainDevice. ```cpp /* 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; } ``` ## esSetSimSlaveState ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esSetSimSlaveState([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wCfgFixedAddress, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wDeviceState, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wDeviceStatusCode) Simulate AL Status Error for slave without device emulation or acknowledge delayed EtherCAT state change. * **Parameters:** * **dwInstanceId** – [in] Simulator Instance ID * **wCfgFixedAddress** – [in] Slave’s station address * **wDeviceState** – [in] Device state (DEVICE_STATE…) * **wDeviceStatusCode** – [in] Device status code (DEVICE_STATUSCODE…) * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ### **Simulate AL Status Error Example** The following code demonstrates how to simulate AL Status Errors for SubDevices without network adapter emulation: ```cpp /* start and immediately stop AL Status Error simulation (single shot) */ dwRes = esSetSimSlaveState(dwSimulatorId, wSlaveAddr, DEVICE_STATE_PREOP, DEVICE_STATUSCODE_ERROR); if (dwRes != EC_E_NOERROR) { goto Exit; } dwRes = esSetSimSlaveState(dwSimulatorId, wSlaveAddr, 0, DEVICE_STATUSCODE_NOERROR); if (dwRes != EC_E_NOERROR) { goto Exit; } ``` ### **Simulate AL Status Delay Example** The following code demonstrates how to simulate the EtherCAT® state transition being delayed for some cycles by the SubDevice application. `APPL_StartMailboxHandlerCallback_DelayALStatus()` starts the EtherCAT® state transition delay and `APPL_ApplicationCallback_DelayALStatus()` stops the EtherCAT® state transition delay: ```cpp /* AL Status delay timer */ static CEcTimer S_oAlStatusDelayTimer; /* EC_PF_SSC_APPL_START_MAILBOX_HANDLER */ static EC_T_WORD EC_FNCALL APPL_StartMailboxHandlerCallback_DelayALStatus( EC_T_VOID* pvContext, EC_T_DWORD /* dwSimulatorId */, EC_T_WORD /* wCfgFixedAddress */) { T_EC_DEMO_APP_CONTEXT* pAppContext = (T_EC_DEMO_APP_CONTEXT*)pvContext; if (!S_oAlStatusDelayTimer.IsStarted()) { EC_T_DWORD dwBusCycleTimeMsec = pAppContext->AppParms.dwBusCycleTimeNsec / 1000000; /* simulate slave state delay (e.g 3 cycles) */ S_oAlStatusDelayTimer.Start(EC_AT_LEAST(3 * dwBusCycleTimeMsec, 1)); } /* return NOERROR_INWORK to delay the EtherCAT state transition */ return 0xFF; /* NOERROR_INWORK, see also esSetSimSlaveState(..., 0, DEVICE_STATUSCODE_NOERROR) */ } /* EC_PF_SSC_APPL_APPLICATION */ static EC_T_VOID EC_FNCALL APPL_ApplicationCallback_DelayALStatus( EC_T_VOID* /* pvContext */, EC_T_DWORD dwInstanceId, EC_T_WORD wCfgFixedAddress) { /* application ready */ if (S_oAlStatusDelayTimer.IsElapsed()) { /* signal delayed EtherCAT state transition complete (see also NOERROR_INWORK) */ esSetSimSlaveState(dwInstanceId, wCfgFixedAddress, 0, DEVICE_STATUSCODE_NOERROR); S_oAlStatusDelayTimer.Stop(); } } ``` S_oAlStatusDelayTimer simulates the delay until the SubDevice application is ready. #### NOTE If the delay is too long, the transition to PREOP will fail in EcSimulatorSilDemo due to InitCmd timeouts from the ENI file and checks within the SSC: The callbacks must be registered using [`esSetSlaveSscApplication()`](api_general.html.md#_CPPv424esSetSlaveSscApplication10EC_T_DWORD9EC_T_WORDP24EC_T_SLAVE_SSC_APPL_DESC), e.g. in `myAppPrepare()` of EcSimulatorHilDemo / EcSimulatorSilDemo: ```cpp struct _EC_T_SLAVE_SSC_APPL_DESC oSlaveAppDesc; OsMemset(&oSlaveAppDesc, 0, sizeof(struct _EC_T_SLAVE_SSC_APPL_DESC)); oSlaveAppDesc.dwSignature = SIMULATOR_SIGNATURE; oSlaveAppDesc.dwSize = sizeof(struct _EC_T_SLAVE_SSC_APPL_DESC); oSlaveAppDesc.szName = (EC_T_CHAR*)"mySlaveAppl"; oSlaveAppDesc.pvContext = pAppContext; /* register callback APPL_Application, called after frame processing*/ oSlaveAppDesc.pfnApplication = APPL_ApplicationCallback_DelayALStatus; /* register callback for master state transition request INIT to higher */ oSlaveAppDesc.pfnStartMailboxHandler = APPL_StartMailboxHandlerCallback_DelayALStatus; /* register SlaveSscApplication callbacks (Master INIT) */ dwRes = esSetSlaveSscApplication(dwSimulatorId, wSlaveAddress, &oSlaveAppDesc); if (dwRes != EC_E_NOERROR) { goto Exit; } ``` ```cpp dwRes = emSetMasterState(0, ETHERCAT_STATE_CHANGE_TIMEOUT, eEcatState_PREOP); ``` #### SEE ALSO - [`esSetSlaveSscApplication()`](api_general.html.md#_CPPv424esSetSlaveSscApplication10EC_T_DWORD9EC_T_WORDP24EC_T_SLAVE_SSC_APPL_DESC): [`EC_T_SLAVE_SSC_APPL_DESC::pfnAckErrorInd`](api_general.html.md#_CPPv4N24EC_T_SLAVE_SSC_APPL_DESC14pfnAckErrorIndE) # api_general.html.md # Header files Function prototypes, definitions etc. of the API can be found in the header file `EcSimulator.h` which is the main header file to include when using EC-Simulator. # 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`](error-codes_generic.html.md#c.EC_E_NOERROR): The function was successfully executed. - [`EC_E_NOTSUPPORTED`](error-codes_generic.html.md#c.EC_E_NOTSUPPORTED): Unsupported feature or functionality. - [`EC_E_BUSY`](error-codes_generic.html.md#c.EC_E_BUSY): The stack is currently busy and the function has to be re-tried at a later time. - [`EC_E_NOMEMORY`](error-codes_generic.html.md#c.EC_E_NOMEMORY): Not enough memory or frame buffer resources available. - [`EC_E_INVALIDPARM`](error-codes_generic.html.md#c.EC_E_INVALIDPARM): Invalid or inconsistent parameters. - [`EC_E_TIMEOUT`](error-codes_generic.html.md#c.EC_E_TIMEOUT): Timeout error. - [`EC_E_SLAVE_ERROR`](error-codes_generic.html.md#c.EC_E_SLAVE_ERROR): A SubDevice error was detected. - [`EC_E_INVALID_SLAVE_STATE`](error-codes_generic.html.md#c.EC_E_INVALID_SLAVE_STATE): The SubDevice is not in the requested state to execute the operation (e.g. when initiating a mailbox transfer the SubDevice must be at least in PREOP state). - [`EC_E_SLAVE_NOT_ADDRESSABLE`](error-codes_generic.html.md#c.EC_E_SLAVE_NOT_ADDRESSABLE): The SubDevice does not respond to its station address (e.g. when requesting its AL_STATUS value). The SubDevice may be removed from the bus or powered-off. - [`EC_E_LINK_DISCONNECTED`](error-codes_generic.html.md#c.EC_E_LINK_DISCONNECTED): Link cable not connected. - [`EC_E_MASTERCORE_INACCESSIBLE`](error-codes_generic.html.md#c.EC_E_MASTERCORE_INACCESSIBLE): MainDevice core inaccessible. This result code usually means a remote connected server / EC-Simulator stack does not respond anymore. # Multiple EtherCAT® Network Support ## 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. ![Diagram showing multiple EC-Simulator stack instances within the same application process, each identified by a unique Instance ID with its own Real-time Ethernet Driver](../Media/overview.png) The Real-time Ethernet Driver can be of same or different type (emllPcap, emllIntelGbe, …). ## Licensing For each network identified with the unique Instance ID a separate runtime license is required. # General functions ## esInitSimulator ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esInitSimulator([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceId, const [EC_T_SIMULATOR_INIT_PARMS](api_general.html.md#_CPPv425EC_T_SIMULATOR_INIT_PARMS) \*pParms) Initialize EC-Simulator HiL. This function has to be called prior to calling any other function of EC-Simulator HiL. For EC-Simulator SiL (emllSimulator) this function is implicitly called by emInitMaster() and may not be called explicitly. \_ * **Parameters:** * **dwInstanceId** – [in] Simulator Instance ID * **pParms** – [in] Pointer to init parameters * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ### struct EC_T_SIMULATOR_INIT_PARMS ### Public Members ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSignature [in] Set to SIMULATOR_SIGNATURE ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSize [in] Set to sizeof(EC_T_SIMULATOR_INIT_PARMS) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSimulatorAddress [in] Reserved ### [EC_T_OS_PARMS](api_general.html.md#_CPPv413EC_T_OS_PARMS) \*pOsParms [in] OS layer parameters ### [EC_T_LINK_PARMS](emll_init.html.md#_CPPv415EC_T_LINK_PARMS) \*apLinkParms[EC_SIMULATOR_MAX_LINK_PARMS] [in] Link layer parameters ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwBusCycleTimeNsec [in] Bus cycle time in nanoseconds [ns] ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bDisableProcessDataImage [in] Disable Process Data Image (Process Data Variables not supported) ### EC_T_SIMULATOR_DEVICE_CONNECTION_DESC aoDeviceConnection[EC_SIMULATOR_MAX_LINK_PARMS] [in] see EC_SIMULATOR_DEVICE_CONNECTION_TYPE… ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bConnectHcGroups [in] Connect hot connect groups in topology (floating group heads to free ports) ### [EC_T_PERF_MEAS_INTERNAL_PARMS](api_general.html.md#_CPPv429EC_T_PERF_MEAS_INTERNAL_PARMS) PerfMeasInternalParms [in] Internal performance measurement parameters ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bApiLockByApp [in] Lock pending API against esDeinitSimulator(). EC_FALSE (default): locked internally. EC_TRUE: application is responsible for locking. ### struct EC_T_OS_PARMS ### Public Members ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSignature [in] Set to EC_OS_PARMS_SIGNATURE ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSize [in] Set to sizeof(EC_T_OS_PARMS) ### [EC_T_LOG_PARMS](api_general.html.md#_CPPv414EC_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](api.html.md#_CPPv410EC_T_DWORD) dwSupportedFeatures [in/out] Reserved ### EC_PF_QUERY_MSEC_COUNT pfSystemQueryMsecCount [in] Function to get system’s ms count ### struct EC_T_LOG_PARMS ### Public Members ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwLogLevel [in] Log level. See [EC_LOG_LEVEL…](api_general.html.md#d3-d63-group-e-c-l-o-g-l-e-v-e-l-s) ### [EC_PF_LOGMSGHK](api_general.html.md#_CPPv414EC_PF_LOGMSGHK) pfLogMsg [in] Log callback function called on every message ### 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](api.html.md#_CPPv410EC_T_DWORD) (\*EC_PF_LOGMSGHK)(EC_T_LOG_CONTEXT \*pContext, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwLogMsgSeverity, const [EC_T_CHAR](api.html.md#_CPPv49EC_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](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code Log messages are passed from the EC-Simulator to the callback given at [`EC_T_LOG_PARMS::pfLogMsg`](api_general.html.md#_CPPv4N14EC_T_LOG_PARMS8pfLogMsgE). The example program demonstrates how messages can be processed by the application, see `Examples/Common/EcLogging.cpp`. For performance reasons the EC-Simulator automatically filters log messages according to [`EC_T_LOG_PARMS::dwLogLevel`](api_general.html.md#_CPPv4N14EC_T_LOG_PARMS10dwLogLevelE). E.g. messages of severity [`EC_LOG_LEVEL_WARNING`](api_general.html.md#c.EC_LOG_LEVEL_WARNING) are not passed to the application if [`EC_T_LOG_PARMS::dwLogLevel`](api_general.html.md#_CPPv4N14EC_T_LOG_PARMS10dwLogLevelE) is set to [`EC_LOG_LEVEL_ERROR`](api_general.html.md#c.EC_LOG_LEVEL_ERROR). The application can provide customized log message handlers of type [`EC_PF_LOGMSGHK`](api_general.html.md#_CPPv414EC_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](api.html.md#_CPPv49EC_T_BOOL) bEnabled [in] Enable/disable internal performance counters ### [EC_T_PERF_MEAS_COUNTER_PARMS](api_general.html.md#_CPPv428EC_T_PERF_MEAS_COUNTER_PARMS) CounterParms [in] Timer function settings. When not provided OsMeasGetCounterTicks is used. ### [EC_T_PERF_MEAS_HISTOGRAM_PARMS](api_general.html.md#_CPPv430EC_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](api_general.html.md#_CPPv431EC_PF_PERF_MEAS_GETCOUNTERTICKS) pfGetCounterTicks [in] Function returning the current counter ticks ### EC_T_VOID \*pvGetCounterTicksContext [in] Context passed into GetCounterTicks ### [EC_T_UINT64](api.html.md#_CPPv411EC_T_UINT64) qwFrequency [in] Frequency in Hz used by the timer in GetCounterTicks ### typedef [EC_T_UINT64](api.html.md#_CPPv411EC_T_UINT64) (\*EC_PF_PERF_MEAS_GETCOUNTERTICKS)(EC_T_VOID \*pvContext) * **Param pvContext:** **[in]** Arbitrarily application-defined parameter passed to callback ### struct EC_T_PERF_MEAS_HISTOGRAM_PARMS ### Public Members ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwBinCount [in] Amount of bins to use for the histogram ### [EC_T_UINT64](api.html.md#_CPPv411EC_T_UINT64) qwMinTicks [in] Results below qwMinTicks are stored in the first bin ### [EC_T_UINT64](api.html.md#_CPPv411EC_T_UINT64) qwMaxTicks [in] Results above qwMaxTicks are stored in the last bin ## esDeinitSimulator ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esDeinitSimulator([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceId) Deinitialize EC-Simulator HiL. Waits for pending API calls if [esInitSimulator()](api_general.html.md#da/dca/_ec_simulator_api_8cpp_1a9abcdec979e4ebcde0ddc9fd83da2948) was called with [EC_T_SIMULATOR_INIT_PARMS::bApiLockByApp](api_general.html.md#dc/dc1/struct_e_c___t___s_i_m_u_l_a_t_o_r___i_n_i_t___p_a_r_m_s_1aeebfa6d6f7ed3bbc5bb278370878f3b5) = EC_FALSE (default). For EC-Simulator SiL (emllSimulator) this function is implicitly called by emDeinitMaster() and may not be called explicitly. \_ * **Parameters:** **dwInstanceId** – [in] Simulator Instance ID * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ## esGetSimulatorParms ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esGetSimulatorParms([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceId, [EC_T_SIMULATOR_INIT_PARMS](api_general.html.md#_CPPv425EC_T_SIMULATOR_INIT_PARMS) \*pParms, [EC_T_DWORD](api.html.md#_CPPv410EC_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](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code #### SEE ALSO [`esInitSimulator()`](api_general.html.md#_CPPv415esInitSimulator10EC_T_DWORDPK25EC_T_SIMULATOR_INIT_PARMS) ## esSetSimulatorParms ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esSetSimulatorParms([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceId, const [EC_T_SIMULATOR_INIT_PARMS](api_general.html.md#_CPPv425EC_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](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code #### SEE ALSO [`esInitSimulator()`](api_general.html.md#_CPPv415esInitSimulator10EC_T_DWORDPK25EC_T_SIMULATOR_INIT_PARMS) ## esSetLogParms ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esSetLogParms([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_LOG_PARMS](api_general.html.md#_CPPv414EC_T_LOG_PARMS) \*pLogParms) Sets log parameters. Used to change the parameters provided by esInitSimulator(). * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **pLogParms** – [in] New Log parameters #### SEE ALSO [`esInitSimulator()`](api_general.html.md#_CPPv415esInitSimulator10EC_T_DWORDPK25EC_T_SIMULATOR_INIT_PARMS) #### SEE ALSO [`esSetSimulatorParms()`](api_general.html.md#_CPPv419esSetSimulatorParms10EC_T_DWORDPK25EC_T_SIMULATOR_INIT_PARMS) ## esGetSrcMacAddress ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esGetSrcMacAddress([EC_T_DWORD](api.html.md#_CPPv410EC_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](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code Refers to adapter from EC_T_SIMULATOR_INIT_PARMS.pLinkParms at [`esInitSimulator()`](api_general.html.md#_CPPv415esInitSimulator10EC_T_DWORDPK25EC_T_SIMULATOR_INIT_PARMS). ## esSetLicenseKey (HiL) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esSetLicenseKey([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, const [EC_T_CHAR](api.html.md#_CPPv49EC_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](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) if successful * [EC_E_INVALIDSTATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga2a6310e052fca1b94797e8e26f031739) if EtherCAT stack isn’t initialized * [EC_E_INVALIDPARM](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga1e10d9022db11a708658c71b0dead2fe) if dwInstanceID is out of range * [EC_E_INVALIDSIZE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gacd9f0baea7a294f85c3f5bde1543d1d0) if the format of the license key is wrong. The correct length is 26, 53 or 56 characters. * [EC_E_LICENSE_MISSING](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga810a43bd89a1ef6ffa39af31090ac83e) if the license key doesn’t match the MAC Address Must be called after [`esInitSimulator()`](api_general.html.md#_CPPv415esInitSimulator10EC_T_DWORDPK25EC_T_SIMULATOR_INIT_PARMS) and before [`esConfigureNetwork()`](api_general.html.md#_CPPv418esConfigureNetwork10EC_T_DWORD13EC_T_CNF_TYPE10EC_T_PBYTE10EC_T_DWORD). This function may not be called if a non protected version is used. Example: ```cpp dwRes = esSetLicenseKey(dwInstanceID, "DA1099F2-15C249E9-54327FBC"); ``` ## esSetOemKey (HiL) ### static [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esSetOemKey([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_UINT64](api.html.md#_CPPv411EC_T_UINT64) qwOemKey) Must be called after [`esInitSimulator()`](api_general.html.md#_CPPv415esInitSimulator10EC_T_DWORDPK25EC_T_SIMULATOR_INIT_PARMS) and before [`esConfigureNetwork()`](api_general.html.md#_CPPv418esConfigureNetwork10EC_T_DWORD13EC_T_CNF_TYPE10EC_T_PBYTE10EC_T_DWORD). Example: ```cpp dwRes = esSetOemKey(dwInstanceID, 0x1234567812345678); ``` ## esConfigureNetwork ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esConfigureNetwork([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_CNF_TYPE](api_general.html.md#_CPPv413EC_T_CNF_TYPE) eCnfType, [EC_T_PBYTE](api.html.md#_CPPv410EC_T_PBYTE) pbyCnfData, [EC_T_DWORD](api.html.md#_CPPv410EC_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](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) if successful * [EC_E_INVALIDSTATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga2a6310e052fca1b94797e8e26f031739) if EtherCAT stack isn’t initialized or eCnfType is eCnfType_GenPreopENI or eCnfType_GenOpENI and link is disconnected * [EC_E_INVALIDPARM](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga1e10d9022db11a708658c71b0dead2fe) if dwInstanceID is out of range or pParms is EC_NULL contains some values out of range * [EC_E_LINK_DISCONNECTED](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8dac899f16df522b9c6754c7d8d0fb72) if link is disconnected * [EC_E_FEATURE_DISABLED](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gab1113b4cdd40bec6cddbd07d8780ff8a) if a configured feature is not included in the license key * [EC_E_NOTSUPPORTED](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga11f77305fb1d3868539a735298cc7864) if a configured feature is not supported (e.g not compiled in the library) * [EC_E_CFGFILENOTFOUND](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga7da2ce5dd71f5dbc9c5b37ced65de133) if the ENI file cannot be found * [EC_E_WRONG_FORMAT](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga7ef775b882e22c0ac3ff95e8f0b5fb53) if format errors have been detected in the ENI or EEPROM in case of eCnfType_GenPreopENI or eCnfType_GenOpENI * [EC_E_OEM_SIGNATURE_MISMATCH](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gaa9c0e78be6f5d34aa079232c84a9f796) if the OEM signature in the ENI file doesn’t match the used OEM key * [EC_E_ENI_ENCRYPTION_WRONG_VERSION](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga5c1f9e38352dc3ac3d458c30be5fa064) if the ENI encryption version is not supported (e.g. the library is too old) * [EC_E_ENI_ENCRYPTED](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gae95f45d1e8937074725ff7fe77cbaf12) if the ENI is encrypted and no OEM key has been set * [EC_E_XML_CYCCMDS_MISSING](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gaefee0a6b4f7097cc1ccdab22e2efccca) if the ENI doesn’t contain cyclic commands * [EC_E_XML_ALSTATUS_READ_MISSING](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga570d575d0d3bf5ee8e3a11cdd9e09eb2) if the ENI doesn’t contain any read AL status command * [EC_E_XML_CYCCMDS_SIZEMISMATCH](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga057e7cdfe426e792a7ab60830d2b3cf7) if the size of the cyclic commands in the ENI mismatch * [EC_E_XML_INVALID_INP_OFF](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga26f2972ae26bb55a653adbb40a8fefa0) if some input offsets in the ENI are invalid * [EC_E_XML_INVALID_OUT_OFF](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gad32f71e9d681cba85774d28f4416ee00) if some output offsets in the ENI are invalid * [EC_E_XML_INVALID_CMD_WITH_RED](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga6bdb2349373a8e935d23521806c4462b) if the ENI contains LRW commands and cable redundancy is configured * [EC_E_XML_PREV_PORT_MISSING](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga9ad1388e4ca96dcc4cef15851b09b654) if some previous port information are missing in the ENI * [EC_E_XML_DC_CYCCMDS_MISSING](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga6aa2d4a50dde9e285f7c0f936edbb1d0) if the DC related cyclic commands are missing in the ENI * [EC_E_XML_AOE_NETID_INVALID](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga11c2ea29d41ed1e850c4c0e76a0f3b89) if the ENI contains some invalid NetID ### 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. 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_None Reset configuration ### enumerator eCnfType_ConfigData pbyCnfData: Binary structured configuration ### 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_GenEBI Generate EBI based on bus-scan result ## esGetCfgSlaveInfo ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esGetCfgSlaveInfo([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bFixedAddressing, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wSlaveAddress, [EC_T_CFG_SLAVE_INFO](api_general.html.md#_CPPv419EC_T_CFG_SLAVE_INFO) \*pSlaveInfo) Return information about a configured slave from the ENI file. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **bFixedAddressing** – [in] EC_TRUE: use station address, EC_FALSE: use AutoInc address * **wSlaveAddress** – [in] Slave address according bFixedAddressing * **pSlaveInfo** – [out] Information about the slave * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code Content of [`EC_T_CFG_SLAVE_INFO`](api_general.html.md#_CPPv419EC_T_CFG_SLAVE_INFO) is subject to be extended. ### struct EC_T_CFG_SLAVE_INFO ### Public Members ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSlaveId [out] Slave’s ID to bind bus slave and config slave information ### [EC_T_CHAR](api.html.md#_CPPv49EC_T_CHAR) abyDeviceName[ECAT_DEVICE_NAMESIZE] [out] Slave’s configured name (80 Byte) (from ENI file) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwHCGroupIdx [out] Index of Hot Connect group, 0 for mandatory ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bIsPresent [out] Slave present on bus ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bIsHCGroupPresent [out] Slave’s Hot Connect group present on bus ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwVendorId [out] Vendor identification (from ENI file) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwProductCode [out] Product code (from ENI file) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwRevisionNumber [out] Revision number (from ENI file) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSerialNumber [out] Serial number (from ENI file) ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wStationAddress [out] Slave’s configured station address (from ENI file) ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wAutoIncAddress [out] Slave’s auto increment address (may differ from ENI file) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwPdOffsIn [out] Process input data bit offset (from ENI file) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwPdSizeIn [out] Process input data bit size (from ENI file) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwPdOffsOut [out] Process output data bit offset (from ENI file) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwPdSizeOut [out] Process output data bit size (from ENI file) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwPdOffsIn2 [out] 2nd sync unit process input data bit offset (from ENI file) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwPdSizeIn2 [out] 2nd sync unit process input data bit size (from ENI file) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwPdOffsOut2 [out] 2nd sync unit process output data bit offset (from ENI file) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwPdSizeOut2 [out] 2nd sync unit process output data bit size (from ENI file) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwPdOffsIn3 [out] 3rd sync unit process input data bit offset (from ENI file) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwPdSizeIn3 [out] 3rd sync unit process input data bit size (from ENI file) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwPdOffsOut3 [out] 3rd sync unit process output data bit offset (from ENI file) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwPdSizeOut3 [out] 3rd sync unit process output data bit size (from ENI file) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwPdOffsIn4 [out] 4th sync unit process input data bit offset (from ENI file) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwPdSizeIn4 [out] 4th sync unit process input data bit size (from ENI file) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwPdOffsOut4 [out] 4th sync unit process output data bit offset (from ENI file) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwPdSizeOut4 [out] 4th sync unit process output data bit size (from ENI file) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwMbxSupportedProtocols [out] Mailbox protocols supported by the slave (from ENI file). Combination of [Supported mailbox protocols](api_general.html.md#d6-d4d-group-e-c-m-b-x-p-r-o-t-o-c-o-l-s) flags. ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwMbxOutSize [out] Mailbox output byte size (from ENI file) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwMbxInSize [out] Mailbox input byte size (from ENI file) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwMbxOutSize2 [out] Bootstrap mailbox output byte size (from ENI file) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwMbxInSize2 [out] Bootstrap mailbox input byte size (from ENI file) ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bDcSupport [out] Slave supports DC (from ENI file) ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wNumProcessVarsInp [out] Number of input process data variables (from ENI file) ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wNumProcessVarsOutp [out] Number of output process data variables (from ENI file) ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wPrevStationAddress [out] Station address of the previous slave (from ENI file) ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wPrevPort [out] Connected port of the previous slave (from ENI file) ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wIdentifyAdo [out] ADO used for identification command (from ENI file) ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wIdentifyData [out] Identification value to be validated (from ENI file) ### [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) byPortDescriptor [out] Port descriptor (ESC register 0x0007) (from ENI file) ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wWkcStateDiagOffsIn[EC_CFG_SLAVE_PD_SECTIONS] [out] Offset of WkcState bit in diagnosis image (ENI: ProcessData/Recv[1..4]/BitStart): 0xFFFFFFFF = offset not available. WkcState bit values: 0 = Data valid, 1 = Data invalid. ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wWkcStateDiagOffsOut[EC_CFG_SLAVE_PD_SECTIONS] [out] Offset of WkcState bit in diagnosis image (ENI: ProcessData/Send[1..4]/BitStart): 0xFFFFFFFF = offset not available. WkcState bit values: 0 = Data valid, 1 = Data invalid. ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) awMasterSyncUnitIn[EC_CFG_SLAVE_PD_SECTIONS] [out] Sync Unit (ENI: ProcessData/TxPdo[1..4]@Su) ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) awMasterSyncUnitOut[EC_CFG_SLAVE_PD_SECTIONS] [out] Sync Unit (ENI: ProcessData/RxPdo[1..4]@Su) ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bDisabled [out] Slave disabled by API SetSlaveDisabled / SetSlavesDisabled. ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bDisconnected [out] Slave disconnected by API SetSlaveDisconnected / SetSlavesDisconnected. ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bExtended [out] Slave generated by API ConfigExtend ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bDcReferenceClock [out] Slave is reference clock (from ENI file) ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bDcPotentialRefClock [out] Slave can be used as a reference clock (from ENI file) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwDcCycleTime0 [out] Cycle time of Sync0 event [ns] (from ENI file) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwDcCycleTime1 [out] Calculated value dwDcCycleTime1 [ns] = Cycle time of Sync1 event - Cycle time of Sync1 event + Shift time of Sync0 event (from ENI file) ### [EC_T_INT](api.html.md#_CPPv48EC_T_INT) nDcShiftTime [out] Shift time of Sync0 event [ns] (from ENI file) ### [EC_T_CHAR](api.html.md#_CPPv49EC_T_CHAR) szProductRevision[24] [out] Slave’s ProductRevision (ENI:Slave/Info/ProductRevision), e.g. “EK1100-0000-0018”. Empty string if not present in ENI. **Supported mailbox protocols flags** ### EC_MBX_PROTOCOL_AOE ### EC_MBX_PROTOCOL_EOE ### EC_MBX_PROTOCOL_COE ### EC_MBX_PROTOCOL_FOE ### EC_MBX_PROTOCOL_SOE ### EC_MBX_PROTOCOL_VOE ### **esGetCfgSlaveInfo() Example** ```cpp /* get information about slave configured in ENI file */ EC_T_CFG_SLAVE_INFO oSlaveInfo; OsMemset(&oSlaveInfo, 0, sizeof(EC_T_CFG_SLAVE_INFO)); dwRes = esGetCfgSlaveInfo(dwInstanceId, EC_TRUE, 1001, &oSlaveInfo); ``` ## esGetCfgSlaveSmInfo ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esGetCfgSlaveSmInfo([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bFixedAddressing, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wSlaveAddress, [EC_T_CFG_SLAVE_SM_INFO](api_general.html.md#_CPPv422EC_T_CFG_SLAVE_SM_INFO) \*pSlaveSmInfo) Return SyncManager information of a configured slave from the ENI file. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **bFixedAddressing** – [in] EC_TRUE: use station address, EC_FALSE: use AutoInc address * **wSlaveAddress** – [in] Slave address according bFixedAddressing * **pSlaveSmInfo** – [out] Information about the slave. * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ### struct EC_T_CFG_SLAVE_SM_ENTRY ### Public Members ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wPhysAddr [out] ESC (0x800 + y \* 8) ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wLength [out] ESC (0x802 + y \* 8) ### [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) byOpMode [out] Bits 0..1 ESC (0x804 + y \* 8) ### [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) byDirection [out] Bits 2..3 ESC (0x804 + y \* 8) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwPdBitOffs [out] Process input data bit offset (from ENI file) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwPdBitSize [out] Process input data bit size (from ENI file) ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wWkcStateDiagBitOffs [out] Offset of WkcState bit in diagnosis image ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wMasterSyncUnit [out] Sync Unit (ENI: ProcessData/TxPdo[1..4]@Su) ### struct EC_T_CFG_SLAVE_SM_INFO ### Public Members ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSlaveId [out] Slave ID ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSmInfoNumOf [out] Number of available sync managers ### [EC_T_CFG_SLAVE_SM_ENTRY](api_general.html.md#_CPPv423EC_T_CFG_SLAVE_SM_ENTRY) aoSmInfos[ECREG_SYNCMANAGER_MAX_NUMOF] [out] Sync managers info ### **esGetCfgSlaveSmInfo() Example** ```cpp /* get information about slave's sync managers configured in ENI file */ EC_T_CFG_SLAVE_SM_INFO oSlaveSmInfo; OsMemset(&oSlaveSmInfo, 0, sizeof(EC_T_CFG_SLAVE_SM_INFO)); dwRes = esGetCfgSlaveSmInfo(dwInstanceId, EC_TRUE, 1001, &oSlaveSmInfo); ``` ## esSetSlaveSscApplication ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esSetSlaveSscApplication([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wCfgFixedAddress, [EC_T_SLAVE_SSC_APPL_DESC](api_general.html.md#_CPPv424EC_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](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ### struct EC_T_SLAVE_SSC_APPL_DESC ### Public Members ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSignature [in] Set to SIMULATOR_SIGNATURE ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSize [in] Set to sizeof(EC_T_SLAVE_SSC_APPL_DESC) ### EC_T_VOID \*pvContext [in] First parameter of SSC_APPL-callbacks ### EC_PF_SSC_APPL_MAIN_INIT pfnMainInit [in] SSC_APPL-callback for APPL_MainInit, called by SSC when slave initialization finished ### EC_PF_SSC_APPL_ACK_ERROR_IND pfnAckErrorInd [in] SSC_APPL-callback for APPL_AckErrorInd, called by SSC on error acknowledge by master ### EC_PF_SSC_APPL_APPLICATION pfnApplication [in] SSC_APPL-callback for APPL_Application, called after frame processing ### EC_PF_SSC_APPL_GET_DEVICE_ID pfnGetDeviceID [in] SSC_APPL-callback for APPL_GetDeviceID, called by SSC on Explicit Device ID request by master ### EC_PF_SSC_APPL_START_MAILBOX_HANDLER pfnStartMailboxHandler [in] SSC_APPL-callback for APPL_StartMailboxHandler, called by SSC on INIT to PREOP and INIT to BOOT transition ### EC_PF_SSC_APPL_STOP_MAILBOX_HANDLER pfnStopMailboxHandler [in] SSC_APPL-callback for APPL_StopMailboxHandler, called by SSC on PREOP to INIT and BOOT to INIT transition ### EC_PF_SSC_APPL_START_INPUT_HANDLER pfnStartInputHandler [in] SSC_APPL-callback for APPL_StartInputHandler, called by SSC on PREOP to SAFEOP transition (even if no INPUTs configured) ### EC_PF_SSC_APPL_STOP_INPUT_HANDLER pfnStopInputHandler [in] SSC_APPL-callback for APPL_StopInputHandler, called by SSC on SAFEOP to PREOP transition (even if no INPUTs configured) ### EC_PF_SSC_APPL_START_OUTPUT_HANDLER pfnStartOutputHandler [in] SSC_APPL-callback for APPL_StartOutputHandler, called by SSC on SAFEOP to OP transition (even if no OUTPUTs configured) ### EC_PF_SSC_APPL_STOP_OUTPUT_HANDLER pfnStopOutputHandler [in] SSC_APPL-callback for APPL_StopOutputHandler, called by SSC on OP to SAFEOP transition (even if no OUTPUTs configured) ### EC_PF_SSC_APPL_GENERATE_MAPPING pfnGenerateMapping [in] SSC_APPL-callback for APPL_GenerateMapping, called by SSC on PREOP to SAFEOP transition ### EC_PF_SSC_APPL_INPUT_MAPPING pfnInputMapping [in] SSC_APPL-callback for APPL_InputMapping, called by SSC to map (copy) INPUTs ### EC_PF_SSC_APPL_OUTPUT_MAPPING pfnOutputMapping [in] SSC_APPL-callback for APPL_OutputMapping, called by SSC to map (copy) OUTPUTs ### EC_T_PF_AOE_READ_CB pfnAoeRead [in] SSC_APPL-callback for APPL_AoeRead, called by SSC on AoE read request ### EC_T_PF_AOE_WRITE_CB pfnAoeWrite [in] SSC_APPL-callback for APPL_AoeWrite, called by SSC on AoE write request ### EC_T_PF_AOE_READWRITE_CB pfnAoeReadWrite [in] SSC_APPL-callback for APPL_AoeReadWrite, called by SSC on AoE read/write request ### EC_PF_SSC_APPL_EOE_RECEIVE pfnEoeReceive [in] SSC_APPL-callback for APPL_EoeReceive, called by SSC on received EoE Ethernet frame completion ### EC_PF_SSC_APPL_EOE_SETTING_IND pfnEoeSettingInd [in] SSC_APPL-callback for APPL_EoeSettingInd, called by SSC on EoE settings received ### EC_PF_SSC_APPL_FOE_WRITE pfnFoeWrite [in] SSC_APPL-callback for APPL_FoeWrite, called by SSC on FoE write request ### EC_PF_SSC_APPL_FOE_WRITE_DATA pfnFoeWriteData [in] SSC_APPL-callback for APPL_FoeWriteData, called by SSC when FoE data received ### EC_PF_SSC_APPL_FOE_READ pfnFoeRead [in] SSC_APPL-callback for APPL_FoeRead, called by SSC on FoE read request to transmit first FoE data ### EC_PF_SSC_APPL_FOE_READ_DATA pfnFoeReadData [in] SSC_APPL-callback for APPL_FoeReadData, called by SSC to transmit next FoE read data, 2..n ### EC_PF_SSC_APPL_FOE_ERROR pfnFoeError [in] SSC_APPL-callback for APPL_FoeError, called by SSC on FoE abort by master ### EC_PF_SSC_APPL_SET_PROC_VAR_PTR pfnSetProcVarPtr [in] SSC_APPL-callback for APPL_SetProcVarPtr, called on [esConfigureNetwork()](api_general.html.md#db/d74/_ec_master_api_8cpp_1a600437cfa3d318ecc069859870e9e90d) for each process data variable #### SEE ALSO - [ADS over EtherCAT® (AoE)](api_mailbox.html.md#ads-over-ethercat-r-aoe) - [Ethernet over EtherCAT® (EoE)](api_mailbox.html.md#ethernet-over-ethercat-r-eoe) - [File access over EtherCAT® (FoE)](api_mailbox.html.md#file-access-over-ethercat-r-foe) - [`esInitSimulator()`](api_general.html.md#_CPPv415esInitSimulator10EC_T_DWORDPK25EC_T_SIMULATOR_INIT_PARMS) - [`esConfigureNetwork()`](api_general.html.md#_CPPv418esConfigureNetwork10EC_T_DWORD13EC_T_CNF_TYPE10EC_T_PBYTE10EC_T_DWORD) ## esRegisterClient ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esRegisterClient([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_PF_NOTIFY](api_general.html.md#_CPPv412EC_PF_NOTIFY) pfnNotify, EC_T_VOID \*pCallerData, [EC_T_REGISTERRESULTS](api_general.html.md#_CPPv420EC_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](api_general.html.md#dc/d06/struct_e_c___t___r_e_g_i_s_t_e_r_r_e_s_u_l_t_s) * **Returns:** * [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) if successful * [EC_E_INVALIDSTATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga2a6310e052fca1b94797e8e26f031739) if EtherCAT stack isn’t initialized * [EC_E_INVALIDPARM](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga1e10d9022db11a708658c71b0dead2fe) if dwInstanceID is out of range or the output pointer is EC_NULL * [EC_E_NOMEMORY](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga48c2a7b288dc6922a8c0eb116495e1fd) if some memory cannot be allocated ### typedef [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) (\*EC_PF_NOTIFY)([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwCode, [EC_T_NOTIFYPARMS](api_notifications.html.md#_CPPv416EC_T_NOTIFYPARMS) \*pParms) * **Param dwCode:** **[in]** Notification code, see EC_NOTIFY_… * **Param pParms:** **[in]** Notification code depending data ### struct EC_T_REGISTERRESULTS ### Public Members ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwClntId [out] Client ID ### [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) \*pbyPDIn [out] Pointer to process data input memory ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwPDInSize [out] Size of process data input memory (in bytes) ### [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) \*pbyPDOut [out] Pointer to process data output memory ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwPDOutSize [out] Size of process data output memory (in bytes) ## esUnregisterClient ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esUnregisterClient([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_DWORD](api.html.md#_CPPv410EC_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](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ## esExecJob ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esExecJob([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_USER_JOB](api_general.html.md#_CPPv413EC_T_USER_JOB) eUserJob, [EC_T_USER_JOB_PARMS](api_general.html.md#_CPPv419EC_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](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) if successful * [EC_E_INVALIDSTATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga2a6310e052fca1b94797e8e26f031739) if EtherCAT stack isn’t initialized * [EC_E_INVALIDPARM](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga1e10d9022db11a708658c71b0dead2fe) if dwInstanceID is out of range or the output pointer is EC_NULL * [EC_E_LINK_DISCONNECTED](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8dac899f16df522b9c6754c7d8d0fb72) if the link is disconnected * [EC_E_FEATURE_DISABLED](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gab1113b4cdd40bec6cddbd07d8780ff8a) for eUsrJob_SwitchEoeFrames if EC_IOCTL_SET_EOE_DEFFERED_SWITCHING_ENABLED hasn’t be called before * [EC_E_ADS_IS_RUNNING](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gac053cb32c9b2bee0305b0644ef76e933) if the ADS server is running *Brief job overview:* ### enum EC_T_USER_JOB *Values:* ### enumerator eUsrJob_Undefined ### enumerator eUsrJob_ProcessAllRxFrames ### enumerator eUsrJob_SendAllCycFrames ### enumerator eUsrJob_MasterTimer ### 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 ### union EC_T_USER_JOB_PARMS ### Public Members ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bAllCycFramesProcessed ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwNumFramesSent ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwTaskIdToSend ### struct [EC_T_USER_JOB_PARMS](api_general.html.md#_CPPv419EC_T_USER_JOB_PARMS)::[\_SEND_CYCFRAME_BY_TASKID](api_general.html.md#_CPPv4N19EC_T_USER_JOB_PARMS24_SEND_CYCFRAME_BY_TASKIDE) SendCycFramesByTaskId ### struct [EC_T_USER_JOB_PARMS](api_general.html.md#_CPPv419EC_T_USER_JOB_PARMS)::[\_PROCESS_RXFRAME_BY_TASKID](api_general.html.md#_CPPv4N19EC_T_USER_JOB_PARMS26_PROCESS_RXFRAME_BY_TASKIDE) ProcessRxFramesByTaskId ### struct [EC_T_USER_JOB_PARMS](api_general.html.md#_CPPv419EC_T_USER_JOB_PARMS)::[\_SWITCH_EOE_FRAMES](api_general.html.md#_CPPv4N19EC_T_USER_JOB_PARMS18_SWITCH_EOE_FRAMESE) SwitchEoeFrames ### struct [EC_T_USER_JOB_PARMS](api_general.html.md#_CPPv419EC_T_USER_JOB_PARMS)::[\_START_TASK](api_general.html.md#_CPPv4N19EC_T_USER_JOB_PARMS11_START_TASKE) StartTask ### struct [EC_T_USER_JOB_PARMS](api_general.html.md#_CPPv419EC_T_USER_JOB_PARMS)::[\_STOP_TASK](api_general.html.md#_CPPv4N19EC_T_USER_JOB_PARMS10_STOP_TASKE) StopTask ### struct \_PROCESS_RXFRAME_BY_TASKID ### Public Members ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bCycFramesProcessed ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwTaskId ### struct \_SEND_CYCFRAME_BY_TASKID ### Public Members ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwTaskId ### struct \_START_TASK ### Public Members ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwTaskId ### struct \_STOP_TASK ### Public Members ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwTaskId ### struct \_SWITCH_EOE_FRAMES ### Public Members ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwMaxPortsToProcess ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwNumFramesProcessed *Detailed job description:* 1. [`eUsrJob_ProcessAllRxFrames`](api_general.html.md#_CPPv4N13EC_T_USER_JOB26eUsrJob_ProcessAllRxFramesE) : If the Real-time Ethernet Driver operates in polling mode this call will process all currently received frames, in interrupt mode all received frames are processed immediately and this call just returns with nothing done. ```cpp pUserJobParms->bAllCycFramesProcessed ```
If this flag is set to a value of [`EC_TRUE`](api.html.md#c.EC_TRUE) it indicates that all previously initiated cyclic frames ( [`eUsrJob_SendAllCycFrames`](api_general.html.md#_CPPv4N13EC_T_USER_JOB24eUsrJob_SendAllCycFramesE) ) are received and processed within this call. Not used if pUserJobParms set to [`EC_NULL`](api.html.md#c.EC_NULL).
Return: [`EC_E_NOERROR`](error-codes_generic.html.md#c.EC_E_NOERROR) if successful, error code in case of failures. 2. [`eUsrJob_SimulatorTimer`](api_general.html.md#_CPPv4N13EC_T_USER_JOB22eUsrJob_SimulatorTimerE) : This has to be called cyclically to trigger the SubDevice state machines, copy process data from simulated SubDevice firmware as well as the mailbox handling. The SubDevice state machines handle the EtherCAT® state transitions.
Return: [`EC_E_NOERROR`](error-codes_generic.html.md#c.EC_E_NOERROR) if successful, error code in case of failures. ## esGetMasterState ### EC_T_STATE esGetMasterState([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID) Get the EtherCAT master current state. * **Parameters:** **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **Returns:** EtherCAT master state ## esIoCtl ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esIoCtl([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwCode, const EC_T_VOID \*const pbyInBuf, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInBufSize, EC_T_VOID \*const pbyOutBuf, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwOutBufSize, [EC_T_DWORD](api.html.md#_CPPv410EC_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](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) if successful * [EC_E_INVALIDSTATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga2a6310e052fca1b94797e8e26f031739) if EtherCAT stack isn’t initialized * [EC_E_INVALIDPARM](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga1e10d9022db11a708658c71b0dead2fe) if dwInstanceID is out of range, the input pointer is EC_NULL or contains EC_NULL pointer * [EC_E_NOMEMORY](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga48c2a7b288dc6922a8c0eb116495e1fd) if memory cannot be allocated * [EC_E_ADS_IS_RUNNING](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gac053cb32c9b2bee0305b0644ef76e933) if the ADS server is running ## esIoCtl - 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](api_general.html.md#da/df0/struct_e_c___t___m_e_m_r_e_q___d_e_s_c)) * **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](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ### struct EC_T_MEMREQ_DESC ### Public Members ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwPDOutSize Size of the output process data image ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwPDInSize Size of the input process data image #### SEE ALSO [`esIoCtl()`](api_general.html.md#_CPPv47esIoCtl10EC_T_DWORD10EC_T_DWORDPCK9EC_T_VOID10EC_T_DWORDPC9EC_T_VOID10EC_T_DWORDPC10EC_T_DWORD) ## esIoCtl - 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](api_general.html.md#dd/dff/struct_e_c___t___c_y_c_f_r_a_m_e___r_x___c_b_d_e_s_c)) * **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](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) 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](api_general.html.md#_CPPv419EC_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](api.html.md#_CPPv410EC_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 [`esIoCtl()`](api_general.html.md#_CPPv47esIoCtl10EC_T_DWORD10EC_T_DWORDPCK9EC_T_VOID10EC_T_DWORDPC9EC_T_VOID10EC_T_DWORDPC10EC_T_DWORD) ## esIoCtl - 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](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code #### IMPORTANT With cable redundancy support enabled, EC_FALSE is only set if all links are down. #### SEE ALSO [`esIoCtl()`](api_general.html.md#_CPPv47esIoCtl10EC_T_DWORD10EC_T_DWORDPCK9EC_T_VOID10EC_T_DWORDPC9EC_T_VOID10EC_T_DWORDPC10EC_T_DWORD) ## esIoCtl - 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](api_general.html.md#d2/d75/struct_e_c___t___c_y_c___c_o_n_f_i_g___d_e_s_c) 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](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ### struct EC_T_CYC_CONFIG_DESC ### Public Members ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwNumCycEntries [out] Total number of cyclic entries ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwTaskId [out] Task ID of selected cyclic entry (ENI: Cyclic/TaskId) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwPriority [out] Priority of selected cyclic entry ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwCycleTime [out] Cycle time of selected cyclic entry #### SEE ALSO [`esIoCtl()`](api_general.html.md#_CPPv47esIoCtl10EC_T_DWORD10EC_T_DWORDPCK9EC_T_VOID10EC_T_DWORDPC9EC_T_VOID10EC_T_DWORDPC10EC_T_DWORD) ## esIoCtl - 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](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code #### SEE ALSO [`esIoCtl()`](api_general.html.md#_CPPv47esIoCtl10EC_T_DWORD10EC_T_DWORDPCK9EC_T_VOID10EC_T_DWORDPC9EC_T_VOID10EC_T_DWORDPC10EC_T_DWORD) ## esIoCtl - EC_IOCTL_SIMULATOR_SET_MBX_PROCESS_CTL ### EC_IOCTL_SIMULATOR_SET_MBX_PROCESS_CTL Enable or disable mailbox processing at slave. Default: Enabled. * **Parameters:** * **pbyInBuf** – [in] Pointer to value of [EC_T_SIMULATOR_MBX_PROCESS_CTL_DESC](api_general.html.md#d8/df5/struct_e_c___t___s_i_m_u_l_a_t_o_r___m_b_x___p_r_o_c_e_s_s___c_t_l___d_e_s_c) * **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](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ### struct EC_T_SIMULATOR_MBX_PROCESS_CTL_DESC ### Public Members ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wCfgFixedAddress Slave’s station address. 0: all slaves. ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bReadMbxOutEnabled Read mailbox out sync manager from DPRAM (received mailbox data from the master) ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bProcessMbxEnabled Process mailbox data from the master (MailboxServiceInd) #### SEE ALSO [`esIoCtl()`](api_general.html.md#_CPPv47esIoCtl10EC_T_DWORD10EC_T_DWORDPCK9EC_T_VOID10EC_T_DWORDPC9EC_T_VOID10EC_T_DWORDPC10EC_T_DWORD) ## esIoCtl - EC_IOCTL_SIMULATOR_GET_MBX_PROCESS_CTL ### EC_IOCTL_SIMULATOR_GET_MBX_PROCESS_CTL Get the information if mailbox processing at slave is enabled or disabled. * **Parameters:** * **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 [EC_T_SIMULATOR_MBX_PROCESS_CTL_DESC](api_general.html.md#d8/df5/struct_e_c___t___s_i_m_u_l_a_t_o_r___m_b_x___p_r_o_c_e_s_s___c_t_l___d_e_s_c) * **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](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code #### SEE ALSO [`esIoCtl()`](api_general.html.md#_CPPv47esIoCtl10EC_T_DWORD10EC_T_DWORDPCK9EC_T_VOID10EC_T_DWORDPC9EC_T_VOID10EC_T_DWORDPC10EC_T_DWORD) ## esIoCtl - 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](api_general.html.md#db/d79/struct_e_c___t___l_i_n_k_l_a_y_e_r___m_o_d_e___d_e_s_c) * **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](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ### struct EC_T_LINKLAYER_MODE_DESC ### Public Members ### [EC_T_LINKMODE](emll_init.html.md#_CPPv413EC_T_LINKMODE) eLinkMode [out] Operation mode of main interface ### [EC_T_LINKMODE](emll_init.html.md#_CPPv413EC_T_LINKMODE) eLinkModeRed [out] Operation mode of redundancy interface #### SEE ALSO [`esIoCtl()`](api_general.html.md#_CPPv47esIoCtl10EC_T_DWORD10EC_T_DWORDPCK9EC_T_VOID10EC_T_DWORDPC9EC_T_VOID10EC_T_DWORDPC10EC_T_DWORD) ## esIoCtl - EC_LINKIOCTL_XXXX The generic control interface [`esIoCtl()`](api_general.html.md#_CPPv47esIoCtl10EC_T_DWORD10EC_T_DWORDPCK9EC_T_VOID10EC_T_DWORDPC9EC_T_VOID10EC_T_DWORDPC10EC_T_DWORD) 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. ## esIoCtl - EC_LINKIOCTL_GET_ETHERNET_ADDRESS Get MAC address of the network adapter. **esIoCtl - 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 #### SEE ALSO [`esIoCtl()`](api_general.html.md#_CPPv47esIoCtl10EC_T_DWORD10EC_T_DWORDPCK9EC_T_VOID10EC_T_DWORDPC9EC_T_VOID10EC_T_DWORDPC10EC_T_DWORD) ## esIoCtl - EC_LINKIOCTL_GET_SPEED Get network adapter’s speed in MBits. **esIoCtl - 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 Real-time Ethernet 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 #### SEE ALSO [`esIoCtl()`](api_general.html.md#_CPPv47esIoCtl10EC_T_DWORD10EC_T_DWORDPCK9EC_T_VOID10EC_T_DWORDPC9EC_T_VOID10EC_T_DWORDPC10EC_T_DWORD) ## esIoCtl - EC_LINKIOCTL_GET_PCI_INFO Get network adapter’s PCI information **esIoCtl - EC_LINKIOCTL_GET_PCI_INFO** : **Parameter** : * `pbyInBuf`: [in] Should be set to EC_NULL * `dwInBufSize`: [in] Should be set to 0 * `pbyOutBuf`: [out] Pointer to EC_T_PCI_INFO buffer * `dwOutBufSize`: [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. ### struct EC_T_PCI_INFO ### Public Members ### [EC_T_PCI_INFO_LOCATION](api_general.html.md#_CPPv422EC_T_PCI_INFO_LOCATION) Location PCI location (bus, device, function) ### [EC_T_PCI_INFO_IDENIFICATION](api_general.html.md#_CPPv427EC_T_PCI_INFO_IDENIFICATION) Ident PCI identification (vendor id, device id) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwIoBarCnt I/O bar count ### [EC_T_PCI_INFO_IOBAR](api_general.html.md#_CPPv419EC_T_PCI_INFO_IOBAR) aIoBar PCI I/O bars info ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwMemBarCnt Memory bar count ### [EC_T_PCI_INFO_MEMBAR](api_general.html.md#_CPPv420EC_T_PCI_INFO_MEMBAR) aMemBar PCI Memory bars info ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInterruptCnt IRQ count ### [EC_T_PCI_INFO_INTERRUPT](api_general.html.md#_CPPv423EC_T_PCI_INFO_INTERRUPT) aInterrupt PCI IRQ info ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) adwReserved[16] Reserved for future use ### struct EC_T_PCI_INFO_LOCATION ### Public Members ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwDomainNumber Domain ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwBusNumber Bus number ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwDeviceNumber Device number ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwFunctionNumber Function number ### struct EC_T_PCI_INFO_IDENIFICATION ### Public Members ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwVendorId Vendor ID ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwDeviceId Device ID ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwReserved Reserved for future use ### struct EC_T_PCI_INFO_IOBAR ### Public Members ### [EC_T_UINT64](api.html.md#_CPPv411EC_T_UINT64) qwBaseAddress I/O bar base address ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwLen Bar length ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwReserved Reserved for future use ### struct EC_T_PCI_INFO_MEMBAR ### Public Members ### [EC_T_UINT64](api.html.md#_CPPv411EC_T_UINT64) qwBaseAddress Memory bar base address ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwLen Bar length ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwReserved Reserved for future use ### struct EC_T_PCI_INFO_INTERRUPT ### Public Members ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwIrq IRQ number ### EC_T_CPUSET CpuAffinity Reserved for future use ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) adwReserved[2] Reserved for future use #### SEE ALSO [`esIoCtl()`](api_general.html.md#_CPPv47esIoCtl10EC_T_DWORD10EC_T_DWORDPCK9EC_T_VOID10EC_T_DWORDPC9EC_T_VOID10EC_T_DWORDPC10EC_T_DWORD) ## esIoCtl - EC_LINKIOCTL_FORCE_LINK_STATUS Forces the network adapter’s link status **esIoCtl - EC_LINKIOCTL_FORCE_LINK_STATUS** : **Parameter** : * `pbyInBuf`: [in] Pointer to EC_T_BYTE. See EC_LINK_FORCE_LINK_STATUS_… * `dwInBufSize`: [in] Size of the input buffer in bytes. Must be at least the size of EC_T_BYTE. * `pbyOutBuf`: [out] Should be set to EC_NULL * `dwOutBufSize`: [in] Should be set to 0 * `pdwNumOutData`: [out] Should be set to EC_NULL ### EC_LINK_FORCE_LINK_STATUS_DISCONNECTED Force link status Disconnected: 0 ### EC_LINK_FORCE_LINK_STATUS_OK Force link status OK: 1 ### EC_LINK_FORCE_LINK_STATUS_AUTO Force link status Auto: 2 #### SEE ALSO [`esIoCtl()`](api_general.html.md#_CPPv47esIoCtl10EC_T_DWORD10EC_T_DWORDPCK9EC_T_VOID10EC_T_DWORDPC9EC_T_VOID10EC_T_DWORDPC10EC_T_DWORD) ## esGetVersion ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esGetVersion([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) \*pdwVersion, [EC_T_DWORD](api.html.md#_CPPv410EC_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](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) if successful * [EC_E_INVALIDSTATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga2a6310e052fca1b94797e8e26f031739) if EtherCAT stack isn’t initialized * [EC_E_INVALIDPARM](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga1e10d9022db11a708658c71b0dead2fe) if dwInstanceID is out of range or the output pointer is EC_NULL ## esGetText ### const [EC_T_CHAR](api.html.md#_CPPv49EC_T_CHAR) \*esGetText([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwTextId) Return text tokens by ID. * **Parameters:** **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **Returns:** Textual description of the given ID ## esGetMemoryUsage ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esGetMemoryUsage([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) \*pdwCurrentUsage, [EC_T_DWORD](api.html.md#_CPPv410EC_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](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ## esLogFrameEnable ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esLogFrameEnable([EC_T_DWORD](api.html.md#_CPPv410EC_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](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ```cpp /********************************************************************************/ /** \brief Handler to log frames. * * CAUTION: Called by cyclic task! Do not consume too 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 MainDevice 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 ... */ } ``` ## esLogFrameDisable ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esLogFrameDisable([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID) Disable the frame logging callback. * **Parameters:** **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code # api_mailbox.html.md # ADS over EtherCAT® (AoE) To handle AoE object transfers within the application, the callbacks pfnAoeRead, pfnAoeWrite and/or pfnAoeReadWrite can be registered using [`esSetSlaveAoeObjectTransferCallbacks()`](api_mailbox.html.md#_CPPv436esSetSlaveAoeObjectTransferCallbacks10EC_T_DWORD9EC_T_WORD19EC_T_PF_AOE_READ_CB20EC_T_PF_AOE_WRITE_CB24EC_T_PF_AOE_READWRITE_CBP9EC_T_VOID) or [`esSetSlaveSscApplication()`](api_general.html.md#_CPPv424esSetSlaveSscApplication10EC_T_DWORD9EC_T_WORDP24EC_T_SLAVE_SSC_APPL_DESC), e.g. in `myAppPrepare()` of EcSimulatorHilDemo / EcSimulatorSilDemo. See also [AoE Simulator and MainDevice Example](api_mailbox.html.md#aoe-simulator-and-maindevice-example) ## esAoeGetSlaveNetId ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esAoeGetSlaveNetId([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSlaveId, EC_T_AOE_NETID \*poAoeNetId) Retrieve the NetID of a specific EtherCAT device. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **dwSlaveId** – [in] Slave ID * **poAoeNetId** – [out] AoE NetID of the corresponding slave * **Returns:** * [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) if successful * [EC_E_INVALIDSTATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga2a6310e052fca1b94797e8e26f031739) if EtherCAT stack isn’t initialized * [EC_E_INVALIDPARM](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga1e10d9022db11a708658c71b0dead2fe) if dwInstanceID is out of range, the input pointer is EC_NULL or contains EC_NULL pointer, or dwTimeout is EC_NOWAIT * [EC_E_SLAVE_NOT_PRESENT](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga45555d5de25571188a82d2d76c02dd81) if slave not present * [EC_E_NOTFOUND](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga3113f3b6f82bb50e6ab3cde40268730a) if no slave matching dwSlaveId can be found * [EC_E_NO_MBX_SUPPORT](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga461eba97c1aa71d0d6bc72202035ad98) if slave has no mailbox support * [EC_E_ADS_IS_RUNNING](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gac053cb32c9b2bee0305b0644ef76e933) if ADS server is running ## esAoeRead ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esAoeRead([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSlaveId, EC_T_AOE_NETID \*poTargetNetId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wTargetPort, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwIndexGroup, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwIndexOffset, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwDataLen, [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) \*pbyData, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) \*pdwDataOutLen, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) \*pdwErrorCode, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) \*pdwCmdResult, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwTimeout) Execute an AoE mailbox read request to an EtherCAT slave device. This function may not be called from within the JobTask’s context. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **dwSlaveId** – [in] Slave ID * **poTargetNetId** – [in] Target NetID * **wTargetPort** – [in] Target port * **dwIndexGroup** – [in] AoE read command index group * **dwIndexOffset** – [in] AoE read command index offset * **dwDataLen** – [in] Buffer length [bytes] * **pbyData** – [out] Buffer receiving transferred data * **pdwDataOutLen** – [out] Number of bytes read from the target device * **pdwErrorCode** – [out] AoE response error code * **pdwCmdResult** – [out] AoE read command result code * **dwTimeout** – [in] Timeout [ms]. The function will block at most for this time. * **Returns:** * [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) on success * [EC_E_AOE_VENDOR_SPECIFIC](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga1b4e331b053ac416172151c2d402d9f6) if the AoE device has responded with a user defined error code * [EC_E_MASTER_RED_STATE_INACTIVE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gae2870f20d370920995e27b2a78171a5e) if Master Redundancy is configured and master is inactive ## esAoeWrite ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esAoeWrite([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSlaveId, EC_T_AOE_NETID \*poTargetNetId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wTargetPort, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwIndexGroup, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwIndexOffset, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwDataLen, [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) \*pbyData, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) \*pdwErrorCode, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) \*pdwCmdResult, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwTimeout) Execute an AoE mailbox write request to an EtherCAT slave device. This function may not be called from within the JobTask’s context. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **dwSlaveId** – [in] Slave ID * **poTargetNetId** – [in] Target NetID * **wTargetPort** – [in] Target port * **dwIndexGroup** – [in] AoE write command index group * **dwIndexOffset** – [in] AoE write command index offset * **dwDataLen** – [in] Buffer length [bytes] * **pbyData** – [in] Buffer containing transfered data * **pdwErrorCode** – [out] Pointer to AoE response error code * **pdwCmdResult** – [out] Pointer to AoE write command result code * **dwTimeout** – [in] Timeout [ms]. The function will block at most for this time. * **Returns:** * [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) on success * [EC_E_AOE_VENDOR_SPECIFIC](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga1b4e331b053ac416172151c2d402d9f6) if the AoE device has responded with a user defined error code * [EC_E_MASTER_RED_STATE_INACTIVE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gae2870f20d370920995e27b2a78171a5e) if Master Redundancy is configured and master is inactive ## esAoeReadWrite ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esAoeReadWrite([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSlaveId, EC_T_AOE_NETID \*poTargetNetId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wTargetPort, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwIndexGroup, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwIndexOffset, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwReadDataLen, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwWriteDataLen, [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) \*pbyData, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) \*pdwDataOutLen, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) \*pdwErrorCode, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) \*pdwCmdResult, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwTimeout) Execute an AoE mailbox read/write request to an EtherCAT slave device. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **dwSlaveId** – [in] Slave ID * **poTargetNetId** – [in] Target NetID * **wTargetPort** – [in] Target port * **dwIndexGroup** – [in] AoE read/write command index group * **dwIndexOffset** – [in] AoE read/write command index offset * **dwReadDataLen** – [in] Number of bytes to read from the target device * **dwWriteDataLen** – [in] Number of bytes to write to the target device * **pbyData** – [in, out] Buffer containing and receiving transfered data * **pdwDataOutLen** – [out] Number of bytes read from the target device * **pdwErrorCode** – [out] Pointer to AoE response error code * **pdwCmdResult** – [out] Pointer to AoE write command result code * **dwTimeout** – [in] Timeout [ms]. The function will block at most for this time. EC_NOWAIT is not valid. * **Returns:** * [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) on success * [EC_E_AOE_VENDOR_SPECIFIC](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga1b4e331b053ac416172151c2d402d9f6) if the AoE device has responded with a user defined error code * [EC_E_MASTER_RED_STATE_INACTIVE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gae2870f20d370920995e27b2a78171a5e) if Master Redundancy is configured and master is inactive ## esSetSlaveAoeObjectTransferCallbacks ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esSetSlaveAoeObjectTransferCallbacks([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wCfgFixedAddress, EC_T_PF_AOE_READ_CB pfRead, EC_T_PF_AOE_WRITE_CB pfWrite, EC_T_PF_AOE_READWRITE_CB pfReadWrite, EC_T_VOID \*pvContext) Set AoE read/write callbacks. \_ * **Parameters:** * **dwInstanceId** – [in] Simulator Instance ID * **wCfgFixedAddress** – [in] Slave’s station address. 0: all slaves. * **pfRead** – [in] Read callback function * **pfWrite** – [in] Write callback function * **pfReadWrite** – [in] ReadWrite callback function * **pvContext** – [in] Pointer to context passed as first parameters to callback functions * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ## AoE Simulator and MainDevice Example The following example demonstrates how to handle AoE object transfers within the simulator application: ### **AoE Simulator and MainDevice Example** The following example handlers can be registered at the EC-Simulator: ```cpp /* EC_T_PF_AOE_READ_CB */ EC_T_DWORD EC_FNCALL myAppAoeReadObjectCallback( EC_T_VOID* /* pvContext */, EC_T_DWORD dwSimulatorId, EC_T_WORD wCfgFixedAddress, EC_T_AOE_NETID* /* poSenderNetId */, EC_T_WORD /* wSenderPort */, EC_T_AOE_NETID* /* poTargetNetId */, EC_T_WORD wTargetPort, EC_T_DWORD dwIndexGroup, EC_T_DWORD dwIndexOffset, EC_T_BYTE* pbyReadData, EC_T_DWORD* pdwReadDataLen, EC_T_DWORD* pdwErrorCode, EC_T_DWORD* pdwCmdResult) { if (65535 != wTargetPort) { EC_SETDWORD(pdwErrorCode, EC_E_AOE_TARGET_PORT_NOT_FOUND); goto Exit; } if (0xF302 /* ADSIGRP_CANOPEN_SDO */ != dwIndexGroup) { EC_SETDWORD(pdwErrorCode, EC_E_AOE_INVALIDGRP); goto Exit; } /* check for object 0x2003, subindex 0, no complete access */ if (0x20030000 != dwIndexOffset /* example value */) { EC_SETDWORD(pdwErrorCode, EC_E_AOE_NOTFOUND); goto Exit; } /* check for size of object 0x2003, subindex 0 */ if (4 != EC_GETDWORD(pdwReadDataLen) /* UDINT: sizeof(EC_T_DWORD) */) { EC_SETDWORD(pdwErrorCode, EC_E_AOE_INVALIDSIZE); goto Exit; } /* all checks passed, return data and set success */ EC_SET_FRM_DWORD(pbyReadData, 0x12345678); EC_SETDWORD(pdwErrorCode, EC_E_NOERROR); Exit: EcLogMsg(EC_LOG_LEVEL_VERBOSE, (pEcLogContext, EC_LOG_LEVEL_VERBOSE, "myAppAoeReadObjectCallback(%d, %d, %d, 0x%04X, 0x%04X, %d bytes, 0x%08X, 0x%08X): %s (0x%08X)\n", dwSimulatorId, wCfgFixedAddress, wTargetPort, dwIndexGroup, dwIndexOffset, EC_GETDWORD(pdwReadDataLen), EC_GETDWORD(pdwErrorCode), EC_GETDWORD(pdwCmdResult), esGetText(dwSimulatorId, EC_GETDWORD(pdwErrorCode)), EC_GETDWORD(pdwErrorCode))); return EC_GETDWORD(pdwErrorCode); } /* EC_T_PF_AOE_WRITE_CB */ EC_T_DWORD EC_FNCALL myAppAoeWriteObjectCallback( EC_T_VOID* /* pvContext */, EC_T_DWORD dwSimulatorId, EC_T_WORD wCfgFixedAddress, EC_T_AOE_NETID* /* poSenderNetId */, EC_T_WORD /* wSenderPort */, EC_T_AOE_NETID* /* poTargetNetId */, EC_T_WORD wTargetPort, EC_T_DWORD dwIndexGroup, EC_T_DWORD dwIndexOffset, EC_T_BYTE* pbyWriteData, EC_T_DWORD dwWriteDataLen, EC_T_DWORD* pdwErrorCode, EC_T_DWORD* pdwCmdResult) { EC_T_DWORD dwVal = 0; if (65535 != wTargetPort) { EC_SETDWORD(pdwErrorCode, EC_E_AOE_TARGET_PORT_NOT_FOUND); goto Exit; } if (0xF302 /* ADSIGRP_CANOPEN_SDO */ != dwIndexGroup) { EC_SETDWORD(pdwErrorCode, EC_E_AOE_INVALIDGRP); goto Exit; } /* check for object 0x2003, subindex 0, no complete access */ if (0x20030000 != dwIndexOffset /* example value */) { EC_SETDWORD(pdwErrorCode, EC_E_AOE_NOTFOUND); goto Exit; } /* check for size of object 0x2003, subindex 0 */ if (4 != dwWriteDataLen /* UDINT: sizeof(EC_T_DWORD) */) { EC_SETDWORD(pdwErrorCode, EC_E_AOE_INVALIDSIZE); goto Exit; } /* all checks passed, get data and set success */ dwVal = EC_GET_FRM_DWORD(pbyWriteData); EC_SETDWORD(pdwErrorCode, EC_E_NOERROR); Exit: EcLogMsg(EC_LOG_LEVEL_VERBOSE, (pEcLogContext, EC_LOG_LEVEL_VERBOSE, "myAppAoeWriteObjectCallback(%d, %d, %d, 0x%04X, 0x%04X, %d bytes, 0x%08X, 0x%08X) = %d (0x%08X): %s (0x%08X)\n", dwSimulatorId, wCfgFixedAddress, wTargetPort, dwIndexGroup, dwIndexOffset, dwWriteDataLen, EC_GETDWORD(pdwErrorCode), EC_GETDWORD(pdwCmdResult), dwVal, dwVal, esGetText(dwSimulatorId, EC_GETDWORD(pdwErrorCode)), EC_GETDWORD(pdwErrorCode))); return EC_GETDWORD(pdwErrorCode); } /* EC_T_PF_AOE_READWRITE_CB */ EC_T_DWORD EC_FNCALL myAppAoeReadWriteObjectCallback( EC_T_VOID* /* pvContext */, EC_T_DWORD dwSimulatorId, EC_T_WORD wCfgFixedAddress, EC_T_AOE_NETID* /* poSenderNetId */, EC_T_WORD /* wSenderPort */, EC_T_AOE_NETID* /* poTargetNetId */, EC_T_WORD wTargetPort, EC_T_DWORD dwIndexGroup, EC_T_DWORD dwIndexOffset, EC_T_BYTE* pbyReadData, EC_T_DWORD* pdwReadDataLen, EC_T_BYTE* pbyWriteData, EC_T_DWORD dwWriteDataLen, EC_T_DWORD* pdwErrorCode, EC_T_DWORD* pdwCmdResult) { EC_T_DWORD dwVal = 0; if (65535 != wTargetPort) { EC_SETDWORD(pdwErrorCode, EC_E_AOE_TARGET_PORT_NOT_FOUND); goto Exit; } if (0xF302 /* ADSIGRP_CANOPEN_SDO */ != dwIndexGroup) { EC_SETDWORD(pdwErrorCode, EC_E_AOE_INVALIDGRP); goto Exit; } /* check for object 0x2003, subindex 0, no complete access */ if (0x20030000 != dwIndexOffset /* example value */) { EC_SETDWORD(pdwErrorCode, EC_E_AOE_NOTFOUND); goto Exit; } /* check for size of object 0x2003, subindex 0 */ if ((4 != EC_GETDWORD(pdwReadDataLen) /* UDINT: sizeof(EC_T_DWORD) */) || (4 != dwWriteDataLen /* UDINT: sizeof(EC_T_DWORD) */)) { EC_SETDWORD(pdwErrorCode, EC_E_AOE_INVALIDSIZE); goto Exit; } /* all checks passed, set and get data and set success */ EC_SET_FRM_DWORD(pbyReadData, 0x12345678); dwVal = EC_GET_FRM_DWORD(pbyWriteData); EC_SETDWORD(pdwErrorCode, EC_E_NOERROR); Exit: EcLogMsg(EC_LOG_LEVEL_VERBOSE, (pEcLogContext, EC_LOG_LEVEL_VERBOSE, "myAppAoeReadWriteObjectCallback(%d, %d, %d, 0x%04X, 0x%04X, read %d bytes, write %d bytes, 0x%08X, 0x%08X) = %d (0x%08X): %s (0x%08X)\n", dwSimulatorId, wCfgFixedAddress, wTargetPort, dwIndexGroup, dwIndexOffset, EC_GETDWORD(pdwReadDataLen), dwWriteDataLen, EC_GETDWORD(pdwErrorCode), EC_GETDWORD(pdwCmdResult), dwVal, dwVal, esGetText(dwSimulatorId, EC_GETDWORD(pdwErrorCode)), EC_GETDWORD(pdwErrorCode))); return EC_GETDWORD(pdwErrorCode); } ``` The following example demonstrates object transfers between MainDevice and Simulator: ```cpp EC_T_DWORD dwRes = EC_E_ERROR; EC_T_DWORD dwRetVal = EC_E_ERROR; EC_T_BYTE abyWriteData[sizeof(EC_T_DWORD)]; EC_T_BYTE abyReadData[sizeof(EC_T_DWORD)]; EC_T_BYTE abyReadWriteData[sizeof(EC_T_DWORD)]; EC_T_DWORD dwDataOutLen = 0; EC_T_AOE_NETID oAoeNetId; EC_T_DWORD dwSlaveId = emGetSlaveId(dwMasterId, wSlaveAddress); EC_T_DWORD dwErrorCode = EC_E_ERROR; EC_T_DWORD dwCmdResult = EC_E_ERROR; OsMemset(abyWriteData, 0, sizeof(abyWriteData)); OsMemset(abyReadData, 0, sizeof(abyReadData)); OsMemset(abyReadWriteData, 0, sizeof(abyReadWriteData)); /* EC-Master: get configured AoE net ID */ dwRes = emAoeGetSlaveNetId(dwMasterId, dwSlaveId, &oAoeNetId); if (dwRes != EC_E_NOERROR) { EcLogMsg(EC_LOG_LEVEL_ERROR, (pEcLogContext, EC_LOG_LEVEL_ERROR, "emAoeGetSlaveNetId failed: %s (0x%lx))\n", ecatGetText(dwRes), dwRes)); dwRetVal = dwRes; goto Exit; } /* EC-Simulator: register AoE handlers */ dwRes = esSetSlaveAoeObjectTransferCallbacks(dwSimulatorId, wSlaveAddress, myAppAoeReadObjectCallback, myAppAoeWriteObjectCallback, myAppAoeReadWriteObjectCallback, pAppContext); if (dwRes != EC_E_NOERROR) { EcLogMsg(EC_LOG_LEVEL_ERROR, (pEcLogContext, EC_LOG_LEVEL_ERROR, "esSetSlaveAoeObjectTransferCallbacks failed: %s (0x%lx))\n", esGetText(dwSimulatorId, dwRes), dwRes)); dwRetVal = dwRes; goto Exit; } /* EC-Master: set PREOP state */ dwRes = emSetMasterState(dwMasterId, 30000, eEcatState_PREOP); if (dwRes != EC_E_NOERROR) { EcLogMsg(EC_LOG_LEVEL_ERROR, (pEcLogContext, EC_LOG_LEVEL_ERROR, "emSetMasterState failed: %s (0x%lx))\n", ecatGetText(dwRes), dwRes)); dwRetVal = dwRes; goto Exit; } #define AOE_TARGET_PORT 65535 #define AOE_INDEX_GROUP 0xF302 /* ADSIGRP_CANOPEN_SDO */ /* CoE objects to access via AoE */ #define AOE_COE_OBJ_IDX 0x2003 #define AOE_COE_OBJ_SUBINDEX 0 #define AOE_COE_OBJ_COMPLETEACCESS EC_FALSE /* Bit 16-31: index, Bit 8: complete access, Bit 0-7: subindex */ #define AOE_INDEX_OFFSET ((AOE_COE_OBJ_IDX << 16) | (AOE_COE_OBJ_COMPLETEACCESS << 8) | AOE_COE_OBJ_SUBINDEX) /* EC-Master: write AoE to slave */ EC_SET_FRM_DWORD(abyWriteData, 0x11223344 /* example value */); dwRes = emAoeWrite(dwMasterId, dwSlaveId, &oAoeNetId, AOE_TARGET_PORT, AOE_INDEX_GROUP, AOE_INDEX_OFFSET, sizeof(EC_T_DWORD), abyWriteData, &dwErrorCode, &dwCmdResult, MBX_TIMEOUT); if (dwRes != EC_E_NOERROR) { EcLogMsg(EC_LOG_LEVEL_ERROR, (pEcLogContext, EC_LOG_LEVEL_ERROR, "emAoeWrite failed: %s (0x%lx))\n", ecatGetText(dwRes), dwRes)); dwRetVal = dwRes; goto Exit; } /* EC-Master: read AoE from slave */ EC_SET_FRM_DWORD(abyReadData, 0); dwRes = emAoeRead(dwMasterId, dwSlaveId, &oAoeNetId, AOE_TARGET_PORT, AOE_INDEX_GROUP, AOE_INDEX_OFFSET, sizeof(EC_T_DWORD), abyReadData, &dwDataOutLen, &dwErrorCode, &dwCmdResult, MBX_TIMEOUT); if (dwRes != EC_E_NOERROR) { EcLogMsg(EC_LOG_LEVEL_ERROR, (pEcLogContext, EC_LOG_LEVEL_ERROR, "emAoeRead failed: %s (0x%lx))\n", ecatGetText(dwRes), dwRes)); dwRetVal = dwRes; goto Exit; } /* EC-Master: read + write AoE from/to slave */ EC_SET_FRM_DWORD(abyReadWriteData, 0x11223344 /* example value */); dwRes = emAoeReadWrite(dwMasterId, dwSlaveId, &oAoeNetId, AOE_TARGET_PORT, AOE_INDEX_GROUP, AOE_INDEX_OFFSET, sizeof(EC_T_DWORD), sizeof(EC_T_DWORD), abyReadWriteData, &dwDataOutLen, &dwErrorCode, &dwCmdResult, MBX_TIMEOUT); if (dwRes != EC_E_NOERROR) { EcLogMsg(EC_LOG_LEVEL_ERROR, (pEcLogContext, EC_LOG_LEVEL_ERROR, "emAoeReadWrite failed: %s (0x%lx))\n", ecatGetText(dwRes), dwRes)); dwRetVal = dwRes; goto Exit; } /* EC-Simulator: write AoE to slave */ EC_SET_FRM_DWORD(abyWriteData, 0x11223344 /* example value */); dwRes = esAoeWrite(dwSimulatorId, dwSlaveId, &oAoeNetId, AOE_TARGET_PORT, AOE_INDEX_GROUP, AOE_INDEX_OFFSET, sizeof(EC_T_DWORD), abyWriteData, &dwErrorCode, &dwCmdResult, MBX_TIMEOUT); if (dwRes != EC_E_NOERROR) { EcLogMsg(EC_LOG_LEVEL_ERROR, (pEcLogContext, EC_LOG_LEVEL_ERROR, "emAoeWrite failed: %s (0x%lx))\n", ecatGetText(dwRes), dwRes)); dwRetVal = dwRes; goto Exit; } /* EC-Simulator: read AoE from slave */ EC_SET_FRM_DWORD(abyReadData, 0); dwRes = esAoeRead(dwSimulatorId, dwSlaveId, &oAoeNetId, AOE_TARGET_PORT, AOE_INDEX_GROUP, AOE_INDEX_OFFSET, sizeof(EC_T_DWORD), abyReadData, &dwDataOutLen, &dwErrorCode, &dwCmdResult, MBX_TIMEOUT); if (dwRes != EC_E_NOERROR) { EcLogMsg(EC_LOG_LEVEL_ERROR, (pEcLogContext, EC_LOG_LEVEL_ERROR, "emAoeRead failed: %s (0x%lx))\n", ecatGetText(dwRes), dwRes)); dwRetVal = dwRes; goto Exit; } /* EC-Simulator: read + write AoE from/to slave */ EC_SET_FRM_DWORD(abyReadWriteData, 0x11223344 /* example value */); dwRes = esAoeReadWrite(dwSimulatorId, dwSlaveId, &oAoeNetId, AOE_TARGET_PORT, AOE_INDEX_GROUP, AOE_INDEX_OFFSET, sizeof(EC_T_DWORD), sizeof(EC_T_DWORD), abyReadWriteData, &dwDataOutLen, &dwErrorCode, &dwCmdResult, MBX_TIMEOUT); if (dwRes != EC_E_NOERROR) { EcLogMsg(EC_LOG_LEVEL_ERROR, (pEcLogContext, EC_LOG_LEVEL_ERROR, "emAoeReadWrite failed: %s (0x%lx))\n", ecatGetText(dwRes), dwRes)); dwRetVal = dwRes; goto Exit; } ``` # CAN application protocol over EtherCAT® (CoE) To handle CoE object transfers within the application, the callbacks pfnCoeRead and/or pfnCoeWrite can be registered using [`esSetSlaveCoeObjectTransferCallbacks()`](api_mailbox.html.md#_CPPv436esSetSlaveCoeObjectTransferCallbacks10EC_T_DWORD9EC_T_WORD9EC_T_WORD19EC_T_PF_COE_READ_CB20EC_T_PF_COE_WRITE_CBP9EC_T_VOID) or [`esSetSlaveSscApplication()`](api_general.html.md#_CPPv424esSetSlaveSscApplication10EC_T_DWORD9EC_T_WORDP24EC_T_SLAVE_SSC_APPL_DESC), e.g. in `myAppPrepare()` of EcSimulatorHilDemo / EcSimulatorSilDemo. See also [CoE transfer Simulator and MainDevice Example](api_mailbox.html.md#coe-transfer-simulator-and-maindevice-example) ## esExtendSlaveCoeObjectDictionary ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esExtendSlaveCoeObjectDictionary([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wCfgFixedAddress, EC_T_COE_DICTIONARY_DESC \*pDict) Add data types and / or objects to slave’s CoE object dictionary. \_ * **Parameters:** * **dwInstanceId** – [in] Simulator Instance ID * **wCfgFixedAddress** – [in] Slave’s station address * **pDict** – [in] Pointer to dictionary descriptor * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ## esDeleteSlaveCoeObject ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esDeleteSlaveCoeObject([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wCfgFixedAddress, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wObjectIndex) Delete object from slave’s CoE object dictionary. \_ * **Parameters:** * **dwInstanceId** – [in] Simulator Instance ID * **wCfgFixedAddress** – [in] Slave’s station address * **wObjectIndex** – [in] Object index * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ## esClearSlaveCoeObjectDictionary ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esClearSlaveCoeObjectDictionary([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wCfgFixedAddress) Delete all objects from slave’s CoE object dictionary. \_ * **Parameters:** * **dwInstanceId** – [in] Simulator Instance ID * **wCfgFixedAddress** – [in] Slave’s station address * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ## esResetSlaveCoeObjectDictionary ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esResetSlaveCoeObjectDictionary([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wCfgFixedAddress) Reset all objects from slave’s CoE object dictionary to default. \_ * **Parameters:** * **dwInstanceId** – [in] Simulator Instance ID * **wCfgFixedAddress** – [in] Slave’s station address * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ## esSetSlaveCoeObjectTransferCallbacks ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esSetSlaveCoeObjectTransferCallbacks([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wCfgFixedAddress, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wObjectIndex, [EC_T_PF_COE_READ_CB](api_mailbox.html.md#_CPPv419EC_T_PF_COE_READ_CB) pfRead, [EC_T_PF_COE_WRITE_CB](api_mailbox.html.md#_CPPv420EC_T_PF_COE_WRITE_CB) pfWrite, EC_T_VOID \*pvContext) Set SDO upload / download transfer callbacks. #### NOTE pfRead / pfWrite can also be registered if object dictionary unavailable at EC-Simulator. [esClearSlaveCoeObjectDictionary()](api_mailbox.html.md#da/dca/_ec_simulator_api_8cpp_1a2100ae59345a76d35218bd66d6d754cf) has to be called first. See [esClearSlaveCoeObjectDictionary()](api_mailbox.html.md#da/dca/_ec_simulator_api_8cpp_1a2100ae59345a76d35218bd66d6d754cf). In case of using an ENI and the simulator’s default dictionary wObjectIndex must be set to 0xFFFF. * **Parameters:** * **dwInstanceId** – [in] Simulator Instance ID * **wCfgFixedAddress** – [in] Slave’s station address. 0: all slaves. * **wObjectIndex** – [in] Object index. 0xffff: all objects * **pfRead** – [in] Upload callback function * **pfWrite** – [in] Download callback function * **pvContext** – [in] Pointer to context passed as first parameters to callback functions * **dwInstanceId** – **[in]** Simulator Instance ID * **wCfgFixedAddress** – **[in]** Slave’s station address. 0: All slaves. * **wObjectIndex** – **[in]** Object index. 0xFFFF: all objects. * **pfRead** – **[in]** Upload callback function. EC_NULL: clears callback if already registered. * **pfWrite** – **[in]** Download callback function. EC_NULL: clears callback if already registered. * **pvContext** – **[in]** Arbitrarily application-defined parameter passed to transfer callback functions * **Returns:** * [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116): Success * [EC_E_INVALIDPARM](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga1e10d9022db11a708658c71b0dead2fe): if dwInstanceId is out of range * [EC_E_INVALIDSTATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga2a6310e052fca1b94797e8e26f031739): if simulator instance (dwInstanceId) not initialized, see [esInitSimulator()](api_general.html.md#da/dca/_ec_simulator_api_8cpp_1a9abcdec979e4ebcde0ddc9fd83da2948) * [EC_E_NOTFOUND](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga3113f3b6f82bb50e6ab3cde40268730a): if slave not found in ENI/EXI (wCfgFixedAddress) * [EC_E_NO_MBX_SUPPORT](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga461eba97c1aa71d0d6bc72202035ad98): if slave without Mailbox support * [EC_E_SDO_ABORTCODE_INDEX](error-codes_coe.html.md#df/d91/group___e_c___e_r_r_o_r___c_o_d_e_s___c_o_e_1ga38c3c5e62e8523dd5a294cb58803d804): if nonexistent object (wObjectIndex) #### SEE ALSO - [`esSetSlaveSscApplication()`](api_general.html.md#_CPPv424esSetSlaveSscApplication10EC_T_DWORD9EC_T_WORDP24EC_T_SLAVE_SSC_APPL_DESC) - [`esClearSlaveCoeObjectDictionary()`](api_mailbox.html.md#_CPPv431esClearSlaveCoeObjectDictionary10EC_T_DWORD9EC_T_WORD) ### typedef EC_T_VOID (\*EC_T_PF_COE_READ_CB)(EC_T_VOID \*pvContext, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSimulatorId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wCfgFixedAddress, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wIndex, [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) bySubindex, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSize, [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) \*pbyData, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) \*pdwOutDataLen, [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bCompleteAccess, [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bCheckReadAccess, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) \*pdwErrorCode) CoE Read Object Callback: Handle read requests from the master in the simulator application. The simulator has pre-handled the request and sets pdwErrorCode accordingly. * **Param pvContext:** **[in]** Arbitrarily application-defined parameter passed to callback * **Param dwSimulatorId:** **[in]** Simulator Instance ID * **Param wCfgFixedAddress:** **[in]** Slave fixed address from master request * **Param wIndex:** **[in]** Object Index from master request, e.g. 0x1018 * **Param bySubindex:** **[in]** Object SubIndex from master request * **Param dwSize:** **[in]** Read buffer size according to MbxIn Sync Manager size * **Param pbyData:** **[inout]** Read data buffer: pre-filled by the simulator if the object exists in the simulated slave’s object dictionary and is read-able in the current EtherCAT state * **Param pdwOutDataLen:** **[inout]** Read data length: pre-filled by the simulator if the object exists in the simulated slave’s object dictionary and is read-able in the current EtherCAT state, else the simulator application shall set the value accordingly * **Param bCompleteAccess:** **[in]** EC_TRUE: CoE SDO Upload with Complete Access. See also EC_MAILBOX_FLAG_SDO_COMPLETE. * **Param bCheckReadAccess:** **[in]** EC_TRUE: The simulator application should check the read access, e.g. if the object does not exist in the simulated slave’s object dictionary * **Param pdwErrorCode:** **[inout]** Current transfer error code pre-filled by the simulator. The simulator application shall set the current transfer error accordingly within the callback. * [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116): if object exists in the simulated slave’s object dictionary and is read-able in the current EtherCAT state * [EC_E_SDO_ABORTCODE_INDEX](error-codes_coe.html.md#df/d91/group___e_c___e_r_r_o_r___c_o_d_e_s___c_o_e_1ga38c3c5e62e8523dd5a294cb58803d804): if object does not exist in the simulated slave’s object dictionary and is read-able in the current EtherCAT state * [EC_E_SDO_ABORTCODE_OFFSET](error-codes_coe.html.md#df/d91/group___e_c___e_r_r_o_r___c_o_d_e_s___c_o_e_1gadd3c76fd45406e3cce1cfd0bac5b1210): if object SubIndex does not exist in the accessed object in the simulated slave’s object dictionary * [EC_E_SDO_ABORTCODE_DATA_LENGTH_NOT_MATCH](error-codes_coe.html.md#df/d91/group___e_c___e_r_r_o_r___c_o_d_e_s___c_o_e_1ga81a7871a5686e30272ee67ad08194b90): if the read data length does not match the accessed object length * [EC_E_SDO_ABORTCODE_ACCESS](error-codes_coe.html.md#df/d91/group___e_c___e_r_r_o_r___c_o_d_e_s___c_o_e_1ga69f15f48a4f39407a59175f4ecaa810b): if accessed Entry does not support commanded accesstype e.g. complete access is not supported on simple objects or ENUM descriptions * [EC_E_SDO_ABORTCODE_WRITEONLY](error-codes_coe.html.md#df/d91/group___e_c___e_r_r_o_r___c_o_d_e_s___c_o_e_1ga1df1d4ad8037a803e458faf3f5898cd3): if accessed Entry does not support read operation * [EC_E_SDO_ABORTCODE_TRANSFER_DEVICE_STATE](error-codes_coe.html.md#df/d91/group___e_c___e_r_r_o_r___c_o_d_e_s___c_o_e_1ga389c6c5de9cd017c1ea5feb3468c4e5e): if entry cannot be read in the current EtherCAT state * EC_E_… ### typedef EC_T_VOID (\*EC_T_PF_COE_WRITE_CB)(EC_T_VOID \*pvContext, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSimulatorId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wCfgFixedAddress, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wIndex, [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) bySubindex, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSize, [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) \*pbyData, [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bCompleteAccess, [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bCheckWriteAccess, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) \*pdwErrorCode) CoE Write Object Callback: Handle write requests from the master in the simulator application. The simulator has pre-handled the request and sets pdwErrorCode accordingly. * **Param pvContext:** **[in]** Arbitrarily application-defined parameter passed to callback * **Param dwSimulatorId:** **[in]** Simulator Instance ID * **Param wCfgFixedAddress:** **[in]** Slave fixed address from master request * **Param wIndex:** **[in]** Object Index from master request, e.g. 0x40A2 * **Param bySubindex:** **[in]** Object SubIndex from master request * **Param dwSize:** **[in]** Write data length * **Param pbyData:** **[inout]** Write data buffer: pre-filled by the simulator if the object exists in the simulated slave’s object dictionary and is write-able in the current EtherCAT state * **Param bCompleteAccess:** **[in]** EC_TRUE: CoE SDO Download with Complete Access. See also EC_MAILBOX_FLAG_SDO_COMPLETE. * **Param bCheckWriteAccess:** **[in]** EC_TRUE: The simulator application should check the write access, e.g. if the object does not exist in the simulated slave’s object dictionary * **Param pdwErrorCode:** **[inout]** Current transfer error code pre-filled by the simulator. The simulator application shall set the current transfer error accordingly within the callback. * [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116): if object exists in the simulated slave’s object dictionary and is write-able in the current EtherCAT state * [EC_E_SDO_ABORTCODE_INDEX](error-codes_coe.html.md#df/d91/group___e_c___e_r_r_o_r___c_o_d_e_s___c_o_e_1ga38c3c5e62e8523dd5a294cb58803d804): if object does not exist in the simulated slave’s object dictionary and is write-able in the current EtherCAT state * [EC_E_SDO_ABORTCODE_OFFSET](error-codes_coe.html.md#df/d91/group___e_c___e_r_r_o_r___c_o_d_e_s___c_o_e_1gadd3c76fd45406e3cce1cfd0bac5b1210): if object SubIndex does not exist in the accessed object in the simulated slave’s object dictionary * [EC_E_SDO_ABORTCODE_DATA_LENGTH_NOT_MATCH](error-codes_coe.html.md#df/d91/group___e_c___e_r_r_o_r___c_o_d_e_s___c_o_e_1ga81a7871a5686e30272ee67ad08194b90): if the write data length does not match the accessed object length * [EC_E_SDO_ABORTCODE_ACCESS](error-codes_coe.html.md#df/d91/group___e_c___e_r_r_o_r___c_o_d_e_s___c_o_e_1ga69f15f48a4f39407a59175f4ecaa810b): if accessed Entry does not support commanded accesstype e.g. complete access is not supported on simple objects or ENUM descriptions * [EC_E_SDO_ABORTCODE_READONLY](error-codes_coe.html.md#df/d91/group___e_c___e_r_r_o_r___c_o_d_e_s___c_o_e_1ga01af93e2a2d8a86de098c70057a1ccac): if accessed Entry does not support write operation * [EC_E_SDO_ABORTCODE_TRANSFER_DEVICE_STATE](error-codes_coe.html.md#df/d91/group___e_c___e_r_r_o_r___c_o_d_e_s___c_o_e_1ga389c6c5de9cd017c1ea5feb3468c4e5e): if entry cannot be write in the current EtherCAT state * EC_E_… ## esCoeSdoDownload ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esCoeSdoDownload([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSlaveId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wObIndex, [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) byObSubIndex, const [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) \*pbyData, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwDataLen, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwTimeout, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwFlags) Execute a CoE SDO download to an EtherCAT slave device. This function may not be called from within the JobTask’s context. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **dwSlaveId** – [in] Slave ID * **wObIndex** – [in] Object Index * **byObSubIndex** – [in] Object SubIndex. If Complete Access only 0 or 1 allowed. * **pbyData** – [in] Buffer containing transferred data. Must not be EC_NULL if dwDataLen > 0. * **dwDataLen** – [in] Buffer length [bytes]. Can be 0 for example for array. * **dwTimeout** – [in] Timeout [ms] * **dwFlags** – [in] Mailbox Flags. Bit 0: set if Complete Access (EC_MAILBOX_FLAG_SDO_COMPLETE). * **Returns:** * [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) if successful * [EC_E_INVALIDSTATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga2a6310e052fca1b94797e8e26f031739) if EtherCAT stack isn’t initialized * [EC_E_INVALIDPARM](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga1e10d9022db11a708658c71b0dead2fe) if dwInstanceID is out of range, pbyData is EC_NULL and dwDataLen > 0, or dwTimeout is EC_NOWAIT * [EC_E_NOMEMORY](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga48c2a7b288dc6922a8c0eb116495e1fd) if the mailbox protocol queue of the slave is full * [EC_E_SLAVE_NOT_PRESENT](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga45555d5de25571188a82d2d76c02dd81) if slave not present * [EC_E_NOTFOUND](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga3113f3b6f82bb50e6ab3cde40268730a) if no slave matching dwSlaveId can be found * [EC_E_NO_MBX_SUPPORT](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga461eba97c1aa71d0d6bc72202035ad98) if slave has no mailbox support * [EC_E_INVALID_SLAVE_STATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga9a3a38c9d24ba99a15c7fc3c953e1ff2) if slave is in an invalid state for mailbox transfer * [EC_E_MASTER_RED_STATE_INACTIVE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gae2870f20d370920995e27b2a78171a5e) if Master Redundancy is configured and master is inactive * [EC_E_ADS_IS_RUNNING](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gac053cb32c9b2bee0305b0644ef76e933) if ADS server is running * [CoE SDO error code](error-codes_coe.html.md#df-d91-group-e-c-e-r-r-o-r-c-o-d-e-s-c-o-e) ## esCoeSdoUpload ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esCoeSdoUpload([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSlaveId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wObIndex, [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) byObSubIndex, [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) \*pbyData, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwDataLen, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) \*pdwOutDataLen, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwTimeout, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwFlags) Execute a CoE SDO upload from an EtherCAT slave device to the master. This function may not be called from within the JobTask’s context. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **dwSlaveId** – [in] Slave ID * **wObIndex** – [in] Object index * **byObSubIndex** – [in] Object sub index. If Complete Access only 0 or 1 allowed. * **pbyData** – [out] Buffer receiving transferred data * **dwDataLen** – [in] Buffer length [bytes] * **pdwOutDataLen** – [out] Length of received data [byte] * **dwTimeout** – [in] Timeout [ms] * **dwFlags** – [in] Mailbox Flags. Bit 0: set if Complete Access (EC_MAILBOX_FLAG_SDO_COMPLETE). * **Returns:** * [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) if successful * [EC_E_INVALIDSTATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga2a6310e052fca1b94797e8e26f031739) if EtherCAT stack isn’t initialized * [EC_E_INVALIDPARM](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga1e10d9022db11a708658c71b0dead2fe) if dwInstanceID is out of range, the input pointer is EC_NULL or contains EC_NULL pointer, or dwTimeout is EC_NOWAIT * [EC_E_NOMEMORY](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga48c2a7b288dc6922a8c0eb116495e1fd) if the mailbox protocol queue of the slave is full * [EC_E_SLAVE_NOT_PRESENT](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga45555d5de25571188a82d2d76c02dd81) if slave not present * [EC_E_NOTFOUND](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga3113f3b6f82bb50e6ab3cde40268730a) if no slave matching dwSlaveId can be found * [EC_E_NO_MBX_SUPPORT](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga461eba97c1aa71d0d6bc72202035ad98) if slave has no mailbox support * [EC_E_INVALID_SLAVE_STATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga9a3a38c9d24ba99a15c7fc3c953e1ff2) if slave is in an invalid state for mailbox transfer * [EC_E_MASTER_RED_STATE_INACTIVE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gae2870f20d370920995e27b2a78171a5e) if Master Redundancy is configured and master is inactive * [EC_E_ADS_IS_RUNNING](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gac053cb32c9b2bee0305b0644ef76e933) if ADS server is running * [CoE SDO error code](error-codes_coe.html.md#df-d91-group-e-c-e-r-r-o-r-c-o-d-e-s-c-o-e) ## esCoeGetODList ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esCoeGetODList([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSlaveId, EC_T_COE_ODLIST_TYPE eListType, [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) \*pbyData, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwDataLen, EC_T_COE_ODLIST \*poOdList, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwTimeout) Gets a list of object IDs that are available in a slave. This function may not be called from within the JobTask’s context. #### NOTE The data buffer will receive the slave response containing the list type followed by the list itself. Therefore the buffer must be 2 bytes bigger than the expected list size. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **dwSlaveId** – [in] Slave ID * **eListType** – [in] Which object types shall be transferred * **pbyData** – [out] Buffer receiving transferred data * **dwDataLen** – [in] Buffer length in bytes * **poOdList** – [out] Received OD list object * **dwTimeout** – [in] Timeout [ms] * **Returns:** * [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) if successful * [EC_E_INVALIDSTATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga2a6310e052fca1b94797e8e26f031739) if master isn’t initialized * [EC_E_INVALIDPARM](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga1e10d9022db11a708658c71b0dead2fe) if dwInstanceID is out of range, the input pointer is EC_NULL or contains EC_NULL pointer, or dwTimeout is EC_NOWAIT * [EC_E_NOMEMORY](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga48c2a7b288dc6922a8c0eb116495e1fd) if the mailbox protocol queue of the slave is full * [EC_E_SLAVE_NOT_PRESENT](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga45555d5de25571188a82d2d76c02dd81) if slave not present * [EC_E_NOTFOUND](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga3113f3b6f82bb50e6ab3cde40268730a) if no slave matching dwSlaveId can be found * [EC_E_NO_MBX_SUPPORT](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga461eba97c1aa71d0d6bc72202035ad98) if slave has no mailbox support * [EC_E_INVALID_SLAVE_STATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga9a3a38c9d24ba99a15c7fc3c953e1ff2) if slave is in an invalid state for mailbox transfer * [EC_E_MASTER_RED_STATE_INACTIVE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gae2870f20d370920995e27b2a78171a5e) if Master Redundancy is configured and master is inactive * [EC_E_ADS_IS_RUNNING](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gac053cb32c9b2bee0305b0644ef76e933) if ADS server is running * [CoE SDO error code](error-codes_coe.html.md#df-d91-group-e-c-e-r-r-o-r-c-o-d-e-s-c-o-e) ## esCoeGetODListReq ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esCoeGetODListReq([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, EC_T_MBXTFER \*pMbxTfer, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSlaveId, EC_T_COE_ODLIST_TYPE eListType, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwTimeout) Initiates retrieval of a list of object IDs that are available in a slave and returns immediately. A unique transfer ID must be written into EC_T_MBXTFER.dwTferId. EC_NOTIFY_MBOXRCV is given on completion. #### NOTE The mailbox transfer object will receive the slave response containing the list type followed by the list itself. Therefore the buffer must be 2 bytes bigger than the expected list size. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **pMbxTfer** – [in] Mailbox transfer * **dwSlaveId** – [in] Slave ID * **eListType** – [in] Which object types shall be transferred * **dwTimeout** – [in] Timeout [ms] * **Returns:** * [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) if successful * [EC_E_INVALIDSTATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga2a6310e052fca1b94797e8e26f031739) if EtherCAT stack isn’t initialized * [EC_E_INVALIDPARM](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga1e10d9022db11a708658c71b0dead2fe) if dwInstanceID is out of range, the input pointer is EC_NULL or contains EC_NULL pointer, or dwTimeout is EC_NOWAIT * [EC_E_NOMEMORY](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga48c2a7b288dc6922a8c0eb116495e1fd) if the mailbox protocol queue of the slave is full * [EC_E_SLAVE_NOT_PRESENT](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga45555d5de25571188a82d2d76c02dd81) if slave not present * [EC_E_NOTFOUND](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga3113f3b6f82bb50e6ab3cde40268730a) if no slave matching dwSlaveId can be found * [EC_E_NO_MBX_SUPPORT](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga461eba97c1aa71d0d6bc72202035ad98) if slave has no mailbox support * [EC_E_INVALID_SLAVE_STATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga9a3a38c9d24ba99a15c7fc3c953e1ff2) if slave is in an invalid state for mailbox transfer * [EC_E_MASTER_RED_STATE_INACTIVE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gae2870f20d370920995e27b2a78171a5e) if Master Redundancy is configured and master is inactive * [EC_E_ADS_IS_RUNNING](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gac053cb32c9b2bee0305b0644ef76e933) if ADS server is running * [CoE SDO error code](error-codes_coe.html.md#df-d91-group-e-c-e-r-r-o-r-c-o-d-e-s-c-o-e) ## esCoeGetObjectDesc ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esCoeGetObjectDesc([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSlaveId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wObIndex, [EC_T_CHAR](api.html.md#_CPPv49EC_T_CHAR) \*pchObName, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wObNameLen, [EC_T_COE_OBDESC](api_mailbox.html.md#_CPPv415EC_T_COE_OBDESC) \*poObDesc, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwTimeout) Determines the description of a specific object. This function may not be called from within the JobTask’s context. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **dwSlaveId** – [in] Slave ID * **wObIndex** – [in] Object index * **pchObName** – [out] Buffer receiving object name * **wObNameLen** – [in] Buffer length * **poObDesc** – [out] Received object description object * **dwTimeout** – [in] Timeout [ms] * **Returns:** * [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) if successful * [EC_E_INVALIDSTATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga2a6310e052fca1b94797e8e26f031739) if master isn’t initialized * [EC_E_INVALIDPARM](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga1e10d9022db11a708658c71b0dead2fe) if dwInstanceID is out of range, the input pointer is EC_NULL or contains EC_NULL pointer, or dwTimeout is EC_NOWAIT * [EC_E_NOMEMORY](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga48c2a7b288dc6922a8c0eb116495e1fd) if the mailbox protocol queue of the slave is full * [EC_E_SLAVE_NOT_PRESENT](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga45555d5de25571188a82d2d76c02dd81) if slave not present * [EC_E_NOTFOUND](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga3113f3b6f82bb50e6ab3cde40268730a) if no slave matching dwSlaveId can be found * [EC_E_NO_MBX_SUPPORT](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga461eba97c1aa71d0d6bc72202035ad98) if slave has no mailbox support * [EC_E_INVALID_SLAVE_STATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga9a3a38c9d24ba99a15c7fc3c953e1ff2) if slave is in an invalid state for mailbox transfer * [EC_E_MASTER_RED_STATE_INACTIVE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gae2870f20d370920995e27b2a78171a5e) if Master Redundancy is configured and master is inactive * [EC_E_ADS_IS_RUNNING](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gac053cb32c9b2bee0305b0644ef76e933) if ADS server is running * [CoE SDO error code](error-codes_coe.html.md#df-d91-group-e-c-e-r-r-o-r-c-o-d-e-s-c-o-e) ### struct EC_T_COE_OBDESC ### Public Members ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wObIndex Index in the object dictionary ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wDataType Data type of the object ### [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) byObjCode Object code, see Table 62, ETG.1000 section 6 ### [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) byObjCategory Object category ### [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) byMaxNumSubIndex Maximum sub index number ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wObNameLen Length of the object name ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wStationAddress Station address of the slave ### [EC_T_CHAR](api.html.md#_CPPv49EC_T_CHAR) \*pchObName Object name (not NULL terminated!) ## esCoeGetObjectDescReq ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esCoeGetObjectDescReq([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, EC_T_MBXTFER \*pMbxTfer, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSlaveId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wObIndex, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwTimeout) Initiates retrieval of the description of a specific object and returns immediately. A unique transfer ID must be written into EC_T_MBXTFER.dwTferId. EC_NOTIFY_MBOXRCV is given on completion. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **pMbxTfer** – [in] Mailbox transfer object * **dwSlaveId** – [in] Slave ID * **wObIndex** – [in] Object index * **dwTimeout** – [in] Timeout [ms] * **Returns:** * [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) if successful * [EC_E_INVALIDSTATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga2a6310e052fca1b94797e8e26f031739) if EtherCAT stack isn’t initialized * [EC_E_INVALIDPARM](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga1e10d9022db11a708658c71b0dead2fe) if dwInstanceID is out of range, the input pointer is EC_NULL or contains EC_NULL pointer, or dwTimeout is EC_NOWAIT * [EC_E_NOMEMORY](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga48c2a7b288dc6922a8c0eb116495e1fd) if the mailbox protocol queue of the slave is full * [EC_E_SLAVE_NOT_PRESENT](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga45555d5de25571188a82d2d76c02dd81) if slave not present * [EC_E_NOTFOUND](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga3113f3b6f82bb50e6ab3cde40268730a) if no slave matching dwSlaveId can be found * [EC_E_NO_MBX_SUPPORT](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga461eba97c1aa71d0d6bc72202035ad98) if slave has no mailbox support * [EC_E_INVALID_SLAVE_STATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga9a3a38c9d24ba99a15c7fc3c953e1ff2) if slave is in an invalid state for mailbox transfer * [EC_E_MASTER_RED_STATE_INACTIVE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gae2870f20d370920995e27b2a78171a5e) if Master Redundancy is configured and master is inactive * [EC_E_ADS_IS_RUNNING](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gac053cb32c9b2bee0305b0644ef76e933) if ADS server is running * [CoE SDO error code](error-codes_coe.html.md#df-d91-group-e-c-e-r-r-o-r-c-o-d-e-s-c-o-e) ## esCoeGetEntryDesc ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esCoeGetEntryDesc([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSlaveId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wObIndex, [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) byObSubIndex, [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) byValueInfo, [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) \*pbyData, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wDataLen, [EC_T_COE_ENTRYDESC](api_mailbox.html.md#_CPPv418EC_T_COE_ENTRYDESC) \*poEntryDesc, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwTimeout) Determines the description of a specific object entry. This function may not be called from within the JobTask’s context. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **dwSlaveId** – [in] Slave ID * **wObIndex** – [in] Object index * **byObSubIndex** – [in] Object sub-index * **byValueInfo** – [in] The value info bit mask includes which elements shall be in the response. See Value info flags for available values. * **pbyData** – [out] Buffer receiving additional entry desc data * **wDataLen** – [in] Buffer length in bytes * **poEntryDesc** – [out] Received entry desc object * **dwTimeout** – [in] Timeout [ms] * **Returns:** * [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) if successful * [EC_E_INVALIDSTATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga2a6310e052fca1b94797e8e26f031739) if master isn’t initialized * [EC_E_INVALIDPARM](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga1e10d9022db11a708658c71b0dead2fe) if dwInstanceID is out of range, the input pointer is EC_NULL or contains EC_NULL pointer, or dwTimeout is EC_NOWAIT * [EC_E_NOMEMORY](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga48c2a7b288dc6922a8c0eb116495e1fd) if the mailbox protocol queue of the slave is full * [EC_E_SLAVE_NOT_PRESENT](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga45555d5de25571188a82d2d76c02dd81) if slave not present * [EC_E_NOTFOUND](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga3113f3b6f82bb50e6ab3cde40268730a) if no slave matching dwSlaveId can be found * [EC_E_NO_MBX_SUPPORT](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga461eba97c1aa71d0d6bc72202035ad98) if slave has no mailbox support * [EC_E_INVALID_SLAVE_STATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga9a3a38c9d24ba99a15c7fc3c953e1ff2) if slave is in an invalid state for mailbox transfer * [EC_E_MASTER_RED_STATE_INACTIVE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gae2870f20d370920995e27b2a78171a5e) if Master Redundancy is configured and master is inactive * [EC_E_ADS_IS_RUNNING](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gac053cb32c9b2bee0305b0644ef76e933) if ADS server is running * [CoE SDO error code](error-codes_coe.html.md#df-d91-group-e-c-e-r-r-o-r-c-o-d-e-s-c-o-e) ### struct EC_T_COE_ENTRYDESC ### Public Members ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wObIndex Index in the object dictionary ### [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) byObSubIndex Sub index in the object dictionary ### [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) byValueInfo Bit mask which information is included in pbyData. See Value info flags. ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wDataType Object data type according to ETG.1000 ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wBitLen Object size (number of bits) ### [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) byObAccess Access rights. See Object access flags. ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bRxPdoMapping Object is mappable in a RxPDO ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bTxPdoMapping Object is mappable in a TxPDO ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bObCanBeUsedForBackup Object can be used for backup ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bObCanBeUsedForSettings Object can be used for settings ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wStationAddress Station address of the slave ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wDataLen Size of the remaining object data ### [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) \*pbyData Remaining object data: dwUnitType, pbyDefaultValue, pbyMinValue, pbyMaxValue, pbyDescription (see ETG.1000.5 and ETG.1000.6) See szUnitType, szDefaultValue, szMinValue, szMaxValue, szDescription in CoeReadObjectDictionary() in EcSdoServices.cpp as an example for evaluating EC_T_COE_ENTRYDESC.pbyData. ## esCoeGetEntryDescReq ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esCoeGetEntryDescReq([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, EC_T_MBXTFER \*pMbxTfer, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSlaveId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wObIndex, [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) byObSubIndex, [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) byValueInfo, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwTimeout) Initiates retrieval of the description of a specific object entry and returns immediately. A unique transfer ID must be written into EC_T_MBXTFER.dwTferId. EC_NOTIFY_MBOXRCV is given on completion. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **pMbxTfer** – [in] Mailbox transfer object * **dwSlaveId** – [in] Slave ID * **wObIndex** – [in] Object index * **byObSubIndex** – [in] Object sub-index * **byValueInfo** – [in] The value info bit mask includes which elements shall be in the response. See Value info flags for available values. * **dwTimeout** – [in] Timeout [ms] * **Returns:** * [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) if successful * [EC_E_INVALIDSTATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga2a6310e052fca1b94797e8e26f031739) if EtherCAT stack isn’t initialized * [EC_E_INVALIDPARM](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga1e10d9022db11a708658c71b0dead2fe) if dwInstanceID is out of range, the input pointer is EC_NULL or contains EC_NULL pointer, or dwTimeout is EC_NOWAIT * [EC_E_NOMEMORY](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga48c2a7b288dc6922a8c0eb116495e1fd) if the mailbox protocol queue of the slave is full * [EC_E_SLAVE_NOT_PRESENT](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga45555d5de25571188a82d2d76c02dd81) if slave not present * [EC_E_NOTFOUND](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga3113f3b6f82bb50e6ab3cde40268730a) if no slave matching dwSlaveId can be found * [EC_E_NO_MBX_SUPPORT](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga461eba97c1aa71d0d6bc72202035ad98) if slave has no mailbox support * [EC_E_INVALID_SLAVE_STATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga9a3a38c9d24ba99a15c7fc3c953e1ff2) if slave is in an invalid state for mailbox transfer * [EC_E_MASTER_RED_STATE_INACTIVE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gae2870f20d370920995e27b2a78171a5e) if Master Redundancy is configured and master is inactive * [EC_E_ADS_IS_RUNNING](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gac053cb32c9b2bee0305b0644ef76e933) if ADS server is running * [CoE SDO error code](error-codes_coe.html.md#df-d91-group-e-c-e-r-r-o-r-c-o-d-e-s-c-o-e) ## CoE transfer Simulator and MainDevice Example The following example demonstrates how to handle CoE object transfers within the simulator application: ### **CoE transfer Simulator and MainDevice Example** The following example handlers can be registered at the EC-Simulator: ```cpp /* Length check in application if Object Dictionary unavailable at EC-Simulator */ static EC_T_DWORD myAppCoeObjectGetDataLen( EC_T_VOID* /* pvContext */, EC_T_WORD /* wCfgFixedAddress */, EC_T_WORD wObjectIndex, EC_T_BYTE bySubindex, EC_T_BOOL /* bCompleteAccess */, EC_T_DWORD* pdwDataLen) { EC_T_DWORD dwRetVal = EC_E_SDO_ABORTCODE_INDEX; /* example for 0x1018 Identity Object, SubIndex 1 Vendor ID */ if ((0x1018 == wObjectIndex) && (1 == bySubindex)) { *pdwDataLen = 4; dwRetVal = EC_E_NOERROR; } return dwRetVal; } /* EC_T_PF_COE_READ_CB */ static EC_T_VOID EC_FNCALL myAppCoeReadObjectCallback( EC_T_VOID* pvContext, EC_T_DWORD /* dwSimulatorId */, EC_T_WORD wCfgFixedAddress, EC_T_WORD wObjectIndex, EC_T_BYTE bySubindex, EC_T_DWORD dwBufSize, EC_T_BYTE* pbyData, EC_T_DWORD* pdwOutDataLen, EC_T_BOOL bCompleteAccess, EC_T_BOOL bCheckReadAccess /* EC_TRUE: Object Dictionary unavailable at EC-Simulator */, EC_T_DWORD* pdwErrorCode /* see EC_E_SDO_ABORTCODE_... */) { EC_T_DWORD dwDataLen = *pdwOutDataLen; /* check transfer parameters in application if Object Dictionary unavailable at EC-Simulator */ if (bCheckReadAccess) { *pdwErrorCode = myAppCoeObjectGetDataLen(pvContext, wCfgFixedAddress, wObjectIndex, bySubindex, bCompleteAccess, &dwDataLen); if ((EC_E_NOERROR == *pdwErrorCode) && (dwBufSize < dwDataLen)) { *pdwErrorCode = EC_E_SDO_ABORTCODE_DATA_LENGTH_TOO_LOW; } } if (EC_E_NOERROR == *pdwErrorCode) { /* provide data. example for 0x1018 Identity Object, SubIndex 1 Vendor ID */ if ((0x1018 == wObjectIndex) && (1 == bySubindex)) { OsDbgAssert(4 == dwDataLen); EC_SET_FRM_DWORD((EC_T_DWORD*)pbyData, 0x12345678); } } else { dwDataLen = 0; } *pdwOutDataLen = dwDataLen; return; } /* EC_T_PF_COE_WRITE_CB */ static EC_T_VOID EC_FNCALL myAppCoeWriteObjectCallback( EC_T_VOID* /* pvContext */, EC_T_DWORD /* dwSimulatorId */, EC_T_WORD /* wCfgFixedAddress */, EC_T_WORD wObjectIndex, EC_T_BYTE bySubindex, EC_T_DWORD dwSize, EC_T_BYTE* pbyData, EC_T_BOOL /* bCompleteAccess */, EC_T_BOOL bCheckWriteAccess /* EC_TRUE if Object Dictionary unavailable at EC-Simulator */, EC_T_DWORD* pdwErrorCode) { OsDbgAssert(!bCheckWriteAccess /* Object Dictionary available */ || (EC_E_SDO_ABORTCODE_INDEX == *pdwErrorCode)); if ((0x2000 == wObjectIndex) && (0 == bySubindex)) { /* check write access if Object Dictionary unavailable at EC-Simulator */ if (bCheckWriteAccess && (2 != dwSize)) { if (dwSize > 2) { *pdwErrorCode = EC_E_SDO_ABORTCODE_DATA_LENGTH_TOO_HIGH; } else { *pdwErrorCode = EC_E_SDO_ABORTCODE_DATA_LENGTH_TOO_LOW; } return; } /* handle data, e.g. myCoeSdoWrite(wObjectIndex, bySubindex, pbyData); */ EcLogMsg(EC_LOG_LEVEL_INFO, (pEcLogContext, EC_LOG_LEVEL_INFO, "myAppCoeWriteObjectCallback: 0x%04X, %d: 0x%04X)\n", wObjectIndex, bySubindex, EC_GET_FRM_WORD(pbyData))); *pdwErrorCode = EC_E_NOERROR; return; } } ``` The following example demonstrates objects transfers between MainDevice and Simulator: ```cpp EC_T_DWORD dwRes = EC_E_ERROR; EC_T_DWORD dwRetVal = EC_E_ERROR; EC_T_BYTE abyWriteData[sizeof(EC_T_WORD)]; EC_T_BYTE abyReadData[sizeof(EC_T_DWORD)]; EC_T_DWORD dwDataOutLen = 0; OsMemset(abyWriteData, 0, sizeof(abyWriteData)); OsMemset(abyReadData, 0, sizeof(abyReadData)); /* EC-Simulator: clear Object Dictionary */ dwRes = esClearSlaveCoeObjectDictionary(dwSimulatorId, wSlaveAddress); if (dwRes != EC_E_NOERROR) { EcLogMsg(EC_LOG_LEVEL_ERROR, (pEcLogContext, EC_LOG_LEVEL_ERROR, "esClearSlaveCoeObjectDictionary failed: %s (0x%lx))\n", esGetText(dwSimulatorId, dwRes), dwRes)); dwRetVal = dwRes; goto Exit; } /* EC-Simulator: register CoE handlers */ dwRes = esSetSlaveCoeObjectTransferCallbacks(dwSimulatorId, wSlaveAddress, 0xFFFF /* all objects */, myAppCoeReadObjectCallback, myAppCoeWriteObjectCallback, pAppContext); if (dwRes != EC_E_NOERROR) { EcLogMsg(EC_LOG_LEVEL_ERROR, (pEcLogContext, EC_LOG_LEVEL_ERROR, "esSetSlaveCoeObjectTransferCallbacks failed: %s (0x%lx))\n", esGetText(dwSimulatorId, dwRes), dwRes)); dwRetVal = dwRes; goto Exit; } /* EC-Master: set PREOP state */ dwRes = emSetMasterState(dwMasterId, 30000, eEcatState_PREOP); if (dwRes != EC_E_NOERROR) { EcLogMsg(EC_LOG_LEVEL_ERROR, (pEcLogContext, EC_LOG_LEVEL_ERROR, "emSetMasterState failed: %s (0x%lx))\n", ecatGetText(dwRes), dwRes)); dwRetVal = dwRes; goto Exit; } /* EC-Master: write CoE to slave */ EC_SET_FRM_WORD(abyWriteData, 0x1234 /* example value */); dwRes = emCoeSdoDownload(dwMasterId, emGetSlaveId(dwMasterId, wSlaveAddress), 0x2000, 0, abyWriteData, sizeof(EC_T_WORD), 5000 /* timeout */, 0); if (dwRes != EC_E_NOERROR) { EcLogMsg(EC_LOG_LEVEL_ERROR, (pEcLogContext, EC_LOG_LEVEL_ERROR, "emCoeSdoDownload failed: %s (0x%lx))\n", ecatGetText(dwRes), dwRes)); dwRetVal = dwRes; goto Exit; } /* EC-Master: read CoE from slave */ EC_SET_FRM_DWORD(abyReadData, 0); dwRes = emCoeSdoUpload(dwMasterId, emGetSlaveId(dwMasterId, wSlaveAddress), 0x1018, 1 /* vendor id */, abyReadData, sizeof(EC_T_DWORD), &dwDataOutLen, 5000 /* timeout */, 0); if (dwRes != EC_E_NOERROR) { EcLogMsg(EC_LOG_LEVEL_ERROR, (pEcLogContext, EC_LOG_LEVEL_ERROR, "emCoeSdoUpload failed: %s (0x%lx))\n", ecatGetText(dwRes), dwRes)); dwRetVal = dwRes; goto Exit; } /* EC-Simulator: write CoE to slave */ EC_SET_FRM_WORD(abyWriteData, 0x1234 /* example value */); dwRes = esCoeSdoDownload(dwSimulatorId, esGetSlaveId(dwSimulatorId, wSlaveAddress), 0x2000, 0, abyWriteData, sizeof(EC_T_WORD), 5000 /* timeout */, 0); if (dwRes != EC_E_NOERROR) { EcLogMsg(EC_LOG_LEVEL_ERROR, (pEcLogContext, EC_LOG_LEVEL_ERROR, "esCoeSdoDownload failed: %s (0x%lx))\n", ecatGetText(dwRes), dwRes)); dwRetVal = dwRes; goto Exit; } /* EC-Simulator: read CoE from slave */ EC_SET_FRM_DWORD(abyReadData, 0); dwRes = esCoeSdoUpload(dwSimulatorId, esGetSlaveId(dwSimulatorId, wSlaveAddress), 0x1018, 1 /* vendor id */, abyReadData, sizeof(EC_T_DWORD), &dwDataOutLen, 5000 /* timeout */, 0); if (dwRes != EC_E_NOERROR) { EcLogMsg(EC_LOG_LEVEL_ERROR, (pEcLogContext, EC_LOG_LEVEL_ERROR, "emCoeSdoUpload failed: %s (0x%lx))\n", ecatGetText(dwRes), dwRes)); dwRetVal = dwRes; goto Exit; } ``` # Ethernet over EtherCAT® (EoE) To handle EoE frames within the application, the callback pfnEoeReceive must be registered using [`esSetSlaveSscApplication()`](api_general.html.md#_CPPv424esSetSlaveSscApplication10EC_T_DWORD9EC_T_WORDP24EC_T_SLAVE_SSC_APPL_DESC), e.g. in `myAppPrepare()` of EcSimulatorHilDemo / EcSimulatorSilDemo. See also [EoE Ping Example](api_mailbox.html.md#eoe-ping-example) ## esEoeSendFrame ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esEoeSendFrame([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wCfgFixedAddress, [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) \*pbyFrame, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwFrameLen) Send EoE frame (queued) \_ * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ## esGetCfgSlaveEoeInfo ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esGetCfgSlaveEoeInfo([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bFixedAddressing, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wSlaveAddress, [EC_T_CFG_SLAVE_EOE_INFO](api_mailbox.html.md#_CPPv423EC_T_CFG_SLAVE_EOE_INFO) \*pSlaveEoeInfo) Return EoE information about a configured slave from the ENI file. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **bFixedAddressing** – [in] EC_TRUE: use station address, EC_FALSE: use AutoInc address * **wSlaveAddress** – [in] Slave address according bFixedAddressing * **pSlaveEoeInfo** – [out] Information about the slave * **Returns:** * [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) if successful * [EC_E_INVALIDSTATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga2a6310e052fca1b94797e8e26f031739) if EtherCAT stack isn’t initialized * [EC_E_INVALIDPARM](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga1e10d9022db11a708658c71b0dead2fe) if dwInstanceID is out of range * [EC_E_NOTFOUND](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga3113f3b6f82bb50e6ab3cde40268730a) if no slave matching bFixedAddressing / wSlaveAddress can be found * [EC_E_NO_MBX_SUPPORT](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga461eba97c1aa71d0d6bc72202035ad98) if the slave does not support mailbox communication * [EC_E_NO_EOE_SUPPORT](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gae1e7c653cdf6275070be88c546b34ce1) if the slave supports mailbox communication, but not EoE \\newpage Content of [`EC_T_CFG_SLAVE_EOE_INFO`](api_mailbox.html.md#_CPPv423EC_T_CFG_SLAVE_EOE_INFO) is subject to be extended. ### struct EC_T_CFG_SLAVE_EOE_INFO ### Public Members ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSlaveId [out] Slave ID ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bMacAddr [out] Indicates whether the MAC address could be read and is valid ### [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) abyMacAddr[6] [out] MAC address ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bIpAddr [out] Indicates whether the IP address could be read and is valid ### [EC_T_IPADDR](software-integration_ras-server.html.md#_CPPv411EC_T_IPADDR) oIpAddr [out] IP address ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bSubnetMask [out] Indicates whether the subnet mask could be read and is valid ### [EC_T_IPADDR](software-integration_ras-server.html.md#_CPPv411EC_T_IPADDR) oSubnetMask [out] Subnet mask ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bDefaultGateway [out] Indicates whether the default gateway could be read and is valid ### [EC_T_IPADDR](software-integration_ras-server.html.md#_CPPv411EC_T_IPADDR) oDefaultGateway [out] Default gateway ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bDnsServer [out] Indicates whether the DNS server could be read and is valid ### [EC_T_IPADDR](software-integration_ras-server.html.md#_CPPv411EC_T_IPADDR) oDnsServer [out] DNS server ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bDnsName [out] Indicates whether the DNS name could be read and is valid ### [EC_T_CHAR](api.html.md#_CPPv49EC_T_CHAR) szDnsName[32] [out] DNS name ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bDisableEoe [out] Indicates whether the EoE is Disabled or not \\newpage ### **esGetCfgSlaveEoeInfo() Example** ```cpp EC_T_CFG_SLAVE_EOE_INFO oInfo; OsMemset(&oInfo, 0, sizeof(EC_T_CFG_SLAVE_EOE_INFO)); dwRes = esGetCfgSlaveEoeInfo(pAppContext->dwInstanceId, EC_TRUE, wSlaveAddress, &oInfo); if (dwRes != EC_E_NOERROR) { EcLogMsg(EC_LOG_LEVEL_ERROR, (pEcLogContext, EC_LOG_LEVEL_ERROR, "esGetCfgSlaveEoeInfo failed: %s (0x%lx))\n", esGetText(pAppContext->dwInstanceId, dwRes), dwRes)); dwRetVal = dwRes; goto Exit; } EcLogMsg(EC_LOG_LEVEL_INFO, (pEcLogContext, EC_LOG_LEVEL_INFO, "esGetCfgSlaveEoeInfo(%d): " "MAC address: %02X:%02X:%02X:%02X:%02X:%02X, IP address: %d.%d.%d.%d, subnet mask: %d.%d.%d.%d, " "default gateway: %d.%d.%d.%d, DNS server: %d.%d.%d.%d, DNS name: %s\n", wSlaveAddress, oInfo.abyMacAddr[0], oInfo.abyMacAddr[1], oInfo.abyMacAddr[2], oInfo.abyMacAddr[3], oInfo.abyMacAddr[4], oInfo.abyMacAddr[5], oInfo.oIpAddr.sAddr.by[0], oInfo.oIpAddr.sAddr.by[1], oInfo.oIpAddr.sAddr.by[2], oInfo.oIpAddr.sAddr.by[3], oInfo.oSubnetMask.sAddr.by[0], oInfo.oSubnetMask.sAddr.by[1], oInfo.oSubnetMask.sAddr.by[2], oInfo.oSubnetMask.sAddr.by[3], oInfo.oDefaultGateway.sAddr.by[0], oInfo.oDefaultGateway.sAddr.by[1], oInfo.oDefaultGateway.sAddr.by[2], oInfo.oDefaultGateway.sAddr.by[3], oInfo.oDnsServer.sAddr.by[0], oInfo.oDnsServer.sAddr.by[1], oInfo.oDnsServer.sAddr.by[2], oInfo.oDnsServer.sAddr.by[3], oInfo.szDnsName)); ``` \\newpage ## EoE Ping Example The following example demonstrates how to customize EoE simulation using [`esSetSlaveSscApplication()`](api_general.html.md#_CPPv424esSetSlaveSscApplication10EC_T_DWORD9EC_T_WORDP24EC_T_SLAVE_SSC_APPL_DESC) and [`esEoeSendFrame()`](api_mailbox.html.md#_CPPv414esEoeSendFrame10EC_T_DWORD9EC_T_WORDP9EC_T_BYTE10EC_T_DWORD). ### **EoE Ping Example** The following code demonstrates how to receive EoE frames from the MainDevice and send answers back. ```cpp /********************************************************************************/ /** \brief EoE ARP request and PING request context structure */ typedef struct _T_MY_EOE_CONTEXT { T_EC_DEMO_APP_CONTEXT* pAppContext; EC_T_WORD wSlaveAddress; ETHERNET_ADDRESS oMacAddress; EC_T_IPADDR oIpV4Address; EC_T_LINK_FRAMEDESC oSendFrame; } T_MY_EOE_CONTEXT; /********************************************************************************/ /** \brief EoE ARP request and PING request handler * * \return pReplyFrameDesc->dwSize > 0 if handled with reply */ static EC_T_VOID myAppProcessEoeFrameArpAndPing(EC_T_LINK_FRAMEDESC* pRequestFrameDesc, EC_T_LINK_FRAMEDESC* pReplyFrameDesc, ETHERNET_ADDRESS MacAddress, EC_T_IPADDR IpV4Address) { ETHERNET_FRAME* pRequest = (ETHERNET_FRAME*)pRequestFrameDesc->pbyFrame; ETHERNET_FRAME* pReply = (ETHERNET_FRAME*)pReplyFrameDesc->pbyFrame; /* prepare reply */ OsMemcpy(pReply, pRequest, pRequestFrameDesc->dwSize); pReply->Destination = pRequest->Source; pReply->Source = MacAddress; pReplyFrameDesc->dwSize = 0; /* handle ARP / ping */ switch (EC_ETHFRM_GET_FRAMETYPE(pRequest)) { case ETHERNET_FRAME_TYPE_ARP: { EC_ARP_IP_HEADER* pArpRequest = (EC_ARP_IP_HEADER*)EC_ENDOF(pRequest); /* skip ETHERNET_FRAME header */ EC_ARP_IP_HEADER* pArpReply = (EC_ARP_IP_HEADER*)EC_ENDOF(pReply); /* skip ETHERNET_FRAME header */ /* only Ethernet MAC and IPv4 ARP requests supported */ if ((EC_NTOHS(pArpRequest->wHwAddressType) == EC_ARP_HW_TYPE_ETHERNET) && (EC_NTOHS(pArpRequest->wProtocolType) == ETHERNET_FRAME_TYPE_IP) && (pArpRequest->byHwAddressLength == ETHERNET_ADDRESS_LEN) && (pArpRequest->byProtocolAddressLength == EC_IPv4_ADDRESS_LEN) && (EC_NTOHS(pArpRequest->wOpCode) == EC_ARP_OPCODE_REQUEST)) { /* only answer ARP request if IP address matches */ if ((BroadcastEthernetAddress == pRequest->Destination) && (pArpRequest->Address.IpV4.DestinationIp == IpV4Address)) { pArpReply->Address.IpV4.DestinationMac = pArpRequest->Address.IpV4.SourceMac; pArpReply->Address.IpV4.SourceMac = MacAddress; pArpReply->Address.IpV4.DestinationIp = pArpRequest->Address.IpV4.SourceIp; pArpReply->Address.IpV4.SourceIp = IpV4Address; pArpReply->wOpCode = EC_HTONS(EC_ARP_OPCODE_REPLY); /* reply valid */ pReplyFrameDesc->dwSize = ETHERNET_FRAME_LEN + EC_ARP_IPv4_HEADER_LEN; } } } break; case ETHERNET_FRAME_TYPE_IP: { if (((EC_IP_HEADER*)EC_ENDOF(pRequest))->byProtocol == EC_IP_PROTOCOL_ICMP) { EC_ICMP_HEADER* pIcmpRequest = (EC_ICMP_HEADER*)EC_ENDOF(pRequest); /* skip ETHERNET_FRAME header */ EC_ICMP_HEADER* pIcmpReply = (EC_ICMP_HEADER*)EC_ENDOF(pReply); /* skip ETHERNET_FRAME header */ /* only answer PING request if MAC address and IP address match */ if ((pIcmpRequest->byType == EC_ICMP_TYPE_ECHO) && (pRequest->Destination == MacAddress) && (pIcmpRequest->IpHdr.dwDstAddr == IpV4Address)) { EC_T_WORD wLen = EC_NTOHS(pIcmpRequest->IpHdr.wTotalLength); /* swap src and dest ip address */ pIcmpReply->IpHdr.dwSrcAddr = pIcmpRequest->IpHdr.dwDstAddr; pIcmpReply->IpHdr.dwDstAddr = pIcmpRequest->IpHdr.dwSrcAddr; pIcmpReply->byType = EC_ICMP_TYPE_ECHO_REPLY; pIcmpReply->IpHdr.wCheckSum = 0; #if __GNUC__ >= 9 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Waddress-of-packed-member" #endif pIcmpReply->IpHdr.wCheckSum = EC_HTONS(EcCalculateCrcRfc1071((EC_T_WORD*)&pIcmpReply->IpHdr, EC_IP_HEADER_MINIMUM_LEN)); #if __GNUC__ >= 9 #pragma GCC diagnostic pop #endif pIcmpRequest->wCheckSum = 0; pIcmpRequest->wCheckSum = EC_HTONS(EcCalculateCrcRfc1071((EC_T_WORD*)&pIcmpReply->byType /* skip IpHdr */, (EC_T_WORD)(wLen - EC_IP_HEADER_MINIMUM_LEN))); /* reply valid */ pReplyFrameDesc->dwSize = (EC_T_WORD)(ETHERNET_FRAME_LEN + wLen); } } } break; } } static EC_T_VOID myAppEoe_APPL_EoeReceive(EC_T_VOID* pvContext, EC_T_DWORD dwSimulatorId, EC_T_WORD wCfgFixedAddress, EC_T_WORD* pwFrame, EC_T_WORD wFrameSize) { T_MY_EOE_CONTEXT* poContext = (T_MY_EOE_CONTEXT*)pvContext; EC_T_LINK_FRAMEDESC oReceiveFrame; oReceiveFrame.pbyFrame = (EC_T_BYTE*)pwFrame; oReceiveFrame.dwSize = wFrameSize; /* call ARP request and ping request handler and send reply if filled by handler */ myAppProcessEoeFrameArpAndPing(&oReceiveFrame, &poContext->oSendFrame, poContext->oMacAddress, poContext->oIpV4Address); if (poContext->oSendFrame.dwSize > 0) { esEoeSendFrame(dwSimulatorId, wCfgFixedAddress, poContext->oSendFrame.pbyFrame, poContext->oSendFrame.dwSize); } } static EC_T_VOID myAppEoe_APPL_EoeSettingInd(EC_T_VOID* pvContext, EC_T_DWORD /* dwSimulatorId */, EC_T_WORD /* wCfgFixedAddress */, EC_T_WORD* pwMacAddress, EC_T_WORD* pwIpV4Address, EC_T_WORD* /* pwIpV4SubNetMask */, EC_T_WORD* /* pwIpV4DefaultGateway */, EC_T_WORD* /* pwDnsIpV4Address */) { T_MY_EOE_CONTEXT* poContext = (T_MY_EOE_CONTEXT*)pvContext; poContext->oMacAddress = *((ETHERNET_ADDRESS*)pwMacAddress); poContext->oIpV4Address.dwAddr = EC_GETDWORD(pwIpV4Address); } static EC_INLINESTART EC_T_DWORD myAppEoeInit(T_EC_DEMO_APP_CONTEXT* pAppContext, T_MY_EOE_CONTEXT* poContext, EC_T_WORD wSlaveAddress) { EC_T_DWORD dwRetVal = EC_E_ERROR; EC_T_DWORD dwRes = EC_E_ERROR; poContext->pAppContext = pAppContext; poContext->wSlaveAddress = wSlaveAddress; poContext->oSendFrame.pbyFrame = (EC_T_BYTE*)OsMalloc(ETHERNET_MAX_FRAMEBUF_LEN /* 1536 */); if (EC_NULL == poContext->oSendFrame.pbyFrame) { dwRetVal = EC_E_NOMEMORY; goto Exit; } { struct _EC_T_SLAVE_SSC_APPL_DESC oSlaveApplDesc; OsMemset(&oSlaveApplDesc, 0, sizeof(struct _EC_T_SLAVE_SSC_APPL_DESC)); oSlaveApplDesc.dwSignature = SIMULATOR_SIGNATURE; oSlaveApplDesc.dwSize = sizeof(struct _EC_T_SLAVE_SSC_APPL_DESC); oSlaveApplDesc.szName = (EC_T_CHAR*)"MyAppEoeSlaveAppl"; oSlaveApplDesc.pvContext = poContext; /* first parameter of static wrapper functions */ oSlaveApplDesc.pfnEoeReceive = myAppEoe_APPL_EoeReceive; oSlaveApplDesc.pfnEoeSettingInd = myAppEoe_APPL_EoeSettingInd; /* register callbacks at slave */ dwRes = esSetSlaveSscApplication(pAppContext->dwInstanceId, wSlaveAddress, &oSlaveApplDesc); if (EC_E_NOERROR != dwRes) { dwRetVal = dwRes; goto Exit; } } dwRetVal = EC_E_NOERROR; Exit: if (EC_E_NOERROR != dwRetVal) { OsSafeFree(poContext->oSendFrame.pbyFrame); } return dwRetVal; } EC_INLINESTOP ``` The callbacks need a context. Each SubDevice needs its individual context. If there is only one SubDevice to be registered, a global context can be declared and used: ```cpp T_MY_EOE_CONTEXT G_oContext; ``` The callbacks must be registered using [`esSetSlaveSscApplication()`](api_general.html.md#_CPPv424esSetSlaveSscApplication10EC_T_DWORD9EC_T_WORDP24EC_T_SLAVE_SSC_APPL_DESC), e.g. in `myAppPrepare()` of EcSimulatorHilDemo / EcSimulatorSilDemo: ```cpp OsMemset(&G_oContext, 0, sizeof(G_oContext)); dwRes = myAppEoeInit(pAppContext, &G_oContext, wSlaveAddress); if (EC_E_NOERROR != dwRes) { dwRetVal = dwRes; goto Exit; } ``` \\newpage # File access over EtherCAT® (FoE) The following examples demonstrate how to customize FoE simulation using [`esSetSlaveSscApplication()`](api_general.html.md#_CPPv424esSetSlaveSscApplication10EC_T_DWORD9EC_T_WORDP24EC_T_SLAVE_SSC_APPL_DESC). ### **FoE Download Example** The following code demonstrates how to receive FoE from the MainDevice and store it in a buffer. The data received in this example is stored in `T_MY_CONTEXT::abyFileBuf` : ```cpp #define MYAPP_FOE_BUFFER_SIZE (35264) typedef struct { EC_T_BYTE abyFileBuf[MYAPP_FOE_BUFFER_SIZE]; EC_T_WORD wFileBufLen; /* ... */ } T_MY_CONTEXT; ``` The callback `myAppFoeWrite()` handles download requests from the MainDevice, `myAppFoeWriteData()` copies the FoE payload from the mailbox to `T_MY_CONTEXT::abyFileBuf` : ```cpp extern "C" EC_T_WORD EC_FNCALL myAppFoeWrite( EC_T_VOID* pvContext, EC_T_DWORD /* dwSimulatorId */, EC_T_WORD /* wCfgFixedAddress */, EC_T_WORD*, EC_T_WORD, EC_T_DWORD) { T_MY_CONTEXT* poContext = (T_MY_CONTEXT*)pvContext; poContext->wFileBufLen = 0; return 0; /* accept file download (ECAT_FOE_ERRCODE_... denies download) */ } extern "C" EC_T_WORD EC_FNCALL myAppFoeWriteData( EC_T_VOID* pvContext, EC_T_DWORD /* dwSimulatorId */, EC_T_WORD /* wCfgFixedAddress */, EC_T_WORD* pData, EC_T_WORD wSize, EC_T_BYTE bDataFollowing) { T_MY_CONTEXT* poContext = (T_MY_CONTEXT*)pvContext; if (poContext->wFileBufLen + wSize > sizeof(poContext->abyFileBuf)) { return ECAT_FOE_ERRCODE_DISKFULL; /* abort transfer */ } OsMemcpy(&poContext->abyFileBuf[poContext->wFileBufLen], pData, wSize); poContext->wFileBufLen = poContext->wFileBufLen + wSize; /* FoE ACK segment at Master (more segments follow / download finished) */ return bDataFollowing ? SSC_FOE_ACK : SSC_FOE_ACKFINISHED; } ``` See type `EC_PF_SSC_APPL_FOE_WRITE` . The callbacks must be registered using [`esSetSlaveSscApplication()`](api_general.html.md#_CPPv424esSetSlaveSscApplication10EC_T_DWORD9EC_T_WORDP24EC_T_SLAVE_SSC_APPL_DESC), e.g. in `myAppPrepare()` of EcSimulatorHilDemo / EcSimulatorSilDemo: ```cpp struct _EC_T_SLAVE_SSC_APPL_DESC oSlaveApp; OsMemset(&oSlaveApp, 0, sizeof(struct _EC_T_SLAVE_SSC_APPL_DESC)); T_MY_CONTEXT* poSlaveApplContext = &G_oSlaveApplContext; OsMemset(poSlaveApplContext, 0, sizeof(G_oSlaveApplContext)); oSlaveApp.dwSignature = SIMULATOR_SIGNATURE; oSlaveApp.dwSize = sizeof(struct _EC_T_SLAVE_SSC_APPL_DESC); oSlaveApp.szName = (EC_T_CHAR*)"mySlaveAppl"; oSlaveApp.pvContext = poSlaveApplContext; /* pvContext of callbacks */ oSlaveApp.pfnFoeWrite = myAppFoeWrite; oSlaveApp.pfnFoeWriteData = myAppFoeWriteData; /* register SlaveSscApplication call-backs (Master in INIT) */ dwRes = esSetSlaveSscApplication(dwSimulatorId, wSlaveAddress, &oSlaveApp); if (dwRes != EC_E_NOERROR) { goto Exit; } ``` The following code at MainDevice downloads the file to the SubDevice: ```cpp /* set Master PREOP */ dwRes = emSetMasterState(dwMasterId, 30000 /* dwTimeout */, eEcatState_PREOP); if (dwRes != EC_E_NOERROR) { goto Exit; } /* download file */ dwRes = emFoeFileDownload(dwMasterId, emGetSlaveId(dwMasterId, wSlaveAddress), (EC_T_CHAR*)"foe.dat", (EC_T_DWORD)OsStrlen((EC_T_CHAR*)"foe.dat"), G_abyFileBuf, MYAPP_FOE_BUFFER_SIZE, 0 /* dwPassword */, 30000 /* dwTimeout */); if (dwRes != EC_E_NOERROR) { goto Exit; } ``` \\newpage ### **FoE Upload Example** The following code demonstrates how to send FoE data from a local buffer to the MainDevice. The data sent in this example is stored in `T_MY_CONTEXT::abyFileBuf` : ```cpp #define MYAPP_FOE_BUFFER_SIZE (35264) typedef struct { EC_T_BYTE abyFileBuf[MYAPP_FOE_BUFFER_SIZE]; EC_T_WORD wFileBufLen; /* ... */ } T_MY_CONTEXT; ``` `myAppFoeRead()` handles upload requests from the MainDevice, `myAppFoeReadData()` copies the FoE payload from `T_MY_CONTEXT::abyFileBuf` to the mailbox: ```cpp extern "C" EC_T_WORD EC_FNCALL myAppFoeReadData( EC_T_VOID* pvContext, EC_T_DWORD /* dwSimulatorId */, EC_T_WORD /* wCfgFixedAddress */, EC_T_DWORD dwOffset, EC_T_WORD wMaxBlockSize, EC_T_WORD* pData) { T_MY_CONTEXT* poContext = (T_MY_CONTEXT*)pvContext; if (dwOffset > poContext->wFileBufLen) { return 0; } if (dwOffset + wMaxBlockSize > poContext->wFileBufLen) { wMaxBlockSize = EC_LOWORD(poContext->wFileBufLen - dwOffset); } if (wMaxBlockSize > 0) { OsMemcpy(pData, &poContext->abyFileBuf[dwOffset], wMaxBlockSize); } return wMaxBlockSize; /* amount of data read */ } extern "C" EC_T_WORD EC_FNCALL myAppFoeRead( EC_T_VOID* pvContext, EC_T_DWORD dwSimulatorId, EC_T_WORD wCfgFixedAddress, EC_T_WORD*, EC_T_WORD, EC_T_DWORD, EC_T_WORD wMaxBlockSize, EC_T_WORD* pData) { /* APPL_FoeRead contains returning first data */ return myAppFoeReadData(pvContext, dwSimulatorId, wCfgFixedAddress, 0, wMaxBlockSize, pData); } ``` The callbacks must be registered using [`esSetSlaveSscApplication()`](api_general.html.md#_CPPv424esSetSlaveSscApplication10EC_T_DWORD9EC_T_WORDP24EC_T_SLAVE_SSC_APPL_DESC), e.g. in `myAppPrepare()` of EcSimulatorHilDemo / EcSimulatorSilDemo: ```cpp struct _EC_T_SLAVE_SSC_APPL_DESC oSlaveApp; OsMemset(&oSlaveApp, 0, sizeof(struct _EC_T_SLAVE_SSC_APPL_DESC)); T_MY_CONTEXT* poSlaveApplContext = &G_oSlaveApplContext; OsMemset(poSlaveApplContext, 0, sizeof(G_oSlaveApplContext)); /* pattern for file content */ OsMemset(poSlaveApplContext->abyFileBuf, 0xAA, MYAPP_FOE_BUFFER_SIZE); poSlaveApplContext->wFileBufLen = MYAPP_FOE_BUFFER_SIZE; oSlaveApp.dwSignature = SIMULATOR_SIGNATURE; oSlaveApp.dwSize = sizeof(struct _EC_T_SLAVE_SSC_APPL_DESC); oSlaveApp.szName = (EC_T_CHAR*)"mySlaveAppl"; oSlaveApp.pvContext = poSlaveApplContext; /* pvContext of callbacks */ oSlaveApp.pfnFoeRead = myAppFoeRead; oSlaveApp.pfnFoeReadData = myAppFoeReadData; /* register SlaveSscApplication callbacks (Master in INIT) */ dwRes = esSetSlaveSscApplication(dwSimulatorId, wSlaveAddress, &oSlaveApp); if (dwRes != EC_E_NOERROR) { goto Exit; } ``` The following code at MainDevice uploads the file from the SubDevice: ```cpp /* set Master PREOP */ dwRes = emSetMasterState(dwMasterId, 30000 /* dwTimeout */, eEcatState_PREOP); if (dwRes != EC_E_NOERROR) { goto Exit; } /* upload file */ dwRes = emFoeFileUpload(dwMasterId, emGetSlaveId(dwMasterId, wSlaveAddress), (EC_T_CHAR*)"foe.dat", (EC_T_DWORD)OsStrlen((EC_T_CHAR*)"foe.dat"), G_abyFileBuf, MYAPP_FOE_BUFFER_SIZE, &dwOutDataLen, 0 /* dwPassword */, 30000 /* dwTimeout */); if (dwRes != EC_E_NOERROR) { goto Exit; } ``` #### SEE ALSO - [`esInitSimulator()`](api_general.html.md#_CPPv415esInitSimulator10EC_T_DWORDPK25EC_T_SIMULATOR_INIT_PARMS) - [`esConfigureNetwork()`](api_general.html.md#_CPPv418esConfigureNetwork10EC_T_DWORD13EC_T_CNF_TYPE10EC_T_PBYTE10EC_T_DWORD) \\newpage # Vendor specific access over EtherCAT® (VoE) See also [VoE Receive Example](api_mailbox.html.md#voe-receive-example) ## esVoeSend ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esVoeSend([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wCfgFixedAddress, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wDstFixedAddress, const [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) \*pbyData, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwDataLen) Fill “Mailbox In” (SM1) with VoE data to be polled by Master. The slave must have VoE enabled, see ESI: /EtherCATInfo/Descriptions/Devices/Device/Mailbox/VoE, ENI/EXI: /EtherCATConfig/Config/Slave/Mailbox/Protocol/VoE. \_ * **Parameters:** * **dwInstanceId** – [in] Simulator Instance ID * **wCfgFixedAddress** – [in] Slave’s station address * **wDstFixedAddress** – [in] Destination address * **pbyData** – [in] Data * **dwDataLen** – [in] Data length * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ## esSetVoeReceiveCallback ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esSetVoeReceiveCallback([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wCfgFixedAddress, EC_T_PF_VOE_RECEIVE_CB pfVoeReceive, EC_T_VOID \*pvContext) Set VoE data received callback for “Mailbox Out” (SM0). Within the callback, no EC-Simulator API may be called. The slave must have VoE enabled, see ESI: /EtherCATInfo/Descriptions/Devices/Device/Mailbox/VoE, ENI/EXI: /EtherCATConfig/Config/Slave/Mailbox/Protocol/VoE. * **Parameters:** * **dwInstanceId** – [in] Simulator Instance ID * **wCfgFixedAddress** – [in] Slave’s station address * **pfVoeReceive** – [in] Receive callback function * **pvContext** – [in] Receive callback function context * **Returns:** * [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116): on success * [EC_E_NOTFOUND](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga3113f3b6f82bb50e6ab3cde40268730a): if slave not found in ENI/EXI (wCfgFixedAddress) * [EC_E_NO_MBX_SUPPORT](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga461eba97c1aa71d0d6bc72202035ad98): if slave without Mailbox support ## VoE Receive Example The following examples demonstrate how to register a handler for VoE writes from the MainDevice or from other SubDevices. ### **VoE Receive Example** The following code demonstrates how to send VoE from the MainDevice to the SubDevice and store it in a buffer at the Simulator. The data received in this example is stored in `T_MY_CONTEXT::abyVoeBuf` : ```cpp #define MYAPP_VOE_BUFFER_SIZE (512) typedef struct { EC_T_BYTE abyVoeBuf[MYAPP_VOE_BUFFER_SIZE]; EC_T_DWORD dwVoeBufLen; EC_T_VOID* pvEvent; /* ... */ } T_MY_CONTEXT; ``` `myAppVoeReceiveCallback()` handles write requests from the MainDevice and copies the received VoE payload from the mailbox to `T_MY_CONTEXT::abyVoeBuf` : ```cpp EC_T_BYTE EC_FNCALL myAppVoeReceiveCallback( EC_T_VOID* pvContext, EC_T_DWORD /* dwSimulatorId */, EC_T_WORD /* wCfgFixedAddress VoE receiver address, e.g. 1001 */, EC_T_WORD /* wSrcFixedAddress VoE sender address, 0: Master */, const EC_T_BYTE* pbyData, EC_T_DWORD dwDataLen) { T_MY_CONTEXT* poContext = (T_MY_CONTEXT*)pvContext; OsMemcpy(poContext->abyVoeBuf, pbyData, EC_AT_MOST(MYAPP_VOE_BUFFER_SIZE, dwDataLen)); poContext->dwVoeBufLen = dwDataLen; /* No EC-Simulator APIs may be issued from within the callback context. Signalize VoE data received for deferred processing in other thread. */ OsSetEvent(poContext->pvEvent); return 0; } ``` The following code shows how to register `myAppVoeReceiveCallback()` and send VoE from the MainDevice to the simulated SubDevice: ```cpp EC_T_DWORD dwRes = EC_E_ERROR; EC_T_DWORD dwRetVal = EC_E_ERROR; #define MYAPP_VOE_SEND_BUF_LEN sizeof(EC_T_DWORD) EC_T_BYTE abyVoeSendBuf[MYAPP_VOE_SEND_BUF_LEN]; OsMemset(abyVoeSendBuf, 0, MYAPP_VOE_SEND_BUF_LEN); T_MY_CONTEXT oContext; OsMemset(&oContext, 0, sizeof(T_MY_CONTEXT)); oContext.pvEvent = OsCreateEvent(); if (EC_NULL == oContext.pvEvent) { EcLogMsg(EC_LOG_LEVEL_ERROR, (pEcLogContext, EC_LOG_LEVEL_ERROR, "OsCreateEvent failed\n")); dwRetVal = EC_E_NOMEMORY; goto Exit; } /* EC-Simulator: register VoE handler */ dwRes = esSetVoeReceiveCallback(dwSimulatorId, 1001, myAppVoeReceiveCallback, &oContext); if (dwRes != EC_E_NOERROR) { EcLogMsg(EC_LOG_LEVEL_ERROR, (pEcLogContext, EC_LOG_LEVEL_ERROR, "esSetVoeReceiveCallback failed: %s (0x%lx))\n", esGetText(dwSimulatorId, dwRes), dwRes)); dwRetVal = dwRes; goto Exit; } /* EC-Master: set PREOP state */ dwRes = emSetMasterState(dwMasterId, 30000, eEcatState_PREOP); if (dwRes != EC_E_NOERROR) { EcLogMsg(EC_LOG_LEVEL_ERROR, (pEcLogContext, EC_LOG_LEVEL_ERROR, "emSetMasterState failed: %s (0x%lx))\n", ecatGetText(dwRes), dwRes)); dwRetVal = dwRes; goto Exit; } /* send VoE to slave */ EC_SET_FRM_DWORD(abyVoeSendBuf, 0x12345678); dwRes = emVoeWrite(dwMasterId, emGetSlaveId(dwMasterId, 1001), abyVoeSendBuf, MYAPP_VOE_SEND_BUF_LEN, 5000); if (dwRes != EC_E_NOERROR) { EcLogMsg(EC_LOG_LEVEL_ERROR, (pEcLogContext, EC_LOG_LEVEL_ERROR, "emVoeWrite failed: %s (0x%lx))\n", ecatGetText(dwRes), dwRes)); dwRetVal = dwRes; goto Exit; } /* wait for slave received data in callback */ dwRes = OsWaitForEvent(oContext.pvEvent, 5000); if (dwRes != EC_E_NOERROR) { EcLogMsg(EC_LOG_LEVEL_ERROR, (pEcLogContext, EC_LOG_LEVEL_ERROR, "OsWaitForEvent failed: %s (0x%lx))\n", esGetText(dwSimulatorId, dwRes), dwRes)); dwRetVal = dwRes; goto Exit; } dwRetVal = EC_E_NOERROR; Exit: OsSafeDeleteEvent(oContext.pvEvent); ``` # api_network_operation_functions.html.md # Network operation functions ## esConnectPorts ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esConnectPorts([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceId1, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wCfgFixedAddress1, [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) byPort1, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceId2, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wCfgFixedAddress2, [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) byPort2) Connect a slave ESC port to another slave ESC port or to a network adapter. \_ * **Parameters:** * **dwInstanceId1** – [in] Simulator Instance ID of Port1 * **wCfgFixedAddress1** – [in] Slave’s station address of Port1. 0: network adapter * **byPort1** – [in] ESC port of Port1. 0, 1, 2, 3: port A, port B, port C, port D. * **dwInstanceId2** – [in] Simulator Instance ID of Port2 * **wCfgFixedAddress2** – [in] Slave’s station address of Port2. 0: network adapter * **byPort2** – [in] ESC port of Port2. 0, 1, 2, 3: port A, port B, port C, port D. * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ## esDisconnectPort ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esDisconnectPort([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wCfgFixedAddress, [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) byPort) Disconnect a slave ESC port or a network adapter. \_ * **Parameters:** * **dwInstanceId** – [in] Simulator Instance ID * **wCfgFixedAddress** – [in] Slave’s station address. 0: network adapter. * **byPort** – [in] ESC port. 0, 1, 2, 3: port A, port B, port C, port D. * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ## esPowerSlave ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esPowerSlave([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wCfgFixedAddress, [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bOn) Power on or power off a slave. \_ * **Parameters:** * **dwInstanceId** – [in] Simulator Instance ID * **wCfgFixedAddress** – [in] Slave’s station address * **bOn** – [in] EC_FALSE: switch off, EC_TRUE: switch on * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code # api_notifications.html.md # Notifications ## Notification handler The application can register a notification handler using [`esRegisterClient()`](api_general.html.md#_CPPv416esRegisterClient10EC_T_DWORD12EC_PF_NOTIFYP9EC_T_VOIDP20EC_T_REGISTERRESULTS) for notifications as described below. A further important rule exists due to the fact that this callback function is usually called in the context of the EC-Simulator stack timer thread. As the whole EtherCAT® operation is blocked while calling this function the notification handler must not use much CPU time or even call operating system functions that may block. Time consuming operations should be executed in separate application threads. Data structure filled with detailed information about the according notification: ### struct EC_T_NOTIFYPARMS Data structure filled with detailed information about the according notification. ### Public Members ### EC_T_VOID \*pCallerData [in] Client depending caller data parameter. This pointer is one of the parameters when the client registers. ### [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) \*pbyInBuf [in] Notification input parameters ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInBufSize [in] Size of notification input parameters in bytes ### [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) \*pbyOutBuf [out] Buffer for notification output (result) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwOutBufSize [in] Size of buffer at pbyOutBuf in bytes ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) \*pdwNumOutData [out] Amount of bytes written to pbyOutBuf by notification. EC_NULL: amount not set by notification. ## EC_NOTIFY_SLAVE_PRESENCE This notification is given when a SubDevice appears or disappears from the network. **emNotify - EC_NOTIFY_SLAVE_PRESENCE** : **Parameter** : * `pbyInBuf`: [in] Pointer to EC_T_SLAVE_PRESENCE_NTFY_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 Disconnecting the SubDevice from the network, powering it off or a bad connection will generate this notification. ### struct EC_T_SLAVE_PRESENCE_NTFY_DESC ### Public Members ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wStationAddress Slave station address ### [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) bPresent EC_TRUE: present, EC_FALSE: absent ## EC_NOTIFY_SLAVE_STATECHANGED This notification is given when a SubDevice changed its EtherCAT® state. **emNotify - EC_NOTIFY_SLAVES_STATECHANGED** : **Parameter** : * `pbyInBuf`: [in] Pointer to EC_T_SLAVE_STATECHANGED_NTFY_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_SLAVE_STATECHANGED_NTFY_DESC ### Public Members ### EC_T_SLAVE_PROP SlaveProp Slave properties ### EC_T_STATE newState New slave state ## EC_NOTIFY_STATECHANGED This notification is given when the MainDevice changes its EtherCAT® state. **emNotify - EC_NOTIFY_STATECHANGED** : **Parameter** : * `pbyInBuf`: [in] Pointer to data of type EC_T_STATECHANGE which contains the old and the new MainDevice operational state * `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_STATECHANGE ### Public Members ### EC_T_STATE oldState Old operational state ### EC_T_STATE newState New operational state ## EC_NOTIFY_HC_TOPOCHGDONE This notification is given by eUsrJob_SimulatorTimer when the topology changes. **emNotify - EC_NOTIFY_HC_TOPOCHGDONE** : **Parameter** : * `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 #### SEE ALSO [`esPowerSlave()`](api_network_operation_functions.html.md#_CPPv412esPowerSlave10EC_T_DWORD9EC_T_WORD9EC_T_BOOL) , [`esDisconnectPort()`](api_network_operation_functions.html.md#_CPPv416esDisconnectPort10EC_T_DWORD9EC_T_WORD9EC_T_BYTE) , [`esConnectPorts()`](api_network_operation_functions.html.md#_CPPv414esConnectPorts10EC_T_DWORD9EC_T_WORD9EC_T_BYTE10EC_T_DWORD9EC_T_WORD9EC_T_BYTE) ## EC_NOTIFY_SLAVE_ERROR_STATUS_INFO This notification is given when the Error bit on the specific SubDevice is set or cleared Detailed error information is stored in structure [`EC_T_SLAVE_ERROR_INFO_DESC`](api_notifications.html.md#_CPPv426EC_T_SLAVE_ERROR_INFO_DESC) of `EC_T_ERROR_NOTIFICATION_DESC`. ### struct EC_T_SLAVE_ERROR_INFO_DESC ### Public Members ### EC_T_SLAVE_PROP SlaveProp Slave properties ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wStatus Slave Status (AL Status) ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wStatusCode Error status code (AL STATUS CODE) ## EC_NOTIFY_EEPROM_OPERATION This notification is given, when a SubDevice EEPROM is written by the MainDevice. **emNotify - EC_NOTIFY_EEPROM_OPERATION** : **Parameter** : * `pbyInBuf`: [in] Pointer to EC_T_EEPROM_OPERATION_NTFY_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_EEPROM_OPERATION_NTFY_DESC ### Public Members ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwTferId Transfer ID. For every new EEPROM operation a unique ID has to be assigned. This ID can be used after completion to identify the transfer. ### [EC_T_EEPROM_OPERATION_TYPE](api_notifications.html.md#_CPPv426EC_T_EEPROM_OPERATION_TYPE) eType Type of EEPROM operation ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwResult Result of EEPROM operation ### EC_T_SLAVE_PROP SlaveProp Slave properties ### union \_EC_T_EEPROM_OPERATION_NTFY_DESC_RESULT ### struct \_EC_T_EEPROM_OPERATION_NTFY_DESC_RESULT_ACTIVE ### Public Members ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bSlavePDIAccessActive EC_TRUE: EEPROM active by PDI application, EC_FALSE: EEPROM not active ### struct \_EC_T_EEPROM_OPERATION_NTFY_DESC_RESULT_READ ### Public Members ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wEEPRomStartOffset Start address of EEPRom operation. Given by API. ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) \*pwData Pointer to WORD array containing the data. Given by API. ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwReadLen Number of Words to be read. Given by API. ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwNumOutData Number of Words actually read from EEPRom ### struct \_EC_T_EEPROM_OPERATION_NTFY_DESC_RESULT_WRITE ### Public Members ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wEEPRomStartOffset Start address of EEPRom operation. Given by API. ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) \*pwData Pointer to WORD array containing the data. Given by API. ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwWriteLen Number of Words to be written. Given by API. ### enum EC_T_EEPROM_OPERATION_TYPE *Values:* ### enumerator eEEPRomOp_Unknown Unknown EEPROM operation, only for internal use ### enumerator eEEPRomOp_Assign Assign slave EEPROM operation, used by emAssignSlaveEEPRomReq ### enumerator eEEPRomOp_Active Active slave EEPROM operation, used by emActiveSlaveEEPRomReq ### enumerator eEEPRomOp_Read Read slave EEPRom operation, used by emReadSlaveEEPRomReq ### enumerator eEEPRomOp_Write Write slave EEPRom operation, used by emWriteSlaveEEPRomReq ### enumerator eEEPRomOp_Reload Reload slave EEPRom operation, used by emReloadSlaveEEPRomReq ### enumerator eEEPRomOp_Reset Reset slave EEPRom operation, used by emResetSlaveController ## EC_NOTIFY_FRAME_RESPONSE_ERROR This notification is given, when a Ethernet pause frame (MAC control EtherType 0x8808, Control opcode 0x0001) is received. This may occur if any Flow Control mode is active within the network adapter’s native driver settings. **emNotify - EC_NOTIFY_FRAME_RESPONSE_ERROR** : **Parameter** : * `pbyInBuf`: [in] Pointer to EC_T_ERROR_NOTIFICATION_DESC * `dwInBufSize`: [in] SIZEOF_EC_T_ERROR_NOTIFICATION_FRAME_RSPERR * `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_FRAME_RSPERR_DESC ### Public Members ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bIsCyclicFrame Indicates whether the lost frame was a cyclic frame ### [EC_T_FRAME_RSPERR_TYPE](api_notifications.html.md#_CPPv422EC_T_FRAME_RSPERR_TYPE) EErrorType Frame response error type ### [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) byEcCmdHeaderIdxSet Expected IDX value, this value is valid only for acyclic frames in case EErrorType is not equal to eRspErr_UNEXPECTED ### [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) byEcCmdHeaderIdxAct Actually received IDX value, this value is only valid for acyclic frames in case of EErrorType is equal to: eRspErr_WRONG_IDX and eRspErr_UNEXPECTED ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wCycFrameNum Number of the lost cyclic frame from the ENI ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwTaskId Cyclic Task ID (ENI: Cyclic/TaskId). Only valid if bIsCyclicFrame is set ### enum EC_T_FRAME_RSPERR_TYPE *Values:* ### enumerator eRspErr_UNDEFINED Undefined ### enumerator eRspErr_NO_RESPONSE No Ethernet frame received (timeout, frame loss) ### enumerator eRspErr_WRONG_IDX Wrong IDX value in acyclic frame ### enumerator eRspErr_UNEXPECTED Unexpected frame was received ### enumerator eRspErr_FRAME_RETRY Ethernet frame will be re-sent (timeout, frame loss) ### enumerator eRspErr_RETRY_FAIL All retry mechanism fails to re-sent acyclic frames ### enumerator eRspErr_FOREIGN_SRC_MAC Frame with MAC from other Master received ### enumerator eRspErr_NON_ECAT_FRAME Non EtherCAT frame received ### enumerator eRspErr_CRC Ethernet frame with CRC error received ### enumerator eRspErr_ETHERNET_PAUSE_FRAME Ethernet pause frame (flow control) received ## esNotifyApp ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esNotifyApp([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwCode, [EC_T_NOTIFYPARMS](api_notifications.html.md#_CPPv416EC_T_NOTIFYPARMS) \*pParms) Calls the notification callback functions of all registered clients. #### NOTE EC_E_ERROR and EC_E_INVALIDPARM from registered clients’ callback functions are ignored. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **dwCode** – [in] Application specific notification code. dwCode must be <= EC_NOTIFY_APP_MAX_CODE. The callback functions get “EC_NOTIFY_APP | dwCode” as parameter. * **pParms** – [in] Parameter to all callback functions. Note: Output parameters are not transferred from RAS client to RAS server. * **Returns:** [EC_E_ERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gae45dc6c94a43aa671697ecc700555c22) or first error code different from [EC_E_ERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gae45dc6c94a43aa671697ecc700555c22) and [EC_E_INVALIDPARM](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga1e10d9022db11a708658c71b0dead2fe) of registered clients’ callback functions # api_process_data_access_functions.html.md # Process Data Access Functions ## esGetProcessImageInputPtr ### [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) \*esGetProcessImageInputPtr([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID) Gets the process data input image pointer. * **Parameters:** **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **Returns:** Process data input image pointer The size of the process data image input area is returned by [esIoCtl - EC_IOCTL_GET_PDMEMORYSIZE](api_general.html.md#esioctl-ec-ioctl-get-pdmemorysize) and [`esRegisterClient()`](api_general.html.md#_CPPv416esRegisterClient10EC_T_DWORD12EC_PF_NOTIFYP9EC_T_VOIDP20EC_T_REGISTERRESULTS) at [`EC_T_REGISTERRESULTS::dwPDInSize`](api_general.html.md#_CPPv4N20EC_T_REGISTERRESULTS10dwPDInSizeE). #### SEE ALSO - [`esConfigureNetwork()`](api_general.html.md#_CPPv418esConfigureNetwork10EC_T_DWORD13EC_T_CNF_TYPE10EC_T_PBYTE10EC_T_DWORD) - [esIoCtl - EC_IOCTL_GET_PDMEMORYSIZE](api_general.html.md#esioctl-ec-ioctl-get-pdmemorysize) - [esIoCtl - EC_IOCTL_REGISTER_CYCFRAME_RX_CB](api_general.html.md#esioctl-ec-ioctl-register-cycframe-rx-cb) - [`esExecJob()`](api_general.html.md#_CPPv49esExecJob10EC_T_DWORD13EC_T_USER_JOBP19EC_T_USER_JOB_PARMS) ( `eUsrJob_ProcessAllRxFrames`) in case of polling mode ## esGetProcessImageOutputPtr ### [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) \*esGetProcessImageOutputPtr([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID) Gets the process data output image pointer. * **Parameters:** **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **Returns:** Process data output image pointer The size of the process data image output area is returned by [esIoCtl - EC_IOCTL_GET_PDMEMORYSIZE](api_general.html.md#esioctl-ec-ioctl-get-pdmemorysize) and [`esRegisterClient()`](api_general.html.md#_CPPv416esRegisterClient10EC_T_DWORD12EC_PF_NOTIFYP9EC_T_VOIDP20EC_T_REGISTERRESULTS) at [`EC_T_REGISTERRESULTS::dwPDOutSize`](api_general.html.md#_CPPv4N20EC_T_REGISTERRESULTS11dwPDOutSizeE). #### SEE ALSO - [`esConfigureNetwork()`](api_general.html.md#_CPPv418esConfigureNetwork10EC_T_DWORD13EC_T_CNF_TYPE10EC_T_PBYTE10EC_T_DWORD) - [esIoCtl - EC_IOCTL_GET_PDMEMORYSIZE](api_general.html.md#esioctl-ec-ioctl-get-pdmemorysize) - [esIoCtl - EC_IOCTL_REGISTER_CYCFRAME_RX_CB](api_general.html.md#esioctl-ec-ioctl-register-cycframe-rx-cb) - [`esExecJob()`](api_general.html.md#_CPPv49esExecJob10EC_T_DWORD13EC_T_USER_JOBP19EC_T_USER_JOB_PARMS) ( `eUsrJob_ProcessAllRxFrames`) in case of polling mode \\newpage ## EC_COPYBITS ### EC_COPYBITS(pbyDst, nDstBitOffs, pbySrc, nSrcBitOffs, nBitSize) Copies a block of bits from a source buffer to a destination buffer. #### NOTE The memory buffers must be allocated before. The buffers must be big enough to hold the block starting at the given offsets! The buffers are not checked for overrun. * **Parameters:** * **pbyDst** – [out] Destination buffer * **nDstBitOffs** – [in] Bit offset within destination buffer * **pbySrc** – [in] Source buffer * **nSrcBitOffs** – [in] Bit offset within source buffer * **nBitSize** – [in] Block size in bits #### SEE ALSO - [`EC_SETBITS`](api_process_data_access_functions.html.md#c.EC_SETBITS) - [`EC_GETBITS`](api_process_data_access_functions.html.md#c.EC_GETBITS) ![Diagram illustrating the EC_COPYBITS macro copying 22 bits from a source byte array at bit offset 6 to a destination byte array at bit offset 3](../Media/EC_COPYBITS.PNG) ```cpp EC_T_BYTE pbySrc[] = {0xF4, 0xED, 0x69, 0xA5}; EC_T_BYTE pbyDst[] = {0x00, 0x00, 0x00, 0x00}; EC_COPYBITS(pbyDst, 3, pbySrc, 6, 22); /* pbyDst now contains 0xB8 0x3C 0xAC 0x00 */ ``` ## EC_GET_FRM_WORD ### EC_GET_FRM_WORD(ptr) Reads a value of type EC_T_WORD (16 bit) at given pointer. The value is swapped on big endian systems. * **Parameters:** * **ptr** – [in] Source buffer * **Returns:** EC_T_WORD value (16 bit) from buffer ```cpp EC_T_BYTE byFrame[] = {0x01, 0xF4, 0xDD, 0x85, 0x03, 0x00, 0x60, 0xC1, 0x00}; EC_T_WORD wResult = 0; wResult = EC_GET_FRM_WORD(byFrame); /* wResult is 0xF401 on little endian systems */ wResult = EC_GET_FRM_WORD(byFrame + 5); /* wResult is 0x6000 on little endian systems */ wResult = EC_GET_FRM_WORD(byFrame + 2); /* wResult is 0x85DD on little endian systems */ ``` ## EC_GET_FRM_DWORD ### EC_GET_FRM_DWORD(ptr) Reads a value of type EC_T_DWORD (32 bit) at given pointer. The value is swapped on big endian systems. * **Parameters:** * **ptr** – [in] Source buffer * **Returns:** EC_T_DWORD value (32 bit) from buffer ```cpp EC_T_BYTE byFrame[] = {0x01, 0xF4, 0xDD, 0x85, 0x03, 0x00, 0x60, 0xC1, 0x00}; EC_T_DWORD dwResult = 0; dwResult = EC_GET_FRM_DWORD(byFrame); /* dwResult is 0x85DDF401 on little endian systems */ dwResult = EC_GET_FRM_DWORD(byFrame + 5); /* dwResult is 0x00C16000 on little endian systems */ dwResult = EC_GET_FRM_DWORD(byFrame + 2); /* dwResult is 0x000385DD on little endian systems */ ``` ## EC_GET_FRM_QWORD ### EC_GET_FRM_QWORD(ptr) Reads a value of type EC_T_QWORD (64 bit) at given pointer. The value is swapped on big endian systems. * **Parameters:** * **ptr** – [in] Source buffer * **Returns:** EC_T_QWORD value (64 bit) from buffer ```cpp EC_T_BYTE byFrame[] = {0x01, 0xF4, 0xDD, 0x85, 0x03, 0x00, 0x60, 0xC1, 0x00}; EC_T_UINT64 ui64Result = 0; ui64Result = EC_GET_FRM_QWORD(byFrame + 1); /* wResult is 0x00C160000385DDF4 on little endian systems */ ``` ## EC_SET_FRM_WORD ### EC_SET_FRM_WORD(ptr, w) Writes a value of type EC_T_WORD (16 bit) at given pointer. The value is swapped on big endian systems. * **Parameters:** * **ptr** – [in] Destination buffer * **w** – [in] 16 bit value ```cpp EC_T_BYTE byFrame[32]; /* Initialize the frame buffer */ OsMemset(byFrame, 0xFF, 32); EC_SET_FRM_WORD(byFrame + 1, 0x1234); /* byFrame = FF 34 12 FF FF FF ... */ ``` ## EC_SET_FRM_DWORD ### EC_SET_FRM_DWORD(ptr, dw) Writes a value of type EC_T_DWORD (32 bit) at given pointer. The value is swapped on big endian systems. * **Parameters:** * **ptr** – [in] Destination buffer * **dw** – [in] 32 bit value ```cpp EC_T_BYTE byFrame[32]; /* Initialize the frame buffer */ OsMemset(byFrame, 0xFF, 32); EC_SET_FRM_DWORD(byFrame + 1, 0x12345678); /* byFrame = FF 78 56 34 12 FF ... */ ``` ## EC_SET_FRM_QWORD ### EC_SET_FRM_QWORD(ptr, qw) Writes a value of type EC_T_QWORD (64 bit) at given pointer. The value is swapped on big endian systems. * **Parameters:** * **ptr** – [in] Destination buffer * **qw** – [in] 64 bit value ```cpp EC_T_BYTE byFrame[32]; /* Initialize the frame buffer */ OsMemset(byFrame, 0xFF, 32); EC_SET_FRM_QWORD(byFrame + 1, 0xFEDCBA9876543210); /* byFrame = FF 10 32 54 76 98 BA DC FE FF FF ... */ ``` ## EC_GETBITS ### EC_GETBITS(pbySrcBuf, pbyDstData, nSrcBitOffs, nBitSize) Reads a given number of bits from source buffer starting at given bit offset to destination buffer. #### NOTE This function should only be used to get bit-aligned data. For byte-aligned data the corresponding functions should be used. * **Parameters:** * **pbySrcBuf** – [in] Source buffer to be copied * **pbyDstData** – [out] Destination buffer where data is copied to * **nSrcBitOffs** – [in] Source bit offset where data is copied from * **nBitSize** – [in] Bit count to be copied #### SEE ALSO - [`EC_GET_FRM_WORD`](api_process_data_access_functions.html.md#c.EC_GET_FRM_WORD) - [`EC_GET_FRM_DWORD`](api_process_data_access_functions.html.md#c.EC_GET_FRM_DWORD) - [`EC_GET_FRM_QWORD`](api_process_data_access_functions.html.md#c.EC_GET_FRM_QWORD) ## EC_SETBITS ### EC_SETBITS(pbyDstBuf, pbySrcData, nDstBitOffs, nBitSize) Writes a given number of bits from source data starting at first bit to destination buffer at given bit offset. #### NOTE This function should only be used to set bit-aligned data. For byte-aligned data the corresponding functions should be used. * **Parameters:** * **pbyDstBuf** – [out] Destination buffer where data is copied to * **pbySrcData** – [in] Source buffer to be copied, starting with first bit * **nDstBitOffs** – [in] Destination bit offset where data is copied to * **nBitSize** – [in] Bit count to be copied #### SEE ALSO - [`EC_SET_FRM_WORD`](api_process_data_access_functions.html.md#c.EC_SET_FRM_WORD) - [`EC_SET_FRM_DWORD`](api_process_data_access_functions.html.md#c.EC_SET_FRM_DWORD) - [`EC_SET_FRM_QWORD`](api_process_data_access_functions.html.md#c.EC_SET_FRM_QWORD) ## EC_COPYBIT ### EC_COPYBIT(pbyBuf, nBitOffs, bVal) Copy a boolean bit value into the buffer. * **Parameters:** * **pbyBuf** – Destination buffer. * **nBitOffs** – Bit offset to write. * **bVal** – Boolean bit value. ## EC_TESTBIT ### EC_TESTBIT(pbyBuf, nBitOffs) Test whether a bit in the buffer is set. * **Parameters:** * **pbyBuf** – Source buffer. * **nBitOffs** – Bit offset to test. * **Returns:** EC_TRUE if bit is set, otherwise EC_FALSE. ## EC_SETBIT ### EC_SETBIT(pbyBuf, nBitOffs) Set a single bit in the buffer. * **Parameters:** * **pbyBuf** – Destination buffer. * **nBitOffs** – Bit offset to set. ## EC_CLRBIT ### EC_CLRBIT(pbyBuf, nBitOffs) Clear a single bit in the buffer. * **Parameters:** * **pbyBuf** – Destination buffer. * **nBitOffs** – Bit offset to clear. ## esGetProcessData ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esGetProcessData([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bOutputData, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwOffset, [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) \*pbyData, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwDataLen, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwTimeout) Blocking function to retrieve consistent process data from outside the JobTask context. This function requests a copy of the process data (stored in RAM). The actual memcpy operation is executed by the JobTask to ensure data consistency. While waiting for the copy to complete, the calling context blocks and repeatedly calls sleep with an interval of at least the cycle time or one millisecond, whichever is greater. The function returns either with the requested process data once the copy is finished, or when the specified timeout has expired. #### NOTE The function is blocking and should be used carefully in time-sensitive contexts and may not be called from within the JobTask context. If process data are required outside the cyclic simulator job task (which is calling esExecJob), direct access to the process data is not recommended as data consistency cannot be guaranteed. A call to this function will send a data read request to the simulator stack and then check every millisecond whether new data is provided. The simulator stack will provide new data after calling esExecJob(eUsrJob_SimulatorTimer) within the job task. This function is usually only called remotely (using the Remote API). #### NOTE This function may not be called from within the JobTask’s context. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **bOutputData** – [in] EC_TRUE: read output data, EC_FALSE: read input data * **dwOffset** – [in] Byte offset in Process data to read from * **pbyData** – [out] Buffer receiving transferred data * **dwDataLen** – [in] Buffer length [bytes] * **dwTimeout** – [in] Timeout [ms] * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ## esSetProcessData ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esSetProcessData([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bOutputData, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwOffset, [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) \*pbyData, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwDataLen, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwTimeout) Write Process data synchronized. If process data shall be set outside the cyclic simulator job task (which is calling esExecJob), direct access to the process data is not recommended as data consistency cannot be guaranteed. A call to this function will send a data write request to the simulator stack and then check every millisecond whether new data is written. The simulator stack will copy the data after calling esExecJob(eUsrJob_SimulatorTimer) within the job task. This function is usually only called remotely (using the Remote API). #### NOTE This function may not be called from within the JobTask’s context. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **bOutputData** – [in] EC_TRUE: write output data, EC_FALSE: write input data * **dwOffset** – [in] Byte offset in Process data to write to * **pbyData** – [in] Buffer containing transferred data * **dwDataLen** – [in] Buffer length [bytes] * **dwTimeout** – [in] Timeout [ms] * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ## esSetProcessDataBits ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esSetProcessDataBits([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bOutputData, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwBitOffsetPd, [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) \*pbyData, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwDataBitLen, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwTimeout) Writes a specific number of bits from a given buffer to the process image with a bit offset (synchronized). This function may not be called from within the JobTask’s context. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **bOutputData** – [in] EC_TRUE: write output data, EC_FALSE: write input data * **dwBitOffsetPd** – [in] Bit offset in Process data image * **pbyData** – [in] Buffer containing transferred data * **dwDataBitLen** – [in] Buffer length [bit] * **dwTimeout** – [in] Timeout [ms]. The timeout value must not be set to EC_NOWAIT. * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ## esGetProcessDataBits ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esGetProcessDataBits([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bOutputData, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwBitOffsetPd, [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) \*pbyData, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwDataBitLen, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwTimeout) Reads a specific number of bits from the process image to the given buffer with a bit offset (synchronized). This function may not be called from within the JobTask’s context. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **bOutputData** – [in] EC_TRUE: read output data, EC_FALSE: write input data * **dwBitOffsetPd** – [in] Bit offset in Process data image * **pbyData** – [out] Buffer receiving transferred data * **dwDataBitLen** – [in] Buffer length [bit] * **dwTimeout** – [in] Timeout [ms]. The timeout value must not be set to EC_NOWAIT. * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code # api_slave_control_and_status_functions.html.md # SubDevice control and status functions ## esGetNumConfiguredSlaves ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esGetNumConfiguredSlaves([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID) Returns the number of slaves which are configured in the ENI. * **Parameters:** **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **Returns:** Number of slaves ## esGetNumConnectedSlaves ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esGetNumConnectedSlaves([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID) Get number of currently connected slaves. * **Parameters:** **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **Returns:** Number of connected slaves ## esGetSlaveId ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esGetSlaveId([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wStationAddress) Determines the slave ID using the slave station address. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **wStationAddress** – [in] Station address of the slave * **Returns:** Slave ID or INVALID_SLAVE_ID if the slave could not be found or the stack is not initialized ### Example ```cpp /* get slave id of slave with station address 1001 */ EC_T_DWORD dwSlaveId = esGetSlaveId(dwSimulatorId, 1001); if (INVALID_SLAVE_ID == dwSlaveId) { dwRetVal = EC_E_NOTFOUND; goto Exit; } ``` ## esGetSlaveIdAtPosition ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esGetSlaveIdAtPosition([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wAutoIncAddress) Determines the slave ID using the slave auto increment address. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **wAutoIncAddress** – [in] Auto increment address of the slave * **Returns:** Slave ID or INVALID_SLAVE_ID if no slave matching wAutoIncAddress can be found ### Example ```cpp /* get slave id of third slave (auto inc address 0, -1, -2, ...) */ EC_T_DWORD dwSlaveId = esGetSlaveIdAtPosition(dwSimulatorId, (EC_T_WORD)-2); if (INVALID_SLAVE_ID == dwSlaveId) { dwRetVal = EC_E_NOTFOUND; goto Exit; } ``` ## esGetSlaveState ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esGetSlaveState([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSlaveId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) \*pwCurrDevState, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) \*pwReqDevState) Get the slave state. The slave state is always read automatically from the AL_STATUS register whenever necessary. It is not forced by calling this function. This function may be called from within the JobTask’s context. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **dwSlaveId** – [in] Slave ID * **pwCurrDevState** – [out] Current slave state * **pwReqDevState** – [out] Requested slave state * **Returns:** * [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) if successful * [EC_E_INVALIDSTATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga2a6310e052fca1b94797e8e26f031739) if EtherCAT stack isn’t initialized * [EC_E_INVALIDPARM](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga1e10d9022db11a708658c71b0dead2fe) if dwInstanceID is out of range or the output pointers are EC_NULL * [EC_E_SLAVE_NOT_PRESENT](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga45555d5de25571188a82d2d76c02dd81) if the slave is not present * [EC_E_NOTFOUND](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga3113f3b6f82bb50e6ab3cde40268730a) if no slave matching dwSlaveId can be found ## esSetSlaveState ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esSetSlaveState([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSlaveId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wDeviceState, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwTimeout) Set a specified slave into the requested EtherCAT state. The requested state shall not be higher than the overall operational state. DEVICE_STATE_BOOTSTRAP can only be requested if the slave’s state is INIT. This function may not be called from within the JobTask’s context. If the function is called with EC_NOWAIT, the client may wait for reaching the requested state using the notification callback (EC_NOTIFY_SLAVE_STATECHANGED). * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **dwSlaveId** – [in] Slave ID * **wDeviceState** – [in] Requested device state. See Slave device state’s * **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. * **Returns:** * [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) if successful * [EC_E_INVALIDSTATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga2a6310e052fca1b94797e8e26f031739) if EtherCAT stack isn’t initialized or denies the requested state, see comments below * [EC_E_INVALIDPARM](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga1e10d9022db11a708658c71b0dead2fe) if dwInstanceID is out of range or BOOTSTRAP was requested for a slave that does not support it * [EC_E_NOTFOUND](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga3113f3b6f82bb50e6ab3cde40268730a) if no slave matching dwSlaveId can be found * [EC_E_TIMEOUT](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga2d09527654c655e159d26d36143674cb) if dwTimeout elapsed during the API call * [EC_E_BUSY](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga7c1a3a6dafef1469c97b8e6c4f3868a5) if the EtherCAT stack cannot execute the request at this time, the function has to be called at a later time * [EC_E_NOTREADY](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga4033f6f3b33aa2550d6e46e808a92f37) if the working counter was not set when requesting the slave’s state (slave may not be connected or did not respond) * [EC_E_MASTER_RED_STATE_INACTIVE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gae2870f20d370920995e27b2a78171a5e) if Master Redundancy is configured and master is inactive ## esIsSlavePresent ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esIsSlavePresent([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSlaveId, [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) \*pbPresence) Returns whether a specific slave is currently connected to the Bus. This function may be called from within the JobTask. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **dwSlaveId** – [in] Slave ID * **pbPresence** – [out] EC_TRUE if the slave is currently connected to the bus, EC_FALSE if not * **Returns:** * [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) if successful * [EC_E_INVALIDSTATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga2a6310e052fca1b94797e8e26f031739) if EtherCAT stack isn’t initialized * [EC_E_INVALIDPARM](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga1e10d9022db11a708658c71b0dead2fe) if dwInstanceID is out of range * [EC_E_NOTFOUND](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga3113f3b6f82bb50e6ab3cde40268730a) if no slave matching dwSlaveId can be found ## esGetSlaveProp ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) esGetSlaveProp([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSlaveId, EC_T_SLAVE_PROP \*pSlaveProp) Determines the properties of the slave device. deprecated Use esGetCfgSlaveInfo instead * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **dwSlaveId** – [in] Slave ID * **pSlaveProp** – [out] Slave properties * **Returns:** EC_TRUE if the slave exists, EC_FALSE if no slave matching dwSlaveId can be found ## esGetSlavePortState ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esGetSlavePortState([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSlaveId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) \*pwPortState) Returns the state of the slave ports. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **dwSlaveId** – [in] Slave ID * **pwPortState** – [out] Slave port state. Format: wwww xxxx yyyy zzzz (each nibble : port 3210) wwww : Signal detected 1=yes, 0=no (ESC Register 0x110 Bit 9, 11, 13, 15) xxxx : Loop closed 1=yes, 0=no (ESC Register 0x110 Bit 8, 10, 12, 14) yyyy : Link established 1=yes, 0=no (ESC Register 0x110 Bit 4, 5, 6, 7) zzzz : Slave connected 1=yes, 0=no (zzzz = logical result of w,x,y) * **Returns:** * [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) if successful * [EC_E_INVALIDSTATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga2a6310e052fca1b94797e8e26f031739) if EtherCAT stack isn’t initialized * [EC_E_INVALIDPARM](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga1e10d9022db11a708658c71b0dead2fe) if dwInstanceID is out of range or the output pointer is EC_NULL * [EC_E_NOTFOUND](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga3113f3b6f82bb50e6ab3cde40268730a) if no slave matching dwSlaveId can be found ## esGetProcessVarInfoNumOf, esGetProcessVarInfoEx ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esGetProcessVarInfoNumOf([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_VAR_DIRECTION](api_slave_control_and_status_functions.html.md#_CPPv418EC_T_VAR_DIRECTION) eVarDirection, [EC_T_VAR_SOURCE](api_slave_control_and_status_functions.html.md#_CPPv415EC_T_VAR_SOURCE) eVarSource, [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bFixedAddress, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wSlaveAddress, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) \*pdwProcessVarInfoNumOf) Get process variables information. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **eVarDirection** – [in] INPUTs, OUTPUTs, … . See [EC_T_VAR_DIRECTION](api_slave_control_and_status_functions.html.md#d0-dd4-group-e-c-t-v-a-r-d-i-r-e-c-t-i-o-n) . * **eVarSource** – [in] Slave, Master, … . See [EC_T_VAR_SOURCE](api_slave_control_and_status_functions.html.md#db-db7-group-e-c-t-v-a-r-s-o-u-r-c-e) . * **bFixedAddress** – [in] Use station address if EC_TRUE. Otherwise use AutoInc address. * **wSlaveAddress** – [in] Slave address according to bFixedAddress * **pdwProcessVarInfoNumOf** – [out] Process variables count * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esGetProcessVarInfoEx([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_VAR_DIRECTION](api_slave_control_and_status_functions.html.md#_CPPv418EC_T_VAR_DIRECTION) eVarDirection, [EC_T_VAR_SOURCE](api_slave_control_and_status_functions.html.md#_CPPv415EC_T_VAR_SOURCE) eVarSource, [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bFixedAddress, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wSlaveAddress, [EC_T_PROCESS_VAR_INFO_EX](api_slave_control_and_status_functions.html.md#_CPPv424EC_T_PROCESS_VAR_INFO_EX) \*aoVarInfoEx, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwMaxVarInfoCnt, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) \*pdwVarInfoCnt) Get process variables information. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **eVarDirection** – [in] INPUTs, OUTPUTs, … . See [EC_T_VAR_DIRECTION](api_slave_control_and_status_functions.html.md#d0-dd4-group-e-c-t-v-a-r-d-i-r-e-c-t-i-o-n) . * **eVarSource** – [in] Slave, Master, … . See [EC_T_VAR_SOURCE](api_slave_control_and_status_functions.html.md#db-db7-group-e-c-t-v-a-r-s-o-u-r-c-e) . * **bFixedAddress** – [in] Use station address if EC_TRUE. Otherwise use AutoInc address. * **wSlaveAddress** – [in] Slave address according to bFixedAddress * **aoVarInfoEx** – [out] The read process variable extended information entries * **dwMaxVarInfoCnt** – [in] Maximum number of variables that can be stored at aoVarInfoEx * **pdwVarInfoCnt** – [out] Number process variable entries that have been stored in aoVarInfoEx * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code The following example demonstrates how to get all process data variables: ### **esGetProcessVarInfoEx() Example** ```cpp EC_T_DWORD dwProcessVarInfoNumOf = 0; EC_T_DWORD dwRes = EC_E_NOERROR; dwRes = esGetProcessVarInfoNumOf(dwSimulatorId, eVarDirection_All, eVarSource_All, EC_FALSE, 0, &dwProcessVarInfoNumOf); /* ... */ EC_T_PROCESS_VAR_INFO_EX* aoVarInfoEx = (EC_T_PROCESS_VAR_INFO_EX*)OsMalloc(dwProcessVarInfoNumOf * sizeof(EC_T_PROCESS_VAR_INFO_EX)); dwRes = esGetProcessVarInfoEx(dwSimulatorId, eVarDirection_All, eVarSource_All, EC_FALSE, 0, aoVarInfoEx, dwProcessVarInfoNumOf, EC_NULL); /* ... */ OsSafeFree(aoVarInfoEx); ``` **EC_T_VAR_DIRECTION** ### enum EC_T_VAR_DIRECTION *Values:* ### enumerator eVarDirection_Undefined Undefined Direction ### enumerator eVarDirection_INPUT INPUTs ### enumerator eVarDirection_OUTPUT OUTPUTs ### enumerator eVarDirection_All INPUTs and OUTPUTs ### enumerator eVarDirection_BCppDummy **EC_T_VAR_SOURCE** ### enum EC_T_VAR_SOURCE *Values:* ### enumerator eVarSource_Undefined Undefined Source ### enumerator eVarSource_All Slaves and Master/Monitor/Simulator ### enumerator eVarSource_AllSlaves All Slaves ### enumerator eVarSource_Slave Slave ### enumerator eVarSource_Master Master ### enumerator eVarSource_Monitor Monitor ### enumerator eVarSource_Simulator Simulator ### enumerator eVarSource_BCppDummy ## esGetSlaveInpVarInfoNumOf ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esGetSlaveInpVarInfoNumOf([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bFixedAddressing, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wSlaveAddress, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) \*pwSlaveInpVarInfoNumOf) Gets the number of input variables of a specific slave. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **bFixedAddressing** – [in] EC_TRUE: use station address, EC_FALSE: use AutoInc address * **wSlaveAddress** – [in] Slave address according bFixedAddressing * **pwSlaveInpVarInfoNumOf** – [out] Number of found process variable entries * **Returns:** * [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) if successful * [EC_E_INVALIDSTATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga2a6310e052fca1b94797e8e26f031739) if EtherCAT stack isn’t initialized * [EC_E_INVALIDPARM](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga1e10d9022db11a708658c71b0dead2fe) if dwInstanceID is out of range or the output pointer is EC_NULL * [EC_E_NOTFOUND](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga3113f3b6f82bb50e6ab3cde40268730a) if no slave matching bFixedAddressing / wSlaveAddress can be found ## esGetSlaveOutpVarInfoNumOf ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esGetSlaveOutpVarInfoNumOf([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bFixedAddressing, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wSlaveAddress, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) \*pwSlaveOutpVarInfoNumOf) Gets the number of output variables of a specific slave. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **bFixedAddressing** – [in] EC_TRUE: use station address, EC_FALSE: use AutoInc address * **wSlaveAddress** – [in] Slave address according bFixedAddressing * **pwSlaveOutpVarInfoNumOf** – [out] Number of found process variables * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ## esGetSlaveInpVarInfo ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esGetSlaveInpVarInfo([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bFixedAddressing, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wSlaveAddress, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wNumOfVarsToRead, [EC_T_PROCESS_VAR_INFO](api_slave_control_and_status_functions.html.md#_CPPv421EC_T_PROCESS_VAR_INFO) \*pSlaveProcVarInfoEntries, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) \*pwReadEntries) Gets the process variable information entries of a specific slave. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **bFixedAddressing** – [in] EC_TRUE: use station address, EC_FALSE: use AutoInc address * **wSlaveAddress** – [in] Slave address according bFixedAddressing * **wNumOfVarsToRead** – [in] Number process variable entries that have been stored in pSlaveProcVarInfoEntries * **pSlaveProcVarInfoEntries** – [out] The read process variable information entries * **pwReadEntries** – [out] The number of read process variable information entries * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ### struct EC_T_PROCESS_VAR_INFO ### Public Members ### [EC_T_CHAR](api.html.md#_CPPv49EC_T_CHAR) szName[MAX_PROCESS_VAR_NAME_LEN] [out] Name of the found process variable ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wDataType [out] Data type of the found process variable (according to ETG.1000, section 5). See also EcType.h, DEFTYPE_BOOLEAN. ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wFixedAddr [out] Station address of the slave that is owner of this variable ### [EC_T_INT](api.html.md#_CPPv48EC_T_INT) nBitSize [out] Size in bits of the found process variable ### [EC_T_INT](api.html.md#_CPPv48EC_T_INT) nBitOffs [out] Bit offset in the process data image ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bIsInputData [out] Determines whether the found process variable is an input variable or an output variable ### MAX_PROCESS_VAR_NAME_LEN Maximum length of a process variable name: 71 characters ## esGetSlaveInpVarInfoEx ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esGetSlaveInpVarInfoEx([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bFixedAddressing, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wSlaveAddress, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wNumOfVarsToRead, [EC_T_PROCESS_VAR_INFO_EX](api_slave_control_and_status_functions.html.md#_CPPv424EC_T_PROCESS_VAR_INFO_EX) \*pSlaveProcVarInfoEntriesEx, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) \*pwReadEntries) Gets the input process variable extended information entries of a specific slave. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **bFixedAddressing** – [in] EC_TRUE: use station address, EC_FALSE: use AutoInc address * **wSlaveAddress** – [in] Slave address according bFixedAddressing * **wNumOfVarsToRead** – [in] Number process variable entries that have been stored in pSlaveProcVarInfoEntries * **pSlaveProcVarInfoEntriesEx** – [out] The read process variable extended information entries * **pwReadEntries** – [out] The number of read process variable information entries * **Returns:** * [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) if successful * [EC_E_INVALIDSTATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga2a6310e052fca1b94797e8e26f031739) if EtherCAT stack isn’t initialized * [EC_E_INVALIDPARM](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga1e10d9022db11a708658c71b0dead2fe) if dwInstanceID is out of range or the output pointer is EC_NULL * [EC_E_NOTFOUND](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga3113f3b6f82bb50e6ab3cde40268730a) if no slave matching bFixedAddressing / wSlaveAddress can be found ### struct EC_T_PROCESS_VAR_INFO_EX ### Public Members ### [EC_T_CHAR](api.html.md#_CPPv49EC_T_CHAR) szName[MAX_PROCESS_VAR_NAME_LEN_EX] [out] Name of the found process variable ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wDataType [out] Data type of the found process variable (according to ETG.1000, section 5). See also EcType.h, DEFTYPE_BOOLEAN. ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wFixedAddr [out] Station address of the slave that is owner of this variable ### [EC_T_INT](api.html.md#_CPPv48EC_T_INT) nBitSize [out] Size in bits of the found process variable ### [EC_T_INT](api.html.md#_CPPv48EC_T_INT) nBitOffs [out] Bit offset in the process data image ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bIsInputData [out] Determines whether the found process variable is an input variable or an output variable ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wIndex [out] Object index ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wSubIndex [out] Object sub index ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wPdoIndex [out] Index of PDO (process data object) ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wWkcStateDiagOffs [out] Bit offset in the diagnostic image (API GetDiagnosisImagePtr) ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wMasterSyncUnit [out] Master Sync Unit ID (ENI: Slave/ProcessData/RxPdo[1..4]@Su, Slave/ProcessData/TxPdo[1..4]@Su, comment at Cyclic/Frame/Cmd) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwTaskId [out] ID of task where process variable is located ### EC_T_CYC_COPY_INFO CopyInfo [out] Copy Info if applied to the variable ### MAX_PROCESS_VAR_NAME_LEN_EX Maximum length of an extended process variable name: 127 characters ## esGetSlaveOutpVarInfo ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esGetSlaveOutpVarInfo([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bFixedAddressing, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wSlaveAddress, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wNumOfVarsToRead, [EC_T_PROCESS_VAR_INFO](api_slave_control_and_status_functions.html.md#_CPPv421EC_T_PROCESS_VAR_INFO) \*pSlaveProcVarInfoEntries, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) \*pwReadEntries) Gets the output process variable information entries of a specific slave. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **bFixedAddressing** – [in] EC_TRUE: use station address, EC_FALSE: use AutoInc address * **wSlaveAddress** – [in] Slave address according bFixedAddressing * **wNumOfVarsToRead** – [in] Number of found process variable entries * **pSlaveProcVarInfoEntries** – [out] The read process variable information entries * **pwReadEntries** – [out] The number of read process variable information entries * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code #### SEE ALSO [`EC_T_PROCESS_VAR_INFO`](api_slave_control_and_status_functions.html.md#_CPPv421EC_T_PROCESS_VAR_INFO) ## esGetSlaveOutpVarInfoEx ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esGetSlaveOutpVarInfoEx([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bFixedAddressing, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wSlaveAddress, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wNumOfVarsToRead, [EC_T_PROCESS_VAR_INFO_EX](api_slave_control_and_status_functions.html.md#_CPPv424EC_T_PROCESS_VAR_INFO_EX) \*pSlaveProcVarInfoEntriesEx, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) \*pwReadEntries) Gets the output process variable extended information entries of a specific slave. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **bFixedAddressing** – [in] EC_TRUE: use station address, EC_FALSE: use AutoInc address * **wSlaveAddress** – [in] Slave address according bFixedAddressing * **wNumOfVarsToRead** – [in] Number of process variable information entries * **pSlaveProcVarInfoEntriesEx** – [out] The read process extended variable entries * **pwReadEntries** – [out] The number of read process variable information entries * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code #### SEE ALSO [`EC_T_PROCESS_VAR_INFO_EX`](api_slave_control_and_status_functions.html.md#_CPPv424EC_T_PROCESS_VAR_INFO_EX) ## esGetSlaveInpVarByObjectEx ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esGetSlaveInpVarByObjectEx([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bFixedAddressing, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wSlaveAddress, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wIndex, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wSubIndex, [EC_T_PROCESS_VAR_INFO_EX](api_slave_control_and_status_functions.html.md#_CPPv424EC_T_PROCESS_VAR_INFO_EX) \*pProcessVarInfoEntry) Gets the input process variable extended information entry by object index, subindex of a specific slave. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **bFixedAddressing** – [in] EC_TRUE: use station address, EC_FALSE: use AutoInc address * **wSlaveAddress** – [in] Slave address according bFixedAddressing * **wIndex** – [in] Object index * **wSubIndex** – [in] Object sub index * **pProcessVarInfoEntry** – [out] Process variable extended information entry * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code #### SEE ALSO [`EC_T_PROCESS_VAR_INFO_EX`](api_slave_control_and_status_functions.html.md#_CPPv424EC_T_PROCESS_VAR_INFO_EX) ## esGetSlaveOutpVarByObjectEx ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esGetSlaveOutpVarByObjectEx([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bFixedAddressing, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wSlaveAddress, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wIndex, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wSubIndex, [EC_T_PROCESS_VAR_INFO_EX](api_slave_control_and_status_functions.html.md#_CPPv424EC_T_PROCESS_VAR_INFO_EX) \*pProcessVarInfoEntry) Gets the input process variable extended information entry by object index, subindex of a specific slave. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **bFixedAddressing** – [in] EC_TRUE: use station address, EC_FALSE: use AutoInc address * **wSlaveAddress** – [in] Slave address according bFixedAddressing * **wIndex** – [in] Object index * **wSubIndex** – [in] Object sub index * **pProcessVarInfoEntry** – [out] Process variable extended information entry * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code #### SEE ALSO [`EC_T_PROCESS_VAR_INFO_EX`](api_slave_control_and_status_functions.html.md#_CPPv424EC_T_PROCESS_VAR_INFO_EX) ## esFindInpVarByName ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esFindInpVarByName([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, const [EC_T_CHAR](api.html.md#_CPPv49EC_T_CHAR) \*szVariableName, [EC_T_PROCESS_VAR_INFO](api_slave_control_and_status_functions.html.md#_CPPv421EC_T_PROCESS_VAR_INFO) \*pProcessVarInfoEntry) Finds an input process variable information entry by the variable name. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **szVariableName** – [in] Variable name * **pProcessVarInfoEntry** – [out] Process variable information entry * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code #### SEE ALSO [`EC_T_PROCESS_VAR_INFO`](api_slave_control_and_status_functions.html.md#_CPPv421EC_T_PROCESS_VAR_INFO) ## esFindInpVarByNameEx ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esFindInpVarByNameEx([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, const [EC_T_CHAR](api.html.md#_CPPv49EC_T_CHAR) \*szVariableName, [EC_T_PROCESS_VAR_INFO_EX](api_slave_control_and_status_functions.html.md#_CPPv424EC_T_PROCESS_VAR_INFO_EX) \*pProcessVarInfoEntry) Finds an input process variable extended information entry by the variable name. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **szVariableName** – [in] Variable name * **pProcessVarInfoEntry** – [out] Process variable extended information entry * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code #### SEE ALSO [`EC_T_PROCESS_VAR_INFO`](api_slave_control_and_status_functions.html.md#_CPPv421EC_T_PROCESS_VAR_INFO) ## esFindOutpVarByName ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esFindOutpVarByName([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, const [EC_T_CHAR](api.html.md#_CPPv49EC_T_CHAR) \*szVariableName, [EC_T_PROCESS_VAR_INFO](api_slave_control_and_status_functions.html.md#_CPPv421EC_T_PROCESS_VAR_INFO) \*pProcessVarInfoEntry) Finds an output process variable information entry by the variable name. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **szVariableName** – [in] Variable name * **pProcessVarInfoEntry** – [out] Process variable information entry * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code #### SEE ALSO [`EC_T_PROCESS_VAR_INFO`](api_slave_control_and_status_functions.html.md#_CPPv421EC_T_PROCESS_VAR_INFO) ## esFindOutpVarByNameEx ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esFindOutpVarByNameEx([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, const [EC_T_CHAR](api.html.md#_CPPv49EC_T_CHAR) \*szVariableName, [EC_T_PROCESS_VAR_INFO_EX](api_slave_control_and_status_functions.html.md#_CPPv424EC_T_PROCESS_VAR_INFO_EX) \*pProcessVarInfoEntry) Finds an output process variable extended information entry by the variable name. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **szVariableName** – [in] Variable name * **pProcessVarInfoEntry** – [out] Process variable extended information entry * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code #### SEE ALSO [`EC_T_PROCESS_VAR_INFO_EX`](api_slave_control_and_status_functions.html.md#_CPPv424EC_T_PROCESS_VAR_INFO_EX) ## esWriteSlaveRegister #### WARNING Changing contents of ESC registers may lead to unpredictable behavior of the SubDevices and/or the MainDevice. ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esWriteSlaveRegister([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bFixedAddressing, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wSlaveAddress, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wRegisterOffset, [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) \*pbyData, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wLen, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwTimeout) Writes data into the ESC memory of a specified slave. This function may not be called from within the JobTask’s context #### WARNING Changing contents of ESC registers may lead to unpredictable behavior of the slaves and/or the master. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **bFixedAddressing** – [in] EC_TRUE: use station address, EC_FALSE: use AutoInc address * **wSlaveAddress** – [in] Slave address according bFixedAddressing * **wRegisterOffset** – [in] Register offset. E.g. use 0x0120 to write to the AL Control register. * **pbyData** – [in] Buffer containing transfered data * **wLen** – [in] Number of bytes to send * **dwTimeout** – [in] Timeout [ms] * **Returns:** * [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) if successful * [EC_E_INVALIDSTATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga2a6310e052fca1b94797e8e26f031739) if EtherCAT stack isn’t initialized * [EC_E_INVALIDPARM](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga1e10d9022db11a708658c71b0dead2fe) if dwInstanceID is out of range or the command is not supported or the timeout value is set to EC_NOWAIT * [EC_E_SLAVE_NOT_PRESENT](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga45555d5de25571188a82d2d76c02dd81) if slave not present * [EC_E_NOTFOUND](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga3113f3b6f82bb50e6ab3cde40268730a) if no slave matching bFixedAddressing / wSlaveAddress can be found * [EC_E_TIMEOUT](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga2d09527654c655e159d26d36143674cb) if dwTimeout elapsed during the API call * [EC_E_BUSY](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga7c1a3a6dafef1469c97b8e6c4f3868a5) if another transfer request is already pending or the master or the corresponding slave is currently changing its operational state * [EC_E_NOTREADY](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga4033f6f3b33aa2550d6e46e808a92f37) if the working counter was not set when sending the command (slave may not be connected or did not respond) * [EC_E_INVALIDSIZE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gacd9f0baea7a294f85c3f5bde1543d1d0) if the size of the complete command does not fit into a single Ethernet frame. The maximum amount of data to transfer must not exceed 1486 bytes. ## esReadSlaveRegister ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esReadSlaveRegister([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bFixedAddressing, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wSlaveAddress, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wRegisterOffset, [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) \*pbyData, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wLen, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwTimeout) Reads data from the ESC memory of a specified slave. This function may not be called from within the JobTask’s context. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **bFixedAddressing** – [in] EC_TRUE: use station address, EC_FALSE: use AutoInc address * **wSlaveAddress** – [in] Slave address according bFixedAddressing * **wRegisterOffset** – [in] Register offset. I.e. use 0x0130 to read the AL Status register. * **pbyData** – [out] Buffer receiving transfered data * **wLen** – [in] Number of bytes to receive * **dwTimeout** – [in] Timeout [ms] * **Returns:** * [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) if successful * [EC_E_INVALIDSTATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga2a6310e052fca1b94797e8e26f031739) if EtherCAT stack isn’t initialized * [EC_E_INVALIDPARM](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga1e10d9022db11a708658c71b0dead2fe) if dwInstanceID is out of range or the command is not supported or the timeout value is set to EC_NOWAIT * [EC_E_SLAVE_NOT_PRESENT](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga45555d5de25571188a82d2d76c02dd81) if the slave is not present * [EC_E_NOTFOUND](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga3113f3b6f82bb50e6ab3cde40268730a) if no slave matching bFixedAddressing / wSlaveAddress can be found * [EC_E_TIMEOUT](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga2d09527654c655e159d26d36143674cb) if dwTimeout elapsed during the API call * [EC_E_BUSY](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga7c1a3a6dafef1469c97b8e6c4f3868a5) if another transfer request is already pending or the master or the corresponding slave is currently changing its operational state * [EC_E_NOTREADY](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga4033f6f3b33aa2550d6e46e808a92f37) if the working counter was not set when sending the command (slave may not be connected or did not respond) * [EC_E_INVALIDSIZE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gacd9f0baea7a294f85c3f5bde1543d1d0) if the size of the complete command does not fit into a single Ethernet frame. The maximum amount of data to transfer must not exceed 1486 bytes. ## esReadSlaveEEPRom ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esReadSlaveEEPRom([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bFixedAddressing, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wSlaveAddress, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wEEPRomStartOffset, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) \*pwReadData, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwReadLen, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) \*pdwNumOutData, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwTimeout) Read EEPROM data from a slave. This function may not be called from within the JobTask’s context. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **bFixedAddressing** – [in] EC_TRUE: use station address, EC_FALSE: use AutoInc address * **wSlaveAddress** – [in] Slave address according bFixedAddressing * **wEEPRomStartOffset** – [in] Word address to start EEPROM read from * **pwReadData** – [in] Pointer to EC_T_WORD array to carry the read data * **dwReadLen** – [in] Size of the EC_T_WORD array provided at pwReadData (in EC_T_WORDs) * **pdwNumOutData** – [out] Pointer to EC_T_DWORD carrying actually read data (in EC_T_WORDs) after completion * **dwTimeout** – [in] Timeout [ms]. The function will block at most for this time. The timeout value must not be set to EC_NOWAIT. * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ## esWriteSlaveEEPRom ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esWriteSlaveEEPRom([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bFixedAddressing, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wSlaveAddress, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wEEPRomStartOffset, const [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) \*pwWriteData, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwWriteLen, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwTimeout) Write EEPROM data to slave. This function may not be called from within the JobTask’s context. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **bFixedAddressing** – [in] EC_TRUE: use station address, EC_FALSE: use AutoInc address * **wSlaveAddress** – [in] Slave address according bFixedAddressing * **wEEPRomStartOffset** – [in] Word address to start EEPROM Write from * **pwWriteData** – [in] Pointer to WORD array carrying the data to write * **dwWriteLen** – [in] Size of Write Data WORD array (in WORDS) * **dwTimeout** – [in] Timeout [ms]. The function will block at most for this time. The timeout value must not be set to EC_NOWAIT. * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code #### NOTE The EEPROM’s CRC at word 7 is re-calculated automatically if the written data is completely within the ESC Configuration Area in the EEPROM’s SII. ## esGetSimSlaveInfo ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esGetSimSlaveInfo([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceId, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wCfgFixedAddress, [EC_T_SIM_SLAVE_INFO](api_slave_control_and_status_functions.html.md#_CPPv419EC_T_SIM_SLAVE_INFO) \*pSimSlaveInfo) Get extended configuration and status information for slave from simulator. \_ * **Parameters:** * **dwInstanceId** – [in] Simulator Instance ID * **wCfgFixedAddress** – [in] Slave’s station address * **pSimSlaveInfo** – [out] Extended configuration and status information for slave from simulator * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code Content of [`EC_T_SIM_SLAVE_INFO`](api_slave_control_and_status_functions.html.md#_CPPv419EC_T_SIM_SLAVE_INFO), [`EC_T_SIM_SLAVE_CFG_INFO`](api_slave_control_and_status_functions.html.md#_CPPv423EC_T_SIM_SLAVE_CFG_INFO), [`EC_T_SIM_SLAVE_STATUS_INFO`](api_slave_control_and_status_functions.html.md#_CPPv426EC_T_SIM_SLAVE_STATUS_INFO) is subject to be extended. ### struct EC_T_SIM_SLAVE_INFO ### Public Members ### [EC_T_SIM_SLAVE_CFG_INFO](api_slave_control_and_status_functions.html.md#_CPPv423EC_T_SIM_SLAVE_CFG_INFO) oCfg [out] Config Info (ENI/EXI) ### [EC_T_SIM_SLAVE_STATUS_INFO](api_slave_control_and_status_functions.html.md#_CPPv426EC_T_SIM_SLAVE_STATUS_INFO) oStatus [out] Status Info ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) adwReserved[32] [out] Reserved ### struct EC_T_SIM_SLAVE_CFG_INFO ### Public Members ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wFixedAddress [out] Slave’s station address (ENI/EXI: /EtherCATConfig/Config/Slave/Info/PhysAddr) ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bPowerOff [out] Slave powered off on startup (EXI: /EtherCATConfig/ExtendedConfig/Slaves/Slave@PowerOff) ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bSimulated [out] Slave is simulated (EXI: /EtherCATConfig/ExtendedConfig/Slaves/Slave/Simulated) ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bIgnoreCoeDownloadError [out] Slave ignores CoE download errors (EXI: /EtherCATConfig/ExtendedConfig/Slaves/Slave/Mailbox/CoE@IgnoreDownloadError) ### EC_T_SIMULATOR_DEVICE_CONNECTION_DESC aPortConnection[4] [out] Explicit port connection (optional) (EXI: /EtherCATConfig/ExtendedConfig/Slaves/Slave/PortConnection) ### [EC_T_CHAR](api.html.md#_CPPv49EC_T_CHAR) szApplicationName[EC_SIM_SLAVE_CFG_APP_NAME_SIZE] [out] Configured slave application name (EXI: /EtherCATConfig/ExtendedConfig/Slaves/Slave/Application/Name) ### [EC_T_CHAR](api.html.md#_CPPv49EC_T_CHAR) szApplicationParms[EC_SIM_SLAVE_CFG_APP_PARMS_SIZE] [out] Configured slave application parameters (EXI: /EtherCATConfig/ExtendedConfig/Slaves/Slave/Application/Parameter) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) adwReserved[16] [out] Reserved ### struct EC_T_SIM_SLAVE_STATUS_INFO ### Public Members ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bIsPowerOn [out] Slave is powered on. See esPowerSlave(). ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bIsPresent [out] Slave is present in topology segment and connected to the network. See esConnectPorts(), Hot Connect. ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wAlStatusReq [out] AL Status (0x0130) requested from Simulator application. See esSetSimSlaveState(). ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wAlStatusCodeReq [out] AL Status (0x0134) requested from Simulator application. See esSetSimSlaveState(). ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) adwRes1[4] [out] Reserved ### EC_T_SIMULATOR_DEVICE_CONNECTION_DESC aPortConnection[4] [out] See esConnectPorts() ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) adwRes2[16] [out] Reserved ## esGetBusSlaveInfo ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esGetBusSlaveInfo([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bFixedAddressing, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wSlaveAddress, [EC_T_BUS_SLAVE_INFO](api_slave_control_and_status_functions.html.md#_CPPv419EC_T_BUS_SLAVE_INFO) \*pSlaveInfo) Return information about a slave connected to the EtherCAT bus. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **bFixedAddressing** – [in] EC_TRUE: use station address, EC_FALSE: use AutoInc address * **wSlaveAddress** – [in] Slave address according bFixedAddressing * **pSlaveInfo** – [out] Information from the slave * **Returns:** * [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) if successful * [EC_E_INVALIDSTATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga2a6310e052fca1b94797e8e26f031739) if EtherCAT stack isn’t initialized * [EC_E_INVALIDPARM](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga1e10d9022db11a708658c71b0dead2fe) if dwInstanceID is out of range * [EC_E_NOTFOUND](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga3113f3b6f82bb50e6ab3cde40268730a) if no slave matching bFixedAddressing / wSlaveAddress can be found Content of [`EC_T_BUS_SLAVE_INFO`](api_slave_control_and_status_functions.html.md#_CPPv419EC_T_BUS_SLAVE_INFO) is subject to be extended. ### struct EC_T_BUS_SLAVE_INFO ### Public Members ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSlaveId [out] The slave’s ID to bind bus slave and config slave information ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) adwPortSlaveIds[ESC_PORT_COUNT] [out] The slave’s ID of the slaves connected to ports. See Port slave ID’s. ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wPortState [out] Port link state. Format: wwww xxxx yyyy zzzz (each nibble : port 3210) wwww : Signal detected 1=yes, 0=no xxxx : Loop closed 1=yes, 0=no yyyy : Link established 1=yes, 0=no zzzz : Slave connected 1=yes, 0=no (zzzz = logical result of w,x,y) ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wAutoIncAddress [out] The slave’s auto increment address ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bDcSupport [out] Slave supports DC (Bus Topology Scan) ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bDc64Support [out] Slave supports 64 Bit DC (Bus Topology Scan) ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwVendorId [out] Vendor Identification stored in the EEPROM at offset 0x0008 ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwProductCode [out] Product Code stored in the EEPROM at offset 0x000A ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwRevisionNumber [out] Revision number stored in the EEPROM at offset 0x000C ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSerialNumber [out] Serial number stored in the EEPROM at offset 0x000E ### [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) byESCType [out] Type of ESC (Value of slave ESC register 0x0000) ### [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) byESCRevision [out] Revision number of ESC (Value of slave ESC register 0x0001) ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wESCBuild [out] Build number of ESC (Value of slave ESC register 0x0002) ### [EC_T_BYTE](api.html.md#_CPPv49EC_T_BYTE) byPortDescriptor [out] Port descriptor (Value of slave ESC register 0x0007) ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wFeaturesSupported [out] Features supported (Value of slave ESC register 0x0008) ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wStationAddress [out] The slave’s station address (Value of slave ESC register 0x0010) ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wAliasAddress [out] The slave’s alias address (Value of slave ESC register 0x0012) ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wAlStatus [out] AL status (Value of slave ESC register 0x0130) ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wAlStatusCode [out] AL status code. (Value of slave ESC register 0x0134 during last error acknowledge). This value is reset after a slave state change. ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSystemTimeDifference [out] System time difference. (Value of slave ESC register 0x092C) ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wMbxSupportedProtocols [out] Supported Mailbox Protocols stored in the EEPROM at offset 0x001C ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wDlStatus [out] DL status (Value of slave ESC register 0x0110) ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wPrevPort [out] Connected port of the previous slave ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wIdentifyData [out] Last read identification value see [EC_T_CFG_SLAVE_INFO.wIdentifyAdo](api_general.html.md#d5/dca/struct_e_c___t___c_f_g___s_l_a_v_e___i_n_f_o_1a5972bcd59947447718549523d67d828d) ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bLineCrossed [out] Line crossed was detected at this slave ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSlaveDelay [out] Delay behind slave [ns]. ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwPropagDelay [out] Propagation delay [ns]. ESC register 0x0928. ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bIsRefClock [out] Slave is reference clock ### [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bIsDeviceEmulation [out] Slave without Firmware. ESC register 0x0141, enabled by EEPROM offset 0x0000.8. ### [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wLineCrossedFlags [out] Combination of Line crossed flags ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwCyclicWkcErrorCnt [out] Counter for Cyclic WC Error ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSlaveAbsentCnt [out] Counter for Absent/Not Present Slaves ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwUnexpectedStateCnt [out] Counter for Abnormal State Change ### Get bus SubDevice info with station address example ```cpp EC_T_BUS_SLAVE_INFO oBusSlaveInfo; /* get bus slave info of slave with station address 1001 */ dwRes = esGetBusSlaveInfo(dwSimulatorId, EC_TRUE, 1001, &oBusSlaveInfo); if (dwRes != EC_E_NOERROR) { dwRetVal = dwRes; goto Exit; } ``` ### Get bus SubDevice info with auto-inc address example ```cpp EC_T_BUS_SLAVE_INFO oBusSlaveInfo; /* get bus slave info of third slave (auto inc address 0, -1, -2, ...) */ dwRes = esGetBusSlaveInfo(dwSimulatorId, EC_FALSE, (EC_T_WORD)-2, &oBusSlaveInfo); if (dwRes != EC_E_NOERROR) { dwRetVal = dwRes; goto Exit; } ``` ## esReadSlaveIdentification ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esReadSlaveIdentification([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_BOOL](api.html.md#_CPPv49EC_T_BOOL) bFixedAddressing, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wSlaveAddress, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) wAdo, [EC_T_WORD](api.html.md#_CPPv49EC_T_WORD) \*pwValue, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwTimeout) Read identification value from a slave. This function may not be called from within the JobTask’s context. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **bFixedAddressing** – [in] EC_TRUE: use station address, EC_FALSE: use AutoInc address * **wSlaveAddress** – [in] Slave address according bFixedAddressing * **wAdo** – [in] ADO used for identification command * **pwValue** – [out] Pointer to Word value containing the Identification value * **dwTimeout** – [in] Timeout [ms] * **Returns:** * [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) if successful * [EC_E_INVALIDSTATE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga2a6310e052fca1b94797e8e26f031739) if EtherCAT stack isn’t initialized * [EC_E_INVALIDPARM](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga1e10d9022db11a708658c71b0dead2fe) if dwInstanceID is out of range or the command is not supported or the timeout value is set to EC_NOWAIT * [EC_E_SLAVE_NOT_PRESENT](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga45555d5de25571188a82d2d76c02dd81) if slave not present * [EC_E_NOTFOUND](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga3113f3b6f82bb50e6ab3cde40268730a) if no slave matching bFixedAddressing / wSlaveAddress can be found * [EC_E_TIMEOUT](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga2d09527654c655e159d26d36143674cb) if dwTimeout elapsed during the API call * [EC_E_BUSY](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga7c1a3a6dafef1469c97b8e6c4f3868a5) if another transfer request is already pending or the master or the corresponding slave is currently changing its operational state * [EC_E_NOTREADY](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga4033f6f3b33aa2550d6e46e808a92f37) if the working counter was not set when sending the command (slave may not be connected or did not respond) * [EC_E_ADO_NOT_SUPPORTED](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga76fa8b6a484e5f447a89bc16a8a4c95d) if the slave does not support requesting ID mechanism * [EC_E_MASTER_RED_STATE_INACTIVE](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1gae2870f20d370920995e27b2a78171a5e) if Master Redundancy is configured and master is inactive ## esGetSlaveStatistics ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esGetSlaveStatistics([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSlaveId, EC_T_SLVSTATISTICS_DESC \*pSlaveStatisticsDesc) Get Slave’s statistics counter. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **dwSlaveId** – [in] Slave id * **pSlaveStatisticsDesc** – [out] Pointer to structure EC_T_SLVSTATISTICS_DESC * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code ## esClearSlaveStatistics ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) esClearSlaveStatistics([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwSlaveId) Clears all error registers of a slave. * **Parameters:** * **dwInstanceID** – [in] Instance ID (Multiple EtherCAT Network Support) * **dwSlaveId** – [in] Slave Id, INVALID_SLAVE_ID clears all slaves * **Returns:** [EC_E_NOERROR](error-codes_generic.html.md#d3/d2f/group___e_c___e_r_r_o_r___c_o_d_e_s___g_e_n_e_r_i_c_1ga8c8419c32e88e73d940a4501fe427116) or error code # architecture.html.md # Getting Started This chapter introduces the EC-Simulator architecture and its HiL/SiL editions, extended EXI and mixed-mode operation, operating system configuration, and the Software Development Kit. # architecture_extended-exi.html.md # Extended EtherCAT® Network Configuration (EXI) The EC-Simulator stack has to know about the EtherCAT® bus topology and the cyclic/acyclic frames to exchange with the SubDevices. This configuration is determined in a configuration file which has to be available in the EtherCAT® Network Information Format (ENI). This format is completely independent from EtherCAT® SubDevice vendors, from MainDevice stack vendors and from EtherCAT® configuration tools. Thus inter-operability between those vendors is guaranteed. Because the ENI file does not include information about the SubDevice hardware, the EXI (EtherCAT® Extended Information) file includes EEPROM content and SubDevice Object Dictionary from ESI and ESC register values from real network is typically needed. The EXI file can be exported using EC-Engineer. ![Diagram showing the relationship between the standard ENI format and the EC-Simulator EXI extended network information format including EEPROM content and object dictionary](../Media/EXI.png) ## HiL Simulation Software architecture The EC-Simulator software is ready-to-run on various operating systems, e. g. Linux and Windows, and makes use of the Real-time Ethernet Drivers. The EC-Simulator offers a “C” language API for integration into a Software PLC (LogicLab, logi.cals) or into professional simulation software like ISG Virtuos, etc. ![EC-Simulator HiL software architecture showing the stack running on external hardware connected via Ethernet to the EtherCAT MainDevice](../Media/HiL-architecture.png) # architecture_mixed-mode.html.md # Mixed mode of real SubDevices and simulated SubDevices In order to implement restbus simulation it is possible to mix real SubDevices and simulated SubDevices like this: ![Diagram showing a mixed EC-Simulator network configuration with both real SubDevices and simulated SubDevices for restbus simulation](../Media/mix_real_slaves_and_simulated_slaves.png) All real SubDevices must be configured accordingly: ![EC-Engineer configuration view showing how real SubDevices must be marked in the EtherCAT network topology for mixed mode operation](../Media/real_slaves_configuration.png) See also /EtherCATConfig/ExtendedConfig/Slaves/Slave/Simulated in the EXI file: ![EXI file editor showing the EtherCATConfig/ExtendedConfig/Slaves/Slave/Simulated element for marking SubDevices as simulated in mixed mode](../Media/EtherCATConfig_ExtendedConfig_Slaves_Slave_Simulated.png) The EC-Simulator will automatically assign the network adapters to the corresponding ports in order of configuration. #### SEE ALSO [`EC_T_SIMULATOR_INIT_PARMS::apLinkParms`](api_general.html.md#_CPPv4N25EC_T_SIMULATOR_INIT_PARMS11apLinkParmsE) at [`esInitSimulator()`](api_general.html.md#_CPPv415esInitSimulator10EC_T_DWORDPK25EC_T_SIMULATOR_INIT_PARMS). # architecture_os-configuration.html.md # Operating system configuration The main task is to setup the operating system to support the appropriate network adapter for EtherCAT® usage and for some systems real-time configuration may be needed. The operating system-specific settings and configurations are described in [Platform and Operating Systems (OS)](os.html.md#platform-and-operating-systems-os). \\newpage ## Running EcSimulatorHilDemoGuiDotNet EC-Simulator HiL for Windows contains a .NET example application, the EcSimulatorHilDemoGuiDotNet. Selecting the appropriate network adapter and providing an EtherCAT® Network Configuration file (ENI / EXI) is mandatory before clicking “Start” to run the EC-Simulator: ![EcSimulatorHilDemoGuiDotNet start parameters](../Media/EcSimulatorHilDemoGuiDotNet-start-parameters.png)\\newpage ## Running EcSimulatorHilDemo The EcSimulatorHilDemo is an EC-Simulator example application that handles the following tasks: - Showing basic EtherCAT® communication - Stack initialization - Process Data operations (e.g., flashing INPUTs) - Periodic diagnosis task - Periodic Job Task - Logging to ecsimulator0.log, error0.log The EcSimulatorHilDemo is available “out of the box” for different operating systems. The operating system must be prepared for running EtherCAT® applications. #### SEE ALSO [Operating system configuration](architecture_os-configuration.html.md#operating-system-configuration) ### Setting up and running EcSimulatorHilDemo #### Linux (EcSimulatorHilDemo) 1. Operating system configuration: See the section [Operating system configuration](architecture_os-configuration.html.md#operating-system-configuration) for how to prepare the operating system. 2. Starting EcSimulatorHilDemo ```console $ cd /opt/EC-Simulator/Bin/Linux/x64 $ ./EcSimulatorHilDemo -intelgbe 2 1 -f exi.xml -perf -sp ``` #### Microsoft Windows (EcSimulatorHilDemo) 1. Windows configuration: See the section Operating system configuration for how to prepare the operating system. 2. Determine the network interface: Using the command line option the network interface card used by the example application can be determined. For example the option -ndis 192.168.157.2 0 will be using the network adapter card with the IP address 192.168.157.2 . 3. Simulating EtherCAT® modules: The simulator has to be connected with the target system using an Ethernet switch or a patch cable. Local IT infrastructure should not be mixed with EtherCAT® modules at the same switch as the MainDevice will send many broadcast packets! EtherCAT® requires a 100Mbit/s connection. Gigabit-Ethernet connections between simulator and MainDevice can be typically used, too. 4. Copy all of the example application files into one directory: The application EcSimulatorHilDemo.exe together with the stack DLLs and the EXI file have to be copied into one directory. 5. Run the example application: EcSimulatorHilDemo.exe has to be executed. The file name of the EXI file has to be given as a command line parameter as well as the appropriate Real-time Ethernet Driver parameters. ```console $ EcSimulatorHilDemo.exe -ndis 192.168.157.2 0 -f exi.xml -t 0 -v 3 -sp ``` ### Command line parameters ### EcSimulatorHilDemo [-f ENI-FileName] [-t cycle time] [-b time] [-a affinity] [-v level] [-perf [level]] [-log prefix [msg cnt]] [-lic key] [-oem key] [-fingerprint method] [-flash address] [-sp [port]] [-rec [prefix [frame cnt]]] The parameters are as follows: ### -f Path to ENI file ### -t