COObjWrValue

COObjWrValue

Description

This function writes a value to the given object directory entry.

Prototype

CPU_INT16S COObjWrValue(CO_OBJ     *obj ,
                        void       *value,
                        CPU_INT08U  width,
                        CPU_INT08U  nodeid);

ParameterDescription
objpointer to the CANopen directory entry
valuepointer to the source memory
widthwidth of write value (must be 1, 2 or 4 and reflecting the width of the referenced variable with given parameter pointer: value)
nodeiddevice nodeid (only used in case of node-id dependent value)

Returned Value

 = CO_ERR.NONE   Successful operation

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

Additional Information

The access with this function to an object entry will be done with casting of the object entry values to the requested value width.

Example

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


    CPU_INT32U  value;
    CO_OBJ     *entry;
    :
    value = 0L;
    entry = CODirFind     (&(AppNode.Dir), CO_DEV(0x1234,0x56));
    err   = COObjWrValue  (entry, &value, 4, 0);
    :


Note: The example shows a read access with the knowledge, that the addressed object entry is independent from the CANopen node-ID. To be independent from this knowledge, the API function CONmtGetNodeId() may be used to get the current node ID.