Files
cnc_wams/wasm-port/runtime/sdk/README.md
wangdequan 7cdfc458f9 按规划持续工作
结论:浏览器 interpreter smoke 和 INI panel UI 已接入 vendored LinuxCNC 五轴 switchkins remap 执行路径,只复制 LinuxCNC sample machine 文件到 WASM FS 并调用 SDK C ABI;host 聚合 smoke 通过,未新增 JavaScript M428/M429/M430 或运动学语义。
2026-06-08 18:12:27 +08:00

1.9 KiB

LinuxCNC WASM SDK

This SDK exposes browser/Node JavaScript wrappers for standalone WASM modules built from vendored LinuxCNC source.

Boundary

The SDK is a host-boundary layer only. It may:

  • load generated Emscripten modules;
  • allocate and free C strings;
  • write text files into the Emscripten filesystem;
  • call exported C ABI functions;
  • return LinuxCNC-produced text output to JavaScript callers.

The SDK must not implement G-code interpretation, canonical motion behavior, tool semantics, parameter semantics, kinematics, or planner behavior. Those behaviors must continue to come from vendored LinuxCNC source through the C ABI.

Entrypoints

Use src/index.js for stable imports:

import {
  createLinuxCncIniSdk,
  createLinuxCncInterpSdk,
} from "./src/index.js";

createLinuxCncIniSdk() wraps the INI parser module built from vendored LinuxCNC inifile.cc and exposes getString() plus getBool(). Boolean conversion is performed by vendored LinuxCNC iniFindBool().

createLinuxCncInterpSdk() wraps the interpreter-core module built from vendored LinuxCNC RS274NGC sources and exposes:

  • runProgram(programText)
  • runProgramWithIni(programText, iniPath)
  • runFile(path)
  • runFileWithIni(path, iniPath)
  • runFiveAxisRemapFile(path, iniPath)
  • restoreParameters(path)
  • saveParameters(path, values)
  • loadToolTable(path, options)
  • saveToolTable(path)
  • writeTextFile(path, text)
  • readTextFile(path)

loadToolTable() accepts { randomToolChanger: true } to select the LinuxCNC random-toolchanger branch before calling vendored tooldata_load(). The SDK only forwards that runtime boundary flag.

runFiveAxisRemapFile() is a narrow host boundary for vendored LinuxCNC sample-machine remap validation. Callers provide INI/remap/demo files in the WASM filesystem; the C ABI runs vendored LinuxCNC REMAP, O-word, file execution, and HAL adapter paths.