Skip to content

Merging Lucadev into main for SCALES v1.3.0 - #17

Open
LucaLanzi wants to merge 72 commits into
mainfrom
lucadev
Open

LucaLanzi wants to merge 72 commits into
mainfrom
lucadev

Conversation

@LucaLanzi

Copy link
Copy Markdown
Contributor

Merge lucadevmain

126 files changed, 13,833 insertions(+), 1,348 deletions(-)

(Generated code-coverage HTML/CSS reports have been untracked from this branch — only lightweight coverage/summary.txt files remain per component.)

Summary

This branch is a major fault-protection and data-handling overhaul for the SCALES i.MX/Jetson stack: it introduces a formal flight-processor failover state machine, a full telemetry/data-products pipeline, GDS command-authority arbitration between TCP and UART links, and substantially reworks the Jetson power/thermal management components. It also adds comprehensive unit test coverage and updated SDDs across nearly every existing component.

New Components

  • FPManager — Rebuilt from a stub into the system's fault-protection core. Now driven by a new FPStateMachine (state-machine-instance) that selects the active flight processor, gates remote Jetson commands (remoteJetsonCmdIn/Out, indexed for both the direct GDS path and the CmdSequencer path) so sequences can't reach the hub while the Jetson is powered off, tracks Jetson power/hub-trust state, handles emergency peripheral power-off, and processes FATAL events for graceful shutdown before they hit the framework's terminating handler.
  • DataProducer — New active component that aggregates thermal (i.MX, peripheral/MCP, Jetson) and power (Ina) readings from the other managers into unified data products, with commands to enable/disable production.
  • GdsCmdAuthMux — New active component (with its own GdsMuxStateMachine) that arbitrates between TCP- and UART-sourced command buffers so only the currently-authorized GDS path is forwarded downstream.
  • FatalRelay — Minimal passive component that slots into CdhCore's single-consumer fatalHandler connection, letting a FATAL announcement be routed through FPManager for a graceful shutdown sequence before reaching the real Svc.FatalHandler.
  • HubComAdapter — Adapts GenericHub buffer ports to the context-carrying Svc.ComDataWithContext ports used by the F Prime framer/deframer stack.

Major Component Reworks

  • JetsonManager / JetsonPowerModeManager / JetsonThermalManager — Substantial fixes around Jetson power-mode transitions, unprotected power-mode requests on reboot, missed guard calls, and state-detection for unused CV modules; now integrated with DataProducer and gated through FPManager's new authorization ports.
  • ImxThermalManager — Reworked alongside new ThermalReadingPorts/TempBounds types; old .template.cpp/.hpp test scaffolding removed in favor of real generated tester files.
  • McpManager, InaManager, PerifBoardManager, WatchdogManager — Updated to plug into the new data-product and command-authority ports (WatchdogManagerTester given friend-class access for testing).

New Types / Ports

  • FPManagerState.fpp, TempBounds.fpp, CommandAuthority.fpp
  • ThermalReadingPorts.fpp (unified thermal-reading port definitions for MCP/i.MX/Jetson)
  • PowerPorts.fpp additions: InaPowerReadings, JetsonPowerStateAuthorize (sync authorization), EmergencyPowerOff, JetsonHubTrustStatus

Testing & Docs

  • New/expanded unit test suites (*Tester.cpp/hpp, *TestMain.cpp) for every touched component, including all-new suites for DataProducer, FPManager, GdsCmdAuthMux, and HubComAdapter.
  • SDDs (docs/sdd.md) rewritten/expanded for nearly all components to reflect the new architecture (FPManager's SDD alone grew by ~1,230 lines).
  • .gitignore now excludes generated coverage/*.html and coverage/*.css; the previously-committed coverage HTML/CSS artifacts (62 files) have been untracked and removed from the branch.

Notes for Reviewers

  • This is a squash of many iterative commits (WIP fixes, "attempting Jetson fix," patches on patches) rather than a clean history — worth reviewing by component/file rather than by commit.
  • Twelve coverage/summary.txt files (small, plain-text) are still tracked per component — the current .gitignore rules only cover .html/.css, not .txt. Worth confirming whether these summaries should stay in version control or get excluded too.
  • The FPManager command-gating logic (remoteJetsonCmdIn/Out, jetsonPowerAuthorizeIn) is safety-critical and probably deserves the closest look, given it's what prevents commands from reaching the hub while the Jetson is off.

DatNguyen0829 and others added 30 commits June 17, 2026 10:29
Merge new changes of main into datdev for future development
@LucaLanzi LucaLanzi self-assigned this Aug 4, 2026
Copilot AI review requested due to automatic review settings August 4, 2026 00:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR merges the lucadev branch into main for SCALES v1.3.0, delivering a broad fault-protection and data-handling upgrade across the i.MX/Jetson stack, including new state machines, new comms/command-authority plumbing, expanded telemetry/power/thermal handling, and extensive unit-test + SDD updates.

Changes:

  • Adds new core components for fault protection, data products, command-authority arbitration, hub framing adaptation, and FATAL relaying (FPManager, DataProducer, GdsCmdAuthMux, HubComAdapter, FatalRelay).
  • Refactors thermal/power managers to use unified ThermalReading plumbing and bundled threshold configuration via TempBounds, with gating and improved failure handling paths.
  • Expands unit tests and documentation (SDDs) across touched components; updates .gitignore to stop tracking generated coverage HTML/CSS artifacts.

Reviewed changes

Copilot reviewed 111 out of 126 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
scales/Types/ThermalReading.fpp Extends thermal state enum for “unavailable” readings.
scales/Types/TempBounds.fpp Adds bundled temperature-threshold struct used by multiple managers.
scales/Types/SystemStateData.fpp Formatting/struct closure cleanup.
scales/Types/PowerTypes.fpp Extends PowerReading with a location string.
scales/Types/FPManagerState.fpp Adds operator-visible FPManager protection-state enum.
scales/Types/CommandAuthority.fpp Adds enum for TCP vs UART GDS command authority.
scales/Types/CMakeLists.txt Registers new type definitions for build/autocode.
scales/scalesSvc/WatchdogManager/WatchdogManager.hpp Grants UT harness access via friend.
scales/scalesSvc/WatchdogManager/test/ut/WatchdogManagerTestMain.cpp Adds requirements metadata tagging to gtest.
scales/scalesSvc/WatchdogManager/test/ut/WatchdogManagerTester.cpp Ensures proper component deinit in tester destructor.
scales/scalesSvc/WatchdogManager/docs/sdd.md Rewrites SDD with requirements, traceability, and measured coverage.
scales/scalesSvc/WatchdogManager/coverage/summary.txt Adds lightweight tracked coverage summary output.
scales/scalesSvc/SpacecraftStateManager/docs/sdd.md Marks component as unimplemented; moves prior content to “planned design”.
scales/scalesSvc/PerifBoardManager/test/ut/PerifBoardManagerTestMain.cpp Expands UT suite and adds requirements metadata tagging.
scales/scalesSvc/PerifBoardManager/test/ut/PerifBoardManagerTester.hpp Adds new test cases for emergency latch + parameterized timing.
scales/scalesSvc/PerifBoardManager/test/ut/PerifBoardManagerTester.cpp Fixes deinit leak + adds new test implementations.
scales/scalesSvc/PerifBoardManager/PerifBoardManager.hpp Adds emergency power-off latch and handler declaration.
scales/scalesSvc/PerifBoardManager/PerifBoardManager.fpp Adds emergencyPowerOff sync input port.
scales/scalesSvc/PerifBoardManager/PerifBoardManager.cpp Implements emergency power-off latch behavior in runtime logic.
scales/scalesSvc/PerifBoardManager/docs/sdd.md Updates SDD for ports/requirements/tests/coverage and new latch behavior.
scales/scalesSvc/PerifBoardManager/coverage/summary.txt Adds lightweight tracked coverage summary output.
scales/scalesSvc/McpManager/test/ut/McpManagerTestMain.cpp Expands UT suite and adds requirements metadata tagging.
scales/scalesSvc/McpManager/test/ut/McpManagerTester.hpp Adds UT helpers and expanded behavioral coverage scenarios.
scales/scalesSvc/McpManager/McpManager.hpp Refactors sensor handling, adds bounds gating helpers, adds test access.
scales/scalesSvc/McpManager/McpManager.fpp Adds unified reading outputs + TempBounds params/telem and new events.
scales/scalesSvc/McpManager/coverage/summary.txt Adds lightweight tracked coverage summary output.
scales/scalesSvc/JetsonThermalManager/test/ut/JetsonThermalManagerTestMain.cpp Adds UT cases and requirements metadata tagging.
scales/scalesSvc/JetsonThermalManager/test/ut/JetsonThermalManagerTester.hpp Adds UT helpers, increases history capacity, adds new scenarios.
scales/scalesSvc/JetsonThermalManager/JetsonThermalManager.hpp Adds test access, bounds gating helpers, and temp-path template seam.
scales/scalesSvc/JetsonThermalManager/JetsonThermalManager.fpp Adds unified reading outputs + TempBounds param/telem and gating event.
scales/scalesSvc/JetsonThermalManager/coverage/summary.txt Adds lightweight tracked coverage summary output.
scales/scalesSvc/JetsonThermalManager/CMakeLists.txt Migrates to register_fprime_module/ut form with dependencies.
scales/scalesSvc/JetsonPowerModeManager/test/ut/JetsonPowerModeManagerTestMain.cpp Adds comprehensive UT main with requirements metadata tagging.
scales/scalesSvc/JetsonPowerModeManager/test/ut/JetsonPowerModeManagerTester.hpp Adds new UT harness for mode/power-state behaviors.
scales/scalesSvc/JetsonPowerModeManager/JetsonPowerModeManager.hpp Adds test seams for power-mode reading and shell runner + reboot guard.
scales/scalesSvc/JetsonPowerModeManager/JetsonPowerModeManager.fpp Adds local mode-change notification port + new events.
scales/scalesSvc/JetsonPowerModeManager/coverage/summary.txt Adds lightweight tracked coverage summary output.
scales/scalesSvc/JetsonPowerModeManager/CMakeLists.txt Enables UT target for the component.
scales/scalesSvc/JetsonManager/test/ut/JetsonManagerTestMain.cpp Adds comprehensive UT main with requirements metadata tagging.
scales/scalesSvc/JetsonManager/test/ut/JetsonManagerTester.hpp Adds UT harness updates and hub-trust guard helpers.
scales/scalesSvc/JetsonManager/JetsonManager.hpp Adds new hub trust + boot confirmation guards and FPManager integration ports.
scales/scalesSvc/JetsonManager/JetsonManager.fpp Adds FPManager ports, hub transport status input, new events, and params.
scales/scalesSvc/JetsonManager/coverage/summary.txt Adds lightweight tracked coverage summary output.
scales/scalesSvc/JetsonManager/CMakeLists.txt Enables UT target for the component.
scales/scalesSvc/InaManager/test/ut/InaManagerTestMain.cpp Adds UT main with multiple scenarios and requirements metadata tagging.
scales/scalesSvc/InaManager/test/ut/InaManagerTester.hpp Adds UT harness to mock I2C reads/failures deterministically.
scales/scalesSvc/InaManager/InaManager.hpp Adds friend access for UT and refactors reading storage fields.
scales/scalesSvc/InaManager/InaManager.fpp Adds DataProducer output port and failure events.
scales/scalesSvc/InaManager/InaManager.cpp Adds per-reading location/timestamp and forwards readings to DataProducer.
scales/scalesSvc/InaManager/docs/sdd.md Updates SDD with requirements, coverage, and traceability to UTs.
scales/scalesSvc/InaManager/coverage/summary.txt Adds lightweight tracked coverage summary output.
scales/scalesSvc/InaManager/CMakeLists.txt Enables UT target for the component.
scales/scalesSvc/ImxThermalManager/test/ut/ImxThermalManagerTestMain.template.cpp Removes placeholder template test main.
scales/scalesSvc/ImxThermalManager/test/ut/ImxThermalManagerTestMain.cpp Adds expanded UT suite and requirements metadata tagging.
scales/scalesSvc/ImxThermalManager/test/ut/ImxThermalManagerTester.template.hpp Removes placeholder template tester header.
scales/scalesSvc/ImxThermalManager/test/ut/ImxThermalManagerTester.template.cpp Removes placeholder template tester implementation.
scales/scalesSvc/ImxThermalManager/test/ut/ImxThermalManagerTester.hpp Adds new UT cases and helpers for parsing/bounds gating.
scales/scalesSvc/ImxThermalManager/ImxThermalManager.hpp Refactors component structure, adds bounds gating and test seam.
scales/scalesSvc/ImxThermalManager/ImxThermalManager.fpp Migrates to TempBounds param/telem and adds failure/gating events and outputs.
scales/scalesSvc/ImxThermalManager/ImxThermalManager.cpp Moves OS reads to OSAL, adds parsing validation and bounds gating.
scales/scalesSvc/ImxThermalManager/docs/sdd.md Updates SDD with requirements, traceability, and measured coverage.
scales/scalesSvc/ImxThermalManager/coverage/summary.txt Adds lightweight tracked coverage summary output.
scales/scalesSvc/ImxThermalManager/CMakeLists.txt Migrates to register_fprime_module/ut form with dependencies.
scales/scalesSvc/HubComAdapter/test/ut/HubComAdapterTestMain.cpp Adds UT main with requirements metadata tagging.
scales/scalesSvc/HubComAdapter/test/ut/HubComAdapterTester.hpp Adds UT harness for port-forwarding and status fan-out.
scales/scalesSvc/HubComAdapter/test/ut/HubComAdapterTester.cpp Implements UT cases for framing/deframing port adaptation.
scales/scalesSvc/HubComAdapter/HubComAdapter.hpp Adds new adapter component header.
scales/scalesSvc/HubComAdapter/HubComAdapter.fpp Defines adapter ports and comStatus fan-out interface.
scales/scalesSvc/HubComAdapter/HubComAdapter.cpp Implements pass-through behavior and comStatus fan-out.
scales/scalesSvc/HubComAdapter/coverage/summary.txt Adds lightweight tracked coverage summary output.
scales/scalesSvc/HubComAdapter/CMakeLists.txt Registers module + UT build.
scales/scalesSvc/GdsCmdAuthMux/test/ut/GdsCmdAuthMuxTestMain.cpp Adds UT main with requirements metadata tagging.
scales/scalesSvc/GdsCmdAuthMux/test/ut/GdsCmdAuthMuxTester.hpp Adds UT harness helpers for authority state testing.
scales/scalesSvc/GdsCmdAuthMux/GdsMuxStateMachine.fpp Adds state machine definition for TCP/UART authority behavior.
scales/scalesSvc/GdsCmdAuthMux/GdsCmdAuthMux.hpp Adds component API, internal tracking, and action hooks.
scales/scalesSvc/GdsCmdAuthMux/GdsCmdAuthMux.fpp Defines mux ports, command, events, and telemetry channels.
scales/scalesSvc/GdsCmdAuthMux/docs/README.md Documents state machine, command flow, and operational rules.
scales/scalesSvc/GdsCmdAuthMux/coverage/summary.txt Adds lightweight tracked coverage summary output.
scales/scalesSvc/GdsCmdAuthMux/CMakeLists.txt Registers library + UT build for mux/state machine.
scales/scalesSvc/FPManager/test/ut/FPManagerTester.hpp Adds extensive FPManager UT harness surface.
scales/scalesSvc/FPManager/FPStateMachine.fpp Adds FPManager protection state machine definition.
scales/scalesSvc/FPManager/FPManager.hpp Replaces placeholder with real FPManager interface and helpers.
scales/scalesSvc/FPManager/coverage/summary.txt Adds lightweight tracked coverage summary output.
scales/scalesSvc/FPManager/CMakeLists.txt Registers FPManager library + UT build with state machine inputs.
scales/scalesSvc/FatalRelay/FatalRelay.hpp Adds passive relay component header.
scales/scalesSvc/FatalRelay/FatalRelay.fpp Defines relay port contract for rerouting fatal events.
scales/scalesSvc/FatalRelay/FatalRelay.cpp Implements fatal re-announce behavior.
scales/scalesSvc/FatalRelay/CMakeLists.txt Registers relay module build.
scales/scalesSvc/DataProducer/test/ut/DataProducerTestMain.cpp Adds UT main for DP behavior with requirements metadata tagging.
scales/scalesSvc/DataProducer/test/ut/DataProducerTester.hpp Adds UT harness with product-get mocking and record builders.
scales/scalesSvc/DataProducer/docs/sdd.md Documents DP pipelines, gating rules, and UT traceability.
scales/scalesSvc/DataProducer/DataProducer.hpp Adds DataProducer component interface and batching constants.
scales/scalesSvc/DataProducer/DataProducer.fpp Defines data product records/containers and enable/disable commands.
scales/scalesSvc/DataProducer/coverage/summary.txt Adds lightweight tracked coverage summary output.
scales/scalesSvc/DataProducer/CMakeLists.txt Registers DataProducer library + UT build.
scales/scalesSvc/CMakeLists.txt Wires new subdirectories/components into the build.
scales/Ports/ThermalStatePorts.fpp Replaces thermal-state-only ports with full ThermalReading port contract.
scales/Ports/ThermalReadingPorts.fpp Adds unified thermal-reading port definitions for managers.
scales/Ports/PowerPorts.fpp Adds INA reading fan-out, emergency power-off, and hub-trust ports.
scales/Ports/CMakeLists.txt Registers new port definitions.
.gitignore Ignores generated coverage HTML/CSS artifacts under component coverage dirs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scales/Ports/ThermalReadingPorts.fpp
Comment thread scales/scalesSvc/InaManager/InaManager.fpp Outdated
Comment thread scales/scalesSvc/InaManager/InaManager.fpp Outdated
Comment thread scales/scalesSvc/PerifBoardManager/docs/sdd.md Outdated
Comment thread scales/scalesSvc/InaManager/InaManager.cpp
Comment thread scales/scalesSvc/DataProducer/DataProducer.fpp Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 111 out of 126 changed files in this pull request and generated 1 comment.

Suppressed comments (9)

scales/scalesSvc/InaManager/test/ut/InaManagerTester.cpp:220

  • Unit test expects FAIL_TO_READ_TEMP_AT, but InaManager defines/logs FAIL_TO_READ_PWR_AT. Update these assertions to match the component event name.
    scales/scalesSvc/InaManager/test/ut/InaManagerTester.cpp:248
  • Unit test expects FAIL_TO_READ_TEMP_AT, but InaManager defines/logs FAIL_TO_READ_PWR_AT. Update this assertion to match the component event name.
    scales/scalesSvc/InaManager/test/ut/InaManagerTester.cpp:286
  • Unit test expects FAIL_TO_READ_TEMP_AT, but InaManager defines/logs FAIL_TO_READ_PWR_AT. Update these assertions to match the component event name.
    scales/Ports/ThermalReadingPorts.fpp:19
  • Spelling: Jetson GPU argument is named jetson_gpuTheramlReading (Theraml). Since this name shows up in generated code and docs, fix it to jetson_gpuThermalReading for clarity.
    port JetsonThermalReadings(
        jetson_cpuThermalReading: ThermalReading @< Thermal Reading at the Jetson CPU
        jetson_gpuTheramlReading: ThermalReading @< Thermal Reading at the Jetson GPU
        jetson_cv0ThermalReading: ThermalReading @< Thermal Reading at the Jetson cv0 zone

scales/scalesSvc/InaManager/InaManager.fpp:43

  • InaManager's FAIL_TO_READ_PWR_AT event message still says "temperature", which is misleading for an INA260 power read failure. Please update the format string (and any related documentation/tests) to reference power/current/voltage instead.
    scales/scalesSvc/InaManager/test/ut/InaManagerTester.hpp:72
  • Comment refers to FAIL_TO_READ_TEMP_AT, but InaManager's event is FAIL_TO_READ_PWR_AT (power sensor). Align wording with the actual event name to avoid confusion and keep docs/tests consistent.
    scales/scalesSvc/InaManager/docs/sdd.md:67
  • SDD references FAIL_TO_READ_TEMP_AT, but InaManager defines/logs FAIL_TO_READ_PWR_AT. Update the doc reference to match the actual event name so the traceability text matches the implementation.
    scales/scalesSvc/DataProducer/DataProducer.hpp:94
  • Spelling: parameter name jetson_gpuTheramlReading is misspelled (Theraml). Rename to jetson_gpuThermalReading for clarity and consistency with other parameters.
        FwIndexType portNum,                                         //!< The port number
        const scalesSvc::ThermalReading& jetson_cpuThermalReading,   //!< Thermal Reading at the Jetson CPU
        const scalesSvc::ThermalReading& jetson_gpuTheramlReading,   //!< Thermal Reading at the Jetson GPU
        const scalesSvc::ThermalReading& jetson_cv0ThermalReading,   //!< Thermal Reading at the Jetson cv0 zone
        const scalesSvc::ThermalReading& jetson_cv1ThermalReading,   //!< Thermal Reading at the Jetson cv1 zone

scales/scalesSvc/McpManager/McpManager.hpp:57

  • NUM_SENSORS is introduced, but deviceAddrs still uses a hard-coded size of 3. Use NUM_SENSORS here as well so the array sizes stay consistent if the constant ever changes.

Comment thread scales/scalesSvc/InaManager/test/ut/InaManagerTester.cpp Outdated
@LucaLanzi
LucaLanzi requested a lite review from Copilot August 4, 2026 16:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@LucaLanzi
LucaLanzi requested a lite review from Copilot August 4, 2026 20:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@kevin-f-ortega kevin-f-ortega left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm making my way through this PR. Submitting my current comments. Will continue reviewing the rest of the code

"${CMAKE_CURRENT_LIST_DIR}/PowerPorts.fpp"
"${CMAKE_CURRENT_LIST_DIR}/SystemStateData.fpp"
"${CMAKE_CURRENT_LIST_DIR}/ThermalStatePorts.fpp"
"${CMAKE_CURRENT_LIST_DIR}/ThermalReadingPorts.fpp"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Keep these lists alphabetized

Comment thread .gitignore
@@ -1 +1,2 @@
*.html No newline at end of file
**/coverage/*.html

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I recommend not adding these to the ignore list. You want to include all the generated files in the coverage directory

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.

4 participants