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

◆ PN_API_IOD_outSubmodSubstValReadCbf

typedef PN_API_IOD_IOXS(* PN_API_IOD_outSubmodSubstValReadCbf) (PN_API_IOD_Handle_t *const pnHandle, PN_API_IOD_DevAddr_t *const addr, const uint32_t bufLen, uint8_t *const buffer, uint16_t *const substMode, uint16_t *const substActive)

Callback function prototype to read substitute values for output submodule.

When the IO device receives the special read record requests at index 0x8028 (read input data) and index 0x8029 (read output data), it has to respond with input/output data. Profinet stack offers two ways to deal with this:

  1. completely delegates this task to the user application by setting the value of PN_API_IOD_INCLUDE_REC8028_8029 to 0. In this case, these two special records are treated as normal ones, hence, this callback function is not needed.
  2. Profinet stack itself handles these requests while giving the user application the opportunity to update (or substitute) the value of the submodule's output data through this callback function.
Parameters
[in]pnHandleProfinet API Handle.
[in]addrGeographical address (slot/subslot) of the module/submodule.
[in]bufLenLength of the submodule output substitute data.
[in]bufferPointer to submodule output substitute data.
[in,out]substModeSubstitution mode:
0: substitute value is set to zero.
1: last output value received from controller.
2: replacement value decided by the application.
[in,out]substActiveSubstitute active flag:
0: normal operation (IOXS are GOOD).
1: otherwise (substitute value active).
Returns
IOCS as PN_API_IOD_IOXS.
Return values
PN_API_IOD_STATUS_GOODData received is good.
PN_API_IOD_STATUS_BADData received is bad.
Example
#include "pn_api_iod_alarm.h"
#include "pn_api_iod_callbacks.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,
uint32_t bufLen,
uint8_t *const buffer,
uint16_t *const substMode,
uint16_t *const substActive);
{...}
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_cbOutSubmodSubstValRead(PN_API_IOD_Handle_t *const pnHandle, PN_API_IOD_DevAddr_t *const addr, const uint32_t bufLen, uint8_t *const buffer, uint16_t *const substMode, uint16_t *const substActive)
Callback function to read substitute values for output submodule.
Module/Submodule address (logical/geographical).
Definition pn_api_iod_types.h:445
PN_API_IOD_outSubmodSubstValReadCbf outSubmodSubstValRead
Definition pn_api_iod_callbacks.h:67
Structure representing a set of callbacks.
Definition pn_api_iod_callbacks.h:41