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):
85
85
pass
86
86
87
87
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
90
90
91
91
if node_id is None :
92
92
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):
89
89
od = canopen .import_od (SAMPLE_EDS , node_id = 3 )
90
90
self .assertEqual (od .node_id , 3 )
91
91
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
+
92
107
def test_variable (self ):
93
108
var = self .od ['Producer heartbeat time' ]
94
109
self .assertIsInstance (var , canopen .objectdictionary .ODVariable )
You can’t perform that action at this time.
0 commit comments