Skip to content

Fix DDP fragmentation: add multi-packet handling and data offset support - #38

Open
andrewjswan wants to merge 1 commit into
KaufHA:mainfrom
andrewjswan:multi-packet
Open

Fix DDP fragmentation: add multi-packet handling and data offset support#38
andrewjswan wants to merge 1 commit into
KaufHA:mainfrom
andrewjswan:multi-packet

Conversation

@andrewjswan

Copy link
Copy Markdown

Description

This PR resolves an issue where addressable LED strips with more than 480 pixels stop rendering after the first 480 LEDs. It addresses the bug where incoming fragmented DDP packets with a non-zero data offset were either ignored or caused memory mapping corruption.

Changes

  • ddp.cpp: Extracted 32-bit data_offset from DDP header bytes 4-7, converted byte offset to LED index, and passed it down to the effect processing chain.
  • ddp_light_effect_base.h: Modified interface definition of process_() method to support an optional offset parameter defaulting to 0.
  • ddp_addressable_light_effect.cpp:
    • Updated packet length validation to account for the current offset position.
    • Replaced the high-overhead (i - used) / 3 division inside the performance-critical loop with a fast pointer-style target_led++ increment.
    • Implemented boundary check via break statement to prevent hardware buffer out-of-bounds access.
  • ddp_light_effect.cpp: Added an early exit rule for packets where offset > 0 to ensure single-bulb components ignore stream fragments meant for addressable strip installations.

Verification

  • Tested with Hyperion.ng driving a strip of 900 addressable LEDs.
  • Verified that logs no longer output "Ignoring DDP Packet with non-zero data offset".
  • Confirmed full-length strip coverage (all 900 pixels respond to DDP stream correctly without flicker or ghosting).

- Implement DDP data offset handling in DDPComponent::process_ to support fragmented multi-packet UDP streams.
- Update virtual signature of LightEffect::process_ to accept LED offset parameter.
- Refactor DDPAddressableLightEffect to map color payloads using incoming packet offset and optimize LED index calculation by replacing division with increment.
- Fix single bulb DDPLightEffect to drop non-zero offset packets to prevent memory corruption in chained setups.
- Add hardware state clearing to DDPAddressableLightEffect::start() to prevent erratic LED flashing on effect activation.
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