Skip to content

fix(bit-timing): support extended hardware limits - #2094

Open
timothyanderson096-ocdealcheck wants to merge 2 commits into
hardbyte:mainfrom
timothyanderson096-ocdealcheck:fix/bit-timing-hardware-limits
Open

fix(bit-timing): support extended hardware limits#2094
timothyanderson096-ocdealcheck wants to merge 2 commits into
hardbyte:mainfrom
timothyanderson096-ocdealcheck:fix/bit-timing-hardware-limits

Conversation

@timothyanderson096-ocdealcheck

Copy link
Copy Markdown

Summary of Changes

  • Allow BitTiming.iterate_from_sample_point() and BitTiming.from_sample_point() to use controller-specific tseg1_max, tseg2_max, and brp_max limits.
  • Replace the hardcoded strict search validation with explicit controller bounds while preserving the classical CAN bitrate range.
  • Add regression, boundary, documentation, and towncrier coverage.

The regression case uses a 160 MHz CAN clock at 250 kbit/s and an 87.5% sample point. Before this change it raises ValueError: No suitable bit timings found.; afterwards it selects the valid brp=40, tseg1=13, tseg2=2 timing. A brp_max=39 boundary check confirms the search remains bounded.

Related Issues / Pull Requests

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactoring
  • Other (please describe):

Checklist

  • I have followed the contribution guide.
  • I have added or updated tests as appropriate.
  • I have added or updated documentation as appropriate.
  • I have added a news fragment for towncrier.
  • All checks and tests pass (run directly; see below).

Testing

  • Full test suite: 500 passed, 130 skipped, 29 subtests passed
  • ruff check can examples doc
  • black --check can/bit_timing.py test/test_bit_timing.py
  • mypy --python-version 3.10 .
  • Sphinx HTML build with warnings as errors
  • Sphinx doctest build: 39 passed

Additional Notes

The skipped tests require unavailable hardware or platform-specific drivers.

@mergify

mergify Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8865a0a935

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread can/bit_timing.py
Comment thread can/bit_timing.py Outdated
Comment thread can/bit_timing.py Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BitTiming.from_sample_point rejects valid timing solutions due to hardcoded register limits

1 participant