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

6
tests/mdi-queue/.gitignore vendored Normal file
View File

@@ -0,0 +1,6 @@
dump.rdb
expected-gcode-output
lots-of-gcode
gcode-output
sim.var
sim.var.bak

View File

@@ -0,0 +1,104 @@
[EMC]
DEBUG = 0x7FFFFFFF
VERSION = 1.1
#DEBUG = 0
[DISPLAY]
DISPLAY = linuxcncrsh --path=./
[TASK]
TASK = milltask
CYCLE_TIME = 0.001
[RS274NGC]
PARAMETER_FILE = sim.var
USER_M_PATH = ../subs
SUBROUTINE_PATH = ../subs
#LOG_LEVEL = 99999999
[EMCMOT]
EMCMOT = motmod
COMM_TIMEOUT = 4.0
BASE_PERIOD = 0
SERVO_PERIOD = 1000000
[HAL]
HALFILE = LIB:core_sim.hal
[TRAJ]
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
NO_FORCE_HOMING = 1
[AXIS_X]
HOME = 0.000
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
MAX_VELOCITY = 4
MAX_ACCELERATION = 100.0
[AXIS_Y]
HOME = 0.000
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
MAX_VELOCITY = 4
MAX_ACCELERATION = 100.0
[AXIS_Z]
HOME = 0.0
MIN_LIMIT = -4.0
MAX_LIMIT = 4.0
MAX_VELOCITY = 4
MAX_ACCELERATION = 100.0
[KINS]
KINEMATICS = trivkins
JOINTS = 3
[JOINT_0]
TYPE = LINEAR
HOME = 0.000
MAX_LINEAR_VELOCITY = 4
MAX_LINEAR_ACCELERATION = 100.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
[JOINT_1]
TYPE = LINEAR
HOME = 0.000
MAX_VELOCITY = 4
MAX_ACCELERATION = 100.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
[JOINT_2]
TYPE = LINEAR
HOME = 0.0
MAX_VELOCITY = 4
MAX_ACCELERATION = 100.0
BACKLASH = 0.000
INPUT_SCALE = 4000
OUTPUT_SCALE = 1.000
MIN_LIMIT = -4.0
MAX_LIMIT = 4.0
FERROR = 0.050
MIN_FERROR = 0.010
[EMCIO]
TOOL_TABLE = tool.tbl

View File

@@ -0,0 +1 @@
../shared-checkresult

View File

@@ -0,0 +1,5 @@
g53 g0 x0 y0 z0
m2

View File

@@ -0,0 +1 @@
../linuxcncrsh-test.ini

View File

@@ -0,0 +1,101 @@
#!/bin/bash
rm -f gcode-output
if ! command -v nc ; then
echo "E: Binary 'nc' not in PATH or not installed."
exit 1
fi
if ! command -v linuxcnc ; then
echo "E: Binary 'linuxcnc' not in PATH or not installed."
exit 1
fi
if nc -z localhost 5007; then
echo "E: Process already listening on port 5007. Exiting"
exit 1
fi
linuxcnc -r linuxcncrsh-test.ini &
# let linuxcnc come up
TOGO=80
while [ $TOGO -gt 0 ]; do
echo "I: trying to connect to linuxcncrsh TOGO=$TOGO"
if nc -z localhost 5007; then
break
fi
sleep 0.25
TOGO=$((TOGO - 1))
done
if [ $TOGO -eq 0 ]; then
echo "E: connection to linuxcncrsh timed out"
exit 1
fi
# switch back and forth between tool 1 and tool 2 every few MDI calls
rm -f expected-gcode-output lots-of-gcode
echo "P is -100.000000" >> expected-gcode-output
NUM_MDIS=1
NUM_MDIS_LEFT=$NUM_MDIS
TOOL=1
for i in $(seq 0 1000); do
NUM_MDIS_LEFT=$((NUM_MDIS_LEFT - 1))
if [ $NUM_MDIS_LEFT -eq 0 ]; then
echo "set mdi o<queue-buster> call [$TOOL]" >> lots-of-gcode
{
echo "P is 12345.000000"
echo "P is $((-1 * TOOL)).000000"
echo "P is 54321.000000"
} >> expected-gcode-output
if [ $TOOL -eq 1 ]; then
TOOL=2
else
TOOL=1
fi
NUM_MDIS=$((NUM_MDIS + 1))
if [ $NUM_MDIS -gt 10 ]; then
NUM_MDIS=1
fi
NUM_MDIS_LEFT=$NUM_MDIS
fi
echo "set mdi m100 p$i" >> lots-of-gcode
echo "P is $i.000000" >> expected-gcode-output
done
echo "P is -200.000000" >> expected-gcode-output
(
echo "hello EMC mt 1.0"
echo "set enable EMCTOO"
echo "set mode manual"
echo "set estop off"
echo "set machine on"
echo "set mode auto"
echo "set open dummy.ngc"
echo "set mode mdi"
echo "set mdi m100 p-100"
echo "set wait done"
# here comes a big blob
dd bs=4096 if=lots-of-gcode
echo "set mdi m100 p-200"
echo "set wait done"
echo shutdown
) | nc localhost 5007
# wait for linuxcnc to finish
wait
exit 0

View File

@@ -0,0 +1 @@
../tool.tbl

View File

@@ -0,0 +1,6 @@
#!/bin/bash
TEST_DIR=$(dirname "$1")
cd "$TEST_DIR" || { echo "E: Could not change directory to '$TEST_DIR'"; exit 1; }
diff -u expected-gcode-output gcode-output

View File

@@ -0,0 +1 @@
../shared-checkresult

View File

@@ -0,0 +1 @@
../linuxcncrsh-test.ini

View File

@@ -0,0 +1,96 @@
#!/bin/bash
rm -f gcode-output
if ! command -v nc ; then
echo "E: Binary 'nc' not in PATH or not installed."
exit 1
fi
if ! command -v linuxcnc ; then
echo "E: Binary 'linuxcnc' not in PATH or not installed."
exit 1
fi
if nc -z localhost 5007; then
echo "E: Process already listening on port 5007. Exiting"
exit 1
fi
linuxcnc -r linuxcncrsh-test.ini &
# let linuxcnc come up
TOGO=80
while [ $TOGO -gt 0 ]; do
echo "I: trying to connect to linuxcncrsh TOGO=$TOGO"
if nc -z localhost 5007; then
break
fi
sleep 0.25
TOGO=$((TOGO - 1))
done
if [ $TOGO -eq 0 ]; then
echo connection to linuxcncrsh timed out
exit 1
fi
# switch back and forth between tool 1 and tool 2 every few MDI calls
rm -f expected-gcode-output lots-of-gcode
echo "P is -1.000000" >> expected-gcode-output
NUM_MDIS=1
NUM_MDIS_LEFT=$NUM_MDIS
TOOL=1
for i in $(seq 0 1000); do
NUM_MDIS_LEFT=$((NUM_MDIS_LEFT - 1))
if [ $NUM_MDIS_LEFT -eq 0 ]; then
echo "set mdi t$TOOL m6" >> lots-of-gcode
if [ $TOOL -eq 1 ]; then
TOOL=2
else
TOOL=1
fi
NUM_MDIS=$((NUM_MDIS + 1))
if [ $NUM_MDIS -gt 10 ]; then
NUM_MDIS=1
fi
NUM_MDIS_LEFT=$NUM_MDIS
fi
echo "set mdi m100 p$i" >> lots-of-gcode
echo "P is $i.000000" >> expected-gcode-output
done
echo "P is -2.000000" >> expected-gcode-output
(
echo "hello EMC mt 1.0"
echo "set enable EMCTOO"
# ask linuxcncrsh to not read the next command until it's done running
# the current one
#echo "set set_wait done"
echo "set mode manual"
echo "set estop off"
echo "set machine on"
echo "set mode mdi"
echo "set mdi m100 p-1"
echo "set wait done"
# here comes a big blob
dd bs=4096 if=lots-of-gcode
echo "set mdi m100 p-2"
echo "set wait done"
echo "shutdown"
) | nc localhost 5007
# wait for linuxcnc to finish
wait
exit 0

View File

@@ -0,0 +1 @@
../tool.tbl

17
tests/mdi-queue/subs/M100 Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
#
# This script (M100) is called to append an integer to a log file,
# for testing purposes
#
# Put this in your INI to use:
#
# [RS274NGC]USER_M_PATH = ./subs
#
TEST_DIR=$(dirname INI_FILE_NAME)
OUT_FILE=$TEST_DIR/gcode-output
P=$1
echo "P is $P" >> "$OUT_FILE"

View File

@@ -0,0 +1,11 @@
o<queue-buster> sub
m100 p12345
t#1
m6
m100 p-#5400 ; current tool
m100 p54321
o<queue-buster> endsub

2
tests/mdi-queue/tool.tbl Normal file
View File

@@ -0,0 +1,2 @@
T1 P1 D0.125000 Z+1.000000 ;
T2 P2 ;