Skip to content

Incorrect Parsing of addEventHandler2 Commands with IR_NEC Codes Due to Inconsistent Spacing #1646

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
lagomCat opened this issue May 23, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@lagomCat
Copy link

lagomCat commented May 23, 2025

Firmware:

  • Version 1.18.104
  • Device EKF LED SRGBCW Strip
  • Chip/model: BK7231T

Symptoms

  1. The second addEventHandler2 command executes the action from the last command instead of its own.
  2. When using a two-digit hex code (e.g., 0x10), the associated command gets truncated if spacing is inconsistent with other commands using single-digit hex codes (0x00xF).
  3. Improper parsing of commands occurs when the number of spaces between the hex code and the command is not adjusted based on the length of the hex code.

Example of Incorrect Behavior:

addEventHandler2 IR_NEC 0xEF00 0x0 led_enableAll 1
addEventHandler2 IR_NEC 0xEF00 0x1 led_enableAll 0
addEventHandler2 IR_NEC 0xEF00 0x10 led_basecolor_rgbcw #00000000FF
addEventHandler2 IR_NEC 0xEF00 0x4 led_basecolor_rgbcw #FF00000000
addEventHandler2 IR_NEC 0xEF00 0x5 led_basecolor_rgbcw #00FF000000
addEventHandler2 IR_NEC 0xEF00 0x6 led_basecolor_rgbcw #0000FF0000

Expected: The command for "0x1" executes "led_enableAll 0".
Actual: It executes the command from "0x6": "led_basecolor_rgbcw #0000FF0000".

Expected: The command for "0x10" executes "led_basecolor_rgbcw #00000000FF".
Actual: It executes the command from "0x10": "ed_basecolor_rgbcw #00000000FF".


Corrected Version:

addEventHandler2 IR_NEC 0xEF00 0x0 led_enableAll 1
addEventHandler2 IR_NEC 0xEF00 0x1 led_enableAll 0
addEventHandler2 IR_NEC 0xEF00 0x10 led_basecolor_rgbcw #00000000FF
addEventHandler2 IR_NEC 0xEF00 0x4 led_basecolor_rgbcw #FF00000000
addEventHandler2 IR_NEC 0xEF00 0x5 led_basecolor_rgbcw #00FF000000
addEventHandler2 IR_NEC 0xEF00 0x6 led_basecolor_rgbcw #0000FF0000
addEventHandler2 IR_NEC 0xEF00 0x1 led_enableAll 0

Key Differences:

  • Two spaces between the hex code and the command for single-digit hex codes (0x0 to 0xF).
  • One space for two-digit hex codes (e.g., 0x10).
  • Repeating the 0x1 command at the end ensures correct execution.

Suspected Cause

  • The parser for startup_command does not account for varying lengths of hex codes, leading to misalignment and incorrect command execution.
  • There may be an issue with how the event handler array is managed, causing overwriting or misassociation of commands.

Recommendations

  1. Update the parser to handle variable spacing based on the length of the hex code.
  2. Implement warnings or logs when an event handler is overwritten.
  3. Consider normalizing input spacing or providing guidelines for consistent formatting.

Tested On:

  • NEC IR codes received directly via remote.

  • OpenBeken console logs:

    Info:IR:IR IR_NEC 0xEF00 0x4 (32 bits)
    executing command led_basecolor_rgbcw #0000FF0000

@openshwprojects openshwprojects added the bug Something isn't working label May 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants