Import LinuxCNC source tree

This commit is contained in:
Wang Dequan
2026-08-20 06:17:39 +08:00
commit 2c814634c3
9429 changed files with 10556013 additions and 0 deletions

View File

@@ -0,0 +1 @@
Exercise parameter passing to user-defined code

View File

@@ -0,0 +1,17 @@
N..... USE_LENGTH_UNITS(CANON_UNITS_MM)
N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
N..... SET_G92_OFFSET(0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
N..... SET_XY_ROTATION(0.0000)
N..... SET_FEED_REFERENCE(CANON_XYZ)
N..... ON_RESET()
N..... MESSAGE(" M400 call_level= 1.000000 remap_level=1.000000")
N..... MESSAGE(" P word set: 47.110000")
N..... MESSAGE(" Q word set: 8.150000")
N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
N..... SET_XY_ROTATION(0.0000)
N..... SET_FEED_MODE(0, 0)
N..... SET_FEED_RATE(0.0000)
N..... STOP_SPINDLE_TURNING(0)
N..... SET_SPINDLE_MODE(0 0.0000)
N..... PROGRAM_END()
N..... ON_RESET()

View File

@@ -0,0 +1,18 @@
o<rm400> sub
(debug, M400 call_level= #<_call_level> remap_level=#<_remap_level>)
o100 if [EXISTS[#<P>]]
(debug, P word set: #<P>)
o100 else
(debug, P word missing)
o100 endif
o120 if [EXISTS[#<Q>]]
(debug, Q word set: #<Q>)
o120 else
(debug, Q word missing)
o120 endif
o<rm400> endsub
m2
%

View File

@@ -0,0 +1,9 @@
[EMC]
DEBUG=0
LOG_LEVEL=0
[RS274NGC]
SUBROUTINE_PATH = .
# M405 requires P- Q- and does NOT permit any other words in this block
REMAP=M400 modalgroup=5 argspec=PQ ngc=rm400

View File

@@ -0,0 +1,2 @@
M400 P47.11 Q8.15
M2

View File

@@ -0,0 +1,3 @@
#!/bin/bash
rs274 -i test.ini -g test.ngc | awk '{$1=""; print}'
exit "${PIPESTATUS[0]}"

View File

@@ -0,0 +1,3 @@
Exercise failed parameter passing to user-defined code
The required Q parameter is missing

View File

@@ -0,0 +1,17 @@
executing
1 N..... USE_LENGTH_UNITS(CANON_UNITS_MM)
2 N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
3 N..... SET_G92_OFFSET(0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
4 N..... SET_XY_ROTATION(0.0000)
5 N..... SET_FEED_REFERENCE(CANON_XYZ)
6 N..... ON_RESET()
user-defined M400: missing: Q
O <rm400> call
7 N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
8 N..... SET_XY_ROTATION(0.0000)
9 N..... SET_FEED_MODE(0, 0)
10 N..... SET_FEED_RATE(0.0000)
11 N..... STOP_SPINDLE_TURNING(0)
12 N..... SET_SPINDLE_MODE(0 0.0000)
13 N..... PROGRAM_END()
14 N..... ON_RESET()

View File

@@ -0,0 +1,18 @@
o<rm400> sub
(debug, M400 call_level= #<_call_level> remap_level=#<_remap_level>)
o100 if [EXISTS[#<P>]]
(debug, P word set: #<P>)
o100 else
(debug, P word missing)
o100 endif
o120 if [EXISTS[#<Q>]]
(debug, Q word set: #<Q>)
o120 else
(debug, Q word missing)
o120 endif
o<rm400> endsub
m2
%

View File

@@ -0,0 +1,9 @@
[EMC]
DEBUG=0
LOG_LEVEL=0
[RS274NGC]
SUBROUTINE_PATH = .
# M405 requires P- Q- and does NOT permit any other words in this block
REMAP=M400 modalgroup=5 argspec=PQ ngc=rm400

View File

@@ -0,0 +1,2 @@
M400 P47.11
M2

View File

@@ -0,0 +1,3 @@
#!/bin/bash
rs274 -i test.ini -n 0 -g test.ngc 2>&1
exit "${PIPESTATUS[0]}"

View File

@@ -0,0 +1,3 @@
Exercise failed parameter passing to user-defined code
The required Q parameter is missing

View File

@@ -0,0 +1,17 @@
executing
1 N..... USE_LENGTH_UNITS(CANON_UNITS_MM)
2 N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
3 N..... SET_G92_OFFSET(0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
4 N..... SET_XY_ROTATION(0.0000)
5 N..... SET_FEED_REFERENCE(CANON_XYZ)
6 N..... ON_RESET()
user-defined M400: missing: P,Q
O <rm400> call
7 N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
8 N..... SET_XY_ROTATION(0.0000)
9 N..... SET_FEED_MODE(0, 0)
10 N..... SET_FEED_RATE(0.0000)
11 N..... STOP_SPINDLE_TURNING(0)
12 N..... SET_SPINDLE_MODE(0 0.0000)
13 N..... PROGRAM_END()
14 N..... ON_RESET()

View File

@@ -0,0 +1,18 @@
o<rm400> sub
(debug, M400 call_level= #<_call_level> remap_level=#<_remap_level>)
o100 if [EXISTS[#<P>]]
(debug, P word set: #<P>)
o100 else
(debug, P word missing)
o100 endif
o120 if [EXISTS[#<Q>]]
(debug, Q word set: #<Q>)
o120 else
(debug, Q word missing)
o120 endif
o<rm400> endsub
m2
%

View File

@@ -0,0 +1,9 @@
[EMC]
DEBUG=0
LOG_LEVEL=0
[RS274NGC]
SUBROUTINE_PATH = .
# M405 requires P- Q- and does NOT permit any other words in this block
REMAP=M400 modalgroup=5 argspec=PQ ngc=rm400

View File

@@ -0,0 +1,2 @@
M400 R122.25
M2

View File

@@ -0,0 +1,3 @@
#!/bin/bash
rs274 -i test.ini -n 0 -g test.ngc 2>&1
exit "${PIPESTATUS[0]}"

View File

@@ -0,0 +1 @@
Exercise failed remap NGC procedure - must properly return to top level

View File

@@ -0,0 +1,20 @@
executing
1 N..... USE_LENGTH_UNITS(CANON_UNITS_MM)
2 N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
3 N..... SET_G92_OFFSET(0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
4 N..... SET_XY_ROTATION(0.0000)
5 N..... SET_FEED_REFERENCE(CANON_XYZ)
6 N..... ON_RESET()
7 N..... MESSAGE(" before M400: call_level= 0.000000 remap_level=0.000000")
8 N..... MESSAGE(" in rm400: call_level= 1.000000 remap_level=1.000000")
Attempt to divide by zero
#100 = [1/0]
9 N..... MESSAGE(" after failed M400: call_level= 0.000000 remap_level=0.000000")
10 N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
11 N..... SET_XY_ROTATION(0.0000)
12 N..... SET_FEED_MODE(0, 0)
13 N..... SET_FEED_RATE(0.0000)
14 N..... STOP_SPINDLE_TURNING(0)
15 N..... SET_SPINDLE_MODE(0 0.0000)
16 N..... PROGRAM_END()
17 N..... ON_RESET()

View File

@@ -0,0 +1,6 @@
o<rm400> sub
(debug, in rm400: call_level= #<_call_level> remap_level=#<_remap_level>)
#100 = [1/0]
o<rm400> endsub
m2
%

View File

@@ -0,0 +1,9 @@
[EMC]
DEBUG=0
LOG_LEVEL=0
[RS274NGC]
SUBROUTINE_PATH = .
REMAP=M400 modalgroup=5 ngc=rm400

View File

@@ -0,0 +1,4 @@
(debug, before M400: call_level= #<_call_level> remap_level=#<_remap_level>)
M400
(debug, after failed M400: call_level= #<_call_level> remap_level=#<_remap_level>)
M2

View File

@@ -0,0 +1,3 @@
#!/bin/bash
rs274 -i test.ini -n 0 -g test.ngc 2>&1
exit "${PIPESTATUS[0]}"

View File

@@ -0,0 +1,3 @@
Exercise failed remap NGC procedure
must properly return to top level, convey error text

View File

@@ -0,0 +1,11 @@
executing
1 N..... USE_LENGTH_UNITS(CANON_UNITS_MM)
2 N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
3 N..... SET_G92_OFFSET(0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
4 N..... SET_XY_ROTATION(0.0000)
5 N..... SET_FEED_REFERENCE(CANON_XYZ)
6 N..... ON_RESET()
7 N..... MESSAGE(" before M400: call_level= 0.000000 remap_level=0.000000")
A failed Python remap handler returning INTERP_ERROR
O <interp_error> call
8 N..... ON_RESET()

View File

@@ -0,0 +1,24 @@
# This is a component of LinuxCNC
# Copyright 2011 Michael Haberler <git@mah.priv.at>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
import interpreter
def interp_error(self, **words):
self.set_errormsg("A failed Python remap handler returning INTERP_ERROR")
return interpreter.INTERP_ERROR

View File

@@ -0,0 +1,21 @@
# This is a component of LinuxCNC
# Copyright 2011 Michael Haberler <git@mah.priv.at>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
import remap

View File

@@ -0,0 +1,13 @@
[EMC]
DEBUG=0
LOG_LEVEL=0
[PYTHON]
PATH_PREPEND=.
TOPLEVEL=subs.py
LOG_LEVEL=0
[RS274NGC]
REMAP=M400 modalgroup=5 py=interp_error
LOG_LEVEL=0

View File

@@ -0,0 +1,4 @@
(debug, before M400: call_level= #<_call_level> remap_level=#<_remap_level>)
M400
(debug, after failed M400: call_level= #<_call_level> remap_level=#<_remap_level>)
M2

View File

@@ -0,0 +1,3 @@
#!/bin/bash
export PYTHONUNBUFFERED=1
! rs274 -i test.ini -n 2 -g test.ngc 2>&1

View File

@@ -0,0 +1,3 @@
Exercise CANON_ERROR
.. including embedding printf format-specifiers in the error string

View File

@@ -0,0 +1,20 @@
executing
1 N..... USE_LENGTH_UNITS(CANON_UNITS_MM)
2 N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
3 N..... SET_G92_OFFSET(0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
4 N..... SET_XY_ROTATION(0.0000)
5 N..... SET_FEED_REFERENCE(CANON_XYZ)
6 N..... ON_RESET()
7 N..... MESSAGE(" before M400: call_level= 0.000000 remap_level=0.000000")
8 N..... CANON_ERROR(%s is a literal percent s)
A failed Python prolog returning INTERP_ERROR
O <notcalled> call
9 N..... MESSAGE(" after failed M400: call_level= 0.000000 remap_level=0.000000")
10 N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
11 N..... SET_XY_ROTATION(0.0000)
12 N..... SET_FEED_MODE(0, 0)
13 N..... SET_FEED_RATE(0.0000)
14 N..... STOP_SPINDLE_TURNING(0)
15 N..... SET_SPINDLE_MODE(0 0.0000)
16 N..... PROGRAM_END()
17 N..... ON_RESET()

View File

@@ -0,0 +1,24 @@
# Copyright (C) 2013 Jeff Epler <jepler@unpythonic.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import emccanon
import interpreter
def failingprolog(self,*args, **words):
emccanon.CANON_ERROR("%s is a literal percent s")
self.set_errormsg("A failed Python prolog returning INTERP_ERROR")
return interpreter.INTERP_ERROR

View File

@@ -0,0 +1,16 @@
# Copyright (C) 2013 Jeff Epler <jepler@unpythonic.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import remap

View File

@@ -0,0 +1,15 @@
[EMC]
DEBUG=0
LOG_LEVEL=0
[RS274NGC]
SUBROUTINE_PATH = .
REMAP=M400 modalgroup=5 prolog=failingprolog ngc=notcalled
[PYTHON]
PATH_PREPEND=.
TOPLEVEL=subs.py

View File

@@ -0,0 +1,4 @@
(debug, before M400: call_level= #<_call_level> remap_level=#<_remap_level>)
M400
(debug, after failed M400: call_level= #<_call_level> remap_level=#<_remap_level>)
M2

View File

@@ -0,0 +1,5 @@
#!/bin/bash
export PYTHONUNBUFFERED=1
rs274 -i test.ini -n 0 -g test.ngc 2>&1
# expected to fail
exit 0

View File

@@ -0,0 +1,3 @@
Exercise failed prolog for a remap NGC procedure
must properly return to top level, convey error text

View File

@@ -0,0 +1,13 @@
executing
1 N..... USE_LENGTH_UNITS(CANON_UNITS_MM)
2 N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
3 N..... SET_G92_OFFSET(0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
4 N..... SET_XY_ROTATION(0.0000)
5 N..... SET_FEED_REFERENCE(CANON_XYZ)
6 N..... ON_RESET()
7 N..... MESSAGE(" before M400: call_level= 0.000000 remap_level=0.000000")
8 N..... MESSAGE(" I should complain if I weren't called but I guess I can not do that")
9 N..... MESSAGE("failing_epilog returning INTERP_ERROR")
A failed Python epilog returning INTERP_ERROR
o<mustbecalled>endsub
10 N..... ON_RESET()

View File

@@ -0,0 +1,4 @@
o<mustbecalled>sub
(debug, I should complain if I weren't called but I guess I can not do that)
o<mustbecalled>endsub
m2

View File

@@ -0,0 +1,26 @@
# This is a component of LinuxCNC
# Copyright 2011 Michael Haberler <git@mah.priv.at>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
import emccanon
import interpreter
def failingepilog(self,*args, **words):
emccanon.MESSAGE("failing_epilog returning INTERP_ERROR")
self.set_errormsg("A failed Python epilog returning INTERP_ERROR")
return interpreter.INTERP_ERROR

View File

@@ -0,0 +1,19 @@
# This is a component of LinuxCNC
# Copyright 2011 Michael Haberler <git@mah.priv.at>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
import remap

View File

@@ -0,0 +1,15 @@
[EMC]
DEBUG=0
LOG_LEVEL=0
[PYTHON]
PATH_PREPEND=.
TOPLEVEL=subs.py
LOG_LEVEL=0
[RS274NGC]
LOG_LEVEL=0
SUBROUTINE_PATH = .
REMAP=M400 modalgroup=5 ngc=mustbecalled epilog=failingepilog

View File

@@ -0,0 +1,7 @@
(debug, before M400: call_level= #<_call_level> remap_level=#<_remap_level>)
M400
(this should NOT execute because the failed epilog is supposed to abort!)
(debug, after failed M400: call_level= #<_call_level> remap_level=#<_remap_level>)
M2

View File

@@ -0,0 +1,3 @@
#!/bin/bash
export PYTHONUNBUFFERED=1
! rs274 -i test.ini -n 2 -g test.ngc 2>&1

View File

@@ -0,0 +1,3 @@
Exercise failed prolog for a remap NGC procedure
must properly return to top level, convey error text

View File

@@ -0,0 +1,20 @@
executing
1 N..... USE_LENGTH_UNITS(CANON_UNITS_MM)
2 N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
3 N..... SET_G92_OFFSET(0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
4 N..... SET_XY_ROTATION(0.0000)
5 N..... SET_FEED_REFERENCE(CANON_XYZ)
6 N..... ON_RESET()
7 N..... MESSAGE(" before M400: call_level= 0.000000 remap_level=0.000000")
8 N..... MESSAGE("failingprolog returning INTERP_ERROR")
A failed Python prolog returning INTERP_ERROR
O <notcalled> call
9 N..... MESSAGE(" after failed M400: call_level= 0.000000 remap_level=0.000000")
10 N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
11 N..... SET_XY_ROTATION(0.0000)
12 N..... SET_FEED_MODE(0, 0)
13 N..... SET_FEED_RATE(0.0000)
14 N..... STOP_SPINDLE_TURNING(0)
15 N..... SET_SPINDLE_MODE(0 0.0000)
16 N..... PROGRAM_END()
17 N..... ON_RESET()

View File

View File

@@ -0,0 +1,26 @@
# This is a component of LinuxCNC
# Copyright 2011 Michael Haberler <git@mah.priv.at>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
import emccanon
import interpreter
def failingprolog(self,*args, **words):
emccanon.MESSAGE("failingprolog returning INTERP_ERROR")
self.set_errormsg("A failed Python prolog returning INTERP_ERROR")
return interpreter.INTERP_ERROR

View File

@@ -0,0 +1,18 @@
# This is a component of LinuxCNC
# Copyright 2011 Michael Haberler <git@mah.priv.at>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
import remap

View File

@@ -0,0 +1,15 @@
[EMC]
DEBUG=0
LOG_LEVEL=0
[RS274NGC]
SUBROUTINE_PATH = .
REMAP=M400 modalgroup=5 prolog=failingprolog ngc=notcalled
[PYTHON]
PATH_PREPEND=.
TOPLEVEL=subs.py

View File

@@ -0,0 +1,4 @@
(debug, before M400: call_level= #<_call_level> remap_level=#<_remap_level>)
M400
(debug, after failed M400: call_level= #<_call_level> remap_level=#<_remap_level>)
M2

View File

@@ -0,0 +1,5 @@
#!/bin/bash
export PYTHONUNBUFFERED=1
rs274 -i test.ini -n 0 -g test.ngc 2>&1
# expected to fail
exit 0