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

◆ PN_API_IOD_recordWriteCbf

typedef uint32_t(* PN_API_IOD_recordWriteCbf) (PN_API_IOD_Handle_t *const pnHandle, uint32_t api, uint16_t arNum, uint16_t sessionKey, uint32_t sequenceNum, const PN_API_IOD_DevAddr_t *const addr, uint32_t recordIndex, const uint32_t *bufLen, const uint8_t *buffer, PN_API_IOD_ErrState_t *errState)

Callback function prototype to write user record data as requested by the IO controller.

When the stack receives a "record write" request from the IO controller, it calls this callback function which needs to be implemented by the user application to write a record accessed through slot/subslot number and index, based on the the value in buffer.

Warning
The maximum data length determined by the stack must not be surpassed in any situation.
Parameters
[in]pnHandleProfinet API Handle.
[in]apiApplication Process Identifier.
[in]arNumAR number.
[in]sessionKeySession key.
[in]sequenceNumSequence number.
[in]addrGeographical address (slot/subslot) of the module/submodule.
[in]recordIndexIndex of the record.
[in]bufLenLength of data to write (only for synchronous).
[in]bufferBuffer containing data to be written (only for synchronous).
[in,out]errStateProfinet error state (only for synchronous).
Returns
result of the operation as uint32_t.
Return values
PN_API_OKSuccess.
PN_API_NOT_OKSomething went wrong.
PN_API_ERR_PARAMInvalid parameter.
Example
#include "pn_api_iod_callbacks.h"
#include "pn_api_iod_record.h"
#include "pn_api_iod_startup.h"
//Implement the callback function in the user application
uint32_t api, uint16_t arNum, uint16_t sessionKey, uint32_t sequenceNum,
PN_API_IOD_DevAddr_t *addr, uint32_t recordIndex, uint32_t *bufLen,
uint8_t *buffer, PN_API_IOD_ErrState_t *errState)
{...}
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.
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
Definition pn_api_iod_types.h:740
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