Skip to content

feat: add received_time to inject_tlm - #3720

Open
suhaslord wants to merge 8 commits into
OpenC3:mainfrom
suhaslord:suhas/received-time-inject-tlm
Open

feat: add received_time to inject_tlm#3720
suhaslord wants to merge 8 commits into
OpenC3:mainfrom
suhaslord:suhas/received-time-inject-tlm

Conversation

@suhaslord

Copy link
Copy Markdown

Adds an optional received_time parameter to Python inject_tlm so scripts can inject historical telemetry while still using the normal COSMOS packet path instead of modifying TSDB data directly.

received_time is represented as nanoseconds since the Unix epoch, matching COSMOS's existing packet timestamp serialization. When omitted, behavior is unchanged and the receive time is still set to the current UTC time.

Implementation:

  • thread received_time through the public inject_tlm API
  • forward it through InterfaceTopic and DecomInterfaceTopic
  • convert nanoseconds back to a UTC datetime in handle_inject_tlm
  • expose the option through the Python Script Runner wrapper
  • preserve 0 as a valid Unix-epoch timestamp
  • add regression coverage for both routing paths, conversion, epoch zero, and Script Runner forwarding

Compatibility:
Existing callers remain unchanged because the new argument is optional and appended after scope. The Script Runner wrapper only forwards the new keyword when explicitly supplied.

Closes #3521

Adds an optional received_time parameter to Python inject_tlm so scripts can inject historical telemetry while still using the normal COSMOS packet path instead of modifying TSDB data directly.

received_time is represented as nanoseconds since the Unix epoch, matching COSMOS's existing packet timestamp serialization. When omitted, behavior is unchanged and the receive time is still set to the current UTC time.

Implementation:
- thread received_time through the public inject_tlm API
- forward it through InterfaceTopic and DecomInterfaceTopic
- convert nanoseconds back to a UTC datetime in handle_inject_tlm
- expose the option through the Python Script Runner wrapper
- preserve 0 as a valid Unix-epoch timestamp
- add regression coverage for both routing paths, conversion, epoch zero, and Script Runner forwarding

Compatibility:
Existing callers remain unchanged because the new argument is optional and appended after scope. The Script Runner wrapper only forwards the new keyword when explicitly supplied.

Closes OpenC3#3521
@ryan-pratt
ryan-pratt self-requested a review August 17, 2026 22:19
@ryan-pratt

Copy link
Copy Markdown
Contributor

Hello @suhaslord, thanks for your contribution!

These changes look good, but we also need the corresponding ruby code updated to have parity with this. Please update the ruby code, or if you want, I can push a commit to your branch or send you a patch file. Just let me know. The relevant files are listed here:

  • openc3/lib/openc3/api/tlm_api.rb
  • openc3/lib/openc3/microservices/interface_decom_common.rb
  • openc3/lib/openc3/script/telemetry.rb
  • openc3/lib/openc3/topics/decom_interface_topic.rb
  • openc3/lib/openc3/topics/interface_topic.rb

Once addressed, I'll approve the workflow runs and make sure we get two OpenC3 staff reviews on this.

@suhaslord

suhaslord commented Aug 18, 2026 via email

Copy link
Copy Markdown
Author

@sonarqubecloud

Copy link
Copy Markdown

@EmilyRagan
EmilyRagan requested a review from ryanmelt August 18, 2026 16:20
@codecov

codecov Bot commented Aug 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.23529% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.33%. Comparing base (d43e1eb) to head (36b8743).
⚠️ Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
openc3/lib/openc3/script/telemetry.rb 75.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3720      +/-   ##
==========================================
+ Coverage   79.30%   79.33%   +0.03%     
==========================================
  Files         885      885              
  Lines       65365    65383      +18     
  Branches     2543     2591      +48     
==========================================
+ Hits        51838    51872      +34     
+ Misses      12859    12847      -12     
+ Partials      668      664       -4     
Flag Coverage Δ
frontend 63.61% <ø> (-0.02%) ⬇️
python 81.54% <ø> (+0.01%) ⬆️
ruby-api 82.57% <ø> (+0.40%) ⬆️
ruby-backend 84.07% <88.23%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

Add received_time parameter to inject_tlm to allow injecting historical tlm

2 participants