File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -85,8 +85,8 @@ def import_eds(source, node_id):
8585 pass
8686
8787 if eds .has_section ("DeviceComissioning" ):
88- if val := eds .get ("DeviceComissioning" , "Baudrate" , fallback = None ):
89- od .bitrate = int ( val ) * 1000
88+ if val := eds .getint ("DeviceComissioning" , "Baudrate" , fallback = None ):
89+ od .bitrate = val * 1000
9090
9191 if node_id is None :
9292 if val := eds .get ("DeviceComissioning" , "NodeID" , fallback = None ):
Original file line number Diff line number Diff line change @@ -89,6 +89,21 @@ def test_load_explicit_nodeid(self):
8989 od = canopen .import_od (SAMPLE_EDS , node_id = 3 )
9090 self .assertEqual (od .node_id , 3 )
9191
92+ def test_load_baudrate (self ):
93+ od = canopen .import_od (SAMPLE_EDS )
94+ self .assertEqual (od .bitrate , 500_000 )
95+
96+ def test_load_baudrate_fallback (self ):
97+ import io
98+
99+ # Remove the Baudrate option.
100+ with open (SAMPLE_EDS ) as f :
101+ lines = [L for L in f .readlines () if not L .startswith ("Baudrate=" )]
102+ with io .StringIO ("" .join (lines )) as buf :
103+ buf .name = "mock.eds"
104+ od = canopen .import_od (buf )
105+ self .assertIsNone (od .bitrate )
106+
92107 def test_variable (self ):
93108 var = self .od ['Producer heartbeat time' ]
94109 self .assertIsInstance (var , canopen .objectdictionary .ODVariable )
You can’t perform that action at this time.
0 commit comments