Object Dictionary¶
CANopen devices must have an object dictionary, which is used for configuration and communication with the device. An entry in the object dictionary is defined by:
Index, the 16-bit address of the object in the dictionary
Object type, such as an array, record, or simple variable
Name, a string describing the entry
Type, gives the datatype of the variable (or the datatype of all variables of an array)
Attribute, which gives information on the access rights for this entry, this can be read/write (rw), read-only (ro) or write-only (wo)
The basic datatypes for object dictionary values such as booleans, integers and floats are defined in the standard, as well as composite datatypes such as strings, arrays and records. The composite datatypes can be subindexed with an 8-bit index; the value in subindex 0 of an array or record indicates the number of elements in the data structure, and is of type UNSIGNED8.
Supported formats¶
The currently supported file formats for specifying a node’s object dictionary are:
EDS (standardized INI-file like format)
DCF (same as EDS with bitrate and node ID specified)
EPF (proprietary XML-format used by Inmotion Technologies)
Examples¶
The object dictionary file is normally provided when creating a node. Here is an example where the entire object dictionary gets printed out:
node = network.add_node(6, 'od.eds')
for obj in node.object_dictionary.values():
print(f'0x{obj.index:X}: {obj.name}')
if isinstance(obj, canopen.objectdictionary.ODRecord):
for subobj in obj.values():
print(f' {subobj.subindex}: {subobj.name}')
You can access the objects using either index/subindex or names:
device_name_obj = node.object_dictionary['ManufacturerDeviceName']
vendor_id_obj = node.object_dictionary[0x1018][1]
actual_speed = node.object_dictionary['ApplicationStatus.ActualSpeed']
command_all = node.object_dictionary['ApplicationCommands.CommandAll']
API¶
Constants¶
- canopen.objectdictionary.UNSIGNED8¶
- canopen.objectdictionary.UNSIGNED16¶
- canopen.objectdictionary.UNSIGNED32¶
- canopen.objectdictionary.UNSIGNED64¶
- canopen.objectdictionary.INTEGER8¶
- canopen.objectdictionary.INTEGER16¶
- canopen.objectdictionary.INTEGER32¶
- canopen.objectdictionary.INTEGER64¶
- canopen.objectdictionary.BOOLEAN¶
- canopen.objectdictionary.REAL32¶
- canopen.objectdictionary.REAL64¶
- canopen.objectdictionary.VISIBLE_STRING¶
- canopen.objectdictionary.OCTET_STRING¶
- canopen.objectdictionary.UNICODE_STRING¶
- canopen.objectdictionary.DOMAIN¶
- canopen.objectdictionary.SIGNED_TYPES¶
- canopen.objectdictionary.UNSIGNED_TYPES¶
- canopen.objectdictionary.INTEGER_TYPES¶
- canopen.objectdictionary.FLOAT_TYPES¶
- canopen.objectdictionary.NUMBER_TYPES¶
- canopen.objectdictionary.DATA_TYPES¶