From 96b2f0cc8007c0dbd1116affdc89b10ba0fef5dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Colomb?= Date: Thu, 4 Jul 2024 00:22:23 +0200 Subject: [PATCH] Gracefully handle missing Baudrate setting in DCF. The CiA306 spec is not quite clear on which fields are mandatory within the DeviceComissioning section. Thus it should be assumed that the two options handled here could be missing. Instead of raising an exception, ignore the absence of the Baudrate setting. --- canopen/objectdictionary/eds.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/canopen/objectdictionary/eds.py b/canopen/objectdictionary/eds.py index 40342d32..8dd73762 100644 --- a/canopen/objectdictionary/eds.py +++ b/canopen/objectdictionary/eds.py @@ -85,7 +85,8 @@ def import_eds(source, node_id): pass if eds.has_section("DeviceComissioning"): - od.bitrate = int(eds.get("DeviceComissioning", "Baudrate")) * 1000 + if val := eds.get("DeviceComissioning", "Baudrate", fallback=None): + od.bitrate = int(val) * 1000 if node_id is None: if val := eds.get("DeviceComissioning", "NodeID", fallback=None):