Skip to content

Fix for udp receive reconnect#355

Merged
x46085 merged 8 commits intomainfrom
fix/udp-receive
Dec 19, 2025
Merged

Fix for udp receive reconnect#355
x46085 merged 8 commits intomainfrom
fix/udp-receive

Conversation

@x46085
Copy link
Contributor

@x46085 x46085 commented Dec 14, 2025

Small improvements for the msp-osd artificial horizon with configurable pitch scale and character aspect ratio settings to better match camera FOV and HD OSD character dimensions, and adds an auto-record feature to automatically start VTX DVR recording on service startup. It also fixes serial reconnection handling. For UDP component receive, a new timestamp mode option lets users choose between sender, local, or monotonic clock timestamps when writing to Elodin-DB.


Note

Adds OSD horizon calibration (char aspect ratio, pitch scale), optional VTX auto-record via MSPv2, and a new timestamp mode for UDP receiver, with NixOS options and docs updated.

  • msp-osd:
    • Horizon calibration: Add osd.char_aspect_ratio and osd.pitch_scale; layout.rs uses these for horizon tilt and pitch ladder; main.rs passes full OsdConfig.
    • VTX auto-record: Add serial.auto_record; implement MSPv2 MSP2_COMMON_SET_RECORDING in backends/displayport.rs and trigger on init when enabled.
    • NixOS module: Expose charAspectRatio, pitchScale, and autoRecord; write them to config.toml.
    • Docs/Config: Update README.md and config.toml with new options and guidance.
  • udp-component-receive:
    • Timestamp modes: Add --timestamp-mode {sender|local|monotonic}; apply selected timestamp when writing to Elodin-DB.
    • NixOS module: Add timestampMode and pass via ExecStart.
    • Docs: Update README with new flag and examples.
  • Template:
    • Update flake.nix comments to document new OSD calibration and receiver timestamp options.

Written by Cursor Bugbot for commit bc2f4cb. This will update automatically on new commits. Configure here.

@x46085 x46085 marked this pull request as ready for review December 18, 2025 06:30
// Max offset is half the horizon height to keep horizon visible
let max_pitch_offset = (horizon_height as f32) / 2.0;
let pitch_offset =
(-pitch_deg / osd_config.pitch_scale).clamp(-max_pitch_offset, max_pitch_offset);
Copy link

Choose a reason for hiding this comment

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

Bug: Division by zero possible with configurable pitch_scale

The new configurable pitch_scale parameter is used as a divisor in horizon and pitch ladder calculations without validation. If a user sets pitch_scale to 0 in the config (the documentation describing "lower values = more sensitive" might encourage very low values), the divisions at lines 127 and 188 will produce Infinity or NaN, causing garbled OSD rendering. The previous hardcoded values (10.0, 2.5) could never be zero. Consider adding validation to ensure pitch_scale is positive.

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +249 to 251
# Write to Elodin-DB (handles reconnection if client was unavailable at startup)
if IMPELLER_AVAILABLE:
self._write_to_db(component_name, values.astype(np.float64), msg)

Choose a reason for hiding this comment

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

P1 Badge Keep retrying DB connect after startup failure

The new unconditional call to _write_to_db (now executed whenever impeller_py is importable) means the reconnect branch runs even when no client is initialized, but _write_to_db sets self.client = ImpellerClient(...) before calling connect() and returns on failure without clearing it. If the DB is still down on that first reconnect attempt, self.client remains truthy while _db_available is false, so subsequent packets skip the reconnect block and keep using the dead client; the receiver never starts writing when the DB finally comes up unless the process is restarted.

Useful? React with 👍 / 👎.

@x46085 x46085 merged commit d8d86ad into main Dec 19, 2025
11 checks passed
@x46085 x46085 deleted the fix/udp-receive branch December 19, 2025 01:10
KushMahajan pushed a commit that referenced this pull request Dec 24, 2025
* Fix for horizon line, make pitch scaleable
* Add msp-osd auto-record feature
* Add time configuration to udp-component-receive
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.

1 participant

Comments