Skip to content

Commit 521c01d

Browse files
Re-enable tests/motion-logger/startup-gcode-abort and make it more robust
Instead of using 'sleep(1)' to guess if linuxcnc is ready to take instructions from the UI, look for the 'motion.in-position' pin to show up in hal and abort just after this. This make sure the abort happen earlier in the startup process, and hopefully ensure that the test succeed every time.
1 parent 9b5e2a6 commit 521c01d

3 files changed

Lines changed: 17 additions & 20 deletions

File tree

tests/motion-logger/startup-gcode-abort/expected.motion-logger.in

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ SET_AXIS_VEL_LIMIT axis=2 vel=4
7676
SET_AXIS_ACC_LIMIT axis=2, acc=1000
7777
SET_AXIS_LOCKING_JOINT axis=2, locking_joint=-1
7878

79+
SET_SPINDLE_PARAMS, 1.00e+99, 0.00e+00, -1.00e+99, 0.00e+00
7980
JOG_ABORT joint=0
8081
JOG_ABORT joint=1
8182
JOG_ABORT joint=2
@@ -108,23 +109,8 @@ JOINT_UNHOME joint=-2
108109
FREE
109110

110111
#
111-
# Now Task is done with its internal immediate startup and starts
112-
# draining the interp_list.
113-
#
114-
# emctask_start() called emcTaskPlanInit(), which initialized the
115-
# Interpreter, enqueueing Canon commands on interp_list.
116-
#
117-
118-
SET_TERM_COND termCond=2, tolerance=0
119-
120-
# This is the [RS274NGC]RS274NGC_STARTUP_CODE, up to but not going past
121-
# the very long dwell
122-
123-
SET_LINE x=-1, y=-2, z=-3, a=0, b=0, c=0, u=0, v=0, w=0, id=2, motion_type=1, vel=4.98888, ini_maxvel=4.98888, acc=1247.22, turn=-1
124-
125-
#
126-
# Task has fully booted! It's now in Estop, in Manual, and ready to
127-
# receive commands from the UIs.
112+
# Task is now got the 'motion.in-position' pin visible, and is
113+
# accepting abort calls from the UI.
128114
#
129115

130116
#

tests/motion-logger/startup-gcode-abort/skip

Whitespace-only changes.

tests/motion-logger/startup-gcode-abort/test-ui.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,33 @@
33
import linuxcnc
44
import sys
55
import time
6-
6+
import hal
77

88
#
99
# connect to LinuxCNC
1010
#
1111

12+
comp = hal.component('hal-watcher')
13+
1214
c = linuxcnc.command()
1315
s = linuxcnc.stat()
1416
e = linuxcnc.error_channel()
1517

1618

1719
#
18-
# Immediately abort! Github Issue #49
20+
# Immediately abort once linuxcnc is ready! Github Issue #49
1921
#
2022

21-
time.sleep(1)
23+
24+
# Wait for (any) HAL pin to show up when LinuxCNC is initialized
25+
waitlimit = 300
26+
while 0 < waitlimit:
27+
try:
28+
waiting = 'TRUE' != hal.get_value('motion.in-position')
29+
except RuntimeError:
30+
break
31+
time.sleep(0.1)
32+
waitlimit -= 1
2233

2334
print("UI abort")
2435
sys.stdout.flush()

0 commit comments

Comments
 (0)