Preparing an Endpoint with NvSciEventService for Read/Write

To enable read/write on an endpoint, the following steps must be completed.

  1. Open the endpoint with an event service that is previously instantiated.
  2. Get the event notifier associated with the endpoint that was created in Step 1.

    For the event associated with the notifier to be serviced in an event handler, set the event handler with the notifier.

    The event handler is called in WaitForEvent(), WaitForMultipleEvents() or WaitForMultipleEventsExt() when the associated event arrives.

  3. Get the endpoint information, such as the number of frames and each frame size. This is important as only single frames can be read/written at a given time.
  4. Reset the endpoint. This is important as it ensures that the endpoint is not reading/writing any stale data (for example, from the previous start or instance).
Note:

The event associated with an endpoint is called a native event. It is created internally when NvSciIpcGetEventNotifier() is called and is not visible to the application.

Prepare an endpoint and getting an event notifier

NvSciEventLoopService *eventLoopService;
NvSciIpcEndpoint ipcEndpoint;
NvSciEventNotifier *eventNotifier;
struct NvSciIpcEndpointInfo info;
NvSciError err;
err = NvSciIpcOpenEndpointWithEventService("ipc_endpoint", &ipcEndpoint, &eventLoopService->EventService); 
if (err != NvSciError_Success) {
        goto fail;
}
err = NvSciIpcGetEventNotifier(ipcEndpoint, &eventNotifier);
if (err != NvSciError_Success) {
        goto fail;
}
err = NvSciIpcGetEndpointInfo(ipcEndpoint, &info);
if (err != NvSciError_Success) {
    goto fail;
}
/* Option: set a handler if the event wants to be serviced in the handler */
err = eventNotifier->SetHandler(eventNotifier, eventHandler, cookie, 0);
If (err != NvSciError_Success) {
        goto fail;
}
printf("Endpointinfo: nframes = %d, frame_size = %d\n", info.nframes, info.frame_size);
err = NvSciIpcResetEndpointSafe(ipcEndpoint);
if (err != NvSciError_Success) {
    goto fail;
}