Skip to content

blueberryF435wing initial cleanup#1

Merged
sunyanmeng963 merged 1 commit into
sunyanmeng963:masterfrom
sensei-hacker:blueberryF435wing
Oct 20, 2025
Merged

blueberryF435wing initial cleanup#1
sunyanmeng963 merged 1 commit into
sunyanmeng963:masterfrom
sensei-hacker:blueberryF435wing

Conversation

@sensei-hacker
Copy link
Copy Markdown

Mostly I cleaned up commented-out code and whitespace.

@sensei-hacker sensei-hacker changed the title blueberryF435wing initial fixes blueberryF435wing initial cleanup Oct 20, 2025
@sunyanmeng963 sunyanmeng963 merged commit 796440e into sunyanmeng963:master Oct 20, 2025
20 checks passed
sensei-hacker pushed a commit that referenced this pull request Oct 23, 2025
Update VTOL.md with a more detailed guide on how to set up tilting se…
sensei-hacker pushed a commit that referenced this pull request Oct 23, 2025
sunyanmeng963 pushed a commit that referenced this pull request Dec 15, 2025
sunyanmeng963 pushed a commit that referenced this pull request May 22, 2026
This commit fixes the critical bugs that caused PR iNavFlight#11025 to be reverted
(PR iNavFlight#11139). The original implementation caused telemetry stream corruption
by emitting malformed frames when sensors were unavailable.

Root Cause:
The original PR scheduled telemetry frames unconditionally (if feature
compiled in) but frame functions only wrote data when sensors were available.
This resulted in frames containing only [SYNC][CRC] instead of the proper
[SYNC][LENGTH][TYPE][PAYLOAD][CRC] structure, corrupting the CRSF protocol
stream and breaking ALL telemetry (not just new frames).

Fixes Implemented:

1. RPM Frame (Bug #1 - CRITICAL):
   - Added conditional scheduling: only schedule if ESC_SENSOR_ENABLED
     and motorCount > 0
   - Added protocol limit enforcement: max 19 RPM values per CRSF spec
   - Location: src/main/telemetry/crsf.c:705-707, 337-343

2. Temperature Frame (Bug iNavFlight#2 - CRITICAL):
   - Added conditional scheduling: only schedule if temperature sources
     are actually available (ESC sensors OR temperature sensors)
   - Added bounds checking: prevent buffer overflow beyond 20 temperatures
   - Location: src/main/telemetry/crsf.c:709-732, 361-381

3. Buffer Overflow Protection (Bug iNavFlight#4):
   - Added MAX_CRSF_TEMPS constant and bounds checks in loops
   - Prevents array overflow if >20 temperature sources configured
   - Location: src/main/telemetry/crsf.c:361, 368, 376

4. Protocol Limit Enforcement (Bug iNavFlight#5):
   - Added MAX_CRSF_RPM_VALUES constant (19 per CRSF spec)
   - Clamp motorCount to protocol limit before sending
   - Location: src/main/telemetry/crsf.c:337, 342-344

Implementation Pattern:
Follows the GPS frame pattern:
  ✓ Conditional scheduling - only schedule if sensor available
  ✓ Unconditional writing - always write complete frame data when called

Testing:
- Code compiles successfully (verified with SITL build)
- No syntax errors or warnings
- All fixes follow existing code patterns in crsf.c

Related Issues:
- Original PR: iNavFlight#11025 (merged Nov 28, 2025, reverted same day)
- Revert PR: iNavFlight#11139
- Investigation: claude/developer/sent/pr11025-root-cause-analysis.md

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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.

2 participants