Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/canmatrix/formats/dbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,11 @@ def add_frame_by_id(new_frame): # type: (canmatrix.Frame) -> None
temp = regexp.match(decoded)
if temp:
db.add_attribute("BusType", f'"{temp.group(1)}"')
elif '"Baudrate"' in decoded:
regexp = re.compile(r"^BA_ +\"Baudrate\" +(.+?) *; *")
temp = regexp.match(decoded)
if temp:
db.add_attribute("Baudrate", f'{temp.group(1)}')
else:
regexp = re.compile(
r"^BA_ +\"([A-Za-z0-9\-_]+)\" +([\"\S\-\.]+) *; *")
Expand Down
11 changes: 9 additions & 2 deletions src/canmatrix/formats/fibex.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,15 +464,22 @@ def dump(db, f, **options):
# add the file name as a suffix in the cluster name
cluster_name = f"cluster_{os.path.basename(f.name).split('.')[0]}"
create_short_name_desc(cluster, cluster_name, "clusterDesc")
create_sub_element_fx(cluster, "SPEED", "500")
create_sub_element_fx(cluster, "IS-HIGH-LOW-BIT-ORDER", "true")
create_sub_element_fx(cluster, "BIT-COUNTING-POLICY", "MONOTONE")
attribute = db.attributes["BusType"]
if attribute is not None and attribute == "CAN FD":
protocol = create_sub_element_fx(cluster, "PROTOCOL", "CAN-FD")
create_sub_element_fx(cluster, "CAN-FD-SPEED", "2000000")
if 'Baudrate' in db.attributes:
create_sub_element_fx(cluster, "CAN-FD-SPEED", db.attributes['Baudrate'])
else:
create_sub_element_fx(cluster, "CAN-FD-SPEED", "2000000")
create_sub_element_fx(cluster, "SPEED", "500")
else:
protocol = create_sub_element_fx(cluster, "PROTOCOL", "CAN")
if 'Baudrate' in db.attributes:
create_sub_element_fx(cluster, "SPEED", db.attributes['Baudrate'])
else:
create_sub_element_fx(cluster, "SPEED", "500")
protocol.attrib['{{{pre}}}type'.format(pre=xsi)] = "can:PROTOCOL-TYPE"
create_sub_element_fx(cluster, "PROTOCOL-VERSION", "20")
channel_refs = create_sub_element_fx(cluster, "CHANNEL-REFS")
Expand Down
Loading