Skip to content

TlmArchive - #464

Draft
hrfarmer wants to merge 44 commits into
mainfrom
tlm-archive
Draft

TlmArchive#464
hrfarmer wants to merge 44 commits into
mainfrom
tlm-archive

Conversation

@hrfarmer

@hrfarmer hrfarmer commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

This component will store the telemetry collected before the first antenna deploy, as this information can be very useful for early troubleshooting.

This component was scoped down a lot from what I originally intended, it was functional but writes/other fs actions kept occasionally causing a software hang, which is very undesirable. I'll keep working on an expansion to this component that can constantly log telemetry so any recent missing telemetry could be downlinked, and if the software hangs can be fixed, could go on the second partition.

  • Update SDD

@coderabbitai

coderabbitai Bot commented Jul 21, 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

A new passive TlmArchive component buffers telemetry, checks antenna deployment state, and appends pre-deployment packets to //tlm/pre_deployment.tlm. It is built, instantiated, scheduled at 1Hz, and wired to telemetry and deployment-state ports.

Changes

Telemetry archive

Layer / File(s) Summary
Deployment state query contract
PROVESFlightControllerReference/Components/AntennaDeployer/*
Adds the boolean deployment-state port and handler backed by readDeploymentState().
Telemetry archive component
PROVESFlightControllerReference/Components/TlmArchive/*, PROVESFlightControllerReference/Components/CMakeLists.txt
Defines, builds, and documents TlmArchive; it retains one pending packet, skips writes after deployment, and appends eligible telemetry to the pre-deployment archive.
Reference deployment wiring
PROVESFlightControllerReference/ReferenceDeployment/Top/*
Adds the tlmArchive instance, telemetry connection, 1Hz schedule, and deployment-state connection.

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

Sequence Diagram(s)

sequenceDiagram
  participant TelemetrySplitter
  participant TlmArchive
  participant AntennaDeployer
  participant ArchiveFile
  TelemetrySplitter->>TlmArchive: deliver telemetry packet
  TlmArchive->>AntennaDeployer: query deployment state
  AntennaDeployer-->>TlmArchive: return deployment boolean
  TlmArchive->>ArchiveFile: append packet when not deployed
Loading

Suggested reviewers: ineskhou

Poem

A rabbit hops through packets bright,
And tucks them safely out of sight.
Before antennas bloom in air,
Pre-deployment bytes rest there.
“Thump thump!” says Bun—the archive’s right!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is largely incomplete and missing most required template sections, including testing, issues, checklist, and notes. Fill out the template sections with a clear description, related issues, tests run, checklist items, screenshots if applicable, and further notes.
Title check ❓ Inconclusive The title is related to the change, but it is too generic to clearly convey the primary update. Use a descriptive title like "Add pre-deployment telemetry archiving component".
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

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.

@hrfarmer
hrfarmer marked this pull request as ready for review July 25, 2026 03:30

@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: 4

🤖 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/AntennaDeployer/AntennaDeployer.cpp`:
- Around line 89-92: Update finishDeployment() so the deployment state is
written true only for DEPLOY_RESULT_SUCCESS; preserve false for
DEPLOY_RESULT_FAILED and exhausted retries. Ensure deploymentStateGet_handler()
continues reporting readDeploymentState() so failed deployments remain eligible
for archiving and future DEPLOY commands.

In `@PROVESFlightControllerReference/Components/TlmArchive/TlmArchive.cpp`:
- Around line 29-43: Update the TlmArchive write path around comIn and
deploymentStateGet_handler so the deployment-state check and
PRE_DEPLOYMENT_TLM_PATH append execute under one atomic ownership. Serialize
access with the existing component synchronization mechanism, or pass the
deployment state together with telemetry through a single queued owner, ensuring
no archive write can occur after deployment begins.
- Around line 25-44: Update TlmArchive::comIn_handler so it no longer performs
createDirectory, file open, or file write operations synchronously; instead,
enqueue or buffer each telemetry packet for a bounded worker/component queue.
Implement the worker-side filesystem initialization and append writes,
preserving deployment-state filtering and PRE_DEPLOYMENT_TLM_PATH while ensuring
queue capacity and overflow behavior are bounded.
- Around line 33-44: Update the archive write path in the surrounding TlmArchive
method to log failures from createDirectory() and file.open() before returning.
Pass size by reference to file.write(), capture its Os::File::Status, compare
the reported byte count with the requested size, and emit a log for write
failures or short writes before closing the file.
🪄 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: bf4a10ba-600a-4164-b953-3b26604cab1a

📥 Commits

Reviewing files that changed from the base of the PR and between 24968fa and a80e238.

📒 Files selected for processing (12)
  • PROVESFlightControllerReference/Components/AntennaDeployer/AntennaDeployer.cpp
  • PROVESFlightControllerReference/Components/AntennaDeployer/AntennaDeployer.fpp
  • PROVESFlightControllerReference/Components/AntennaDeployer/AntennaDeployer.hpp
  • PROVESFlightControllerReference/Components/CMakeLists.txt
  • PROVESFlightControllerReference/Components/TlmArchive/CMakeLists.txt
  • PROVESFlightControllerReference/Components/TlmArchive/TlmArchive.cpp
  • PROVESFlightControllerReference/Components/TlmArchive/TlmArchive.fpp
  • PROVESFlightControllerReference/Components/TlmArchive/TlmArchive.hpp
  • PROVESFlightControllerReference/Components/TlmArchive/docs/sdd.md
  • PROVESFlightControllerReference/ReferenceDeployment/Top/instances.fpp
  • PROVESFlightControllerReference/ReferenceDeployment/Top/topology.fpp
  • lib/fprime-zephyr

Comment on lines +89 to +92
bool AntennaDeployer ::deploymentStateGet_handler(FwIndexType portNum) {
(void)portNum;
return this->readDeploymentState();
}

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.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Keep failed deployments marked as not deployed.

finishDeployment() writes true for both DEPLOY_RESULT_SUCCESS and DEPLOY_RESULT_FAILED (Lines 226-231). After retries are exhausted, this handler reports deployed, so TlmArchive stops archiving and future DEPLOY commands are rejected.

Proposed fix
-    if (result == Components::DeployResult::DEPLOY_RESULT_SUCCESS ||
-        result == Components::DeployResult::DEPLOY_RESULT_FAILED) {
+    if (result == Components::DeployResult::DEPLOY_RESULT_SUCCESS) {
🤖 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/AntennaDeployer/AntennaDeployer.cpp`
around lines 89 - 92, Update finishDeployment() so the deployment state is
written true only for DEPLOY_RESULT_SUCCESS; preserve false for
DEPLOY_RESULT_FAILED and exhausted retries. Ensure deploymentStateGet_handler()
continues reporting readDeploymentState() so failed deployments remain eligible
for archiving and future DEPLOY commands.

Comment thread PROVESFlightControllerReference/Components/TlmArchive/TlmArchive.cpp Outdated
Comment thread PROVESFlightControllerReference/Components/TlmArchive/TlmArchive.cpp Outdated

@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.

Great stuff! Great use of topology and ports and great architechure design. Had some comments about robustness with the file systsem since we dont want to hammer the file system too hard when we are depending on teh startup sequence

Main thing I want to see before merge is some manual testing of this, if you could provide screenshots. Especially this working as the startup sequence runs and if you can recerate a dead filesystem (but no worries if not)

Comment thread lib/fprime-zephyr
Comment thread PROVESFlightControllerReference/Components/TlmArchive/docs/sdd.md Outdated
Comment thread PROVESFlightControllerReference/Components/TlmArchive/TlmArchive.cpp Outdated
Comment thread PROVESFlightControllerReference/Components/TlmArchive/TlmArchive.cpp Outdated

@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.

Great stuff! Great use of topology and ports and great architechure design. Had some comments about robustness with the file systsem since we dont want to hammer the file system too hard when we are depending on teh startup sequence

Main thing I want to see before merge is some manual testing of this, if you could provide screenshots. Especially this working as the startup sequence runs and if you can recerate a dead filesystem (but no worries if not)

@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: 2

♻️ Duplicate comments (1)
PROVESFlightControllerReference/Components/TlmArchive/TlmArchive.cpp (1)

59-78: ⚠️ Potential issue | 🟠 Major

Bound filesystem retries and archive growth.

Each run with a pending packet recreates the directory, retries failures on the next tick, and appends without a maximum size. If deployment never completes or the filesystem is unhealthy, this can hammer the filesystem and exhaust //tlm; add bounded failure backoff/disable behavior and a maximum byte or record limit.

This repeats the unresolved archive-lifecycle concerns from the earlier review.

🤖 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/TlmArchive/TlmArchive.cpp` around
lines 59 - 78, Update the TlmArchive packet-write lifecycle around
createDirectory, open, and write to prevent unbounded filesystem retries and
archive growth: track consecutive failures and apply bounded backoff or disable
archiving after the configured failure threshold, and enforce a maximum archive
byte or record limit before appending. Preserve normal logging and reset retry
state after successful writes, using existing TlmArchive state/configuration
symbols where available.
🤖 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/TlmArchive/TlmArchive.fpp`:
- Around line 7-8: Move the blocking archive work currently performed by
TlmArchive.run_handler() behind an active or queued worker, preserving mailbox
draining and archive I/O without executing it on the scheduler thread. Update
TlmArchive in
PROVESFlightControllerReference/Components/TlmArchive/TlmArchive.fpp:7-8 and
remove the direct rateGroup1Hz-to-tlmArchive.run connection in
PROVESFlightControllerReference/ReferenceDeployment/Top/topology.fpp:306,
routing scheduled work through the new asynchronous path instead.

In `@PROVESFlightControllerReference/Components/TlmArchive/TlmArchive.hpp`:
- Around line 28-31: Rename the TlmArchive member fields in TlmArchive.hpp to
m_queue_mutex, m_pending_packet, m_packet_pending, and m_antennas_deployed, then
update every corresponding reference in TlmArchive.cpp while preserving
behavior.

---

Duplicate comments:
In `@PROVESFlightControllerReference/Components/TlmArchive/TlmArchive.cpp`:
- Around line 59-78: Update the TlmArchive packet-write lifecycle around
createDirectory, open, and write to prevent unbounded filesystem retries and
archive growth: track consecutive failures and apply bounded backoff or disable
archiving after the configured failure threshold, and enforce a maximum archive
byte or record limit before appending. Preserve normal logging and reset retry
state after successful writes, using existing TlmArchive state/configuration
symbols where available.
🪄 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: b82e5631-f93e-4dee-a87a-fd6eb37fd263

📥 Commits

Reviewing files that changed from the base of the PR and between a80e238 and 139991e.

📒 Files selected for processing (4)
  • PROVESFlightControllerReference/Components/TlmArchive/TlmArchive.cpp
  • PROVESFlightControllerReference/Components/TlmArchive/TlmArchive.fpp
  • PROVESFlightControllerReference/Components/TlmArchive/TlmArchive.hpp
  • PROVESFlightControllerReference/ReferenceDeployment/Top/topology.fpp

Comment thread PROVESFlightControllerReference/Components/TlmArchive/TlmArchive.fpp Outdated
Comment thread PROVESFlightControllerReference/Components/TlmArchive/TlmArchive.hpp 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.

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 (1)
PROVESFlightControllerReference/Components/TlmArchive/TlmArchive.cpp (1)

83-108: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Enforce the file limit before appending and only account for successful writes.

A failed or short write at Lines 86-89 falls through and can add requestedSize to m_fileSize; size-query failures at Lines 98-101 also do not count toward the failure limit. Additionally, an existing or near-limit archive can receive one more oversized packet before the cap is checked. Initialize/check the current size before append, reject packets that exceed remaining capacity, and update the counter only after a complete write.

🤖 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/TlmArchive/TlmArchive.cpp` around
lines 83 - 108, The TlmArchive append flow must validate the current file size
and enforce the archive limit before writing, rejecting packets larger than the
remaining capacity, including when the archive is already near its cap. Update
m_fileSize only after a complete successful write; do not account for failed or
short writes, and ensure file-size query failures increment the existing failure
counter through the same failure path.
🤖 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/TlmArchive/TlmArchive.cpp`:
- Around line 32-35: Synchronize access to m_failures and m_fileSize between
run_handler() and comIn_handler() using the existing m_queueMutex, covering
limit checks and state updates while releasing it before filesystem I/O;
alternatively, convert both fields to atomics with appropriate acquire/release
operations.

---

Outside diff comments:
In `@PROVESFlightControllerReference/Components/TlmArchive/TlmArchive.cpp`:
- Around line 83-108: The TlmArchive append flow must validate the current file
size and enforce the archive limit before writing, rejecting packets larger than
the remaining capacity, including when the archive is already near its cap.
Update m_fileSize only after a complete successful write; do not account for
failed or short writes, and ensure file-size query failures increment the
existing failure counter through the same failure path.
🪄 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: 077c4fd3-385d-460f-953b-17d8b1f4a701

📥 Commits

Reviewing files that changed from the base of the PR and between 139991e and b4e359c.

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

Comment thread PROVESFlightControllerReference/Components/TlmArchive/TlmArchive.cpp Outdated
@hrfarmer
hrfarmer requested a review from ineskhou July 26, 2026 22:05
@hrfarmer

Copy link
Copy Markdown
Collaborator Author

On startup with startup.seq uploaded

Screen.Recording.2026-07-27.at.12.39.07.mov

Once startup.seq enables the burnwire

Screenshot 2026-07-27 at 13 25 55

After reboot post-burnwire trigger

Screenshot 2026-07-27 at 13 26 47

File size after startup.seq finishes and disables recording

image

}

if ((currentSize > MAX_FILE_SIZE)) {
{

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.

Its a soft check so no biggie but a currentSize + requested_size > MAX_FILE_SIZE is technically more correct

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

yeah thats how it was, but then if that check is there the component never actually hits the file size limit and will just emit the less precise failure count error instead

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.

I guess you could do a latch for that, which could be cleaner. Since the size isnt hard requirement this is more of a suggestion

- Retain the mutex only for packet mailbox access
- Update the design documentation for atomic state synchronization

@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.

Thanks for reposnding to my comments! LGTM

@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.

@hrfarmer , actually I have 2 questions specifically about downlinking the file. I am having a hard time getting the physical tlm data so I can read it. Its through UART but I think it might be related to my GDS configuration. Do you mind downlinking and posting what a file would look like? I'm also wondering why you picked .tlm file, when a .txt might be more accesible?

@ineskhou

ineskhou commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Did Testing with starting without the startup sequence.bin

The sat ran and
Screenshot 2026-08-02 at 4 07 16 PM

timed out
Screenshot 2026-08-02 at 4 07 36 PM

@ineskhou

ineskhou commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Using The script was able unpack telelmtry

tlm.txt

here is the original
hello_tlm.csv

ineskhou
ineskhou previously approved these changes Aug 3, 2026

@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.

Changed Paramaters, watched the buffer fill up based on the changed paramater, LGTM! Don't forget to post your evidence and merge once you've fixed the CI machine

@hrfarmer

hrfarmer commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator Author

Changed Paramaters, watched the buffer fill up based on the changed paramater, LGTM! Don't forget to post your evidence and merge once you've fixed the CI machine

i'm testing it out right now to be sure, but the ci failure actually could be because of the component. this starts doing file system stuff right as the ci script tries to format the file system, so it could be causing some race condition/conflict that's leading to broken behavior. would explain why it seemed to sometimes work and sometimes not

@hrfarmer

hrfarmer commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator Author

At this point after commenting out the run handler in 21309ec and having the radio tests immediately start working again, I'm pretty convinced the component's somehow having an adverse effect on comms, rate groups, or the filesystem thats leading to upstream breakage. Given an issue like this could be a potential game-ender for the satellites and there's only a couple of days until handoff, unless anyone feel strongly otherwise (or it turns out to somehow be a simple fix) I don't feel confident merging for this release ☹️

cc @ineskhou

@hrfarmer
hrfarmer marked this pull request as draft August 4, 2026 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants