[APPS-000] SAM/DAM_MPDO#3
Open
tadasaleksonis-bc wants to merge 7 commits into
Open
Conversation
Add SAM (Source Address Mode) consumer and producer alongside the DAM
first-pass:
- CO_MPDO_applySAM: peer to applyDAM; dispatcher table looks up
(producerNodeId, srcIdx, srcSub) -> (dstIdx, dstSub) and writes the
payload into the local OD.
- CO_MPDO_scanWrite: OD-extension write callback that flags the scanned
entry dirty; CO_MPDO_processTX SAM walker emits one frame per dirty
row on the carrier TX slot, with clear-before-read race ordering.
- Public API: CO_MPDO_configRX_SAM, CO_MPDO_dispatchAdd_SAM,
CO_MPDO_configTX_SAM, CO_MPDO_scanAdd_SAM. Programmatic registration
(no 0x1FA0 / 0x1FD0 OD parsing yet); the OD-driven path is a future
enhancement layered on these primitives.
- CO_MPDO_processTX: inhibit decrement lifted out of the DAM-only block
so SAM-only builds tick the timers.
Compile-tested for CO_CONFIG_MPDO ∈ {0, RX_DAM|TX_DAM, RX_SAM|TX_SAM,
all four, RX_SAM only, TX_SAM only} with -Wall -Wextra -Wpedantic
-Wshadow -Wstrict-prototypes -Wmissing-prototypes -std=c11.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CO_MPDO_dispatchAdd_SAM accepted any (dstIdx, dstSub) without checking it. A mis-provisioned row then either silently dropped frames or wrote through a non-PDO entry at runtime, undebuggable in the field. Validate the destination at registration the same way the producer-side scanAdd_SAM validates its source: the entry must exist, be PDO-writable (ODA_RPDO), and have a storage length in 1..4. Resolve with odOrig=false so the captured length matches the view applySAM writes through. Reject duplicate (producerNodeId, srcIdx, srcSub) keys so dispatch resolves to exactly one row, and stash the validated length in the dispatch row for the apply-time cross-check. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
CO_MPDO_applySAM trusted the live destination entry length and wrote that many bytes, so an OD entry whose length changed after registration would silently absorb the wrong byte count. Cross-check the live length against the value captured at registration and raise CO_EMC_DAM_MPDO on mismatch, mirroring the producer-side scanAdd_SAM length contract. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The SAM dispatcher miss and the runt-DLC drop were both invisible: frames vanished with no trace, leaving field mis-provisioning undebuggable. The spec mandates the silent drop, not silent un-accounting. Add a per-slot badDlcCnt for DLC != 8 drops and a SAM rxDispatchMissCnt for frames with no matching dispatch row. Both are volatile so a diagnostics reader on another context sees fresh values; increments stay in the RX/process context, consistent with the existing single-core flag design. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
SAM TX was purely dirty-flag driven, so cyclic telemetry would have forced the application to poke OD entries on its own timer — racy and a layering violation. Give the scanner a per-row event timer instead, modeled on the TPDO event timer: scanAdd_SAM takes an eventTime_us period (0 keeps the row event-driven), processTX counts it down and marks the row dirty on expiry, feeds timerNext_us, and reloads on send. The inhibit window still bounds the real send rate and the clear-before-read invariant is untouched. Adds a parameter to CO_MPDO_scanAdd_SAM; the producer-side caller on the VC integration branch must pass the period. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
First pass at letting an agent generate DAM/SAM MPDOs before testing integration into brain-rt.