CANopen Master Documentation
Version 6.06.04
|
Within the CANopen CC protocol access to entries of a device Object Dictionary is provided by means of Service Data Objects (SDO). Within the CANopen FD protocol access is provided by means of Universal Service Data Objects (USDO).
For the reason of backwards compatibility and in order to keep switching between CANopen CC and CANopen FD simple it is possible to use only the SDO API. In case the protocol stack is running in CANopen FD mode the corresponding functions of the USDO module are called.
The API provides functions for read (refer to ComSdoReadObject()) and write (refer to ComSdoWriteObject()) access to the device's object dictionary. Both functions use a pointer to an array of type CoObject_ts, which references the object dictionary entry by index and sub-index.
Once the data transfer has been started, a segmented (or block) transfer is handled by the protocol stack autonomously depending on the data element size. In the same way an upload or download of multiple entries is managed by the protocol stack. An active SDO/USDO communication is aborted upon two incidences:
Please note that for CANopen CC only one SDO connection between a SDO server and SDO client is allowed.
The field CoObject_ts::ubMarker can be used by the application for own purposes, e.g. for implementation of a state machine. The possible application value range for the field is 0 to eCOM_OBJECT_MARKER_USER_END.
The SDO/USDO module provides three event handlers which are called on different conditions.
Event | calls function |
Communication success | |
Communication abort, client or server | |
Communication abort, timeout | |
Communication progress (Segmented/Block) |
The code located in the file com_user.c
for these event handlers provides an example and has to be adopted to the application.
The communication timeout between SDO / USDO client request and SDO / USDO server response is device / application specific. The initial SDO / USDO communication timeout for the client is set to 50 milliseconds. The connection timeout value can be changed by means of the ComSdoSetTimeout() function.
In case of a communication timeout the protocol stack will call the ComObjectEventTimeout() handler. The code of the ComObjectEventTimeout() handler provides an example and has to be adopted to the application. It is located inside the com_user.c
file.
In addition, the protocol stack will transmit a SDO / USDO abort message with an appropriate abort code.
Code examples for accessing entries of a device object dictionary are located in the file source/application/examples-com/com_demo_sdo.c
.
The demo function ComDemoSdoObjectRead()
reads data from the following object dictionary entries:
Index / Sub-Index | Name | Local variable |
---|---|---|
1000:00h | device type | ulIdx1000G |
1001:00h | error register | ubIdx1001G |
1008:00h | manufacturer device name | szIdx1008G[] |
1017:00h | producer heartbeat time | uwIdx1017G |
1018:01h | Identity Object, vendor-ID | ulIdx1018_1G |
The array atsObjDictReadG
holds the data elements to be read. Each entry has a pointer to an individual data storage location. Please note that the string size for the manufacturer device name (1008:00h) is limited to 32 byte. In case the manufacturer device name of the CANopen device exceeds this limit the data transfer will be aborted.
In case of a timeout condition, the handler ComObjectEventTimeout() will be called. On success or in case of an communication abort the handler ComObjectEventReady() will be called.
The demo function ComDemoSdoObjectWrite()
writes data to the following object dictionary entries:
Index / Sub-Index | Name | Local variable |
---|---|---|
1017:00h | producer heartbeat time | uwIdx1017G |
1400:01h | RPDO1, identifier | ulIdx1400_1G |
1400:02h | RPDO1, transmission type | ubIdx1400_2G |
1800:01h | TPDO1, identifier | ulIdx1800_1G |
1800:02h | TPDO1, transmission type | ubIdx1800_2G |
1800:05h | TPDO1, event timer | uwIdx1800_5G |
The array atsObjDictWriteG
holds the data elements to be written. Each entry has a pointer to an individual data storage location. The values for each variable are set in the beginning of ComDemoSdoObjectWrite().