...
It is possible to define an interface for custom variables, structures and arrays. The index is the logical reference to one of these data containers. The elements of structures and arrays are reached via the sub-index. For simple variables the sub-index is always 0. If the size of the structures or arrays is bigger than 255 bytes (limit of sub-index), the user must split them. This means more than one index is needed to describe the structure/array within the object dictionary. The elements of the object dictionary have the type LIST_ELEMENT_T. An array of this type, sorted by the index, is the object dictionary. The description of the variables is an array of the type VALUE_DESC_T. Each array entry describes the properties of the corresponding sub-index.
Code Block | ||
---|---|---|
| ||
typedef struct { |
...
UNSIGNED8 *pObj; |
...
VALUE_DESC_T *pValDesc; |
...
UNSIGNED16 index; |
...
UNSIGNED8 numOfElem; |
...
#ifdef CO_CONFIG_ENABLE_OBJ_CALLBACK |
...
CO_OBJ_CB_T pObjCallback; /* obj function pointer */ |
...
#endif /* CO_CONFIG_ENABLE_OBJ_CALLBACK */ |
...
} LIST_ELEMENT_T; |
element name from LIST_ELEMENT_T | description |
index | index of the variable in the object dictionary |
numOfElem | number of elements of the variable |
pObj | pointer to the variable (array, structure, variable) |
pValDesc | pointer to an array of corresponding value descriptions |
pObjCallback | pointer to a callback function corresponding to the object |
Table 18: structure of object dictionary entry
Code Block | ||
---|---|---|
| ||
typedef struct { |
...
UNSIGNED8 *pDefaultVal; |
...
#ifdef CONFIG_LIMITS_CHECK |
...
LIMIT_U8_T *pLimits; |
...
#endif |
...
UNSIGNED8 varType; |
...
UNSIGNED16 attribute; |
...
} VALUE_DESC_T; |
element name from VALUE_DESC_T | description |
pDefaultVal | pointer to the default value of the variable, it will be used to initialize the variable after a reset (hard reset or communication reset), it depends on the variable type (see varType) |
pLimits | pointer to the lower and upper limits of the variable value, it depends on the variable type (see varType) |
varType | type of variable (Table 21) |
attribute | attributes of value (Table 20) |
...
Some entries at the object dictionary are of type UNSIGNED64. If a compiler does not provide this data type, 64-bit variables can be simulated:
Code Block | ||
---|---|---|
| ||
typedef struct |
...
{ |
...
char val[8]; |
...
} UNSIGNED64; |
The initialization in this case is done by the following macro:
Code Block | ||
---|---|---|
| ||
#define SET_U64(b1, b2, b3, b4, b5, b6, b7, b8) \ |
...
{ b8, b7, b6, b5, b4, b3, b2, b1 }; |
For all compilers providing this data type the initialization is done by:
Code Block | ||
---|---|---|
| ||
#define SET_U64(b1, b2, b3, b4, b5, b6, b7, b8) \ |
...
{ b1<<56|b2<<48|b3<<40|b4<<32|b5<<24|b6<<16|b7<<8|b8 }; |
CANopen Library return value
...