Skip to content

Generate message size and cycle time consts#176

Merged
felixvanoost merged 5 commits into
oxibus:mainfrom
felixvanoost:parse-message-cycle-time-attribute
Jul 18, 2026
Merged

Generate message size and cycle time consts#176
felixvanoost merged 5 commits into
oxibus:mainfrom
felixvanoost:parse-message-cycle-time-attribute

Conversation

@felixvanoost

@felixvanoost felixvanoost commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Generates the following new constants per message:

  • MESSAGE_SIZE in bytes. This avoids the overhead of using raw().len() or embedded_can::Frame::dlc() and makes the size known at compile-time.
  • MESSAGE_CYCLE_TIME containing the value from the corresponding GenMsgCycleTime DBC attribute when it is present.

This PR should be stacked on top of #175.

@felixvanoost
felixvanoost requested a review from nyurik July 10, 2026 20:34
@felixvanoost felixvanoost self-assigned this Jul 10, 2026
@felixvanoost felixvanoost added the enhancement New feature or request label Jul 10, 2026
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/lib.rs 88.88% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@felixvanoost
felixvanoost force-pushed the parse-message-cycle-time-attribute branch from 829730a to cee3a5c Compare July 10, 2026 20:40
@felixvanoost felixvanoost changed the title Emit MESSAGE_CYCLE_TIME const from GenMsgCycleTime DBC attribute Generate MESSAGE_CYCLE_TIME const from GenMsgCycleTime DBC attribute Jul 10, 2026
@felixvanoost felixvanoost changed the title Generate MESSAGE_CYCLE_TIME const from GenMsgCycleTime DBC attribute Generate message length and cycle time consts from DBC attributes Jul 10, 2026
@felixvanoost felixvanoost changed the title Generate message length and cycle time consts from DBC attributes Generate message size and cycle time consts from DBC attributes Jul 14, 2026
@felixvanoost felixvanoost changed the title Generate message size and cycle time consts from DBC attributes Generate message size and cycle time consts Jul 14, 2026
@felixvanoost

Copy link
Copy Markdown
Contributor Author

@nyurik this is also ready for review now. :)

nyurik added a commit to oxibus/can-dbc that referenced this pull request Jul 15, 2026
Adds methods to lookup DBC attributes: `message_attribute`,
`signal_attribute`, `attribute_default`, `resolved_message_attribute`
and `resolved_signal_attribute`. These will be used in
oxibus/dbc-codegen#175 and
oxibus/dbc-codegen#176.

---------

Co-authored-by: Yuri Astrakhan <YuriAstrakhan@gmail.com>
@felixvanoost
felixvanoost force-pushed the parse-message-cycle-time-attribute branch from ce2298b to 729de18 Compare July 16, 2026 02:18
@felixvanoost
felixvanoost requested a review from trnila July 17, 2026 14:07
@felixvanoost
felixvanoost force-pushed the parse-message-cycle-time-attribute branch from ea045db to c56765b Compare July 18, 2026 02:38
@felixvanoost
felixvanoost force-pushed the parse-message-cycle-time-attribute branch from c56765b to 4f6e7ed Compare July 18, 2026 02:45

@trnila trnila left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Works great!

embassy is using its own embassy_time::Duration type instead of core::time::Duration. Would it make sense to have this type configurable? The embassy type memory footprint is also smaller than the core one.

@felixvanoost

Copy link
Copy Markdown
Contributor Author

@trnila Since the generated code will be integrated into projects using different timing libraries downstream (embassy-time, fugit, etc.), I think it makes sense to keep core::time::Duration here. Every timing library will have a constructor to ingest a core::time::Duration into its own types, and it keeps the number of optional arguments and coupling to 3rd-party crates lower in dbc-codegen. Perhaps we can look at adding support for more timing libraries as a separate issue/PR?

@felixvanoost
felixvanoost merged commit 1b32231 into oxibus:main Jul 18, 2026
7 checks passed
@felixvanoost
felixvanoost deleted the parse-message-cycle-time-attribute branch July 18, 2026 13:52
@nyurik nyurik mentioned this pull request Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants