Skip to content

Commit 994809c

Browse files
Allow value+$NODEID in EDS files
Fixes #198
1 parent 4947301 commit 994809c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

canopen/objectdictionary/eds.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,10 @@ def _convert_variable(node_id, var_type, value):
136136
elif var_type in objectdictionary.FLOAT_TYPES:
137137
return float(value)
138138
else:
139-
# COB-ID can have a suffix of '$NODEID+' so replace this with node_id before converting
139+
# COB-ID can contain '$NODEID+' so replace this with node_id before converting
140140
value = value.replace(" ","").upper()
141-
if '$NODEID+' in value and node_id is not None:
142-
return int(value.replace('$NODEID+', ''), 0) + node_id
141+
if '$NODEID' in value and node_id is not None:
142+
return int(re.sub(r'\+?\$NODEID\+?', '', value), 0) + node_id
143143
else:
144144
return int(value, 0)
145145

test/sample.eds

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ ObjectType=7
262262
DataType=7
263263
AccessType=RW
264264
PDOMapping=0
265-
DefaultValue=$NODEID+1280
265+
DefaultValue=1280+$NODEID
266266

267267
[1403sub2]
268268
ParameterName=Transmission type RPDO 4

0 commit comments

Comments
 (0)