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

◆ PN_API_IOD_activateCyclicDataExchange()

uint32_t PN_API_IOD_activateCyclicDataExchange ( PN_API_IOD_Handle_t *const  pnHandle)

Activates the exchange of IO data between the user application and Profinet stack for all ARs (RT, IRT).

This function allows the Profinet stack to cyclically send event information to the user application upon completing the transmission or reception of an RTC frame. The user application then should again trigger the process of reading/writing of input/output data (see PN_API_IOD_initiateDataRead() and PN_API_IOD_initiateDataWrite()) in order to transmit/receive another up-to-date RTC frame.

Remarks
  1. Without this function, the IO data exchange between the IO device and IO controller would still take place but on the stack level (isolated from the user application). This means, the cyclic exchange will continue but the values of input/output data won't be up to date.
  2. Before calling this function, the user application needs to have a mechanism to handle the event coming from Profinet stack. In demo app, this mechanism is implemented as a separate thread (see PN_APP_IOD_initCyclicDataExchange()) which blocks while waiting for the event, and once it arrives, an IO data read/write process is initiated.
Parameters
[in]pnHandleProfinet API Handle.
Returns
result of the operation as uint32_t.
Return values
PN_API_OKSuccess.
PN_API_NOT_OKSomething went wrong.
Example
#include "pn_api_iod_data.h"
#include "pn_api_iod_startup.h"
PN_API_IOD_Handle_t* pnHandle = NULL;
uint32_t status;
pnHandle = PN_API_IOD_new();
//Prepare and call PN_API_IOD_startup()
...
//Implement PN_API_IOD_dataWriteCbf in the user application
//Implement PN_API_IOD_dataReadCbf in the user application
...
//Register callback functions
...
status = PN_APP_IOD_initCyclicDataExchange(pnHandle); //as an example
uint32_t PN_API_IOD_activateCyclicDataExchange(PN_API_IOD_Handle_t *const pnHandle)
Activates the exchange of IO data between the user application and Profinet stack for all ARs (RT,...
PN_API_IOD_Handle_t * PN_API_IOD_new(void)
Creates Profinet API handle.
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
uint32_t PN_APP_IOD_initCyclicDataExchange(PN_API_IOD_Handle_t *const pnHandle)
Initiates continuous exchange of IO data between the user application and Profinet stack for all ARs ...