René's URL Explorer Experiment


Title: `brp` parameter validation for `BitTiming` can be too restrictive for some peripherals · Issue #2061 · hardbyte/python-can · GitHub

Open Graph Title: `brp` parameter validation for `BitTiming` can be too restrictive for some peripherals · Issue #2061 · hardbyte/python-can

X Title: `brp` parameter validation for `BitTiming` can be too restrictive for some peripherals · Issue #2061 · hardbyte/python-can

Description: Describe the bug The BitTiming class unconditionally requires that the bitrate prescaler brp is within the interval [1,64]; this is checked in the _validate function, which is unconditionally called from __init__ even when strict=False: ...

Open Graph Description: Describe the bug The BitTiming class unconditionally requires that the bitrate prescaler brp is within the interval [1,64]; this is checked in the _validate function, which is unconditionally calle...

X Description: Describe the bug The BitTiming class unconditionally requires that the bitrate prescaler brp is within the interval [1,64]; this is checked in the _validate function, which is unconditionally calle...

Opengraph URL: https://github.com/hardbyte/python-can/issues/2061

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`brp` parameter validation for `BitTiming` can be too restrictive for some peripherals","articleBody":"### Describe the bug\nThe `BitTiming` class unconditionally requires that the bitrate prescaler `brp` is within the interval `[1,64]`; this is checked in the `_validate` function, which is unconditionally called from `__init__` even when `strict=False`:\n```python\n    def _validate(self) -\u003e None:\n        if not 1 \u003c= self.brp \u003c= 64:\n            raise ValueError(f\"bitrate prescaler (={self.brp}) must be in [1...64].\")\n\n        # other checks omitted\n```\n\nI was using `python-can` with a FYSETC UCAN transceiver running candleLight firmware, which speaks the `gs_usb` protocol. The transceiver uses a clock frequency of `fclock=48MHz`, but it also supports a large range of possible `brp` values from 1 to 1024 to implement lower bitrates (see [bxcan.c](https://github.com/candle-usb/candleLight_fw/blob/5fc2e6b560928f94079e206364354250157448c2/src/can/bxcan.c#L57) ). \n\nI need to configure a baud rate of 33333 bit/s and want to use the default sample point of 87.5%, which requires a prescaler value \u003e 64 to keep the other paramters (specifically `tseg1` within their valid range). This is currently not possible without patching the code of `python-can` directly, since the `gs_usb` interface kind does not allow direct specification of the `BitTimings`, and the validation check will reject the prescaler value, so the automatic parameter finding does not work. However, the device supports higher prescaler values just fine; and removing the bitrate prescaler check in `_validate` allows me to configure the device and send CAN messages.\n\n\n\n### To Reproduce\nThe following code will raise `ValueError(\"No suitable bit timings found.\")` from `BitTimings.from_sample_point`\n```python\nimport can\ncan_bus = can.Bus(interface='gs_usb', channel=0, bitrate=33333)\n```\n\nNote: this requires a suitable board with candleLight firmware to be present and attached. Internally, the device configuration routine retrieves the CAN clock speed and calls `BitTiming.from_sample_point` with those values:\n\n```python\nfrom can.bit_timing import BitTiming\nBitTiming.from_sample_point(f_clock=48000000,bitrate=33333,sample_point=87.5)\n```\nThis can be called without hardware to reproduce the issue.\n\n### Expected behavior\nIdeally, the parameter validation takes the valid parameter range of the attached device into account (if known), so that the code above just works as-is. The `gs_usb` protocol allows the host to query valid timing parameters, including the CAN clock frequency and the range of allowed `brp` values (start, stop, increment). \n\nAlternatively, having an option to pass a raw `BitTimings` object to the `can.Bus` method would work as well, although it would be less convenient.\n\n### Additional context\n\nOS and version: Linux 6.17.0-23-generic (Ubuntu 25.10)\nPython version: 3.13.7\npython-can version: 4.6.1\npython-can interface/s (if applicable): gs_usb\n\n\n\n\u003cdetails\u003e\u003csummary\u003eTraceback and logs\u003c/summary\u003e\n\n```\nTraceback (most recent call last):\n  File \"/home/user/Development/canbus/./gs_usb_bitrate_test.py\", line 3, in \u003cmodule\u003e\n    can_bus = can.Bus(interface='gs_usb', channel=0, bitrate=33333)\n  File \"/home/user/Development/canbus/venv/lib/python3.13/site-packages/can/util.py\", line 392, in wrapper\n    return f(*args, **kwargs)\n  File \"/home/user/Development/canbus/venv/lib/python3.13/site-packages/can/interface.py\", line 137, in Bus\n    bus = cls(channel, **kwargs)\n  File \"/home/user/Development/canbus/venv/lib/python3.13/site-packages/can/interfaces/gs_usb.py\", line 63, in __init__\n    bit_timing = can.BitTiming.from_sample_point(\n        f_clock=self.gs_usb.device_capability.fclk_can,\n        bitrate=bitrate,\n        sample_point=87.5,\n    )\n  File \"/home/user/Development/canbus/venv/lib/python3.13/site-packages/can/bit_timing.py\", line 295, in from_sample_point\n    raise ValueError(\"No suitable bit timings found.\")\nValueError: No suitable bit timings found.\n```\n\n\u003c/details\u003e\n","author":{"url":"https://github.com/SeTcbPrivilege","@type":"Person","name":"SeTcbPrivilege"},"datePublished":"2026-05-15T15:30:00.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/2061/python-can/issues/2061"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:fa53cec8-9c7b-53c4-3dbc-bd60a05821cb
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id964A:1DF241:5E362B1:7C64AE7:6A5DC2D3
html-safe-noncef5258d569a383fc482635fa84698f31bdb550f86c87fec00794b05eecdf6b1d4
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NjRBOjFERjI0MTo1RTM2MkIxOjdDNjRBRTc6NkE1REMyRDMiLCJ2aXNpdG9yX2lkIjoiNTE0Nzc0NTM3NjY2NjUwMTg0MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac8560c49555c326732c98e97107abf28019dbf53aa7d117301d83677c2d3c9819
hovercard-subject-tagissue:4455068446
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/hardbyte/python-can/2061/issue_layout
twitter:imagehttps://opengraph.githubassets.com/9be1c0a6a372b7a9b44461ab2b9b133240e208f2aca142404fba11c9aad2eb37/hardbyte/python-can/issues/2061
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/9be1c0a6a372b7a9b44461ab2b9b133240e208f2aca142404fba11c9aad2eb37/hardbyte/python-can/issues/2061
og:image:altDescribe the bug The BitTiming class unconditionally requires that the bitrate prescaler brp is within the interval [1,64]; this is checked in the _validate function, which is unconditionally calle...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameSeTcbPrivilege
hostnamegithub.com
expected-hostnamegithub.com
None5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b
turbo-cache-controlno-preview
go-importgithub.com/hardbyte/python-can git https://github.com/hardbyte/python-can.git
octolytics-dimension-user_id855189
octolytics-dimension-user_loginhardbyte
octolytics-dimension-repository_id69090889
octolytics-dimension-repository_nwohardbyte/python-can
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id69090889
octolytics-dimension-repository_network_root_nwohardbyte/python-can
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release9c975978430e9ad293956f2bbdaf153b1bd84a99
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/hardbyte/python-can/issues/2061#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fhardbyte%2Fpython-can%2Fissues%2F2061
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fhardbyte%2Fpython-can%2Fissues%2F2061
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=hardbyte%2Fpython-can
Reloadhttps://github.com/hardbyte/python-can/issues/2061
Reloadhttps://github.com/hardbyte/python-can/issues/2061
Reloadhttps://github.com/hardbyte/python-can/issues/2061
hardbyte https://github.com/hardbyte
python-canhttps://github.com/hardbyte/python-can
Notifications https://github.com/login?return_to=%2Fhardbyte%2Fpython-can
Fork 687 https://github.com/login?return_to=%2Fhardbyte%2Fpython-can
Star 1.6k https://github.com/login?return_to=%2Fhardbyte%2Fpython-can
Code https://github.com/hardbyte/python-can
Issues 224 https://github.com/hardbyte/python-can/issues
Pull requests 35 https://github.com/hardbyte/python-can/pulls
Discussions https://github.com/hardbyte/python-can/discussions
Actions https://github.com/hardbyte/python-can/actions
Security and quality 0 https://github.com/hardbyte/python-can/security
Insights https://github.com/hardbyte/python-can/pulse
Code https://github.com/hardbyte/python-can
Issues https://github.com/hardbyte/python-can/issues
Pull requests https://github.com/hardbyte/python-can/pulls
Discussions https://github.com/hardbyte/python-can/discussions
Actions https://github.com/hardbyte/python-can/actions
Security and quality https://github.com/hardbyte/python-can/security
Insights https://github.com/hardbyte/python-can/pulse
#2062https://github.com/hardbyte/python-can/pull/2062
brp parameter validation for BitTiming can be too restrictive for some peripheralshttps://github.com/hardbyte/python-can/issues/2061#top
#2062https://github.com/hardbyte/python-can/pull/2062
bughttps://github.com/hardbyte/python-can/issues?q=state%3Aopen%20label%3A%22bug%22
https://github.com/SeTcbPrivilege
SeTcbPrivilegehttps://github.com/SeTcbPrivilege
on May 15, 2026https://github.com/hardbyte/python-can/issues/2061#issue-4455068446
bxcan.chttps://github.com/candle-usb/candleLight_fw/blob/5fc2e6b560928f94079e206364354250157448c2/src/can/bxcan.c#L57
bughttps://github.com/hardbyte/python-can/issues?q=state%3Aopen%20label%3A%22bug%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.