OpenBK7231T_App icon indicating copy to clipboard operation
OpenBK7231T_App copied to clipboard

BUG: addEventHandler ... do ... endon not parsed as script block (OBK 1.18.100)

Open derei opened this issue 7 months ago • 0 comments

Summary

On OpenBeken v1.18.100 (tested on BK7231N), event handlers declared using addEventHandler ... do ... endon inside .bat scripts fail to execute properly. When the event fires, OBK throws cmd not found errors for valid scripting commands like delay and endon.

Environment

  • Firmware: OpenBK7231N_QIO_1.18.100.bin
  • Chipset: BK7231N
  • Script location: /scene1.bat and /autoexec.bat
  • Launch method: "Save, Reset SVM and run file as script thread"

Problem Description

Handlers using do ... endon blocks are accepted during script start (CMD_StartScript: started /scene1.bat), and even log the handler being added:

Info:EVENT:CMD_AddEventHandler: added OnChannelChange with cmd do

But when the trigger fires (e.g., OnChannelChange 10), OBK logs:

Error:CMD:cmd delay NOT found (args 200) Error:CMD:cmd endon NOT found (args )

This means the do block is being treated as a flattened runtime string, not parsed into a proper SVM block.

Example That Fails (When Placed in Script File and Run via SVM)

  • When saved in /autoexec.bat or /scene1.bat and executed via:
  • Filesystem -> "Save, Reset SVM and run file as script thread" …this multi-line handler appears to load correctly, but fails at runtime:
addEventHandler OnChannelChange 10 do
toggleChannel 1
delay 200
toggleChannel 2
endon

Runtime Logs:

Info:EVENT:EventHandlers_FireEvent: executing command do
Error:CMD:cmd delay NOT found (args 200)
Error:CMD:cmd endon NOT found (args )

This confirms the block was interpreted as a raw command string - not a parsed handler in the script VM.

Workaround That Works

  • Only a flattened backlog call executes successfully:
addEventHandler OnChannelChange 10 do backlog toggleChannel 1; toggleChannel 2 endon

Expected Behavior

When executed as a script thread (via startScript or Filesystem -> "Save, Reset SVM and run"), OBK should correctly interpret addEventHandler ... do ... endon as a script block and store the handler with parsed structure - not literal string evaluation.

Request

  • Please confirm whether this is a regression in 1.18.100 or intended behavior
  • If possible, expose whether SVM is being initialized successfully
  • Recommend adding a log line like SVM_HandlerParsed or similar for validation

This issue persisted after confirming:

  • UTF-8 (no BOM) encoding
  • Unix LF line endings
  • No trailing semicolons
  • Correct filename casing (autoexec.bat and scene1.bat both tested)

derei avatar May 16 '25 10:05 derei