Repository navigation
fix(bit_timing): make the sample point solver's register ranges configurable - #2165
ChuangMuLinze wants to merge 2 commits into
Conversation
…gurable `iterate_from_sample_point` built every candidate with `strict=True`, whose `brp <= 32`, `tseg1 <= 16` and `tseg2 <= 8` limits are the ISO 11898-1 minimum ranges. A controller whose registers reach further therefore had valid timings rejected, and `from_sample_point` raised "No suitable bit timings found" with no way for a caller to widen the search. STM32G431 FDCAN at 160 MHz for 250 kbit/s at 87.5% is such a clock: the only solution is brp=40, tseg1=13, tseg2=2, and the strict brp limit rejected it. `from_sample_point`, `iterate_from_sample_point` and `BitTiming` now take `tseg1_max`, `tseg2_max` and `brp_max`, and the solver scans prescalers up to the configured maximum. The defaults are the previous limits, so existing callers see no change. Fixes hardbyte#2083
AI Review: PR #2165 – configurable register ranges for the sample point solverThe PR fixes the reported case: API design
Documentation
Tests
Changelog
Verdictrequest changes |
`black --check .` is the first command of the lint environment and reformats this file: the parametrize decorator fits on one line, and so does the call in `test_from_sample_point_rejects_impossible_ranges`. No behavior changes.
|
The The other four failing jobs are not from this change.
|
Summary of Changes
iterate_from_sample_pointbuilt every candidate withstrict=True, whosebrp <= 32,tseg1 <= 16andtseg2 <= 8limits are the ISO 11898-1 minimum ranges every compliantcontroller must support. A controller whose registers reach further had valid timings rejected
and
from_sample_pointraisedNo suitable bit timings found, with no way for a caller to widenthe search.
BitTiming,from_sample_pointanditerate_from_sample_pointtaketseg1_max,tseg2_maxand
brp_max._restrict_to_minimum_rangeuses those bounds instead of hardcoded ones.brp_maxrather than stopping at 64.solution.
Related Issues / Pull Requests
BitTiming.from_sample_pointrejects valid timing solutions due to hardcoded register limits #2083Type of Change
Checklist
the docstrings, which the API docs render.
doc/changelog.d/2083.fixed.rst) for towncrier.tox) — see below for what I ran.Additional Notes
The case from the issue, STM32G431 FDCAN at 160 MHz for 250 kbit/s at 87.5%, now returns the
solution the issue predicted:
Without the new arguments it still raises, which
test_from_sample_point_keeps_default_rangespins.
Test run:
The five new behaviour tests fail on unpatched
main(unexpected keyword argument), so they coverthe change.
I ran pytest directly rather than through
tox; this sandbox has no tox environment, so Iinstalled
wrapt,pytest-timeoutandpytest-covto satisfy the project'saddopts. Everythingelse is the repository's own
tox.iniconfiguration.