Skip to content

Commit bae280f

Browse files
authored
Merge pull request #880 from SabrineBH/support_can_fd_protocol_bug_fixing
Fix regression in DBC files with no attribute "BusType"
2 parents 2301fba + 637fbeb commit bae280f

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

src/canmatrix/formats/dbc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ def add_frame_by_id(new_frame): # type: (canmatrix.Frame) -> None
866866
temp.group(2)).add_attribute(
867867
temp.group(1),
868868
temp.group(3))
869-
elif decoded.find('"BusType"') != -1:
869+
elif '"BusType"' in decoded:
870870
regexp = re.compile(r"^BA_ +\"BusType\" +\"(.+?)\" *; *")
871871
temp = regexp.match(decoded)
872872
if temp:

src/canmatrix/formats/fibex.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,7 @@ def dump(db, f, **options):
473473
create_sub_element_fx(cluster, "SPEED", "500")
474474
create_sub_element_fx(cluster, "IS-HIGH-LOW-BIT-ORDER", "true")
475475
create_sub_element_fx(cluster, "BIT-COUNTING-POLICY", "MONOTONE")
476-
attribute = db.attributes["BusType"]
477-
if attribute is not None and attribute == "CAN FD":
476+
if 'BusType' in db.attributes and db.attributes['BusType'] == "CAN FD":
478477
protocol = create_sub_element_fx(cluster, "PROTOCOL", "CAN-FD")
479478
create_sub_element_fx(cluster, "CAN-FD-SPEED", "2000000")
480479
else:

0 commit comments

Comments
 (0)