oxidecomputer / oxidecomputer/pmbus
want a `SMBALERT_MASK::CommandData` that depends on the type of the register being masked
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 11
- Forks
- 5
- Avg merge
- 1h 10m
- Merged PRs (30d)
- 2
Description
As seen in oxidecomputer/hubris#2511, it would be nice to have a typed abstraction for SMBALERT_MASK which constructs command data based on which status register's CommandData is used as the mask, i.e. which emits the correct register address for the status register being masked. One can very easily just write code such as this:
pub fn set_status_iout_smbalert_mask(
&self,
mask: STATUS_IOUT::CommandData,
) -> Result<(), i2c::ResponseCode> {
self.device
.write(&[
CommandCode::SMBALERT_MASK as u8,
CommandCode::STATUS_IOUT as u8,
mask.0,
])
}
and, in fact, I have, but it feels a bit dirty --- as though one is basically doing an end run around all the typed abstractions the pmbus crate provides. I would like to figure out a way to have a version of set_smbalert_mask that could take any status register (and only any status register)'s command data, and just did the right thing with it.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by examining the existing typed abstractions for SMBALERT_MASK, status registers, and their CommandData types. Determine how a generic set_smbalert_mask can accept only status-register CommandData while deriving the correct status-register address; it is done when the resulting command data emits the appropriate address without bypassing the crate's typed abstractions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- embedded-iot
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100