Skip to content

Fix isotp_send_with_id ignoring the identifier for Single Frames - #79

Merged
SimonCahill merged 2 commits into
SimonCahill:masterfrom
mproskauer-cmt:fix/send-with-id-single-frame
Sep 12, 2026
Merged

SimonCahill merged 2 commits into
SimonCahill:masterfrom
mproskauer-cmt:fix/send-with-id-single-frame

Conversation

@mproskauer-cmt

Copy link
Copy Markdown
Contributor

Problem

isotp_send_with_id() is documented as overriding the link's transmit identifier for one send, and the README recommends it for functional addressing. Since 276549c (#36) the override only reached the First Frame: isotp_send_single_frame() discarded its id argument and transmitted with link->send_arbitration_id. ISO 15765-2 restricts functional addressing to Single Frames, so a functional request such as isotp_send_with_id(&link, 0x7DF, ...) on a link initialised with 0x7E0 went out on 0x7E0.

Full details and a standalone reproduction are in #78.

Fix

isotp_send_single_frame() now passes id to isotp_user_send_can() and the (void)id that hid the unused parameter is gone. The change covers both the Classical CAN Single Frame and the CAN FD SF_DL escape format, which share the same send call. isotp_send_first_frame() already used id and is unchanged.

Test

SendsWithOverriddenIdentifier in tests/test_framing.cpp sends through isotp_send_with_id() and asserts on the identifier captured by the mock:

  • a Single Frame goes out on the override,
  • the link's own identifier is untouched and a following isotp_send() uses it,
  • a First Frame goes out on the override,
  • with ISO_TP_MAX_CAN_FRAME_SIZE > 8, an escaped Single Frame goes out on the override.

The test is compiled into all twelve framing configurations. Against master it fails in every one of them with the link identifier (0x123) where the override (0x7DF) is expected. With the fix, all pass.

Verification

Run locally on macOS with Apple clang 21, using isotpc_STATIC_LIBRARY=ON because the shared-library target does not link on macOS without the user hooks (pre-existing, not touched here):

configuration result
standard 192/192
isotpc_ENABLE_CAN_SEND_ARG=ON 192/192
isotpc_ENABLE_CAN_SEND_ARG=ON isotpc_ENABLE_TRANSCEIVE_EVENTS=ON 192/192
isotpc_MAX_CAN_FRAME_SIZE=64 192/192
isotpc_NO_FORMATTED_ERRORS=ON 192/192
CAN FD with all features (CI matrix entry) 204/204
Debug build (coverage job configuration) 192/192

isotpc_BUILD_EXAMPLES=ON compiles the examples without warnings, and make version-gate passes. I could not run the cppcheck/Infer gate or the libFuzzer target locally; CI will cover those.

Version

Bumped to 1.9.3 in vars.mk, CMakeLists.txt and library.json so the version gate passes. Happy to change it if you would rather pick the number.

Fixes #78

Co-authored by Fable 5.1 High

isotp_send_single_frame() discarded its id argument and transmitted with
link->send_arbitration_id, so isotp_send_with_id() only overrode the
identifier of a First Frame. ISO 15765-2 restricts functional addressing
to Single Frames, which made the documented use case send on the
physical identifier instead.

Pass id through to isotp_user_send_can(), add a regression test covering
the Single Frame, First Frame and CAN FD escaped Single Frame paths, and
bump the version to 1.9.3 for the version gate.

Fixes SimonCahill#78

Co-authored by Fable 5.1 High
Co-authored by Fable 5.1 High
@SimonCahill

Copy link
Copy Markdown
Owner

Nice catch!

@SimonCahill
SimonCahill merged commit 1fc19e2 into SimonCahill:master Sep 12, 2026
17 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.

isotp_send_with_id() ignores the identifier for Single Frames

2 participants