Application Callbacks
To use the full potential of EtherNet/IP the stack allows you to interact at several stages of the protocol. For example you may receive a callback after new assembly data has arrived.
The stack calls the callback handler registered via the function goal_eipNew(). The callback handler returns a GOAL_STATUS_T value.
Parameter | Description |
---|---|
GOAL_EIP_T *pHdlEip | GOAL EtherNet/IP handle |
GOAL_EIP_CB_ID_T id | callback id |
GOAL_EIP_CB_DATA_T *pCb | callback parameters |
Table: parameters of the callback handler
Â
The callback parameter is an array of unions that has up to 10 elements.
Â
/****************************************************************************/
/** EtherNet/IP Callback Handler
*
* This function collects all callbacks from the stack and decides if the
* callback must be handled.
*/
GOAL_STATUS_T main_eipCallback(
GOAL_EIP_T *pHdlEip, /**< PROFINET handle */
GOAL_EIP_CB_ID_T id, /**< callback id */
GOAL_EIP_CB_DATA_T *pCb /**< callback parameters */
)
{
GOAL_STATUS_T res = GOAL_OK; /* result */
switch (id) {
case GOAL_EIP_CB_ID_INIT:
/* initialize application resources */
break;
/* ... */
}
return res;
}
GOAL_EIP_CB_ID_INIT
The stack was initialized. The application can initialize its resources.
Parameter
<none>
Return Value
GOAL_OK - success
other - fail
GOAL_EIP_CB_ID_READY
Initialization is done.
Parameter
<none>
Return Value
<ignored>
GOAL_EIP_CB_ID_CONNECT_EVENT
Inform the application about a connection event
Parameter
Element | Member | data type | Description |
---|---|---|---|
0 | outputAssembly | uint32_t | instance id of output assembly |
1 | inputAssembly | uint32_t | instance id of output assembly |
2 | connectionEvent | uint32_t | GOAL_EIP_CONNECTION_EVENT_* |
Table: callback parameters of GOAL_EIP_CB_ID_CONNECT_EVENT
Return Value
<ignored>
GOAL_EIP_CB_ID_ASSEMBLY_DATA_RECV
New data for an assembly has been received.
Parameter
Element | Member | data type | Description |
---|---|---|---|
0 | instanceNr | uint32_t | instance id of assembly |
Table: callback parameters of GOAL_EIP_CB_ID_ASSEMBLY_DATA_RECV
Return Value
GOAL_OK - success
other - fail
GOAL_EIP_CB_ID_ASSEMBLY_DATA_SEND
Inform application that data of an assembly will be sent.
Parameter
Element | Member | data type | Description |
---|---|---|---|
0 | instanceNr | uint32_t | instance id of assembly |
Table: callback parameters of GOAL_EIP_CB_ID_ASSEMBLY_DATA_SEND
Return Value
GOAL_OK - data has changed
other - data has not changed
GOAL_EIP_CB_ID_RUN_IDLE_CHANGED
Inform application that the Run/Idle header of consumed cyclic data has changed.
Parameter
Element | Member | data type | Description |
---|---|---|---|
0 | outputAssembly | uint32_t | instance id of output assembly |
1 | inputAssembly | uint32_t | instance id of output assembly |
2 | runIdleValue | uint32_t | current value of the run/idle flag |
Table: callback parameters of GOAL_EIP_CB_ID_RUN_IDLE_CHANGED
Return Value
<ignored>
GOAL_EIP_CB_ID_LED_CHANGED
Inform the application that a Module Status or Network Status LED must be changed. The parameter contains a bitmap made out of GOAL_EIP_LED_* macros. If a bit is set the corresponding LED must be set. Otherwise it must be cleared.
Parameter
Element | Member | data type | Description |
---|---|---|---|
0 | leds | uint32_t | bitmap of active LEDs |
Table: callback parameters of GOAL_EIP_CB_ID_LED_CHANGED
Return Value
<ignored>
GOAL_EIP_CB_ID_DEVICE_RESET
Inform the application that the device will be reset. Depending on the platform the device is either reset or the reset is only simulated. Therefore the application must reinitialize its resources. The callback parameter indicates the reset type.
Parameter
Element | Member | data type | Description |
---|---|---|---|
0 | resetState | uint32_t | GOAL_EIP_RESET_* |
Table: callback parameters of GOAL_EIP_CB_ID_LED_CHANGED
Return Value
<ignored>
GOAL_EIP_CB_ID_REVISION_CHECK
If the compatibility bit is set in the Electronic Key Segment the application can decide whether a Minor Revision is supported or not. This means the application can decide if it is stil compatible to a previous revision of itself.
Parameter
Element | Member | data type | Description |
---|---|---|---|
0 | minorRevision | uint8_t | requested minor revision of application |
Table: callback parameters of GOAL_EIP_CB_ID_REVISION_CHECK
Return Value
GOAL_OK Revision is supported
other Revision is not supported
GOAL_EIP_CB_ID_ACD_CONFLICT
Inform the application about a detected address conflict. Depending on whether the application return GOAL_OK or GOAL_ERROR, the device will try to solve the conflict with the configured behavior or transit into an error fault. The configuration is done with the function goal_eipCfgAcdConflictFallbackIp().
Parameter
Element | Member | data type | Description |
---|---|---|---|
0 | acdActivity | uint8_t | ACD status as following: |
1 | acdRemoteMac | uint8_t * | Array of device MAC, which caused address conflict |
2 | acdArpPru | uint8_t * | Array of raw frame, which caused address conflict |
3 | flgDhcpEnabled | GOAL_BOOL_T | DHCP enabled |
Table: callback parameters of GOAL_EIP_CB_ID_ACD_CONFLICT
Return Value
GOAL_OK - Device will append configured behavior
GOAL_ERROR - Device will transit into an error fault