sbus_futaba: Add SBUS2 telemetry decoding and optimize performance - #135
sbus_futaba: Add SBUS2 telemetry decoding and optimize performance#135edwin-oetelaar wants to merge 7 commits into
Conversation
This commit adds full support for Futaba SBUS2 telemetry frames while
significantly improving the decoder's execution performance and memory footprint.
Background:
Standard Futaba SBUS frames end with a 0x00 footer byte. SBUS2 receivers
use non-zero footers (e.g. 0x04, 0x14, 0x24, 0x34) to request telemetry
slot data (slots 0-7, 8-15, 16-23, 24-31). Following an inter-frame gap
(~1960 µs), sensors and receivers respond with 3-byte telemetry slots.
Previously, non-zero footers produced warnings and subsequent telemetry
bytes triggered "excess data" warnings, causing frame decoding to fail.
Key Changes:
- SBUS2 Telemetry Support:
* Recognize valid SBUS2 telemetry footers and indicate requested telemetry
slot groups in UI annotations.
* Added a state machine transition to decode 3-byte telemetry packets
(1-byte Slot ID + 2-byte 16-bit payload value) after inter-frame gaps.
* Handled UART IDLE gaps between main servo frames and telemetry bursts seamlessly.
- High-Performance Byte-Buffer Architecture:
* Replaced bit-by-bit accumulator tuple parsing with byte-level buffering,
eliminating thousands of micro-allocations per capture.
* Implemented fast 11-bit channel extraction directly from the 22-byte payload
using bitwise shifts.
- Precise Sample Alignment & Visual Usability:
* Added bit-level UART sample interpolation for Byte 23 (Digital Ch 17, 18,
Frame Lost, Failsafe) and Channels 1-16. This prevents annotation overlapping
in PulseView and ensures clean, distinct visual rendering.
- Code Quality & Documentation:
* Restructured state machine representation to use integer constants.
* Added standardized docstrings (Brief, Params, Invariants, Output) to all methods.
Tested against live Futaba SBUS2 receiver captures containing receiver battery
voltage telemetry slots in PulseView.
edwin-oetelaar
left a comment
There was a problem hiding this comment.
Hi everyone,
I noticed that the current sbus_futaba decoder has trouble decoding frames from Futaba SBUS2 receivers when telemetry is enabled, as non-zero footers and telemetry response bytes trigger unexpected warnings.
I have updated the decoder to support SBUS2 telemetry decoding while also refactoring the internal bit-accumulator logic into a high-performance byte-buffer architecture for significantly faster decoding in PulseView.
Summary of Changes
- SBUS2 Telemetry: Added support for non-zero footers (
0x04,0x14, etc.) and decoding of 3-byte telemetry slots (Slot ID + 16-bit payload). - Performance: Replaced bit-by-bit tuple slicing with direct byte-buffer bitwise unpacking.
- UI & Alignment: Added bit-accurate sample timing interpolation for Digital channels (Ch 17, 18), flags (Frame Lost, Failsafe), and Proportional channels so annotations render cleanly without overlapping in PulseView.
- Code Quality: Added docstrings (
Brief,Params,Invariants,Output) to all methods and converted state flags to integer constants.
Tested on a physical SBUS2 receiver trace with receiver battery voltage telemetry.
Feedback and suggestions are very welcome!
Best regards,
Edwin van den Oetelaar
|
added some more decoding of telemetry : SBUS2 telemetry decoding now recognizes sensor type flags: |
Added details about SBUS2 decoding improvements and included a screenshot.
This commit adds full support for Futaba SBUS2 telemetry frames while significantly improving the decoder's execution performance and memory footprint.
Background:
Standard Futaba SBUS frames end with a 0x00 footer byte. SBUS2 receivers use non-zero footers (e.g. 0x04, 0x14, 0x24, 0x34) to request telemetry slot data (slots 0-7, 8-15, 16-23, 24-31). Following an inter-frame gap (~1960 µs), sensors and receivers respond with 3-byte telemetry slots. Previously, non-zero footers produced warnings and subsequent telemetry bytes triggered "excess data" warnings, causing frame decoding to fail.
Key Changes:
SBUS2 Telemetry Support:
High-Performance Byte-Buffer Architecture:
Precise Sample Alignment & Visual Usability:
Code Quality & Documentation:
Tested against live Futaba SBUS2 receiver captures containing receiver battery voltage telemetry slots in PulseView.