From a227ad14a62bf96e646495d41006c73ad2bc8201 Mon Sep 17 00:00:00 2001 From: wangdequan Date: Sat, 23 May 2026 18:02:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E7=A4=BA=E8=AF=8D=EF=BC=9A=20?= =?UTF-8?q?=E5=AF=B9=E6=A0=87=20LinuxCNC=EF=BC=8C=E5=88=86=E9=98=B6?= =?UTF-8?q?=E6=AE=B5=E5=AE=8C=E5=96=84=20Web=20=E7=89=88=E6=95=B0=E6=8E=A7?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E4=BB=BF=E7=9C=9F=E7=9A=84=20WASM=20?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=EF=BC=8C=E7=BB=A7=E7=BB=AD=E8=A1=A5=E9=BD=90?= =?UTF-8?q?=20G=20=E4=BB=A3=E7=A0=81=E8=AF=AD=E6=B3=95=E5=B9=B6=E4=B8=A5?= =?UTF-8?q?=E6=A0=BC=E6=B5=8B=E8=AF=95=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 总结: 对齐 LinuxCNC read_g 的 G80 特例:同一行 G80 与另一个运动模态 G 码共存时不触发同组冲突;新增 G80 G1 与 G1 G80 用例。已通过 ./test-native.sh 和 ./test-linuxcnc-source-link.sh。 --- core/src/smoke_gcode_parser.cpp | 11 ++++++++--- core/tests/cnc_sim_api_smoke.cpp | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/core/src/smoke_gcode_parser.cpp b/core/src/smoke_gcode_parser.cpp index 422dd79..13eb3c9 100644 --- a/core/src/smoke_gcode_parser.cpp +++ b/core/src/smoke_gcode_parser.cpp @@ -644,21 +644,26 @@ int supported_linuxcnc_m_modal_group(int value) { } bool check_linuxcnc_modal_group_conflicts(const std::vector &word_list, std::string *error) { - std::array g_modes{}; + std::array g_modes{}; std::array m_modes{}; + g_modes.fill(-1); for (const Word &word : word_list) { if (word.letter == 'G') { const int mode = supported_linuxcnc_g_modal_group(word.value); if (mode < 0) { continue; } - if (g_modes[static_cast(mode)]) { + const int code = linuxcnc_g_code_number(word.value); + const int previous_code = g_modes[static_cast(mode)]; + if (previous_code != -1 && previous_code != 800 && code != 800) { if (error) { *error = "Two G codes used from same modal group"; } return false; } - g_modes[static_cast(mode)] = true; + if (previous_code == -1 || previous_code == 800) { + g_modes[static_cast(mode)] = code; + } } else if (word.letter == 'M') { const int mode = supported_linuxcnc_m_modal_group(rounded_value(word.value)); if (mode < 0) { diff --git a/core/tests/cnc_sim_api_smoke.cpp b/core/tests/cnc_sim_api_smoke.cpp index d78e9b8..bc1c5c3 100644 --- a/core/tests/cnc_sim_api_smoke.cpp +++ b/core/tests/cnc_sim_api_smoke.cpp @@ -3582,6 +3582,26 @@ int main() { sizeof(same_modal_group_g_program) - 1) != 0, "expected LinuxCNC to reject two G codes from the same modal group"); + const char g80_before_motion_program[] = + "G21 G90\n" + "F100\n" + "G80 G1 X1\n"; + events.clear(); + ok &= expect(cnc_sim_parse_program(sim, + g80_before_motion_program, + sizeof(g80_before_motion_program) - 1) == 0, + "expected LinuxCNC to allow G80 before another motion G code"); + + const char g80_after_motion_program[] = + "G21 G90\n" + "F100\n" + "G1 G80 X1\n"; + events.clear(); + ok &= expect(cnc_sim_parse_program(sim, + g80_after_motion_program, + sizeof(g80_after_motion_program) - 1) == 0, + "expected LinuxCNC to allow G80 after another motion G code"); + const char same_modal_group_m_program[] = "G21 G90\n" "M3 M4\n";