EtherCAT Slave  1.06.01
Process data memory access

This chapter provides guidance to the developers who want to optimize the access to the process data. The SDK uses by default the process data buffers provided by the Beckhoff Stack if none is provided. The PDO setter and getter functions listed in the PDO Help functions copy the process data from one memory area to another. Those functions have time and performance costs, therefore, the SDK allows to register callbacks to access the customer specific memory areas and enable zero copy behaviour.

The SDK API provides the customer the following API:

Function Description
EC_API_SLV_cbRegisterPreSeqInputPDBuffer Request a buffer to read input process data
EC_API_SLV_cbRegisterPreSeqOutputPDBuffer Request a buffer to write output process data
EC_API_SLV_cbRegisterPostSeqInputPDBuffer Triggered after input process data has been read
EC_API_SLV_cbRegisterPostSeqOutputPDBuffer Triggered after input process data has been written

Using these functions, the end user can register its own callbacks and handle the process data on its own will. For instance, the customer can implement a triple buffer mechanism in a Dual Port RAM and the SDK will get and set the data from it.

EC_API_SLV_SHandle_t* ptSlave = pApplicationInstance_p->ptEcSlvApi;
EC_API_SLV_cbRegisterPreSeqInputPDBuffer (ptSlave, ptSlave, DPR_PreSequenceInputProcessData);
EC_API_SLV_cbRegisterPreSeqOutputPDBuffer (ptSlave, ptSlave, DPR_PreSequenceOutputProcessData);
EC_API_SLV_cbRegisterPostSeqInputPDBuffer (ptSlave, ptSlave, DPR_PostSequenceInputProcessData);
EC_API_SLV_cbRegisterPostSeqOutputPDBuffer (ptSlave, ptSlave, DPR_PostSequenceOutputProcessData);
//Slave to Master COMM (TXPDO)
void* DPR_PreSequenceInputProcessData(void* pContext_p, uint32_t i32uLength_p)
{
void* pvPayload = NULL;
// Get latest processdata of application from DPR to send to the Master.
pvPayload = (void*) DPR_getBuffer(DPR_eService_GetInputProcessData, i32uLength_p);
return pvPayload;
}
//Master to Slave COMM (RXPDO)
void* DPR_PreSequenceOutputProcessData(void* pContext_p, uint32_t i32uLength_p)
{
void* pvPayload = NULL;
//Get dirty buffer to write the process data received from the Master.
pvPayload = (void*) DPR_getBuffer(DPR_eService_SetOutputProcessData, i32uLength_p);
return pvPayload;
}
//Slave to Master COMM (TXPDO)
void DPR_PostSequenceInputProcessData(void* pContext_p, void* pvBuffer_p, uint32_t i32uLength_p)
{
//Buffer has been read. Nothing to do.
DPR_setBuffer(DPR_eService_GetInputProcessData, pvBuffer_p, i32uLength_p);
}
//Master to Slave COMM (RXPDO)
void DPR_PostSequenceOutputProcessData(void* pContext_p, void* pvBuffer_p, uint32_t i32uLength_p)
{
//Buffer has been written. Flip the dirty buffer with the latest buffer.
DPR_setBuffer(DPR_eService_SetOutputProcessData, pvBuffer_p, i32uLength_p);
}


EC_API_SLV_cbRegisterPostSeqInputPDBuffer
void EC_API_SLV_cbRegisterPostSeqInputPDBuffer(EC_API_SLV_SHandle_t *pEcSlaveApi_p, void *pContext_p, EC_API_SLV_CBPostSeqInputPD_t cbFunc_p)
This is the function to register a function which releases an external Process data buffer.
Definition: ecSlvApi_ProcDataStub.c:959
EC_API_SLV_SHandle_t
struct EC_API_SLV_SHandle EC_API_SLV_SHandle_t
EC_API_SLV_SHandle_t describes the EtherCAT Slave API.
Definition: ecSlvApi.h:135
EC_API_SLV_cbRegisterPreSeqInputPDBuffer
void EC_API_SLV_cbRegisterPreSeqInputPDBuffer(EC_API_SLV_SHandle_t *pEcSlaveApi_p, void *pContext_p, EC_API_SLV_CBPreSeqInputPD_t cbFunc_p)
This is the function to register a function which gets an external Process data buffer.
Definition: ecSlvApi_ProcDataStub.c:881
EC_API_SLV_cbRegisterPostSeqOutputPDBuffer
void EC_API_SLV_cbRegisterPostSeqOutputPDBuffer(EC_API_SLV_SHandle_t *pEcSlaveApi_p, void *pContext_p, EC_API_SLV_CBPostSeqOutputPD_t cbFunc_p)
This is the function to register a function which releases an external Process data buffer.
Definition: ecSlvApi_ProcDataStub.c:998
EC_API_SLV_cbRegisterPreSeqOutputPDBuffer
void EC_API_SLV_cbRegisterPreSeqOutputPDBuffer(EC_API_SLV_SHandle_t *pEcSlaveApi_p, void *pContext_p, EC_API_SLV_CBPreSeqOutputPD_t cbFunc_p)
This is the function to register a function which gets an external Process data buffer.
Definition: ecSlvApi_ProcDataStub.c:920