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,10 @@
#!/bin/sh
result=$1
if grep -qi error: "$result" ; then
echo "found string 'error' in $result"
exit 1
fi
exit 0

View File

@@ -0,0 +1,66 @@
#!/usr/bin/env python3
import os
import sys
import time
import linuxcnc
import linuxcnc_util
import hal
def wait_for_hal_pin(name, value, timeout=10):
start_time = time.time()
while (time.time() - start_time) < timeout:
if hal.get_value(name) == value:
return
time.sleep(0.1)
raise RuntimeError("error: hal pin %s didn't get to %s after %.3f seconds" % (name, value, timeout))
# unbuffer stdout
sys.stdout = os.fdopen(sys.stdout.fileno(), 'w')
retval = 0
h = hal.component("python-ui")
h.newpin("ext-estop-button", hal.HAL_BIT, hal.HAL_OUT)
h.ready() # mark the component as 'ready'
hal.connect('python-ui.ext-estop-button', 'ext-estop')
c = linuxcnc.command()
s = linuxcnc.stat()
e = linuxcnc.error_channel()
l = linuxcnc_util.LinuxCNC(command=c, status=s, error=e)
c.state(linuxcnc.STATE_ESTOP_RESET)
c.state(linuxcnc.STATE_ON)
c.wait_complete()
if False == hal.get_value('estop-all-ok'):
print("error: estop not OK before ext-estop-button is touched")
retval = 1
h['ext-estop-button'] = 1
# Give HAL and classicladder time to react
try:
wait_for_hal_pin('estop-all-ok', False)
except RuntimeError as e:
print("error: estop still OK after ext-estop-button is set")
retval = 1
h['ext-estop-button'] = 0
c.state(linuxcnc.STATE_ESTOP_RESET)
# Give HAL and classicladder time to react
try:
wait_for_hal_pin('estop-all-ok', True)
except RuntimeError as e:
print("error: estop not OK aftet ext-estop-button is unset")
retval = 1
print("exiting linuxcnc")
sys.exit(retval)

View File

@@ -0,0 +1,238 @@
_FILES_CLASSICLADDER
_FILE-symbols.csv
#VER=1.0
%I0,GUI-E,
%I1,EXT-E,
%I2,E-RESET,
%I3,I3,
%I4,I4,
%I5,I5,
%I6,I6,
%I7,I7,
%I8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ter
%C2,%C2,Counter
%C3,%C3,Counter
%C4,%C4,Counter
%C5,%C5,Counter
%C6,%C6,Counter
%C7,%C7,Counter
%C8,%C8,Counter
%C9,%C9,Counter
%E0,%E0,Error Flag Bit
%E1,%E1,Error Flag Bit
%E2,%E2,Error Flag Bit
%E3,%E3,Error Flag Bit
%E4,%E4,Error Flag Bit
%E5,%E5,Error Flag Bit
%E6,%E6,Error Flag Bit
%E7,%E7,Error Flag Bit
%E8,%E8,Error Flag Bit
%E9,%E9,Error Flag Bit
_/FILE-symbols.csv
_FILE-modbusioconf.csv
#VER=1.0
_/FILE-modbusioconf.csv
_FILE-ioconf.csv
#VER=1.0
_/FILE-ioconf.csv
_FILE-sequential.csv
#VER=1.0
_/FILE-sequential.csv
_FILE-sections.csv
#VER=1.0
#NAME000=Prog1
000,0,-1,1,1,0
_/FILE-sections.csv
_FILE-rung_1.csv
#VER=2.0
#LABEL=Rung 1
#COMMENT=Stepper Estop Chain
#PREVRUNG=0
#NEXTRUNG=-1
0-0-50/0 , 1-0-50/0 , 9-0-50/0 , 9-0-50/1 , 9-0-0/0 , 9-0-0/0 , 9-0-60/0 , 9-0-0/0 , 9-0-0/0 , 50-0-60/0
0-0-0/0 , 2-0-50/1 , 9-0-0/0 , 9-0-0/0 , 9-0-0/0 , 9-0-0/0 , 9-0-50/2 , 9-0-0/0 , 9-0-0/0 , 0-1-60/1
0-0-50/0 , 1-0-50/0 , 2-0-50/1 , 9-0-0/0 , 9-0-0/0 , 9-0-0/0 , 9-0-0/0 , 9-0-0/1 , 9-0-0/0 , 0-1-60/1
9-0-0/0 , 1-0-50/0 , 2-0-50/1 , 1-0-60/0 , 9-0-0/0 , 9-0-0/0 , 9-0-0/0 , 9-0-0/0 , 9-0-0/0 , 0-1-0/0
0-0-60/1 , 0-0-0/0 , 0-0-0/0 , 1-1-50/2 , 0-1-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-60/6
0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0
_/FILE-rung_1.csv
_FILE-rung_0.csv
#VER=2.0
#LABEL=
#COMMENT=
#PREVRUNG=0
#NEXTRUNG=1
0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0
0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0
0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0
0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0
0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0
0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0 , 0-0-0/0
_/FILE-rung_0.csv
_FILE-arithmetic_expressions.csv
#VER=2.0
_/FILE-arithmetic_expressions.csv
_FILE-timers_iec.csv
1,0,0
1,0,0
1,0,0
1,0,0
1,0,0
1,0,0
1,0,0
1,0,0
1,0,0
1,0,0
_/FILE-timers_iec.csv
_FILE-counters.csv
0
0
0
0
0
0
0
0
0
0
_/FILE-counters.csv
_FILE-monostables.csv
1,10
1,20
_/FILE-monostables.csv
_FILE-timers.csv
1,10
1,20
0,20
2,1
2,5
_/FILE-timers.csv
_FILE-com_params.txt
MODBUS_MASTER_SERIAL_PORT=
MODBUS_MASTER_SERIAL_SPEED=9600
MODBUS_MASTER_SERIAL_DATABITS=8
MODBUS_MASTER_SERIAL_STOPBITS=1
MODBUS_MASTER_SERIAL_PARITY=0
MODBUS_ELEMENT_OFFSET=0
MODBUS_MASTER_SERIAL_USE_RTS_TO_SEND=0
MODBUS_MASTER_TIME_INTER_FRAME=100
MODBUS_MASTER_TIME_OUT_RECEIPT=500
MODBUS_MASTER_TIME_AFTER_TRANSMIT=0
MODBUS_DEBUG_LEVEL=0
MODBUS_MAP_COIL_READ=0
MODBUS_MAP_COIL_WRITE=0
MODBUS_MAP_INPUT=0
MODBUS_MAP_HOLDING=0
MODBUS_MAP_REGISTER_READ=0
MODBUS_MAP_REGISTER_WRITE=0
_/FILE-com_params.txt
_FILE-general.txt
PERIODIC_REFRESH=1
SIZE_NBR_RUNGS=12
SIZE_NBR_BITS=20
SIZE_NBR_WORDS=4
SIZE_NBR_TIMERS=5
SIZE_NBR_MONOSTABLES=2
SIZE_NBR_COUNTERS=10
SIZE_NBR_TIMERS_IEC=10
SIZE_NBR_PHYS_INPUTS=10
SIZE_NBR_PHYS_OUTPUTS=10
SIZE_NBR_ARITHM_EXPR=4
SIZE_NBR_SECTIONS=4
SIZE_NBR_SYMBOLS=121
_/FILE-general.txt
_/FILES_CLASSICLADDER

View File

@@ -0,0 +1,35 @@
# HAL config file for using classic ladder
# The core_sim.hal file sets up motion, stepgen and other common items
# Remove core_sim.hal connections for the following pins and implement
# using classic latter functionality instead:
unlinkp iocontrol.0.user-enable-out
unlinkp iocontrol.0.emc-enable-in
# This file adds:
# the possibility of an external momentary or sustained NC estop button
# (load the realtime portion)
# these classicladder parameters need to be optimized after ladder completion
loadrt classicladder_rt numRungs=12 numBits=20 numWords=4 numTimers=5 numMonostables=2 numPhysInputs=10 numPhysOutputs=10 numArithmExpr=4 numSections=4
# We kick ladder into a thread at the slower servo rate rather than base rate
addf classicladder.0.refresh servo-thread 1
# invoke the user part of CL to silently load the program
# later we will need to add the clp file mentioned below
# to the ini file so that we do not need to hardcode it here.
loadusr -w classicladder --nogui classicladder-estop.clp
# three axis motion allows 6 other outputs on pins 8,9,1,14,16,17
# five additional input pins are available 10,11,12,13,15
# these are setup by the work they perform below
# estop signals
# signal is the internal or gui estop command from EMC
net gui-estop iocontrol.0.user-enable-out classicladder.0.in-00
# one-shot on timer when signal above goes high.
net estop-strobe iocontrol.0.user-request-enable classicladder.0.in-02
# this bit is an external estop button connected to parport pin 11 and ground
net ext-estop classicladder.0.in-01
# This bit signal is command to estop from CL to EMC
net estop-all-ok iocontrol.0.emc-enable-in classicladder.0.out-00

View File

@@ -0,0 +1,35 @@
[EMC]
VERSION = 1.1
MACHINE = LinuxCNC-test-classicladder-estop
# Debug level, 0 means no messages. See src/emc/nml_int/emcglb.h for others
DEBUG = 0
[DISPLAY]
DISPLAY = ./classicladder-estop-ui.py
CYCLE_TIME = 0.200
POSITION_OFFSET = RELATIVE
POSITION_FEEDBACK = ACTUAL
[EMCMOT]
EMCMOT = motmod
COMM_TIMEOUT = 1.0
BASE_PERIOD = 50000
SERVO_PERIOD = 1000000
[TASK]
TASK = milltask
CYCLE_TIME = 0.010
[HAL]
HALFILE = core_sim.hal
HALFILE = classicladder-estop.hal
HALFILE = simulated_home.hal
[TRAJ]
COORDINATES = X Y Z
LINEAR_UNITS = mm
ANGULAR_UNITS = degree
[KINS]
KINEMATICS = trivkins
JOINTS = 3

View File

View File

@@ -0,0 +1,10 @@
#!/bin/sh
#
# Test setup based on configs/sim/axis/classicladder/
#
# Disable eatmydata, as it do not seem to work with classicladder
if [ "libeatmydata.so" = "$LD_PRELOAD" ] ; then
unset LD_PRELOAD
fi
exec linuxcnc "$(dirname "$0")/classicladder-estop.ini"