Repository navigation
rewrite(phase4): mock.hpp batch B — Table 24 response suppression + regmap/discovery wiring - #147
Merged
Merged
Conversation
…egmap/discovery wiring Part of the v3.0.0 ground-up rewrite (cpp-RCP #129, ROADMAP.md Phase 17), branch rewrite/v3-from-c-rcp. Phase 4 batch B of a four-batch mock.hpp port, built on batch A's server::Endpoint admission wiring. ## Ported (c-RCP src/mock.c -> mock::Server) - Table 24 response suppression (src/mock.c:1716-1760, REQ-RMAP-048/049): new private static Server::suppress_response_per_stream_cfg(), resolving stream_id via regmap::request_stream_cfg::resolve_index() and zeroing out_resp/out_resp_payload when the resolved stream's rx_ack_stream_index (Acknowledge-classified responses) or rx_resp_stream_index (everything else) is 0. - Storage: Server::set_request_stream_cfg()/request_stream_cfg() and set_ep_id_map()/ep_id_map(), mirroring c-RCP's rcp_mock_server_set_request_stream_cfg()/_set_ep_id_map() (src/mock.c:444-460/565-580), bounds-checked against regmap::request_stream_cfg::kMaxEntries/regmap::ep_id_map::kMaxEntries, syncing svr_request_stream_cfg_capacity/svr_ep_bytebus_id_map_capacity (REQ-RMAP-034/037). - Discovery wiring (mock.h:501-529, src/mock.c:663-687, REQ-RMAP-066): discovery::DiscoveryClaim member, discovery_claim() getter, set_discovery_timeout_us() keeping it and regs_.svr_ep_cfg.svr_discovery_timeout in sync. Confirmed by direct source read that c-RCP's own mock.c never wires the claim into dispatch, so nothing beyond storage was added. ## dispatch_* changes Each of the ten operational dispatch_*() functions (gpio/spi/i2c/adc/ pwm_in/lin/can/uart/iseled/mdio) renamed to dispatch_*_inner() (unchanged batch-A body), with a new thin dispatch_*() wrapper calling _inner then suppress_response_per_stream_cfg() -- mirroring c-RCP's dispatch_plain()/dispatch_plain_inner() split, generalized per endpoint type. dispatch() gained a trailing, defaulted avtp::StreamId stream_id parameter threaded to all ten; the default resolves to "no stream configured," so no pre-existing call site's behavior changes. dispatch_ep0() left untouched (not one of the ten operational endpoints). ## Bug found and fixed make_initial_register_map()'s ten default ep_id_mapping rows all left request_stream_index at its struct default (0) -- TC18's own end-of-table sentinel -- which would make regmap::ep_id_map::effective_count() read the whole populated table as zero rows. Fixed to 1 (matching row_init_default()'s own power-on convention); also fixed svr_ep_bytebus_id_map_capacity to sync to 10. Neither was exercised by existing tests, so this is inert today but fixes future batch-C consumers (broadcast_safe_state, sequencer access control). ## Small addition to already-merged discovery.hpp Added DiscoveryClaim::set_timeout() -- batch B's set_discovery_timeout_us() needed a way to re-derive the claim's window from a new register value without resetting holder_/ claimed_at_ (c-RCP's own documented contract), and no such mutator existed. ## Verification Existing 60 test cases required no changes (default request_streams table is empty, so suppression is a no-op unless a test opts in). 11 new TEST_CASEs added: ep_id_mapping bug-fix assertions, bounds-check tests, 5 Table-24 suppression tests ported from c-RCP's tests/test_mock.c:1061-1204, one sweep across all ten endpoint types, 3 discovery-claim tests ported from tests/test_mock.c:1917-1980 (adapted to DiscoveryClaim's steady_clock-based API). include/rcp/mock.hpp: 1387 -> 1759 lines. tests/test_mock.cpp: 1285 -> 1561 lines, 60 -> 71 TEST_CASEs (583 assertions). include/rcp/ discovery.hpp: 818 -> 837 lines. Full tree rebuilds clean (0 errors, 0 warnings), 58/58 ctest suites pass (100%) -- independently re-verified from a fresh build, not just the porting agent's own report. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Signed-off-by: Matt <47545907+SoundMatt@users.noreply.github.com>
10 tasks
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.
Part of the v3.0.0 ground-up rewrite (#129, ROADMAP.md Phase 17), branch
rewrite/v3-from-c-rcp. Phase 4 batch B of a four-batchmock.hppport, built on batch A'sserver::Endpointadmission wiring.Ported
suppress_response_per_stream_cfg(), resolvingstream_idand zeroing the response when the resolved stream'srx_ack_stream_index/rx_resp_stream_indexis 0.set_request_stream_cfg()/set_ep_id_map()(REQ-RMAP-034/037), bounds-checked, syncing capacity fields.discovery::DiscoveryClaimmember, getter,set_discovery_timeout_us(). Confirmed by direct source read that c-RCP's ownmock.cnever wires the claim into dispatch, so nothing beyond storage was added.dispatch_* changes
Each of the ten operational
dispatch_*()functions renamed todispatch_*_inner()(unchanged batch-A body), with a thin wrapper calling_innerthen the suppression step — mirroring c-RCP'sdispatch_plain()/dispatch_plain_inner()split.dispatch()gained a trailing, defaultedstream_idparameter; the default preserves all pre-existing call-site behavior.Bug found and fixed
make_initial_register_map()'s ten defaultep_id_mappingrows all leftrequest_stream_indexat 0 — TC18's own end-of-table sentinel — which would makeep_id_map::effective_count()read the whole populated table as zero rows. Fixed to 1, matching the power-on convention. Inert today, fixes future batch-C consumers.Small addition to discovery.hpp
Added
DiscoveryClaim::set_timeout()— needed to re-derive the claim's window from a new register value without resetting the held claim, matching c-RCP's documented contract.Verification
Existing 60 tests pass unmodified. 11 new TEST_CASEs: bug-fix assertions, bounds checks, 5 Table-24 suppression tests, a sweep across all ten endpoint types, 3 discovery-claim tests.
mock.hpp: 1387→1759 lines.test_mock.cpp: 1285→1561 lines, 60→71 TEST_CASEs (583 assertions).Full tree rebuilds clean (0 errors/warnings), 58/58 ctest suites pass (100%) — independently re-verified from a fresh build.