File tree Expand file tree Collapse file tree 3 files changed +18
-4
lines changed
Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -37,11 +37,11 @@ def import_eds(source, node_id):
3737
3838 for section in eds .sections ():
3939 # Match dummy definitions
40- match = re .match (r"^[D|d ]ummy[U|u ]sage$" , section )
40+ match = re .match (r"^[Dd ]ummy[Uu ]sage$" , section )
4141 if match is not None :
42- for i in range (1 ,8 ):
42+ for i in range (1 , 8 ):
4343 key = "Dummy%04d" % i
44- if eds .getint (section ,key ) == 1 :
44+ if eds .getint (section , key ) == 1 :
4545 var = objectdictionary .Variable (key , i , 0 )
4646 var .data_type = i
4747 var .access_type = "const"
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ LSS_SerialNumber=0
3939[DummyUsage]
4040Dummy0001=0
4141Dummy0002=0
42- Dummy0003=0
42+ Dummy0003=1
4343Dummy0004=0
4444Dummy0005=0
4545Dummy0006=0
Original file line number Diff line number Diff line change @@ -76,3 +76,17 @@ def test_compact_subobj_parameter_name_with_percent(self):
7676 def test_sub_index_w_capital_s (self ):
7777 name = self .od [0x3010 ][0 ].name
7878 self .assertEqual (name , 'Temperature' )
79+
80+ def test_dummy_variable (self ):
81+ var = self .od ['Dummy0003' ]
82+ self .assertIsInstance (var , canopen .objectdictionary .Variable )
83+ self .assertEqual (var .index , 0x0003 )
84+ self .assertEqual (var .subindex , 0 )
85+ self .assertEqual (var .name , 'Dummy0003' )
86+ self .assertEqual (var .data_type , canopen .objectdictionary .INTEGER16 )
87+ self .assertEqual (var .access_type , 'const' )
88+ self .assertEqual (len (var ), 16 )
89+
90+ def test_dummy_variable_undefined (self ):
91+ with self .assertRaises (KeyError ):
92+ var_undef = self .od ['Dummy0001' ]
You can’t perform that action at this time.
0 commit comments