Skip to content

[APPS-000] SAM/DAM_MPDO#3

Open
tadasaleksonis-bc wants to merge 7 commits into
masterfrom
taleksonis/feature/canopen_mpdo_support
Open

[APPS-000] SAM/DAM_MPDO#3
tadasaleksonis-bc wants to merge 7 commits into
masterfrom
taleksonis/feature/canopen_mpdo_support

Conversation

@tadasaleksonis-bc

Copy link
Copy Markdown

First pass at letting an agent generate DAM/SAM MPDOs before testing integration into brain-rt.

tadasaleksonis-bc and others added 7 commits May 14, 2026 18:30
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>
@tadasaleksonis-bc tadasaleksonis-bc marked this pull request as ready for review June 17, 2026 23:12
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.

1 participant