Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DBC: parse bus comments even when no DBName specified #565

Merged
merged 1 commit into from
May 24, 2023

Conversation

mon
Copy link
Contributor

@mon mon commented May 16, 2023

This PR fixes two discrepancies I found vs CANdb++'s bus comment behaviour (I assume CANdb++ is the standard to match here?).

Firstly, a DBName is not actually required for a bus comment to be valid, and the filename (without extension) is used if one isn't specified. This auto-name isn't serialised on save.

Secondly, multiple CM_ entries get concatenated together. This behaviour is frankly a bit odd and feels wrong, especially since CANdb++ will then serialise the concatenated version to a single CM_. But since it's "correct" behaviour, I've added it.

I'm happy to amend the PR to remove the comment concatenation if you'd prefer to just drop extra CM_ entries (which is what cantools does at the moment).

Screenshot of CANdb++ behaviour on the newly added test dbc:
image

@coveralls
Copy link

Pull Request Test Coverage Report for Build 4988374293

  • 5 of 5 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.002%) to 94.089%

Totals Coverage Status
Change from base Build 4982762184: 0.002%
Covered Lines: 7099
Relevant Lines: 7545

💛 - Coveralls

Copy link
Member

@andlaus andlaus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks fair enough to me, but @juleq is the expert here...

@@ -1675,7 +1677,7 @@ def _load_bus(attributes, comments):
try:
bus_name = attributes['database']['DBName'].value
except KeyError:
return None
bus_name = ''
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if empty bus names are valid...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is my main concern as well. I'm sure None is more-invalid, so hopefully juleq can chime in with better detail.

Other options could be a dummy bus name "bus" or somehow bring forward the DBC filename to use as CANdb++ does.

@andlaus
Copy link
Member

andlaus commented May 24, 2023

can you see any obstacles to merging this, @juleq?

@juleq
Copy link
Collaborator

juleq commented May 24, 2023

Yes, candb++ is authoritative, thanks for checking and adapting. Merging now.

@juleq juleq merged commit 279a5a9 into cantools:master May 24, 2023
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants