EtherCAT SubDevice
 
Loading...
Searching...
No Matches
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 provides the following API to register the customer callbacks :

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 output 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);
//SubDevice to MainDevice 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 MainDevice.
pvPayload = (void*) DPR_getBuffer(DPR_eService_GetInputProcessData, i32uLength_p);
return pvPayload;
}
//MainDevice to SubDevice 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 MainDevice.
pvPayload = (void*) DPR_getBuffer(DPR_eService_SetOutputProcessData, i32uLength_p);
return pvPayload;
}
//SubDevice to MainDevice 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);
}
//MainDevice to SubDevice 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);
}
uint32_t EC_API_SLV_cbRegisterPostSeqInputPDBuffer(EC_API_SLV_SHandle_t *pHandle, EC_API_SLV_CBPostSeqInputPD_t cbFunc, void *pContext)
This is the function to register a function which releases an external Process data buffer.
Definition ecSlvApi_pdo.c:2323
uint32_t EC_API_SLV_cbRegisterPreSeqOutputPDBuffer(EC_API_SLV_SHandle_t *pHandle, EC_API_SLV_CBPreSeqOutputPD_t cbFunc, void *pContext)
This is the function to register a function which gets an external Process data buffer.
Definition ecSlvApi_pdo.c:2281
uint32_t EC_API_SLV_cbRegisterPostSeqOutputPDBuffer(EC_API_SLV_SHandle_t *pHandle, EC_API_SLV_CBPostSeqOutputPD_t cbFunc, void *pContext)
This is the function to register a function which releases an external Process data buffer.
Definition ecSlvApi_pdo.c:2366
uint32_t EC_API_SLV_cbRegisterPreSeqInputPDBuffer(EC_API_SLV_SHandle_t *pHandle, EC_API_SLV_CBPreSeqInputPD_t cbFunc, void *pContext)
This is the function to register a function which gets an external Process data buffer.
Definition ecSlvApi_pdo.c:2238
Definition ecSlvApiInternal.h:331