User Type Objects
User type objects are provided to implement special behavior of read and/or write access to an object entry. Several system types are using this mechanism to provide the specified behavior of several pre-defined CANopen object entries.
The implemented access hook functions (called "type functions") are used for any access to the object entry, regardless of the accessing component (CAN network via CAN messages or the application via service functions).
An example user type (called "DemoType") is declared with the following structure.
Note: if a new user type don't need to have special behavior on accessing (e.g. get size, control, read data or write data), the corresponding type function can be set to 0 to switch this access to basic behavior.
The following list shows the type function prototypes. The return value of the size type function (e.g. DemoSize()
) shall return the size of the user type in bytes. The other type functions shall return CO_ERR.NONE
after successful operation. If an error is detected the corresponding error codes must be returned: CO_ERR_TYPE.RD
, CO_ERR_TYPE.WR
or CO_ERR_TYPE.CTRL
.
To integrate the user type "DemoType" into the code generation system and keep the object directory definition readable, the following lines should be added within the corresponding header file:
The following diagram shows the internal behavior of read access to the user type object:
End of topic