rchSetPacketReceiver (Function) |
|
Registers or unregisters an event-driven receiver for incoming RTCU Communication Hub packets. The callback and the rchReceivePacket polling receiver are mutually exclusive. Unregister the callback before using polling reception.
Input: cb : CALLBACK Address of a callback with the rchPacketReceiver signature. Omit cb to unregister event-driven reception.
arg : DINT (Default 0) Application-defined value passed unchanged to every callback invocation.
Returns: INT
Operation: •Packets are delivered in FIFO order to one non-reentrant callback. The queue holds three packets, including the callback currently executing. Further packets are rejected as busy. •The Data parameter is valid only while the callback is executing. Copy data that must be used later. •In packet mode 0, a packet is acknowledged when accepted into the queue and the callback return value is ignored. •In packet mode 1, the callback return value is sent as the packet reply. This is equivalent to calling rchReceivePacketDone when using polling reception.
Keep the callback short and deterministic. Defer lengthy work after copying the data.
Declaration: FUNCTION ALIGN rchSetPacketReceiver : INT; The callback function must use the rchPacketReceiver declaration shown above.
Example: FUNCTION CALLBACK onPacket : INT; |