Skip to content

[643] Fixed new protections don't accept volatile#644

Merged
jorgesg82 merged 5 commits into
developmentfrom
643-new-protections-dont-accept-volatile
May 11, 2026
Merged

[643] Fixed new protections don't accept volatile#644
jorgesg82 merged 5 commits into
developmentfrom
643-new-protections-dont-accept-volatile

Conversation

@jorgesg82
Copy link
Copy Markdown
Contributor

Volatile Protection Sources

Related PR: #628 - ProtectionManager Without Ethernet / Fault Runtime Redesign

Summary

This follow-up extends the compile-time protection model introduced in PR #628 so protections
can use volatile variables directly as sample sources.

Protection source storage now preserves cv-qualification through a reference source wrapper,
while rule evaluation still works with plain sample values. This keeps the public protection
declaration API unchanged and avoids making all protection reads volatile by default.

Main Changes

  • Add ReferenceSampleSource<Storage> to preserve the storage type used by a protection source.
  • Keep SampleSource<Storage> as an alias for the reference source wrapper.
  • Make Protection store the actual readable source type instead of forcing every source into
    SampleSource<T>.
  • Make ProtectionEngine wrap raw variables with a source type that preserves volatile.
  • Add simulator coverage proving a protection declared over a volatile float reads and reports
    the observed value correctly.

Example

inline volatile float temperature_c = 0.0f;

inline constexpr auto temperature_protection =
    Protections::protection<"temperature", temperature_c>(
        Protections::Rules::above(80.0f, 60.0f)
    );

@jorgesg82 jorgesg82 self-assigned this May 8, 2026
@jorgesg82 jorgesg82 linked an issue May 8, 2026 that may be closed by this pull request
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

ST-LIB Release Plan

  • Current version: 6.1.0
  • Pending changesets: 1
  • Highest requested bump: patch
  • Next version if merged now: 6.1.1

Pending changes

  • patch Allow protections to read volatile sample sources (.changesets/volatile-protection-sources.md)

Copy link
Copy Markdown
Contributor

@FoniksFox FoniksFox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and it seems to be working correctly

@jorgesg82 jorgesg82 merged commit a751647 into development May 11, 2026
24 checks passed
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.

New protections don't accept volatile

2 participants