Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions configs/sim/gmoccapy/simulated_home.hal
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
loadrt or2 names=or2_0
loadrt comp names=comp_x,comp_y,comp_z

net Xhomeswpos => comp_x.in0
Expand All @@ -17,16 +16,10 @@ setp comp_x.hyst .02
setp comp_y.hyst .02
setp comp_z.hyst .02

net Xhomesw <= comp_x.out
net Xhomesw <= comp_x.out => joint.0.home-sw-in
net Yhomesw <= comp_y.out => joint.1.home-sw-in
net Zhomesw <= comp_z.out

net Xhomesw => or2_0.in0
net Zhomesw => or2_0.in1
net XZhomesw or2_0.out => joint.0.home-sw-in joint.2.home-sw-in
net Zhomesw <= comp_z.out => joint.2.home-sw-in

addf comp_x servo-thread
addf comp_y servo-thread
addf comp_z servo-thread

addf or2_0 servo-thread
2 changes: 1 addition & 1 deletion configs/sim/touchy/touchy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ SERVO_PERIOD = 1000000

HALFILE = core_sim.hal
# add a test panel so people can actually test the screen
HALCMD = loadusr gladevcp --always_above -c touchy_test touchy_test_panel.glade
HALCMD = loadusr -Wn touchy_test gladevcp --always_above -c touchy_test touchy_test_panel.glade
POSTGUI_HALFILE = touchy_postgui.hal

[TRAJ]
Expand Down
28 changes: 28 additions & 0 deletions lib/python/linuxcnc_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,34 @@ def wait_for_home(self, joints, timeout=10.0):
raise LinuxCNC_Exception("timeout waiting for homing to complete:\nstatus.homed:" + str(self.status.homed) + "\nstatus.position:" + str(self.status.position))


def home_joints(self, joints, timeout=10.0):
"""Arguments:

'joints' is a list of unhomed joint numbers.

'timeout' is a float, the number of seconds to wait for
each joint to home before giving up.

Homes the joints one after the other: motion refuses to home a
joint while another one is homing. A joint counts as done once
it is homed and no joint is homing any more; motion keeps the
homing flag set until it accepts the next home command.

Returns once all the joints are homed, raises
LinuxCNC_Exception if one did not home before the timeout."""

for joint in joints:
self.command.home(joint)
start_time = time.time()
while True:
self.status.poll()
if self.status.homed[joint] and not any(j["homing"] for j in self.status.joint):
break
if (time.time() - start_time) > timeout:
raise LinuxCNC_Exception("timeout waiting for joint %d to home:\nstatus.homed:" % joint + str(self.status.homed) + "\nstatus.position:" + str(self.status.position))
time.sleep(0.01)


def wait_for_axis_to_stop(self, axis_letter, timeout=10.0):
"""Arguments:
'axis_letter' is a single character from the set [xyzabcuvw]
Expand Down
4 changes: 3 additions & 1 deletion src/emc/task/taskintf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1704,7 +1704,9 @@ int emcTrajUpdate(EMC_TRAJ_STAT * stat)

if (emcmotStatus.motionFlag & EMCMOT_MOTION_ERROR_BIT) {
stat->status = RCS_STATUS::ERROR;
} else if (stat->inpos && (stat->queue == 0)) {
} else if (stat->inpos && (stat->queue == 0) && !emcmotStatus.probing) {
// a probe move that ends without contact is reported a servo
// cycle after the planner goes idle, so wait for the verdict
stat->status = RCS_STATUS::DONE;
} else {
stat->status = RCS_STATUS::EXEC;
Expand Down
5 changes: 1 addition & 4 deletions tests/abort/on_abort_command-crazy-move/test-ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@

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])
l.home_joints([0, 1, 2])

#
# Print status function
Expand Down
7 changes: 2 additions & 5 deletions tests/abort/stop-button-crazy-move/test-ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

# Time increment and timeout, seconds
TIME_INCR = 0.1
TIMEOUT = 10.0
TIMEOUT = 60.0

#
# connect to LinuxCNC
Expand All @@ -37,10 +37,7 @@

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])
l.home_joints([0, 1, 2])

#
# Print status function
Expand Down
12 changes: 12 additions & 0 deletions tests/hal-show/checkresult
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
set -e

TESTDIR=$(dirname "$1")
cd "${TESTDIR}"

# The owner column is the component ID, which depends on the order in which
# halcmd and rtapi_app take IDs during each loadrt. That order changes with
# CPU load, so mask it.
sed --in-place --regexp-extended --expression='s/^ *[0-9]+( +[a-z0-9]+ +(IN|OUT|I\/O) .*)$/(ignored comp id)\1/' result

diff -u expected result
24 changes: 12 additions & 12 deletions tests/hal-show/expected
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Component Pins:
Owner Type Dir Value Name
10 bool IN FALSE conv-bool-uint.0.in <== net-conv-bool-uint.0.in
16 real IN 0 conv-real-sint.0.in <== net-conv-real-sint.0.in
19 sint IN 0 conv-sint-real.0.in <== net-conv-sint-real.0.in
22 sint IN 0 conv-sint-uint.0.in <== net-conv-sint-uint.0.in
13 uint IN 0x0000000000000000 conv-uint-bool.0.in <== net-conv-uint-bool.0.in
25 uint IN 0x0000000000000000 conv-uint-sint.0.in <== net-conv-uint-sint.0.in
(ignored comp id) bool IN FALSE conv-bool-uint.0.in <== net-conv-bool-uint.0.in
(ignored comp id) real IN 0 conv-real-sint.0.in <== net-conv-real-sint.0.in
(ignored comp id) sint IN 0 conv-sint-real.0.in <== net-conv-sint-real.0.in
(ignored comp id) sint IN 0 conv-sint-uint.0.in <== net-conv-sint-uint.0.in
(ignored comp id) uint IN 0x0000000000000000 conv-uint-bool.0.in <== net-conv-uint-bool.0.in
(ignored comp id) uint IN 0x0000000000000000 conv-uint-sint.0.in <== net-conv-uint-sint.0.in

Signals:
Type Value Name (linked to)
Expand Down Expand Up @@ -36,12 +36,12 @@ sint 0 net-conv-uint-sint.0.out

Component Pins:
Owner Type Dir Value Name
10 bool IN TRUE conv-bool-uint.0.in <== net-conv-bool-uint.0.in
16 real IN 2.147484e+09 conv-real-sint.0.in <== net-conv-real-sint.0.in
19 sint IN -2147483648 conv-sint-real.0.in <== net-conv-sint-real.0.in
22 sint IN -9223372036854775808 conv-sint-uint.0.in <== net-conv-sint-uint.0.in
13 uint IN 0x00000000FFFFFFFF conv-uint-bool.0.in <== net-conv-uint-bool.0.in
25 uint IN 0xFFFFFFFFFFFFFFFF conv-uint-sint.0.in <== net-conv-uint-sint.0.in
(ignored comp id) bool IN TRUE conv-bool-uint.0.in <== net-conv-bool-uint.0.in
(ignored comp id) real IN 2.147484e+09 conv-real-sint.0.in <== net-conv-real-sint.0.in
(ignored comp id) sint IN -2147483648 conv-sint-real.0.in <== net-conv-sint-real.0.in
(ignored comp id) sint IN -9223372036854775808 conv-sint-uint.0.in <== net-conv-sint-uint.0.in
(ignored comp id) uint IN 0x00000000FFFFFFFF conv-uint-bool.0.in <== net-conv-uint-bool.0.in
(ignored comp id) uint IN 0xFFFFFFFFFFFFFFFF conv-uint-sint.0.in <== net-conv-uint-sint.0.in

Signals:
Type Value Name (linked to)
Expand Down
3 changes: 2 additions & 1 deletion tests/halmodule/stream/stream_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
assert reader.sampleno == i+1
assert reader.read() is None
assert reader.num_underruns == 1
# report before ready(): halrun ends the run once it sees ready
print("pass", flush=True)
c.ready()
print("pass")

try:
while 1: time.sleep(1)
Expand Down
7 changes: 2 additions & 5 deletions tests/interp/g28.2/immediate-mode-guard/test-ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"""

import linuxcnc
import linuxcnc_util
import hal

import sys
Expand Down Expand Up @@ -74,11 +75,7 @@ def drain_errors():
c.state(linuxcnc.STATE_ESTOP_RESET)
c.state(linuxcnc.STATE_ON)
c.mode(linuxcnc.MODE_MANUAL)
c.home(0)
c.home(1)
c.home(2)
if not wait_homed([1, 1, 1]):
fail("initial home-all did not home all joints: {}".format(list(s.homed[:3])))
linuxcnc_util.LinuxCNC(command=c, status=s, error=e).home_joints([0, 1, 2])

# Get into a coordinated (teleop) mode -- what a stray FREE dip would destroy.
c.teleop_enable(1)
Expand Down
17 changes: 2 additions & 15 deletions tests/interp/g28.2/invalid-pword/test-ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"""

import linuxcnc
import linuxcnc_util
import hal

import os
Expand Down Expand Up @@ -68,16 +69,6 @@ def wait_idle(timeout=10.0):
return False


def wait_homed(expected, timeout=10.0):
t0 = time.time()
while time.time() - t0 < timeout:
poll()
if list(s.homed[:3]) == expected:
return True
time.sleep(0.01)
return False


def drain_errors():
msgs = []
while True:
Expand All @@ -95,11 +86,7 @@ def mode_name(m):

c.state(linuxcnc.STATE_ESTOP_RESET)
c.state(linuxcnc.STATE_ON)
c.home(0)
c.home(1)
c.home(2)
if not wait_homed([1, 1, 1]):
fail("initial home-all did not home all joints: {}".format(list(s.homed[:3])))
linuxcnc_util.LinuxCNC(command=c, status=s, error=e).home_joints([0, 1, 2])

# Establish a coordinated mode worth preserving.
c.mode(linuxcnc.MODE_MDI)
Expand Down
16 changes: 2 additions & 14 deletions tests/interp/g28.2/position-model/test-ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"""

import linuxcnc
import linuxcnc_util
import hal

import sys
Expand All @@ -46,16 +47,6 @@ def wait_idle(timeout=10.0):
return False


def wait_homed(expected, timeout=10.0):
t0 = time.time()
while time.time() - t0 < timeout:
poll()
if list(s.homed[:len(expected)]) == expected:
return True
time.sleep(0.01)
return False


def fail(msg):
print("FAIL: " + msg)
sys.exit(1)
Expand All @@ -76,10 +67,7 @@ def mdi(cmd):

c.state(linuxcnc.STATE_ESTOP_RESET)
c.state(linuxcnc.STATE_ON)
for j in range(4):
c.home(j)
if not wait_homed([1, 1, 1, 1]):
fail("initial home-all did not home all joints: {}".format(list(s.homed[:4])))
linuxcnc_util.LinuxCNC(command=c, status=s).home_joints([0, 1, 2, 3])

c.mode(linuxcnc.MODE_MDI)
time.sleep(0.2)
Expand Down
17 changes: 2 additions & 15 deletions tests/interp/g28.2/sequencing/test-ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"""

import linuxcnc
import linuxcnc_util
import hal

import sys
Expand Down Expand Up @@ -53,16 +54,6 @@ def wait_x(expected, timeout=5.0):
return False


def wait_homed(expected, timeout=5.0):
t0 = time.time()
while time.time() - t0 < timeout:
poll()
if list(s.homed[:3]) == expected:
return True
time.sleep(0.01)
return False


def fail(msg):
print("FAIL: " + msg)
sys.exit(1)
Expand All @@ -74,11 +65,7 @@ def near(a, b, tol=0.001):

c.state(linuxcnc.STATE_ESTOP_RESET)
c.state(linuxcnc.STATE_ON)
c.home(0)
c.home(1)
c.home(2)
if not wait_homed([1, 1, 1]):
fail("initial home-all did not home all joints: {}".format(list(s.homed[:3])))
linuxcnc_util.LinuxCNC(command=c, status=s).home_joints([0, 1, 2])

c.mode(linuxcnc.MODE_MDI)
time.sleep(0.2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ SPINDLE_OFF
DISABLE
JOINT_UNHOME joint=-2
FREE
SET_TERM_COND termCond=2, tolerance=0.001
JOG_ABORT joint=0
JOG_ABORT joint=1
JOG_ABORT joint=2
Expand Down
16 changes: 16 additions & 0 deletions tests/interp/m98m99/12-M99-endless-main-program/test-ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,22 @@
e = linuxcnc.error_channel()


#
# Task queues the canon commands of interpreter init before it reads its
# first command. Let it issue them, or an early ESTOP_RESET wipes them
# and the log depends on how fast this script starts.
#

deadline = time.monotonic() + 60
while True:
s.poll()
if s.state == linuxcnc.RCS_DONE: break
if time.monotonic() > deadline:
print("task did not finish startup")
sys.exit(1)
time.sleep(0.01)


#
# Come out of E-stop, turn the machine on, home, and switch to Auto mode.
#
Expand Down
6 changes: 1 addition & 5 deletions tests/interp/mdi-oword-m66/test-ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@

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])
l.home_joints([0, 1, 2])

c.mode(linuxcnc.MODE_MDI)

Expand Down
5 changes: 1 addition & 4 deletions tests/interp/subroutine-return/test-ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@

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])
l.home_joints([0, 1, 2])

c.mode(linuxcnc.MODE_AUTO)

Expand Down
5 changes: 2 additions & 3 deletions tests/maxkins/test-ui.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3

import linuxcnc
import linuxcnc_util
import hal

import time
Expand Down Expand Up @@ -49,9 +50,7 @@ def wait_for_linuxcnc_startup(status, timeout=10.0):
# HOME_ABSOLUTE_ENCODER = 1 is used in the ini file.
c.state(linuxcnc.STATE_ESTOP_RESET)
c.state(linuxcnc.STATE_ON)
for joint in range(9):
c.home(joint)
c.wait_complete()
linuxcnc_util.LinuxCNC(command=c, status=s, error=e).home_joints(range(9))

LETTERS = 'XYZABCUVW'

Expand Down
1 change: 1 addition & 0 deletions tests/motion-logger/basic/expected.builtin-startup.in
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ SPINDLE_OFF
DISABLE
JOINT_UNHOME joint=-2
FREE
SET_TERM_COND termCond=2, tolerance=0.001
JOG_ABORT joint=0
JOG_ABORT joint=1
JOG_ABORT joint=2
Expand Down
Loading
Loading