rust-embedded / rust-embedded/embedded-hal-mock

Support for don't care writes in I2C

Open
#135 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
146
Forks
29
PR merge metrics
No merged PRs in 30d

Description

Motivation

I have a test case where there are a ton of I²C writes which I don't care about in this specific test. I still want to mock execute them but the data written is not relevant.

Implementation

I have some ideas how this could be implemented.

  1. The impl Transaction block 1 could be extended with a function write_ignore then either implemented by extending the enum Mode2 with WriteIgnore or a new field in the Transaction struct3

  2. Another way would be to add an option to write()4 but that would break all tests for every user of the I²C whether they want this feature or not, so I don't think that is the path forward.

  3. The same builder style interface as with_error5 could be used to modify Transaction

  • Are there any negative implications I did not consider?
  • Any preferred implementation style?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/eh1/i2c.rs, reading the impl Transaction block, Mode, Transaction, and the with_error builder referenced in the issue. Compare the proposed ways to represent an ignored write, then add coverage showing that I2C writes can execute without matching their data while existing write expectations remain unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
testing-qa
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.