fix(0x11): send ECUReset positive response before performing the reset#82
Merged
Conversation
ISO 14229-1 (ECUReset): "The ECUReset positive response message (if required) shall be sent before the reset is executed in the server(s)." The handler did the opposite — it called fn_reset() first and only then built and sent the 0x51 response. On real hardware fn_reset reboots the MCU and never returns, so the response was never transmitted and the tester saw no answer. Reorder so the positive response (or suppressPosRsp handling) is emitted first, then fn_reset() is invoked. Add a regression test that stamps a monotonic counter from the transport and reset callbacks and asserts the response is sent strictly before the reset. Closes #76
…response-ordering # Conflicts: # tests/unit/test_service_11.c
This was referenced Jun 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #76.
Bug
ISO 14229-1 (ECUReset) requires:
The handler did the reverse — it called
fn_reset()first, then built and sent the0x51response:On a real ECU,
fn_resetperforms the actual reset (e.g.NVIC_SystemReset()) and never returns, so the positive response was never put on the wire and the tester saw no answer.Fix
Reorder: emit the positive response (or honour suppressPosRsp), then call
fn_reset(). The0x51reply is 2 bytes (single ISO-TP frame) so it is fully handed to transport synchronously before the reset is performed.Test
Added
test_ecu_reset_response_sent_before_reset: local transport and reset callbacks stamp a shared monotonic counter; the test assertssend_order < reset_order(and the0x51 01payload). Fails before the fix, passes after.Verification
100% tests passed, 0 tests failed out of 59clang-format 18 --dry-run --Werror(CI Docker image) clean acrosssrc include examplesand the test fileNote
This is the response-ordering defect. The related stuck-
suppressPosRspleak (next service after a0x11 0x81getting silently suppressed) is fixed separately in #81 — it lives inuds_core.cdispatch, so the two changes touch different files and don't conflict.