COIfRead

Description

This function waits for a CAN frame on the interface without timeout. If a CAN frame is received, the given receive frame buffer will be filled with the received data.

Prototype

CPU_INT16S COIfRead(CO_IF *cif, CO_IF_FRM *frm);

ParameterDescription
cifpointer to the interface structure
frmpointer to the receive frame buffer

Returned Value

>0     the size of CO_IF.FRM on success

<0     the internal CanBus error code

Example

The read function is rarely used from within the application, because the CANopen will receive all messages by default and allows to work on all non-CANopen messages with a callback function. See CANopen Config Manual for details on working with the callback functions.

If necessary, the following example show how to call the blocking receive function for the interface of the CANopen node AppNode:


    CO_IF_FRM   frame;
    CPU_INT16S  err;
    :
    err = COIfRead (&(AppNode.If), &frame);
    if (err < 0) {
        /* error in interface layer */
    } else {
        /* frame contains received data */
    }
    :