Application Callbacks

To use the full potential of POWERLINK the stack allows you to interact at several stages of the protocol. For example, you may receive a callback after the device transition to a new communication state.

goal_eplNewStateInd - Indicate transition to a new communcation state

This function will be indicated at the slave, if it will be forced to another communication state. It is called before the transition change. This user interface ensures a save behavior of the application, before the node goes to another state. Additionally, a change to READY_TO_OPERATE can be prevent.

Returns a GOAL_STATUS_T as result.

goal_eplNewStateInd parameters

 

goal_eplNewStateInd parameters

 

Parameter

Description

GOAL_EPL_T *pHdlEpl

GOAL POWERLINK handle

GOAL_EPL_NODE_STATE_T newState

new state

GOAL_BOOL_T success

state of transition to new state

See nmtslave.c for a demonstration.

goal_eplSwResetInd - Reset the device

This function will reset the device. It's called after a "NMT SwReset" command was received.

In this function the devices should be reinitialized completely. All application parameters from the Object Dictionary are set to the default values before this function is called. The user has to ensure that his application will be reset. Additionally, it is possible for the application to load parameters from a nonvolatile memory. Returns a GOAL_STATUS_T as result.

goal_eplSwResetInd parameters

goal_eplSwResetInd parameters

Parameter

Description

GOAL_EPL_T *pHdlEpl

GOAL POWERLINK handle

See nmtslave for a demonstration.

goal_eplResetApplInd - Reset the application

This function will reset the device's application. It's called after a "NMT Reset Node" command was received.

All application parameters from the Object Dictionary are set to the default values before this function is called. The user has to ensure that his application will be reset. Additionally, it is possible for the application to load parameters from a nonvolatile memory. Returns a GOAL_STATUS_T as result.

goal_eplResetApplInd parameters

goal_eplResetApplInd parameters

Parameter

Description

GOAL_EPL_T *pHdlEpl

GOAL POWERLINK handle

goal_eplResetCommInd - Reset communication parameters

This function is user defined. It is called after a "NMT Reset Communication" command was received.

All communication parameters from the Object Dictionary besides the node ID are set to the default values before this function is called. The default values are taken from the object dictionary's "default" value, stored as defaultVal in the object dictionary's VALUE_DESC_T struct. In this function the EPL node can get a new node id from a DIP-Switch or nonvolatile memory. Further communication parameters can be loaded from a nonvolatile memory too. In this case the object dictionary values have to be overwritten using goal_eplPutObj() and goal_eplSetCommPar() . Returns a GOAL_STATUS_T as result.

goal_eplResetCommInd parameters

goal_eplResetCommInd parameters

Parameter

Description

GOAL_EPL_T *pHdlEpl

GOAL POWERLINK handle

See nmtslave for a demonstration.

goal_eplResetConfInd - Reset configuration

This function is user defined. It is called after a "NMT Reset Configuration" command was received.

In this function the EPL node can get a new node id from a DIP-Switch or nonvolatile memory. Further communication parameters can be loaded from a nonvolatile memory too. In this case the object dictionary values have to be overwritten using goal_eplPutObj() and goal_eplSetCommPar() . Returns a GOAL_STATUS_T as result.

goal_eplResetConfInd parameters

goal_eplResetConfInd parameters

Parameter

Description

GOAL_EPL_T *pHdlEpl

GOAL POWERLINK handle

See nmtslave for a demonstration.

goal_eplGetEplNodeId - Get the node ID of the device

This function has to be filled by the user. It returns the node ID, in the range of 1..254, of the device from e.g. a DIP switch or nonvolatile memory to the EPL layer.

It is called from the EPL layer to initialize the node. Returns a GOAL_STATUS_T as result.

goal__eplGetEplNodeId parameters

goal__eplGetEplNodeId parameters

Parameter

Description

GOAL_EPL_T *pHdlEpl

GOAL POWERLINK handle

uint8_t *pEplNodeId

node ID pointer

goal_eplSdoInitCon - Init SDO connection finished

This function is called after a SDO connection was established or the initialization was aborted. It has to be filled by the user. The parameter flgTimeout gets the information for a timeout or success. Returns a GOAL_STATUS_T as result.

goal_eplSdoInitCon parameters

goal_eplSdoInitCon parameters

Parameter

Description

GOAL_EPL_T *pHdlEpl

GOAL POWERLINK handle

uint8_t node

actual node number

GOAL_BOOL_T flgTimeout

flag for connection timeout

goal_eplSdoWrInd - Indicate the occurence of a SDO write access

This function is called if an SDO write request reaches the EPL SDO server. Parameters of the function are the Index and Sub Index of the entry in the local object dictionary where the data should be written to.

If numerical data with size up to 4 bytes should be written, the library stores the previous value in temporary buffer. The new value is put into the local object dictionary.

If the application does not accept this new value, i.e. the function returns with a value > 0, the old value is restored from the temporary buffer to the object dictionary and the SDO write request will be answered with an abort domain transfer by the library. The abort code can be specified by the return -value.

The return value, which has to be specified by the application, selects the possible protocol answer of the write request to the SDO server.

goal_eplSdoWrInd parameters

goal_eplSdoWrInd parameters

Parameter

Description

GOAL_EPL_T *pHdlEpl

GOAL POWERLINK handle

uint16_t index

index to object

uint8_t subIndex

subindex to object

Returns a GOAL_STATUS_T as result. Typical values are listed in the following table.

goal_eplSdoWrInd return values

goal_eplSdoWrInd return values

Parameter

Description

GOAL_OK

success

GOAL_EPL_E_NONEXIST_OBJECT

object doesn't exist

GOAL_EPL_E_NONEXIST_SUBINDEX

subindex doesn't exist

GOAL_EPL_E_NO_READ_PERM

read is not permitted

GOAL_EPL_E_NO_WRITE_PERM

write is not permitted

GOAL_EPL_E_MAP

mapping error

GOAL_EPL_E_DATA_LENGTH

data length error

GOAL_EPL_E_TRANS_TYPE

wrong trans type

GOAL_EPL_E_VALUE_TO_HIGH

value to high

GOAL_EPL_E_VALUE_TO_LOW

value to low

GOAL_EPL_E_WRONG_SIZE

wrong size

GOAL_EPL_E_PARA_INCOMP

parameter incompatible

GOAL_EPL_E_HARDWARE_FAULT

hardware fault

GOAL_EPL_E_SDO_CMD_SPEC_INVALID

sdo command specifier invalid

GOAL_EPL_E_MEM

memory error

GOAL_EPL_E_SDO_TIMEOUT

SDO timeout

GOAL_EPL_E_INVALID_TRANSMODE

sdo invalid transmode

GOAL_EPL_E_DEVICE_STATE

bad device state

GOAL_ERROR

default error

goal_eplSdoRdInd - Indicate the occurence of a SDO read access

This function determines a reaction to the device for an index - subindex read access via SDO. With this function the object dictionary has to be made up to date e.g. by reading of digital inputs. If an error occurs an abort domain transfer will be started.

The return value, which has to be specified by the application, selects the possible protocol answer of the write request to the SDO server.

goal_eplSdoRdInd parameters

goal_eplSdoRdInd parameters

Parameter

Description

GOAL_EPL_T *pHdlEpl

GOAL POWERLINK handle

uint16_t index

index to object

uint8_t subIndex

subindex to object

Returns a GOAL_STATUS_T as result. Typical values are listed in the following table.

goal_eplSdoRdInd return values

goal_eplSdoRdInd return values

Parameter

Description

GOAL_OK

success

GOAL_EPL_E_NONEXIST_SUBINDEX

subindex doesn't exist

GOAL_EPL_E_NO_READ_PERM

read is not permitted

GOAL_EPL_E_NO_WRITE_PERM

write is not permitted

GOAL_EPL_E_MAP

mapping error

GOAL_EPL_E_DATA_LENGTH

data length error

GOAL_EPL_E_TRANS_TYPE

wrong trans type

GOAL_EPL_E_VALUE_TO_HIGH

value to high

GOAL_EPL_E_VALUE_TO_LOW

value to low

GOAL_EPL_E_WRONG_SIZE

wrong size

GOAL_EPL_E_PARA_INCOMP

parameter incompatible

GOAL_EPL_E_HARDWARE_FAULT

hardware fault

GOAL_EPL_E_SDO_CMD_SPEC_INVALID

sdo command specifier invalid

GOAL_EPL_E_MEM

memory error

GOAL_EPL_E_SDO_TIMEOUT

SDO timeout

GOAL_EPL_E_INVALID_TRANSMODE

sdo invalid transmode

GOAL_EPL_E_SDO_OTHER

unknown SDO error

GOAL_EPL_E_DEVICE_STATE

bad device state

GOAL_ERROR

default error

goal_eplTestSdoValue - Check the value of a SDO before writing to object dictionary

This function is called before a write access to an object should be done. At this point the EPL library has been tested the correctness of the attributes for this object. The user can start further tests for this write access. If the return value is not GOAL_OK the write access will be refused.

Parameter are index, subindex, pointer to the data (little endian format) and the length of the data. The function is called immediately after receiving the first message - in the case of a segmented transfer not all data may be available. Returns a GOAL_STATUS_T as result.

goal_eplTestSdoValue parameters

goal_eplTestSdoValue parameters

Parameter

Description

GOAL_EPL_T *pHdlEpl

GOAL POWERLINK handle

uint16_t index

index of object

uint8_t subIndex

subindex of object

void *pData

pointer to new data

uint32_t size

data size

goal_eplSdoWrCon - Confirmation function for SDO write access

This function signs that the message sent by goal_eplWriteSdoReq() was confirmed by the SDO server. It handles errors and is useful for program synchronization. If the flgError isn't zero, the last SDO transfer was terminated by an abort domain transfer. Returns a GOAL_STATUS_T as result.

The reason for the termination contains the flgError.

combinations of the flgError

combinations of the flgError

Parameter

Description

GOAL_EPL_E_SDO_TIMEOUT

timeout

GOAL_EPL_E_SDO_NO_ERROR

no error occurs

GOAL_EPL_E_SDO_SERVICE

the service failed

GOAL_EPL_E_SDO_ACCESS

access

GOAL_EPL_E_SDO_OTHER

unknown SDO error

GOAL_EPL_E_SDO_UNSUPP_ACCESS

unsupported access

GOAL_EPL_E_SDO_NONEXIST_OBJECT

object doesn't exist

GOAL_EPL_E_SDO_INCONS_PARA

inconsistent parameter

GOAL_EPL_E_SDO_ILLEG_PARA

illegal parameter

GOAL_EPL_E_SDO_HARDWARE_FAULT

hardware fault

GOAL_EPL_E_SDO_TYPE_CONFLICT

false type

GOAL_EPL_E_SDO_INCONS_OBJ_ATTR

inconsistent object attribute

goal_eplSdoWrCon parameters

goal_eplSdoWrCon parameters

Parameter

Description

GOAL_EPL_T *pHdlEpl

GOAL POWERLINK handle

uint8_t sdoNr

number of SDO

uint32_t flgError

errorflag, if zero sucess

goal_eplSdoRdCon - Confirmation function for SDO read access

This functions signs that the message sent by goal_eplReadSdoReq() was confirmed by the SDO Server. It handles errors and is useful for program synchronization. If the flgError isn't zero, the last SDO transfer was terminated by an abort domain transfer. The flgError contains the reason for the termination. In case of success the parameter pObj from goal_eplReadSdoReq() points to the read value. Returns a GOAL_STATUS_T as result.

combinations of the flgError

combinations of the flgError

Parameter

Description

GOAL_EPL_E_SDO_NO_ERROR

no error occurs

GOAL_EPL_E_SDO_SERVICE

the service failed

GOAL_EPL_E_SDO_INCONS_PARA

inconsistent parameter

GOAL_EPL_E_SDO_ILLEG_PARA

illegal parameter

GOAL_EPL_E_SDO_ACCESS

access

GOAL_EPL_E_SDO_UNSUPP_ACCESS

unsupported access

GOAL_EPL_E_SDO_NONEXIST_OBJECT

object doesn't exist

GOAL_EPL_E_SDO_INVALID_ADDRESS

invalid address

GOAL_EPL_E_SDO_HARDWARE_FAULT

hardware fault

GOAL_EPL_E_SDO_TYPE_CONFLICT

false type

GOAL_EPL_E_SDO_INCONS_OBJ_ATTR

inconsistent object attribute

GOAL_EPL_E_SDO_OTHER

unknown SDO error

GOAL_EPL_E_SDO_TIMEOUT

timeout

goal_eplSdoRdCon parameters

goal_eplSdoRdCon parameters

Parameter

Description

GOAL_EPL_T *pHdlEpl

GOAL POWERLINK handle

uint8_t sdoNr

number of SDO

uint32_t flgError

errorflag, if zero sucess

goal_eplSdoClosedInd - Connection closed indication

This function indicates, that a SDO connection is closed by the remote node. Returns a GOAL_STATUS_T as result.

goal_eplSdoClosedInd parameters

goal_eplSdoClosedInd parameters

Parameter

Description

GOAL_EPL_T *pHdlEpl

GOAL POWERLINK handle

uint8_t node

node id of remote node

GOAL_EPL_USER_T kind

kind of SDO (client or server)

goal_eplNewPdoValueInd - User indication for new rxPdo values

The function is called by the plc driver when a new value of mapped object of a rxPdo is received. Returns a GOAL_STATUS_T as result.

goal_eplNewPdoValueInd parameters

goal_eplNewPdoValueInd parameters

Parameter

Description

GOAL_EPL_T *pHdlEpl

GOAL POWERLINK handle

uint16_t index

mapped object index

uint16_t subIndex

mapped object subIndex

uint8_t *pAddr

mapped object data pointer

uint32_t size

mapped object data length

goal_eplDllErrorInd - Indicate errors on the Data Link Layer

This function has to be filled by the user. It indicates a physical error on the ethernet bus on the propagation of the EPL frames and errors on the EPL Data Link Layer. The Errors are handled by the Library and the drivers itself. So, this indication is only an information for the user. On communication error the user should reset the application. Returns a GOAL_STATUS_T as result.

The following errors are indicated by the DLL error code (as far as they are supported from the ethernet controller):

DLL error code

DLL error code

Parameter

Description

GOAL_EPL_E_DLL_LOSS_OF_LINK

loss of link

GOAL_EPL_E_DLL_BAD_PHYS_MODE

incorrect phys. ETH operation mode

GOAL_EPL_E_DLL_MAC_BUFFER

MAC buffer overflow or MAC buffer becomes empty

GOAL_EPL_E_DLL_CRC_TH

CRC failure threshold counter reached

GOAL_EPL_E_DLL_COLLISION

collision detected (only reported, if supported)

GOAL_EPL_E_DLL_LOSS_SOC_TH

Loss of SoC threshold counter reached

goal_eplDllErrorInd parameters

goal_eplDllErrorInd parameters

Parameter

Description

GOAL_EPL_T *pHdlEpl

GOAL POWERLINK handle

uint16_t errorCode

DLL error Code

goal_eplPdoErrorInd - PDO error indication

This function indicates, that a PDO error occurred. Based on the PDO number the user is able to appraise the error in detail. Returns a GOAL_STATUS_T as result.

goal_eplPdoErrorInd parameters

goal_eplPdoErrorInd parameters

Parameter

Description

GOAL_EPL_T *pHdlEpl

GOAL POWERLINK handle

uint16_t pdoNr

PDO number

uint16_t errorCode

error code

goal_eplLedInd - Set POWERLINK leds

This function indicates, that the POWERLINK status or error indication led has to be changed. Returns a GOAL_STATUS_T as result.

goal_eplLedInd parameters

goal_eplLedInd parameters

Parameter

Description

GOAL_EPL_T *pHdlEpl

GOAL POWERLINK handle

GOAL_EPL_LED_TYPE_T ledType

LED type

GOAL_BOOL_T flgLedOff

flag to set the LED off

goal_soaInd - Update the transmit PDO data

This function updates the the data objects of the transmit PDO before the POWERLINK stack assembles the PDO object. No returns.

goal_soaInd parameters

goal_soaInd parameters

Parameter

Description

GOAL_EPL_T *pHdlEpl

GOAL POWERLINK handle

Â