diff --git a/wasm-port/docs/compatibility-validation.md b/wasm-port/docs/compatibility-validation.md index 9509bab..aa0bb40 100644 --- a/wasm-port/docs/compatibility-validation.md +++ b/wasm-port/docs/compatibility-validation.md @@ -52,6 +52,7 @@ The validation fails if: | --- | --- | | `linuxcnc_ini_probe` | Validates vendored LinuxCNC INI parsing can be used standalone. | | `linuxcnc_interp_state_probe` | Validates interpreter state constants and structs compile under the standalone boundary. | +| `linuxcnc_emc_status_probe` | Validates the standalone `emcStatus` machine-units status boundary used by vendored interpreter conversion code. | | `linuxcnc_namedparam_harness` | Validates LinuxCNC named parameter behavior, `_ini[...]`, and `_hal[...]` adapter resolution. | | `linuxcnc_interp_minimal_harness` | Runs G-code fixtures through vendored LinuxCNC parser/execution/conversion code and captures canonical events. | | `linuxcnc_parameter_file_harness` | Validates LinuxCNC parameter file restore/save behavior and required/read-only parameter handling. | diff --git a/wasm-port/docs/drift-report.md b/wasm-port/docs/drift-report.md index fb0c384..8123696 100644 --- a/wasm-port/docs/drift-report.md +++ b/wasm-port/docs/drift-report.md @@ -33,6 +33,7 @@ semantic rewrites: | Interpreter reset | LinuxCNC `ON_RESET` is captured as a canonical test event on the vendored interpreter reset/file-open path. | | Interpreter init | LinuxCNC `INIT_CANON` and the canonical initialization sequence from vendored `Interp::init()` are captured as test events. | | Comment logging | LinuxCNC `LOGOPEN`, `LOG`, `LOGAPPEND`, and `LOGCLOSE` callbacks are captured as canonical test events instead of writing host log files. | +| EMC status machine units | A narrow standalone `emcStatus` shim exposes the machine-units field used by vendored interpreter conversion code; `linuxcnc_emc_status_probe` guards the inch/mm boundary. | | Python/remap | Python/remap hooks are stubbed at the runtime edge. | | Dynamic interpreter path | `interp_base.cc` probe uses standalone `EMC2_HOME` compile-time path boundary. | | Realtime scheduler | TP probes seed deterministic status/config data instead of running LinuxCNC realtime process topology. | diff --git a/wasm-port/docs/source-reuse-map.md b/wasm-port/docs/source-reuse-map.md index 8bfd35c..924633f 100644 --- a/wasm-port/docs/source-reuse-map.md +++ b/wasm-port/docs/source-reuse-map.md @@ -33,7 +33,7 @@ Current validation is intentionally mechanical: | --- | --- | --- | --- | --- | | INI parsing | `src/emc/ini/inifile.cc`, `inifile.h`, `inifile.hh` | Copy unchanged | Native file IO remains LinuxCNC-style in the vendored parser; browser OPFS integration remains outside this layer | Vendor byte sync, `linuxcnc_ini_probe`, `linuxcnc_inifile_source_probe` | | RTAPI compatibility headers | `src/rtapi/rtapi_*.h` in the manifest | Copy unchanged plus standalone shim include path | `runtime/core/shims/rtapi.h` supplies the minimal standalone RTAPI surface needed by vendored code | Vendor byte sync, compile coverage through dependent source probes | -| Canon/NML-facing interpreter types | `src/emc/nml_intf/canon*.hh`, `emctool.h`, `interp_return.hh`, `motion_types.h`, `emcpose.*`, `emcpos.h`, `debugflags.h`, `src/emc/linuxcnc.h` | Copy unchanged | NML transport is not ported; wrappers provide only the status/type edges needed by standalone probes | Vendor byte sync, dependent source probes, `linuxcnc_tp_api_probe`, interpreter harnesses | +| Canon/NML-facing interpreter types | `src/emc/nml_intf/canon*.hh`, `emctool.h`, `interp_return.hh`, `motion_types.h`, `emcpose.*`, `emcpos.h`, `debugflags.h`, `src/emc/linuxcnc.h` | Copy unchanged plus narrow standalone status shim | NML transport is not ported; `runtime/core/shims/nml_intf/emc.hh` exposes only the `emcStatus` machine-units status edge currently needed by vendored interpreter conversion code | Vendor byte sync, dependent source probes, `linuxcnc_emc_status_probe`, `linuxcnc_tp_api_probe`, interpreter harnesses | | Motion state headers | `src/emc/motion/state_tag.h`, `emcmotcfg.h`, `simple_tp.h`, `motion.h`, `mot_priv.h`, `axis.h` | Copy unchanged | Realtime motion process is not ported; standalone probes seed the small motion status/config state required by TP calls | Vendor byte sync, `linuxcnc_tp_api_probe` | | Identity/trivial kinematics | `src/emc/kinematics/kinematics.h`, `cubic.h`, `kins_util.c`, `trivkins.c` | Copy unchanged | HAL component lifecycle and RTAPI module metadata are replaced by standalone shims; forward/inverse mapping behavior remains LinuxCNC source | Vendor byte sync, per-file source probes, `linuxcnc_kinematics_probe` | | Switchable 5-axis bridge kinematics | `src/emc/kinematics/5axiskins.c`, `switchkins.c`, `switchkins.h`, `userkfuncs.c`, plus `src/rtapi/rtapi_ctype.h` | Copy unchanged | HAL pin allocation, HAL component lifecycle, and RTAPI module metadata are standalone runtime edges; switchable 5-axis forward/inverse behavior remains LinuxCNC source | Vendor byte sync, per-file source probes, `linuxcnc_5axis_kinematics_probe` | @@ -53,7 +53,7 @@ Current validation is intentionally mechanical: | --- | --- | --- | | Native file IO | `inifile.cc`, `rs274ngc_pre.cc`, parameter file paths | Allowed in native probes; browser OPFS remains a host-side future adapter | | RTAPI | `rtapi_*.h`, TP, posemath, motion headers | Minimal standalone shim in `runtime/core/shims/rtapi.h` | -| NML transport | `emc.hh`, motion/NML type headers | Transport is not ported; only structs/types needed by vendored compute code are used | +| NML transport | `emc.hh`, motion/NML type headers | Transport is not ported; only the status/type edges needed by vendored compute code are exposed through standalone shims and probes | | HAL runtime | named parameter lookup, kinematics component lifecycle, and runtime status edges | Standalone HAL adapter under `runtime/core/linuxcnc_wrap/` | | Python/remap | `rs274ngc_pre.cc`, `interp_o_word.cc`, remap hooks | Stubbed at runtime boundary; no Python CNC semantics are reimplemented | | Canonical machine actions | `interp_convert.cc`, `interp_execute.cc`, `interp_queue.cc` | Captured by standalone canonical event sink functions for regression fixtures | diff --git a/wasm-port/runtime/core/linuxcnc_wrap/linuxcnc_emc_status_probe.cpp b/wasm-port/runtime/core/linuxcnc_wrap/linuxcnc_emc_status_probe.cpp index 3b56762..8338117 100644 --- a/wasm-port/runtime/core/linuxcnc_wrap/linuxcnc_emc_status_probe.cpp +++ b/wasm-port/runtime/core/linuxcnc_wrap/linuxcnc_emc_status_probe.cpp @@ -1,4 +1,39 @@ #include "nml_intf/emc.hh" +#include + static EMC_STAT standalone_emc_status; EMC_STAT *emcStatus = &standalone_emc_status; + +int main() +{ + const bool default_units_visible = emcStatus->motion.traj.linearUnits == 1.0; + const bool default_machine_units_mm = + emcStatus->motion.traj.linearUnits > 0.5; + + emcStatus->motion.traj.linearUnits = 1.0 / 25.4; + const bool inch_machine_units_visible = + emcStatus->motion.traj.linearUnits <= 0.5; + + emcStatus->motion.traj.linearUnits = 1.0; + const bool mm_machine_units_visible = + emcStatus->motion.traj.linearUnits > 0.5; + + std::cout << "emc_status_default_linear_units=" + << emcStatus->motion.traj.linearUnits << "\n"; + std::cout << "emc_status_default_units_visible=" + << default_units_visible << "\n"; + std::cout << "emc_status_default_machine_units_mm=" + << default_machine_units_mm << "\n"; + std::cout << "emc_status_inch_machine_units_visible=" + << inch_machine_units_visible << "\n"; + std::cout << "emc_status_mm_machine_units_visible=" + << mm_machine_units_visible << "\n"; + + if (!default_units_visible || !default_machine_units_mm || + !inch_machine_units_visible || !mm_machine_units_visible) { + return 1; + } + + return 0; +} diff --git a/wasm-port/tests/native/verify_native_probes.sh b/wasm-port/tests/native/verify_native_probes.sh index 9e7a206..9e35f57 100755 --- a/wasm-port/tests/native/verify_native_probes.sh +++ b/wasm-port/tests/native/verify_native_probes.sh @@ -77,6 +77,8 @@ check_exitcode() { check_source_probe_coverage check_exitcode linuxcnc_interp_state_probe +check_exitcode linuxcnc_emc_status_probe +check_exitcode linuxcnc_emc_status_probe.run check_exitcode linuxcnc_inifile_source_probe check_exitcode linuxcnc_tp_api_probe check_exitcode linuxcnc_tp_api_probe.run @@ -202,6 +204,13 @@ check_exitcode linuxcnc_rs274ngc_pre_source_probe check_exitcode linuxcnc_interp_base_source_probe check_exitcode linuxcnc_gomath_source_probe +EMC_STATUS_STDOUT="$BUILD_DIR/linuxcnc_emc_status_probe.run.stdout.log" +grep -Fq "emc_status_default_linear_units=1" "$EMC_STATUS_STDOUT" +grep -Fq "emc_status_default_units_visible=1" "$EMC_STATUS_STDOUT" +grep -Fq "emc_status_default_machine_units_mm=1" "$EMC_STATUS_STDOUT" +grep -Fq "emc_status_inch_machine_units_visible=1" "$EMC_STATUS_STDOUT" +grep -Fq "emc_status_mm_machine_units_visible=1" "$EMC_STATUS_STDOUT" + NAMEDPARAM_STDOUT="$BUILD_DIR/linuxcnc_namedparam_harness.run.stdout.log" grep -Fq "init_named_parameters=0" "$NAMEDPARAM_STDOUT" grep -Fq "global_named_count=57" "$NAMEDPARAM_STDOUT" diff --git a/wasm-port/tools/build_native_probes.sh b/wasm-port/tools/build_native_probes.sh index 8b3fae8..4b7ac6f 100755 --- a/wasm-port/tools/build_native_probes.sh +++ b/wasm-port/tools/build_native_probes.sh @@ -342,6 +342,10 @@ STATE_PROBE_SOURCES=( "$WRAP_DIR/linuxcnc_interp_state_probe.cpp" ) +EMC_STATUS_PROBE_SOURCES=( + "$WRAP_DIR/linuxcnc_emc_status_probe.cpp" +) + TP_API_PROBE_SOURCES=( "$WRAP_DIR/linuxcnc_tp_api_probe.cpp" ) @@ -660,6 +664,28 @@ build_binary_target \ STATE_PROBE_SOURCES \ NO_LINK_FLAGS +build_binary_target \ + linuxcnc_emc_status_probe \ + "$BUILD_DIR/linuxcnc_emc_status_probe" \ + COMMON_FLAGS \ + EMC_STATUS_PROBE_SOURCES \ + NO_LINK_FLAGS + +if [[ "$(tr -d '[:space:]' < "$BUILD_DIR/linuxcnc_emc_status_probe.exitcode")" == "0" ]]; then + set +e + "$BUILD_DIR/linuxcnc_emc_status_probe" \ + >"$BUILD_DIR/linuxcnc_emc_status_probe.run.stdout.log" \ + 2>"$BUILD_DIR/linuxcnc_emc_status_probe.run.stderr.log" + EMC_STATUS_RUN_RC=$? + set -e + echo "$EMC_STATUS_RUN_RC" > "$BUILD_DIR/linuxcnc_emc_status_probe.run.exitcode" +else + rm -f \ + "$BUILD_DIR/linuxcnc_emc_status_probe.run.exitcode" \ + "$BUILD_DIR/linuxcnc_emc_status_probe.run.stdout.log" \ + "$BUILD_DIR/linuxcnc_emc_status_probe.run.stderr.log" +fi + build_binary_target \ linuxcnc_tp_api_probe \ "$BUILD_DIR/linuxcnc_tp_api_probe" \