Skip to content

Commit

Permalink
Merge pull request #123 from fredrikhoyer/eds_bugfix
Browse files Browse the repository at this point in the history
Small enhancement to the EDS parser + bug fix of a failing unites
  • Loading branch information
christiansandberg authored Nov 5, 2018
2 parents 6cd0d99 + 0e675f7 commit 3a59759
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion canopen/objectdictionary/eds.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def import_eds(source, node_id):
continue

# Match subindexes
match = re.match(r"^([0-9A-Fa-f]{4})sub([0-9A-Fa-f]+)$", section)
match = re.match(r"^([0-9A-Fa-f]{4})[S|s]ub([0-9A-Fa-f]+)$", section)
if match is not None:
index = int(match.group(1), 16)
subindex = int(match.group(2), 16)
Expand Down
13 changes: 13 additions & 0 deletions test/sample.eds
Original file line number Diff line number Diff line change
Expand Up @@ -862,3 +862,16 @@ DataType=0x0008
AccessType=rw
DefaultValue=
PDOMapping=0

[3010]
ParameterName=ReadRawValue
ObjectType=0x9
SubNumber=1

[3010Sub0]
ParameterName=Temperature
ObjectType=0x7
DataType=0x0008
AccessType=ro
DefaultValue=0
PDOMapping=1
4 changes: 4 additions & 0 deletions test/test_eds.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,7 @@ def test_parameter_name_with_percent(self):
def test_compact_subobj_parameter_name_with_percent(self):
name = self.od[0x3006].name
self.assertEqual(name, 'Valve 1 % Open')

def test_sub_index_w_capital_s(self):
name = self.od[0x3010][0].name
self.assertEqual(name, 'Temperature')
3 changes: 2 additions & 1 deletion test/test_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def test_slave_send_heartbeat(self):
self.local_node.nmt.stop_heartbeat()
# The NMT master will change the state INITIALISING (0)
# to PRE-OPERATIONAL (127)
self.assertEqual(state, canopen.nmt.NMT_STATES[127])
self.assertEqual(state, 'PRE-OPERATIONAL')

def test_nmt_state_initializing_to_preoper(self):
# Initialize the heartbeat timer
Expand Down Expand Up @@ -220,6 +220,7 @@ def test_heartbeat(self):
time.sleep(0.2)
self.assertEqual(self.remote_node.nmt.state, 'OPERATIONAL')

self.local_node.nmt.stop_heartbeat()

class TestPDO(unittest.TestCase):
"""
Expand Down

0 comments on commit 3a59759

Please sign in to comment.