snap_hysteresis's tolerance band is asymmetric at two of its eight edges

オープン
#76 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
rust
領域
embedded-iot

調査の方向性

Start with src/lib.rs and run ops_tests::hysteresis::the_band_edges_are_asymmetric, which records the current behavior. Decide whether the tolerance policy should remain approximate or change to midpoint, scaled tolerance, or inclusive slack. Done means a deliberate behavior choice, updated tests, and a changelog-visible commit if behavior changes.

索引モデルが issue の本文から書いたものです。

説明

bug

ops::snap_hysteresis (src/lib.rs) rejects an input further than
HYSTERESIS_TOLERANCE from the nearest legal setting. The constant is
0.05f32, whose exact value is 0.05000000074505805969, and the
comparison is against a subtraction whose result depends on which side
of its decimal value each f32 literal rounded to.

Measured

Both functions were transcribed verbatim into a scratch binary and run
under rustc -O rather than reasoned about on paper:

Setting −0.05 edge diff +0.05 edge diff
0 °C accepted 0.05 accepted 0.05
1 °C rejected 0.050000012 accepted 0.049999952
2 °C accepted 0.049999952 accepted 0.049999952
4 °C accepted 0.049999952 rejected 0.05000019

Six of eight edges are accepted, and the two rejections fall on
opposite sides — the low edge at 1 °C, the high edge at 4 °C. No
single description of the band is correct for all four settings.

So a caller asking for 0.95 °C of hysteresis gets InvalidInput, while
one asking for 1.05 °C gets Hysteresis::OneC. Both are the same
distance from 1 °C as written; only their f32 representations differ.

Status

Pinned as measured by
ops_tests::hysteresis::the_band_edges_are_asymmetric, added while
closing #66, so any change to it is deliberate rather than silent.
Whether it should change is this issue.

Note the ±0.05 °C band is driver policy, not a datasheet tolerance —
SBOS663A §7.5.3.1 Table 9 specifies the four discrete encodings and
says nothing about how an arbitrary float should reach one. #66 Part 2
records the band as a legal choice.

Options

Roughly in increasing order of disruption:

  1. Leave it. Document the band as approximate. A caller sitting
    within 0.05 °C of an edge is already asking for a setting it did not
    name, and the four settings are 1 °C apart.
  2. Compare against the midpoint between adjacent settings, or
    against a tolerance scaled per setting, so the decision does not
    turn on one constant's representation.
  3. Make the comparison inclusive with slack — e.g. > against
    HYSTERESIS_TOLERANCE + f32::EPSILON, making all eight edges
    accept.

Any of 2 or 3 changes behaviour for callers currently on the rejected
side of an edge, so it needs a changelog-visible commit.

Provenance

Raised while closing #66. Not a regression — the behaviour predates
that work; it was simply never asserted.

主要言語
Rust
スター
2
フォーク
7
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

OpenDevicePartnership/tmp108 のほかの issue

OpenDevicePartnership/tmp108 の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。