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,5 @@
Exercise a Python oword subroutine, including parameter passing and return values
not a remap, but it comes with the remapping code so test it here.
must properly return to top level

View File

@@ -0,0 +1,42 @@
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 introspect: call_level= 0.000000")
8 N..... SELECT_TOOL(3)
9 N..... STOP_SPINDLE_TURNING(0)
10 N..... CHANGE_TOOL()
11 N..... SET_FEED_RATE(200.0000)
12 N..... SET_SPINDLE_SPEED(0, 3000.0000)
13 N..... START_SPINDLE_CLOCKWISE(0)
debug: 1073741824 logging: 0
call_level= 1
argc= 4
args=( 1.00000 2.00000 3.00000 3.14159 )
param # 0 = 1.0
param # 1 = 2.0
param # 2 = 3.0
param # 3 = 3.14159
current oword subname= introspect
m_modes[0]= -1
g_modes[0]= -1
current tool= 3.0 3.0
feed= 200.0
speed= 3000.0
global parameter set in test.ngc: 47.11
parameter set via test.ini: 3.14159
locals: ['a_new_local']
globals: ['_a', '_a_global_set_in_test_dot_ngc', '_a_new_global', '_abs_a', '_abs_b', '_abs_c', '_abs_u', '_abs_v', '_abs_w', '_abs_x', '_abs_y', '_abs_z', '_absolute', '_adaptive_feed', '_b', '_c', '_call_level', '_ccomp', '_coord_system', '_current_pocket', '_current_tool', '_feed', '_feed_hold', '_feed_override', '_flood', '_ijk_absolute_mode', '_imperial', '_incremental', '_ini[example]variable', '_inverse_time', '_lathe_diameter_mode', '_lathe_radius_mode', '_line', '_metric', '_metric_machine', '_mist', '_motion_mode', '_plane', '_remap_level', '_retract_old_z', '_retract_r_plane', '_rpm', '_selected_pocket', '_selected_tool', '_speed_override', '_spindle_css_mode', '_spindle_cw', '_spindle_on', '_spindle_rpm_mode', '_task', '_tool_offset', '_u', '_units_per_minute', '_units_per_rev', '_v', '_value', '_value_returned', '_vmajor', '_vminor', '_w', '_x', '_y', '_z', 'foo']
params(): ['a_new_local', '_a', '_a_global_set_in_test_dot_ngc', '_a_new_global', '_abs_a', '_abs_b', '_abs_c', '_abs_u', '_abs_v', '_abs_w', '_abs_x', '_abs_y', '_abs_z', '_absolute', '_adaptive_feed', '_b', '_c', '_call_level', '_ccomp', '_coord_system', '_current_pocket', '_current_tool', '_feed', '_feed_hold', '_feed_override', '_flood', '_ijk_absolute_mode', '_imperial', '_incremental', '_ini[example]variable', '_inverse_time', '_lathe_diameter_mode', '_lathe_radius_mode', '_line', '_metric', '_metric_machine', '_mist', '_motion_mode', '_plane', '_remap_level', '_retract_old_z', '_retract_r_plane', '_rpm', '_selected_pocket', '_selected_tool', '_speed_override', '_spindle_css_mode', '_spindle_cw', '_spindle_on', '_spindle_rpm_mode', '_task', '_tool_offset', '_u', '_units_per_minute', '_units_per_rev', '_v', '_value', '_value_returned', '_vmajor', '_vminor', '_w', '_x', '_y', '_z', 'foo']
14 N..... MESSAGE(" after introspect: return value=2.718280 call_level= 0.000000")
15 N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
16 N..... SET_XY_ROTATION(0.0000)
17 N..... SET_FEED_MODE(0, 0)
18 N..... SET_FEED_RATE(0.0000)
19 N..... STOP_SPINDLE_TURNING(0)
20 N..... SET_SPINDLE_MODE(0 0.0000)
21 N..... PROGRAM_END()
22 N..... ON_RESET()

View File

@@ -0,0 +1,3 @@
o<foo> sub
o<foo> ebdsub
m2

View File

@@ -0,0 +1,80 @@
# This is a component of LinuxCNC
# Copyright 2011, 2012, 2013 Michael Haberler <git@mah.priv.at>,
# Sebastian Kuzminsky <seb@highlab.com>
#
# 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
EMC_DEBUG_CONFIG = 0x00000002
EMC_DEBUG_VERSIONS = 0x00000008
EMC_DEBUG_TASK_ISSUE = 0x00000010
EMC_DEBUG_NML = 0x00000040
EMC_DEBUG_MOTION_TIME = 0x00000080
EMC_DEBUG_INTERP = 0x00000100
EMC_DEBUG_RCS = 0x00000200
EMC_DEBUG_INTERP_LIST = 0x00000800
EMC_DEBUG_IOCONTROL = 0x00001000
EMC_DEBUG_OWORD = 0x00002000
EMC_DEBUG_REMAP = 0x00004000
EMC_DEBUG_PYTHON = 0x00008000
EMC_DEBUG_NAMEDPARAM = 0x00010000
EMC_DEBUG_GDBONSIGNAL = 0x00020000
def introspect(self,*args):
print("debug: ", self.debugmask,"logging:",self.loggingLevel)
print("call_level=",self.call_level)
print("argc=", len(args))
print("args=(", end=' ')
for arg in args:
if type(arg) == float:
print("%0.5f" % arg, end=' ')
else:
print(arg, end=' ')
print(")")
# the low-level access within the block
for n in range(len(args)):
print("param #",n ,"=", self.blocks[0].params[n])
# this is a low-level interface.
for x in self.sub_context[1].named_params:
print("name:",x.key(),"value=",x.data().value, "attr=",x.data().attr)
#for r in self.remaps:
# print r.key(), str(r.data())
print("current oword subname=", self.blocks[0].o_name)
print("m_modes[0]=", self.blocks[0].m_modes[0])
print("g_modes[0]=", self.blocks[0].g_modes[0])
# this is the high level named & numbered parameter interface
print("current tool=",self.params[5400],self.params["_current_tool"])
print("feed=",self.params['_feed'])
print("speed=",self.params['_rpm'])
print("global parameter set in test.ngc:",self.params['_a_global_set_in_test_dot_ngc'])
print("parameter set via test.ini:",self.params['_ini[example]variable'])
assert self.params['_ini[example]variable'] == args[3]
self.params["a_new_local"] = 321.0
self.params["_a_new_global"] = 456.0
print("locals: ",self.params.locals())
print("globals: ",self.params.globals())
print("params(): ",self.params())
return 2.71828

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 oword

View File

@@ -0,0 +1,15 @@
[EMC]
DEBUG=0
[RS274NGC]
SUBROUTINE_PATH = .
LOG_LEVEL=0
INI_VARS = 1
REMAP= M123 ngc=foo modalgroup=5 argspec=Pq
[PYTHON]
PATH_PREPEND=.
TOPLEVEL=subs.py
[EXAMPLE]
VARIABLE = 3.14159

View File

@@ -0,0 +1,11 @@
#<_a_global_set_in_test_dot_ngc> = 47.11
(debug, before introspect: call_level= #<_call_level>)
#<foo> = 423432.2
T3M6
F200
S3000 M3
o<introspect> call [1.0] [2.0] [3.0] [#<_ini[example]variable>]
(debug, after introspect: return value=#<_value> call_level= #<_call_level>)
M2

3
tests/remap/introspect/test.sh Executable file
View File

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