CODirRdWord

Description

This function reads a 16bit value from the given object directory. The object entry is addressed with the given key and the value will be written to the given destination pointer.

Prototype

CPU_INT16S CODirRdWord(CO_DIR *cod, CPU_INT32U key, CPU_INT16U *val);

ParameterDescription
codpointer to the CANopen object directory
keyobject entry key; should be generated with the macro CO_DEV()
valpointer to the value destination

Returned Value

= CO_ERR.NONE  Successful operation

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

Example

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


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


Note: This function uses CODirFind() on each function call. To improve access performance for multiple accesses to a single object entry, the application may use CODirFind() once and COObjRdValue() multiple times.