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,2 @@
extend predefined named parameters by Python functions
assert they do the right thing

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..... SET_FEED_RATE(100.0000)
8 N..... SET_SPINDLE_SPEED(0, 300.0000)
9 N..... START_SPINDLE_CLOCKWISE(0)
10 N..... STRAIGHT_FEED(1.0000, 1.0000, 0.0000, 0.0000, 0.0000, 0.0000)
11 N..... COMMENT("interpreter: motion mode set to none")
12 N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
13 N..... SET_XY_ROTATION(0.0000)
14 N..... SET_FEED_MODE(0, 0)
15 N..... SET_FEED_RATE(0.0000)
16 N..... STOP_SPINDLE_TURNING(0)
17 N..... SET_SPINDLE_MODE(0 0.0000)
18 N..... PROGRAM_END()
19 N..... ON_RESET()

View File

@@ -0,0 +1,33 @@
# This is a component of LinuxCNC
# Copyright 2012 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.
#
# trivial example
def _pi(self, *args):
return 3.1415926535
# the Python equivalent of '#<_motion_mode> :
# return the currently active motion code (times 10)
def _py_motion_mode(self, *args):
return self.active_g_codes[1]
def _error(self, *args):
# this sets the error message and aborts execution (except in (debug,#<_err>))
return "badly botched"
# return a whacky type to exercise the error reporting mechanism
def _badreturntype(self, *args):
return object()

View File

@@ -0,0 +1,18 @@
# This is a component of LinuxCNC
# Copyright 2012 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 namedparams

View File

@@ -0,0 +1,10 @@
[EMC]
DEBUG=0
[RS274NGC]
SUBROUTINE_PATH = .
LOG_LEVEL=0
[PYTHON]
PATH_PREPEND=.
TOPLEVEL=subs.py

View File

@@ -0,0 +1,34 @@
; add a python predefined named parameter which does the same thing as the builtin
; _motion_mode
; assert accessibility and results at Python and NGC level
;py,from interpreter import *
; basic value access:
;py,assert this.params["_pi"] == 3.1415926535
; _py_motion_mode: it's a Python predefined variable (32), global (1) and readonly (2)
; see interp_internal.hh, #defines for PA_*
;py,assert this.sub_context[0].named_params["_py_motion_mode"].attr == 35
s300m3f100
g1 x1 y1
;py,assert this.params["_motion_mode"] == 10
;py,assert this.params["_py_motion_mode"] == 10
o100 if [#<_motion_mode> NE 10]
(abort,_motion_mode != 10: #<_motion_mode>)
o100 endif
o200 if [#<_py_motion_mode> NE 10]
(abort,_py_motion_mode != 10: #<_py_motion_mode>)
o200 endif
g80
;py,assert this.params["_motion_mode"] == 800
;py,assert this.params["_py_motion_mode"] == 800
o300 if [#<_motion_mode> NE 800]
(abort,_motion_mode != 800: #<_motion_mode>)
o300 endif
o400 if [#<_py_motion_mode> NE 800]
(abort,_py_motion_mode != 800: #<_py_motion_mode>)
o400 endif
m2

View File

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