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

15
debian/tests/linuxcnc-test vendored Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/sh
#
# Based on tests/single-step/
set -e
cd "$(dirname "$0")"
if ! linuxcnc -r linuxcnc-test.ini ; then
echo "error: failed to execute linuxcnc"
exit 1
fi
echo "success: linuxcnc ran successfully."
exit 0

88
debian/tests/linuxcnc-test-ui.py vendored Executable file
View File

@@ -0,0 +1,88 @@
#!/usr/bin/env python3
import linuxcnc
import linuxcnc_util
import hal
import time
import sys
import os
#
# connect to LinuxCNC
#
c = linuxcnc.command()
s = linuxcnc.stat()
e = linuxcnc.error_channel()
l = linuxcnc_util.LinuxCNC(command=c, status=s, error=e)
#
# Create and connect test feedback comp
#
h = hal.component("test-ui")
h.newpin("Xpos", hal.HAL_FLOAT, hal.HAL_IN)
h.newpin("Ypos", hal.HAL_FLOAT, hal.HAL_IN)
h.newpin("Zpos", hal.HAL_FLOAT, hal.HAL_IN)
h.newpin("counter", hal.HAL_FLOAT, hal.HAL_IN)
h.ready()
os.system("halcmd source ./linuxcnc-test.hal")
def print_state():
sys.stderr.write(
"line=%d; Xpos=%.2f; Ypos=%.2f; Zpos=%.2f; counter=%d\n" %
(s.current_line, h["Xpos"], h["Ypos"], h["Zpos"], h["counter"]))
#
# Come out of E-stop, turn the machine on, home, and switch to Auto mode.
#
c.state(linuxcnc.STATE_ESTOP_RESET)
c.state(linuxcnc.STATE_ON)
c.home(0)
c.home(1)
c.home(2)
l.wait_for_home([1, 1, 1, 0, 0, 0, 0, 0, 0])
c.mode(linuxcnc.MODE_AUTO)
#
# run the .ngc test file, starting from the special line
#
c.program_open('linuxcnc-test.ngc')
epsilon = 0.000001
def mod_5_is_0(x):
return abs((x+epsilon) % 5) < 2*epsilon
# Take first step
c.auto(linuxcnc.AUTO_STEP)
count = 0
while True:
s.poll()
(x, y) = (h["Xpos"], h["Ypos"])
if mod_5_is_0(x) and mod_5_is_0(y):
# Both axes on goal; make next step and let motion start
sys.stderr.write("Taking step from X%.2f Y%.2f\n" % (x, y))
c.auto(linuxcnc.AUTO_STEP)
time.sleep(0.1)
print_state()
count += 1
if count >= 1000: # Shouldn't happen, but prevent runaways
sys.stderr.write("Finished: Exceeded max cycles\n")
sys.exit(1)
if s.interp_state == linuxcnc.INTERP_IDLE:
sys.stderr.write("Finished: Detected program finish\n")
break
time.sleep(0.1)
if h["counter"] != 25:
sys.stderr.write("End counter incorrect: %d != 25\n" % h["counter"])
sys.exit(1)
sys.exit(0)

4
debian/tests/linuxcnc-test.hal vendored Normal file
View File

@@ -0,0 +1,4 @@
net Xpos => test-ui.Xpos
net Ypos => test-ui.Ypos
net Zpos => test-ui.Zpos
net counter <= motion.analog-out-00 => test-ui.counter

100
debian/tests/linuxcnc-test.ini vendored Normal file
View File

@@ -0,0 +1,100 @@
[EMC]
VERSION = 1.1
#DEBUG = 0xffffffff
DEBUG = 0x0
[DISPLAY]
DISPLAY = ./linuxcnc-test-ui.py
[TASK]
TASK = milltask
CYCLE_TIME = 0.001
[RS274NGC]
LOG_LEVEL = 999
[EMCMOT]
EMCMOT = motmod
COMM_TIMEOUT = 4.0
BASE_PERIOD = 0
SERVO_PERIOD = 1000000
[EMCIO]
TOOL_TABLE = simpockets.tbl
TOOL_CHANGE_QUILL_UP = 1
RANDOM_TOOLCHANGER = 0
[HAL]
HALFILE = LIB:core_sim.hal
[TRAJ]
NO_FORCE_HOMING = 1
AXES = 3
COORDINATES = X Y Z
HOME = 0 0 0
LINEAR_UNITS = inch
ANGULAR_UNITS = degree
DEFAULT_LINEAR_VELOCITY = 1200
MAX_LINEAR_VELOCITY = 4000
[KINS]
KINEMATICS = trivkins
JOINTS = 3
[AXIS_X]
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
MAX_VELOCITY = 4000
MAX_ACCELERATION = 10000.0
[JOINT_0]
TYPE = LINEAR
HOME = 0.000
MAX_VELOCITY = 4000
MAX_ACCELERATION = 10000.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 = 4000
MAX_ACCELERATION = 10000.0
[JOINT_1]
TYPE = LINEAR
HOME = 0.000
MAX_VELOCITY = 4000
MAX_ACCELERATION = 10000.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
MAX_LIMIT = 40
MAX_VELOCITY = 4000
MAX_ACCELERATION = 10000.0
[JOINT_2]
TYPE = LINEAR
HOME = 0.0
MAX_VELOCITY = 4000
MAX_ACCELERATION = 10000.0
BACKLASH = 0.000
INPUT_SCALE = 4000
OUTPUT_SCALE = 1.000
MIN_LIMIT = -40
MAX_LIMIT = 40
FERROR = 0.050
MIN_FERROR = 0.010

12
debian/tests/linuxcnc-test.ngc vendored Normal file
View File

@@ -0,0 +1,12 @@
#1 = 0
O100 repeat [6]
M67 E0 Q[#1]
(DEBUG, 1)
G1 F500 X[5 + #1]
(DEBUG, 2)
G1 F500 Y[5 + #1]
(DEBUG, 3)
G1 F500 X[10 + #1]
#1 = [#1 + 5]
O100 endrepeat
M2

24
debian/tests/rs274-test vendored Executable file
View File

@@ -0,0 +1,24 @@
#!/bin/sh
set -e
cd "$(dirname "$0")"
if [ -z "$AUTOPKGTEST_TMP" ]; then
AUTOPKGTEST_TMP="."
fi
log=$AUTOPKGTEST_TMP/rs274.out
if ! rs274 -g rs274.ngc > "$log" 2>&1 ; then
echo "error: failed to run rs274"
cat "$log"
exit 1
fi
if ! diff -u "$log" rs274.res ; then
echo "error: rs274 output do not match rs274.res"
exit 1
fi
echo "success: rs274 output matches rs274.res"
exit 0

5
debian/tests/rs274.ngc vendored Normal file
View File

@@ -0,0 +1,5 @@
%
(Test simple move)
G0 X0 Y0 Z0
G1 X1 Y1 Z1 F10
%

14
debian/tests/rs274.res vendored Normal file
View File

@@ -0,0 +1,14 @@
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..... COMMENT("Test simple move")
8 N..... STRAIGHT_TRAVERSE(0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000)
9 N..... SET_FEED_RATE(10.0000)
10 N..... STRAIGHT_FEED(1.0000, 1.0000, 1.0000, 0.0000, 0.0000, 0.0000)
11 N..... FINISH()
12 N..... ON_RESET()
13 N..... ON_RESET()