PROFINET Device4.2.0
 
Loading...
Searching...
No Matches

◆ PN_API_IOD_dataWriteCbf

typedef PN_API_IOD_IOXS(* PN_API_IOD_dataWriteCbf) (PN_API_IOD_Handle_t *const pnHandle, PN_API_IOD_DevAddr_t *const addr, const uint32_t bufLen, uint8_t *const buffer, const PN_API_IOD_IOXS remoteIocs)

Callback function prototype to write input data from the physical input of a submodule to the IO controller.

This function is called by Profinet stack after the user application calls PN_API_IOD_initiateDataWrite(). The user application needs to fill up the buffer. IOPS must be returned to the stack as a return value. This value is communicated to the IO controller.

Warning
The length specified with bufLen must not be exceeded under any circumstances.
Parameters
[in]pnHandleProfinet API Handle.
[in]addrGeographical address (slot/subslot) of the module/submodule.
[in]bufLenLength of data.
[in]bufferPointer to data buffer to read from.
[in]remoteIocsLast IOCS from the IO controller, can be: PN_API_IOD_STATUS_BAD or PN_API_IOD_STATUS_GOOD.
Returns
Local IOPS as PN_API_IOD_IOXS.
Return values
PN_API_IOD_STATUS_GOODData sent is good.
PN_API_IOD_STATUS_BADData sent is bad.
Example
#include "pn_api_iod_callbacks.h"
#include "pn_api_iod_data.h"
#include "pn_api_iod_startup.h"
//Implement the callback function in the user application
PN_API_IOD_Handle_t *const pnHandle,
PN_API_IOD_DevAddr_t *const addr,
const uint32_t bufLen, uint8_t *const buffer,
const PN_API_IOD_IOXS remoteIocs)
{...}
PN_API_IOD_Handle_t* pnHandle = NULL;
uint32_t status;
pnHandle = PN_API_IOD_new();
//Store callback functions implemented by the user application
...}
//Register callback function
status = PN_API_IOD_registerCallbacks(pnHandle, &callbacks);
PN_API_IOD_Handle_t * PN_API_IOD_new(void)
Creates Profinet API handle.
uint32_t PN_API_IOD_registerCallbacks(PN_API_IOD_Handle_t *const pnHandle, PN_API_IOD_Callbacks_t *callbacksInst)
Register callback functions.
#define PN_API_IOD_IOXS
IO provider/consumer status.
Definition pn_api_iod_types.h:44
struct PN_API_IOD_Handle PN_API_IOD_Handle_t
API handle instance which holds IO device's info.
Definition pn_api_iod_types.h:61
PN_API_IOD_IOXS PN_APP_IOD_cbDataWrite(PN_API_IOD_Handle_t *const pnHandle, PN_API_IOD_DevAddr_t *const addr, const uint32_t bufLen, uint8_t *const buffer, const PN_API_IOD_IOXS remoteIocs)
Callback function to write input data from the physical input of a submodule to the IO controller.
Module/Submodule address (logical/geographical).
Definition pn_api_iod_types.h:445
PN_API_IOD_dataWriteCbf writeData
Definition pn_api_iod_callbacks.h:55
Structure representing a set of callbacks.
Definition pn_api_iod_callbacks.h:41