Skip to content

To_proc_time cmd added#455

Open
collinc04 wants to merge 17 commits into
mainfrom
time_toggle
Open

To_proc_time cmd added#455
collinc04 wants to merge 17 commits into
mainfrom
time_toggle

Conversation

@collinc04

@collinc04 collinc04 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

To_Proc_Time command added

Description

Added a command to switch between timebases

Interactions

Does not interfere with command loss timer as that has been moved to the 10hz rate group.
Cancels all queued sequences, just like time_set does

Related Issues/Tickets

How Has This Been Tested?

  • Unit tests
  • Integration tests
  • Z Tests
  • Manual testing (describe steps)

Screenshots / Recordings (if applicable)

Checklist

  • Written detailed sdd with requirements, channels, ports, commands, telemetry defined and correctly formatted and spelled
  • Have written relevant integration tests and have documented them in the sdd
  • Have done a code review with
  • Have tested this PR on every supported board with correct board definitions

Further Notes / Considerations

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

RtcManager tracks proc-time mode, falls back to uptime-based time when RTC access or conversion fails, supports TO_PROC_TIME, and restores RTC mode after manual setting. An integration test covers toggling, and the fprime-zephyr submodule reference changes.

Changes

RTC proc-time management

Layer / File(s) Summary
Proc-time command and state contract
PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.fpp, PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.hpp, PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.cpp
The component declares TO_PROC_TIME(), proc-time events, and an atomic mode flag initialized to RTC mode.
Time-source switching, fallback, and validation
PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.cpp, PROVESFlightControllerReference/test/int/rtc_test.py
Time retrieval uses uptime-based proc time when selected or when RTC access/conversion fails; manual time setting restores RTC mode, and integration coverage exercises the toggle.

Zephyr submodule reference

Layer / File(s) Summary
Zephyr submodule pointer update
lib/fprime-zephyr
The recorded fprime-zephyr submodule commit is updated.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Test
  participant RtcManager
  participant RTC
  participant Uptime
  Test->>RtcManager: set RTC time
  RtcManager->>RTC: read RTC time
  RTC-->>RtcManager: return RTC value
  Test->>RtcManager: issue TO_PROC_TIME
  RtcManager->>Uptime: read uptime
  Uptime-->>RtcManager: return proc time
  RtcManager-->>Test: emit timebase event
Loading

Suggested reviewers: mikefly123

Poem

A rabbit hops through clocks tonight,
RTC fades; uptime shines bright.
One command makes proc-time grow,
Manual setting brings RTC aglow.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely states the main change: adding the To_Proc_Time command.
Description check ✅ Passed The description covers the required template sections and is mostly complete, with only minor gaps like no issue links or detailed test steps.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nateinaction nateinaction 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 like this initial take, here's a suggested design:

Use F Prime's built-in enum TimeBase. Store the selected timebase as an F Prime parameter so it can be stored over multiple boots. No F Prime commands necessary, the parameter will be all you need to set and store the chosen timebase. The parameter default should be TB_SC_TIME. Check the timebase once near the beginning of timeGetPort_handler() after the variable sets but before the RTC device ready check. If the timebase is TB_PROC_TIME, return the proc time.

Also to consider... Since this component supports fewer time bases than the upstream F Prime TimeBase enum we may want to have our own TimeBase enum declared in the FPP that only copies the upstream enum but removes the unsupported timebases like TB_WORKSTATION_TIME.

What do you think?

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.cpp`:
- Around line 52-54: Update timeGetPort_handler to check m_ProcTimeSet before
any RTC readiness or read logic; when set, return the current proc-time/uptime
value immediately and preserve the flag so RTC handling cannot overwrite it.
- Around line 171-179: In the proc-time initialization block, remove the unused
proc_time object and the useconds_since_boot calculation. Keep the uptime
conversion, log_ACTIVITY_HI_procTimeSet call, and m_ProcTimeSet update
unchanged.

In `@PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.fpp`:
- Around line 61-64: Rename the `procTimeSet` event to `ProcTimeSet` in the
RtcManager component, and update its generated logging call in `RtcManager.cpp`
from `log_ACTIVITY_HI_procTimeSet` to `log_ACTIVITY_HI_ProcTimeSet` so all
references remain consistent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 686300f0-9451-47e5-9fc5-094b892c2de2

📥 Commits

Reviewing files that changed from the base of the PR and between b2437a9 and 989a4f5.

📒 Files selected for processing (3)
  • PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.cpp
  • PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.fpp
  • PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.hpp

Comment thread PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.cpp Outdated
Comment on lines +61 to +64
event procTimeSet(
seconds: U32 @< Uptime in seconds
) severity activity high id 17 format "Proc time set, current uptime: {}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use PascalCase for event names to match existing conventions.

The existing events in this component (e.g., TimeSet, DeviceNotReady, AlarmSet) use PascalCase. Consider renaming procTimeSet to ProcTimeSet for consistency. Note that if you change this, you will also need to update the auto-generated logging call in RtcManager.cpp to log_ACTIVITY_HI_ProcTimeSet.

♻️ Proposed refactor
-        event procTimeSet(
+        event ProcTimeSet(
             seconds: U32 @< Uptime in seconds
         ) severity activity high id 17 format "Proc time set, current uptime: {}"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
event procTimeSet(
seconds: U32 @< Uptime in seconds
) severity activity high id 17 format "Proc time set, current uptime: {}"
event ProcTimeSet(
seconds: U32 @< Uptime in seconds
) severity activity high id 17 format "Proc time set, current uptime: {}"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.fpp`
around lines 61 - 64, Rename the `procTimeSet` event to `ProcTimeSet` in the
RtcManager component, and update its generated logging call in `RtcManager.cpp`
from `log_ACTIVITY_HI_procTimeSet` to `log_ACTIVITY_HI_ProcTimeSet` so all
references remain consistent.

@collinc04 collinc04 changed the title To_proc_time cmd added To_proc_time cmd added, LoRa mode beaconed Jul 20, 2026
@collinc04

Copy link
Copy Markdown
Contributor Author

I like this initial take, here's a suggested design:

Use F Prime's built-in enum TimeBase. Store the selected timebase as an F Prime parameter so it can be stored over multiple boots. No F Prime commands necessary, the parameter will be all you need to set and store the chosen timebase. The parameter default should be TB_SC_TIME. Check the timebase once near the beginning of timeGetPort_handler() after the variable sets but before the RTC device ready check. If the timebase is TB_PROC_TIME, return the proc time.

Also to consider... Since this component supports fewer time bases than the upstream F Prime TimeBase enum we may want to have our own TimeBase enum declared in the FPP that only copies the upstream enum but removes the unsupported timebases like TB_WORKSTATION_TIME.

What do you think?

I like the idea of using a timebase to survive multiple boots, I think this is a good idea

@ineskhou ineskhou moved this to In progress in V1.X.X Jul 20, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.cpp (3)

21-21: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use the repository member-naming convention.

Rename m_ProcTimeSet to an underscore-separated form such as m_proc_time_set in RtcManager.hpp and RtcManager.cpp. Based on learnings, F Prime component members under PROVESFlightControllerReference/Components use the m_ plus underscore-separated convention.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.cpp` at
line 21, Rename the RtcManager member m_ProcTimeSet to m_proc_time_set
throughout RtcManager.hpp and RtcManager.cpp, including its declaration,
initializer, and all references, while preserving its existing behavior.

Source: Learnings


52-62: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Do not make RTC fallback permanently sticky.

After any RTC failure sets m_ProcTimeSet, Line 53 bypasses all future RTC probes, so the successful-read path at Line 99 cannot restore RTC mode. Keep explicit proc-time selection separate from transient fallback, or retry RTC before honoring the fallback state.

Also applies to: 75-78, 91-99

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.cpp`
around lines 52 - 62, Update the RTC time-selection logic in RtcManager so a
transient RTC readiness or read failure does not permanently bypass future RTC
probes through m_ProcTimeSet. Separate explicit proc-time configuration from
fallback state, or retry the RTC before honoring fallback; ensure the successful
RTC path can clear or supersede the fallback state and restore RTC mode.

176-185: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Persist the selected timebase.

m_ProcTimeSet is initialized to false and TO_PROC_TIME only sets that volatile atomic flag, so a proc-time selection is lost on reset. Store the selected Fw::Time::TimeBase in an F Prime parameter with TB_SC_TIME as the default, and use the runtime flag only for transient fallback if needed.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.cpp`
around lines 176 - 185, Persist the selected timebase by adding an F Prime
parameter initialized to Fw::Time::TB_SC_TIME, then update
TO_PROC_TIME_cmdHandler to store Fw::Time::TB_PROC_TIME through that parameter
instead of relying solely on m_ProcTimeSet. Use m_ProcTimeSet only for transient
fallback behavior where required, and ensure timebase initialization restores
the persisted parameter value after reset.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.cpp`:
- Line 21: Rename the RtcManager member m_ProcTimeSet to m_proc_time_set
throughout RtcManager.hpp and RtcManager.cpp, including its declaration,
initializer, and all references, while preserving its existing behavior.
- Around line 52-62: Update the RTC time-selection logic in RtcManager so a
transient RTC readiness or read failure does not permanently bypass future RTC
probes through m_ProcTimeSet. Separate explicit proc-time configuration from
fallback state, or retry the RTC before honoring fallback; ensure the successful
RTC path can clear or supersede the fallback state and restore RTC mode.
- Around line 176-185: Persist the selected timebase by adding an F Prime
parameter initialized to Fw::Time::TB_SC_TIME, then update
TO_PROC_TIME_cmdHandler to store Fw::Time::TB_PROC_TIME through that parameter
instead of relying solely on m_ProcTimeSet. Use m_ProcTimeSet only for transient
fallback behavior where required, and ensure timebase initialization restores
the persisted parameter value after reset.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 18522e3c-8807-49ed-8e68-dde1157ae383

📥 Commits

Reviewing files that changed from the base of the PR and between 989a4f5 and e5b955e.

📒 Files selected for processing (3)
  • PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.cpp
  • PROVESFlightControllerReference/ReferenceDeployment/Top/ReferenceDeploymentPackets.fppi
  • lib/fprime-zephyr

@collinc04 collinc04 changed the title To_proc_time cmd added, LoRa mode beaconed To_proc_time cmd added Jul 25, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (4)
PROVESFlightControllerReference/ReferenceDeployment/Top/ReferenceDeploymentPackets.fppi (1)

17-21: 🗄️ Data Integrity & Integration | 🔴 Critical | 🏗️ Heavy lift

Align the Beacon fields with the LoRa component contract.

The supplied lib/fprime-zephyr/fprime-zephyr/Drv/LoRa/LoRa.fpp contract exposes DATA_RATE, CODING_RATE, BANDWIDTH_TX, BANDWIDTH_RX, and TRANSMIT, but does not establish the referenced Module* channels. Packet generation/build will fail unless the pinned submodule provides those generated names. Also, expose TX and RX bandwidth separately rather than collapsing them into ModuleBandwidth.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@PROVESFlightControllerReference/ReferenceDeployment/Top/ReferenceDeploymentPackets.fppi`
around lines 17 - 21, Update the LoRa config fields in
ReferenceDeploymentPackets to use the LoRa contract’s established DATA_RATE,
CODING_RATE, BANDWIDTH_TX, BANDWIDTH_RX, and TRANSMIT channels; replace
ModuleBandwidth with separate TX and RX bandwidth fields and remove the
unsupported Module* references.
PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.cpp (3)

21-21: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use underscore-separated member naming.

Rename m_ProcTimeSet to m_proc_time_set consistently in the declaration and implementation. Based on learnings, F Prime component members under PROVESFlightControllerReference/Components use the m_ plus underscore-separated naming convention.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.cpp` at
line 21, Rename the member m_ProcTimeSet to m_proc_time_set consistently across
its declaration, initializer, and all implementation references within
RtcManager.

Source: Learnings


52-62: 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

Allow RTC recovery after an automatic fallback.

Once any RTC failure sets m_ProcTimeSet = true, the next invocation returns at Lines 53-56 before attempting another RTC read. Consequently, the successful-conversion path at Lines 99-103 is unreachable, so a transient RTC failure permanently selects proc time until TIME_SET.

Keep explicit proc-time selection separate from transient fallback state, or retry RTC reads while in fallback mode.

Also applies to: 75-75, 91-95, 99-103

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.cpp`
around lines 52 - 62, The RtcManager time-update flow permanently treats
transient RTC failure as explicit proc-time mode via m_ProcTimeSet. Separate the
automatic fallback state from explicit proc-time selection, or allow RTC reads
while fallback is active, and ensure the successful RTC conversion path can
clear the fallback and restore RTC-based time without requiring TIME_SET.

20-21: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Persist the selected timebase across reboots.

m_ProcTimeSet is initialized to false, so TO_PROC_TIME reverts to RTC mode after every reboot. Store the selection in F Prime’s persistent parameter contract, initialize the default from that parameter (TB_SC_TIME), and update it from both TO_PROC_TIME and TIME_SET.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.cpp`
around lines 20 - 21, Update RtcManager’s m_ProcTimeSet handling to use the F
Prime persistent parameter contract, defaulting from the TB_SC_TIME parameter
instead of false. Persist updates whenever TO_PROC_TIME or TIME_SET changes the
selected timebase, while preserving the existing RTC and processor-time
behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.cpp`:
- Line 46: Update the timeGetPort_handler definition in RtcManager.cpp to use
FwIndexType for portNum, matching the override declaration in RtcManager.hpp and
the generated virtual method signature.

---

Outside diff comments:
In `@PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.cpp`:
- Line 21: Rename the member m_ProcTimeSet to m_proc_time_set consistently
across its declaration, initializer, and all implementation references within
RtcManager.
- Around line 52-62: The RtcManager time-update flow permanently treats
transient RTC failure as explicit proc-time mode via m_ProcTimeSet. Separate the
automatic fallback state from explicit proc-time selection, or allow RTC reads
while fallback is active, and ensure the successful RTC conversion path can
clear the fallback and restore RTC-based time without requiring TIME_SET.
- Around line 20-21: Update RtcManager’s m_ProcTimeSet handling to use the F
Prime persistent parameter contract, defaulting from the TB_SC_TIME parameter
instead of false. Persist updates whenever TO_PROC_TIME or TIME_SET changes the
selected timebase, while preserving the existing RTC and processor-time
behavior.

In
`@PROVESFlightControllerReference/ReferenceDeployment/Top/ReferenceDeploymentPackets.fppi`:
- Around line 17-21: Update the LoRa config fields in ReferenceDeploymentPackets
to use the LoRa contract’s established DATA_RATE, CODING_RATE, BANDWIDTH_TX,
BANDWIDTH_RX, and TRANSMIT channels; replace ModuleBandwidth with separate TX
and RX bandwidth fields and remove the unsupported Module* references.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 42a3d8a5-35ad-4e05-b41c-e3804df75d57

📥 Commits

Reviewing files that changed from the base of the PR and between e5b955e and e4a68d7.

📒 Files selected for processing (2)
  • PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.cpp
  • PROVESFlightControllerReference/ReferenceDeployment/Top/ReferenceDeploymentPackets.fppi

Comment thread PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.cpp Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (4)
PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.cpp (3)

21-21: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use lower_snake_case for the new member state.

Rename m_ProcTimeSet and its declaration/usages to m_proc_time_set to match the established m_ plus underscore-separated member naming convention in this component path.

Based on learnings, PROVES Flight Controller components use underscore-style member names such as m_transmit_enable_ticks.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.cpp` at
line 21, Rename the member state m_ProcTimeSet to m_proc_time_set throughout its
declaration, initializer, and all usages in the RtcManager implementation,
preserving its existing behavior and following the component’s lower_snake_case
naming convention.

Source: Learnings


52-66: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Keep RTC fallback recoverable.

The failure branches set m_ProcTimeSet = true, but the early return at Lines 53-57 then prevents every future RTC readiness/read/conversion attempt. Consequently, the reset at Line 99 cannot restore RTC mode unless TIME_SET is issued. Keep explicit TO_PROC_TIME selection separate from transient fallback, or avoid setting this persistent flag in the failure branches.

🐛 Proposed direction
 if (!device_is_ready(this->m_dev)) {
     this->log_CONSOLE_RtcNotReady();
-    this->m_ProcTimeSet = true;
     time.set(TimeBase::TB_PROC_TIME, 0, seconds_since_boot, useconds_since_boot);
     return;
 }

 if (rc != 0) {
     this->log_CONSOLE_RtcGetTimeFailed(rc);
-    this->m_ProcTimeSet = true;
     time.set(TimeBase::TB_PROC_TIME, 0, seconds_since_boot, useconds_since_boot);
     return;
 }

 if (errno == ERANGE) {
     this->log_CONSOLE_RtcInvalidTime();
-    this->m_ProcTimeSet = true;
     time.set(TimeBase::TB_PROC_TIME, 0, seconds_since_boot, useconds_since_boot);
     return;
 }

Also applies to: 70-95

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.cpp`
around lines 52 - 66, Keep m_ProcTimeSet reserved for explicit TO_PROC_TIME
selection and stop setting it in RTC failure branches, including the readiness,
read, and conversion handling around the affected code. Preserve the uptime
fallback for each failure, but allow subsequent calls to retry RTC
readiness/read/conversion and let the existing reset at the TIME_SET path
restore RTC mode.

52-66: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Report automatic proc-time fallback transitions.

The new TimeBase and ProcTimeSet events are emitted only by TO_PROC_TIME_cmdHandler. Device-not-ready, RTC-read failure, and invalid-time fallback paths change the returned timebase without emitting either event, so downstream telemetry cannot distinguish an operator-selected switch from an automatic RTC failure.

Emit the transition event once when fallback changes the active source.

Also applies to: 70-95

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.cpp`
around lines 52 - 66, Update the automatic fallback paths in RtcManager,
including the device-not-ready handling and the RTC-read/invalid-time paths
around the affected code, to emit the same TimeBase and ProcTimeSet transition
events used by TO_PROC_TIME_cmdHandler when the active source changes to
processor time. Emit the transition only on the state change, preserving the
existing time assignment and avoiding duplicate events on subsequent calls
already in processor-time mode.
PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.fpp (1)

34-36: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Persist the selected timebase across boots.

TO_PROC_TIME only sets the in-memory m_ProcTimeSet flag, which is false after construction and stays false on subsequent boots. Add a persisted supported-timebase parameter with default TB_SC_TIME, or demonstrate that the selection is stored/restored elsewhere before relying on proc-time operation.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.fpp`
around lines 34 - 36, The TO_PROC_TIME handling in RtcManager must persist the
selected timebase across boots instead of relying only on the in-memory
m_ProcTimeSet flag. Add a persisted supported-timebase parameter defaulting to
TB_SC_TIME, update it when TO_PROC_TIME selects processor time, and restore
m_ProcTimeSet from that parameter during initialization; alternatively, reuse an
existing storage/restore mechanism if one already persists this selection.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.cpp`:
- Line 21: Rename the member state m_ProcTimeSet to m_proc_time_set throughout
its declaration, initializer, and all usages in the RtcManager implementation,
preserving its existing behavior and following the component’s lower_snake_case
naming convention.
- Around line 52-66: Keep m_ProcTimeSet reserved for explicit TO_PROC_TIME
selection and stop setting it in RTC failure branches, including the readiness,
read, and conversion handling around the affected code. Preserve the uptime
fallback for each failure, but allow subsequent calls to retry RTC
readiness/read/conversion and let the existing reset at the TIME_SET path
restore RTC mode.
- Around line 52-66: Update the automatic fallback paths in RtcManager,
including the device-not-ready handling and the RTC-read/invalid-time paths
around the affected code, to emit the same TimeBase and ProcTimeSet transition
events used by TO_PROC_TIME_cmdHandler when the active source changes to
processor time. Emit the transition only on the state change, preserving the
existing time assignment and avoiding duplicate events on subsequent calls
already in processor-time mode.

In `@PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.fpp`:
- Around line 34-36: The TO_PROC_TIME handling in RtcManager must persist the
selected timebase across boots instead of relying only on the in-memory
m_ProcTimeSet flag. Add a persisted supported-timebase parameter defaulting to
TB_SC_TIME, update it when TO_PROC_TIME selects processor time, and restore
m_ProcTimeSet from that parameter during initialization; alternatively, reuse an
existing storage/restore mechanism if one already persists this selection.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: cbd345c4-b26f-4ef2-8447-b1e962dbb708

📥 Commits

Reviewing files that changed from the base of the PR and between e4a68d7 and f7f6fa6.

📒 Files selected for processing (2)
  • PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.cpp
  • PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.fpp

@collinc04
collinc04 requested a review from Mikefly123 July 25, 2026 06:25
@collinc04

Copy link
Copy Markdown
Contributor Author

I'd like to note that I have separated this from the beaconing packet change, work will continue on that one in the fprime-zephyr repo

Comment thread lib/fprime-zephyr
Comment thread lib/fprime-zephyr

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There's a piece on the ticket:

Audit time usage Document where time matters and what TIME_SET changes, including:

Command sequences (cmdSeq, payloadSeq, safeModeSeq) — canceled on time set
AuthenticationRouter comm-loss timer (switched by another PR)

I think Detumble also falls into that category. Can you audit and explain what happens to all the components that depend on time when this time set hits?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Following up on this one, I think we need to cancel running sequences when we set the time, otherwise unexpected things may happen.

I also have a board without an RTC battery so am unable to test these toggle changes. Do you mind uploading verification evidence like I did on the hardcoded startup component?

// Check device readiness
if (!device_is_ready(this->m_dev)) {
this->log_CONSOLE_RtcNotReady();
this->m_ProcTimeSet = true; // proc time flag

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My vision for this component was more something that didn't change the behavior of the RTC bring up, but something the operator could physcially comamnd. That way we don't have to audit the behavoir of every failing case and how this flag would change it/ less changes are always better.

That being said totally open to it, if tested for these cases. It could fix issues if we've been having timebase issues with flashing back and forth between timebases, and I think if our sat completly runs on monotonic time, that would be fine and safer than a flaky RTC.

I think the other thing is, the RTC does fail on the first few seconds of startup, you can observe monotonic time for a bit before the RTC kicks on. Do these cases that do not allow the RTC to retry account for that or does every run run on monotinic time?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

My general thought was that if we implement a command toggle for it, then it should stay that way if it fails unless commanded otherwise so that we don't switch back to a potentially bad RTC.

I did remove the flag set on the device not ready case in the bring up, because otherwise it would boot up in monotonic time unless otherwise set

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

But what if we have flaky events? one wrong I2C value could set us to monotonic. I also think the behavoir of the RTC is that we start on monotonic on boot, so if the RTC is not working we are on monotonic time. At least that's what I've observe on my board in the past.

If you want to keep latched implementation of the component, I think we at least want events in these places so that we know why the time is set to monotonic. I'd also want that more visible on the sdd

)

@ TO_PROC_TIME command to use proc time instead of RTC time
sync command TO_PROC_TIME()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could be good to have a testcase for this commadn to show we can toggle it on and off no problem. We could push back getting the test in after the code freeze, but we should make a ticket if thats the case

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I made one, forgot to push oops 😓

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Could use some more verification though? It only checks for event emission, what do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This also uses await, so It probably needs to be changed to be more in line with #407

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@PROVESFlightControllerReference/test/int/rtc_test.py`:
- Around line 441-455: Update test_proc_toggle to capture both TimeBase results
returned by await_event: assert the initial event reports the RTC source, then
send TO_PROC_TIME and assert the subsequent event reports the PROC source.
Preserve the existing timing setup and timeouts.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b5323cc7-7181-4c7c-9439-f4c2a5f09c46

📥 Commits

Reviewing files that changed from the base of the PR and between f7f6fa6 and 55aedcf.

📒 Files selected for processing (1)
  • PROVESFlightControllerReference/test/int/rtc_test.py

Comment thread PROVESFlightControllerReference/test/int/rtc_test.py

@ineskhou ineskhou left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry hope these comments aren't too much of a mess bascially:

  1. Up to you as designer to choose to latch to monotonic for errors or not (you can also ask for a trade in the discord if you want), but if you do I'd want more clear events and documentation for it in the sdd.
  2. Looking for manual testing (see startup manager)
  3. Want checking that other parts of the system that use the RTC will not be negatavly affected by these timebase changes.
  4. Few nits (spelling, extra variable, ect)

But you've put a lot of work in this and it looks great! Thanks for staying in there through all these reviews

fprime_test_api.send_command(f"{rtcManager}.TO_PROC_TIME")

# Assert that we receive a TimeBase event within 10 seconds
fprime_test_api.await_event(f"{rtcManager}.TimeBase", timeout=10)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could be good to have this test assert what the timebase is that is being set (PROC vs RTC) and/or actually check the physcial timebase. Checking the event doesn't let us know if the system of the sat is on PROC time. At minimum before merge, woudl want manual evidence on this happening on a board

That being said, test updates will not block merge.

def test_proc_toggle(fprime_test_api: IntegrationTestAPI, start_gds):
"""Test for events emitted by proc time toggle"""

# Set time to Curiosity landing on Mars (7 minutes of terror! https://youtu.be/Ki_Af_o9Q9s)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

love it!!!

seconds: U32 @< Uptime in seconds
) severity activity high id 17 format "Proc time set, current uptime: {}"

@ Timebase even fires when the timebase changes and indicates the current timebase

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Typo? Even --> event

// Check device readiness
if (!device_is_ready(this->m_dev)) {
this->log_CONSOLE_RtcNotReady();
this->m_ProcTimeSet = true; // proc time flag

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

But what if we have flaky events? one wrong I2C value could set us to monotonic. I also think the behavoir of the RTC is that we start on monotonic on boot, so if the RTC is not working we are on monotonic time. At least that's what I've observe on my board in the past.

If you want to keep latched implementation of the component, I think we at least want events in these places so that we know why the time is set to monotonic. I'd also want that more visible on the sdd

Comment thread lib/fprime-zephyr

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Following up on this one, I think we need to cancel running sequences when we set the time, otherwise unexpected things may happen.

I also have a board without an RTC battery so am unable to test these toggle changes. Do you mind uploading verification evidence like I did on the hardcoded startup component?

Comment thread PROVESFlightControllerReference/Components/Drv/RtcManager/RtcManager.cpp Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

4 participants