Skip to content

Commit be8ea48

Browse files
committed
Fix
Fix
1 parent c437716 commit be8ea48

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/canmatrix/formats/dbc.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,11 @@ def add_frame_by_id(new_frame): # type: (canmatrix.Frame) -> None
860860
temp.group(2)).add_attribute(
861861
temp.group(1),
862862
temp.group(3))
863+
elif '"BusType"' in decoded:
864+
regexp = re.compile(r"^BA_ +\"BusType\" +\"(.+?)\" *; *")
865+
temp = regexp.match(decoded)
866+
if temp:
867+
db.add_attribute("BusType", f'"{temp.group(1)}"')
863868
else:
864869
regexp = re.compile(
865870
r"^BA_ +\"([A-Za-z0-9\-_]+)\" +([\"\S\-\.]+) *; *")

src/canmatrix/formats/fibex.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,11 @@ def dump(db, f, **options):
467467
create_sub_element_fx(cluster, "SPEED", "500")
468468
create_sub_element_fx(cluster, "IS-HIGH-LOW-BIT-ORDER", "true")
469469
create_sub_element_fx(cluster, "BIT-COUNTING-POLICY", "MONOTONE")
470-
protocol = create_sub_element_fx(cluster, "PROTOCOL", "CAN")
470+
if 'BusType' in db.attributes and db.attributes['BusType'] == "CAN FD":
471+
protocol = create_sub_element_fx(cluster, "PROTOCOL", "CAN-FD")
472+
create_sub_element_fx(cluster, "CAN-FD-SPEED", "2000000")
473+
else:
474+
protocol = create_sub_element_fx(cluster, "PROTOCOL", "CAN")
471475
protocol.attrib['{{{pre}}}type'.format(pre=xsi)] = "can:PROTOCOL-TYPE"
472476
create_sub_element_fx(cluster, "PROTOCOL-VERSION", "20")
473477
channel_refs = create_sub_element_fx(cluster, "CHANNEL-REFS")

0 commit comments

Comments
 (0)