Skip to content

fix(kvaser): pass unsigned integer for local TXACK - #2134

Merged
zariiii9003 merged 2 commits into
hardbyte:mainfrom
timothyanderson096-ocdealcheck:fix/kvaser-txack-buffer-width-2050
Nov 22, 2026
Merged

zariiii9003 merged 2 commits into
hardbyte:mainfrom
timothyanderson096-ocdealcheck:fix/kvaser-txack-buffer-width-2050

Conversation

@timothyanderson096-ocdealcheck

@timothyanderson096-ocdealcheck timothyanderson096-ocdealcheck commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary of Changes

CANlib documents canIOCTL_SET_LOCAL_TXACK as taking an unsigned integer, but the Kvaser constructor passes a one-byte buffer. Use ctypes.c_uint and its native size. Preserve the existing TXECHO byte buffer and error propagation.

Adds a constructor regression covering all four single_handle / receive_own_messages combinations and a news fragment. The vendor contract provides the independent expected type and size.

Related Issues / Pull Requests

Fixes #2050.

Related: #2051, #2079 and #1908. The other ioctl reports may have separate causes; this change addresses only the TXACK argument contract. Hardware confirmation remains desirable before release.

Type of Change

  • Bug fix

Checklist

  • Contribution guide followed; current base and existing discussions checked.
  • Regression tests added.
  • Documentation/news fragment added in doc/changelog.d/2050.fixed.rst.
  • All checks and tests pass (tox) — focused and configured static/docs results are below; full suite and hosted matrix remain unverified.

Validation

The regression fix was additionally updated to use the reviewer-requested user-visible changelog wording. The earlier validation below applies to the source-level fix; hosted checks of the latest head remain to be verified.

  • Linux CPython 3.12.14 and 3.14.10, configured focused pytest with timeout/coverage: 19 tests and 4 subtests pass.
  • Original production with identical final tests on Python 3.14: 19 passing controls and 4 failing subtests, each reporting the TXACK buffer width as 1 instead of 4. Only native CANlib boundaries are mocked.
  • On the configured Python 3.14 runtime: Black 26.10.1 checks all 155 files; Ruff 0.17.5 and the complete configured Pylint 4.1.4 targets pass; Mypy 2.4.1 passes all five configured Python 3.11–3.15 targets (65 source files each).
  • Configured strict HTML build and all 39 documentation doctests pass. Whitespace checks pass.

Native CANlib, physical adapters, the full test suite and hosted OS/interpreter validation remain unverified. This is a vendor-contract regression, not a physical receiver reproduction.

Prepared with OpenAI Codex assistance and independent inspection.

Timothy Anderson — Spotted Ridge Engineering / OC Labs
Independent software verification · GDN (Global Decision Network)
timothyanderson096@gmail.com · Engineering evidence

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T00:06:24.883072Z 4d417b4 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@zariiii9003

Copy link
Copy Markdown
Collaborator

AI Review

Verdict: Approve, with one requested change to the changelog fragment and one to the issue link.

Correctness

The change is correct. The CANlib documentation for canIOCTL_SET_LOCAL_TXACK says that buf points to an unsigned int. The current code passes a 1-byte c_byte with buflen=1. Passing c_uint with ctypes.sizeof(ctypes.c_uint) matches the documentation. The canIOCTL_SET_LOCAL_TXECHO call is correctly left as a byte, since CANlib documents that argument as an unsigned byte.

Relation to #2050

This change very likely fixes #2050:

Please write Fixes #2050 instead of "Related to". Ideally the reporter confirms this on hardware before release.

Tests

The new test is a valid regression test. With plain unittest, it fails without the fix (1 != 4 in all four subtests) and passes with it. black, ruff, pylint and mypy report no new findings.

Requested changes

  1. Changelog fragment: use a single line that describes the effect users see, for example:

    Fix ``canERR_PARAM`` raised when opening a Kvaser channel with Linux CANlib, a regression introduced in 4.6.0.
  2. Issue link: use Fixes #2050 in the PR description (see above).

Follow-up (not blocking)

Because Linux CANlib checks buflen, the other canIoCtl calls in the Kvaser backend should be checked against the documented argument types. #2051 and #2079 report other ioctl failures that this may explain. This regression stops 4.6.x users on Linux from opening a Kvaser channel at all, so a patch release is worth considering.

@zariiii9003
zariiii9003 merged commit 8c848b8 into hardbyte:main Nov 22, 2026
26 of 27 checks passed
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.

Can't connect to a kvaser device with 4.6.1

2 participants