RegisterMailboxCallback

Registers a function that the KINGSTAR Subsystem will call when a mailbox message comes in.

Syntax

KsError RegisterMailboxCallback(
     MailboxCallback callback,
     PVOID context
);

Parameters

callback: pointer to the function that will be called when a mailbox message arrives. See the MailboxCallback type.

context: pointer passed to the callback function if you need it.

Return value

If the function succeeds, it returns errNoError, otherwise an error code. For more information about the error code, see the KsError list.

Usable EtherCAT states

ecatInit, ecatBoot, ecatPreOP, ecatSafeOP, ecatOP

Example

Copy
/*
*    Assume that there is already a callback function in namespace userApp:
*    namespace userApp
*    {
*        static UCHAR VoEData[2048] = { 0 };
*
*        int mbCallBack(PVOID Context, INT SlaveId, MailboxType Type, MailboxData Data)
*        {
*            if (Type == MailboxType::mbVoe)
*                memcpy((void*)VoEData, (void*)Data.Voe.Data, Data.Voe.DataLength);
*
*            return 0;
*        }
*    }
*/
MailboxCallback callBack = userApp::mbCallBack;
nRet = RegisterMailboxCallback(callBack, NULL);

Requirements

  RT Win32
Minimum supported version 4.2 4.2
Header ksapi.h ksapi.h
Library KsApi_Rtss.lib KsApi.lib

See also

Create

RegisterCallback

Start