CANopenDemo
CANopenNode demo, tutorial and testing
Data Structures | Functions
objectAccessOD.h File Reference

Example object oriented access to the Object Dictionary variable. More...

#include "301/CO_ODinterface.h"
+ Include dependency graph for objectAccessOD.h:

Go to the source code of this file.

Data Structures

struct  objectAccessOD_t
 Object declaration for objectAccessOD. More...
 

Functions

CO_ReturnError_t objectAccessOD_init (objectAccessOD_t *thisObj, OD_entry_t *OD_demoRecord, uint32_t *errInfo)
 Initialize objectAccessOD object. More...
 
static float64_t objectAccessOD_readAverage (objectAccessOD_t *thisObj)
 Read "average" variable from Object Dictionary. More...
 

Detailed Description

Example object oriented access to the Object Dictionary variable.

Author

This file is part of CANopenNode, an opensource CANopen Stack. Project home page is https://github.com/CANopenNode/CANopenNode. For more information on CANopen see http://www.can-cia.org/.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Function Documentation

◆ objectAccessOD_init()

CO_ReturnError_t objectAccessOD_init ( objectAccessOD_t thisObj,
OD_entry_t OD_demoRecord,
uint32_t errInfo 
)

Initialize objectAccessOD object.

Parameters
thisObjThis object will be initialized.
OD_demoRecordObject Dictionary entry for demoRecord.
[out]errInfoIf OD entry is erroneous, errInfo indicates its index.
Returns
CO_ReturnError_t CO_ERROR_NO in case of success.

◆ objectAccessOD_readAverage()

static float64_t objectAccessOD_readAverage ( objectAccessOD_t thisObj)
inlinestatic

Read "average" variable from Object Dictionary.

This is a demonstration of extended OD variable. OD variable is not accessed from memory location, because it does not exist. Average is calculated from internal values, so function access is necessary. "read" function specified by OD_extension_init() is called. For "read" function to use, "OD_IO_t io_average" structure has been initialized before. If objectAccessOD_readAverage() is used from mainline, it has to be protected with CO_LOCK_OD / CO_UNLOCK_OD macros as every access to OD variable from mainline.

Parameters
thisObjThis object contains access information to "average" parameter
Returns
Value of the parameter.