CODirRdBuffer

CODirRdBuffer

Description

This function reads a buffer byte stream from the given object directory. The object entry is addressed with the given key and the bytes will be read from the given destination buffer of the given length.

Prototype

CPU_INT16S CODirRdBuffer(CO_DIR     *cod,
                         CPU_INT32U  key,
                         CPU_INT08U *buffer,
                         CPU_INT32U  len);

ParameterMeaning
codpointer to the CANopen object directory
keyobject entry key; should be generated with the macro CO_DEV()
bufferpointer to the destination buffer
lenlength of destination buffer

Returned Value

 = CO_ERR.NONE   Successful operation

!= CO_ERR.NONE  An error is detected (see section "Error Identification")

Example

The following example writes the value to the hypothetical application specific object entry "[1234:56]" within the object directory of the CANopen node AppNode.


    CPU_INT16S  err;
    CPU_INT08U  buffer[10];
    :
    err = CODirRdBuffer (&(AppNode.Dir), CO_DEV(0x1234, 0x56), buffer, 10);
    if (err != CO_ERR_NONE) {
        /* object [1234:56] is missing or error during writing */
    } else {
        /* value holds the content of object [1234:56] */
    }
    :