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 @@
subs/test1.ngc
sim.var.bak

View File

@@ -0,0 +1 @@
Test for https://github.com/LinuxCNC/linuxcnc/issues/455

View File

@@ -0,0 +1,12 @@
#!/bin/bash -e
TEST_DIR=$(dirname "$1")
cd "$TEST_DIR"
# Avoid false negatives: This string should be present
grep -q 'test RAN' result
# Test: This string should be absent
if grep -q 'duplicate O-word label' result; then
exit 1
fi

View File

@@ -0,0 +1,4 @@
#!/bin/bash
sed -i subs/test1.ngc \
-e '/HERE/ a ;'

View File

@@ -0,0 +1,104 @@
[EMC]
#DEBUG = 0xffffffff
VERSION = 1.1
[DISPLAY]
DISPLAY = ./test-ui.py
[TASK]
TASK = milltask
CYCLE_TIME = 0.001
MDI_QUEUED_COMMANDS=10000
[RS274NGC]
PARAMETER_FILE = sim.var
SUBROUTINE_PATH = ./subs
LOG_LEVEL = 999
[EMCMOT]
EMCMOT = motmod
COMM_TIMEOUT = 4.0
BASE_PERIOD = 0
SERVO_PERIOD = 1000000
[HAL]
HALUI = halui
HALFILE = LIB:core_sim.hal
POSTGUI_HALFILE = postgui.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 = 1.2
MAX_LINEAR_VELOCITY = 4
[KINS]
JOINTS = 3
KINEMATICS = trivkins
[AXIS_X]
MAX_VELOCITY = 4
MAX_ACCELERATION = 1000.0
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
[AXIS_Y]
MAX_VELOCITY = 4
MAX_ACCELERATION = 1000.0
MIN_LIMIT = -40.0
MAX_LIMIT = 40.0
[AXIS_Z]
MAX_VELOCITY = 4
MAX_ACCELERATION = 1000.0
MIN_LIMIT = -4.0
MAX_LIMIT = 4.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
[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
[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 = -4.0
MAX_LIMIT = 4.0
FERROR = 0.050
MIN_FERROR = 0.010
[EMCIO]
TOOL_CHANGE_QUILL_UP = 1
RANDOM_TOOLCHANGER = 0
TOOL_TABLE = simpockets.tbl

View File

@@ -0,0 +1,3 @@
T1 P1 D0.125000 Z+1.000000 ;
T10 P3 D0.500000 Z+3.000000 ;
T99999 P50 Z+2.000000 ;

View File

@@ -0,0 +1,12 @@
o<test1> sub
; add extra space HERE
o100 if [ #1 GT 5]
(print, true)
o100 else
(print, false)
o100 endif
(print, test RAN)
o<test1> endsub
M2

View File

@@ -0,0 +1,88 @@
#!/usr/bin/env python3
import linuxcnc
import hal
import time
import sys
import os
from shutil import copyfile
def wait_for_linuxcnc_startup(status, timeout=10.0):
"""Poll the Status buffer waiting for it to look initialized,
rather than just allocated (all-zero). Returns on success, throws
RuntimeError on failure."""
start_time = time.time()
while time.time() - start_time < timeout:
status.poll()
if (status.angular_units == 0.0) \
or (status.axis_mask == 0) \
or (status.cycle_time == 0.0) \
or (status.exec_state != linuxcnc.EXEC_DONE) \
or (status.interp_state != linuxcnc.INTERP_IDLE) \
or (status.inpos == False) \
or (status.linear_units == 0.0) \
or (status.max_acceleration == 0.0) \
or (status.max_velocity == 0.0) \
or (status.program_units == 0.0) \
or (status.rapidrate == 0.0) \
or (status.state != linuxcnc.RCS_DONE) \
or (status.task_state != linuxcnc.STATE_ESTOP):
time.sleep(0.1)
else:
# looks good
return
# timeout, throw an exception
raise RuntimeError
#
# set up pins
# shell out to halcmd to net our pins to where they need to go
#
h = hal.component("python-ui")
h.ready()
#
# connect to LinuxCNC
#
c = linuxcnc.command()
s = linuxcnc.stat()
e = linuxcnc.error_channel()
# Wait for LinuxCNC to initialize itself so the Status buffer stabilizes.
wait_for_linuxcnc_startup(s)
c.state(linuxcnc.STATE_ESTOP_RESET)
c.state(linuxcnc.STATE_ON)
c.home(-1)
c.wait_complete()
# Get into MDI mode
c.mode(linuxcnc.MODE_MDI)
# Copy the original sub into place and call it
copyfile('subs/test1-orig.ngc', 'subs/test1.ngc')
c.mdi('o<test1> call [20]')
c.wait_complete()
# Pretend the file was edited: copy new sub with spacing changes and
# call it
os.system('./edit.sh')
c.mdi('o<test1> call [20]')
c.wait_complete()
# Run again
c.mdi('o<test1> call [20]')
c.wait_complete()
sys.exit(0)

View File

@@ -0,0 +1,3 @@
#!/bin/bash
exec linuxcnc -r interp.ini