Generate raw signal getters and setters - #193
Conversation
|
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 Though perhaps slightly painful, I think this resolves a big inconsistency in the function naming. |
|
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 |
|
I'm happy to avoid the renaming if you prefer. We can keep the existing |
|
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. |
|
This could be safe and not surprising anyone while moving towards correct naming?
Suffix |
I'm happy to rename to |
4cff4d3 to
4a14b82
Compare
|
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
sure, releasing is simple :) |
|
note though that we can keep 0.3.x going if we also keep the old one as deprecated |
|
Either version is OK with me, though there have been many feature additions and general updates since |
|
0.3.* is simpler to update to - i.e. it has no breaking changes (deprecations are ok as they are warnings) - so likely more ppl will update to it faster. If we can, we should stick to it |
| msg: &Message, | ||
| ) -> Result<()> { | ||
| writeln!(w, "/// Get raw value of '{}'", signal.name)?; | ||
| writeln!(w, "/// Get physical value of '{}'", signal.name)?; |
There was a problem hiding this comment.
can we factor rendering comment into a function so its not duplicated with the code above?
| /// - Receivers: Node1 | ||
| #[inline(always)] | ||
| pub fn value1(&self) -> CanMultiplexedValue1 { | ||
| let signal = self.raw.view_bits::<Lsb0>()[8..16].load_le::<u8>(); |
There was a problem hiding this comment.
can we call the newly introduced function value1_raw_val?
| 1 => CanMultiplexedValue1::One, | ||
| 0 => CanMultiplexedValue1::Zero, | ||
| _ => CanMultiplexedValue1::_Other(self.value1_raw()), | ||
| _ => CanMultiplexedValue1::_Other(self.value1_phys_val()), |
There was a problem hiding this comment.
The signal is raw value, but then we are passing physical value into _Other.
Not sure if physical values exists for multiplexor - isnt it just raw value (enumerator value)?
| #[inline(always)] | ||
| pub fn value1_raw(&self) -> u8 { | ||
| pub fn value1_phys_val(&self) -> u8 { | ||
| let signal = self.raw.view_bits::<Lsb0>()[8..16].load_le::<u8>(); |
There was a problem hiding this comment.
can we call the newly introduced function value1_raw_val?
| /// - Offset: 0 | ||
| /// - Byte order: LittleEndian | ||
| /// - Value type: Signed | ||
| /// - Unit: "" |
There was a problem hiding this comment.
maybe we could omit empty units? and quotes?
<signal>_raw_valgetters and setters for every signal. These directly extract/pack the raw message payload bytes without any scaling or range checking.<signal>_rawgetters to<signal>_phys_val, representing the physical (scaled) signal value.This fixes the previously confusing function name but is a breaking API change.