按规划持续工作

This commit is contained in:
2026-06-09 06:13:28 +08:00
parent 902c6ecaea
commit 2658ee3b72
255 changed files with 12487 additions and 150 deletions

View File

@@ -0,0 +1,16 @@
This test verifies that M62-M68 can be remapped through both python
and NGC, and that calling the original M-codes is supported in the
remap subroutine.
It also serves as an example of how to do this, since esp. the M66
python function is not trivial and must be a generator yielding
`INTERP_EXECUTE_FINISH`.
The recursive call to the original functions needs supporting code for
mode 5 M-codes in `interp_convert.cc` `convert_m()`, and for M62-M68
in `rs274ngc_pre.cc`, `find_remappings()`.
The peculiar M66 needs special handling in the interpreter for
`input_flag`, and to ensure that its result (in param `#5399`) is
available within the remap, `Interp::pycall()` runs `read_inputs()`
before returning control back to the python generator.

View File

@@ -0,0 +1,123 @@
********** Testing python remaps
----Testing M62/M63 digital output w/motion----
cmd: "M62 P1"
M62 remapping pre: motion dout0=0; hal d_out=0
M62 remapping post: motion dout0=1; hal d_out=1
cmd: "M63 P1"
M63 remapping pre: motion dout0=1; hal d_out=1
M63 remapping post: motion dout0=0; hal d_out=0
cmd: "M62 P1"
M62 remapping pre: motion dout0=0; hal d_out=0
M62 remapping post: motion dout0=1; hal d_out=1
cmd: "M63 P1"
M63 remapping pre: motion dout0=1; hal d_out=1
M63 remapping post: motion dout0=0; hal d_out=0
----Testing M64/M65 digital output, immediate----
cmd: "M64 P1"
M64 remapping pre: motion dout0=0; hal d_out=0
M64 remapping post: motion dout0=1; hal d_out=1
cmd: "M65 P1"
M65 remapping pre: motion dout0=1; hal d_out=1
M65 remapping post: motion dout0=0; hal d_out=0
cmd: "M64 P1"
M64 remapping pre: motion dout0=0; hal d_out=0
M64 remapping post: motion dout0=1; hal d_out=1
cmd: "M65 P1"
M65 remapping pre: motion dout0=1; hal d_out=1
M65 remapping post: motion dout0=0; hal d_out=0
----Testing M66 digital input----
cmd: "M66 P1"; input: 1.0000
M66 remapping pre: 5399=0.000000; 100=0.000000; ain0=0.00; din0=0
M66 remapping post: 5399=1.000000; 100=1.000000; ain0=0.00; din0=1
cmd: "M66 P1"; input: 0.0000
M66 remapping pre: 5399=1.000000; 100=1.000000; ain0=0.00; din0=1
M66 remapping post: 5399=0.000000; 100=0.000000; ain0=0.00; din0=0
----Testing M66 analog input----
cmd: "M66 E1 L0"; input: 42.1300
M66 remapping pre: 5399=0.000000; 100=0.000000; ain0=0.00; din0=0
M66 remapping post: 5399=42.130000; 100=42.130000; ain0=42.13; din0=0
cmd: "M66 E1 L0"; input: -13.4200
M66 remapping pre: 5399=42.130000; 100=42.130000; ain0=42.13; din0=0
M66 remapping post: 5399=-13.420000; 100=-13.420000; ain0=-13.42; din0=0
----Testing M67 analog output w/motion----
cmd: "M67 E1 Q42.13"
M67 remapping pre: motion aout0=0.00; hal a_out=0.00
M67 remapping post: motion aout0=42.13; hal a_out=42.13
cmd: "M67 E1 Q-13.42"
M67 remapping pre: motion aout0=42.13; hal a_out=42.13
M67 remapping post: motion aout0=-13.42; hal a_out=-13.42
cmd: "M67 E1 Q0.00"
M67 remapping pre: motion aout0=-13.42; hal a_out=-13.42
M67 remapping post: motion aout0=0.00; hal a_out=0.00
----Testing M68 analog output, immediate----
cmd: "M68 E1 Q42.13"
M68 remapping pre: motion aout0=0.00; hal a_out=0.00
M68 remapping post: motion aout0=42.13; hal a_out=42.13
cmd: "M68 E1 Q-13.42"
M68 remapping pre: motion aout0=42.13; hal a_out=42.13
M68 remapping post: motion aout0=-13.42; hal a_out=-13.42
cmd: "M68 E1 Q0.00"
M68 remapping pre: motion aout0=-13.42; hal a_out=-13.42
M68 remapping post: motion aout0=0.00; hal a_out=0.00
********** Testing ngc remaps
----Testing M62/M63 digital output w/motion----
cmd: "M62 P1"
M62 remapping pre: motion dout0=0; hal d_out=0
M62 remapping post: motion dout0=1; hal d_out=1
cmd: "M63 P1"
M63 remapping pre: motion dout0=1; hal d_out=1
M63 remapping post: motion dout0=0; hal d_out=0
cmd: "M62 P1"
M62 remapping pre: motion dout0=0; hal d_out=0
M62 remapping post: motion dout0=1; hal d_out=1
cmd: "M63 P1"
M63 remapping pre: motion dout0=1; hal d_out=1
M63 remapping post: motion dout0=0; hal d_out=0
----Testing M64/M65 digital output, immediate----
cmd: "M64 P1"
M64 remapping pre: motion dout0=0; hal d_out=0
M64 remapping post: motion dout0=1; hal d_out=1
cmd: "M65 P1"
M65 remapping pre: motion dout0=1; hal d_out=1
M65 remapping post: motion dout0=0; hal d_out=0
cmd: "M64 P1"
M64 remapping pre: motion dout0=0; hal d_out=0
M64 remapping post: motion dout0=1; hal d_out=1
cmd: "M65 P1"
M65 remapping pre: motion dout0=1; hal d_out=1
M65 remapping post: motion dout0=0; hal d_out=0
----Testing M66 digital input----
cmd: "M66 P1"; input: 1.0000
M66 remapping pre: 5399=0.000000; 100=0.000000; ain0=0.00; din0=0
M66 remapping post: 5399=1.000000; 100=1.000000; ain0=0.00; din0=1
cmd: "M66 P1"; input: 0.0000
M66 remapping pre: 5399=1.000000; 100=1.000000; ain0=0.00; din0=1
M66 remapping post: 5399=0.000000; 100=0.000000; ain0=0.00; din0=0
----Testing M66 analog input----
cmd: "M66 E1 L0"; input: 42.1300
M66 remapping pre: 5399=0.000000; 100=0.000000; ain0=0.00; din0=0
M66 remapping post: 5399=42.130000; 100=42.130000; ain0=42.13; din0=0
cmd: "M66 E1 L0"; input: -13.4200
M66 remapping pre: 5399=42.130000; 100=42.130000; ain0=42.13; din0=0
M66 remapping post: 5399=-13.420000; 100=-13.420000; ain0=-13.42; din0=0
----Testing M67 analog output w/motion----
cmd: "M67 E1 Q42.13"
M67 remapping pre: motion aout0=0.00; hal a_out=0.00
M67 remapping post: motion aout0=42.13; hal a_out=42.13
cmd: "M67 E1 Q-13.42"
M67 remapping pre: motion aout0=42.13; hal a_out=42.13
M67 remapping post: motion aout0=-13.42; hal a_out=-13.42
cmd: "M67 E1 Q0.00"
M67 remapping pre: motion aout0=-13.42; hal a_out=-13.42
M67 remapping post: motion aout0=0.00; hal a_out=0.00
----Testing M68 analog output, immediate----
cmd: "M68 E1 Q42.13"
M68 remapping pre: motion aout0=0.00; hal a_out=0.00
M68 remapping post: motion aout0=42.13; hal a_out=42.13
cmd: "M68 E1 Q-13.42"
M68 remapping pre: motion aout0=42.13; hal a_out=42.13
M68 remapping post: motion aout0=-13.42; hal a_out=-13.42
cmd: "M68 E1 Q0.00"
M68 remapping pre: motion aout0=-13.42; hal a_out=-13.42
M68 remapping post: motion aout0=0.00; hal a_out=0.00

View File

@@ -0,0 +1,13 @@
o<io_input_M66> sub
(debug,X io_input_M66 remapping pre: 5399=#5399)
o<analog_or_digital> if [EXISTS[#<e>]]
; analog input
M66 E0 L0
o<analog_or_digital> else
; digital input
M66 P0 L0
o<analog_or_digital> endif
; Result should be available here after M66; save it for test to check
#100 = #5399
(debug,X io_input_M66 remapping post: 5399=#5399)
o<io_input_M66> endsub

View File

@@ -0,0 +1,5 @@
o<io_output_M62> sub
(debug,X io_output_M62 remapping pre: 5399=#5399)
M62 P0
(debug,X io_output_M62 remapping post: 5399=#5399)
o<io_output_M62> endsub

View File

@@ -0,0 +1,3 @@
o<io_output_M63> sub
M63 P0
o<io_output_M63> endsub

View File

@@ -0,0 +1,3 @@
o<io_output_M64> sub
M64 P0
o<io_output_M64> endsub

View File

@@ -0,0 +1,3 @@
o<io_output_M65> sub
M65 P0
o<io_output_M65> endsub

View File

@@ -0,0 +1,3 @@
o<io_output_M67> sub
M67 E0 Q#<Q>
o<io_output_M67> endsub

View File

@@ -0,0 +1,3 @@
o<io_output_M68> sub
M68 E0 Q#<Q>
o<io_output_M68> endsub

View File

@@ -0,0 +1,129 @@
# This config file was created 2017-05-10 09:59:22.679734 by the update_ini script
# The original config files may be found in the /home/jepler/src/linuxcnc/master/tests/remap/remap-io/test-ngc.old directory
[EMC]
# The version string for this INI file.
VERSION = 1.1
DEBUG = 0x0
[DISPLAY]
DISPLAY = ./test-ui.py
[FILTER]
#No Content
[RS274NGC]
PARAMETER_FILE = sim.var
SUBROUTINE_PATH = .
REMAP= M62 modalgroup=5 argspec=P ngc=io_output_m62
REMAP= M63 modalgroup=5 argspec=P ngc=io_output_m63
REMAP= M64 modalgroup=5 argspec=P ngc=io_output_m64
REMAP= M65 modalgroup=5 argspec=P ngc=io_output_m65
REMAP= M66 modalgroup=5 argspec=pelq ngc=io_input_m66
REMAP= M67 modalgroup=5 argspec=EQ ngc=io_output_m67
REMAP= M68 modalgroup=5 argspec=EQ ngc=io_output_m68
[EMCMOT]
EMCMOT = motmod
COMM_TIMEOUT = 4.0
BASE_PERIOD = 0
SERVO_PERIOD = 1000000
[TASK]
TASK = milltask
CYCLE_TIME = 0.001
[HAL]
HALUI = halui
HALFILE = core_sim.hal
[HALUI]
#No Content
[TRAJ]
NO_FORCE_HOMING=1
AXES = 3
COORDINATES = X Y Z
HOME = 0 0 0
LINEAR_UNITS = inch
ANGULAR_UNITS = degree
DEFAULT_LINEAR_VELOCITY = 1.2
MAX_LINEAR_VELOCITY = 4
[EMCIO]
TOOL_TABLE = simpockets.tbl
TOOL_CHANGE_QUILL_UP = 1
RANDOM_TOOLCHANGER = 0
[KINS]
KINEMATICS = trivkins
#This is a best-guess at the number of joints, it should be checked
JOINTS = 3
[AXIS_X]
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
MAX_VELOCITY = 4
MAX_ACCELERATION = 1000.0
[JOINT_0]
TYPE = LINEAR
HOME = 0.000
MAX_VELOCITY = 4
MAX_ACCELERATION = 1000.0
BACKLASH = 0.000
INPUT_SCALE = 4000
OUTPUT_SCALE = 1.000
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
FERROR = 0.050
MIN_FERROR = 0.010
[AXIS_Y]
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
MAX_VELOCITY = 4
MAX_ACCELERATION = 1000.0
[JOINT_1]
TYPE = LINEAR
HOME = 0.000
MAX_VELOCITY = 4
MAX_ACCELERATION = 1000.0
BACKLASH = 0.000
INPUT_SCALE = 4000
OUTPUT_SCALE = 1.000
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
FERROR = 0.050
MIN_FERROR = 0.010
[AXIS_Z]
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
MAX_VELOCITY = 4
MAX_ACCELERATION = 1000.0
[JOINT_2]
TYPE = LINEAR
HOME = 0.0
MAX_VELOCITY = 4
MAX_ACCELERATION = 1000.0
BACKLASH = 0.000
INPUT_SCALE = 4000
OUTPUT_SCALE = 1.000
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
FERROR = 0.050
MIN_FERROR = 0.010
[PYTHON]
TOPLEVEL= toplevel.py
PATH_PREPEND= .

View File

@@ -0,0 +1,13 @@
#!/bin/bash -e
export PYTHONUNBUFFERED=1
do_test() {
INI="$1"
linuxcnc -r "$INI" | grep -i m6
}
echo "********** Testing python remaps"
do_test test-py.ini
echo
echo "********** Testing ngc remaps"
do_test test-ngc.ini