RtecatRegisterMailboxCallback
RtecatRegisterMailboxCallback registers a function that the E-CAT Fieldbus will call when a mailbox message arrives.
Syntax
RTECAT_ERROR RtecatRegisterMailboxCallback(
[in] RTECAT_HANDLE MainDevice,
[in] MAILBOX_CALLBACK UserCallback,
[in] VOID* pContext
);
Parameters
[in] MainDevice
A handle to a MainDevice. To retrieve the corresponding handle, use RtecatCreateMainDevice or RtecatOpenMainDevice.
[in] UserCallback
A pointer to the function of type MAILBOX_CALLBACK to be called when a mailbox message arrives. MAILBOX_CALLBACK is defined in RtecatApi.h:
typedef int(*MAILBOX_CALLBACK)(PVOID Context, ULONG SubDeviceIndex, RTECAT_MAILBOX_TYPE Type, RTECAT_MAILBOX_DATA Data);
Parameters:
Context: A pointer to the user data.
SubDeviceIndex: The SubDevice index in the SubDevice array.
Type: The message type sent by the SubDevice.
Data: The message content.
[in] pContext
A pointer used to pass data to the callback function.
Return Values
The function returns an RTECAT_ERROR value. If the function succeeds, it returns ecatErrNoError. If the function fails, it returns a different value.
Possible return values:
| Return value | Meaning |
|---|---|
|
ecatErrNoError |
The function succeeded. |
|
ecatErrNullParameter |
Parameter UserCallback is NULL. |
|
ecatErrWrongParameter |
Parameter MainDevice is invalid. |
|
ecatErrMainDeviceNotReady |
The MainDevice is not ready. |
|
ecatErrWrongMainDeviceStatus |
The command can't be used in the current MainDevice status. |
Remarks
RtecatRegisterMailboxCallback is a synchronous function that executes immediately and returns a result upon completion.
wRTOS Runtime stops calling the callback function if it returns a non-zero return code.
Requirements
| Minimum supported version | Header | Library |
|---|---|---|
|
wRTOS 1.0 SDK |
RtecatApi.h |
RtecatApi_W64.lib (Windows), RtecatApi.lib (RTSS) |
See Also: