Skip to content

Generate raw signal getters and setters - #193

Open
felixvanoost wants to merge 2 commits into
oxibus:mainfrom
felixvanoost:generate-raw-accessors
Open

Generate raw signal getters and setters#193
felixvanoost wants to merge 2 commits into
oxibus:mainfrom
felixvanoost:generate-raw-accessors

Conversation

@felixvanoost

Copy link
Copy Markdown
Contributor
  • Generates new <signal>_raw getters and setters for every signal. These directly extract/pack the raw message payload bytes without any scaling or range checking.
  • Renames the existing <signal>_raw getters to <signal>_phys, representing the physical (scaled) signal value. This fixes the previously confusing function name but is a breaking API change.

@felixvanoost
felixvanoost requested review from nyurik and trnila August 24, 2026 17:40
@felixvanoost felixvanoost self-assigned this Aug 24, 2026
@felixvanoost felixvanoost added the enhancement New feature or request label Aug 24, 2026
@nyurik

nyurik commented Aug 24, 2026

Copy link
Copy Markdown
Member

wouldn't this be really hard to update for the users? E.g. if they are using _raw now, would the meaning of that change?

@felixvanoost

felixvanoost commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

wouldn't this be really hard to update for the users? E.g. if they are using _raw now, would the meaning of that change?

Users currently calling _raw() can simply rename to _phys() to achieve the same behaviour as before. It should be a simple change as long as users are aware of it. Perhaps a good opportunity to bump the release version?

Though perhaps slightly painful, I think this resolves a big inconsistency in the function naming.

@nyurik

nyurik commented Aug 24, 2026

Copy link
Copy Markdown
Member

right, but my point is that if we can make it backwards compat, perhas we should try to? A modification A->B + new A with the same signature is usually a path for foot-gun

@felixvanoost

Copy link
Copy Markdown
Contributor Author

I'm happy to avoid the renaming if you prefer. We can keep the existing _raw() naming for the physical values, and I can call these new getter/setters _bits() instead. This is fully backwards compatible but IMO it now creates two naming changes that should be resolved at some point.

@nyurik

nyurik commented Aug 24, 2026

Copy link
Copy Markdown
Member

TBH I don't know what's better - I am not as much of a domain expert as others here, rather I focus on Rust itself. I am totally OK to rename things, as long as the old code fails to compile - thus helping users update it. If the meaning changes, but fn signature stays the same, we get a lot of non-obvious errors.

@trnila

trnila commented Aug 24, 2026

Copy link
Copy Markdown
Member

This could be safe and not surprising anyone while moving towards correct naming?

  • rename {signal}_raw to {signal}_phys / {signal}_phys_val to get scaled physical values (now with correct name)
    • current users will have to trivially rename function in order to compile
  • new function {signal}_raw_bits() / {signal_raw_val()} to get received bits/value without any scaling

Suffix _val is little bit longer, but it could be consistent at least.

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.

3 participants