Skip to content

Commit 25394c3

Browse files
committed
Reading DefaultValue from EDS is wrong for data type OCTET_STRING and DOMAIN.
The DefaultValue for data type OCTET_STRING and DOMAIN is formatted with two hex digits for each byte in the EDS - see corresponding CiA standard. Also the content of the default value has to end up in a bytes instance and not in a string instance. (otherwise an exception is thrown when the SDOServer tries to answer a SDO upload request for an object dictionary entry with this data type.)
1 parent dd2d1a7 commit 25394c3

File tree

1 file changed

+3
-1
lines changed
  • canopen/objectdictionary

1 file changed

+3
-1
lines changed

canopen/objectdictionary/eds.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ def import_from_node(node_id, network):
138138

139139

140140
def _convert_variable(node_id, var_type, value):
141-
if var_type in objectdictionary.DATA_TYPES:
141+
if var_type in (objectdictionary.OCTET_STRING, objectdictionary.DOMAIN):
142+
return bytes.fromhex(value)
143+
elif var_type in (objectdictionary.VISIBLE_STRING, objectdictionary.UNICODE_STRING):
142144
return value
143145
elif var_type in objectdictionary.FLOAT_TYPES:
144146
return float(value)

0 commit comments

Comments
 (0)