Skip to content

Commit fc4ea87

Browse files
Merge pull request #206 from rubenverhoef/StorageLocation
[StorageLocation] Add Support for StorageLocation of EDS
2 parents bf3b194 + 706327d commit fc4ea87

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

canopen/objectdictionary/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ def __init__(self, name, index):
123123
self.index = index
124124
#: Name of record
125125
self.name = name
126+
#: Storage location of index
127+
self.storage_location = None
126128
self.subindices = {}
127129
self.names = {}
128130

@@ -177,6 +179,8 @@ def __init__(self, name, index):
177179
self.index = index
178180
#: Name of array
179181
self.name = name
182+
#: Storage location of index
183+
self.storage_location = None
180184
self.subindices = {}
181185
self.names = {}
182186

@@ -193,7 +197,7 @@ def __getitem__(self, subindex):
193197
var.parent = self
194198
for attr in ("data_type", "unit", "factor", "min", "max", "default",
195199
"access_type", "description", "value_descriptions",
196-
"bit_definitions"):
200+
"bit_definitions", "storage_location"):
197201
if attr in template.__dict__:
198202
var.__dict__[attr] = template.__dict__[attr]
199203
else:
@@ -266,6 +270,8 @@ def __init__(self, name, index, subindex=0):
266270
self.value_descriptions = {}
267271
#: Dictionary of bitfield definitions
268272
self.bit_definitions = {}
273+
#: Storage location of index
274+
self.storage_location = None
269275

270276
def __eq__(self, other):
271277
return (self.index == other.index and

canopen/objectdictionary/eds.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ def import_eds(source, node_id):
5959
# If the keyword ObjectType is missing, this is regarded as
6060
# "ObjectType=0x7" (=VAR).
6161
object_type = VAR
62+
try:
63+
storage_location = eds.get(section, "StorageLocation")
64+
except NoOptionError:
65+
storage_location = None
6266

6367
if object_type in (VAR, DOMAIN):
6468
var = build_variable(eds, section, node_id, index)
@@ -70,12 +74,15 @@ def import_eds(source, node_id):
7074
last_subindex.data_type = objectdictionary.UNSIGNED8
7175
arr.add_member(last_subindex)
7276
arr.add_member(build_variable(eds, section, node_id, index, 1))
77+
arr.storage_location = storage_location
7378
od.add_object(arr)
7479
elif object_type == ARR:
7580
arr = objectdictionary.Array(name, index)
81+
arr.storage_location = storage_location
7682
od.add_object(arr)
7783
elif object_type == RECORD:
7884
record = objectdictionary.Record(name, index)
85+
record.storage_location = storage_location
7986
od.add_object(record)
8087

8188
continue
@@ -154,6 +161,10 @@ def build_variable(eds, section, node_id, index, subindex=0):
154161
"""
155162
name = eds.get(section, "ParameterName")
156163
var = objectdictionary.Variable(name, index, subindex)
164+
try:
165+
var.storage_location = eds.get(section, "StorageLocation")
166+
except NoOptionError:
167+
var.storage_location = None
157168
var.data_type = int(eds.get(section, "DataType"), 0)
158169
var.access_type = eds.get(section, "AccessType").lower()
159170
if var.data_type > 0x1B:

0 commit comments

Comments
 (0)