fix(foundation): stabilize async discovery and bus reset recovery - #18
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 31c784ea56
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "ConfigROMStore::FindLatestForNode: node=%u using gen=%u with unit profile " | ||
| "instead of partial gen=%u", | ||
| nodeId, latestWithUnitProfile->gen.value, latest ? latest->gen.value : 0); | ||
| return latestWithUnitProfile; |
There was a problem hiding this comment.
Do not return older ROMs for reused node IDs
When the latest ROM cached for this node is partial, this fallback returns any older ROM with unit directories for the same node number. Node IDs are reassigned across bus resets and device unplug/replug, so if device A previously had a rich ROM at node 0 and device B later appears at node 0 with only a minimal/partial ROM, ExportConfigROM with a stale/zero generation will expose A's raw ROM for B. Prefer the richer cache only when it is for the same GUID as the latest node entry, otherwise return the latest generation for the node.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in the latest update. The fallback now only reuses an older richer ROM when it matches the latest node entry's GUID, and the stack includes a regression test covering node ID reuse with a different GUID.
There was a problem hiding this comment.
Could you please update stale comments in PacketRouter.hpp / PacketHelpers.hpp that still imply “big-endian packet header” or “zero-copy” since your code is correct.
There was a problem hiding this comment.
| const char* StateString() const; | ||
| static const char* StateString(State state); | ||
|
|
||
| enum class RecoveryReasonCode : uint8_t { |
There was a problem hiding this comment.
Kindly add source in the comment: where does it comes from?
There was a problem hiding this comment.
Added in b66b488. These are ASFW-defined BusResetCoordinator diagnostics labels, not OHCI/IEEE 1394 wire or register values. The comment now states that they label the coordinator FSM branch that most recently recorded a recovery trigger.
| constexpr uint32_t kNikonOui = 0x0090B5; | ||
| constexpr uint8_t kNikonSlowPublishRetryBudget = 4; | ||
| constexpr uint64_t kNikonSlowPublishDelayNs = 500ULL * 1'000'000ULL; |
There was a problem hiding this comment.
Not the best place for such variables, but let's leave it here for now. We will think of better place later
There was a problem hiding this comment.
Noted. I’ll keep the placement unchanged in this PR and leave centralizing these constants for a follow-up cleanup.
|
|
||
| namespace { | ||
|
|
||
| constexpr uint32_t kUnitSpecIdSBP2 = 0x00609E; |
|
Thanks. This is amazing piece of work. |
I’m happy to contribute. This is an amazing project, and I’m glad my PR helps : ) |
fix(foundation): stabilize async discovery and bus reset recovery
DICE and main had diverged into two parallel lines. This merge records DICE (40a796c) as a second parent so main's prior history — including gly11's merged PRs #18/#19/#20 and the sbp2/ci/foundation fixes — is preserved as ancestry, while the resulting tree is taken wholesale from DICE. main-only code is superseded by DICE's implementation but remains recoverable from history (refs/backup/main-pre-dice-merge = 757456d). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
fix(foundation): stabilize async discovery and bus reset recovery
DICE and main had diverged into two parallel lines. This merge records DICE (40a796c) as a second parent so main's prior history — including gly11's merged PRs mrmidi#18/mrmidi#19/mrmidi#20 and the sbp2/ci/foundation fixes — is preserved as ancestry, while the resulting tree is taken wholesale from DICE. main-only code is superseded by DICE's implementation but remains recoverable from history (refs/backup/main-pre-dice-merge = 757456d). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Summary
This PR extracts the async, discovery, and bus-reset foundation fixes from the larger bring-up branch so they can be reviewed independently before higher-level protocol work.
Async TX/RX Foundations
Bus Reset & Controller Bring-Up
Config ROM & Discovery
Tests
Why this PR
These changes are shared foundations for subsequent protocol work, but they are useful and reviewable on their own. Keeping them separate reduces the follow-up PR size and lets reviewers focus first on async response handling, bus reset recovery, and discovery convergence.
This PR intentionally does not include higher-level protocol session/command plumbing, debug UI, local diagnostic scripts, install helpers, or documentation-only planning notes.
Verification
Directly ran:
Also verified with:
The Xcode build succeeds. Existing Swift warnings and a CoreSimulator version warning are still present, but they do not block the build.