AdsSyncAddDeviceNotificationReqEx

A notification is defined within an ADS server (e.g. PLC). When a certain event occurs a function (the callback function) is invoked in the ADS client (C program).

LONG AdsSyncAddDeviceNotificationReqEx(
  LONG                     port,
  PAmsAddr                 pAddr,
  ULONG                    nIndexGroup,
  ULONG                    nIndexOffset,
  PAdsNotificationAttrib   pNoteAttrib,
  PAdsNotificationFuncEx   pNoteFunc,
  ULONG                    hUser,
  PULONG                   pNotification
);

Parameter

port

[in] port number of an ADS port that had previously been opened with AdsPortOpenEx or AdsPortOpen.

pAddr

[in] Structure with NetId and port number of the ADS server.

nIndexGroup

[in] IndexGroup.

nIndexOffset

[in] IndexOffset.

pNoteAttrib

[in] Pointer to the structure that contains further information.

pNoteFunc

[in] Name of the callback function.

hUser

[in] 32-bit value that is passed to the callback function.

pNotification

[out] Address of the variable that will receive the handle of the notification.

Return value

Returns the function's error state.

Limitation:

A limited number of 550 notifications are available per ADS port.

Comments

If the TwinCAT router is stopped and then started again, the notifications become invalid. You can trap this event with the AdsAmsRegisterRouterNotification() function.

Sample

See Sample 8: Event-driven reading