OpenBK7231T_App icon indicating copy to clipboard operation
OpenBK7231T_App copied to clipboard

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

Open lagomCat opened this issue 7 months ago • 2 comments

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

lagomCat avatar May 23 '25 17:05 lagomCat

I am unable to reproduce it at the moment:

Image

openshwprojects avatar Jun 21 '25 05:06 openshwprojects

На данный момент я не могу это воспроизвести:

It's possible that the different behavior between modules is related to the fact that, after each change to the initial command set for the IR receiver, you have to reassign the pin connected to the IR receiver. I changed the startup command settings many times with no effect. But once I removed IRRecv from the configuration and then reassigned it — the set of commands I had saved in the settings finally started working. So, there’s definitely some issue here, but I haven’t been able to reliably reproduce the exact sequence yet.

lagomCat avatar Jul 01 '25 08:07 lagomCat