Skip to content

Commit

Permalink
Correctly the result if compare two frame with different ID (#552)
Browse files Browse the repository at this point in the history
When comparing two dbc, the the frame has different ID it should be marked as "changed" frame.
  • Loading branch information
annguyen0 authored Mar 21, 2021
1 parent 490a783 commit b466fe8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/canmatrix/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,16 @@ def compare_db(db1, db2, ignore=None):
if ignore is None:
ignore = dict()
for f1 in db1.frames:
f2 = db2.frame_by_id(f1.arbitration_id)
if f2 is None:
f2 = db2.frame_by_name(f1.name)
f2id = db2.frame_by_id(f1.arbitration_id)
if f2id is None and f2 is None:
result.add_child(CompareResult("deleted", "FRAME", f1))
else:
result.add_child(compare_frame(f1, f2, ignore))
for f2 in db2.frames:
f1 = db1.frame_by_id(f2.arbitration_id)
if f1 is None:
f1 = db1.frame_by_name(f2.name)
f1id = db1.frame_by_id(f2.arbitration_id)
if f1id is None and f1 is None:
result.add_child(CompareResult("added", "FRAME", f2))

if "ATTRIBUTE" in ignore and ignore["ATTRIBUTE"] == "*":
Expand Down

0 comments on commit b466fe8

Please sign in to comment.